diff options
818 files changed, 21811 insertions, 20618 deletions
diff --git a/contrib/array/array_iterator.h b/contrib/array/array_iterator.h index 68da385c9a..7889fdc0b2 100644 --- a/contrib/array/array_iterator.h +++ b/contrib/array/array_iterator.h @@ -34,7 +34,6 @@ int32 array_all_int4le(ArrayType *array, int4 value); int32 array_oideq(ArrayType *array, Oid value); int32 array_all_oidne(ArrayType *array, Oid value); - #endif /* diff --git a/contrib/btree_gist/btree_gist.c b/contrib/btree_gist/btree_gist.c index 999d199ff2..4235c0a5d9 100644 --- a/contrib/btree_gist/btree_gist.c +++ b/contrib/btree_gist/btree_gist.c @@ -8,43 +8,46 @@ #include "utils/geo_decls.h" #include "utils/elog.h" -typedef int (*CMPFUNC)(const void *a, const void *b); -typedef void (*BINARY_UNION)(Datum*, char*); +typedef int (*CMPFUNC) (const void *a, const void *b); +typedef void (*BINARY_UNION) (Datum *, char *); -typedef struct intkey { - int4 lower; - int4 upper; -} INT4KEY; +typedef struct intkey +{ + int4 lower; + int4 upper; +} INT4KEY; -typedef struct tskey { - Timestamp lower; - Timestamp upper; -} TSKEY; +typedef struct tskey +{ + Timestamp lower; + Timestamp upper; +} TSKEY; /* used for sorting */ -typedef struct rix { - int index; - char *r; -} RIX; +typedef struct rix +{ + int index; + char *r; +} RIX; /* ** int4key in/out */ PG_FUNCTION_INFO_V1(int4key_in); PG_FUNCTION_INFO_V1(int4key_out); -Datum int4key_in(PG_FUNCTION_ARGS); -Datum int4key_out(PG_FUNCTION_ARGS); +Datum int4key_in(PG_FUNCTION_ARGS); +Datum int4key_out(PG_FUNCTION_ARGS); /* ** tskey in/out */ PG_FUNCTION_INFO_V1(tskey_in); PG_FUNCTION_INFO_V1(tskey_out); -Datum tskey_in(PG_FUNCTION_ARGS); -Datum tskey_out(PG_FUNCTION_ARGS); +Datum tskey_in(PG_FUNCTION_ARGS); +Datum tskey_out(PG_FUNCTION_ARGS); /* -** int4 ops +** int4 ops */ PG_FUNCTION_INFO_V1(gint4_compress); PG_FUNCTION_INFO_V1(gint4_union); @@ -53,15 +56,15 @@ PG_FUNCTION_INFO_V1(gint4_consistent); PG_FUNCTION_INFO_V1(gint4_penalty); PG_FUNCTION_INFO_V1(gint4_same); -Datum gint4_compress(PG_FUNCTION_ARGS); -Datum gint4_union(PG_FUNCTION_ARGS); -Datum gint4_picksplit(PG_FUNCTION_ARGS); -Datum gint4_consistent(PG_FUNCTION_ARGS); -Datum gint4_penalty(PG_FUNCTION_ARGS); -Datum gint4_same(PG_FUNCTION_ARGS); +Datum gint4_compress(PG_FUNCTION_ARGS); +Datum gint4_union(PG_FUNCTION_ARGS); +Datum gint4_picksplit(PG_FUNCTION_ARGS); +Datum gint4_consistent(PG_FUNCTION_ARGS); +Datum gint4_penalty(PG_FUNCTION_ARGS); +Datum gint4_same(PG_FUNCTION_ARGS); static void gint4_binary_union(Datum *r1, char *r2); -static int int4key_cmp(const void *a, const void *b); +static int int4key_cmp(const void *a, const void *b); /* ** timestamp ops @@ -73,51 +76,51 @@ PG_FUNCTION_INFO_V1(gts_consistent); PG_FUNCTION_INFO_V1(gts_penalty); PG_FUNCTION_INFO_V1(gts_same); -Datum gts_compress(PG_FUNCTION_ARGS); -Datum gts_union(PG_FUNCTION_ARGS); -Datum gts_picksplit(PG_FUNCTION_ARGS); -Datum gts_consistent(PG_FUNCTION_ARGS); -Datum gts_penalty(PG_FUNCTION_ARGS); -Datum gts_same(PG_FUNCTION_ARGS); +Datum gts_compress(PG_FUNCTION_ARGS); +Datum gts_union(PG_FUNCTION_ARGS); +Datum gts_picksplit(PG_FUNCTION_ARGS); +Datum gts_consistent(PG_FUNCTION_ARGS); +Datum gts_penalty(PG_FUNCTION_ARGS); +Datum gts_same(PG_FUNCTION_ARGS); static void gts_binary_union(Datum *r1, char *r2); -static int tskey_cmp(const void *a, const void *b); +static int tskey_cmp(const void *a, const void *b); /* define for comparison */ #define TSGE( ts1, ts2 ) (DatumGetBool(DirectFunctionCall2( \ - timestamp_ge, \ - PointerGetDatum( ts1 ), \ - PointerGetDatum( ts2 ) \ + timestamp_ge, \ + PointerGetDatum( ts1 ), \ + PointerGetDatum( ts2 ) \ ))) #define TSGT( ts1, ts2 ) (DatumGetBool(DirectFunctionCall2( \ - timestamp_gt, \ - PointerGetDatum( ts1 ), \ - PointerGetDatum( ts2 ) \ + timestamp_gt, \ + PointerGetDatum( ts1 ), \ + PointerGetDatum( ts2 ) \ ))) #define TSEQ( ts1, ts2 ) (DatumGetBool(DirectFunctionCall2( \ - timestamp_eq, \ - PointerGetDatum( ts1 ), \ - PointerGetDatum( ts2 ) \ + timestamp_eq, \ + PointerGetDatum( ts1 ), \ + PointerGetDatum( ts2 ) \ ))) #define TSLT( ts1, ts2 ) (DatumGetBool(DirectFunctionCall2( \ - timestamp_lt, \ - PointerGetDatum( ts1 ), \ - PointerGetDatum( ts2 ) \ + timestamp_lt, \ + PointerGetDatum( ts1 ), \ + PointerGetDatum( ts2 ) \ ))) #define TSLE( ts1, ts2 ) (DatumGetBool(DirectFunctionCall2( \ - timestamp_le, \ - PointerGetDatum( ts1 ), \ - PointerGetDatum( ts2 ) \ + timestamp_le, \ + PointerGetDatum( ts1 ), \ + PointerGetDatum( ts2 ) \ ))) /* ** Common btree-function (for all ops) */ -static GIST_SPLITVEC * btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v, - BINARY_UNION bu, CMPFUNC cmp); +static GIST_SPLITVEC *btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v, + BINARY_UNION bu, CMPFUNC cmp); PG_FUNCTION_INFO_V1(btree_decompress); -Datum btree_decompress(PG_FUNCTION_ARGS); +Datum btree_decompress(PG_FUNCTION_ARGS); /************************************************** * int4 ops @@ -126,334 +129,364 @@ Datum btree_decompress(PG_FUNCTION_ARGS); Datum gint4_compress(PG_FUNCTION_ARGS) { - GISTENTRY *entry=(GISTENTRY*)PG_GETARG_POINTER(0); - GISTENTRY *retval; + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + GISTENTRY *retval; + + if (entry->leafkey) + { + INT4KEY *r = palloc(sizeof(INT4KEY)); - if ( entry->leafkey) { - INT4KEY *r = palloc(sizeof(INT4KEY)); retval = palloc(sizeof(GISTENTRY)); r->lower = r->upper = (entry->key); - + gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page, - entry->offset, sizeof(INT4KEY),FALSE); + entry->offset, sizeof(INT4KEY), FALSE); - } else { - retval = entry; } - PG_RETURN_POINTER( retval ); + else + retval = entry; + PG_RETURN_POINTER(retval); } -Datum +Datum gint4_consistent(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); - int4 query = PG_GETARG_INT32(1); - INT4KEY *kkk= (INT4KEY *)DatumGetPointer(entry->key); - StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); - bool retval; - - switch(strategy) { - case BTLessEqualStrategyNumber: - retval = ( query >= kkk->lower ); - break; - case BTLessStrategyNumber: - if (GIST_LEAF(entry)) - retval = ( query > kkk->lower ); - else - retval = ( query >= kkk->lower ); - break; - case BTEqualStrategyNumber: - /* in leaf page kkk->lower always = kkk->upper */ - if (GIST_LEAF(entry)) - retval = ( query == kkk->lower ); - else - retval = ( kkk->lower <= query && query <= kkk->upper ); - break; - case BTGreaterStrategyNumber: - if (GIST_LEAF(entry)) - retval = ( query < kkk->upper ); - else - retval = ( query <= kkk->upper ); - break; - case BTGreaterEqualStrategyNumber: - retval = ( query <= kkk->upper ); - break; - default: - retval = FALSE; - } - PG_RETURN_BOOL(retval); + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + int4 query = PG_GETARG_INT32(1); + INT4KEY *kkk = (INT4KEY *) DatumGetPointer(entry->key); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + bool retval; + + switch (strategy) + { + case BTLessEqualStrategyNumber: + retval = (query >= kkk->lower); + break; + case BTLessStrategyNumber: + if (GIST_LEAF(entry)) + retval = (query > kkk->lower); + else + retval = (query >= kkk->lower); + break; + case BTEqualStrategyNumber: + /* in leaf page kkk->lower always = kkk->upper */ + if (GIST_LEAF(entry)) + retval = (query == kkk->lower); + else + retval = (kkk->lower <= query && query <= kkk->upper); + break; + case BTGreaterStrategyNumber: + if (GIST_LEAF(entry)) + retval = (query < kkk->upper); + else + retval = (query <= kkk->upper); + break; + case BTGreaterEqualStrategyNumber: + retval = (query <= kkk->upper); + break; + default: + retval = FALSE; + } + PG_RETURN_BOOL(retval); } Datum gint4_union(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea*) PG_GETARG_POINTER(0); - int i, numranges; - INT4KEY *cur, *out=palloc(sizeof(INT4KEY)); - - numranges = (VARSIZE(entryvec) - VARHDRSZ)/sizeof(GISTENTRY); - *(int*) PG_GETARG_POINTER(1) = sizeof(INT4KEY); - - cur = (INT4KEY *)DatumGetPointer( (((GISTENTRY *)(VARDATA(entryvec)))[0].key) ); - out->lower = cur->lower; - out->upper = cur->upper; - - for (i = 1; i < numranges; i++) { - cur = (INT4KEY *)DatumGetPointer( (((GISTENTRY *)(VARDATA(entryvec)))[i].key) ); - if ( out->lower > cur->lower ) out->lower = cur->lower; - if ( out->upper < cur->upper ) out->upper = cur->upper; - } + bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + int i, + numranges; + INT4KEY *cur, + *out = palloc(sizeof(INT4KEY)); + + numranges = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); + *(int *) PG_GETARG_POINTER(1) = sizeof(INT4KEY); + + cur = (INT4KEY *) DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[0].key)); + out->lower = cur->lower; + out->upper = cur->upper; + + for (i = 1; i < numranges; i++) + { + cur = (INT4KEY *) DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)); + if (out->lower > cur->lower) + out->lower = cur->lower; + if (out->upper < cur->upper) + out->upper = cur->upper; + } - PG_RETURN_POINTER( out ); + PG_RETURN_POINTER(out); } Datum gint4_penalty(PG_FUNCTION_ARGS) { - INT4KEY *origentry = (INT4KEY*) DatumGetPointer( ((GISTENTRY*) PG_GETARG_POINTER(0))->key ); - INT4KEY *newentry = (INT4KEY*) DatumGetPointer( ((GISTENTRY*) PG_GETARG_POINTER(1))->key ); - float *result = (float*) PG_GETARG_POINTER(2); - - *result = Max( newentry->upper - origentry->upper, 0 ) + - Max( origentry->lower - newentry->lower, 0 ); - - PG_RETURN_POINTER( result ); + INT4KEY *origentry = (INT4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); + INT4KEY *newentry = (INT4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); + + *result = Max(newentry->upper - origentry->upper, 0) + + Max(origentry->lower - newentry->lower, 0); + + PG_RETURN_POINTER(result); } Datum gint4_picksplit(PG_FUNCTION_ARGS) { - PG_RETURN_POINTER( btree_picksplit( - (bytea*)PG_GETARG_POINTER(0), - (GIST_SPLITVEC*)PG_GETARG_POINTER(1), - gint4_binary_union, - int4key_cmp - ) ); + PG_RETURN_POINTER(btree_picksplit( + (bytea *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + gint4_binary_union, + int4key_cmp + )); } Datum gint4_same(PG_FUNCTION_ARGS) { - INT4KEY *b1 = (INT4KEY*) PG_GETARG_POINTER(0); - INT4KEY *b2 = (INT4KEY*) PG_GETARG_POINTER(1); - bool *result = (bool*) PG_GETARG_POINTER(2); + INT4KEY *b1 = (INT4KEY *) PG_GETARG_POINTER(0); + INT4KEY *b2 = (INT4KEY *) PG_GETARG_POINTER(1); + bool *result = (bool *) PG_GETARG_POINTER(2); - *result = ( b1->lower == b2->lower && b1->upper == b2->upper ) ? TRUE : FALSE; - PG_RETURN_POINTER(result); + *result = (b1->lower == b2->lower && b1->upper == b2->upper) ? TRUE : FALSE; + PG_RETURN_POINTER(result); } -static void +static void gint4_binary_union(Datum *r1, char *r2) { - INT4KEY *b1; - INT4KEY *b2 = (INT4KEY*) r2; - if ( ! DatumGetPointer( *r1 ) ) { - *r1 = PointerGetDatum( palloc( sizeof(INT4KEY) ) ); - b1 = (INT4KEY*)DatumGetPointer( *r1 ); - b1->upper = b2->upper; - b1->lower = b2->lower; - } else { - b1 = (INT4KEY*)DatumGetPointer( *r1 ); - - b1->lower = ( b1->lower > b2->lower ) ? - b2->lower : b1->lower; - b1->upper = ( b1->upper > b2->upper ) ? - b1->upper : b2->upper; - } + INT4KEY *b1; + INT4KEY *b2 = (INT4KEY *) r2; + + if (!DatumGetPointer(*r1)) + { + *r1 = PointerGetDatum(palloc(sizeof(INT4KEY))); + b1 = (INT4KEY *) DatumGetPointer(*r1); + b1->upper = b2->upper; + b1->lower = b2->lower; + } + else + { + b1 = (INT4KEY *) DatumGetPointer(*r1); + + b1->lower = (b1->lower > b2->lower) ? + b2->lower : b1->lower; + b1->upper = (b1->upper > b2->upper) ? + b1->upper : b2->upper; + } } -static int -int4key_cmp(const void *a, const void *b) { - return ( ((INT4KEY*)(((RIX*)a)->r))->lower - ((INT4KEY*)(((RIX*)b)->r))->lower ); +static int +int4key_cmp(const void *a, const void *b) +{ + return (((INT4KEY *) (((RIX *) a)->r))->lower - ((INT4KEY *) (((RIX *) b)->r))->lower); } /************************************************** * timestamp ops - **************************************************/ + **************************************************/ Datum gts_compress(PG_FUNCTION_ARGS) { - GISTENTRY *entry=(GISTENTRY*)PG_GETARG_POINTER(0); - GISTENTRY *retval; + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + GISTENTRY *retval; + + if (entry->leafkey) + { + TSKEY *r = (TSKEY *) palloc(sizeof(TSKEY)); - if ( entry->leafkey) { - TSKEY *r = (TSKEY *)palloc( sizeof(TSKEY) ); retval = palloc(sizeof(GISTENTRY)); - if ( entry->key ) { - r->lower = r->upper = *(Timestamp*)(entry->key); + if (entry->key) + { + r->lower = r->upper = *(Timestamp *) (entry->key); gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page, entry->offset, sizeof(TSKEY), FALSE); - } else { + } + else + { gistentryinit(*retval, PointerGetDatum(NULL), entry->rel, entry->page, entry->offset, 0, FALSE); - } - } else { - retval = entry; + } } - PG_RETURN_POINTER( retval ); + else + retval = entry; + PG_RETURN_POINTER(retval); } -Datum +Datum gts_consistent(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); - Timestamp *query = (Timestamp *)PG_GETARG_POINTER(1); - StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); - bool retval; - TSKEY *key; - /* - ** if entry is not leaf, use gbox_internal_consistent, - ** else use gbox_leaf_consistent - */ - if ( ! entry->key ) - return FALSE; - key = (TSKEY*) DatumGetPointer(entry->key); - - switch(strategy) { - case BTLessEqualStrategyNumber: - retval = TSGE( query, &(key->lower) ); - break; - case BTLessStrategyNumber: - if (GIST_LEAF(entry)) - retval = TSGT( query, &(key->lower) ); - else - retval = TSGE( query, &(key->lower) ); - break; - case BTEqualStrategyNumber: - /* in leaf page key->lower always = key->upper */ - if (GIST_LEAF(entry)) - retval = TSEQ( query, &(key->lower)); - else - retval = ( TSLE( &(key->lower), query ) && TSLE( query, &(key->upper) ) ); - break; - case BTGreaterStrategyNumber: - if (GIST_LEAF(entry)) - retval = TSLT( query, &(key->upper) ); - else - retval = TSLE( query, &(key->upper) ); - break; - case BTGreaterEqualStrategyNumber: - retval = TSLE( query, &(key->upper) ); - break; - default: - retval = FALSE; - } - PG_RETURN_BOOL(retval); + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + Timestamp *query = (Timestamp *) PG_GETARG_POINTER(1); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + bool retval; + TSKEY *key; + + /* + * * if entry is not leaf, use gbox_internal_consistent, * else use + * gbox_leaf_consistent + */ + if (!entry->key) + return FALSE; + key = (TSKEY *) DatumGetPointer(entry->key); + + switch (strategy) + { + case BTLessEqualStrategyNumber: + retval = TSGE(query, &(key->lower)); + break; + case BTLessStrategyNumber: + if (GIST_LEAF(entry)) + retval = TSGT(query, &(key->lower)); + else + retval = TSGE(query, &(key->lower)); + break; + case BTEqualStrategyNumber: + /* in leaf page key->lower always = key->upper */ + if (GIST_LEAF(entry)) + retval = TSEQ(query, &(key->lower)); + else + retval = (TSLE(&(key->lower), query) && TSLE(query, &(key->upper))); + break; + case BTGreaterStrategyNumber: + if (GIST_LEAF(entry)) + retval = TSLT(query, &(key->upper)); + else + retval = TSLE(query, &(key->upper)); + break; + case BTGreaterEqualStrategyNumber: + retval = TSLE(query, &(key->upper)); + break; + default: + retval = FALSE; + } + PG_RETURN_BOOL(retval); } Datum gts_union(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea*) PG_GETARG_POINTER(0); - int i, numranges; - TSKEY *cur, *out=palloc(sizeof(TSKEY)); - - numranges = (VARSIZE(entryvec) - VARHDRSZ)/sizeof(GISTENTRY); - *(int*) PG_GETARG_POINTER(1) = sizeof(TSKEY); - - cur = (TSKEY *)DatumGetPointer( (((GISTENTRY *)(VARDATA(entryvec)))[0].key) ); - out->lower = cur->lower; - out->upper = cur->upper; - - for (i = 1; i < numranges; i++) { - cur = (TSKEY *)DatumGetPointer( (((GISTENTRY *)(VARDATA(entryvec)))[i].key) ); - if ( TSGT( &out->lower, &cur->lower ) ) out->lower = cur->lower; - if ( TSLT( &out->upper, &cur->upper ) ) out->upper = cur->upper; - } + bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + int i, + numranges; + TSKEY *cur, + *out = palloc(sizeof(TSKEY)); + + numranges = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); + *(int *) PG_GETARG_POINTER(1) = sizeof(TSKEY); + + cur = (TSKEY *) DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[0].key)); + out->lower = cur->lower; + out->upper = cur->upper; + + for (i = 1; i < numranges; i++) + { + cur = (TSKEY *) DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)); + if (TSGT(&out->lower, &cur->lower)) + out->lower = cur->lower; + if (TSLT(&out->upper, &cur->upper)) + out->upper = cur->upper; + } - PG_RETURN_POINTER( out ); + PG_RETURN_POINTER(out); } Datum gts_penalty(PG_FUNCTION_ARGS) { - TSKEY *origentry = (TSKEY*) DatumGetPointer( ((GISTENTRY*) PG_GETARG_POINTER(0))->key ); - TSKEY *newentry = (TSKEY*) DatumGetPointer( ((GISTENTRY*) PG_GETARG_POINTER(1))->key ); - float *result = (float*) PG_GETARG_POINTER(2); - Interval *intr; + TSKEY *origentry = (TSKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); + TSKEY *newentry = (TSKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); + Interval *intr; - intr = DatumGetIntervalP( DirectFunctionCall2( - timestamp_mi, - TimestampGetDatum( newentry->upper ), - TimestampGetDatum( origentry->upper )) ); + intr = DatumGetIntervalP(DirectFunctionCall2( + timestamp_mi, + TimestampGetDatum(newentry->upper), + TimestampGetDatum(origentry->upper))); /* see interval_larger */ - *result = Max( intr->time+intr->month * (30.0 * 86400),0 ); - pfree( intr ); - - intr = DatumGetIntervalP( DirectFunctionCall2( - timestamp_mi, - TimestampGetDatum( origentry->lower ), - TimestampGetDatum( newentry->lower )) ); + *result = Max(intr->time + intr->month * (30.0 * 86400), 0); + pfree(intr); + + intr = DatumGetIntervalP(DirectFunctionCall2( + timestamp_mi, + TimestampGetDatum(origentry->lower), + TimestampGetDatum(newentry->lower))); /* see interval_larger */ - *result += Max( intr->time+intr->month * (30.0 * 86400),0 ); - pfree( intr ); - - PG_RETURN_POINTER( result ); + *result += Max(intr->time + intr->month * (30.0 * 86400), 0); + pfree(intr); + + PG_RETURN_POINTER(result); } Datum gts_picksplit(PG_FUNCTION_ARGS) { - PG_RETURN_POINTER( btree_picksplit( - (bytea*)PG_GETARG_POINTER(0), - (GIST_SPLITVEC*)PG_GETARG_POINTER(1), - gts_binary_union, - tskey_cmp - ) ); + PG_RETURN_POINTER(btree_picksplit( + (bytea *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + gts_binary_union, + tskey_cmp + )); } Datum gts_same(PG_FUNCTION_ARGS) { - TSKEY *b1 = (TSKEY*) PG_GETARG_POINTER(0); - TSKEY *b2 = (TSKEY*) PG_GETARG_POINTER(1); - - bool *result = (bool*) PG_GETARG_POINTER(2); - if ( b1 && b2 ) - *result = ( TSEQ( &(b1->lower), &(b2->lower) ) && TSEQ( &(b1->upper), &(b2->upper) ) ) ? TRUE : FALSE; - else - *result = ( b1==NULL && b2==NULL ) ? TRUE : FALSE; - PG_RETURN_POINTER(result); + TSKEY *b1 = (TSKEY *) PG_GETARG_POINTER(0); + TSKEY *b2 = (TSKEY *) PG_GETARG_POINTER(1); + + bool *result = (bool *) PG_GETARG_POINTER(2); + + if (b1 && b2) + *result = (TSEQ(&(b1->lower), &(b2->lower)) && TSEQ(&(b1->upper), &(b2->upper))) ? TRUE : FALSE; + else + *result = (b1 == NULL && b2 == NULL) ? TRUE : FALSE; + PG_RETURN_POINTER(result); } -static void +static void gts_binary_union(Datum *r1, char *r2) { - TSKEY *b1; - TSKEY *b2 = (TSKEY*) r2; - - if ( ! DatumGetPointer( *r1 ) ) { - *r1 = PointerGetDatum( palloc( sizeof(TSKEY) ) ); - b1 = (TSKEY*)DatumGetPointer( *r1 ); - b1->upper = b2->upper; - b1->lower = b2->lower; - } else { - b1 = (TSKEY*)DatumGetPointer( *r1 ); - - b1->lower = ( TSGT( &b1->lower, &b2->lower) ) ? - b2->lower : b1->lower; - b1->upper = ( TSGT( &b1->upper, &b2->upper) ) ? - b1->upper : b2->upper; - } + TSKEY *b1; + TSKEY *b2 = (TSKEY *) r2; + + if (!DatumGetPointer(*r1)) + { + *r1 = PointerGetDatum(palloc(sizeof(TSKEY))); + b1 = (TSKEY *) DatumGetPointer(*r1); + b1->upper = b2->upper; + b1->lower = b2->lower; + } + else + { + b1 = (TSKEY *) DatumGetPointer(*r1); + + b1->lower = (TSGT(&b1->lower, &b2->lower)) ? + b2->lower : b1->lower; + b1->upper = (TSGT(&b1->upper, &b2->upper)) ? + b1->upper : b2->upper; + } } -static int -tskey_cmp(const void *a, const void *b) { - return DatumGetInt32( - DirectFunctionCall2( - timestamp_cmp, - TimestampGetDatum( ((TSKEY*)(((RIX*)a)->r))->lower ), - TimestampGetDatum( ((TSKEY*)(((RIX*)b)->r))->lower ) - ) - ); +static int +tskey_cmp(const void *a, const void *b) +{ + return DatumGetInt32( + DirectFunctionCall2( + timestamp_cmp, + TimestampGetDatum(((TSKEY *) (((RIX *) a)->r))->lower), + TimestampGetDatum(((TSKEY *) (((RIX *) b)->r))->lower) + ) + ); } /************************************************** @@ -466,43 +499,48 @@ tskey_cmp(const void *a, const void *b) { static GIST_SPLITVEC * btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v, BINARY_UNION bu, CMPFUNC cmp) { - OffsetNumber i; - RIX *array; - OffsetNumber maxoff; - int nbytes; - - maxoff = ((VARSIZE(entryvec) - VARHDRSZ)/sizeof(GISTENTRY)) - 1; - nbytes = (maxoff + 2) * sizeof(OffsetNumber); - v->spl_left = (OffsetNumber *) palloc(nbytes); - v->spl_right = (OffsetNumber *) palloc(nbytes); - v->spl_nleft = 0; - v->spl_nright = 0; - v->spl_ldatum = PointerGetDatum( 0 ); - v->spl_rdatum = PointerGetDatum( 0 ); - array = (RIX*)palloc( sizeof(RIX) * (maxoff+1) ); - - /* copy the data into RIXes, and sort the RIXes */ - for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - array[i].index = i; - array[i].r=(char *)DatumGetPointer( (((GISTENTRY *)(VARDATA(entryvec)))[i].key) ); - } - qsort((void*)&array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, - sizeof(RIX), cmp); - - for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - if (i <= (maxoff - FirstOffsetNumber + 1)/2) { - v->spl_left[ v->spl_nleft ] = array[i].index; - v->spl_nleft++; - (*bu)( &v->spl_ldatum, array[i].r ); - } else { - v->spl_right[ v->spl_nright ] = array[i].index; - v->spl_nright++; - (*bu)( &v->spl_rdatum, array[i].r ); - } - } - pfree(array); - - return( v ); + OffsetNumber i; + RIX *array; + OffsetNumber maxoff; + int nbytes; + + maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 1; + nbytes = (maxoff + 2) * sizeof(OffsetNumber); + v->spl_left = (OffsetNumber *) palloc(nbytes); + v->spl_right = (OffsetNumber *) palloc(nbytes); + v->spl_nleft = 0; + v->spl_nright = 0; + v->spl_ldatum = PointerGetDatum(0); + v->spl_rdatum = PointerGetDatum(0); + array = (RIX *) palloc(sizeof(RIX) * (maxoff + 1)); + + /* copy the data into RIXes, and sort the RIXes */ + for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) + { + array[i].index = i; + array[i].r = (char *) DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)); + } + qsort((void *) &array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, + sizeof(RIX), cmp); + + for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) + { + if (i <= (maxoff - FirstOffsetNumber + 1) / 2) + { + v->spl_left[v->spl_nleft] = array[i].index; + v->spl_nleft++; + (*bu) (&v->spl_ldatum, array[i].r); + } + else + { + v->spl_right[v->spl_nright] = array[i].index; + v->spl_nright++; + (*bu) (&v->spl_rdatum, array[i].r); + } + } + pfree(array); + + return (v); } /* @@ -512,38 +550,44 @@ btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v, BINARY_UNION bu, CMPFUNC cmp) Datum btree_decompress(PG_FUNCTION_ARGS) { - PG_RETURN_POINTER(PG_GETARG_POINTER(0)); + PG_RETURN_POINTER(PG_GETARG_POINTER(0)); } /************************************************** * In/Out for keys, not really needed **************************************************/ -Datum -int4key_in(PG_FUNCTION_ARGS) { - INT4KEY *key = palloc(sizeof(INT4KEY)); +Datum +int4key_in(PG_FUNCTION_ARGS) +{ + INT4KEY *key = palloc(sizeof(INT4KEY)); - if ( sscanf( PG_GETARG_POINTER(0), "%d|%d", &(key->lower), &(key->upper)) != 2 ) + if (sscanf(PG_GETARG_POINTER(0), "%d|%d", &(key->lower), &(key->upper)) != 2) elog(ERROR, "Error in input format"); - - PG_RETURN_POINTER( key ); + + PG_RETURN_POINTER(key); } -Datum int4key_out(PG_FUNCTION_ARGS) { - INT4KEY *key = (INT4KEY *) PG_GETARG_POINTER(0); - char *str=palloc(sizeof(char)*22); - sprintf(str,"%d|%d", key->lower, key->upper); - PG_RETURN_POINTER( str ); +Datum +int4key_out(PG_FUNCTION_ARGS) +{ + INT4KEY *key = (INT4KEY *) PG_GETARG_POINTER(0); + char *str = palloc(sizeof(char) * 22); + + sprintf(str, "%d|%d", key->lower, key->upper); + PG_RETURN_POINTER(str); } Datum -tskey_in(PG_FUNCTION_ARGS) { +tskey_in(PG_FUNCTION_ARGS) +{ elog(ERROR, "Not implemented"); - PG_RETURN_POINTER( NULL ); + PG_RETURN_POINTER(NULL); } Datum -tskey_out(PG_FUNCTION_ARGS) { +tskey_out(PG_FUNCTION_ARGS) +{ elog(ERROR, "Not implemented"); - PG_RETURN_POINTER( NULL ); + PG_RETURN_POINTER(NULL); } diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index 2c5974162b..c7c3197c92 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -4,7 +4,7 @@ * darcy@druid.net * http://www.druid.net/darcy/ * - * $Id: chkpass.c,v 1.4 2001/05/30 02:11:46 darcy Exp $ + * $Id: chkpass.c,v 1.5 2001/10/25 05:49:19 momjian Exp $ * best viewed with tabs set to 4 */ @@ -31,7 +31,7 @@ typedef struct chkpass { - char password[16]; + char password[16]; } chkpass; /* @@ -62,12 +62,12 @@ PG_FUNCTION_INFO_V1(chkpass_in) Datum chkpass_in(PG_FUNCTION_ARGS) { - char *str = PG_GETARG_CSTRING(0); - chkpass *result; + char *str = PG_GETARG_CSTRING(0); + chkpass *result; char mysalt[4]; - static bool random_initialized = false; + static bool random_initialized = false; static char salt_chars[] = - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; /* special case to let us enter encrypted passwords */ if (*str == ':') @@ -81,7 +81,7 @@ chkpass_in(PG_FUNCTION_ARGS) if (verify_pass(str) != 0) { elog(ERROR, "chkpass_in: purported CHKPASS \"%s\" is a weak password", - str); + str); PG_RETURN_POINTER(NULL); } @@ -159,17 +159,18 @@ Datum chkpass_eq(PG_FUNCTION_ARGS) { chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0); - text *a2 = (text *) PG_GETARG_TEXT_P(1); - char str[10]; - int sz = 8; + text *a2 = (text *) PG_GETARG_TEXT_P(1); + char str[10]; + int sz = 8; if (!a1 || !a2) PG_RETURN_BOOL(0); - if (a2->vl_len < 12) sz = a2->vl_len - 4; + if (a2->vl_len < 12) + sz = a2->vl_len - 4; strncpy(str, a2->vl_dat, sz); str[sz] = 0; - PG_RETURN_BOOL (strcmp(a1->password, crypt(str, a1->password)) == 0); + PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0); } PG_FUNCTION_INFO_V1(chkpass_ne) @@ -177,14 +178,15 @@ Datum chkpass_ne(PG_FUNCTION_ARGS) { chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0); - text *a2 = (text *) PG_GETARG_TEXT_P(1); - char str[10]; - int sz = 8; + text *a2 = (text *) PG_GETARG_TEXT_P(1); + char str[10]; + int sz = 8; - if (!a1 || !a2) PG_RETURN_BOOL(0); - if (a2->vl_len < 12) sz = a2->vl_len - 4; + if (!a1 || !a2) + PG_RETURN_BOOL(0); + if (a2->vl_len < 12) + sz = a2->vl_len - 4; strncpy(str, a2->vl_dat, sz); str[sz] = 0; - PG_RETURN_BOOL (strcmp(a1->password, crypt(str, a1->password)) != 0); + PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0); } - diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 72f6e5a069..c97e86d3b4 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -166,7 +166,6 @@ g_cube_consistent(GISTENTRY *entry, NDBOX * query, StrategyNumber strategy) { - /* * if entry is not leaf, use g_cube_internal_consistent, else use * g_cube_leaf_consistent @@ -206,7 +205,7 @@ g_cube_union(bytea *entryvec, int *sizep) for (i = 1; i < numranges; i++) { out = g_cube_binary_union(tmp, (NDBOX *) - DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i]).key), + DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i]).key), sizep); if (i > 1) pfree(tmp); @@ -220,13 +219,13 @@ g_cube_union(bytea *entryvec, int *sizep) ** GiST Compress and Decompress methods for boxes ** do not do anything. */ -GISTENTRY * +GISTENTRY * g_cube_compress(GISTENTRY *entry) { return (entry); } -GISTENTRY * +GISTENTRY * g_cube_decompress(GISTENTRY *entry) { return (entry); @@ -365,7 +364,6 @@ g_cube_picksplit(bytea *entryvec, maxoff = OffsetNumberNext(maxoff); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - /* * If we've already decided where to place this item, just put it * on the right list. Otherwise, we need to figure out which page @@ -1001,7 +999,6 @@ cube_contains(NDBOX * box_a, NDBOX * box_b) if (a->dim < b->dim) { - /* * the further comparisons will make sense if the excess * dimensions of (b) were zeroes diff --git a/contrib/dbase/dbf.c b/contrib/dbase/dbf.c index 9ed0c475d1..053e9adffb 100644 --- a/contrib/dbase/dbf.c +++ b/contrib/dbase/dbf.c @@ -21,159 +21,171 @@ /* open a dbf-file, get it's field-info and store this information */ -dbhead *dbf_open(u_char *file, int flags) { - int file_no; - dbhead *dbh; - f_descr *fields; - dbf_header *head; - dbf_field *fieldc; +dbhead * +dbf_open(u_char *file, int flags) +{ + int file_no; + dbhead *dbh; + f_descr *fields; + dbf_header *head; + dbf_field *fieldc; int t; - if ((dbh = (dbhead *)malloc(sizeof(dbhead))) == NULL) { - return (dbhead *)DBF_ERROR; - } + if ((dbh = (dbhead *) malloc(sizeof(dbhead))) == NULL) + return (dbhead *) DBF_ERROR; - if ((head = (dbf_header *)malloc(sizeof(dbf_header))) == NULL) { + if ((head = (dbf_header *) malloc(sizeof(dbf_header))) == NULL) + { free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } - if ((fieldc = (dbf_field *)malloc(sizeof(dbf_field))) == NULL) { + if ((fieldc = (dbf_field *) malloc(sizeof(dbf_field))) == NULL) + { free(head); free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } - if ((file_no = open(file, flags)) == -1) { + if ((file_no = open(file, flags)) == -1) + { free(fieldc); free(head); free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } /* read in the disk-header */ - if (read(file_no, head, sizeof(dbf_header)) == -1) { + if (read(file_no, head, sizeof(dbf_header)) == -1) + { close(file_no); free(fieldc); free(head); free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } - if (!(head->dbh_dbt & DBH_NORMAL)) { - close(file_no); - free(fieldc); - free(head); - free(dbh); - return (dbhead *)DBF_ERROR; + if (!(head->dbh_dbt & DBH_NORMAL)) + { + close(file_no); + free(fieldc); + free(head); + free(dbh); + return (dbhead *) DBF_ERROR; } dbh->db_fd = file_no; - if (head->dbh_dbt & DBH_MEMO) { + if (head->dbh_dbt & DBH_MEMO) dbh->db_memo = 1; - } else { + else dbh->db_memo = 0; - } dbh->db_year = head->dbh_year; dbh->db_month = head->dbh_month; dbh->db_day = head->dbh_day; - dbh->db_hlen = get_short((u_char *)&head->dbh_hlen); - dbh->db_records = get_long((u_char *)&head->dbh_records); + dbh->db_hlen = get_short((u_char *) &head->dbh_hlen); + dbh->db_records = get_long((u_char *) &head->dbh_records); dbh->db_currec = 0; - dbh->db_rlen = get_short((u_char *)&head->dbh_rlen); + dbh->db_rlen = get_short((u_char *) &head->dbh_rlen); dbh->db_nfields = (dbh->db_hlen - sizeof(dbf_header)) / sizeof(dbf_field); - /* dbh->db_hlen - sizeof(dbf_header) isn't the - correct size, cos dbh->hlen is in fact - a little more cos of the 0x0D (and - possibly another byte, 0x4E, I have - seen this somewhere). Because of rounding - everything turns out right :) */ - - if ((fields = (f_descr *)calloc(dbh->db_nfields, sizeof(f_descr))) - == NULL) { - close(file_no); - free(fieldc); - free(head); - free(dbh); - return (dbhead *)DBF_ERROR; + /* + * dbh->db_hlen - sizeof(dbf_header) isn't the correct size, cos + * dbh->hlen is in fact a little more cos of the 0x0D (and possibly + * another byte, 0x4E, I have seen this somewhere). Because of + * rounding everything turns out right :) + */ + + if ((fields = (f_descr *) calloc(dbh->db_nfields, sizeof(f_descr))) + == NULL) + { + close(file_no); + free(fieldc); + free(head); + free(dbh); + return (dbhead *) DBF_ERROR; } - for (t = 0; t < dbh->db_nfields; t++) { + for (t = 0; t < dbh->db_nfields; t++) + { /* Maybe I have calculated the number of fields incorrectly. This can happen when programs reserve lots of space at the end of the header for future - expansion. This will catch this situation */ - if (fields[t].db_name[0] == 0x0D) { + expansion. This will catch this situation */ + if (fields[t].db_name[0] == 0x0D) + { dbh->db_nfields = t; break; } read(file_no, fieldc, sizeof(dbf_field)); strncpy(fields[t].db_name, fieldc->dbf_name, DBF_NAMELEN); - fields[t].db_type = fieldc->dbf_type; + fields[t].db_type = fieldc->dbf_type; fields[t].db_flen = fieldc->dbf_flen; - fields[t].db_dec = fieldc->dbf_dec; + fields[t].db_dec = fieldc->dbf_dec; } dbh->db_offset = dbh->db_hlen; dbh->db_fields = fields; - if ((dbh->db_buff = (u_char *)malloc(dbh->db_rlen)) == NULL) { - return (dbhead *)DBF_ERROR; - } + if ((dbh->db_buff = (u_char *) malloc(dbh->db_rlen)) == NULL) + return (dbhead *) DBF_ERROR; - free(fieldc); - free(head); + free(fieldc); + free(head); return dbh; } -int dbf_write_head(dbhead *dbh) { +int +dbf_write_head(dbhead * dbh) +{ dbf_header head; - time_t now; - struct tm *dbf_time; + time_t now; + struct tm *dbf_time; - if (lseek(dbh->db_fd, 0, SEEK_SET) == -1) { + if (lseek(dbh->db_fd, 0, SEEK_SET) == -1) return DBF_ERROR; - } /* fill up the diskheader */ /* Set dataarea of head to '\0' */ - memset(&head,'\0',sizeof(dbf_header)); + memset(&head, '\0', sizeof(dbf_header)); head.dbh_dbt = DBH_NORMAL; - if (dbh->db_memo) head.dbh_dbt = DBH_MEMO; + if (dbh->db_memo) + head.dbh_dbt = DBH_MEMO; - now = time((time_t *)NULL); + now = time((time_t *) NULL); dbf_time = localtime(&now); head.dbh_year = dbf_time->tm_year; - head.dbh_month = dbf_time->tm_mon + 1; /* Months since January + 1 */ + head.dbh_month = dbf_time->tm_mon + 1; /* Months since January + + * 1 */ head.dbh_day = dbf_time->tm_mday; put_long(head.dbh_records, dbh->db_records); put_short(head.dbh_hlen, dbh->db_hlen); put_short(head.dbh_rlen, dbh->db_rlen); - + if (write(dbh->db_fd, &head, sizeof(dbf_header)) != sizeof(dbf_header)) return DBF_ERROR; return 0; } -int dbf_put_fields(dbhead *dbh) { +int +dbf_put_fields(dbhead * dbh) +{ dbf_field field; u_long t; u_char end = 0x0D; - if (lseek(dbh->db_fd, sizeof(dbf_header), SEEK_SET) == -1) { + if (lseek(dbh->db_fd, sizeof(dbf_header), SEEK_SET) == -1) return DBF_ERROR; - } /* Set dataarea of field to '\0' */ - memset(&field,'\0',sizeof(dbf_field)); + memset(&field, '\0', sizeof(dbf_field)); - for (t = 0; t < dbh->db_nfields; t++) { + for (t = 0; t < dbh->db_nfields; t++) + { strncpy(field.dbf_name, dbh->db_fields[t].db_name, DBF_NAMELEN - 1); field.dbf_type = dbh->db_fields[t].db_type; field.dbf_flen = dbh->db_fields[t].db_flen; @@ -189,16 +201,18 @@ int dbf_put_fields(dbhead *dbh) { return 0; } -int dbf_add_field(dbhead *dbh, u_char *name, u_char type, - u_char length, u_char dec) { -f_descr *ptr; -u_char *foo; -u_long size, field_no; +int +dbf_add_field(dbhead * dbh, u_char *name, u_char type, + u_char length, u_char dec) +{ + f_descr *ptr; + u_char *foo; + u_long size, + field_no; size = (dbh->db_nfields + 1) * sizeof(f_descr); - if (!(ptr = (f_descr *) realloc(dbh->db_fields, size))) { + if (!(ptr = (f_descr *) realloc(dbh->db_fields, size))) return DBF_ERROR; - } dbh->db_fields = ptr; field_no = dbh->db_nfields; @@ -211,71 +225,81 @@ u_long size, field_no; dbh->db_hlen += sizeof(dbf_field); dbh->db_rlen += length; - if (!(foo = (u_char *) realloc(dbh->db_buff, dbh->db_rlen))) { + if (!(foo = (u_char *) realloc(dbh->db_buff, dbh->db_rlen))) return DBF_ERROR; - } dbh->db_buff = foo; return 0; } -dbhead *dbf_open_new(u_char *name, int flags) { -dbhead *dbh; +dbhead * +dbf_open_new(u_char *name, int flags) +{ + dbhead *dbh; - if (!(dbh = (dbhead *)malloc(sizeof(dbhead)))) { - return (dbhead *)DBF_ERROR; - } + if (!(dbh = (dbhead *) malloc(sizeof(dbhead)))) + return (dbhead *) DBF_ERROR; - if (flags & O_CREAT) { - if ((dbh->db_fd = open(name, flags, DBF_FILE_MODE)) == -1) { + if (flags & O_CREAT) + { + if ((dbh->db_fd = open(name, flags, DBF_FILE_MODE)) == -1) + { free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } - } else { - if ((dbh->db_fd = open(name, flags)) == -1) { + } + else + { + if ((dbh->db_fd = open(name, flags)) == -1) + { free(dbh); - return (dbhead *)DBF_ERROR; + return (dbhead *) DBF_ERROR; } } - + dbh->db_offset = 0; dbh->db_memo = 0; dbh->db_year = 0; dbh->db_month = 0; - dbh->db_day = 0; + dbh->db_day = 0; dbh->db_hlen = sizeof(dbf_header) + 1; dbh->db_records = 0; dbh->db_currec = 0; dbh->db_rlen = 1; dbh->db_nfields = 0; dbh->db_buff = NULL; - dbh->db_fields = (f_descr *)NULL; + dbh->db_fields = (f_descr *) NULL; return dbh; } - -void dbf_close(dbhead *dbh) { - int t; + +void +dbf_close(dbhead * dbh) +{ + int t; close(dbh->db_fd); - for (t = 0; t < dbh->db_nfields; t++) { + for (t = 0; t < dbh->db_nfields; t++) free(&dbh->db_fields[t]); - } - if (dbh->db_buff != NULL) { + if (dbh->db_buff != NULL) free(dbh->db_buff); - } free(dbh); } - -int dbf_get_record(dbhead *dbh, field *fields, u_long rec) { - u_char *data; - int t, i, offset; - u_char *dbffield, *end; + +int +dbf_get_record(dbhead * dbh, field * fields, u_long rec) +{ + u_char *data; + int t, + i, + offset; + u_char *dbffield, + *end; /* calculate at which offset we have to read. *DON'T* forget the 0x0D which seperates field-descriptions from records! @@ -284,112 +308,133 @@ int dbf_get_record(dbhead *dbh, field *fields, u_long rec) { */ offset = dbh->db_hlen + (rec * dbh->db_rlen); - if (lseek(dbh->db_fd, offset, SEEK_SET) == -1) { + if (lseek(dbh->db_fd, offset, SEEK_SET) == -1) + { lseek(dbh->db_fd, 0, SEEK_SET); dbh->db_offset = 0; return DBF_ERROR; } - dbh->db_offset = offset; - dbh->db_currec = rec; + dbh->db_offset = offset; + dbh->db_currec = rec; data = dbh->db_buff; - read(dbh->db_fd, data, dbh->db_rlen); - - if (data[0] == DBF_DELETED) { - return DBF_DELETED; - } - - dbffield = &data[1]; - for (t = 0; t < dbh->db_nfields; t++) { - strncpy(fields[t].db_name, dbh->db_fields[t].db_name, DBF_NAMELEN); - fields[t].db_type = dbh->db_fields[t].db_type; - fields[t].db_flen = dbh->db_fields[t].db_flen; - fields[t].db_dec = dbh->db_fields[t].db_dec; - - if (fields[t].db_type == 'C') { - end = &dbffield[fields[t].db_flen - 1 ]; - i = fields[t].db_flen; - while (( i > 0) && ((*end < 0x21) || (*end > 0x7E))) { - end--; - i--; - } - strncpy(fields[t].db_contents, dbffield, i); - fields[t].db_contents[i] = '\0'; - } else { - end = dbffield; - i = fields[t].db_flen; - while (( i > 0) && ((*end < 0x21) || (*end > 0x7E))) { - end++; - i--; - } - strncpy(fields[t].db_contents, end, i); - fields[t].db_contents[i] = '\0'; - } + read(dbh->db_fd, data, dbh->db_rlen); + + if (data[0] == DBF_DELETED) + return DBF_DELETED; + + dbffield = &data[1]; + for (t = 0; t < dbh->db_nfields; t++) + { + strncpy(fields[t].db_name, dbh->db_fields[t].db_name, DBF_NAMELEN); + fields[t].db_type = dbh->db_fields[t].db_type; + fields[t].db_flen = dbh->db_fields[t].db_flen; + fields[t].db_dec = dbh->db_fields[t].db_dec; + + if (fields[t].db_type == 'C') + { + end = &dbffield[fields[t].db_flen - 1]; + i = fields[t].db_flen; + while ((i > 0) && ((*end < 0x21) || (*end > 0x7E))) + { + end--; + i--; + } + strncpy(fields[t].db_contents, dbffield, i); + fields[t].db_contents[i] = '\0'; + } + else + { + end = dbffield; + i = fields[t].db_flen; + while ((i > 0) && ((*end < 0x21) || (*end > 0x7E))) + { + end++; + i--; + } + strncpy(fields[t].db_contents, end, i); + fields[t].db_contents[i] = '\0'; + } - dbffield += fields[t].db_flen; + dbffield += fields[t].db_flen; } - dbh->db_offset += dbh->db_rlen; + dbh->db_offset += dbh->db_rlen; return DBF_VALID; } -field *dbf_build_record(dbhead *dbh) { - int t; - field *fields; +field * +dbf_build_record(dbhead * dbh) +{ + int t; + field *fields; - if (!(fields = (field *)calloc(dbh->db_nfields, sizeof(field)))) { - return (field *)DBF_ERROR; - } - - for ( t = 0; t < dbh->db_nfields; t++) { + if (!(fields = (field *) calloc(dbh->db_nfields, sizeof(field)))) + return (field *) DBF_ERROR; + + for (t = 0; t < dbh->db_nfields; t++) + { if (!(fields[t].db_contents = - (u_char *)malloc(dbh->db_fields[t].db_flen + 1))) { - for (t = 0; t < dbh->db_nfields; t++) { - if (fields[t].db_contents != 0) { + (u_char *) malloc(dbh->db_fields[t].db_flen + 1))) + { + for (t = 0; t < dbh->db_nfields; t++) + { + if (fields[t].db_contents != 0) + { free(fields[t].db_contents); free(fields); } - return (field *)DBF_ERROR; + return (field *) DBF_ERROR; } } strncpy(fields[t].db_name, dbh->db_fields[t].db_name, DBF_NAMELEN); fields[t].db_type = dbh->db_fields[t].db_type; fields[t].db_flen = dbh->db_fields[t].db_flen; - fields[t].db_dec = dbh->db_fields[t].db_dec; + fields[t].db_dec = dbh->db_fields[t].db_dec; } return fields; } -void dbf_free_record(dbhead *dbh, field *rec) { - int t; +void +dbf_free_record(dbhead * dbh, field * rec) +{ + int t; - for ( t = 0; t < dbh->db_nfields; t++) { + for (t = 0; t < dbh->db_nfields; t++) free(rec[t].db_contents); - } free(rec); } -int dbf_put_record(dbhead *dbh, field *rec, u_long where) { - u_long offset, new, idx, t, h, length; - u_char *data, end = 0x1a; - double fl; - u_char foo[128], format[32]; - -/* offset: offset in file for this record +int +dbf_put_record(dbhead * dbh, field * rec, u_long where) +{ + u_long offset, + new, + idx, + t, + h, + length; + u_char *data, + end = 0x1a; + double fl; + u_char foo[128], + format[32]; + +/* offset: offset in file for this record new: real offset after lseek idx: index to which place we are inside the 'hardcore'-data for this record t: field-counter data: the hardcore-data that is put on disk h: index into the field-part in the hardcore-data - length: length of the data to copy + length: length of the data to copy fl: a float used to get the right precision with real numbers foo: copy of db_contents when field is not 'C' - format: sprintf format-string to get the right precision with real numbers + format: sprintf format-string to get the right precision with real numbers NOTE: this declaration of 'foo' can cause overflow when the contents-field is longer the 127 chars (which is highly unlikely, cos it is not used @@ -399,16 +444,17 @@ int dbf_put_record(dbhead *dbh, field *rec, u_long where) { DO A SEEK_END WITH 0!!!!!! USE -1 !!!!!!!!!! */ - if (where > dbh->db_records) { - if ((new = lseek(dbh->db_fd, -1, SEEK_END)) == -1) { + if (where > dbh->db_records) + { + if ((new = lseek(dbh->db_fd, -1, SEEK_END)) == -1) return DBF_ERROR; - } dbh->db_records++; - } else { + } + else + { offset = dbh->db_hlen + (where * dbh->db_rlen); - if ((new = lseek(dbh->db_fd, offset, SEEK_SET)) == -1) { + if ((new = lseek(dbh->db_fd, offset, SEEK_SET)) == -1) return DBF_ERROR; - } } dbh->db_offset = new; @@ -416,49 +462,54 @@ int dbf_put_record(dbhead *dbh, field *rec, u_long where) { data = dbh->db_buff; /* Set dataarea of data to ' ' (space) */ - memset(data,' ',dbh->db_rlen); + memset(data, ' ', dbh->db_rlen); /* data[0] = DBF_VALID; */ idx = 1; - for (t = 0; t < dbh->db_nfields; t++) { + for (t = 0; t < dbh->db_nfields; t++) + { /* if field is empty, don't do a thing */ - if (rec[t].db_contents[0] != '\0') { + if (rec[t].db_contents[0] != '\0') + { /* Handle text */ - if (rec[t].db_type == 'C') { - if (strlen(rec[t].db_contents) > rec[t].db_flen) { - length = rec[t].db_flen; - } else { - length = strlen(rec[t].db_contents); + if (rec[t].db_type == 'C') + { + if (strlen(rec[t].db_contents) > rec[t].db_flen) + length = rec[t].db_flen; + else + length = strlen(rec[t].db_contents); + strncpy(data + idx, rec[t].db_contents, length); } - strncpy(data+idx, rec[t].db_contents, length); - } else { + else + { /* Handle the rest */ /* Numeric is special, because of real numbers */ - if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0)) { - fl = atof(rec[t].db_contents); - sprintf(format, "%%.%df", rec[t].db_dec); - sprintf(foo, format, fl); - } else { - strcpy(foo, rec[t].db_contents); - } - if (strlen(foo) > rec[t].db_flen) { - length = rec[t].db_flen; - } else { - length = strlen(foo); + if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0)) + { + fl = atof(rec[t].db_contents); + sprintf(format, "%%.%df", rec[t].db_dec); + sprintf(foo, format, fl); + } + else + strcpy(foo, rec[t].db_contents); + if (strlen(foo) > rec[t].db_flen) + length = rec[t].db_flen; + else + length = strlen(foo); + h = rec[t].db_flen - length; + strncpy(data + idx + h, foo, length); } - h = rec[t].db_flen - length; - strncpy(data+idx+h, foo, length); } - } - idx += rec[t].db_flen; + idx += rec[t].db_flen; } if (write(dbh->db_fd, data, dbh->db_rlen) != dbh->db_rlen) return DBF_ERROR; /* There's a 0x1A at the end of a dbf-file */ - if (where == dbh->db_records) { + if (where == dbh->db_records) + { if (write(dbh->db_fd, &end, 1) != 1) return DBF_ERROR; } diff --git a/contrib/dbase/dbf.h b/contrib/dbase/dbf.h index a6e92517ea..b54093bace 100644 --- a/contrib/dbase/dbf.h +++ b/contrib/dbase/dbf.h @@ -26,7 +26,7 @@ /* maximum fieldname-length */ -#define DBF_NAMELEN 11 +#define DBF_NAMELEN 11 /* magic-cookies for the file */ @@ -37,89 +37,93 @@ #define DBF_ERROR -1 #define DBF_VALID 0x20 -#define DBF_DELETED 0x2A +#define DBF_DELETED 0x2A /* diskheader */ -typedef struct { - u_char dbh_dbt; /* indentification field */ - u_char dbh_year; /* last modification-date */ - u_char dbh_month; - u_char dbh_day; - u_char dbh_records[4]; /* number of records */ - u_char dbh_hlen[2]; /* length of this header */ - u_char dbh_rlen[2]; /* length of a record */ - u_char dbh_stub[20]; /* misc stuff we don't need */ -} dbf_header; +typedef struct +{ + u_char dbh_dbt; /* indentification field */ + u_char dbh_year; /* last modification-date */ + u_char dbh_month; + u_char dbh_day; + u_char dbh_records[4]; /* number of records */ + u_char dbh_hlen[2]; /* length of this header */ + u_char dbh_rlen[2]; /* length of a record */ + u_char dbh_stub[20]; /* misc stuff we don't need */ +} dbf_header; /* disk field-description */ -typedef struct { - u_char dbf_name[DBF_NAMELEN]; /* field-name terminated with \0 */ - u_char dbf_type; /* field-type */ - u_char dbf_reserved[4]; /* some reserved stuff */ - u_char dbf_flen; /* field-length */ - u_char dbf_dec; /* number of decimal positions if - type is 'N' */ - u_char dbf_stub[14]; /* stuff we don't need */ -} dbf_field; +typedef struct +{ + u_char dbf_name[DBF_NAMELEN]; /* field-name terminated with \0 */ + u_char dbf_type; /* field-type */ + u_char dbf_reserved[4]; /* some reserved stuff */ + u_char dbf_flen; /* field-length */ + u_char dbf_dec; /* number of decimal positions if type is + * 'N' */ + u_char dbf_stub[14]; /* stuff we don't need */ +} dbf_field; /* memory field-description */ -typedef struct { - u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ - u_char db_type; /* field-type */ - u_char db_flen; /* field-length */ - u_char db_dec; /* number of decimal positions */ -} f_descr; +typedef struct +{ + u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ + u_char db_type; /* field-type */ + u_char db_flen; /* field-length */ + u_char db_dec; /* number of decimal positions */ +} f_descr; /* memory dfb-header */ -typedef struct { - int db_fd; /* file-descriptor */ - u_long db_offset; /* current offset in file */ - u_char db_memo; /* memo-file present */ - u_char db_year; /* last update as YYMMDD */ - u_char db_month; - u_char db_day; - u_long db_hlen; /* length of the diskheader, for - calculating the offsets */ - u_long db_records; /* number of records */ - u_long db_currec; /* current record-number starting - at 0 */ - u_short db_rlen; /* length of the record */ - u_char db_nfields; /* number of fields */ - u_char *db_buff; /* record-buffer to save malloc()'s */ - f_descr *db_fields; /* pointer to an array of field- - descriptions */ -} dbhead; +typedef struct +{ + int db_fd; /* file-descriptor */ + u_long db_offset; /* current offset in file */ + u_char db_memo; /* memo-file present */ + u_char db_year; /* last update as YYMMDD */ + u_char db_month; + u_char db_day; + u_long db_hlen; /* length of the diskheader, for + * calculating the offsets */ + u_long db_records; /* number of records */ + u_long db_currec; /* current record-number starting at 0 */ + u_short db_rlen; /* length of the record */ + u_char db_nfields; /* number of fields */ + u_char *db_buff; /* record-buffer to save malloc()'s */ + f_descr *db_fields; /* pointer to an array of field- + * descriptions */ +} dbhead; /* structure that contains everything a user wants from a field, including the contents (in ASCII). Warning! db_flen may be bigger than the actual length of db_name! This is because a field doesn't have to be completely filled */ - -typedef struct { - u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ - u_char db_type; /* field-type */ - u_char db_flen; /* field-length */ - u_char db_dec; /* number of decimal positions */ - u_char* db_contents; /* contents of the field in ASCII */ -} field; + +typedef struct +{ + u_char db_name[DBF_NAMELEN]; /* field-name terminated with \0 */ + u_char db_type; /* field-type */ + u_char db_flen; /* field-length */ + u_char db_dec; /* number of decimal positions */ + u_char *db_contents; /* contents of the field in ASCII */ +} field; /* prototypes for functions */ -extern dbhead* dbf_open(u_char *file ,int flags); -extern int dbf_write_head(dbhead *dbh); -extern int dbf_put_fields(dbhead *dbh); -extern int dbf_add_field(dbhead *dbh, u_char *name, u_char type, - u_char length, u_char dec); -extern dbhead * dbf_open_new(u_char *name, int flags); -extern void dbf_close(dbhead *dbh); -extern int dbf_get_record(dbhead *dbh, field *fields, u_long rec); -extern field* dbf_build_record(dbhead *dbh); -extern void dbf_free_record(dbhead *dbh, field* fields); -extern int dbf_put_record(dbhead *dbh, field *rec, u_long where); +extern dbhead *dbf_open(u_char *file, int flags); +extern int dbf_write_head(dbhead * dbh); +extern int dbf_put_fields(dbhead * dbh); +extern int dbf_add_field(dbhead * dbh, u_char *name, u_char type, + u_char length, u_char dec); +extern dbhead *dbf_open_new(u_char *name, int flags); +extern void dbf_close(dbhead * dbh); +extern int dbf_get_record(dbhead * dbh, field * fields, u_long rec); +extern field *dbf_build_record(dbhead * dbh); +extern void dbf_free_record(dbhead * dbh, field * fields); +extern int dbf_put_record(dbhead * dbh, field * rec, u_long where); /********************************************************************* @@ -131,5 +135,4 @@ extern long get_long(u_char *cp); extern void put_long(u_char *cp, long lval); extern short get_short(u_char *cp); extern void put_short(u_char *cp, short lval); - -#endif /* _DBF_H */ +#endif /* _DBF_H */ diff --git a/contrib/dbase/dbf2pg.c b/contrib/dbase/dbf2pg.c index 839bb7211f..e2393de542 100644 --- a/contrib/dbase/dbf2pg.c +++ b/contrib/dbase/dbf2pg.c @@ -22,146 +22,178 @@ #include "libpq-fe.h" #include "dbf.h" -int verbose = 0, upper = 0, lower = 0, create = 0, fieldlow = 0; -int del = 0; -unsigned int begin = 0, end = 0; +int verbose = 0, + upper = 0, + lower = 0, + create = 0, + fieldlow = 0; +int del = 0; +unsigned int begin = 0, + end = 0; unsigned int t_block = 0; #ifdef HAVE_ICONV_H -char *charset_from=NULL; -char *charset_to="ISO-8859-1"; -iconv_t iconv_d; -char convert_charset_buff[8192]; +char *charset_from = NULL; +char *charset_to = "ISO-8859-1"; +iconv_t iconv_d; +char convert_charset_buff[8192]; #endif -char *host = NULL; -char *dbase = "test"; -char *table = "test"; -char *username = NULL; -char *password = NULL; -char *subarg = NULL; -char escape_buff[8192]; +char *host = NULL; +char *dbase = "test"; +char *table = "test"; +char *username = NULL; +char *password = NULL; +char *subarg = NULL; +char escape_buff[8192]; -void do_substitute(char *subarg, dbhead *dbh); +void do_substitute(char *subarg, dbhead * dbh); inline void strtoupper(char *string); inline void strtolower(char *string); -void do_create(PGconn *, char*, dbhead*); -void do_inserts(PGconn *, char*, dbhead*); -int check_table(PGconn *, char*); +void do_create(PGconn *, char *, dbhead *); +void do_inserts(PGconn *, char *, dbhead *); +int check_table(PGconn *, char *); + +char *Escape(char *); -char *Escape(char*); #ifdef HAVE_ICONV_H -char *convert_charset(char *string); +char *convert_charset(char *string); #endif -void usage(void); +void usage(void); unsigned int isinteger(char *); -char *simple_prompt(const char *prompt, int maxlen, bool echo); +char *simple_prompt(const char *prompt, int maxlen, bool echo); -unsigned int isinteger(char *buff) { - char *i=buff; +unsigned int +isinteger(char *buff) +{ + char *i = buff; - while (*i != '\0') { - if (i==buff) + while (*i != '\0') + { + if (i == buff) if ((*i == '-') || - (*i == '+')) { - i++; continue; + (*i == '+')) + { + i++; + continue; } - if (!isdigit((int)*i)) return 0; + if (!isdigit((int) *i)) + return 0; i++; } return 1; } -inline void strtoupper(char *string) { - while(*string != '\0') { +inline void +strtoupper(char *string) +{ + while (*string != '\0') + { *string = toupper(*string); string++; } } -inline void strtolower(char *string) { - while(*string != '\0') { +inline void +strtolower(char *string) +{ + while (*string != '\0') + { *string = tolower(*string); string++; } } /* FIXME: should this check for overflow? */ -char *Escape(char *string) { - char *foo, *bar; - - foo = escape_buff; - - bar = string; - while (*bar != '\0') { - if ((*bar == '\t') || - (*bar == '\n') || - (*bar == '\\')) { - *foo++ = '\\'; - } - *foo++ = *bar++; - } - *foo = '\0'; - - return escape_buff; -} +char * +Escape(char *string) +{ + char *foo, + *bar; -#ifdef HAVE_ICONV_H -char *convert_charset(char *string) { - size_t in_size, out_size, nconv; - char *in_ptr,*out_ptr; + foo = escape_buff; - in_size=strlen(string)+1; - out_size=sizeof(convert_charset_buff); - in_ptr=string; - out_ptr=convert_charset_buff; + bar = string; + while (*bar != '\0') + { + if ((*bar == '\t') || + (*bar == '\n') || + (*bar == '\\')) + *foo++ = '\\'; + *foo++ = *bar++; + } + *foo = '\0'; + + return escape_buff; +} - iconv(iconv_d, NULL, &in_size, &out_ptr, &out_size); /* necessary to reset state information */ - while(in_size>0) +#ifdef HAVE_ICONV_H +char * +convert_charset(char *string) +{ + size_t in_size, + out_size, + nconv; + char *in_ptr, + *out_ptr; + + in_size = strlen(string) + 1; + out_size = sizeof(convert_charset_buff); + in_ptr = string; + out_ptr = convert_charset_buff; + + iconv(iconv_d, NULL, &in_size, &out_ptr, &out_size); /* necessary to reset + * state information */ + while (in_size > 0) { nconv = iconv(iconv_d, &in_ptr, &in_size, &out_ptr, &out_size); - if(nconv == (size_t) -1) + if (nconv == (size_t) -1) { printf("WARNING: cannot convert charset of string \"%s\".\n", - string); - strcpy(convert_charset_buff,string); + string); + strcpy(convert_charset_buff, string); return convert_charset_buff; } } - *out_ptr = 0; /* terminate output string */ + *out_ptr = 0; /* terminate output string */ return convert_charset_buff; } #endif -int check_table(PGconn *conn, char *table) { - char *q = "select relname from pg_class where " - "relkind='r' and relname !~* '^pg'"; - PGresult *res; - int i = 0; +int +check_table(PGconn *conn, char *table) +{ + char *q = "select relname from pg_class where " + "relkind='r' and relname !~* '^pg'"; + PGresult *res; + int i = 0; - if (!(res = PQexec(conn, q))) { + if (!(res = PQexec(conn, q))) + { printf("%s\n", PQerrorMessage(conn)); return 0; } - for (i = 0; i < PQntuples(res); i++) { - if (!strcmp(table, PQgetvalue(res, i, PQfnumber(res, "relname")))) { + for (i = 0; i < PQntuples(res); i++) + { + if (!strcmp(table, PQgetvalue(res, i, PQfnumber(res, "relname")))) return 1; - } } return 0; } -void usage(void){ +void +usage(void) +{ printf("dbf2pg\n" -"usage: dbf2pg [-u | -l] [-h hostname] [-W] [-U username]\n" -" [-B transaction_size] [-F charset_from [-T charset_to]]\n" -" [-s oldname=newname[,oldname=newname[...]]] [-d dbase]\n" -" [-t table] [-c | -D] [-f] [-v[v]] dbf-file\n"); + "usage: dbf2pg [-u | -l] [-h hostname] [-W] [-U username]\n" + " [-B transaction_size] [-F charset_from [-T charset_to]]\n" + " [-s oldname=newname[,oldname=newname[...]]] [-d dbase]\n" + " [-t table] [-c | -D] [-f] [-v[v]] dbf-file\n"); } /* patch submitted by Jeffrey Y. Sue <jysue@aloha.net> */ @@ -169,66 +201,80 @@ void usage(void){ /* Mainly for avoiding conflicts between fieldnames and SQL-reserved */ /* keywords */ -void do_substitute(char *subarg, dbhead *dbh) +void +do_substitute(char *subarg, dbhead * dbh) { - /* NOTE: subarg is modified in this function */ - int i,bad; - char *p,*oldname,*newname; - if (!subarg) { - return; - } - if (verbose>1) { - printf("Substituting new field names\n"); - } - /* use strstr instead of strtok because of possible empty tokens */ - oldname = subarg; - while (oldname && strlen(oldname) && (p=strstr(oldname,"=")) ) { - *p = '\0'; /* mark end of oldname */ - newname = ++p; /* point past \0 of oldname */ - if (strlen(newname)) { /* if not an empty string */ - p = strstr(newname,","); - if (p) { - *p = '\0'; /* mark end of newname */ - p++; /* point past where the comma was */ - } - } - if (strlen(newname)>=DBF_NAMELEN) { - printf("Truncating new field name %s to %d chars\n", - newname,DBF_NAMELEN-1); - newname[DBF_NAMELEN-1] = '\0'; - } - bad = 1; - for (i=0;i<dbh->db_nfields;i++) { - if (strcmp(dbh->db_fields[i].db_name,oldname)==0) { - bad = 0; - strcpy(dbh->db_fields[i].db_name,newname); - if (verbose>1) { - printf("Substitute old:%s new:%s\n", - oldname,newname); - } - break; - } - } - if (bad) { - printf("Warning: old field name %s not found\n", - oldname); - } - oldname = p; - } -} /* do_substitute */ - -void do_create(PGconn *conn, char *table, dbhead *dbh) { - char *query; - char t[20]; - int i, length; - PGresult *res; - - if (verbose > 1) { - printf("Building CREATE-clause\n"); + /* NOTE: subarg is modified in this function */ + int i, + bad; + char *p, + *oldname, + *newname; + + if (!subarg) + return; + if (verbose > 1) + printf("Substituting new field names\n"); + /* use strstr instead of strtok because of possible empty tokens */ + oldname = subarg; + while (oldname && strlen(oldname) && (p = strstr(oldname, "="))) + { + *p = '\0'; /* mark end of oldname */ + newname = ++p; /* point past \0 of oldname */ + if (strlen(newname)) + { /* if not an empty string */ + p = strstr(newname, ","); + if (p) + { + *p = '\0'; /* mark end of newname */ + p++; /* point past where the comma was */ + } + } + if (strlen(newname) >= DBF_NAMELEN) + { + printf("Truncating new field name %s to %d chars\n", + newname, DBF_NAMELEN - 1); + newname[DBF_NAMELEN - 1] = '\0'; + } + bad = 1; + for (i = 0; i < dbh->db_nfields; i++) + { + if (strcmp(dbh->db_fields[i].db_name, oldname) == 0) + { + bad = 0; + strcpy(dbh->db_fields[i].db_name, newname); + if (verbose > 1) + { + printf("Substitute old:%s new:%s\n", + oldname, newname); + } + break; + } + } + if (bad) + { + printf("Warning: old field name %s not found\n", + oldname); + } + oldname = p; } +} /* do_substitute */ - if (!(query = (char *)malloc( - (dbh->db_nfields * 40) + 29 + strlen(table)))) { +void +do_create(PGconn *conn, char *table, dbhead * dbh) +{ + char *query; + char t[20]; + int i, + length; + PGresult *res; + + if (verbose > 1) + printf("Building CREATE-clause\n"); + + if (!(query = (char *) malloc( + (dbh->db_nfields * 40) + 29 + strlen(table)))) + { fprintf(stderr, "Memory allocation error in function do_create\n"); PQfinish(conn); close(dbh->db_fd); @@ -238,61 +284,65 @@ void do_create(PGconn *conn, char *table, dbhead *dbh) { sprintf(query, "CREATE TABLE %s (", table); length = strlen(query); - for ( i = 0; i < dbh->db_nfields; i++) { - if (!strlen(dbh->db_fields[i].db_name)) { - continue; - /* skip field if length of name == 0 */ - } - if ((strlen(query) != length)) { - strcat(query, ","); - } - - if (fieldlow) - strtolower(dbh->db_fields[i].db_name); - - strcat(query, dbh->db_fields[i].db_name); - switch(dbh->db_fields[i].db_type) { - case 'D': - strcat(query, " date"); - break; - case 'C': - if (dbh->db_fields[i].db_flen > 1) { - strcat(query, " varchar"); - sprintf(t, "(%d)", - dbh->db_fields[i].db_flen); - strcat(query, t); - } else { - strcat(query, " char"); - } - break; - case 'N': - if (dbh->db_fields[i].db_dec != 0) { - strcat(query, " real"); - } else { - strcat(query, " int"); - } - break; - case 'L': - strcat(query, " char"); - break; - } + for (i = 0; i < dbh->db_nfields; i++) + { + if (!strlen(dbh->db_fields[i].db_name)) + { + continue; + /* skip field if length of name == 0 */ + } + if ((strlen(query) != length)) + strcat(query, ","); + + if (fieldlow) + strtolower(dbh->db_fields[i].db_name); + + strcat(query, dbh->db_fields[i].db_name); + switch (dbh->db_fields[i].db_type) + { + case 'D': + strcat(query, " date"); + break; + case 'C': + if (dbh->db_fields[i].db_flen > 1) + { + strcat(query, " varchar"); + sprintf(t, "(%d)", + dbh->db_fields[i].db_flen); + strcat(query, t); + } + else + strcat(query, " char"); + break; + case 'N': + if (dbh->db_fields[i].db_dec != 0) + strcat(query, " real"); + else + strcat(query, " int"); + break; + case 'L': + strcat(query, " char"); + break; + } } strcat(query, ")"); - if (verbose > 1) { + if (verbose > 1) + { printf("Sending create-clause\n"); printf("%s\n", query); } - if ((res = PQexec(conn, query)) == NULL) { + if ((res = PQexec(conn, query)) == NULL) + { fprintf(stderr, "Error creating table!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); - close(dbh->db_fd); - free(dbh); - free(query); - PQfinish(conn); - exit(1); + close(dbh->db_fd); + free(dbh); + free(query); + PQfinish(conn); + exit(1); } PQclear(res); @@ -300,148 +350,179 @@ void do_create(PGconn *conn, char *table, dbhead *dbh) { } /* FIXME: can be optimized to not use strcat, but it is worth the effort? */ -void do_inserts(PGconn *conn, char *table, dbhead *dbh) { - PGresult *res; - field *fields; - int i, h, result; - char *query, *foo; +void +do_inserts(PGconn *conn, char *table, dbhead * dbh) +{ + PGresult *res; + field *fields; + int i, + h, + result; + char *query, + *foo; char pgdate[10]; - if (verbose > 1) { + if (verbose > 1) printf("Inserting records\n"); - } - h = 2; /* 2 because of terminating \n\0 */ + h = 2; /* 2 because of terminating \n\0 */ - for ( i = 0 ; i < dbh->db_nfields ; i++ ) { + for (i = 0; i < dbh->db_nfields; i++) + { h += dbh->db_fields[i].db_flen > 2 ? - dbh->db_fields[i].db_flen : - 2; /* account for possible NULL values (\N) */ - h += 1; /* the delimiter */ + dbh->db_fields[i].db_flen : + 2; /* account for possible NULL values (\N) */ + h += 1; /* the delimiter */ } - /* make sure we can build the COPY query, note that we don't need to just - add this value, since the COPY query is a separate query (see below) */ - if (h < 17+strlen(table)) h = 17+strlen(table); + /* + * make sure we can build the COPY query, note that we don't need to + * just add this value, since the COPY query is a separate query (see + * below) + */ + if (h < 17 + strlen(table)) + h = 17 + strlen(table); - if (!(query = (char *)malloc(h))) { + if (!(query = (char *) malloc(h))) + { PQfinish(conn); fprintf(stderr, - "Memory allocation error in function do_inserts (query)\n"); + "Memory allocation error in function do_inserts (query)\n"); close(dbh->db_fd); free(dbh); exit(1); } - if ((fields = dbf_build_record(dbh)) == (field *)DBF_ERROR) { - fprintf(stderr, - "Couldn't allocate memory for record in do_insert\n"); + if ((fields = dbf_build_record(dbh)) == (field *) DBF_ERROR) + { + fprintf(stderr, + "Couldn't allocate memory for record in do_insert\n"); PQfinish(conn); - free(query); - dbf_close(dbh); - exit(1); - } - - if (end == 0) /* "end" is a user option, if not specified, */ - end = dbh->db_records; /* then all records are processed. */ - - if (t_block == 0) /* user not specified transaction block size */ - t_block = end-begin; /* then we set it to be the full data */ - - for (i = begin; i < end; i++) { + free(query); + dbf_close(dbh); + exit(1); + } + + if (end == 0) /* "end" is a user option, if not + * specified, */ + end = dbh->db_records; /* then all records are processed. */ + + if (t_block == 0) /* user not specified transaction block + * size */ + t_block = end - begin; /* then we set it to be the full data */ + + for (i = begin; i < end; i++) + { /* we need to start a new transaction and COPY statement */ - if (((i-begin) % t_block) == 0) { + if (((i - begin) % t_block) == 0) + { if (verbose > 1) fprintf(stderr, "Transaction: START\n"); res = PQexec(conn, "BEGIN"); - if (res == NULL) { + if (res == NULL) + { fprintf(stderr, "Error starting transaction!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); - exit(1); + exit(1); } sprintf(query, "COPY %s FROM stdin", table); res = PQexec(conn, query); - if (res == NULL) { + if (res == NULL) + { fprintf(stderr, "Error starting COPY!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); - exit(1); + exit(1); } } /* build line and submit */ - result = dbf_get_record(dbh, fields, i); - if (result == DBF_VALID) { + result = dbf_get_record(dbh, fields, i); + if (result == DBF_VALID) + { query[0] = '\0'; - for (h = 0; h < dbh->db_nfields; h++) { - if (!strlen(fields[h].db_name)) { + for (h = 0; h < dbh->db_nfields; h++) + { + if (!strlen(fields[h].db_name)) continue; - } - if (h!=0) /* not for the first field! */ - strcat(query, "\t"); /* COPY statement field separator */ + if (h != 0) /* not for the first field! */ + strcat(query, "\t"); /* COPY statement field + * separator */ - if (upper) { - strtoupper(fields[h].db_contents); - } - if (lower) { + if (upper) + strtoupper(fields[h].db_contents); + if (lower) strtolower(fields[h].db_contents); - } foo = fields[h].db_contents; #ifdef HAVE_ICONV_H - if(charset_from) + if (charset_from) foo = convert_charset(foo); #endif foo = Escape(foo); /* handle the date first - liuk */ - if(fields[h].db_type=='D') { - if((strlen(foo)==8) && isinteger(foo)) { - sprintf(pgdate,"%c%c%c%c-%c%c-%c%c", - foo[0],foo[1],foo[2],foo[3], - foo[4],foo[5],foo[6],foo[7]); - strcat(query,pgdate); - } else { - /* empty field must be inserted as NULL value in this - way */ - strcat(query,"\\N"); + if (fields[h].db_type == 'D') + { + if ((strlen(foo) == 8) && isinteger(foo)) + { + sprintf(pgdate, "%c%c%c%c-%c%c-%c%c", + foo[0], foo[1], foo[2], foo[3], + foo[4], foo[5], foo[6], foo[7]); + strcat(query, pgdate); + } + else + { + /* + * empty field must be inserted as NULL value in + * this way + */ + strcat(query, "\\N"); } } else if ((fields[h].db_type == 'N') && - (fields[h].db_dec == 0)){ - if (isinteger(foo)) { + (fields[h].db_dec == 0)) + { + if (isinteger(foo)) strcat(query, foo); - } else { + else + { strcat(query, "\\N"); if (verbose) fprintf(stderr, "Illegal numeric value found " - "in record %d, field \"%s\"\n", - i, fields[h].db_name); + "in record %d, field \"%s\"\n", + i, fields[h].db_name); } - } else { + } + else + { strcat(query, foo); /* must be character */ } } strcat(query, "\n"); - if ((verbose > 1) && (( i % 100) == 0)) {/* Only show every 100 */ - printf("Inserting record %d\n", i); /* records. */ + if ((verbose > 1) && ((i % 100) == 0)) + { /* Only show every 100 */ + printf("Inserting record %d\n", i); /* records. */ } PQputline(conn, query); } /* we need to end this copy and transaction */ - if (((i-begin) % t_block) == t_block-1) { + if (((i - begin) % t_block) == t_block - 1) + { if (verbose > 1) fprintf(stderr, "Transaction: END\n"); PQputline(conn, "\\.\n"); - if (PQendcopy(conn) != 0) { + if (PQendcopy(conn) != 0) + { fprintf(stderr, "Something went wrong while copying. Check " - "your tables!\n"); + "your tables!\n"); exit(1); } res = PQexec(conn, "END"); - if (res == NULL) { + if (res == NULL) + { fprintf(stderr, "Error committing work!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); exit(1); @@ -451,17 +532,20 @@ void do_inserts(PGconn *conn, char *table, dbhead *dbh) { /* last row copied in, end copy and transaction */ /* remember, i is now 1 greater then when we left the loop */ - if (((i-begin) % t_block) != 0) { + if (((i - begin) % t_block) != 0) + { if (verbose > 1) fprintf(stderr, "Transaction: END\n"); PQputline(conn, "\\.\n"); - if (PQendcopy(conn) != 0) { + if (PQendcopy(conn) != 0) + { fprintf(stderr, "Something went wrong while copying. Check " - "your tables!\n"); + "your tables!\n"); } res = PQexec(conn, "END"); - if (res == NULL) { + if (res == NULL) + { fprintf(stderr, "Error committing work!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); exit(1); @@ -492,7 +576,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo) { int length; char *destination; - FILE *termin, *termout; + FILE *termin, + *termout; + #ifdef HAVE_TERMIOS_H struct termios t_orig, t; @@ -505,8 +591,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) prompt_state = true; /* disable SIGINT */ /* - * Do not try to collapse these into one "w+" mode file. - * Doesn't work on some platforms (eg, HPUX 10.20). + * Do not try to collapse these into one "w+" mode file. Doesn't work + * on some platforms (eg, HPUX 10.20). */ termin = fopen("/dev/tty", "r"); termout = fopen("/dev/tty", "w"); @@ -529,7 +615,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) tcsetattr(fileno(termin), TCSAFLUSH, &t); } #endif - + if (prompt) { fputs(gettext(prompt), termout); @@ -579,19 +665,23 @@ simple_prompt(const char *prompt, int maxlen, bool echo) } -int main(int argc, char **argv) +int +main(int argc, char **argv) { - PGconn *conn; + PGconn *conn; int i; - extern int optind; - extern char *optarg; - char *query; - dbhead *dbh; + extern int optind; + extern char *optarg; + char *query; + dbhead *dbh; - while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != EOF) { - switch (i) { + while ((i = getopt(argc, argv, "DWflucvh:b:e:d:t:s:B:U:F:T:")) != EOF) + { + switch (i) + { case 'D': - if (create) { + if (create) + { usage(); printf("Can't use -c and -D at the same time!\n"); exit(1); @@ -599,32 +689,34 @@ int main(int argc, char **argv) del = 1; break; case 'W': - password=simple_prompt("Password: ",100,0); + password = simple_prompt("Password: ", 100, 0); break; case 'f': - fieldlow=1; + fieldlow = 1; break; case 'v': verbose++; break; case 'c': - if (del) { + if (del) + { usage(); printf("Can't use -c and -D at the same time!\n"); exit(1); } - create=1; + create = 1; break; case 'l': - lower=1; + lower = 1; break; case 'u': - if (lower) { + if (lower) + { usage(); printf("Can't use -u and -l at the same time!\n"); exit(1); } - upper=1; + upper = 1; break; case 'b': begin = atoi(optarg); @@ -633,28 +725,28 @@ int main(int argc, char **argv) end = atoi(optarg); break; case 'h': - host = (char *)strdup(optarg); + host = (char *) strdup(optarg); break; case 'd': - dbase = (char *)strdup(optarg); + dbase = (char *) strdup(optarg); break; case 't': - table = (char *)strdup(optarg); - break; + table = (char *) strdup(optarg); + break; case 's': - subarg = (char *)strdup(optarg); + subarg = (char *) strdup(optarg); break; case 'B': t_block = atoi(optarg); break; case 'U': - username = (char *)strdup(optarg); + username = (char *) strdup(optarg); break; case 'F': - charset_from = (char *)strdup(optarg); + charset_from = (char *) strdup(optarg); break; case 'T': - charset_to = (char *)strdup(optarg); + charset_to = (char *) strdup(optarg); break; case ':': usage(); @@ -663,7 +755,11 @@ int main(int argc, char **argv) break; case '?': usage(); - /* FIXME: Ivan thinks this is bad: printf("unknown argument: %s\n", argv[0]); */ + + /* + * FIXME: Ivan thinks this is bad: printf("unknown + * argument: %s\n", argv[0]); + */ exit(1); break; default: @@ -674,80 +770,83 @@ int main(int argc, char **argv) argc -= optind; argv = &argv[optind]; - if (argc != 1) { + if (argc != 1) + { usage(); - if(username) + if (username) free(username); - if(password) + if (password) free(password); exit(1); } #ifdef HAVE_ICONV_H - if(charset_from) + if (charset_from) { - if(verbose>1) + if (verbose > 1) printf("Setting conversion from charset \"%s\" to \"%s\".\n", - charset_from,charset_to); - iconv_d = iconv_open(charset_to,charset_from); - if(iconv_d == (iconv_t) -1) + charset_from, charset_to); + iconv_d = iconv_open(charset_to, charset_from); + if (iconv_d == (iconv_t) - 1) { printf("Cannot convert from charset \"%s\" to charset \"%s\".\n", - charset_from,charset_to); + charset_from, charset_to); exit(1); } } #endif - if (verbose > 1) { + if (verbose > 1) printf("Opening dbf-file\n"); - } - if ((dbh = dbf_open(argv[0], O_RDONLY)) == (dbhead *)-1) { + if ((dbh = dbf_open(argv[0], O_RDONLY)) == (dbhead *) - 1) + { fprintf(stderr, "Couldn't open xbase-file %s\n", argv[0]); - if(username) + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(1); } if (fieldlow) - for ( i = 0 ; i < dbh->db_nfields ; i++ ) - strtolower(dbh->db_fields[i].db_name); + for (i = 0; i < dbh->db_nfields; i++) + strtolower(dbh->db_fields[i].db_name); - if (verbose) { + if (verbose) + { printf("dbf-file: %s, PG-dbase: %s, PG-table: %s\n", argv[0], - dbase, - table); + dbase, + table); printf("Number of records: %ld\n", dbh->db_records); printf("NAME:\t\tLENGTH:\t\tTYPE:\n"); printf("-------------------------------------\n"); - for (i = 0; i < dbh->db_nfields ; i++) { - printf("%-12s\t%7d\t\t%5c\n",dbh->db_fields[i].db_name, - dbh->db_fields[i].db_flen, - dbh->db_fields[i].db_type); + for (i = 0; i < dbh->db_nfields; i++) + { + printf("%-12s\t%7d\t\t%5c\n", dbh->db_fields[i].db_name, + dbh->db_fields[i].db_flen, + dbh->db_fields[i].db_type); } } - if (verbose > 1) { + if (verbose > 1) printf("Making connection to PG-server\n"); - } - conn = PQsetdbLogin(host,NULL,NULL,NULL, dbase, username, password); - if (PQstatus(conn) != CONNECTION_OK) { + conn = PQsetdbLogin(host, NULL, NULL, NULL, dbase, username, password); + if (PQstatus(conn) != CONNECTION_OK) + { fprintf(stderr, "Couldn't get a connection with the "); fprintf(stderr, "designated host!\n"); fprintf(stderr, "Detailed report: %s\n", PQerrorMessage(conn)); close(dbh->db_fd); free(dbh); - if(username) + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(1); } @@ -756,55 +855,60 @@ int main(int argc, char **argv) do_substitute(subarg, dbh); /* create table if specified, else check if target table exists */ - if (!create) { - if (!check_table(conn, table)) { + if (!create) + { + if (!check_table(conn, table)) + { printf("Table does not exist!\n"); - if(username) + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(1); } - if (del) { - if (!(query = (char *)malloc(13 + strlen(table)))) { + if (del) + { + if (!(query = (char *) malloc(13 + strlen(table)))) + { printf("Memory-allocation error in main (delete)!\n"); close(dbh->db_fd); free(dbh); PQfinish(conn); - if(username) + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(1); } - if (verbose > 1) { + if (verbose > 1) printf("Deleting from original table\n"); - } sprintf(query, "DELETE FROM %s", table); PQexec(conn, query); free(query); } - } else { - if (!(query = (char *)malloc(12 + strlen(table)))) { + } + else + { + if (!(query = (char *) malloc(12 + strlen(table)))) + { printf("Memory-allocation error in main (drop)!\n"); close(dbh->db_fd); free(dbh); PQfinish(conn); - if(username) + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(1); } - if (verbose > 1) { + if (verbose > 1) printf("Dropping original table (if one exists)\n"); - } sprintf(query, "DROP TABLE %s", table); PQexec(conn, query); free(query); @@ -819,18 +923,17 @@ int main(int argc, char **argv) PQexec(conn, "SET DATESTYLE TO 'ISO';"); do_inserts(conn, table, dbh); - if (verbose > 1) { + if (verbose > 1) printf("Closing up....\n"); - } - close(dbh->db_fd); - free(dbh); - PQfinish(conn); - if(username) + close(dbh->db_fd); + free(dbh); + PQfinish(conn); + if (username) free(username); - if(password) + if (password) free(password); - if(charset_from) + if (charset_from) iconv_close(iconv_d); exit(0); } diff --git a/contrib/dbase/endian.c b/contrib/dbase/endian.c index 55c53d8980..5bc6a186a0 100644 --- a/contrib/dbase/endian.c +++ b/contrib/dbase/endian.c @@ -5,41 +5,45 @@ /* * routine to change little endian long to host long */ -long get_long(u_char *cp) +long +get_long(u_char *cp) { - long ret; + long ret; - ret = *cp++; - ret += ((*cp++)<<8); - ret += ((*cp++)<<16); - ret += ((*cp++)<<24); + ret = *cp++; + ret += ((*cp++) << 8); + ret += ((*cp++) << 16); + ret += ((*cp++) << 24); - return ret; + return ret; } -void put_long(u_char *cp, long lval) +void +put_long(u_char *cp, long lval) { - cp[0] = lval & 0xff; - cp[1] = (lval >> 8) & 0xff; - cp[2] = (lval >> 16) & 0xff; - cp[3] = (lval >> 24) & 0xff; + cp[0] = lval & 0xff; + cp[1] = (lval >> 8) & 0xff; + cp[2] = (lval >> 16) & 0xff; + cp[3] = (lval >> 24) & 0xff; } /* * routine to change little endian short to host short */ -short get_short(u_char *cp) +short +get_short(u_char *cp) { - short ret; + short ret; - ret = *cp++; - ret += ((*cp++)<<8); + ret = *cp++; + ret += ((*cp++) << 8); - return ret; + return ret; } -void put_short(u_char *cp, short sval) +void +put_short(u_char *cp, short sval) { - cp[0] = sval & 0xff; - cp[1] = (sval >> 8) & 0xff; + cp[0] = sval & 0xff; + cp[1] = (sval >> 8) & 0xff; } diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index e858cfd0ba..4ab1315fa7 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -4,18 +4,18 @@ * Functions returning results from a remote database * * Copyright (c) Joseph Conway <joe.conway@mail.com>, 2001; - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without a written agreement * is hereby granted, provided that the above copyright notice and this * paragraph and the following two paragraphs appear in all copies. - * + * * IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS * DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -30,29 +30,28 @@ PG_FUNCTION_INFO_V1(dblink); Datum dblink(PG_FUNCTION_ARGS) { - PGconn *conn = NULL; - PGresult *res = NULL; - dblink_results *results; - char *optstr; - char *sqlstatement; - char *curstr = "DECLARE mycursor CURSOR FOR "; - char *execstatement; - char *msg; - int ntuples = 0; - ReturnSetInfo *rsi; - - if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) { + PGconn *conn = NULL; + PGresult *res = NULL; + dblink_results *results; + char *optstr; + char *sqlstatement; + char *curstr = "DECLARE mycursor CURSOR FOR "; + char *execstatement; + char *msg; + int ntuples = 0; + ReturnSetInfo *rsi; + + if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) elog(ERROR, "dblink: NULL arguments are not permitted"); - } - if (fcinfo->resultinfo == NULL || ! IsA(fcinfo->resultinfo, ReturnSetInfo)) { + if (fcinfo->resultinfo == NULL || !IsA(fcinfo->resultinfo, ReturnSetInfo)) elog(ERROR, "dblink: function called in context that does not accept a set result"); - } optstr = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0)))); sqlstatement = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1)))); - if (fcinfo->flinfo->fn_extra == NULL) { + if (fcinfo->flinfo->fn_extra == NULL) + { conn = PQconnectdb(optstr); if (PQstatus(conn) == CONNECTION_BAD) @@ -73,13 +72,14 @@ dblink(PG_FUNCTION_ARGS) PQclear(res); execstatement = (char *) palloc(strlen(curstr) + strlen(sqlstatement) + 1); - if (execstatement != NULL) { + if (execstatement != NULL) + { strcpy(execstatement, curstr); strcat(execstatement, sqlstatement); strcat(execstatement, "\0"); - } else { - elog(ERROR, "dblink: insufficient memory" ); } + else + elog(ERROR, "dblink: insufficient memory"); res = PQexec(conn, execstatement); if (!res || (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK)) @@ -88,23 +88,27 @@ dblink(PG_FUNCTION_ARGS) PQclear(res); PQfinish(conn); elog(ERROR, "dblink: sql error: %s", msg); - } else { + } + else + { /* * got results, start fetching them */ - PQclear(res); + PQclear(res); - res = PQexec(conn, "FETCH ALL in mycursor"); - if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { + res = PQexec(conn, "FETCH ALL in mycursor"); + if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) + { msg = pstrdup(PQerrorMessage(conn)); PQclear(res); PQfinish(conn); elog(ERROR, "dblink: sql error: %s", msg); - } + } ntuples = PQntuples(res); - if (ntuples > 0) { + if (ntuples > 0) + { results = init_dblink_results(fcinfo->flinfo->fn_mcxt); results->tup_num = 0; @@ -116,44 +120,48 @@ dblink(PG_FUNCTION_ARGS) results = NULL; results = fcinfo->flinfo->fn_extra; - /* close the cursor */ - res = PQexec(conn, "CLOSE mycursor"); - PQclear(res); + /* close the cursor */ + res = PQexec(conn, "CLOSE mycursor"); + PQclear(res); - /* commit the transaction */ - res = PQexec(conn, "COMMIT"); - PQclear(res); + /* commit the transaction */ + res = PQexec(conn, "COMMIT"); + PQclear(res); - /* close the connection to the database and cleanup */ - PQfinish(conn); + /* close the connection to the database and cleanup */ + PQfinish(conn); - rsi = (ReturnSetInfo *)fcinfo->resultinfo; + rsi = (ReturnSetInfo *) fcinfo->resultinfo; rsi->isDone = ExprMultipleResult; PG_RETURN_POINTER(results); - } else { + } + else + { - PQclear(res); + PQclear(res); - /* close the cursor */ - res = PQexec(conn, "CLOSE mycursor"); - PQclear(res); + /* close the cursor */ + res = PQexec(conn, "CLOSE mycursor"); + PQclear(res); - /* commit the transaction */ - res = PQexec(conn, "COMMIT"); - PQclear(res); + /* commit the transaction */ + res = PQexec(conn, "COMMIT"); + PQclear(res); - /* close the connection to the database and cleanup */ - PQfinish(conn); + /* close the connection to the database and cleanup */ + PQfinish(conn); - rsi = (ReturnSetInfo *)fcinfo->resultinfo; - rsi->isDone = ExprEndResult ; + rsi = (ReturnSetInfo *) fcinfo->resultinfo; + rsi->isDone = ExprEndResult; PG_RETURN_NULL(); } } - } else { + } + else + { /* * check for more results */ @@ -162,29 +170,30 @@ dblink(PG_FUNCTION_ARGS) results->tup_num++; ntuples = PQntuples(results->res); - if (results->tup_num < ntuples) { - + if (results->tup_num < ntuples) + { /* * fetch them if available */ - rsi = (ReturnSetInfo *)fcinfo->resultinfo; + rsi = (ReturnSetInfo *) fcinfo->resultinfo; rsi->isDone = ExprMultipleResult; PG_RETURN_POINTER(results); - } else { - + } + else + { /* * or if no more, clean things up */ results = fcinfo->flinfo->fn_extra; - PQclear(results->res); + PQclear(results->res); - rsi = (ReturnSetInfo *)fcinfo->resultinfo; - rsi->isDone = ExprEndResult ; + rsi = (ReturnSetInfo *) fcinfo->resultinfo; + rsi->isDone = ExprEndResult; PG_RETURN_NULL(); } @@ -204,48 +213,48 @@ PG_FUNCTION_INFO_V1(dblink_tok); Datum dblink_tok(PG_FUNCTION_ARGS) { - dblink_results *results; - int fldnum; - text *result_text; - char *result; - int nfields = 0; - int text_len = 0; - - if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) { + dblink_results *results; + int fldnum; + text *result_text; + char *result; + int nfields = 0; + int text_len = 0; + + if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) elog(ERROR, "dblink: NULL arguments are not permitted"); - } results = (dblink_results *) PG_GETARG_POINTER(0); - if (results == NULL) { + if (results == NULL) elog(ERROR, "dblink: function called with invalid result pointer"); - } fldnum = PG_GETARG_INT32(1); - if (fldnum < 0) { + if (fldnum < 0) elog(ERROR, "dblink: field number < 0 not permitted"); - } nfields = PQnfields(results->res); - if (fldnum > (nfields - 1)) { + if (fldnum > (nfields - 1)) elog(ERROR, "dblink: field number %d does not exist", fldnum); - } - if (PQgetisnull(results->res, results->tup_num, fldnum) == 1) { + if (PQgetisnull(results->res, results->tup_num, fldnum) == 1) + { PG_RETURN_NULL(); - } else { + } + else + { text_len = PQgetlength(results->res, results->tup_num, fldnum); result = (char *) palloc(text_len + 1); - if (result != NULL) { + if (result != NULL) + { strcpy(result, PQgetvalue(results->res, results->tup_num, fldnum)); strcat(result, "\0"); - } else { - elog(ERROR, "dblink: insufficient memory" ); } + else + elog(ERROR, "dblink: insufficient memory"); result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result))); @@ -267,8 +276,8 @@ dblink_tok(PG_FUNCTION_ARGS) dblink_results * init_dblink_results(MemoryContext fn_mcxt) { - MemoryContext oldcontext; - dblink_results *retval; + MemoryContext oldcontext; + dblink_results *retval; oldcontext = MemoryContextSwitchTo(fn_mcxt); diff --git a/contrib/dblink/dblink.h b/contrib/dblink/dblink.h index 1b2a48e9fb..f4de437e3d 100644 --- a/contrib/dblink/dblink.h +++ b/contrib/dblink/dblink.h @@ -4,18 +4,18 @@ * Functions returning results from a remote database * * Copyright (c) Joseph Conway <joe.conway@mail.com>, 2001; - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without a written agreement * is hereby granted, provided that the above copyright notice and this * paragraph and the following two paragraphs appear in all copies. - * + * * IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS * DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -52,9 +52,9 @@ typedef struct /* * the actual query results */ - PGresult *res; + PGresult *res; -} dblink_results; +} dblink_results; /* * External declarations @@ -66,5 +66,4 @@ extern Datum dblink_tok(PG_FUNCTION_ARGS); * Internal declarations */ dblink_results *init_dblink_results(MemoryContext fn_mcxt); - #endif /* DBLINK_H */ diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c index 8fd568d720..a259e4b08b 100644 --- a/contrib/fulltextindex/fti.c +++ b/contrib/fulltextindex/fti.c @@ -6,52 +6,52 @@ #include "commands/trigger.h" /* - * Trigger function accepts variable number of arguments: + * Trigger function accepts variable number of arguments: * * 1. relation in which to store the substrings * 2. fields to extract substrings from * - * The relation in which to insert *must* have the following layout: + * The relation in which to insert *must* have the following layout: * * string varchar(#) * id oid * - * where # is the largest size of the varchar columns being indexed + * where # is the largest size of the varchar columns being indexed * * Example: * - * -- Create the SQL function based on the compiled shared object - * create function fti() returns opaque as - * '/usr/local/pgsql/lib/contrib/fti.so' language 'C'; + * -- Create the SQL function based on the compiled shared object + * create function fti() returns opaque as + * '/usr/local/pgsql/lib/contrib/fti.so' language 'C'; * - * -- Create the FTI table - * create table product_fti (string varchar(255), id oid); + * -- Create the FTI table + * create table product_fti (string varchar(255), id oid); * - * -- Create an index to assist string matches - * create index product_fti_string_idx on product_fti (string); + * -- Create an index to assist string matches + * create index product_fti_string_idx on product_fti (string); * - * -- Create an index to assist trigger'd deletes - * create index product_fti_id_idx on product_fti (id); + * -- Create an index to assist trigger'd deletes + * create index product_fti_id_idx on product_fti (id); * - * -- Create an index on the product oid column to assist joins - * -- between the fti table and the product table - * create index product_oid_idx on product (oid); + * -- Create an index on the product oid column to assist joins + * -- between the fti table and the product table + * create index product_oid_idx on product (oid); * - * -- Create the trigger to perform incremental changes to the full text index. - * create trigger product_fti_trig after update or insert or delete on product - * for each row execute procedure fti(product_fti, title, artist); - * ^^^^^^^^^^^ - * table where full text index is stored - * ^^^^^^^^^^^^^ - * columns to index in the base table + * -- Create the trigger to perform incremental changes to the full text index. + * create trigger product_fti_trig after update or insert or delete on product + * for each row execute procedure fti(product_fti, title, artist); + * ^^^^^^^^^^^ + * table where full text index is stored + * ^^^^^^^^^^^^^ + * columns to index in the base table * - * After populating 'product', try something like: + * After populating 'product', try something like: * - * SELECT DISTINCT(p.*) FROM product p, product_fti f1, product_fti f2 WHERE + * SELECT DISTINCT(p.*) FROM product p, product_fti f1, product_fti f2 WHERE * f1.string ~ '^slippery' AND f2.string ~ '^wet' AND p.oid=f1.id AND p.oid=f2.id; * - * To check that your indicies are being used correctly, make sure you - * EXPLAIN SELECT ... your test query above. + * To check that your indicies are being used correctly, make sure you + * EXPLAIN SELECT ... your test query above. * * CHANGELOG * --------- @@ -76,14 +76,14 @@ * TODO * ---- * - * prevent generating duplicate words for an oid in the fti table - * save a plan for deletes - * create a function that will make the index *after* we have populated - * the main table (probably first delete all contents to be sure there's - * nothing in it, then re-populate the fti-table) + * prevent generating duplicate words for an oid in the fti table + * save a plan for deletes + * create a function that will make the index *after* we have populated + * the main table (probably first delete all contents to be sure there's + * nothing in it, then re-populate the fti-table) * - * can we do something with operator overloading or a seperate function - * that can build the final query automatigally? + * can we do something with operator overloading or a seperate function + * that can build the final query automatigally? */ #define MAX_FTI_QUERY_LENGTH 8192 @@ -103,16 +103,15 @@ char *StopWords[] = { /* list of words to skip in indexing */ "the", "yes" }; - -#endif /* USE_STOP_WORDS */ +#endif /* USE_STOP_WORDS */ /* stuff for caching query-plans, stolen from contrib/spi/\*.c */ typedef struct { - char *ident; - int nplans; - void **splan; -} EPlan; + char *ident; + int nplans; + void **splan; +} EPlan; static EPlan *InsertPlans = NULL; static EPlan *DeletePlans = NULL; @@ -201,13 +200,11 @@ fti(PG_FUNCTION_ARGS) Oid *argtypes; Datum values[1]; EPlan *plan; - int i; + int i; snprintf(query, MAX_FTI_QUERY_LENGTH, "D%s", indexname); for (i = 1; i < nargs; i++) - { snprintf(query, MAX_FTI_QUERY_LENGTH, "%s$%s", query, args[i]); - } plan = find_plan(query, &DeletePlans, &nDeletePlans); if (plan->nplans <= 0) @@ -238,23 +235,21 @@ fti(PG_FUNCTION_ARGS) if (isinsert) { - char *substring; - char *column; - void *pplan; - Oid *argtypes; + char *substring; + char *column; + void *pplan; + Oid *argtypes; Datum values[2]; int colnum; - struct varlena *data; - EPlan *plan; - int i; - char *buff; - char *string; + struct varlena *data; + EPlan *plan; + int i; + char *buff; + char *string; snprintf(query, MAX_FTI_QUERY_LENGTH, "I%s", indexname); for (i = 1; i < nargs; i++) - { snprintf(query, MAX_FTI_QUERY_LENGTH, "%s$%s", query, args[i]); - } plan = find_plan(query, &InsertPlans, &nInsertPlans); @@ -269,7 +264,7 @@ fti(PG_FUNCTION_ARGS) /* prepare plan to gain speed */ snprintf(query, MAX_FTI_QUERY_LENGTH, "INSERT INTO %s (string, id) VALUES ($1, $2)", - indexname); + indexname); pplan = SPI_prepare(query, 2, argtypes); if (!pplan) elog(ERROR, "Full Text Indexing: SPI_prepare: Returned NULL in insert"); @@ -303,7 +298,7 @@ fti(PG_FUNCTION_ARGS) string++; } - data = (struct varlena *) palloc(sizeof(int32) + strlen(column) + 1); + data = (struct varlena *) palloc(sizeof(int32) + strlen(column) +1); buff = palloc(strlen(column) + 1); /* saves lots of calls in while-loop and in breakup() */ @@ -348,7 +343,6 @@ breakup(char *string, char *substring) while (cur_pos > string) /* don't read before start of 'string' */ { - /* * skip pieces at the end of a string that are not alfa-numeric * (ie. 'string$%^&', last_start first points to '&', and after @@ -409,7 +403,7 @@ is_stopword(char *text) else StopHigh = StopMiddle; } -#endif /* USE_STOP_WORDS */ +#endif /* USE_STOP_WORDS */ return (false); } diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c index d6ec0f5c30..94b9e9de77 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.c +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c @@ -24,13 +24,13 @@ * documentation for any purpose, without fee, and without a written agreement * is hereby granted, provided that the above copyright notice and this * paragraph and the following two paragraphs appear in all copies. - * + * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS * DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -50,23 +50,22 @@ PG_FUNCTION_INFO_V1(levenshtein); Datum levenshtein(PG_FUNCTION_ARGS) { - char *str_s; - char *str_s0; - char *str_t; - int cols = 0; - int rows = 0; - int *u_cells; - int *l_cells; - int *tmp; - int i; - int j; + char *str_s; + char *str_s0; + char *str_t; + int cols = 0; + int rows = 0; + int *u_cells; + int *l_cells; + int *tmp; + int i; + int j; /* - * Fetch the arguments. - * str_s is referred to as the "source" - * cols = length of source + 1 to allow for the initialization column - * str_t is referred to as the "target", rows = length of target + 1 - * rows = length of target + 1 to allow for the initialization row + * Fetch the arguments. str_s is referred to as the "source" cols = + * length of source + 1 to allow for the initialization column str_t + * is referred to as the "target", rows = length of target + 1 rows = + * length of target + 1 to allow for the initialization row */ str_s = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0)))); str_t = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1)))); @@ -75,18 +74,19 @@ levenshtein(PG_FUNCTION_ARGS) rows = strlen(str_t) + 1; /* - * Restrict the length of the strings being compared to something reasonable - * because we will have to perform rows * cols calcualtions. If longer strings need to be - * compared, increase MAX_LEVENSHTEIN_STRLEN to suit (but within your tolerance for - * speed and memory usage). + * Restrict the length of the strings being compared to something + * reasonable because we will have to perform rows * cols + * calcualtions. If longer strings need to be compared, increase + * MAX_LEVENSHTEIN_STRLEN to suit (but within your tolerance for speed + * and memory usage). */ if ((cols > MAX_LEVENSHTEIN_STRLEN + 1) || (rows > MAX_LEVENSHTEIN_STRLEN + 1)) elog(ERROR, "levenshtein: Arguments may not exceed %d characters in length", MAX_LEVENSHTEIN_STRLEN); /* - * If either rows or cols is 0, the answer is the other value. - * This makes sense since it would take that many insertions - * the build a matching string + * If either rows or cols is 0, the answer is the other value. This + * makes sense since it would take that many insertions the build a + * matching string */ if (cols == 0) @@ -96,8 +96,9 @@ levenshtein(PG_FUNCTION_ARGS) PG_RETURN_INT32(cols); /* - * Allocate two vectors of integers. One will be used for the "upper" row, - * the other for the "lower" row. Initialize the "upper" row to 0..cols + * Allocate two vectors of integers. One will be used for the "upper" + * row, the other for the "lower" row. Initialize the "upper" row to + * 0..cols */ u_cells = palloc(sizeof(int) * cols); for (i = 0; i < cols; i++) @@ -106,33 +107,35 @@ levenshtein(PG_FUNCTION_ARGS) l_cells = palloc(sizeof(int) * cols); /* - * Use str_s0 to "rewind" the pointer to str_s in the nested for loop below + * Use str_s0 to "rewind" the pointer to str_s in the nested for loop + * below */ str_s0 = str_s; /* - * Loop throught the rows, starting at row 1. Row 0 is used for the initial - * "upper" row. + * Loop throught the rows, starting at row 1. Row 0 is used for the + * initial "upper" row. */ for (j = 1; j < rows; j++) { /* - * We'll always start with col 1, - * and initialize lower row col 0 to j + * We'll always start with col 1, and initialize lower row col 0 + * to j */ l_cells[0] = j; for (i = 1; i < cols; i++) { - int c = 0; - int c1 = 0; - int c2 = 0; - int c3 = 0; + int c = 0; + int c1 = 0; + int c2 = 0; + int c3 = 0; /* - * The "cost" value is 0 if the character at the current col position - * in the source string, matches the character at the current row position - * in the target string; cost is 1 otherwise. + * The "cost" value is 0 if the character at the current col + * position in the source string, matches the character at the + * current row position in the target string; cost is 1 + * otherwise. */ c = ((CHAREQ(str_s, str_t)) ? 0 : 1); @@ -152,8 +155,7 @@ levenshtein(PG_FUNCTION_ARGS) c3 = u_cells[i - 1] + c; /* - * The lower right cell is set to the minimum - * of c1, c2, c3 + * The lower right cell is set to the minimum of c1, c2, c3 */ l_cells[i] = (c1 < c2 ? c1 : c2) < c3 ? (c1 < c2 ? c1 : c2) : c3; @@ -164,8 +166,8 @@ levenshtein(PG_FUNCTION_ARGS) } /* - * Lower row now becomes the upper row, and the upper row - * gets reused as the new lower row. + * Lower row now becomes the upper row, and the upper row gets + * reused as the new lower row. */ tmp = u_cells; u_cells = l_cells; @@ -183,8 +185,8 @@ levenshtein(PG_FUNCTION_ARGS) } /* - * Because the final value (at position row, col) was swapped from - * the lower row to the upper row, that's where we'll find it. + * Because the final value (at position row, col) was swapped from the + * lower row to the upper row, that's where we'll find it. */ PG_RETURN_INT32(u_cells[cols - 1]); } @@ -199,10 +201,10 @@ Datum metaphone(PG_FUNCTION_ARGS) { int reqlen; - char *str_i; + char *str_i; size_t str_i_len; - char *metaph; - text *result_text; + char *metaph; + text *result_text; int retval; str_i = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0)))); @@ -240,7 +242,7 @@ metaphone(PG_FUNCTION_ARGS) } -/* +/* * Original code by Michael G Schwern starts here. * Code slightly modified for use as PostgreSQL * function (palloc, etc). Original includes @@ -255,26 +257,28 @@ metaphone(PG_FUNCTION_ARGS) /* Look at the current letter in the word */ #define Curr_Letter (toupper(word[w_idx])) /* Go N letters back. */ -#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0') +#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0') /* Previous letter. I dunno, should this return null on failure? */ #define Prev_Letter (Look_Back_Letter(1)) /* Look two letters down. It makes sure you don't walk off the string. */ #define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \ - : '\0') + : '\0') #define Look_Ahead_Letter(n) (toupper(Lookahead(word+w_idx, n))) - + /* Allows us to safely look ahead an arbitrary # of letters */ /* I probably could have just used strlen... */ -char Lookahead(char * word, int how_far) { - char letter_ahead = '\0'; /* null by default */ - int idx; - for(idx = 0; word[idx] != '\0' && idx < how_far; idx++); - /* Edge forward in the string... */ - - letter_ahead = word[idx]; /* idx will be either == to how_far or - * at the end of the string - */ +char +Lookahead(char *word, int how_far) +{ + char letter_ahead = '\0'; /* null by default */ + int idx; + + for (idx = 0; word[idx] != '\0' && idx < how_far; idx++); + /* Edge forward in the string... */ + + letter_ahead = word[idx]; /* idx will be either == to how_far or at + * the end of the string */ return letter_ahead; } @@ -282,29 +286,30 @@ char Lookahead(char * word, int how_far) { /* phonize one letter */ #define Phonize(c) do {(*phoned_word)[p_idx++] = c;} while (0) /* Slap a null character on the end of the phoned word */ -#define End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0) +#define End_Phoned_Word do {(*phoned_word)[p_idx] = '\0';} while (0) /* How long is the phoned word? */ #define Phone_Len (p_idx) /* Note is a letter is a 'break' in the word */ -#define Isbreak(c) (!isalpha(c)) - - -int _metaphone ( - /* IN */ - char * word, - int max_phonemes, - /* OUT */ - char ** phoned_word -) { - int w_idx = 0; /* point in the phonization we're at. */ - int p_idx = 0; /* end of the phoned phrase */ - +#define Isbreak(c) (!isalpha(c)) + + +int +_metaphone( + /* IN */ + char *word, + int max_phonemes, + /* OUT */ + char **phoned_word +) +{ + int w_idx = 0; /* point in the phonization we're at. */ + int p_idx = 0; /* end of the phoned phrase */ + /*-- Parameter checks --*/ /* - * Shouldn't be necessary, but left these here anyway - * jec Aug 3, 2001 + * Shouldn't be necessary, but left these here anyway jec Aug 3, 2001 */ /* Negative phoneme length is meaningless */ @@ -314,13 +319,16 @@ int _metaphone ( /* Empty/null string is meaningless */ if ((word == NULL) || !(strlen(word) > 0)) elog(ERROR, "metaphone: Input string length must be > 0"); - + /*-- Allocate memory for our phoned_phrase --*/ - if (max_phonemes == 0) { /* Assume largest possible */ - *phoned_word = palloc(sizeof(char) * strlen(word) + 1); + if (max_phonemes == 0) + { /* Assume largest possible */ + *phoned_word = palloc(sizeof(char) * strlen(word) +1); if (!*phoned_word) return META_ERROR; - } else { + } + else + { *phoned_word = palloc(sizeof(char) * max_phonemes + 1); if (!*phoned_word) return META_ERROR; @@ -328,62 +336,70 @@ int _metaphone ( /*-- The first phoneme has to be processed specially. --*/ /* Find our first letter */ - for( ; !isalpha(Curr_Letter); w_idx++ ) { + for (; !isalpha(Curr_Letter); w_idx++) + { /* On the off chance we were given nothing but crap... */ - if( Curr_Letter == '\0' ) { + if (Curr_Letter == '\0') + { End_Phoned_Word - return META_SUCCESS; /* For testing */ + return META_SUCCESS; /* For testing */ } - } - - switch (Curr_Letter) { - /* AE becomes E */ + } + + switch (Curr_Letter) + { + /* AE becomes E */ case 'A': - if( Next_Letter == 'E' ) { + if (Next_Letter == 'E') + { Phonize('E'); - w_idx+=2; + w_idx += 2; } /* Remember, preserve vowels at the beginning */ - else { + else + { Phonize('A'); w_idx++; } break; - /* [GKP]N becomes N */ + /* [GKP]N becomes N */ case 'G': case 'K': case 'P': - if( Next_Letter == 'N' ) { + if (Next_Letter == 'N') + { Phonize('N'); - w_idx+=2; + w_idx += 2; } break; - /* WH becomes H, - WR becomes R - W if followed by a vowel */ + + /* + * WH becomes H, WR becomes R W if followed by a vowel + */ case 'W': - if( Next_Letter == 'H' || - Next_Letter == 'R' ) + if (Next_Letter == 'H' || + Next_Letter == 'R') { - Phonize(Next_Letter); - w_idx+=2; + Phonize(Next_Letter); + w_idx += 2; } - else if ( isvowel(Next_Letter) ) { - Phonize('W'); - w_idx+=2; + else if (isvowel(Next_Letter)) + { + Phonize('W'); + w_idx += 2; } /* else ignore */ break; - /* X becomes S */ + /* X becomes S */ case 'X': Phonize('S'); w_idx++; break; - /* Vowels are kept */ - /* We did A already - case 'A': - case 'a': - */ + /* Vowels are kept */ + + /* + * We did A already case 'A': case 'a': + */ case 'E': case 'I': case 'O': @@ -395,220 +411,235 @@ int _metaphone ( /* do nothing */ break; } - - - + + + /* On to the metaphoning */ - for(; Curr_Letter != '\0' && - (max_phonemes == 0 || Phone_Len < max_phonemes); - w_idx++) { - /* How many letters to skip because an eariler encoding handled - * multiple letters */ - unsigned short int skip_letter = 0; - - - /* THOUGHT: It would be nice if, rather than having things like... - * well, SCI. For SCI you encode the S, then have to remember - * to skip the C. So the phonome SCI invades both S and C. It would - * be better, IMHO, to skip the C from the S part of the encoding. - * Hell, I'm trying it. + for (; Curr_Letter != '\0' && + (max_phonemes == 0 || Phone_Len < max_phonemes); + w_idx++) + { + /* + * How many letters to skip because an eariler encoding handled + * multiple letters */ - + unsigned short int skip_letter = 0; + + + /* + * THOUGHT: It would be nice if, rather than having things + * like... well, SCI. For SCI you encode the S, then have to + * remember to skip the C. So the phonome SCI invades both S and + * C. It would be better, IMHO, to skip the C from the S part of + * the encoding. Hell, I'm trying it. + */ + /* Ignore non-alphas */ - if( !isalpha(Curr_Letter) ) + if (!isalpha(Curr_Letter)) continue; - + /* Drop duplicates, except CC */ - if( Curr_Letter == Prev_Letter && - Curr_Letter != 'C' ) + if (Curr_Letter == Prev_Letter && + Curr_Letter != 'C') continue; - - switch (Curr_Letter) { - /* B -> B unless in MB */ + + switch (Curr_Letter) + { + /* B -> B unless in MB */ case 'B': - if( Prev_Letter != 'M' ) + if (Prev_Letter != 'M') Phonize('B'); break; - /* 'sh' if -CIA- or -CH, but not SCH, except SCHW. - * (SCHW is handled in S) - * S if -CI-, -CE- or -CY- - * dropped if -SCI-, SCE-, -SCY- (handed in S) - * else K - */ + + /* + * 'sh' if -CIA- or -CH, but not SCH, except SCHW. (SCHW + * is handled in S) S if -CI-, -CE- or -CY- dropped if + * -SCI-, SCE-, -SCY- (handed in S) else K + */ case 'C': - if( MAKESOFT(Next_Letter) ) { /* C[IEY] */ - if( After_Next_Letter == 'A' && - Next_Letter == 'I' ) { /* CIA */ + if (MAKESOFT(Next_Letter)) + { /* C[IEY] */ + if (After_Next_Letter == 'A' && + Next_Letter == 'I') + { /* CIA */ Phonize(SH); } /* SC[IEY] */ - else if ( Prev_Letter == 'S' ) { - /* Dropped */ - } - else { - Phonize('S'); + else if (Prev_Letter == 'S') + { + /* Dropped */ } + else + Phonize('S'); } - else if ( Next_Letter == 'H' ) { + else if (Next_Letter == 'H') + { #ifndef USE_TRADITIONAL_METAPHONE - if( After_Next_Letter == 'R' || - Prev_Letter == 'S' ) { /* Christ, School */ + if (After_Next_Letter == 'R' || + Prev_Letter == 'S') + { /* Christ, School */ Phonize('K'); } - else { + else Phonize(SH); - } #else Phonize(SH); #endif skip_letter++; } - else { + else Phonize('K'); - } break; - /* J if in -DGE-, -DGI- or -DGY- - * else T - */ + + /* + * J if in -DGE-, -DGI- or -DGY- else T + */ case 'D': - if( Next_Letter == 'G' && - MAKESOFT(After_Next_Letter) ) { + if (Next_Letter == 'G' && + MAKESOFT(After_Next_Letter)) + { Phonize('J'); skip_letter++; } else Phonize('T'); break; - /* F if in -GH and not B--GH, D--GH, -H--GH, -H---GH - * else dropped if -GNED, -GN, - * else dropped if -DGE-, -DGI- or -DGY- (handled in D) - * else J if in -GE-, -GI, -GY and not GG - * else K - */ + + /* + * F if in -GH and not B--GH, D--GH, -H--GH, -H---GH else + * dropped if -GNED, -GN, else dropped if -DGE-, -DGI- or + * -DGY- (handled in D) else J if in -GE-, -GI, -GY and + * not GG else K + */ case 'G': - if( Next_Letter == 'H' ) { - if( !( NOGHTOF(Look_Back_Letter(3)) || - Look_Back_Letter(4) == 'H' ) ) { + if (Next_Letter == 'H') + { + if (!(NOGHTOF(Look_Back_Letter(3)) || + Look_Back_Letter(4) == 'H')) + { Phonize('F'); skip_letter++; } - else { + else + { /* silent */ } } - else if( Next_Letter == 'N' ) { - if( Isbreak(After_Next_Letter) || - ( After_Next_Letter == 'E' && - Look_Ahead_Letter(3) == 'D' ) ) { + else if (Next_Letter == 'N') + { + if (Isbreak(After_Next_Letter) || + (After_Next_Letter == 'E' && + Look_Ahead_Letter(3) == 'D')) + { /* dropped */ } else Phonize('K'); } - else if( MAKESOFT(Next_Letter) && - Prev_Letter != 'G' ) { + else if (MAKESOFT(Next_Letter) && + Prev_Letter != 'G') Phonize('J'); - } - else { + else Phonize('K'); - } break; - /* H if before a vowel and not after C,G,P,S,T */ + /* H if before a vowel and not after C,G,P,S,T */ case 'H': - if( isvowel(Next_Letter) && - !AFFECTH(Prev_Letter) ) + if (isvowel(Next_Letter) && + !AFFECTH(Prev_Letter)) Phonize('H'); break; - /* dropped if after C - * else K - */ + + /* + * dropped if after C else K + */ case 'K': - if( Prev_Letter != 'C' ) + if (Prev_Letter != 'C') Phonize('K'); break; - /* F if before H - * else P - */ + + /* + * F if before H else P + */ case 'P': - if( Next_Letter == 'H' ) { + if (Next_Letter == 'H') Phonize('F'); - } - else { + else Phonize('P'); - } break; - /* K - */ + + /* + * K + */ case 'Q': Phonize('K'); break; - /* 'sh' in -SH-, -SIO- or -SIA- or -SCHW- - * else S - */ + + /* + * 'sh' in -SH-, -SIO- or -SIA- or -SCHW- else S + */ case 'S': - if( Next_Letter == 'I' && - ( After_Next_Letter == 'O' || - After_Next_Letter == 'A' ) ) { + if (Next_Letter == 'I' && + (After_Next_Letter == 'O' || + After_Next_Letter == 'A')) Phonize(SH); - } - else if ( Next_Letter == 'H' ) { + else if (Next_Letter == 'H') + { Phonize(SH); skip_letter++; } #ifndef USE_TRADITIONAL_METAPHONE - else if ( Next_Letter == 'C' && - Look_Ahead_Letter(2) == 'H' && - Look_Ahead_Letter(3) == 'W' ) { + else if (Next_Letter == 'C' && + Look_Ahead_Letter(2) == 'H' && + Look_Ahead_Letter(3) == 'W') + { Phonize(SH); skip_letter += 2; } #endif - else { + else Phonize('S'); - } break; - /* 'sh' in -TIA- or -TIO- - * else 'th' before H - * else T - */ + + /* + * 'sh' in -TIA- or -TIO- else 'th' before H else T + */ case 'T': - if( Next_Letter == 'I' && - ( After_Next_Letter == 'O' || - After_Next_Letter == 'A' ) ) { + if (Next_Letter == 'I' && + (After_Next_Letter == 'O' || + After_Next_Letter == 'A')) Phonize(SH); - } - else if ( Next_Letter == 'H' ) { + else if (Next_Letter == 'H') + { Phonize(TH); skip_letter++; } - else { + else Phonize('T'); - } break; - /* F */ + /* F */ case 'V': Phonize('F'); break; - /* W before a vowel, else dropped */ + /* W before a vowel, else dropped */ case 'W': - if( isvowel(Next_Letter) ) + if (isvowel(Next_Letter)) Phonize('W'); break; - /* KS */ + /* KS */ case 'X': Phonize('K'); Phonize('S'); break; - /* Y if followed by a vowel */ + /* Y if followed by a vowel */ case 'Y': - if( isvowel(Next_Letter) ) + if (isvowel(Next_Letter)) Phonize('Y'); break; - /* S */ + /* S */ case 'Z': Phonize('S'); break; - /* No transformation */ + /* No transformation */ case 'F': case 'J': case 'L': @@ -620,15 +651,15 @@ int _metaphone ( default: /* nothing */ break; - } /* END SWITCH */ - + } /* END SWITCH */ + w_idx += skip_letter; - } /* END FOR */ - + } /* END FOR */ + End_Phoned_Word; - - return(META_SUCCESS); -} /* END metaphone */ + + return (META_SUCCESS); +} /* END metaphone */ /* diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.h b/contrib/fuzzystrmatch/fuzzystrmatch.h index 9a9be1e9a0..9c53981843 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.h +++ b/contrib/fuzzystrmatch/fuzzystrmatch.h @@ -24,13 +24,13 @@ * documentation for any purpose, without fee, and without a written agreement * is hereby granted, provided that the above copyright notice and this * paragraph and the following two paragraphs appear in all copies. - * + * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS * DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -88,7 +88,7 @@ static const char *soundex_table = "01230120022455012623010202"; */ #define MAX_METAPHONE_STRLEN 255 -/* +/* * Original code by Michael G Schwern starts here. * Code slightly modified for use as PostgreSQL * function (combined *.h into here). @@ -96,26 +96,26 @@ static const char *soundex_table = "01230120022455012623010202"; /************************************************************************** metaphone -- Breaks english phrases down into their phonemes. - + Input - word -- An english word to be phonized - max_phonemes -- How many phonemes to calculate. If 0, then it + word -- An english word to be phonized + max_phonemes -- How many phonemes to calculate. If 0, then it will phonize the entire phrase. - phoned_word -- The final phonized word. (We'll allocate the + phoned_word -- The final phonized word. (We'll allocate the memory.) Output error -- A simple error flag, returns TRUE or FALSE - - NOTES: ALL non-alpha characters are ignored, this includes whitespace, + + NOTES: ALL non-alpha characters are ignored, this includes whitespace, although non-alpha characters will break up phonemes. ****************************************************************************/ /************************************************************************** my constants -- constants I like - + Probably redundant. - + ***************************************************************************/ #define META_ERROR FALSE @@ -123,22 +123,23 @@ static const char *soundex_table = "01230120022455012623010202"; #define META_FAILURE FALSE -/* I add modifications to the traditional metaphone algorithm that you +/* I add modifications to the traditional metaphone algorithm that you might find in books. Define this if you want metaphone to behave traditionally */ #undef USE_TRADITIONAL_METAPHONE /* Special encodings */ -#define SH 'X' +#define SH 'X' #define TH '0' -char Lookahead(char * word, int how_far); -int _metaphone ( - /* IN */ - char * word, - int max_phonemes, - /* OUT */ - char ** phoned_word +char Lookahead(char *word, int how_far); +int +_metaphone( + /* IN */ + char *word, + int max_phonemes, + /* OUT */ + char **phoned_word ); /* Metachar.h ... little bits about characters for metaphone */ @@ -146,9 +147,9 @@ int _metaphone ( /*-- Character encoding array & accessing macros --*/ /* Stolen directly out of the book... */ -char _codes[26] = { - 1,16,4,16,9,2,4,16,9,2,0,2,2,2,1,4,0,2,4,4,1,0,0,0,8,0 -/* a b c d e f g h i j k l m n o p q r s t u v w x y z */ +char _codes[26] = { + 1, 16, 4, 16, 9, 2, 4, 16, 9, 2, 0, 2, 2, 2, 1, 4, 0, 2, 4, 4, 1, 0, 0, 0, 8, 0 +/* a b c d e f g h i j k l m n o p q r s t u v w x y z */ }; @@ -157,16 +158,15 @@ char _codes[26] = { #define isvowel(c) (ENCODE(c) & 1) /* AEIOU */ /* These letters are passed through unchanged */ -#define NOCHANGE(c) (ENCODE(c) & 2) /* FJMNR */ +#define NOCHANGE(c) (ENCODE(c) & 2) /* FJMNR */ /* These form dipthongs when preceding H */ -#define AFFECTH(c) (ENCODE(c) & 4) /* CGPST */ +#define AFFECTH(c) (ENCODE(c) & 4) /* CGPST */ /* These make C and G soft */ -#define MAKESOFT(c) (ENCODE(c) & 8) /* EIY */ +#define MAKESOFT(c) (ENCODE(c) & 8) /* EIY */ /* These prevent GH from becoming F */ -#define NOGHTOF(c) (ENCODE(c) & 16) /* BDH */ - +#define NOGHTOF(c) (ENCODE(c) & 16) /* BDH */ #endif /* FUZZYSTRMATCH_H */ diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c index 1dcdc35850..431756e9a7 100644 --- a/contrib/lo/lo.c +++ b/contrib/lo/lo.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for managed LargeObjects. * - * $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.8 2001/03/22 03:59:09 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.9 2001/10/25 05:49:19 momjian Exp $ * */ @@ -33,8 +33,8 @@ typedef Oid Blob; */ Blob *lo_in(char *str); /* Create from String */ -char *lo_out(Blob * addr);/* Output oid as String */ -Oid lo_oid(Blob * addr);/* Return oid as an oid */ +char *lo_out(Blob * addr); /* Output oid as String */ +Oid lo_oid(Blob * addr); /* Return oid as an oid */ Blob *lo(Oid oid); /* Return Blob based on oid */ Datum lo_manage(PG_FUNCTION_ARGS); /* Trigger handler */ @@ -64,7 +64,6 @@ lo_in(char *str) } else { - /* * There is no Oid passed, so create a new one */ @@ -140,7 +139,7 @@ lo_manage(PG_FUNCTION_ARGS) TupleDesc tupdesc; /* Tuple Descriptor */ HeapTuple rettuple; /* Tuple to be returned */ bool isdelete; /* are we deleting? */ - HeapTuple newtuple = NULL;/* The new value for tuple */ + HeapTuple newtuple = NULL; /* The new value for tuple */ HeapTuple trigtuple; /* The original value of tuple */ if (!CALLED_AS_TRIGGER(fcinfo)) diff --git a/contrib/mSQL-interface/mpgsql.c b/contrib/mSQL-interface/mpgsql.c index 5b35fe1638..8b59485471 100644 --- a/contrib/mSQL-interface/mpgsql.c +++ b/contrib/mSQL-interface/mpgsql.c @@ -229,7 +229,7 @@ msqlGetSequenceInfo(int a, char *b) { } -m_field * +m_field * msqlFetchField(m_result * mr) { m_field *m = (m_field *) mr->fieldCursor; @@ -242,7 +242,7 @@ msqlFetchField(m_result * mr) return NULL; } -m_result * +m_result * msqlListDBs(int a) { m_result *m; @@ -256,7 +256,7 @@ msqlListDBs(int a) return NULL; } -m_result * +m_result * msqlListTables(int a) { m_result *m; @@ -272,13 +272,13 @@ msqlListTables(int a) return NULL; } -m_result * +m_result * msqlListFields(int a, char *b) { } -m_result * +m_result * msqlListIndex(int a, char *b, char *c) { m_result *m; @@ -294,7 +294,7 @@ msqlListIndex(int a, char *b, char *c) return NULL; } -m_result * +m_result * msqlStoreResult(void) { if (queryres) diff --git a/contrib/miscutil/misc_utils.h b/contrib/miscutil/misc_utils.h index f4577f49de..0fb07012df 100644 --- a/contrib/miscutil/misc_utils.h +++ b/contrib/miscutil/misc_utils.h @@ -6,5 +6,4 @@ int unlisten(char *relname); int max(int x, int y); int min(int x, int y); int active_listeners(text *relname); - #endif diff --git a/contrib/pg_controldata/pg_controldata.c b/contrib/pg_controldata/pg_controldata.c index bf7209cb29..1cbd352caf 100644 --- a/contrib/pg_controldata/pg_controldata.c +++ b/contrib/pg_controldata/pg_controldata.c @@ -6,7 +6,7 @@ * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001; * licence: BSD * - * $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.4 2001/09/06 10:49:29 petere Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.5 2001/10/25 05:49:19 momjian Exp $ */ #include "postgres.h" @@ -24,7 +24,7 @@ dbState(DBState state) { switch (state) { - case DB_STARTUP: + case DB_STARTUP: return "STARTUP"; case DB_SHUTDOWNED: return "SHUTDOWNED"; diff --git a/contrib/pg_dumplo/lo_export.c b/contrib/pg_dumplo/lo_export.c index ef62549791..adb216fee2 100644 --- a/contrib/pg_dumplo/lo_export.c +++ b/contrib/pg_dumplo/lo_export.c @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------------- * pg_dumplo * - * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.7 2001/03/22 06:16:06 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.8 2001/10/25 05:49:19 momjian Exp $ * * Karel Zak 1999-2000 * ------------------------------------------------------------------------- @@ -32,14 +32,14 @@ load_lolist(LODumpMaster * pgLO) int i; int n; - /* + /* * Now find any candidate tables who have columns of type oid. * * NOTE: System tables including pg_largeobject will be ignored. * Otherwise we'd end up dumping all LOs, referenced or not. * - * NOTE: the system oid column is ignored, as it has attnum < 1. - * This shouldn't matter for correctness, but it saves time. + * NOTE: the system oid column is ignored, as it has attnum < 1. This + * shouldn't matter for correctness, but it saves time. */ pgLO->res = PQexec(pgLO->conn, "SELECT c.relname, a.attname " @@ -107,8 +107,7 @@ pglo_export(LODumpMaster * pgLO) for (ll = pgLO->lolist; ll->lo_table != NULL; ll++) { - - /* + /* * Query: find the LOs referenced by this column */ sprintf(Qbuff, "SELECT DISTINCT l.loid FROM \"%s\" x, pg_largeobject l WHERE x.\"%s\" = l.loid", diff --git a/contrib/pg_dumplo/lo_import.c b/contrib/pg_dumplo/lo_import.c index a75e905be1..aec2aa0cee 100644 --- a/contrib/pg_dumplo/lo_import.c +++ b/contrib/pg_dumplo/lo_import.c @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------------- * pg_dumplo * - * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.5 2001/03/22 06:16:06 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.6 2001/10/25 05:49:19 momjian Exp $ * * Karel Zak 1999-2000 * ------------------------------------------------------------------------- @@ -50,7 +50,7 @@ pglo_import(LODumpMaster * pgLO) sprintf(lo_path, "%s/%s", pgLO->space, path); - /* + /* * Import LO */ if ((new_oid = lo_import(pgLO->conn, lo_path)) == 0) @@ -78,7 +78,7 @@ pglo_import(LODumpMaster * pgLO) pgLO->counter++; - /* + /* * UPDATE oid in tab */ sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u", diff --git a/contrib/pg_dumplo/main.c b/contrib/pg_dumplo/main.c index 211753b605..45f5dc6312 100644 --- a/contrib/pg_dumplo/main.c +++ b/contrib/pg_dumplo/main.c @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------------- * pg_dumplo * - * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.8 2001/03/22 06:16:06 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.9 2001/10/25 05:49:19 momjian Exp $ * * Karel Zak 1999-2000 * ------------------------------------------------------------------------- @@ -152,7 +152,7 @@ main(int argc, char **argv) exit(RE_ERROR); } - /* + /* * Check space */ if (!pgLO->space && !pgLO->action == ACTION_SHOW) @@ -170,7 +170,7 @@ main(int argc, char **argv) exit(RE_ERROR); } - /* + /* * Make connection */ pgLO->conn = PQsetdbLogin(pgLO->host, NULL, NULL, NULL, pgLO->db, @@ -186,7 +186,7 @@ main(int argc, char **argv) pgLO->user = PQuser(pgLO->conn); - /* + /* * Init index file */ if (pgLO->action != ACTION_SHOW) @@ -304,7 +304,6 @@ usage() "-q run quietly\n" "-w not dump, but show all LO in DB\n" ); /* puts() */ - #endif puts( diff --git a/contrib/pg_dumplo/pg_dumplo.h b/contrib/pg_dumplo/pg_dumplo.h index 3ab25495cb..1c76cfb624 100644 --- a/contrib/pg_dumplo/pg_dumplo.h +++ b/contrib/pg_dumplo/pg_dumplo.h @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------------- * pg_dumplo * - * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.4 2001/03/22 03:59:10 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.5 2001/10/25 05:49:19 momjian Exp $ * * Karel Zak 1999-2000 * ------------------------------------------------------------------------- @@ -64,11 +64,11 @@ typedef struct typedef enum { - ACTION_NONE, - ACTION_SHOW, - ACTION_EXPORT_ATTR, - ACTION_EXPORT_ALL, - ACTION_IMPORT + ACTION_NONE, + ACTION_SHOW, + ACTION_EXPORT_ATTR, + ACTION_EXPORT_ALL, + ACTION_IMPORT } PGLODUMP_ACTIONS; extern char *progname; @@ -78,5 +78,4 @@ extern void index_file(LODumpMaster * pgLO); extern void load_lolist(LODumpMaster * pgLO); extern void pglo_export(LODumpMaster * pgLO); extern void pglo_import(LODumpMaster * pgLO); - #endif /* PG_DUMPLO_H */ diff --git a/contrib/pg_resetxlog/pg_resetxlog.c b/contrib/pg_resetxlog/pg_resetxlog.c index 20db41ccf4..b6981345e2 100644 --- a/contrib/pg_resetxlog/pg_resetxlog.c +++ b/contrib/pg_resetxlog/pg_resetxlog.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.7 2001/10/25 00:55:48 momjian Exp $ + * $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.8 2001/10/25 05:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -147,7 +147,6 @@ ReadControlFile(void) if ((fd = open(ControlFilePath, O_RDONLY)) < 0) { - /* * If pg_control is not there at all, or we can't read it, the * odds are we've been handed a bad DataDir path, so give up. User @@ -412,7 +411,6 @@ CheckControlVersion0(char *buffer, int len) (char *) malloc(_INTL_MAXLOGRECSZ)); if (record == NULL) { - /* * We have to guess at the checkpoint contents. */ @@ -493,7 +491,7 @@ ReadRecordV0(XLogRecPtr *RecPtr, char *buffer) readFile = XLogFileOpen(readId, readSeg); if (readFile < 0) goto next_record_is_invalid; - readOff = (uint32) (-1);/* force read to occur below */ + readOff = (uint32) (-1); /* force read to occur below */ } targetPageOff = ((RecPtr->xrecoff % XLogSegSize) / BLCKSZ) * BLCKSZ; @@ -617,7 +615,6 @@ GuessControlValues(void) { #ifdef USE_LOCALE char *localeptr; - #endif /* diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 5fc18fe688..c8aa0c14b7 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.11 2001/10/24 08:07:22 ishii Exp $ + * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.12 2001/10/25 05:49:19 momjian Exp $ * * pgbench: a simple TPC-B like benchmark program for PostgreSQL * written by Tatsuo Ishii @@ -39,7 +39,6 @@ /* for getrlimit */ #include <sys/resource.h> - #endif /* WIN32 */ /******************************************************************** @@ -67,7 +66,8 @@ int tps = 1; int remains; /* number of remained clients */ -int is_connect; /* establish connection for each transactoin */ +int is_connect; /* establish connection for each + * transactoin */ char *pghost = ""; char *pgport = NULL; @@ -107,31 +107,32 @@ getrand(int min, int max) } /* set up a connection to the backend */ -static PGconn *doConnect() +static PGconn * +doConnect() { - PGconn *con; - - con = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, - login, pwd); - if (con == NULL) - { - fprintf(stderr, "Connection to database '%s' failed.\n", dbName); - fprintf(stderr, "Memory allocatin problem?\n"); - return(NULL); - } - - if (PQstatus(con) == CONNECTION_BAD) - { - fprintf(stderr, "Connection to database '%s' failed.\n", dbName); - - if (PQerrorMessage(con)) - fprintf(stderr, "%s", PQerrorMessage(con)); - else - fprintf(stderr, "No explanation from the backend\n"); + PGconn *con; + + con = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, + login, pwd); + if (con == NULL) + { + fprintf(stderr, "Connection to database '%s' failed.\n", dbName); + fprintf(stderr, "Memory allocatin problem?\n"); + return (NULL); + } + + if (PQstatus(con) == CONNECTION_BAD) + { + fprintf(stderr, "Connection to database '%s' failed.\n", dbName); + + if (PQerrorMessage(con)) + fprintf(stderr, "%s", PQerrorMessage(con)); + else + fprintf(stderr, "No explanation from the backend\n"); - return(NULL); - } - return (con); + return (NULL); + } + return (con); } /* throw away response from backend */ @@ -162,7 +163,7 @@ check(CState * state, PGresult *res, int n, int good) st->con = NULL; return (-1); } - return (0); /* OK */ + return (0); /* OK */ } /* process a transaction */ @@ -242,8 +243,8 @@ doOne(CState * state, int n, int debug) if (is_connect) { - PQfinish(st->con); - st->con = NULL; + PQfinish(st->con); + st->con = NULL; } if (++st->cnt >= nxacts) @@ -251,8 +252,8 @@ doOne(CState * state, int n, int debug) remains--; /* I've done */ if (st->con != NULL) { - PQfinish(st->con); - st->con = NULL; + PQfinish(st->con); + st->con = NULL; } return; } @@ -267,15 +268,15 @@ doOne(CState * state, int n, int debug) if (st->con == NULL) { - if ((st->con = doConnect()) == NULL) - { - fprintf(stderr, "Client %d aborted in establishing connection.\n", - n); - remains--; /* I've aborted */ - PQfinish(st->con); - st->con = NULL; - return; - } + if ((st->con = doConnect()) == NULL) + { + fprintf(stderr, "Client %d aborted in establishing connection.\n", + n); + remains--; /* I've aborted */ + PQfinish(st->con); + st->con = NULL; + return; + } } switch (st->state) @@ -358,8 +359,8 @@ doSelectOnly(CState * state, int n, int debug) if (is_connect) { - PQfinish(st->con); - st->con = NULL; + PQfinish(st->con); + st->con = NULL; } if (++st->cnt >= nxacts) @@ -367,8 +368,8 @@ doSelectOnly(CState * state, int n, int debug) remains--; /* I've done */ if (st->con != NULL) { - PQfinish(st->con); - st->con = NULL; + PQfinish(st->con); + st->con = NULL; } return; } @@ -383,15 +384,15 @@ doSelectOnly(CState * state, int n, int debug) if (st->con == NULL) { - if ((st->con = doConnect()) == NULL) - { - fprintf(stderr, "Client %d aborted in establishing connection.\n", - n); - remains--; /* I've aborted */ - PQfinish(st->con); - st->con = NULL; - return; - } + if ((st->con = doConnect()) == NULL) + { + fprintf(stderr, "Client %d aborted in establishing connection.\n", + n); + remains--; /* I've aborted */ + PQfinish(st->con); + st->con = NULL; + return; + } } switch (st->state) @@ -450,7 +451,7 @@ init() int i; if ((con = doConnect()) == NULL) - exit(1); + exit(1); for (i = 0; i < (sizeof(DDLs) / sizeof(char *)); i++) { @@ -532,29 +533,30 @@ init() if (j % 10000 == 0) { /* - * every 10000 tuples, we commit the copy command. - * this should avoid generating too much WAL logs + * every 10000 tuples, we commit the copy command. this should + * avoid generating too much WAL logs */ fprintf(stderr, "%d tuples done.\n", j); if (PQputline(con, "\\.\n")) { - fprintf(stderr, "very last PQputline failed\n"); - exit(1); + fprintf(stderr, "very last PQputline failed\n"); + exit(1); } if (PQendcopy(con)) { - fprintf(stderr, "PQendcopy failed\n"); - exit(1); + fprintf(stderr, "PQendcopy failed\n"); + exit(1); } + /* * do a checkpoint to purge the old WAL logs */ res = PQexec(con, "checkpoint"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "%s", PQerrorMessage(con)); - exit(1); + fprintf(stderr, "%s", PQerrorMessage(con)); + exit(1); } } } @@ -634,7 +636,6 @@ main(int argc, char **argv) #ifndef __CYGWIN__ struct rlimit rlim; - #endif PGconn *con; @@ -691,9 +692,9 @@ main(int argc, char **argv) } #endif /* #ifndef __CYGWIN__ */ break; - case 'C': - is_connect = 1; - break; + case 'C': + is_connect = 1; + break; case 's': tps = atoi(optarg); if (tps <= 0) @@ -734,7 +735,7 @@ main(int argc, char **argv) if (is_init_mode) { - init(); + init(); exit(0); } @@ -749,7 +750,7 @@ main(int argc, char **argv) /* opening connection... */ con = doConnect(); if (con == NULL) - exit(1); + exit(1); if (PQstatus(con) == CONNECTION_BAD) { @@ -836,12 +837,12 @@ main(int argc, char **argv) if (is_connect == 0) { - /* make connections to the database */ - for (i = 0; i < nclients; i++) - { - if ((state[i].con = doConnect()) == NULL) - exit(1); - } + /* make connections to the database */ + for (i = 0; i < nclients; i++) + { + if ((state[i].con = doConnect()) == NULL) + exit(1); + } } /* time after connections set up */ diff --git a/contrib/pgcrypto/blf.c b/contrib/pgcrypto/blf.c index 28d44d9de9..aae5b6033a 100644 --- a/contrib/pgcrypto/blf.c +++ b/contrib/pgcrypto/blf.c @@ -11,15 +11,15 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Niels Provos. + * must display the following acknowledgement: + * This product includes software developed by Niels Provos. * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -46,338 +46,354 @@ #undef inline #ifdef __GNUC__ #define inline __inline -#else /* !__GNUC__ */ +#else /* !__GNUC__ */ #define inline -#endif /* !__GNUC__ */ +#endif /* !__GNUC__ */ /* Function for Feistel Networks */ -#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \ +#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \ + (s)[0x100 + (((x)>>16)&0xFF)]) \ ^ (s)[0x200 + (((x)>> 8)&0xFF)]) \ - + (s)[0x300 + ( (x) &0xFF)]) + + (s)[0x300 + ( (x) &0xFF)]) #define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n]) void -Blowfish_encipher(blf_ctx *c, uint32 *x) +Blowfish_encipher(blf_ctx * c, uint32 *x) { - uint32 Xl; - uint32 Xr; - uint32 *s = c->S[0]; - uint32 *p = c->P; + uint32 Xl; + uint32 Xr; + uint32 *s = c->S[0]; + uint32 *p = c->P; Xl = x[0]; Xr = x[1]; Xl ^= p[0]; - BLFRND(s, p, Xr, Xl, 1); BLFRND(s, p, Xl, Xr, 2); - BLFRND(s, p, Xr, Xl, 3); BLFRND(s, p, Xl, Xr, 4); - BLFRND(s, p, Xr, Xl, 5); BLFRND(s, p, Xl, Xr, 6); - BLFRND(s, p, Xr, Xl, 7); BLFRND(s, p, Xl, Xr, 8); - BLFRND(s, p, Xr, Xl, 9); BLFRND(s, p, Xl, Xr, 10); - BLFRND(s, p, Xr, Xl, 11); BLFRND(s, p, Xl, Xr, 12); - BLFRND(s, p, Xr, Xl, 13); BLFRND(s, p, Xl, Xr, 14); - BLFRND(s, p, Xr, Xl, 15); BLFRND(s, p, Xl, Xr, 16); + BLFRND(s, p, Xr, Xl, 1); + BLFRND(s, p, Xl, Xr, 2); + BLFRND(s, p, Xr, Xl, 3); + BLFRND(s, p, Xl, Xr, 4); + BLFRND(s, p, Xr, Xl, 5); + BLFRND(s, p, Xl, Xr, 6); + BLFRND(s, p, Xr, Xl, 7); + BLFRND(s, p, Xl, Xr, 8); + BLFRND(s, p, Xr, Xl, 9); + BLFRND(s, p, Xl, Xr, 10); + BLFRND(s, p, Xr, Xl, 11); + BLFRND(s, p, Xl, Xr, 12); + BLFRND(s, p, Xr, Xl, 13); + BLFRND(s, p, Xl, Xr, 14); + BLFRND(s, p, Xr, Xl, 15); + BLFRND(s, p, Xl, Xr, 16); x[0] = Xr ^ p[17]; x[1] = Xl; } void -Blowfish_decipher(blf_ctx *c, uint32 *x) +Blowfish_decipher(blf_ctx * c, uint32 *x) { - uint32 Xl; - uint32 Xr; - uint32 *s = c->S[0]; - uint32 *p = c->P; + uint32 Xl; + uint32 Xr; + uint32 *s = c->S[0]; + uint32 *p = c->P; Xl = x[0]; Xr = x[1]; Xl ^= p[17]; - BLFRND(s, p, Xr, Xl, 16); BLFRND(s, p, Xl, Xr, 15); - BLFRND(s, p, Xr, Xl, 14); BLFRND(s, p, Xl, Xr, 13); - BLFRND(s, p, Xr, Xl, 12); BLFRND(s, p, Xl, Xr, 11); - BLFRND(s, p, Xr, Xl, 10); BLFRND(s, p, Xl, Xr, 9); - BLFRND(s, p, Xr, Xl, 8); BLFRND(s, p, Xl, Xr, 7); - BLFRND(s, p, Xr, Xl, 6); BLFRND(s, p, Xl, Xr, 5); - BLFRND(s, p, Xr, Xl, 4); BLFRND(s, p, Xl, Xr, 3); - BLFRND(s, p, Xr, Xl, 2); BLFRND(s, p, Xl, Xr, 1); + BLFRND(s, p, Xr, Xl, 16); + BLFRND(s, p, Xl, Xr, 15); + BLFRND(s, p, Xr, Xl, 14); + BLFRND(s, p, Xl, Xr, 13); + BLFRND(s, p, Xr, Xl, 12); + BLFRND(s, p, Xl, Xr, 11); + BLFRND(s, p, Xr, Xl, 10); + BLFRND(s, p, Xl, Xr, 9); + BLFRND(s, p, Xr, Xl, 8); + BLFRND(s, p, Xl, Xr, 7); + BLFRND(s, p, Xr, Xl, 6); + BLFRND(s, p, Xl, Xr, 5); + BLFRND(s, p, Xr, Xl, 4); + BLFRND(s, p, Xl, Xr, 3); + BLFRND(s, p, Xr, Xl, 2); + BLFRND(s, p, Xl, Xr, 1); x[0] = Xr ^ p[0]; x[1] = Xl; } void -Blowfish_initstate(blf_ctx *c) +Blowfish_initstate(blf_ctx * c) { /* P-box and S-box tables initialized with digits of Pi */ const blf_ctx initstate = - { { - { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, - 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, - 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, - 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, - 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, - 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, - 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, - 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, - 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, - 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, - 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a}, - { - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, - 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, - 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, - 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, - 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, - 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, - 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, - 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, - 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, - 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, - 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, - 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, - 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, - 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, - 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, - 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, - 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, - 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, - 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, - 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, - 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, - 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7}, - { - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, - 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, - 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, - 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, - 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, - 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, - 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, - 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, - 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, - 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, - 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, - 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0}, - { - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, - 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, - 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, - 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, - 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, - 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, - 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, - 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, - 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, - 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, - 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6} + {{ + { + 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, + 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, + 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, + 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, + 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, + 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, + 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, + 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, + 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, + 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, + 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, + 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, + 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, + 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, + 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, + 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, + 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, + 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, + 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, + 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, + 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, + 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, + 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, + 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, + 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, + 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, + 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, + 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, + 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, + 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, + 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, + 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, + 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, + 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, + 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, + 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, + 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, + 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, + 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, + 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, + 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, + 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, + 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a}, + { + 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, + 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, + 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, + 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, + 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, + 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, + 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, + 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, + 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, + 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, + 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, + 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, + 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, + 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, + 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, + 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, + 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, + 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, + 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, + 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, + 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, + 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, + 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, + 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, + 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, + 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, + 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, + 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, + 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, + 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, + 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, + 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, + 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, + 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, + 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, + 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, + 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, + 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, + 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, + 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, + 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, + 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, + 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7}, + { + 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, + 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, + 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, + 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, + 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, + 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, + 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, + 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, + 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, + 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, + 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, + 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, + 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, + 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, + 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, + 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, + 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, + 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, + 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, + 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, + 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, + 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, + 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, + 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, + 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, + 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, + 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, + 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, + 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, + 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, + 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, + 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, + 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, + 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, + 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, + 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, + 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, + 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, + 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, + 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, + 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, + 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, + 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0}, + { + 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, + 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, + 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, + 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, + 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, + 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, + 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, + 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, + 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, + 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, + 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, + 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, + 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, + 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, + 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, + 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, + 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, + 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, + 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, + 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, + 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, + 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, + 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, + 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, + 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, + 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, + 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, + 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, + 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, + 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, + 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, + 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, + 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, + 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, + 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, + 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, + 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, + 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, + 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, + 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, + 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, + 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, + 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6} }, { 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, @@ -385,7 +401,7 @@ Blowfish_initstate(blf_ctx *c) 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b - } }; + }}; *c = initstate; @@ -394,14 +410,15 @@ Blowfish_initstate(blf_ctx *c) uint32 Blowfish_stream2word(const uint8 *data, uint16 databytes, uint16 *current) { - uint8 i; - uint16 j; - uint32 temp; + uint8 i; + uint16 j; + uint32 temp; temp = 0x00000000; j = *current; - for (i = 0; i < 4; i++, j++) { + for (i = 0; i < 4; i++, j++) + { if (j >= databytes) j = 0; temp = (temp << 8) | data[j]; @@ -412,16 +429,17 @@ Blowfish_stream2word(const uint8 *data, uint16 databytes, uint16 *current) } void -Blowfish_expand0state(blf_ctx *c, const uint8 *key, uint16 keybytes) +Blowfish_expand0state(blf_ctx * c, const uint8 *key, uint16 keybytes) { - uint16 i; - uint16 j; - uint16 k; - uint32 temp; - uint32 data[2]; + uint16 i; + uint16 j; + uint16 k; + uint32 temp; + uint32 data[2]; j = 0; - for (i = 0; i < BLF_N + 2; i++) { + for (i = 0; i < BLF_N + 2; i++) + { /* Extract 4 int8 to 1 int32 from keystream */ temp = Blowfish_stream2word(key, keybytes, &j); c->P[i] = c->P[i] ^ temp; @@ -430,15 +448,18 @@ Blowfish_expand0state(blf_ctx *c, const uint8 *key, uint16 keybytes) j = 0; data[0] = 0x00000000; data[1] = 0x00000000; - for (i = 0; i < BLF_N + 2; i += 2) { + for (i = 0; i < BLF_N + 2; i += 2) + { Blowfish_encipher(c, data); c->P[i] = data[0]; c->P[i + 1] = data[1]; } - for (i = 0; i < 4; i++) { - for (k = 0; k < 256; k += 2) { + for (i = 0; i < 4; i++) + { + for (k = 0; k < 256; k += 2) + { Blowfish_encipher(c, data); c->S[i][k] = data[0]; @@ -449,17 +470,18 @@ Blowfish_expand0state(blf_ctx *c, const uint8 *key, uint16 keybytes) void -Blowfish_expandstate(blf_ctx *c, const uint8 *data, uint16 databytes, - const uint8 *key, uint16 keybytes) +Blowfish_expandstate(blf_ctx * c, const uint8 *data, uint16 databytes, + const uint8 *key, uint16 keybytes) { - uint16 i; - uint16 j; - uint16 k; - uint32 temp; - uint32 d[2]; + uint16 i; + uint16 j; + uint16 k; + uint32 temp; + uint32 d[2]; j = 0; - for (i = 0; i < BLF_N + 2; i++) { + for (i = 0; i < BLF_N + 2; i++) + { /* Extract 4 int8 to 1 int32 from keystream */ temp = Blowfish_stream2word(key, keybytes, &j); c->P[i] = c->P[i] ^ temp; @@ -468,7 +490,8 @@ Blowfish_expandstate(blf_ctx *c, const uint8 *data, uint16 databytes, j = 0; d[0] = 0x00000000; d[1] = 0x00000000; - for (i = 0; i < BLF_N + 2; i += 2) { + for (i = 0; i < BLF_N + 2; i += 2) + { d[0] ^= Blowfish_stream2word(data, databytes, &j); d[1] ^= Blowfish_stream2word(data, databytes, &j); Blowfish_encipher(c, d); @@ -477,9 +500,11 @@ Blowfish_expandstate(blf_ctx *c, const uint8 *data, uint16 databytes, c->P[i + 1] = d[1]; } - for (i = 0; i < 4; i++) { - for (k = 0; k < 256; k += 2) { - d[0]^= Blowfish_stream2word(data, databytes, &j); + for (i = 0; i < 4; i++) + { + for (k = 0; k < 256; k += 2) + { + d[0] ^= Blowfish_stream2word(data, databytes, &j); d[1] ^= Blowfish_stream2word(data, databytes, &j); Blowfish_encipher(c, d); @@ -491,7 +516,7 @@ Blowfish_expandstate(blf_ctx *c, const uint8 *data, uint16 databytes, } void -blf_key(blf_ctx *c, const uint8 *k, uint16 len) +blf_key(blf_ctx * c, const uint8 *k, uint16 len) { /* Initalize S-boxes and subkeys with Pi */ Blowfish_initstate(c); @@ -501,38 +526,43 @@ blf_key(blf_ctx *c, const uint8 *k, uint16 len) } void -blf_enc(blf_ctx *c, uint32 *data, uint16 blocks) +blf_enc(blf_ctx * c, uint32 *data, uint16 blocks) { - uint32 *d; - uint16 i; + uint32 *d; + uint16 i; d = data; - for (i = 0; i < blocks; i++) { + for (i = 0; i < blocks; i++) + { Blowfish_encipher(c, d); d += 2; } } void -blf_dec(blf_ctx *c, uint32 *data, uint16 blocks) +blf_dec(blf_ctx * c, uint32 *data, uint16 blocks) { - uint32 *d; - uint16 i; + uint32 *d; + uint16 i; d = data; - for (i = 0; i < blocks; i++) { + for (i = 0; i < blocks; i++) + { Blowfish_decipher(c, d); d += 2; } } void -blf_ecb_encrypt(blf_ctx *c, uint8 *data, uint32 len) +blf_ecb_encrypt(blf_ctx * c, uint8 *data, uint32 len) { - uint32 l, r, d[2]; - uint32 i; + uint32 l, + r, + d[2]; + uint32 i; - for (i = 0; i < len; i += 8) { + for (i = 0; i < len; i += 8) + { l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]; r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]; d[0] = l; @@ -553,12 +583,15 @@ blf_ecb_encrypt(blf_ctx *c, uint8 *data, uint32 len) } void -blf_ecb_decrypt(blf_ctx *c, uint8 *data, uint32 len) +blf_ecb_decrypt(blf_ctx * c, uint8 *data, uint32 len) { - uint32 l, r, d[2]; - uint32 i; + uint32 l, + r, + d[2]; + uint32 i; - for (i = 0; i < len; i += 8) { + for (i = 0; i < len; i += 8) + { l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]; r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]; d[0] = l; @@ -579,12 +612,16 @@ blf_ecb_decrypt(blf_ctx *c, uint8 *data, uint32 len) } void -blf_cbc_encrypt(blf_ctx *c, uint8 *iv, uint8 *data, uint32 len) +blf_cbc_encrypt(blf_ctx * c, uint8 *iv, uint8 *data, uint32 len) { - uint32 l, r, d[2]; - uint32 i, j; + uint32 l, + r, + d[2]; + uint32 i, + j; - for (i = 0; i < len; i += 8) { + for (i = 0; i < len; i += 8) + { for (j = 0; j < 8; j++) data[j] ^= iv[j]; l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]; @@ -608,15 +645,19 @@ blf_cbc_encrypt(blf_ctx *c, uint8 *iv, uint8 *data, uint32 len) } void -blf_cbc_decrypt(blf_ctx *c, uint8 *iva, uint8 *data, uint32 len) +blf_cbc_decrypt(blf_ctx * c, uint8 *iva, uint8 *data, uint32 len) { - uint32 l, r, d[2]; - uint8 *iv; - uint32 i, j; + uint32 l, + r, + d[2]; + uint8 *iv; + uint32 i, + j; iv = data + len - 16; data = data + len - 8; - for (i = len - 8; i >= 8; i -= 8) { + for (i = len - 8; i >= 8; i -= 8) + { l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]; r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]; d[0] = l; diff --git a/contrib/pgcrypto/blf.h b/contrib/pgcrypto/blf.h index daf9703b77..37d4021803 100644 --- a/contrib/pgcrypto/blf.h +++ b/contrib/pgcrypto/blf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: blf.h,v 1.3 2001/05/15 02:40:35 deraadt Exp $ */ +/* $OpenBSD: blf.h,v 1.3 2001/05/15 02:40:35 deraadt Exp $ */ /* * Blowfish - a fast block cipher designed by Bruce Schneier @@ -10,15 +10,15 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Niels Provos. + * must display the following acknowledgement: + * This product includes software developed by Niels Provos. * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -42,14 +42,15 @@ * of the key affect all cipherbits. */ -#define BLF_N 16 /* Number of Subkeys */ -#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */ +#define BLF_N 16 /* Number of Subkeys */ +#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */ /* Blowfish context */ -typedef struct BlowfishContext { - uint32 S[4][256]; /* S-Boxes */ - uint32 P[BLF_N + 2]; /* Subkeys */ -} blf_ctx; +typedef struct BlowfishContext +{ + uint32 S[4][256]; /* S-Boxes */ + uint32 P[BLF_N + 2]; /* Subkeys */ +} blf_ctx; /* Raw access to customized Blowfish * blf_key is just: @@ -57,26 +58,25 @@ typedef struct BlowfishContext { * Blowfish_expand0state( state, key, keylen ) */ -void Blowfish_encipher (blf_ctx *, uint32 *); -void Blowfish_decipher (blf_ctx *, uint32 *); -void Blowfish_initstate (blf_ctx *); -void Blowfish_expand0state (blf_ctx *, const uint8 *, uint16); -void Blowfish_expandstate - (blf_ctx *, const uint8 *, uint16, const uint8 *, uint16); +void Blowfish_encipher(blf_ctx *, uint32 *); +void Blowfish_decipher(blf_ctx *, uint32 *); +void Blowfish_initstate(blf_ctx *); +void Blowfish_expand0state(blf_ctx *, const uint8 *, uint16); +void Blowfish_expandstate + (blf_ctx *, const uint8 *, uint16, const uint8 *, uint16); /* Standard Blowfish */ -void blf_key (blf_ctx *, const uint8 *, uint16); -void blf_enc (blf_ctx *, uint32 *, uint16); -void blf_dec (blf_ctx *, uint32 *, uint16); +void blf_key(blf_ctx *, const uint8 *, uint16); +void blf_enc(blf_ctx *, uint32 *, uint16); +void blf_dec(blf_ctx *, uint32 *, uint16); /* Converts uint8 to uint32 */ -uint32 Blowfish_stream2word (const uint8 *, uint16, uint16 *); +uint32 Blowfish_stream2word(const uint8 *, uint16, uint16 *); -void blf_ecb_encrypt (blf_ctx *, uint8 *, uint32); -void blf_ecb_decrypt (blf_ctx *, uint8 *, uint32); - -void blf_cbc_encrypt (blf_ctx *, uint8 *, uint8 *, uint32); -void blf_cbc_decrypt (blf_ctx *, uint8 *, uint8 *, uint32); +void blf_ecb_encrypt(blf_ctx *, uint8 *, uint32); +void blf_ecb_decrypt(blf_ctx *, uint8 *, uint32); +void blf_cbc_encrypt(blf_ctx *, uint8 *, uint8 *, uint32); +void blf_cbc_decrypt(blf_ctx *, uint8 *, uint8 *, uint32); #endif diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index d60807f241..3bc8e19fa9 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -57,10 +57,11 @@ typedef unsigned int BF_word; typedef BF_word BF_key[BF_N + 2]; -typedef struct { - BF_word S[4][0x100]; - BF_key P; -} BF_ctx; +typedef struct +{ + BF_word S[4][0x100]; + BF_key P; +} BF_ctx; /* * Magic IV for 64 Blowfish encryptions that we do at the end. @@ -347,7 +348,7 @@ static BF_ctx BF_init_state = { }; static unsigned char BF_itoa64[64 + 1] = - "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; +"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; static unsigned char BF_atoi64[0x60] = { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1, @@ -367,22 +368,30 @@ do { \ (dst) = tmp; \ } while (0) -static int BF_decode(BF_word *dst, const char *src, int size) +static int +BF_decode(BF_word * dst, const char *src, int size) { - unsigned char *dptr = (unsigned char *)dst; + unsigned char *dptr = (unsigned char *) dst; unsigned char *end = dptr + size; - unsigned char *sptr = (unsigned char *)src; - unsigned int tmp, c1, c2, c3, c4; - - do { + unsigned char *sptr = (unsigned char *) src; + unsigned int tmp, + c1, + c2, + c3, + c4; + + do + { BF_safe_atoi64(c1, *sptr++); BF_safe_atoi64(c2, *sptr++); *dptr++ = (c1 << 2) | ((c2 & 0x30) >> 4); - if (dptr >= end) break; + if (dptr >= end) + break; BF_safe_atoi64(c3, *sptr++); *dptr++ = ((c2 & 0x0F) << 4) | ((c3 & 0x3C) >> 2); - if (dptr >= end) break; + if (dptr >= end) + break; BF_safe_atoi64(c4, *sptr++); *dptr++ = ((c3 & 0x03) << 6) | c4; @@ -391,18 +400,22 @@ static int BF_decode(BF_word *dst, const char *src, int size) return 0; } -static void BF_encode(char *dst, const BF_word *src, int size) +static void +BF_encode(char *dst, const BF_word * src, int size) { - unsigned char *sptr = (unsigned char *)src; + unsigned char *sptr = (unsigned char *) src; unsigned char *end = sptr + size; - unsigned char *dptr = (unsigned char *)dst; - unsigned int c1, c2; + unsigned char *dptr = (unsigned char *) dst; + unsigned int c1, + c2; - do { + do + { c1 = *sptr++; *dptr++ = BF_itoa64[c1 >> 2]; c1 = (c1 & 0x03) << 4; - if (sptr >= end) { + if (sptr >= end) + { *dptr++ = BF_itoa64[c1]; break; } @@ -411,7 +424,8 @@ static void BF_encode(char *dst, const BF_word *src, int size) c1 |= c2 >> 4; *dptr++ = BF_itoa64[c1]; c1 = (c2 & 0x0f) << 2; - if (sptr >= end) { + if (sptr >= end) + { *dptr++ = BF_itoa64[c1]; break; } @@ -423,18 +437,20 @@ static void BF_encode(char *dst, const BF_word *src, int size) } while (sptr < end); } -static void BF_swap(BF_word *x, int count) +static void +BF_swap(BF_word * x, int count) { - static int endianness_check = 1; - char *is_little_endian = (char *)&endianness_check; - BF_word tmp; + static int endianness_check = 1; + char *is_little_endian = (char *) &endianness_check; + BF_word tmp; if (*is_little_endian) - do { - tmp = *x; - tmp = (tmp << 16) | (tmp >> 16); - *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF); - } while (--count); + do + { + tmp = *x; + tmp = (tmp << 16) | (tmp >> 16); + *x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF); + } while (--count); } #if BF_SCALE @@ -504,7 +520,8 @@ static void BF_swap(BF_word *x, int count) #if BF_ASM -extern void _BF_body_r(BF_ctx *ctx); +extern void _BF_body_r(BF_ctx * ctx); + #define BF_body() \ _BF_body_r(&data.ctx); @@ -527,22 +544,28 @@ extern void _BF_body_r(BF_ctx *ctx); *(ptr - 2) = L; \ *(ptr - 1) = R; \ } while (ptr < &data.ctx.S[3][0xFF]); - #endif -static void BF_set_key(const char *key, BF_key expanded, BF_key initial) +static void +BF_set_key(const char *key, BF_key expanded, BF_key initial) { const char *ptr = key; - int i, j; - BF_word tmp; + int i, + j; + BF_word tmp; - for (i = 0; i < BF_N + 2; i++) { + for (i = 0; i < BF_N + 2; i++) + { tmp = 0; - for (j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) + { tmp <<= 8; tmp |= *ptr; - if (!*ptr) ptr = key; else ptr++; + if (!*ptr) + ptr = key; + else + ptr++; } expanded[i] = tmp; @@ -550,41 +573,51 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial) } } -char *_crypt_blowfish_rn(const char *key, const char *setting, - char *output, int size) +char * +_crypt_blowfish_rn(const char *key, const char *setting, + char *output, int size) { - struct { - BF_ctx ctx; - BF_key expanded_key; - union { - BF_word salt[4]; - BF_word output[6]; - } binary; - } data; - BF_word L, R; - BF_word tmp1, tmp2, tmp3, tmp4; - BF_word *ptr; - BF_word count; - int i; - - if (size < 7 + 22 + 31 + 1) { + struct + { + BF_ctx ctx; + BF_key expanded_key; + union + { + BF_word salt[4]; + BF_word output[6]; + } binary; + } data; + BF_word L, + R; + BF_word tmp1, + tmp2, + tmp3, + tmp4; + BF_word *ptr; + BF_word count; + int i; + + if (size < 7 + 22 + 31 + 1) + { __set_errno(ERANGE); return NULL; } if (setting[0] != '$' || - setting[1] != '2' || - setting[2] != 'a' || - setting[3] != '$' || - setting[4] < '0' || setting[4] > '3' || - setting[5] < '0' || setting[5] > '9' || - setting[6] != '$') { + setting[1] != '2' || + setting[2] != 'a' || + setting[3] != '$' || + setting[4] < '0' || setting[4] > '3' || + setting[5] < '0' || setting[5] > '9' || + setting[6] != '$') + { __set_errno(EINVAL); return NULL; } - count = (BF_word)1 << ((setting[4] - '0') * 10 + (setting[5] - '0')); - if (count < 16 || BF_decode(data.binary.salt, &setting[7], 16)) { + count = (BF_word) 1 << ((setting[4] - '0') * 10 + (setting[5] - '0')); + if (count < 16 || BF_decode(data.binary.salt, &setting[7], 16)) + { memset(data.binary.salt, 0, sizeof(data.binary.salt)); __set_errno(EINVAL); return NULL; @@ -596,7 +629,8 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, memcpy(data.ctx.S, BF_init_state.S, sizeof(data.ctx.S)); L = R = 0; - for (i = 0; i < BF_N + 2; i += 2) { + for (i = 0; i < BF_N + 2; i += 2) + { L ^= data.binary.salt[i & 2]; R ^= data.binary.salt[(i & 2) + 1]; BF_ENCRYPT; @@ -605,7 +639,8 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, } ptr = data.ctx.S[0]; - do { + do + { ptr += 4; L ^= data.binary.salt[(BF_N + 2) & 3]; R ^= data.binary.salt[(BF_N + 3) & 3]; @@ -620,7 +655,8 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, *(ptr - 1) = R; } while (ptr < &data.ctx.S[3][0xFF]); - do { + do + { data.ctx.P[0] ^= data.expanded_key[0]; data.ctx.P[1] ^= data.expanded_key[1]; data.ctx.P[2] ^= data.expanded_key[2]; @@ -668,12 +704,14 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, BF_body(); } while (--count); - for (i = 0; i < 6; i += 2) { + for (i = 0; i < 6; i += 2) + { L = BF_magic_w[i]; R = BF_magic_w[i + 1]; count = 64; - do { + do + { BF_ENCRYPT; } while (--count); @@ -683,7 +721,7 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, memcpy(output, setting, 7 + 22 - 1); output[7 + 22 - 1] = BF_itoa64[(int) - BF_atoi64[(int)setting[7 + 22 - 1] - 0x20] & 0x30]; + BF_atoi64[(int) setting[7 + 22 - 1] - 0x20] & 0x30]; /* This has to be bug-compatible with the original implementation, so * only encode 23 of the 24 bytes. :-) */ @@ -698,4 +736,3 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, return output; } - diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c index de6b1865e3..eacb192ad0 100644 --- a/contrib/pgcrypto/crypt-des.c +++ b/contrib/pgcrypto/crypt-des.c @@ -244,8 +244,8 @@ des_init() } /* - * Convert the inverted S-boxes into 4 arrays of 8 bits. - * Each will handle 12 bits of the S-box input. + * Convert the inverted S-boxes into 4 arrays of 8 bits. Each will + * handle 12 bits of the S-box input. */ for (b = 0; b < 4; b++) for (i = 0; i < 64; i++) @@ -409,10 +409,9 @@ des_setkey(const char *key) && rawkey1 == old_rawkey1) { /* - * Already setup for this key. - * This optimisation fails on a zero key (which is weak and - * has bad parity anyway) in order to simplify the starting - * conditions. + * Already setup for this key. This optimisation fails on a zero + * key (which is weak and has bad parity anyway) in order to + * simplify the starting conditions. */ return (0); } @@ -420,7 +419,7 @@ des_setkey(const char *key) old_rawkey1 = rawkey1; /* - * Do key permutation and split into two 28-bit subkeys. + * Do key permutation and split into two 28-bit subkeys. */ k0 = key_perm_maskl[0][rawkey0 >> 25] | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f] @@ -438,8 +437,9 @@ des_setkey(const char *key) | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f] | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f] | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f]; + /* - * Rotate subkeys and do compression permutation. + * Rotate subkeys and do compression permutation. */ shifts = 0; for (round = 0; round < 16; round++) @@ -476,10 +476,10 @@ des_setkey(const char *key) } static int -do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) +do_des(uint32 l_in, uint32 r_in, uint32 *l_out, uint32 *r_out, int count) { /* - * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. + * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */ uint32 l, r, @@ -513,7 +513,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) } /* - * Do initial permutation (IP). + * Do initial permutation (IP). */ l = ip_maskl[0][l_in >> 24] | ip_maskl[1][(l_in >> 16) & 0xff] @@ -556,21 +556,24 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) | ((r & 0x000001f8) << 3) | ((r & 0x0000001f) << 1) | ((r & 0x80000000) >> 31); + /* - * Do salting for crypt() and friends, and - * XOR with the permuted key. + * Do salting for crypt() and friends, and XOR with the + * permuted key. */ f = (r48l ^ r48r) & saltbits; r48l ^= f ^ *kl++; r48r ^= f ^ *kr++; + /* - * Do sbox lookups (which shrink it back to 32 bits) - * and do the pbox permutation at the same time. + * Do sbox lookups (which shrink it back to 32 bits) and do + * the pbox permutation at the same time. */ f = psbox[0][m_sbox[0][r48l >> 12]] | psbox[1][m_sbox[1][r48l & 0xfff]] | psbox[2][m_sbox[2][r48r >> 12]] | psbox[3][m_sbox[3][r48r & 0xfff]]; + /* * Now that we've permuted things, complete f(). */ @@ -581,6 +584,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) r = l; l = f; } + /* * Do final permutation (inverse of IP). */ @@ -654,8 +658,8 @@ px_crypt_des(const char *key, const char *setting) /* - * Copy the key, shifting each character up by one bit - * and padding with zeros. + * Copy the key, shifting each character up by one bit and padding + * with zeros. */ q = (uint8 *) keybuf; while (q - (uint8 *) keybuf - 8) @@ -670,9 +674,8 @@ px_crypt_des(const char *key, const char *setting) if (*setting == _PASSWORD_EFMT1) { /* - * "new"-style: - * setting - underscore, 4 bytes of count, 4 bytes of salt - * key - unlimited characters + * "new"-style: setting - underscore, 4 bytes of count, 4 bytes of + * salt key - unlimited characters */ for (i = 1, count = 0L; i < 5; i++) count |= ascii_to_bin(setting[i]) << (i - 1) * 6; @@ -687,6 +690,7 @@ px_crypt_des(const char *key, const char *setting) */ if (des_cipher((uint8 *) keybuf, (uint8 *) keybuf, 0L, 1)) return (NULL); + /* * And XOR with the next 8 characters of the key. */ @@ -700,11 +704,10 @@ px_crypt_des(const char *key, const char *setting) strncpy(output, setting, 9); /* - * Double check that we weren't given a short setting. - * If we were, the above code will probably have created - * wierd values for count and salt, but we don't really care. - * Just make sure the output string doesn't have an extra - * NUL in it. + * Double check that we weren't given a short setting. If we were, + * the above code will probably have created wierd values for + * count and salt, but we don't really care. Just make sure the + * output string doesn't have an extra NUL in it. */ output[9] = '\0'; p = output + strlen(output); @@ -713,9 +716,7 @@ px_crypt_des(const char *key, const char *setting) #endif /* !DISABLE_XDES */ { /* - * "old"-style: - * setting - 2 bytes of salt - * key - up to 8 characters + * "old"-style: setting - 2 bytes of salt key - up to 8 characters */ count = 25; @@ -723,22 +724,24 @@ px_crypt_des(const char *key, const char *setting) | ascii_to_bin(setting[0]); output[0] = setting[0]; + /* - * If the encrypted password that the salt was extracted from - * is only 1 character long, the salt will be corrupted. We - * need to ensure that the output string doesn't have an extra - * NUL in it! + * If the encrypted password that the salt was extracted from is + * only 1 character long, the salt will be corrupted. We need to + * ensure that the output string doesn't have an extra NUL in it! */ output[1] = setting[1] ? setting[1] : output[0]; p = output + 2; } setup_salt(salt); + /* * Do it. */ if (do_des(0L, 0L, &r0, &r1, count)) return (NULL); + /* * Now encode the result... */ diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c index 6913826842..9c017b0e4d 100644 --- a/contrib/pgcrypto/crypt-gensalt.c +++ b/contrib/pgcrypto/crypt-gensalt.c @@ -7,7 +7,7 @@ * entirely in crypt_blowfish.c. * * Put bcrypt generator also here as crypt-blowfish.c - * may not be compiled always. -- marko + * may not be compiled always. -- marko */ #include "postgres.h" @@ -22,48 +22,55 @@ typedef unsigned int BF_word; unsigned char _crypt_itoa64[64 + 1] = - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -char *_crypt_gensalt_traditional_rn(unsigned long count, - const char *input, int size, char *output, int output_size) +char * +_crypt_gensalt_traditional_rn(unsigned long count, + const char *input, int size, char *output, int output_size) { - if (size < 2 || output_size < 2 + 1 || (count && count != 25)) { - if (output_size > 0) output[0] = '\0'; + if (size < 2 || output_size < 2 + 1 || (count && count != 25)) + { + if (output_size > 0) + output[0] = '\0'; __set_errno((output_size < 2 + 1) ? ERANGE : EINVAL); return NULL; } - output[0] = _crypt_itoa64[(unsigned int)input[0] & 0x3f]; - output[1] = _crypt_itoa64[(unsigned int)input[1] & 0x3f]; + output[0] = _crypt_itoa64[(unsigned int) input[0] & 0x3f]; + output[1] = _crypt_itoa64[(unsigned int) input[1] & 0x3f]; output[2] = '\0'; return output; } -char *_crypt_gensalt_extended_rn(unsigned long count, - const char *input, int size, char *output, int output_size) +char * +_crypt_gensalt_extended_rn(unsigned long count, + const char *input, int size, char *output, int output_size) { unsigned long value; /* Even iteration counts make it easier to detect weak DES keys from a look * at the hash, so they should be avoided */ if (size < 3 || output_size < 1 + 4 + 4 + 1 || - (count && (count > 0xffffff || !(count & 1)))) { - if (output_size > 0) output[0] = '\0'; + (count && (count > 0xffffff || !(count & 1)))) + { + if (output_size > 0) + output[0] = '\0'; __set_errno((output_size < 1 + 4 + 4 + 1) ? ERANGE : EINVAL); return NULL; } - if (!count) count = 725; + if (!count) + count = 725; output[0] = '_'; output[1] = _crypt_itoa64[count & 0x3f]; output[2] = _crypt_itoa64[(count >> 6) & 0x3f]; output[3] = _crypt_itoa64[(count >> 12) & 0x3f]; output[4] = _crypt_itoa64[(count >> 18) & 0x3f]; - value = (unsigned long)input[0] | - ((unsigned long)input[1] << 8) | - ((unsigned long)input[2] << 16); + value = (unsigned long) input[0] | + ((unsigned long) input[1] << 8) | + ((unsigned long) input[2] << 16); output[5] = _crypt_itoa64[value & 0x3f]; output[6] = _crypt_itoa64[(value >> 6) & 0x3f]; output[7] = _crypt_itoa64[(value >> 12) & 0x3f]; @@ -73,13 +80,16 @@ char *_crypt_gensalt_extended_rn(unsigned long count, return output; } -char *_crypt_gensalt_md5_rn(unsigned long count, - const char *input, int size, char *output, int output_size) +char * +_crypt_gensalt_md5_rn(unsigned long count, + const char *input, int size, char *output, int output_size) { unsigned long value; - if (size < 3 || output_size < 3 + 4 + 1 || (count && count != 1000)) { - if (output_size > 0) output[0] = '\0'; + if (size < 3 || output_size < 3 + 4 + 1 || (count && count != 1000)) + { + if (output_size > 0) + output[0] = '\0'; __set_errno((output_size < 3 + 4 + 1) ? ERANGE : EINVAL); return NULL; } @@ -87,19 +97,20 @@ char *_crypt_gensalt_md5_rn(unsigned long count, output[0] = '$'; output[1] = '1'; output[2] = '$'; - value = (unsigned long)input[0] | - ((unsigned long)input[1] << 8) | - ((unsigned long)input[2] << 16); + value = (unsigned long) input[0] | + ((unsigned long) input[1] << 8) | + ((unsigned long) input[2] << 16); output[3] = _crypt_itoa64[value & 0x3f]; output[4] = _crypt_itoa64[(value >> 6) & 0x3f]; output[5] = _crypt_itoa64[(value >> 12) & 0x3f]; output[6] = _crypt_itoa64[(value >> 18) & 0x3f]; output[7] = '\0'; - if (size >= 6 && output_size >= 3 + 4 + 4 + 1) { - value = (unsigned long)input[3] | - ((unsigned long)input[4] << 8) | - ((unsigned long)input[5] << 16); + if (size >= 6 && output_size >= 3 + 4 + 4 + 1) + { + value = (unsigned long) input[3] | + ((unsigned long) input[4] << 8) | + ((unsigned long) input[5] << 16); output[7] = _crypt_itoa64[value & 0x3f]; output[8] = _crypt_itoa64[(value >> 6) & 0x3f]; output[9] = _crypt_itoa64[(value >> 12) & 0x3f]; @@ -113,20 +124,24 @@ char *_crypt_gensalt_md5_rn(unsigned long count, static unsigned char BF_itoa64[64 + 1] = - "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; +"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; -static void BF_encode(char *dst, const BF_word *src, int size) +static void +BF_encode(char *dst, const BF_word * src, int size) { - unsigned char *sptr = (unsigned char *)src; + unsigned char *sptr = (unsigned char *) src; unsigned char *end = sptr + size; - unsigned char *dptr = (unsigned char *)dst; - unsigned int c1, c2; + unsigned char *dptr = (unsigned char *) dst; + unsigned int c1, + c2; - do { + do + { c1 = *sptr++; *dptr++ = BF_itoa64[c1 >> 2]; c1 = (c1 & 0x03) << 4; - if (sptr >= end) { + if (sptr >= end) + { *dptr++ = BF_itoa64[c1]; break; } @@ -135,7 +150,8 @@ static void BF_encode(char *dst, const BF_word *src, int size) c1 |= c2 >> 4; *dptr++ = BF_itoa64[c1]; c1 = (c2 & 0x0f) << 2; - if (sptr >= end) { + if (sptr >= end) + { *dptr++ = BF_itoa64[c1]; break; } @@ -147,17 +163,21 @@ static void BF_encode(char *dst, const BF_word *src, int size) } while (sptr < end); } -char *_crypt_gensalt_blowfish_rn(unsigned long count, - const char *input, int size, char *output, int output_size) +char * +_crypt_gensalt_blowfish_rn(unsigned long count, + const char *input, int size, char *output, int output_size) { if (size < 16 || output_size < 7 + 22 + 1 || - (count && (count < 4 || count > 31))) { - if (output_size > 0) output[0] = '\0'; + (count && (count < 4 || count > 31))) + { + if (output_size > 0) + output[0] = '\0'; __set_errno((output_size < 7 + 22 + 1) ? ERANGE : EINVAL); return NULL; } - if (!count) count = 5; + if (!count) + count = 5; output[0] = '$'; output[1] = '2'; @@ -167,9 +187,8 @@ char *_crypt_gensalt_blowfish_rn(unsigned long count, output[5] = '0' + count % 10; output[6] = '$'; - BF_encode(&output[7], (BF_word *)input, 16); + BF_encode(&output[7], (BF_word *) input, 16); output[7 + 22] = '\0'; return output; } - diff --git a/contrib/pgcrypto/crypt-md5.c b/contrib/pgcrypto/crypt-md5.c index 02fba69496..7b45bb2151 100644 --- a/contrib/pgcrypto/crypt-md5.c +++ b/contrib/pgcrypto/crypt-md5.c @@ -9,7 +9,7 @@ * $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $ * */ -/* $Id: crypt-md5.c,v 1.1 2001/08/21 01:32:01 momjian Exp $ */ +/* $Id: crypt-md5.c,v 1.2 2001/10/25 05:49:19 momjian Exp $ */ #include <postgres.h> #include "px.h" @@ -23,12 +23,9 @@ char * px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) { - static char *magic = "$1$"; /* - * This string is magic for - * this algorithm. Having - * it this way, we can get - * get better later on - */ + static char *magic = "$1$"; /* This string is magic for this + * algorithm. Having it this way, we can + * get get better later on */ static char *p; static const char *sp, *ep; @@ -43,7 +40,7 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) if (!passwd || dstlen < 120) return NULL; - + /* Refine the Salt first */ sp = salt; @@ -99,9 +96,9 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) px_md_finish(ctx, final); /* - * and now, just to make sure things don't run too fast - * On a 60 Mhz Pentium this takes 34 msec, so you would - * need 30 seconds to build a 1000 entry dictionary... + * and now, just to make sure things don't run too fast On a 60 Mhz + * Pentium this takes 34 msec, so you would need 30 seconds to build a + * 1000 entry dictionary... */ for (i = 0; i < 1000; i++) { diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c index 421f5f1739..00ff81e5b7 100644 --- a/contrib/pgcrypto/internal.c +++ b/contrib/pgcrypto/internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: internal.c,v 1.5 2001/10/15 19:12:48 tgl Exp $ + * $Id: internal.c,v 1.6 2001/10/25 05:49:19 momjian Exp $ */ @@ -61,11 +61,18 @@ static struct int_digest { char *name; void (*init) (PX_MD * h); -} int_digest_list[] = +} int_digest_list[] = + { - { "md5", init_md5 }, - { "sha1", init_sha1 }, - { NULL, NULL } + { + "md5", init_md5 + }, + { + "sha1", init_sha1 + }, + { + NULL, NULL + } }; /* MD5 */ @@ -83,7 +90,7 @@ int_md5_block_len(PX_MD * h) } static void -int_md5_update(PX_MD * h, const uint8 * data, uint dlen) +int_md5_update(PX_MD * h, const uint8 *data, uint dlen) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -99,7 +106,7 @@ int_md5_reset(PX_MD * h) } static void -int_md5_finish(PX_MD * h, uint8 * dst) +int_md5_finish(PX_MD * h, uint8 *dst) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -130,7 +137,7 @@ int_sha1_block_len(PX_MD * h) } static void -int_sha1_update(PX_MD * h, const uint8 * data, uint dlen) +int_sha1_update(PX_MD * h, const uint8 *data, uint dlen) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -146,7 +153,7 @@ int_sha1_reset(PX_MD * h) } static void -int_sha1_finish(PX_MD * h, uint8 * dst) +int_sha1_finish(PX_MD * h, uint8 *dst) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -209,22 +216,27 @@ init_sha1(PX_MD * md) #define INT_MAX_KEY (512/8) #define INT_MAX_IV (128/8) -struct int_ctx { - uint8 keybuf[INT_MAX_KEY]; - uint8 iv[INT_MAX_IV]; - union { - blf_ctx bf; +struct int_ctx +{ + uint8 keybuf[INT_MAX_KEY]; + uint8 iv[INT_MAX_IV]; + union + { + blf_ctx bf; rijndael_ctx rj; - } ctx; - uint keylen; - int is_init; - int mode; + } ctx; + uint keylen; + int is_init; + int mode; }; -static void intctx_free(PX_Cipher *c) +static void +intctx_free(PX_Cipher * c) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; - if (cx) { + struct int_ctx *cx = (struct int_ctx *) c->ptr; + + if (cx) + { memset(cx, 0, sizeof *cx); px_free(cx); } @@ -238,78 +250,88 @@ static void intctx_free(PX_Cipher *c) #define MODE_ECB 0 #define MODE_CBC 1 -static uint rj_block_size(PX_Cipher *c) +static uint +rj_block_size(PX_Cipher * c) { - return 128/8; + return 128 / 8; } -static uint rj_key_size(PX_Cipher *c) +static uint +rj_key_size(PX_Cipher * c) { - return 256/8; + return 256 / 8; } -static uint rj_iv_size(PX_Cipher *c) +static uint +rj_iv_size(PX_Cipher * c) { - return 128/8; + return 128 / 8; } -static int rj_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) +static int +rj_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; + struct int_ctx *cx = (struct int_ctx *) c->ptr; - if (klen <= 128/8) - cx->keylen = 128/8; - else if (klen <= 192/8) - cx->keylen = 192/8; - else if (klen <= 256/8) - cx->keylen = 256/8; + if (klen <= 128 / 8) + cx->keylen = 128 / 8; + else if (klen <= 192 / 8) + cx->keylen = 192 / 8; + else if (klen <= 256 / 8) + cx->keylen = 256 / 8; else return -1; memcpy(&cx->keybuf, key, klen); if (iv) - memcpy(cx->iv, iv, 128/8); + memcpy(cx->iv, iv, 128 / 8); return 0; } -static int rj_real_init(struct int_ctx *cx, int dir) +static int +rj_real_init(struct int_ctx * cx, int dir) { - aes_set_key(&cx->ctx.rj, cx->keybuf, cx->keylen*8, dir); + aes_set_key(&cx->ctx.rj, cx->keybuf, cx->keylen * 8, dir); return 0; } -static int rj_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +static int +rj_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; - - if (!cx->is_init) { + struct int_ctx *cx = (struct int_ctx *) c->ptr; + + if (!cx->is_init) + { if (rj_real_init(cx, 1)) return -1; } - + if (dlen == 0) return 0; - if ((dlen & 15) || (((unsigned)res) & 3)) + if ((dlen & 15) || (((unsigned) res) & 3)) return -1; memcpy(res, data, dlen); - if (cx->mode == MODE_CBC) { + if (cx->mode == MODE_CBC) + { aes_cbc_encrypt(&cx->ctx.rj, cx->iv, res, dlen); memcpy(cx->iv, res + dlen - 16, 16); - } else + } + else aes_ecb_encrypt(&cx->ctx.rj, res, dlen); - + return 0; } -static int rj_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +static int +rj_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; - + struct int_ctx *cx = (struct int_ctx *) c->ptr; + if (!cx->is_init) if (rj_real_init(cx, 0)) return -1; @@ -317,17 +339,19 @@ static int rj_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) if (dlen == 0) return 0; - if ((dlen & 15) || (((unsigned)res) & 3)) + if ((dlen & 15) || (((unsigned) res) & 3)) return -1; memcpy(res, data, dlen); - if (cx->mode == MODE_CBC) { + if (cx->mode == MODE_CBC) + { aes_cbc_decrypt(&cx->ctx.rj, cx->iv, res, dlen); memcpy(cx->iv, data + dlen - 16, 16); - } else + } + else aes_ecb_decrypt(&cx->ctx.rj, res, dlen); - + return 0; } @@ -335,11 +359,12 @@ static int rj_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) * initializers */ -static PX_Cipher * rj_load(int mode) +static PX_Cipher * +rj_load(int mode) { - PX_Cipher *c; + PX_Cipher *c; struct int_ctx *cx; - + c = px_alloc(sizeof *c); memset(c, 0, sizeof *c); @@ -363,24 +388,28 @@ static PX_Cipher * rj_load(int mode) * blowfish */ -static uint bf_block_size(PX_Cipher *c) +static uint +bf_block_size(PX_Cipher * c) { return 8; } -static uint bf_key_size(PX_Cipher *c) +static uint +bf_key_size(PX_Cipher * c) { return BLF_MAXKEYLEN; } -static uint bf_iv_size(PX_Cipher *c) +static uint +bf_iv_size(PX_Cipher * c) { return 8; } -static int bf_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) +static int +bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; + struct int_ctx *cx = (struct int_ctx *) c->ptr; blf_key(&cx->ctx.bf, key, klen); if (iv) @@ -389,55 +418,60 @@ static int bf_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) return 0; } -static int bf_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +static int +bf_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; + struct int_ctx *cx = (struct int_ctx *) c->ptr; if (dlen == 0) return 0; - - if ((dlen & 7) || (((unsigned)res) & 3)) + + if ((dlen & 7) || (((unsigned) res) & 3)) return -1; memcpy(res, data, dlen); - switch (cx->mode) { - case MODE_ECB: - blf_ecb_encrypt(&cx->ctx.bf, res, dlen); - break; - case MODE_CBC: - blf_cbc_encrypt(&cx->ctx.bf, cx->iv, res, dlen); - memcpy(cx->iv, res + dlen - 8, 8); + switch (cx->mode) + { + case MODE_ECB: + blf_ecb_encrypt(&cx->ctx.bf, res, dlen); + break; + case MODE_CBC: + blf_cbc_encrypt(&cx->ctx.bf, cx->iv, res, dlen); + memcpy(cx->iv, res + dlen - 8, 8); } return 0; } -static int bf_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +static int +bf_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - struct int_ctx *cx = (struct int_ctx *)c->ptr; + struct int_ctx *cx = (struct int_ctx *) c->ptr; if (dlen == 0) return 0; - if ((dlen & 7) || (((unsigned)res) & 3)) + if ((dlen & 7) || (((unsigned) res) & 3)) return -1; memcpy(res, data, dlen); - switch (cx->mode) { - case MODE_ECB: - blf_ecb_decrypt(&cx->ctx.bf, res, dlen); - break; - case MODE_CBC: - blf_cbc_decrypt(&cx->ctx.bf, cx->iv, res, dlen); - memcpy(cx->iv, data + dlen - 8, 8); + switch (cx->mode) + { + case MODE_ECB: + blf_ecb_decrypt(&cx->ctx.bf, res, dlen); + break; + case MODE_CBC: + blf_cbc_decrypt(&cx->ctx.bf, cx->iv, res, dlen); + memcpy(cx->iv, data + dlen - 8, 8); } return 0; } -static PX_Cipher * bf_load(int mode) +static PX_Cipher * +bf_load(int mode) { - PX_Cipher *c; + PX_Cipher *c; struct int_ctx *cx; - + c = px_alloc(sizeof *c); memset(c, 0, sizeof *c); @@ -458,47 +492,64 @@ static PX_Cipher * bf_load(int mode) /* ciphers */ -static PX_Cipher * rj_128_ecb() +static PX_Cipher * +rj_128_ecb() { return rj_load(MODE_ECB); } -static PX_Cipher * rj_128_cbc() +static PX_Cipher * +rj_128_cbc() { return rj_load(MODE_CBC); } -static PX_Cipher * bf_ecb_load() +static PX_Cipher * +bf_ecb_load() { return bf_load(MODE_ECB); } -static PX_Cipher * bf_cbc_load() +static PX_Cipher * +bf_cbc_load() { return bf_load(MODE_CBC); } -static struct { - char *name; - PX_Cipher *(*load)(void); -} int_ciphers [] = { - { "bf-cbc", bf_cbc_load }, - { "bf-ecb", bf_ecb_load }, - { "aes-128-cbc", rj_128_cbc }, - { "aes-128-ecb", rj_128_ecb }, - { NULL, NULL } +static struct +{ + char *name; + PX_Cipher *(*load) (void); +} int_ciphers[] = + +{ + { + "bf-cbc", bf_cbc_load + }, + { + "bf-ecb", bf_ecb_load + }, + { + "aes-128-cbc", rj_128_cbc + }, + { + "aes-128-ecb", rj_128_ecb + }, + { + NULL, NULL + } }; -static PX_Alias int_aliases [] = { - { "bf", "bf-cbc" }, - { "blowfish", "bf-cbc" }, - { "aes", "aes-128-cbc" }, - { "aes-ecb", "aes-128-ecb" }, - { "aes-cbc", "aes-128-cbc" }, - { "aes-128", "aes-128-cbc" }, - { "rijndael", "aes-128-cbc" }, - { "rijndael-128", "aes-128-cbc" }, - { NULL, NULL } +static PX_Alias int_aliases[] = { + {"bf", "bf-cbc"}, + {"blowfish", "bf-cbc"}, + {"aes", "aes-128-cbc"}, + {"aes-ecb", "aes-128-ecb"}, + {"aes-cbc", "aes-128-cbc"}, + {"aes-128", "aes-128-cbc"}, + {"rijndael", "aes-128-cbc"}, + {"rijndael-128", "aes-128-cbc"}, + {NULL, NULL} }; /* PUBLIC FUNCTIONS */ @@ -523,15 +574,16 @@ px_find_digest(const char *name, PX_MD ** res) } int -px_find_cipher(const char *name, PX_Cipher **res) +px_find_cipher(const char *name, PX_Cipher ** res) { - int i; - PX_Cipher *c = NULL; + int i; + PX_Cipher *c = NULL; name = px_resolve_alias(int_aliases, name); for (i = 0; int_ciphers[i].name; i++) - if (!strcmp(int_ciphers[i].name, name)) { + if (!strcmp(int_ciphers[i].name, name)) + { c = int_ciphers[i].load(); break; } @@ -542,5 +594,3 @@ px_find_cipher(const char *name, PX_Cipher **res) *res = c; return 0; } - - diff --git a/contrib/pgcrypto/md5.c b/contrib/pgcrypto/md5.c index d022d61627..4b03f19606 100644 --- a/contrib/pgcrypto/md5.c +++ b/contrib/pgcrypto/md5.c @@ -1,4 +1,4 @@ -/* $Id: md5.c,v 1.7 2001/10/25 01:29:37 momjian Exp $ */ +/* $Id: md5.c,v 1.8 2001/10/25 05:49:19 momjian Exp $ */ /* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */ /* @@ -132,7 +132,7 @@ static const uint8 md5_paddat[MD5_BUFLEN] = { static void md5_calc(uint8 *, md5_ctxt *); void -md5_init(md5_ctxt *ctxt) +md5_init(md5_ctxt * ctxt) { ctxt->md5_n = 0; ctxt->md5_i = 0; @@ -144,7 +144,7 @@ md5_init(md5_ctxt *ctxt) } void -md5_loop(md5_ctxt *ctxt, const uint8 *input, unsigned len) +md5_loop(md5_ctxt * ctxt, const uint8 *input, unsigned len) { unsigned int gap, i; @@ -173,7 +173,7 @@ md5_loop(md5_ctxt *ctxt, const uint8 *input, unsigned len) } void -md5_pad(md5_ctxt *ctxt) +md5_pad(md5_ctxt * ctxt) { unsigned int gap; @@ -215,7 +215,7 @@ md5_pad(md5_ctxt *ctxt) } void -md5_result(uint8 *digest, md5_ctxt *ctxt) +md5_result(uint8 *digest, md5_ctxt * ctxt) { /* 4 byte words */ #if BYTE_ORDER == LITTLE_ENDIAN @@ -242,11 +242,11 @@ md5_result(uint8 *digest, md5_ctxt *ctxt) } #if BYTE_ORDER == BIG_ENDIAN -static uint32 X[16]; +static uint32 X[16]; #endif static void -md5_calc(uint8 *b64, md5_ctxt *ctxt) +md5_calc(uint8 *b64, md5_ctxt * ctxt) { uint32 A = ctxt->md5_sta; uint32 B = ctxt->md5_stb; diff --git a/contrib/pgcrypto/mhash.c b/contrib/pgcrypto/mhash.c index 36d70471a9..8811232c37 100644 --- a/contrib/pgcrypto/mhash.c +++ b/contrib/pgcrypto/mhash.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mhash.c,v 1.4 2001/08/21 00:42:41 momjian Exp $ + * $Id: mhash.c,v 1.5 2001/10/25 05:49:19 momjian Exp $ */ #include <postgres.h> @@ -75,7 +75,7 @@ digest_reset(PX_MD * h) } static void -digest_update(PX_MD * h, const uint8 * data, uint dlen) +digest_update(PX_MD * h, const uint8 *data, uint dlen) { MHASH mh = (MHASH) h->p.ptr; @@ -83,7 +83,7 @@ digest_update(PX_MD * h, const uint8 * data, uint dlen) } static void -digest_finish(PX_MD * h, uint8 * dst) +digest_finish(PX_MD * h, uint8 *dst) { MHASH mh = (MHASH) h->p.ptr; uint hlen = digest_result_size(h); @@ -111,34 +111,37 @@ digest_free(PX_MD * h) /* ENCRYPT / DECRYPT */ static uint -cipher_block_size(PX_Cipher *c) +cipher_block_size(PX_Cipher * c) { - MCRYPT ctx = (MCRYPT)c->ptr; + MCRYPT ctx = (MCRYPT) c->ptr; + return mcrypt_enc_get_block_size(ctx); } static uint -cipher_key_size(PX_Cipher *c) +cipher_key_size(PX_Cipher * c) { - MCRYPT ctx = (MCRYPT)c->ptr; + MCRYPT ctx = (MCRYPT) c->ptr; + return mcrypt_enc_get_key_size(ctx); } static uint -cipher_iv_size(PX_Cipher *c) +cipher_iv_size(PX_Cipher * c) { - MCRYPT ctx = (MCRYPT)c->ptr; + MCRYPT ctx = (MCRYPT) c->ptr; + return mcrypt_enc_mode_has_iv(ctx) ? mcrypt_enc_get_iv_size(ctx) : 0; } static int -cipher_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) +cipher_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv) { - int err; - MCRYPT ctx = (MCRYPT)c->ptr; + int err; + MCRYPT ctx = (MCRYPT) c->ptr; - err = mcrypt_generic_init(ctx, (char *)key, klen, (char*)iv); + err = mcrypt_generic_init(ctx, (char *) key, klen, (char *) iv); if (err < 0) elog(ERROR, "mcrypt_generic_init error: %s", mcrypt_strerror(err)); @@ -147,10 +150,10 @@ cipher_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) } static int -cipher_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +cipher_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - int err; - MCRYPT ctx = (MCRYPT)c->ptr; + int err; + MCRYPT ctx = (MCRYPT) c->ptr; memcpy(res, data, dlen); @@ -161,10 +164,10 @@ cipher_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) } static int -cipher_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +cipher_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - int err; - MCRYPT ctx = (MCRYPT)c->ptr; + int err; + MCRYPT ctx = (MCRYPT) c->ptr; memcpy(res, data, dlen); @@ -176,15 +179,15 @@ cipher_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) static void -cipher_free(PX_Cipher *c) +cipher_free(PX_Cipher * c) { - MCRYPT ctx = (MCRYPT)c->ptr; + MCRYPT ctx = (MCRYPT) c->ptr; if (c->pstat) mcrypt_generic_end(ctx); else mcrypt_module_close(ctx); - + px_free(c); } @@ -223,33 +226,34 @@ static char *modes[] = { }; static PX_Alias aliases[] = { - {"bf", "blowfish" }, - {"3des", "tripledes" }, - {"des3", "tripledes" }, - {"aes", "rijndael-128" }, - {"rijndael", "rijndael-128" }, - {"aes-128", "rijndael-128" }, - {"aes-192", "rijndael-192" }, - {"aes-256", "rijndael-256" }, - { NULL, NULL } + {"bf", "blowfish"}, + {"3des", "tripledes"}, + {"des3", "tripledes"}, + {"aes", "rijndael-128"}, + {"rijndael", "rijndael-128"}, + {"aes-128", "rijndael-128"}, + {"aes-192", "rijndael-192"}, + {"aes-256", "rijndael-256"}, + {NULL, NULL} }; static PX_Alias mode_aliases[] = { -#if 0 /* N/A */ - { "cfb", "ncfb" }, - { "ofb", "nofb" }, - { "cfb64", "ncfb" }, +#if 0 /* N/A */ + {"cfb", "ncfb"}, + {"ofb", "nofb"}, + {"cfb64", "ncfb"}, #endif /* { "ofb64", "nofb" }, not sure it works */ - { "cfb8", "cfb" }, - { "ofb8", "ofb" }, - { NULL, NULL } + {"cfb8", "cfb"}, + {"ofb8", "ofb"}, + {NULL, NULL} }; -static int is_mode(char *s) +static int +is_mode(char *s) { - char **p; - + char **p; + if (*s >= '0' && *s <= '9') return 0; @@ -263,7 +267,7 @@ static int is_mode(char *s) /* PUBLIC FUNCTIONS */ int -px_find_digest(const char *name, PX_MD **res) +px_find_digest(const char *name, PX_MD ** res) { PX_MD *h; MHASH mh; @@ -290,19 +294,21 @@ px_find_digest(const char *name, PX_MD **res) int -px_find_cipher(const char *name, PX_Cipher **res) +px_find_cipher(const char *name, PX_Cipher ** res) { - char nbuf[PX_MAX_NAMELEN + 1]; + char nbuf[PX_MAX_NAMELEN + 1]; const char *mode = NULL; - char *p; - MCRYPT ctx; + char *p; + MCRYPT ctx; - PX_Cipher *c; + PX_Cipher *c; strcpy(nbuf, name); - - if ((p = strrchr(nbuf, '-')) != NULL) { - if (is_mode(p + 1)) { + + if ((p = strrchr(nbuf, '-')) != NULL) + { + if (is_mode(p + 1)) + { mode = p + 1; *p = 0; } @@ -310,19 +316,19 @@ px_find_cipher(const char *name, PX_Cipher **res) name = px_resolve_alias(aliases, nbuf); - if (!mode) { + if (!mode) + { mode = "cbc"; + /* - if (mcrypt_module_is_block_algorithm(name, NULL)) - mode = "cbc"; - else - mode = "stream"; - */ + * if (mcrypt_module_is_block_algorithm(name, NULL)) mode = "cbc"; + * else mode = "stream"; + */ } mode = px_resolve_alias(mode_aliases, mode); - - ctx = mcrypt_module_open((char*)name, NULL, (char*)mode, NULL); - if (ctx == (void*)MCRYPT_FAILED) + + ctx = mcrypt_module_open((char *) name, NULL, (char *) mode, NULL); + if (ctx == (void *) MCRYPT_FAILED) return -1; c = palloc(sizeof *c); @@ -339,4 +345,3 @@ px_find_cipher(const char *name, PX_Cipher **res) *res = c; return 0; } - diff --git a/contrib/pgcrypto/misc.c b/contrib/pgcrypto/misc.c index 7a3c429708..5c803c0d5b 100644 --- a/contrib/pgcrypto/misc.c +++ b/contrib/pgcrypto/misc.c @@ -33,7 +33,7 @@ #include "px-crypt.h" char px_crypt_a64[] = - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; /* 0000000000111111111122222222223333333333444444444455555555556666 */ /* 0123456789012345678901234567890123456789012345678901234567890123 */ diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c index 6b2ae9c98a..f9769b7e20 100644 --- a/contrib/pgcrypto/openssl.c +++ b/contrib/pgcrypto/openssl.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openssl.c,v 1.5 2001/09/23 04:12:44 momjian Exp $ + * $Id: openssl.c,v 1.6 2001/10/25 05:49:19 momjian Exp $ */ #include <postgres.h> @@ -60,7 +60,7 @@ digest_reset(PX_MD * h) } static void -digest_update(PX_MD * h, const uint8 * data, uint dlen) +digest_update(PX_MD * h, const uint8 *data, uint dlen) { EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr; @@ -68,7 +68,7 @@ digest_update(PX_MD * h, const uint8 * data, uint dlen) } static void -digest_finish(PX_MD * h, uint8 * dst) +digest_finish(PX_MD * h, uint8 *dst) { EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr; @@ -94,50 +94,57 @@ digest_free(PX_MD * h) */ -typedef struct { - union { - struct { - BF_KEY key; - int num; - } bf; +typedef struct +{ + union + { + struct + { + BF_KEY key; + int num; + } bf; EVP_CIPHER_CTX evp_ctx; - } u; + } u; const EVP_CIPHER *evp_ciph; - uint8 key[EVP_MAX_KEY_LENGTH]; - uint8 iv[EVP_MAX_IV_LENGTH]; - uint klen; - uint init; -} ossldata; + uint8 key[EVP_MAX_KEY_LENGTH]; + uint8 iv[EVP_MAX_IV_LENGTH]; + uint klen; + uint init; +} ossldata; /* generic EVP */ static uint -gen_evp_block_size(PX_Cipher *c) +gen_evp_block_size(PX_Cipher * c) { - ossldata *od = (ossldata *)c->ptr; + ossldata *od = (ossldata *) c->ptr; + return EVP_CIPHER_block_size(od->evp_ciph); } static uint -gen_evp_key_size(PX_Cipher *c) +gen_evp_key_size(PX_Cipher * c) { - ossldata *od = (ossldata *)c->ptr; + ossldata *od = (ossldata *) c->ptr; + return EVP_CIPHER_key_length(od->evp_ciph); } static uint -gen_evp_iv_size(PX_Cipher *c) +gen_evp_iv_size(PX_Cipher * c) { - uint ivlen; - ossldata *od = (ossldata *)c->ptr; + uint ivlen; + ossldata *od = (ossldata *) c->ptr; + ivlen = EVP_CIPHER_iv_length(od->evp_ciph); return ivlen; } static void -gen_evp_free(PX_Cipher *c) +gen_evp_free(PX_Cipher * c) { - ossldata *od = (ossldata*)c->ptr; + ossldata *od = (ossldata *) c->ptr; + memset(od, 0, sizeof(*od)); pfree(od); pfree(c); @@ -146,13 +153,14 @@ gen_evp_free(PX_Cipher *c) /* fun */ static int -gen_evp_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) +gen_evp_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv) { - ossldata *od = (ossldata*)c->ptr; - uint bs = gen_evp_block_size(c); - if (iv) { + ossldata *od = (ossldata *) c->ptr; + uint bs = gen_evp_block_size(c); + + if (iv) memcpy(od->iv, iv, bs); - } else + else memset(od->iv, 0, bs); memcpy(od->key, key, klen); od->klen = klen; @@ -161,19 +169,20 @@ gen_evp_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) } static void -_gen_init(PX_Cipher *c, int enc) +_gen_init(PX_Cipher * c, int enc) { - ossldata *od = c->ptr; - + ossldata *od = c->ptr; + od->evp_ciph->init(&od->u.evp_ctx, od->key, od->iv, enc); od->init = 1; od->u.evp_ctx.encrypt = enc; } static int -gen_evp_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +gen_evp_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + if (!od->init) _gen_init(c, 1); od->evp_ciph->do_cipher(&od->u.evp_ctx, res, data, dlen); @@ -181,9 +190,10 @@ gen_evp_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) } static int -gen_evp_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +gen_evp_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + if (!od->init) _gen_init(c, 0); od->evp_ciph->do_cipher(&od->u.evp_ctx, res, data, dlen); @@ -193,84 +203,95 @@ gen_evp_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) /* Blowfish */ static int -bf_init(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv) +bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_set_key(&od->u.bf.key, klen, key); - if (iv) { + if (iv) memcpy(od->iv, iv, BF_BLOCK); - } else + else memset(od->iv, 0, BF_BLOCK); od->u.bf.num = 0; return 0; } static int -bf_ecb_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - uint bs = gen_evp_block_size(c), i; - ossldata *od = c->ptr; + uint bs = gen_evp_block_size(c), + i; + ossldata *od = c->ptr; + for (i = 0; i < dlen / bs; i++) - BF_ecb_encrypt(data+i*bs, res+i*bs, &od->u.bf.key, BF_ENCRYPT); + BF_ecb_encrypt(data + i * bs, res + i * bs, &od->u.bf.key, BF_ENCRYPT); return 0; } static int -bf_ecb_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - uint bs = gen_evp_block_size(c), i; - ossldata *od = c->ptr; + uint bs = gen_evp_block_size(c), + i; + ossldata *od = c->ptr; + for (i = 0; i < dlen / bs; i++) - BF_ecb_encrypt(data+i*bs, res+i*bs, &od->u.bf.key, BF_DECRYPT); + BF_ecb_encrypt(data + i * bs, res + i * bs, &od->u.bf.key, BF_DECRYPT); return 0; } static int -bf_cbc_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_cbc_encrypt(data, res, dlen, &od->u.bf.key, od->iv, BF_ENCRYPT); return 0; } static int -bf_cbc_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_cbc_encrypt(data, res, dlen, &od->u.bf.key, od->iv, BF_DECRYPT); return 0; } static int -bf_cfb64_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_cfb64_encrypt(data, res, dlen, &od->u.bf.key, od->iv, - &od->u.bf.num, BF_ENCRYPT); + &od->u.bf.num, BF_ENCRYPT); return 0; } static int -bf_cfb64_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_cfb64_encrypt(data, res, dlen, &od->u.bf.key, od->iv, - &od->u.bf.num, BF_DECRYPT); + &od->u.bf.num, BF_DECRYPT); return 0; } static int -bf_ofb64_encrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_ofb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_ofb64_encrypt(data, res, dlen, &od->u.bf.key, od->iv, &od->u.bf.num); return 0; } static int -bf_ofb64_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) +bf_ofb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res) { - ossldata *od = c->ptr; + ossldata *od = c->ptr; + BF_ofb64_encrypt(data, res, dlen, &od->u.bf.key, od->iv, &od->u.bf.num); return 0; } @@ -279,14 +300,14 @@ bf_ofb64_decrypt(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res) * aliases */ -static PX_Alias ossl_aliases [] = { - { "bf", "bf-cbc" }, - { "blowfish", "bf-cbc" }, - { "blowfish-cbc", "bf-cbc" }, - { "blowfish-ecb", "bf-ecb" }, - { "blowfish-cfb", "bf-cfb" }, - { "blowfish-ofb", "bf-ofb" }, - { NULL } +static PX_Alias ossl_aliases[] = { + {"bf", "bf-cbc"}, + {"blowfish", "bf-cbc"}, + {"blowfish-cbc", "bf-cbc"}, + {"blowfish-ecb", "bf-ecb"}, + {"blowfish-cfb", "bf-cfb"}, + {"blowfish-ofb", "bf-ofb"}, + {NULL} }; /* @@ -299,19 +320,44 @@ static PX_Alias ossl_mode_aliases [] = { /* * Special handlers */ -struct { - char *name; - PX_Cipher cf; -} spec_types [] = { - { "bf-cbc", { gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, - bf_init, bf_cbc_encrypt, bf_cbc_decrypt, gen_evp_free}}, - { "bf-ecb", { gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, - bf_init, bf_ecb_encrypt, bf_ecb_decrypt, gen_evp_free}}, - { "bf-cfb", { gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, - bf_init, bf_cfb64_encrypt, bf_cfb64_decrypt, gen_evp_free}}, - { "bf-ofb", { gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, - bf_init, bf_ofb64_encrypt, bf_ofb64_decrypt, gen_evp_free}}, - { NULL } +struct +{ + char *name; + PX_Cipher cf; +} spec_types[] = + +{ + { + "bf-cbc", + { + gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, + bf_init, bf_cbc_encrypt, bf_cbc_decrypt, gen_evp_free + } + }, + { + "bf-ecb", + { + gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, + bf_init, bf_ecb_encrypt, bf_ecb_decrypt, gen_evp_free + } + }, + { + "bf-cfb", + { + gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, + bf_init, bf_cfb64_encrypt, bf_cfb64_decrypt, gen_evp_free + } + }, + { + "bf-ofb", + { + gen_evp_block_size, gen_evp_key_size, gen_evp_iv_size, + bf_init, bf_ofb64_encrypt, bf_ofb64_decrypt, gen_evp_free + } + }, + { + NULL + } }; /* @@ -322,7 +368,7 @@ static PX_Cipher gen_evp_handler = { gen_evp_init, gen_evp_encrypt, gen_evp_decrypt, gen_evp_free }; -static int px_openssl_initialized = 0; +static int px_openssl_initialized = 0; /* ATM not needed static void *o_alloc(uint s) { return px_alloc(s); } @@ -333,7 +379,7 @@ static void o_free(void *p) { px_free(p); } /* PUBLIC functions */ int -px_find_digest(const char *name, PX_MD **res) +px_find_digest(const char *name, PX_MD ** res) { const EVP_MD *md; EVP_MD_CTX *ctx; @@ -342,7 +388,7 @@ px_find_digest(const char *name, PX_MD **res) if (!px_openssl_initialized) { px_openssl_initialized = 1; - /*CRYPTO_set_mem_functions(o_alloc, o_realloc, o_free);*/ + /* CRYPTO_set_mem_functions(o_alloc, o_realloc, o_free); */ OpenSSL_add_all_algorithms(); } @@ -368,17 +414,19 @@ px_find_digest(const char *name, PX_MD **res) int -px_find_cipher(const char *name, PX_Cipher **res) +px_find_cipher(const char *name, PX_Cipher ** res) { - uint i; - PX_Cipher *c = NULL, *csrc; - ossldata *od; + uint i; + PX_Cipher *c = NULL, + *csrc; + ossldata *od; const EVP_CIPHER *evp_c; - if (!px_openssl_initialized) { + if (!px_openssl_initialized) + { px_openssl_initialized = 1; - /*CRYPTO_set_mem_functions(o_alloc, o_realloc, o_free);*/ + /* CRYPTO_set_mem_functions(o_alloc, o_realloc, o_free); */ OpenSSL_add_all_algorithms(); } @@ -390,23 +438,23 @@ px_find_cipher(const char *name, PX_Cipher **res) od = px_alloc(sizeof(*od)); memset(od, 0, sizeof(*od)); od->evp_ciph = evp_c; - + csrc = NULL; for (i = 0; spec_types[i].name; i++) - if (!strcmp(name, spec_types[i].name)) { + if (!strcmp(name, spec_types[i].name)) + { csrc = &spec_types[i].cf; break; } - + if (csrc == NULL) csrc = &gen_evp_handler; c = px_alloc(sizeof(*c)); memcpy(c, csrc, sizeof(*c)); c->ptr = od; - + *res = c; return 0; } - diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index 2bd9b21e16..a6424e61fb 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pgcrypto.c,v 1.9 2001/09/23 04:12:44 momjian Exp $ + * $Id: pgcrypto.c,v 1.10 2001/10/25 05:49:19 momjian Exp $ */ #include <postgres.h> @@ -41,7 +41,7 @@ typedef int (*PFN) (const char *name, void **res); static void * - find_provider(text * name, PFN pf, char *desc, int silent); + find_provider(text *name, PFN pf, char *desc, int silent); /* SQL function: hash(text, text) returns text */ PG_FUNCTION_INFO_V1(pg_digest); @@ -313,17 +313,21 @@ PG_FUNCTION_INFO_V1(pg_encrypt); Datum pg_encrypt(PG_FUNCTION_ARGS) { - int err; - bytea *data, *key, *res; - text *type; - PX_Combo *c; - uint dlen, klen, rlen; - + int err; + bytea *data, + *key, + *res; + text *type; + PX_Combo *c; + uint dlen, + klen, + rlen; + if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2)) PG_RETURN_NULL(); - + type = PG_GETARG_TEXT_P(2); - c = find_provider(type, (PFN)px_find_combo, "Cipher", 0); + c = find_provider(type, (PFN) px_find_combo, "Cipher", 0); data = PG_GETARG_BYTEA_P(0); key = PG_GETARG_BYTEA_P(1); @@ -341,8 +345,9 @@ pg_encrypt(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(data, 0); PG_FREE_IF_COPY(key, 1); PG_FREE_IF_COPY(type, 2); - - if (err) { + + if (err) + { pfree(res); elog(ERROR, "encrypt error: %d", err); } @@ -357,17 +362,21 @@ PG_FUNCTION_INFO_V1(pg_decrypt); Datum pg_decrypt(PG_FUNCTION_ARGS) { - int err; - bytea *data, *key, *res; - text *type; - PX_Combo *c; - uint dlen, klen, rlen; - + int err; + bytea *data, + *key, + *res; + text *type; + PX_Combo *c; + uint dlen, + klen, + rlen; + if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2)) PG_RETURN_NULL(); - + type = PG_GETARG_TEXT_P(2); - c = find_provider(type, (PFN)px_find_combo, "Cipher", 0); + c = find_provider(type, (PFN) px_find_combo, "Cipher", 0); data = PG_GETARG_BYTEA_P(0); key = PG_GETARG_BYTEA_P(1); @@ -401,18 +410,24 @@ PG_FUNCTION_INFO_V1(pg_encrypt_iv); Datum pg_encrypt_iv(PG_FUNCTION_ARGS) { - int err; - bytea *data, *key, *iv, *res; - text *type; - PX_Combo *c; - uint dlen, klen, ivlen, rlen; - + int err; + bytea *data, + *key, + *iv, + *res; + text *type; + PX_Combo *c; + uint dlen, + klen, + ivlen, + rlen; + if (PG_ARGISNULL(0) || PG_ARGISNULL(1) - || PG_ARGISNULL(2) || PG_ARGISNULL(3)) + || PG_ARGISNULL(2) || PG_ARGISNULL(3)) PG_RETURN_NULL(); - + type = PG_GETARG_TEXT_P(3); - c = find_provider(type, (PFN)px_find_combo, "Cipher", 0); + c = find_provider(type, (PFN) px_find_combo, "Cipher", 0); data = PG_GETARG_BYTEA_P(0); key = PG_GETARG_BYTEA_P(1); @@ -449,18 +464,24 @@ PG_FUNCTION_INFO_V1(pg_decrypt_iv); Datum pg_decrypt_iv(PG_FUNCTION_ARGS) { - int err; - bytea *data, *key, *iv, *res; - text *type; - PX_Combo *c; - uint dlen, klen, rlen, ivlen; - + int err; + bytea *data, + *key, + *iv, + *res; + text *type; + PX_Combo *c; + uint dlen, + klen, + rlen, + ivlen; + if (PG_ARGISNULL(0) || PG_ARGISNULL(1) - || PG_ARGISNULL(2) || PG_ARGISNULL(3)) + || PG_ARGISNULL(2) || PG_ARGISNULL(3)) PG_RETURN_NULL(); - + type = PG_GETARG_TEXT_P(3); - c = find_provider(type, (PFN)px_find_combo, "Cipher", 0); + c = find_provider(type, (PFN) px_find_combo, "Cipher", 0); data = PG_GETARG_BYTEA_P(0); key = PG_GETARG_BYTEA_P(1); @@ -480,7 +501,7 @@ pg_decrypt_iv(PG_FUNCTION_ARGS) if (err) elog(ERROR, "decrypt_iv error: %d", err); - + VARATT_SIZEP(res) = VARHDRSZ + rlen; PG_FREE_IF_COPY(data, 0); @@ -497,15 +518,15 @@ PG_FUNCTION_INFO_V1(pg_cipher_exists); Datum pg_cipher_exists(PG_FUNCTION_ARGS) { - text *arg; - PX_Combo *c; + text *arg; + PX_Combo *c; if (PG_ARGISNULL(0)) PG_RETURN_NULL(); arg = PG_GETARG_TEXT_P(0); - c = find_provider(arg, (PFN)px_find_combo, "Cipher", 1); + c = find_provider(arg, (PFN) px_find_combo, "Cipher", 1); if (c != NULL) px_combo_free(c); @@ -514,7 +535,7 @@ pg_cipher_exists(PG_FUNCTION_ARGS) static void * -find_provider(text * name, +find_provider(text *name, PFN provider_lookup, char *desc, int silent) { diff --git a/contrib/pgcrypto/pgcrypto.h b/contrib/pgcrypto/pgcrypto.h index 1b49c8d895..26d04c5dc4 100644 --- a/contrib/pgcrypto/pgcrypto.h +++ b/contrib/pgcrypto/pgcrypto.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pgcrypto.h,v 1.5 2001/09/23 04:12:44 momjian Exp $ + * $Id: pgcrypto.h,v 1.6 2001/10/25 05:49:20 momjian Exp $ */ #ifndef _PG_CRYPTO_H @@ -45,6 +45,4 @@ Datum pg_decrypt(PG_FUNCTION_ARGS); Datum pg_encrypt_iv(PG_FUNCTION_ARGS); Datum pg_decrypt_iv(PG_FUNCTION_ARGS); Datum pg_cipher_exists(PG_FUNCTION_ARGS); - #endif - diff --git a/contrib/pgcrypto/px-crypt.c b/contrib/pgcrypto/px-crypt.c index 7d767279b1..c082140808 100644 --- a/contrib/pgcrypto/px-crypt.c +++ b/contrib/pgcrypto/px-crypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: px-crypt.c,v 1.2 2001/09/23 04:12:44 momjian Exp $ + * $Id: px-crypt.c,v 1.3 2001/10/25 05:49:20 momjian Exp $ */ #include <postgres.h> @@ -38,7 +38,7 @@ static char * run_crypt_des(const char *psw, const char *salt, - char *buf, unsigned len) + char *buf, unsigned len) { char *res; @@ -51,37 +51,51 @@ run_crypt_des(const char *psw, const char *salt, static char * run_crypt_md5(const char *psw, const char *salt, - char *buf, unsigned len) + char *buf, unsigned len) { char *res; + res = px_crypt_md5(psw, salt, buf, len); return res; } static char * run_crypt_bf(const char *psw, const char *salt, - char *buf, unsigned len) + char *buf, unsigned len) { char *res; + res = _crypt_blowfish_rn(psw, salt, buf, len); return res; } static struct { - char *id; + char *id; unsigned id_len; char *(*crypt) (const char *psw, const char *salt, char *buf, unsigned len); } px_crypt_list[] = { - { "$2a$", 4, run_crypt_bf }, - { "$2$", 3, NULL }, /* N/A */ - { "$1$", 3, run_crypt_md5 }, - { "_", 1, run_crypt_des }, - { "", 0, run_crypt_des }, - { NULL, 0, NULL } + { + "$2a$", 4, run_crypt_bf + }, + { + "$2$", 3, NULL + }, /* N/A */ + { + "$1$", 3, run_crypt_md5 + }, + { + "_", 1, run_crypt_des + }, + { + "", 0, run_crypt_des + }, + { + NULL, 0, NULL + } }; char * @@ -125,41 +139,45 @@ px_crypt(const char *psw, const char *salt, * salt generators */ -struct generator { - char *name; - char *(*gen)(unsigned long count, const char *input, int size, - char *output, int output_size); - int input_len; - int def_rounds; - int min_rounds; - int max_rounds; +struct generator +{ + char *name; + char *(*gen) (unsigned long count, const char *input, int size, + char *output, int output_size); + int input_len; + int def_rounds; + int min_rounds; + int max_rounds; }; -static struct generator gen_list [] = { - { "des", _crypt_gensalt_traditional_rn, 2, 0, 0, 0 }, - { "md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0 }, - { "xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF }, - { "bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31 }, - { NULL, NULL, 0, 0, 0 } +static struct generator gen_list[] = { + {"des", _crypt_gensalt_traditional_rn, 2, 0, 0, 0}, + {"md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0}, + {"xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF}, + {"bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31}, + {NULL, NULL, 0, 0, 0} }; uint px_gen_salt(const char *salt_type, char *buf, int rounds) { - int i, res; + int i, + res; struct generator *g; - char *p; - char rbuf[16]; - - for (i = 0; gen_list[i].name; i++) { + char *p; + char rbuf[16]; + + for (i = 0; gen_list[i].name; i++) + { g = &gen_list[i]; if (strcasecmp(g->name, salt_type) != 0) continue; - if (g->def_rounds) { + if (g->def_rounds) + { if (rounds == 0) rounds = g->def_rounds; - + if (rounds < g->min_rounds || rounds > g->max_rounds) return 0; } @@ -170,10 +188,9 @@ px_gen_salt(const char *salt_type, char *buf, int rounds) p = g->gen(rounds, rbuf, g->input_len, buf, PX_MAX_SALT_LEN); memset(rbuf, 0, sizeof(rbuf)); - + return p != NULL ? strlen(p) : 0; } return 0; } - diff --git a/contrib/pgcrypto/px-crypt.h b/contrib/pgcrypto/px-crypt.h index 5edebb3d3b..7265d41491 100644 --- a/contrib/pgcrypto/px-crypt.h +++ b/contrib/pgcrypto/px-crypt.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: px-crypt.h,v 1.2 2001/09/23 04:12:44 momjian Exp $ + * $Id: px-crypt.h,v 1.3 2001/10/25 05:49:20 momjian Exp $ */ #ifndef _PX_CRYPT_H @@ -36,7 +36,7 @@ #define PX_MAX_CRYPT 128 /* max salt returned by gen_salt() */ -#define PX_MAX_SALT_LEN 128 +#define PX_MAX_SALT_LEN 128 /* default rounds for xdes salt */ /* NetBSD bin/passwd/local_passwd.c has (29 * 25)*/ @@ -58,19 +58,20 @@ unsigned px_gen_salt(const char *salt_type, char *dst, int rounds); /* misc.c */ extern void px_crypt_to64(char *s, unsigned long v, int n); extern char px_crypt_a64[]; + /* avoid conflicts with system libs */ #define _crypt_to64 px_crypt_to64 #define _crypt_a64 px_crypt_a64 /* crypt-gensalt.c */ char *_crypt_gensalt_traditional_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_extended_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_md5_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_blowfish_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); #ifndef PX_SYSTEM_CRYPT @@ -85,8 +86,7 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, char *px_crypt_des(const char *key, const char *setting); /* crypt-md5.c */ -char *px_crypt_md5(const char *pw, const char *salt, - char *dst, unsigned dstlen); - +char *px_crypt_md5(const char *pw, const char *salt, + char *dst, unsigned dstlen); #endif /* !PX_SYSTEM_CRYPT */ #endif /* _PX_CRYPT_H */ diff --git a/contrib/pgcrypto/px-hmac.c b/contrib/pgcrypto/px-hmac.c index d635aba124..147a559238 100644 --- a/contrib/pgcrypto/px-hmac.c +++ b/contrib/pgcrypto/px-hmac.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: px-hmac.c,v 1.1 2001/08/21 01:32:01 momjian Exp $ + * $Id: px-hmac.c,v 1.2 2001/10/25 05:49:20 momjian Exp $ */ @@ -50,7 +50,7 @@ hmac_block_size(PX_HMAC * h) } static void -hmac_init(PX_HMAC * h, const uint8 * key, uint klen) +hmac_init(PX_HMAC * h, const uint8 *key, uint klen) { uint bs, hlen, @@ -95,13 +95,13 @@ hmac_reset(PX_HMAC * h) } static void -hmac_update(PX_HMAC * h, const uint8 * data, uint dlen) +hmac_update(PX_HMAC * h, const uint8 *data, uint dlen) { px_md_update(h->md, data, dlen); } static void -hmac_finish(PX_HMAC * h, uint8 * dst) +hmac_finish(PX_HMAC * h, uint8 *dst) { PX_MD *md = h->md; uint bs, diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c index 9c18f6f250..20550bf100 100644 --- a/contrib/pgcrypto/px.c +++ b/contrib/pgcrypto/px.c @@ -1,7 +1,7 @@ /* * px.c * Various cryptographic stuff for PostgreSQL. - * + * * Copyright (c) 2001 Marko Kreen * All rights reserved. * @@ -9,15 +9,15 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: px.c,v 1.2 2001/09/06 03:21:39 momjian Exp $ + * $Id: px.c,v 1.3 2001/10/25 05:49:20 momjian Exp $ */ #include <postgres.h> @@ -35,9 +35,10 @@ const char * -px_resolve_alias(const PX_Alias *list, const char *name) +px_resolve_alias(const PX_Alias * list, const char *name) { - while (list->name) { + while (list->name) + { if (!strcasecmp(list->alias, name)) return list->name; list++; @@ -50,32 +51,35 @@ px_resolve_alias(const PX_Alias *list, const char *name) */ static uint -combo_encrypt_len(PX_Combo *cx, uint dlen) +combo_encrypt_len(PX_Combo * cx, uint dlen) { return dlen + 512; } static uint -combo_decrypt_len(PX_Combo *cx, uint dlen) +combo_decrypt_len(PX_Combo * cx, uint dlen) { return dlen; } static int -combo_init(PX_Combo *cx, const uint8 *key, uint klen, - const uint8 *iv, uint ivlen) +combo_init(PX_Combo * cx, const uint8 *key, uint klen, + const uint8 *iv, uint ivlen) { - int err; - uint bs, ks, ivs; - PX_Cipher *c = cx->cipher; - uint8 *ivbuf = NULL; - uint8 *keybuf; + int err; + uint bs, + ks, + ivs; + PX_Cipher *c = cx->cipher; + uint8 *ivbuf = NULL; + uint8 *keybuf; bs = px_cipher_block_size(c); ks = px_cipher_key_size(c); ivs = px_cipher_iv_size(c); - if (ivs > 0) { + if (ivs > 0) + { ivbuf = px_alloc(ivs); memset(ivbuf, 0, ivs); if (ivlen > ivs) @@ -97,39 +101,48 @@ combo_init(PX_Combo *cx, const uint8 *key, uint klen, } static int -combo_encrypt(PX_Combo *cx, const uint8 *data, uint dlen, - uint8 *res, uint *rlen) +combo_encrypt(PX_Combo * cx, const uint8 *data, uint dlen, + uint8 *res, uint *rlen) { - int err = 0; - uint8 *bbuf; - uint bs, maxlen, bpos, i, pad; + int err = 0; + uint8 *bbuf; + uint bs, + maxlen, + bpos, + i, + pad; - PX_Cipher *c = cx->cipher; + PX_Cipher *c = cx->cipher; bbuf = NULL; maxlen = *rlen; bs = px_cipher_block_size(c); - + /* encrypt */ - if (bs > 1) { + if (bs > 1) + { bbuf = px_alloc(bs * 4); bpos = dlen % bs; *rlen = dlen - bpos; memcpy(bbuf, data + *rlen, bpos); /* encrypt full-block data */ - if (*rlen) { + if (*rlen) + { err = px_cipher_encrypt(c, data, *rlen, res); if (err) goto out; } - + /* bbuf has now bpos bytes of stuff */ - if (cx->padding) { + if (cx->padding) + { pad = bs - (bpos % bs); for (i = 0; i < pad; i++) bbuf[bpos++] = pad; - } else if (bpos % bs) { + } + else if (bpos % bs) + { /* ERROR? */ pad = bs - (bpos % bs); for (i = 0; i < pad; i++) @@ -137,11 +150,14 @@ combo_encrypt(PX_Combo *cx, const uint8 *data, uint dlen, } /* encrypt the rest - pad */ - if (bpos) { + if (bpos) + { err = px_cipher_encrypt(c, bbuf, bpos, res + *rlen); *rlen += bpos; } - } else { + } + else + { /* stream cipher/mode - no pad needed */ err = px_cipher_encrypt(c, data, dlen, res); if (err) @@ -149,48 +165,53 @@ combo_encrypt(PX_Combo *cx, const uint8 *data, uint dlen, *rlen = dlen; } out: - if (bbuf) px_free(bbuf); + if (bbuf) + px_free(bbuf); return err; } static int -combo_decrypt(PX_Combo *cx, const uint8 *data, uint dlen, - uint8 *res, uint *rlen) +combo_decrypt(PX_Combo * cx, const uint8 *data, uint dlen, + uint8 *res, uint *rlen) { - uint bs, i, pad; - uint pad_ok; + uint bs, + i, + pad; + uint pad_ok; - PX_Cipher *c = cx->cipher; + PX_Cipher *c = cx->cipher; bs = px_cipher_block_size(c); - if (bs > 1 && (dlen % bs) != 0) { + if (bs > 1 && (dlen % bs) != 0) goto block_error; - } - + /* decrypt */ *rlen = dlen; px_cipher_decrypt(c, data, dlen, res); - + /* unpad */ - if (bs > 1 && cx->padding) { + if (bs > 1 && cx->padding) + { pad = res[*rlen - 1]; pad_ok = 0; - if (pad > 0 && pad <= bs && pad <= *rlen) { + if (pad > 0 && pad <= bs && pad <= *rlen) + { pad_ok = 1; for (i = *rlen - pad; i < *rlen; i++) - if (res[i] != pad) { + if (res[i] != pad) + { pad_ok = 0; break; } } - + if (pad_ok) *rlen -= pad; } return 0; - + /* error reporting should be done in pgcrypto.c */ block_error: elog(NOTICE, "Data not a multiple of block size"); @@ -198,7 +219,7 @@ block_error: } static void -combo_free(PX_Combo *cx) +combo_free(PX_Combo * cx) { if (cx->cipher) px_cipher_free(cx->cipher); @@ -211,31 +232,38 @@ combo_free(PX_Combo *cx) static int parse_cipher_name(char *full, char **cipher, char **pad) { - char *p, *p2, *q; + char *p, + *p2, + *q; + *cipher = full; *pad = NULL; - + p = strchr(full, '/'); if (p != NULL) *p++ = 0; - while (p != NULL) { + while (p != NULL) + { if ((q = strchr(p, '/')) != NULL) *q++ = 0; - - if (!*p) { + + if (!*p) + { p = q; continue; } p2 = strchr(p, ':'); - if (p2 != NULL) { + if (p2 != NULL) + { *p2++ = 0; if (!strcmp(p, "pad")) *pad = p2; else return -1; - } else + } + else return -1; - + p = q; } return 0; @@ -244,12 +272,14 @@ parse_cipher_name(char *full, char **cipher, char **pad) /* provider */ int -px_find_combo(const char *name, PX_Combo **res) +px_find_combo(const char *name, PX_Combo ** res) { - int err; - char *buf, *s_cipher, *s_pad; + int err; + char *buf, + *s_cipher, + *s_pad; - PX_Combo *cx; + PX_Combo *cx; cx = px_alloc(sizeof(*cx)); memset(cx, 0, sizeof(*cx)); @@ -258,7 +288,8 @@ px_find_combo(const char *name, PX_Combo **res) strcpy(buf, name); err = parse_cipher_name(buf, &s_cipher, &s_pad); - if (err) { + if (err) + { px_free(buf); px_free(cx); return err; @@ -267,15 +298,17 @@ px_find_combo(const char *name, PX_Combo **res) err = px_find_cipher(s_cipher, &cx->cipher); if (err) goto err1; - - if (s_pad != NULL) { + + if (s_pad != NULL) + { if (!strcmp(s_pad, "pkcs")) cx->padding = 1; else if (!strcmp(s_pad, "none")) cx->padding = 0; else goto err1; - } else + } + else cx->padding = 1; cx->init = combo_init; @@ -290,7 +323,7 @@ px_find_combo(const char *name, PX_Combo **res) *res = cx; return 0; - + err1: if (cx->cipher) px_cipher_free(cx->cipher); @@ -298,4 +331,3 @@ err1: px_free(buf); return -1; } - diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index d4cffc3c06..d2a87b26e1 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -1,7 +1,7 @@ /* * px.h * Header file for pgcrypto. - * + * * Copyright (c) 2001 Marko Kreen * All rights reserved. * @@ -9,15 +9,15 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: px.h,v 1.2 2001/09/23 04:12:44 momjian Exp $ + * $Id: px.h,v 1.3 2001/10/25 05:49:20 momjian Exp $ */ #ifndef __PX_H @@ -36,22 +36,21 @@ #define px_alloc(s) palloc(s) #define px_realloc(p, s) prealloc(p, s) -#define px_free(p) pfree(p) +#define px_free(p) pfree(p) #else -void *xalloc(size_t s); -void *xrealloc(void *p, size_t s); -void xfree(void *p); +void *xalloc(size_t s); +void *xrealloc(void *p, size_t s); +void xfree(void *p); #define px_alloc(s) xalloc(s) #define px_realloc(p, s) xrealloc(p, s) -#define px_free(p) xfree(p) - +#define px_free(p) xfree(p) #endif /* max len of 'type' parms */ -#define PX_MAX_NAMELEN 128 +#define PX_MAX_NAMELEN 128 /* max salt returned */ #define PX_MAX_SALT_LEN 128 @@ -63,79 +62,86 @@ typedef struct px_hmac PX_HMAC; typedef struct px_cipher PX_Cipher; typedef struct px_combo PX_Combo; -struct px_digest { - uint (*result_size)(PX_MD *h); - uint (*block_size)(PX_MD *h); - void (*reset)(PX_MD *h); - void (*update)(PX_MD *h, const uint8 *data, uint dlen); - void (*finish)(PX_MD *h, uint8 *dst); - void (*free)(PX_MD *h); +struct px_digest +{ + uint (*result_size) (PX_MD * h); + uint (*block_size) (PX_MD * h); + void (*reset) (PX_MD * h); + void (*update) (PX_MD * h, const uint8 *data, uint dlen); + void (*finish) (PX_MD * h, uint8 *dst); + void (*free) (PX_MD * h); /* private */ - union { - uint code; + union + { + uint code; const void *ptr; - } p; + } p; }; -struct px_alias { - char *alias; - char *name; +struct px_alias +{ + char *alias; + char *name; }; -struct px_hmac { - uint (*result_size)(PX_HMAC *h); - uint (*block_size)(PX_HMAC *h); - void (*reset)(PX_HMAC *h); - void (*update)(PX_HMAC *h, const uint8 *data, uint dlen); - void (*finish)(PX_HMAC *h, uint8 *dst); - void (*free)(PX_HMAC *h); - void (*init)(PX_HMAC *h, const uint8 *key, uint klen); - - PX_MD *md; +struct px_hmac +{ + uint (*result_size) (PX_HMAC * h); + uint (*block_size) (PX_HMAC * h); + void (*reset) (PX_HMAC * h); + void (*update) (PX_HMAC * h, const uint8 *data, uint dlen); + void (*finish) (PX_HMAC * h, uint8 *dst); + void (*free) (PX_HMAC * h); + void (*init) (PX_HMAC * h, const uint8 *key, uint klen); + + PX_MD *md; /* private */ - struct { - uint8 *ipad; - uint8 *opad; - } p; + struct + { + uint8 *ipad; + uint8 *opad; + } p; }; -struct px_cipher { - uint (*block_size)(PX_Cipher *c); - uint (*key_size)(PX_Cipher *c); /* max key len */ - uint (*iv_size)(PX_Cipher *c); - - int (*init)(PX_Cipher *c, const uint8 *key, uint klen, const uint8 *iv); - int (*encrypt)(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res); - int (*decrypt)(PX_Cipher *c, const uint8 *data, uint dlen, uint8 *res); - void (*free)(PX_Cipher *c); +struct px_cipher +{ + uint (*block_size) (PX_Cipher * c); + uint (*key_size) (PX_Cipher * c); /* max key len */ + uint (*iv_size) (PX_Cipher * c); + + int (*init) (PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv); + int (*encrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res); + int (*decrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res); + void (*free) (PX_Cipher * c); /* private */ - void *ptr; - int pstat; /* mcrypt uses it */ + void *ptr; + int pstat; /* mcrypt uses it */ }; -struct px_combo { - int (*init)(PX_Combo *cx, const uint8 *key, uint klen, - const uint8 *iv, uint ivlen); - int (*encrypt)(PX_Combo *cx, const uint8 *data, uint dlen, - uint8 *res, uint *rlen); - int (*decrypt)(PX_Combo *cx, const uint8 *data, uint dlen, - uint8 *res, uint *rlen); - uint (*encrypt_len)(PX_Combo *cx, uint dlen); - uint (*decrypt_len)(PX_Combo *cx, uint dlen); - void (*free)(PX_Combo *cx); - - PX_Cipher *cipher; - uint padding; +struct px_combo +{ + int (*init) (PX_Combo * cx, const uint8 *key, uint klen, + const uint8 *iv, uint ivlen); + int (*encrypt) (PX_Combo * cx, const uint8 *data, uint dlen, + uint8 *res, uint *rlen); + int (*decrypt) (PX_Combo * cx, const uint8 *data, uint dlen, + uint8 *res, uint *rlen); + uint (*encrypt_len) (PX_Combo * cx, uint dlen); + uint (*decrypt_len) (PX_Combo * cx, uint dlen); + void (*free) (PX_Combo * cx); + + PX_Cipher *cipher; + uint padding; }; -int px_find_digest(const char *name, PX_MD **res); -int px_find_hmac(const char *name, PX_HMAC **res); -int px_find_cipher(const char *name, PX_Cipher **res); -int px_find_combo(const char *name, PX_Combo **res); +int px_find_digest(const char *name, PX_MD ** res); +int px_find_hmac(const char *name, PX_HMAC ** res); +int px_find_cipher(const char *name, PX_Cipher ** res); +int px_find_combo(const char *name, PX_Combo ** res); -int px_get_random_bytes(uint8 *dst, unsigned count); +int px_get_random_bytes(uint8 *dst, unsigned count); -const char *px_resolve_alias(const PX_Alias *aliases, const char *name); +const char *px_resolve_alias(const PX_Alias * aliases, const char *name); #define px_md_result_size(md) (md)->result_size(md) #define px_md_block_size(md) (md)->block_size(md) @@ -174,6 +180,4 @@ const char *px_resolve_alias(const PX_Alias *aliases, const char *name); (c)->decrypt(c, data, dlen, res, rlen) #define px_combo_free(c) (c)->free(c) - -#endif /* __PX_H */ - +#endif /* __PX_H */ diff --git a/contrib/pgcrypto/random.c b/contrib/pgcrypto/random.c index 179d450ef9..559e40c456 100644 --- a/contrib/pgcrypto/random.c +++ b/contrib/pgcrypto/random.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: random.c,v 1.2 2001/09/29 03:12:51 momjian Exp $ + * $Id: random.c,v 1.3 2001/10/25 05:49:20 momjian Exp $ */ @@ -44,13 +44,15 @@ static int safe_read(int fd, void *buf, size_t count) { - int done = 0; - char *p = buf; - int res; - - while (count) { + int done = 0; + char *p = buf; + int res; + + while (count) + { res = read(fd, p, count); - if (res <= 0) { + if (res <= 0) + { if (errno == EINTR) continue; return -1; @@ -65,8 +67,8 @@ safe_read(int fd, void *buf, size_t count) int px_get_random_bytes(uint8 *dst, unsigned count) { - int fd; - int res; + int fd; + int res; fd = open(RAND_DEV, O_RDONLY); if (fd == -1) @@ -75,21 +77,20 @@ px_get_random_bytes(uint8 *dst, unsigned count) close(fd); return res; } - -#endif /* RAND_DEV */ +#endif /* RAND_DEV */ #ifdef RAND_SILLY -int px_get_random_bytes(uint8 *dst, unsigned count) +int +px_get_random_bytes(uint8 *dst, unsigned count) { - int i; - for (i = 0; i < count; i++) { + int i; + + for (i = 0; i < count; i++) *dst++ = random(); - } return i; } - -#endif /* RAND_SILLY */ +#endif /* RAND_SILLY */ #ifdef RAND_OPENSSL @@ -98,30 +99,29 @@ int px_get_random_bytes(uint8 *dst, unsigned count) #include <openssl/rand.h> #include <openssl/err.h> -static int openssl_random_init = 0; +static int openssl_random_init = 0; -int px_get_random_bytes(uint8 *dst, unsigned count) +int +px_get_random_bytes(uint8 *dst, unsigned count) { - int res; + int res; - if (!openssl_random_init) { - if (RAND_get_rand_method() == NULL) { + if (!openssl_random_init) + { + if (RAND_get_rand_method() == NULL) RAND_set_rand_method(RAND_SSLeay()); - } openssl_random_init = 1; } - + /* - * OpenSSL random should re-feeded occasionally. - * From /dev/urandom preferrably. + * OpenSSL random should re-feeded occasionally. From /dev/urandom + * preferrably. */ - + res = RAND_bytes(dst, count); if (res > 0) return count; return -1; } - -#endif /* RAND_OPENSSL */ - +#endif /* RAND_OPENSSL */ diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c index 258202fa99..cca8759e8b 100644 --- a/contrib/pgcrypto/rijndael.c +++ b/contrib/pgcrypto/rijndael.c @@ -1,40 +1,40 @@ -/* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */ - -/* This is an independent implementation of the encryption algorithm: */ -/* */ -/* RIJNDAEL by Joan Daemen and Vincent Rijmen */ -/* */ -/* which is a candidate algorithm in the Advanced Encryption Standard */ -/* programme of the US National Institute of Standards and Technology. */ -/* */ -/* Copyright in this implementation is held by Dr B R Gladman but I */ +/* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */ + +/* This is an independent implementation of the encryption algorithm: */ +/* */ +/* RIJNDAEL by Joan Daemen and Vincent Rijmen */ +/* */ +/* which is a candidate algorithm in the Advanced Encryption Standard */ +/* programme of the US National Institute of Standards and Technology. */ +/* */ +/* Copyright in this implementation is held by Dr B R Gladman but I */ /* hereby give permission for its free direct or derivative use subject */ -/* to acknowledgment of its origin and compliance with any conditions */ -/* that the originators of the algorithm place on its exploitation. */ -/* */ -/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */ +/* to acknowledgment of its origin and compliance with any conditions */ +/* that the originators of the algorithm place on its exploitation. */ +/* */ +/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */ /* Timing data for Rijndael (rijndael.c) Algorithm: rijndael (rijndael.c) 128 bit key: -Key Setup: 305/1389 cycles (encrypt/decrypt) -Encrypt: 374 cycles = 68.4 mbits/sec -Decrypt: 352 cycles = 72.7 mbits/sec -Mean: 363 cycles = 70.5 mbits/sec +Key Setup: 305/1389 cycles (encrypt/decrypt) +Encrypt: 374 cycles = 68.4 mbits/sec +Decrypt: 352 cycles = 72.7 mbits/sec +Mean: 363 cycles = 70.5 mbits/sec 192 bit key: -Key Setup: 277/1595 cycles (encrypt/decrypt) -Encrypt: 439 cycles = 58.3 mbits/sec -Decrypt: 425 cycles = 60.2 mbits/sec -Mean: 432 cycles = 59.3 mbits/sec +Key Setup: 277/1595 cycles (encrypt/decrypt) +Encrypt: 439 cycles = 58.3 mbits/sec +Decrypt: 425 cycles = 60.2 mbits/sec +Mean: 432 cycles = 59.3 mbits/sec 256 bit key: -Key Setup: 374/1960 cycles (encrypt/decrypt) -Encrypt: 502 cycles = 51.0 mbits/sec -Decrypt: 498 cycles = 51.4 mbits/sec -Mean: 500 cycles = 51.2 mbits/sec +Key Setup: 374/1960 cycles (encrypt/decrypt) +Encrypt: 502 cycles = 51.0 mbits/sec +Decrypt: 498 cycles = 51.4 mbits/sec +Mean: 500 cycles = 51.2 mbits/sec */ @@ -47,29 +47,29 @@ Mean: 500 cycles = 51.2 mbits/sec static void gen_tabs(void); -/* 3. Basic macros for speeding up generic operations */ +/* 3. Basic macros for speeding up generic operations */ -/* Circular rotate of 32 bit values */ +/* Circular rotate of 32 bit values */ -#define rotr(x,n) (((x) >> ((int)(n))) | ((x) << (32 - (int)(n)))) -#define rotl(x,n) (((x) << ((int)(n))) | ((x) >> (32 - (int)(n)))) +#define rotr(x,n) (((x) >> ((int)(n))) | ((x) << (32 - (int)(n)))) +#define rotl(x,n) (((x) << ((int)(n))) | ((x) >> (32 - (int)(n)))) -/* Invert byte order in a 32 bit variable */ +/* Invert byte order in a 32 bit variable */ -#define bswap(x) ((rotl(x, 8) & 0x00ff00ff) | (rotr(x, 8) & 0xff00ff00)) +#define bswap(x) ((rotl(x, 8) & 0x00ff00ff) | (rotr(x, 8) & 0xff00ff00)) -/* Extract byte from a 32 bit quantity (little endian notation) */ +/* Extract byte from a 32 bit quantity (little endian notation) */ -#define byte(x,n) ((u1byte)((x) >> (8 * n))) +#define byte(x,n) ((u1byte)((x) >> (8 * n))) #if BYTE_ORDER != LITTLE_ENDIAN #define BYTE_SWAP #endif -#ifdef BYTE_SWAP -#define io_swap(x) bswap(x) +#ifdef BYTE_SWAP +#define io_swap(x) bswap(x) #else -#define io_swap(x) (x) +#define io_swap(x) (x) #endif #ifdef PRINT_TABS @@ -81,279 +81,311 @@ static void gen_tabs(void); #include "rijndael.tbl" #define tab_gen 1 -#else /* !PRE_CALC_TABLES */ +#else /* !PRE_CALC_TABLES */ -static u1byte pow_tab[256]; -static u1byte log_tab[256]; -static u1byte sbx_tab[256]; -static u1byte isb_tab[256]; -static u4byte rco_tab[ 10]; -static u4byte ft_tab[4][256]; -static u4byte it_tab[4][256]; +static u1byte pow_tab[256]; +static u1byte log_tab[256]; +static u1byte sbx_tab[256]; +static u1byte isb_tab[256]; +static u4byte rco_tab[10]; +static u4byte ft_tab[4][256]; +static u4byte it_tab[4][256]; -#ifdef LARGE_TABLES -static u4byte fl_tab[4][256]; -static u4byte il_tab[4][256]; +#ifdef LARGE_TABLES +static u4byte fl_tab[4][256]; +static u4byte il_tab[4][256]; #endif -static u4byte tab_gen = 0; -#endif /* !PRE_CALC_TABLES */ +static u4byte tab_gen = 0; +#endif /* !PRE_CALC_TABLES */ -#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0) +#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0) -#define f_rn(bo, bi, n, k) \ - bo[n] = ft_tab[0][byte(bi[n],0)] ^ \ - ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) +#define f_rn(bo, bi, n, k) \ + bo[n] = ft_tab[0][byte(bi[n],0)] ^ \ + ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ + ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ + ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) -#define i_rn(bo, bi, n, k) \ - bo[n] = it_tab[0][byte(bi[n],0)] ^ \ - it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) +#define i_rn(bo, bi, n, k) \ + bo[n] = it_tab[0][byte(bi[n],0)] ^ \ + it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ + it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ + it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) #ifdef LARGE_TABLES -#define ls_box(x) \ - ( fl_tab[0][byte(x, 0)] ^ \ - fl_tab[1][byte(x, 1)] ^ \ - fl_tab[2][byte(x, 2)] ^ \ - fl_tab[3][byte(x, 3)] ) +#define ls_box(x) \ + ( fl_tab[0][byte(x, 0)] ^ \ + fl_tab[1][byte(x, 1)] ^ \ + fl_tab[2][byte(x, 2)] ^ \ + fl_tab[3][byte(x, 3)] ) -#define f_rl(bo, bi, n, k) \ - bo[n] = fl_tab[0][byte(bi[n],0)] ^ \ - fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) +#define f_rl(bo, bi, n, k) \ + bo[n] = fl_tab[0][byte(bi[n],0)] ^ \ + fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ + fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ + fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) -#define i_rl(bo, bi, n, k) \ - bo[n] = il_tab[0][byte(bi[n],0)] ^ \ - il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) +#define i_rl(bo, bi, n, k) \ + bo[n] = il_tab[0][byte(bi[n],0)] ^ \ + il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ + il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ + il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) #else -#define ls_box(x) \ - ((u4byte)sbx_tab[byte(x, 0)] << 0) ^ \ - ((u4byte)sbx_tab[byte(x, 1)] << 8) ^ \ - ((u4byte)sbx_tab[byte(x, 2)] << 16) ^ \ - ((u4byte)sbx_tab[byte(x, 3)] << 24) - -#define f_rl(bo, bi, n, k) \ - bo[n] = (u4byte)sbx_tab[byte(bi[n],0)] ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n) - -#define i_rl(bo, bi, n, k) \ - bo[n] = (u4byte)isb_tab[byte(bi[n],0)] ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n) - +#define ls_box(x) \ + ((u4byte)sbx_tab[byte(x, 0)] << 0) ^ \ + ((u4byte)sbx_tab[byte(x, 1)] << 8) ^ \ + ((u4byte)sbx_tab[byte(x, 2)] << 16) ^ \ + ((u4byte)sbx_tab[byte(x, 3)] << 24) + +#define f_rl(bo, bi, n, k) \ + bo[n] = (u4byte)sbx_tab[byte(bi[n],0)] ^ \ + rotl(((u4byte)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \ + rotl(((u4byte)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ + rotl(((u4byte)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n) + +#define i_rl(bo, bi, n, k) \ + bo[n] = (u4byte)isb_tab[byte(bi[n],0)] ^ \ + rotl(((u4byte)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \ + rotl(((u4byte)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ + rotl(((u4byte)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n) #endif static void gen_tabs(void) { #ifndef PRE_CALC_TABLES - u4byte i, t; - u1byte p, q; + u4byte i, + t; + u1byte p, + q; - /* log and power tables for GF(2**8) finite field with */ - /* 0x11b as modular polynomial - the simplest prmitive */ - /* root is 0x11, used here to generate the tables */ + /* log and power tables for GF(2**8) finite field with */ + /* 0x11b as modular polynomial - the simplest prmitive */ + /* root is 0x11, used here to generate the tables */ - for(i = 0,p = 1; i < 256; ++i) { - pow_tab[i] = (u1byte)p; log_tab[p] = (u1byte)i; + for (i = 0, p = 1; i < 256; ++i) + { + pow_tab[i] = (u1byte) p; + log_tab[p] = (u1byte) i; p = p ^ (p << 1) ^ (p & 0x80 ? 0x01b : 0); } - log_tab[1] = 0; p = 1; + log_tab[1] = 0; + p = 1; - for(i = 0; i < 10; ++i) { - rco_tab[i] = p; + for (i = 0; i < 10; ++i) + { + rco_tab[i] = p; p = (p << 1) ^ (p & 0x80 ? 0x1b : 0); } - /* note that the affine byte transformation matrix in */ - /* rijndael specification is in big endian format with */ - /* bit 0 as the most significant bit. In the remainder */ - /* of the specification the bits are numbered from the */ - /* least significant end of a byte. */ - - for(i = 0; i < 256; ++i) { - p = (i ? pow_tab[255 - log_tab[i]] : 0); q = p; - q = (q >> 7) | (q << 1); p ^= q; - q = (q >> 7) | (q << 1); p ^= q; - q = (q >> 7) | (q << 1); p ^= q; - q = (q >> 7) | (q << 1); p ^= q ^ 0x63; - sbx_tab[i] = (u1byte)p; isb_tab[p] = (u1byte)i; + /* note that the affine byte transformation matrix in */ + /* rijndael specification is in big endian format with */ + /* bit 0 as the most significant bit. In the remainder */ + /* of the specification the bits are numbered from the */ + /* least significant end of a byte. */ + + for (i = 0; i < 256; ++i) + { + p = (i ? pow_tab[255 - log_tab[i]] : 0); + q = p; + q = (q >> 7) | (q << 1); + p ^= q; + q = (q >> 7) | (q << 1); + p ^= q; + q = (q >> 7) | (q << 1); + p ^= q; + q = (q >> 7) | (q << 1); + p ^= q ^ 0x63; + sbx_tab[i] = (u1byte) p; + isb_tab[p] = (u1byte) i; } - for(i = 0; i < 256; ++i) { - p = sbx_tab[i]; + for (i = 0; i < 256; ++i) + { + p = sbx_tab[i]; -#ifdef LARGE_TABLES - - t = p; fl_tab[0][i] = t; - fl_tab[1][i] = rotl(t, 8); +#ifdef LARGE_TABLES + + t = p; + fl_tab[0][i] = t; + fl_tab[1][i] = rotl(t, 8); fl_tab[2][i] = rotl(t, 16); fl_tab[3][i] = rotl(t, 24); #endif - t = ((u4byte)ff_mult(2, p)) | - ((u4byte)p << 8) | - ((u4byte)p << 16) | - ((u4byte)ff_mult(3, p) << 24); - + t = ((u4byte) ff_mult(2, p)) | + ((u4byte) p << 8) | + ((u4byte) p << 16) | + ((u4byte) ff_mult(3, p) << 24); + ft_tab[0][i] = t; - ft_tab[1][i] = rotl(t, 8); + ft_tab[1][i] = rotl(t, 8); ft_tab[2][i] = rotl(t, 16); ft_tab[3][i] = rotl(t, 24); - p = isb_tab[i]; + p = isb_tab[i]; -#ifdef LARGE_TABLES - - t = p; il_tab[0][i] = t; - il_tab[1][i] = rotl(t, 8); - il_tab[2][i] = rotl(t, 16); +#ifdef LARGE_TABLES + + t = p; + il_tab[0][i] = t; + il_tab[1][i] = rotl(t, 8); + il_tab[2][i] = rotl(t, 16); il_tab[3][i] = rotl(t, 24); -#endif - t = ((u4byte)ff_mult(14, p)) | - ((u4byte)ff_mult( 9, p) << 8) | - ((u4byte)ff_mult(13, p) << 16) | - ((u4byte)ff_mult(11, p) << 24); - - it_tab[0][i] = t; - it_tab[1][i] = rotl(t, 8); - it_tab[2][i] = rotl(t, 16); - it_tab[3][i] = rotl(t, 24); +#endif + t = ((u4byte) ff_mult(14, p)) | + ((u4byte) ff_mult(9, p) << 8) | + ((u4byte) ff_mult(13, p) << 16) | + ((u4byte) ff_mult(11, p) << 24); + + it_tab[0][i] = t; + it_tab[1][i] = rotl(t, 8); + it_tab[2][i] = rotl(t, 16); + it_tab[3][i] = rotl(t, 24); } tab_gen = 1; -#endif /* !PRE_CALC_TABLES */ +#endif /* !PRE_CALC_TABLES */ } #define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b) -#define imix_col(y,x) \ - u = star_x(x); \ - v = star_x(u); \ - w = star_x(v); \ - t = w ^ (x); \ - (y) = u ^ v ^ w; \ +#define imix_col(y,x) \ + u = star_x(x); \ + v = star_x(u); \ + w = star_x(v); \ + t = w ^ (x); \ + (y) = u ^ v ^ w; \ (y) ^= rotr(u ^ t, 8) ^ \ - rotr(v ^ t, 16) ^ \ - rotr(t,24) + rotr(v ^ t, 16) ^ \ + rotr(t,24) -/* initialise the key schedule from the user supplied key */ +/* initialise the key schedule from the user supplied key */ -#define loop4(i) \ -do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ - t ^= e_key[4 * i]; e_key[4 * i + 4] = t; \ - t ^= e_key[4 * i + 1]; e_key[4 * i + 5] = t; \ - t ^= e_key[4 * i + 2]; e_key[4 * i + 6] = t; \ - t ^= e_key[4 * i + 3]; e_key[4 * i + 7] = t; \ +#define loop4(i) \ +do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ + t ^= e_key[4 * i]; e_key[4 * i + 4] = t; \ + t ^= e_key[4 * i + 1]; e_key[4 * i + 5] = t; \ + t ^= e_key[4 * i + 2]; e_key[4 * i + 6] = t; \ + t ^= e_key[4 * i + 3]; e_key[4 * i + 7] = t; \ } while (0) -#define loop6(i) \ -do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ - t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \ - t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \ - t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \ - t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \ - t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \ - t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \ +#define loop6(i) \ +do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ + t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \ + t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \ + t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \ + t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \ + t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \ + t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \ } while (0) -#define loop8(i) \ -do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ - t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \ - t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \ - t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \ - t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \ - t = e_key[8 * i + 4] ^ ls_box(t); \ - e_key[8 * i + 12] = t; \ - t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \ - t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \ - t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \ +#define loop8(i) \ +do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ + t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \ + t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \ + t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \ + t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \ + t = e_key[8 * i + 4] ^ ls_box(t); \ + e_key[8 * i + 12] = t; \ + t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \ + t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \ + t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \ } while (0) rijndael_ctx * -rijndael_set_key(rijndael_ctx *ctx, const u4byte *in_key, const u4byte key_len, - int encrypt) -{ - u4byte i, t, u, v, w; - u4byte *e_key = ctx->e_key; - u4byte *d_key = ctx->d_key; +rijndael_set_key(rijndael_ctx * ctx, const u4byte * in_key, const u4byte key_len, + int encrypt) +{ + u4byte i, + t, + u, + v, + w; + u4byte *e_key = ctx->e_key; + u4byte *d_key = ctx->d_key; ctx->decrypt = !encrypt; - if(!tab_gen) + if (!tab_gen) gen_tabs(); ctx->k_len = (key_len + 31) / 32; - e_key[0] = io_swap(in_key[0]); e_key[1] = io_swap(in_key[1]); - e_key[2] = io_swap(in_key[2]); e_key[3] = io_swap(in_key[3]); - - switch(ctx->k_len) { - case 4: t = e_key[3]; - for(i = 0; i < 10; ++i) - loop4(i); - break; - - case 6: e_key[4] = io_swap(in_key[4]); t = e_key[5] = io_swap(in_key[5]); - for(i = 0; i < 8; ++i) - loop6(i); - break; - - case 8: e_key[4] = io_swap(in_key[4]); e_key[5] = io_swap(in_key[5]); - e_key[6] = io_swap(in_key[6]); t = e_key[7] = io_swap(in_key[7]); - for(i = 0; i < 7; ++i) - loop8(i); - break; + e_key[0] = io_swap(in_key[0]); + e_key[1] = io_swap(in_key[1]); + e_key[2] = io_swap(in_key[2]); + e_key[3] = io_swap(in_key[3]); + + switch (ctx->k_len) + { + case 4: + t = e_key[3]; + for (i = 0; i < 10; ++i) + loop4(i); + break; + + case 6: + e_key[4] = io_swap(in_key[4]); + t = e_key[5] = io_swap(in_key[5]); + for (i = 0; i < 8; ++i) + loop6(i); + break; + + case 8: + e_key[4] = io_swap(in_key[4]); + e_key[5] = io_swap(in_key[5]); + e_key[6] = io_swap(in_key[6]); + t = e_key[7] = io_swap(in_key[7]); + for (i = 0; i < 7; ++i) + loop8(i); + break; } - if (!encrypt) { - d_key[0] = e_key[0]; d_key[1] = e_key[1]; - d_key[2] = e_key[2]; d_key[3] = e_key[3]; + if (!encrypt) + { + d_key[0] = e_key[0]; + d_key[1] = e_key[1]; + d_key[2] = e_key[2]; + d_key[3] = e_key[3]; - for(i = 4; i < 4 * ctx->k_len + 24; ++i) { + for (i = 4; i < 4 * ctx->k_len + 24; ++i) imix_col(d_key[i], e_key[i]); - } } return ctx; } -/* encrypt a block of text */ +/* encrypt a block of text */ #define f_nround(bo, bi, k) \ - f_rn(bo, bi, 0, k); \ - f_rn(bo, bi, 1, k); \ - f_rn(bo, bi, 2, k); \ - f_rn(bo, bi, 3, k); \ - k += 4 + f_rn(bo, bi, 0, k); \ + f_rn(bo, bi, 1, k); \ + f_rn(bo, bi, 2, k); \ + f_rn(bo, bi, 3, k); \ + k += 4 #define f_lround(bo, bi, k) \ - f_rl(bo, bi, 0, k); \ - f_rl(bo, bi, 1, k); \ - f_rl(bo, bi, 2, k); \ - f_rl(bo, bi, 3, k) + f_rl(bo, bi, 0, k); \ + f_rl(bo, bi, 1, k); \ + f_rl(bo, bi, 2, k); \ + f_rl(bo, bi, 3, k) void -rijndael_encrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) -{ - u4byte k_len = ctx->k_len; - u4byte *e_key = ctx->e_key; - u4byte b0[4], b1[4], *kp; +rijndael_encrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk) +{ + u4byte k_len = ctx->k_len; + u4byte *e_key = ctx->e_key; + u4byte b0[4], + b1[4], + *kp; b0[0] = io_swap(in_blk[0]) ^ e_key[0]; b0[1] = io_swap(in_blk[1]) ^ e_key[1]; @@ -362,46 +394,59 @@ rijndael_encrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) kp = e_key + 4; - if(k_len > 6) { - f_nround(b1, b0, kp); f_nround(b0, b1, kp); + if (k_len > 6) + { + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); } - if(k_len > 4) { - f_nround(b1, b0, kp); f_nround(b0, b1, kp); + if (k_len > 4) + { + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); } - f_nround(b1, b0, kp); f_nround(b0, b1, kp); - f_nround(b1, b0, kp); f_nround(b0, b1, kp); - f_nround(b1, b0, kp); f_nround(b0, b1, kp); - f_nround(b1, b0, kp); f_nround(b0, b1, kp); - f_nround(b1, b0, kp); f_lround(b0, b1, kp); - - out_blk[0] = io_swap(b0[0]); out_blk[1] = io_swap(b0[1]); - out_blk[2] = io_swap(b0[2]); out_blk[3] = io_swap(b0[3]); + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); + f_nround(b1, b0, kp); + f_nround(b0, b1, kp); + f_nround(b1, b0, kp); + f_lround(b0, b1, kp); + + out_blk[0] = io_swap(b0[0]); + out_blk[1] = io_swap(b0[1]); + out_blk[2] = io_swap(b0[2]); + out_blk[3] = io_swap(b0[3]); } -/* decrypt a block of text */ +/* decrypt a block of text */ #define i_nround(bo, bi, k) \ - i_rn(bo, bi, 0, k); \ - i_rn(bo, bi, 1, k); \ - i_rn(bo, bi, 2, k); \ - i_rn(bo, bi, 3, k); \ - k -= 4 + i_rn(bo, bi, 0, k); \ + i_rn(bo, bi, 1, k); \ + i_rn(bo, bi, 2, k); \ + i_rn(bo, bi, 3, k); \ + k -= 4 #define i_lround(bo, bi, k) \ - i_rl(bo, bi, 0, k); \ - i_rl(bo, bi, 1, k); \ - i_rl(bo, bi, 2, k); \ - i_rl(bo, bi, 3, k) + i_rl(bo, bi, 0, k); \ + i_rl(bo, bi, 1, k); \ + i_rl(bo, bi, 2, k); \ + i_rl(bo, bi, 3, k) void -rijndael_decrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) -{ - u4byte b0[4], b1[4], *kp; - u4byte k_len = ctx->k_len; - u4byte *e_key = ctx->e_key; - u4byte *d_key = ctx->d_key; +rijndael_decrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk) +{ + u4byte b0[4], + b1[4], + *kp; + u4byte k_len = ctx->k_len; + u4byte *e_key = ctx->e_key; + u4byte *d_key = ctx->d_key; b0[0] = io_swap(in_blk[0]) ^ e_key[4 * k_len + 24]; b0[1] = io_swap(in_blk[1]) ^ e_key[4 * k_len + 25]; @@ -410,22 +455,33 @@ rijndael_decrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) kp = d_key + 4 * (k_len + 5); - if(k_len > 6) { - i_nround(b1, b0, kp); i_nround(b0, b1, kp); + if (k_len > 6) + { + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); } - if(k_len > 4) { - i_nround(b1, b0, kp); i_nround(b0, b1, kp); + if (k_len > 4) + { + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); } - i_nround(b1, b0, kp); i_nround(b0, b1, kp); - i_nround(b1, b0, kp); i_nround(b0, b1, kp); - i_nround(b1, b0, kp); i_nround(b0, b1, kp); - i_nround(b1, b0, kp); i_nround(b0, b1, kp); - i_nround(b1, b0, kp); i_lround(b0, b1, kp); - - out_blk[0] = io_swap(b0[0]); out_blk[1] = io_swap(b0[1]); - out_blk[2] = io_swap(b0[2]); out_blk[3] = io_swap(b0[3]); + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); + i_nround(b1, b0, kp); + i_nround(b0, b1, kp); + i_nround(b1, b0, kp); + i_lround(b0, b1, kp); + + out_blk[0] = io_swap(b0[0]); + out_blk[1] = io_swap(b0[1]); + out_blk[2] = io_swap(b0[2]); + out_blk[3] = io_swap(b0[3]); } /* @@ -435,19 +491,24 @@ rijndael_decrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) * should be true for PX. -marko */ -void aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc) +void +aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc) { - uint32 *k; - k = (uint32*)key; + uint32 *k; + + k = (uint32 *) key; rijndael_set_key(ctx, k, keybits, enc); } -void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) +void +aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) { - unsigned bs = 16; - uint32 *d; - while (len >= bs) { - d = (uint32*)data; + unsigned bs = 16; + uint32 *d; + + while (len >= bs) + { + d = (uint32 *) data; rijndael_encrypt(ctx, d, d); len -= bs; @@ -455,12 +516,15 @@ void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) } } -void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) +void +aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) { - unsigned bs = 16; - uint32 *d; - while (len >= bs) { - d = (uint32*)data; + unsigned bs = 16; + uint32 *d; + + while (len >= bs) + { + d = (uint32 *) data; rijndael_decrypt(ctx, d, d); len -= bs; @@ -468,42 +532,55 @@ void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) } } -void aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len) +void +aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len) { - uint32 *iv = (uint32 *)iva; - uint32 *d = (uint32 *)data; - unsigned bs = 16; - - while (len >= bs) { - d[0] ^= iv[0]; d[1] ^= iv[1]; - d[2] ^= iv[2]; d[3] ^= iv[3]; - + uint32 *iv = (uint32 *) iva; + uint32 *d = (uint32 *) data; + unsigned bs = 16; + + while (len >= bs) + { + d[0] ^= iv[0]; + d[1] ^= iv[1]; + d[2] ^= iv[2]; + d[3] ^= iv[3]; + rijndael_encrypt(ctx, d, d); iv = d; - d += bs/4; + d += bs / 4; len -= bs; } } -void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len) +void +aes_cbc_decrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len) { - uint32 *d = (uint32 *)data; - unsigned bs = 16; - uint32 buf[4], iv[4]; + uint32 *d = (uint32 *) data; + unsigned bs = 16; + uint32 buf[4], + iv[4]; memcpy(iv, iva, bs); - while (len >= bs) { - buf[0] = d[0]; buf[1] = d[1]; - buf[2] = d[2]; buf[3] = d[3]; - + while (len >= bs) + { + buf[0] = d[0]; + buf[1] = d[1]; + buf[2] = d[2]; + buf[3] = d[3]; + rijndael_decrypt(ctx, buf, d); - - d[0] ^= iv[0]; d[1] ^= iv[1]; - d[2] ^= iv[2]; d[3] ^= iv[3]; - - iv[0] = buf[0]; iv[1] = buf[1]; - iv[2] = buf[2]; iv[3] = buf[3]; + + d[0] ^= iv[0]; + d[1] ^= iv[1]; + d[2] ^= iv[2]; + d[3] ^= iv[3]; + + iv[0] = buf[0]; + iv[1] = buf[1]; + iv[2] = buf[2]; + iv[3] = buf[3]; d += 4; len -= bs; } @@ -514,15 +591,18 @@ void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len) * * On i386 lifts 17k from .bss to .rodata * and avoids 1k code and setup time. - * -marko + * -marko */ #ifdef PRINT_TABS -static void show256u8(char *name, uint8 *data) +static void +show256u8(char *name, uint8 *data) { - int i; + int i; + printf("static const u1byte %s[256] = {\n ", name); - for (i = 0; i < 256; ) { + for (i = 0; i < 256;) + { printf("%u", pow_tab[i++]); if (i < 256) printf(i % 16 ? ", " : ",\n "); @@ -531,12 +611,17 @@ static void show256u8(char *name, uint8 *data) } -static void show4x256u32(char *name, uint32 data[4][256]) +static void +show4x256u32(char *name, uint32 data[4][256]) { - int i, j; + int i, + j; + printf("static const u4byte %s[4][256] = {\n{\n ", name); - for (i = 0; i < 4; i++) { - for (j = 0; j < 256; ) { + for (i = 0; i < 4; i++) + { + for (j = 0; j < 256;) + { printf("0x%08x", data[i][j]); j++; if (j < 256) @@ -547,11 +632,12 @@ static void show4x256u32(char *name, uint32 data[4][256]) printf("};\n\n"); } -int main() +int +main() { - int i; - char *hdr = "/* Generated by rijndael.c */\n\n"; - + int i; + char *hdr = "/* Generated by rijndael.c */\n\n"; + gen_tabs(); printf(hdr); @@ -559,7 +645,7 @@ int main() show256u8("log_tab", log_tab); show256u8("sbx_tab", sbx_tab); show256u8("isb_tab", isb_tab); - + show4x256u32("ft_tab", ft_tab); show4x256u32("it_tab", it_tab); #ifdef LARGE_TABLES @@ -567,14 +653,15 @@ int main() show4x256u32("il_tab", il_tab); #endif printf("static const u4byte rco_tab[10] = {\n "); - for (i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) + { printf("0x%08x", rco_tab[i]); - if (i < 9) printf(", "); - if (i == 4) printf("\n "); + if (i < 9) + printf(", "); + if (i == 4) + printf("\n "); } printf("\n};\n\n"); return 0; } - #endif - diff --git a/contrib/pgcrypto/rijndael.h b/contrib/pgcrypto/rijndael.h index bdefda828f..2f54e0c738 100644 --- a/contrib/pgcrypto/rijndael.h +++ b/contrib/pgcrypto/rijndael.h @@ -1,57 +1,57 @@ -/* $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */ - -/* This is an independent implementation of the encryption algorithm: */ -/* */ -/* RIJNDAEL by Joan Daemen and Vincent Rijmen */ -/* */ -/* which is a candidate algorithm in the Advanced Encryption Standard */ -/* programme of the US National Institute of Standards and Technology. */ -/* */ -/* Copyright in this implementation is held by Dr B R Gladman but I */ +/* $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */ + +/* This is an independent implementation of the encryption algorithm: */ +/* */ +/* RIJNDAEL by Joan Daemen and Vincent Rijmen */ +/* */ +/* which is a candidate algorithm in the Advanced Encryption Standard */ +/* programme of the US National Institute of Standards and Technology. */ +/* */ +/* Copyright in this implementation is held by Dr B R Gladman but I */ /* hereby give permission for its free direct or derivative use subject */ -/* to acknowledgment of its origin and compliance with any conditions */ -/* that the originators of the algorithm place on its exploitation. */ -/* */ -/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */ +/* to acknowledgment of its origin and compliance with any conditions */ +/* that the originators of the algorithm place on its exploitation. */ +/* */ +/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */ #ifndef _RIJNDAEL_H_ #define _RIJNDAEL_H_ -/* 1. Standard types for AES cryptography source code */ +/* 1. Standard types for AES cryptography source code */ -typedef uint8 u1byte; /* an 8 bit unsigned character type */ -typedef uint16 u2byte; /* a 16 bit unsigned integer type */ -typedef uint32 u4byte; /* a 32 bit unsigned integer type */ +typedef uint8 u1byte; /* an 8 bit unsigned character type */ +typedef uint16 u2byte; /* a 16 bit unsigned integer type */ +typedef uint32 u4byte; /* a 32 bit unsigned integer type */ -typedef int8 s1byte; /* an 8 bit signed character type */ -typedef int16 s2byte; /* a 16 bit signed integer type */ -typedef int32 s4byte; /* a 32 bit signed integer type */ +typedef int8 s1byte; /* an 8 bit signed character type */ +typedef int16 s2byte; /* a 16 bit signed integer type */ +typedef int32 s4byte; /* a 32 bit signed integer type */ -typedef struct _rijndael_ctx { - u4byte k_len; - int decrypt; - u4byte e_key[64]; - u4byte d_key[64]; -} rijndael_ctx; +typedef struct _rijndael_ctx +{ + u4byte k_len; + int decrypt; + u4byte e_key[64]; + u4byte d_key[64]; +} rijndael_ctx; -/* 2. Standard interface for AES cryptographic routines */ +/* 2. Standard interface for AES cryptographic routines */ /* These are all based on 32 bit unsigned values and will therefore */ -/* require endian conversions for big-endian architectures */ +/* require endian conversions for big-endian architectures */ rijndael_ctx * -rijndael_set_key (rijndael_ctx *, const u4byte *, const u4byte, int); -void rijndael_encrypt (rijndael_ctx *, const u4byte *, u4byte *); -void rijndael_decrypt (rijndael_ctx *, const u4byte *, u4byte *); + rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int); +void rijndael_encrypt(rijndael_ctx *, const u4byte *, u4byte *); +void rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *); /* conventional interface */ -void aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc); -void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len); -void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len); -void aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len); -void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len); +void aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc); +void aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len); +void aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len); +void aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len); +void aes_cbc_decrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len); - -#endif /* _RIJNDAEL_H_ */ +#endif /* _RIJNDAEL_H_ */ diff --git a/contrib/pgcrypto/sha1.c b/contrib/pgcrypto/sha1.c index 20c6230540..2609569790 100644 --- a/contrib/pgcrypto/sha1.c +++ b/contrib/pgcrypto/sha1.c @@ -1,4 +1,4 @@ -/* $Id: sha1.c,v 1.7 2001/10/25 01:29:37 momjian Exp $ */ +/* $Id: sha1.c,v 1.8 2001/10/25 05:49:20 momjian Exp $ */ /* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* @@ -87,7 +87,7 @@ do { \ static void sha1_step(struct sha1_ctxt *); static void -sha1_step(struct sha1_ctxt *ctxt) +sha1_step(struct sha1_ctxt * ctxt) { uint32 a, b, @@ -232,7 +232,7 @@ sha1_step(struct sha1_ctxt *ctxt) /*------------------------------------------------------------*/ void -sha1_init(struct sha1_ctxt *ctxt) +sha1_init(struct sha1_ctxt * ctxt) { bzero(ctxt, sizeof(struct sha1_ctxt)); H(0) = 0x67452301; @@ -243,7 +243,7 @@ sha1_init(struct sha1_ctxt *ctxt) } void -sha1_pad(struct sha1_ctxt *ctxt) +sha1_pad(struct sha1_ctxt * ctxt) { size_t padlen; /* pad length in bytes */ size_t padstart; @@ -286,7 +286,7 @@ sha1_pad(struct sha1_ctxt *ctxt) } void -sha1_loop(struct sha1_ctxt *ctxt, const uint8 *input0, size_t len) +sha1_loop(struct sha1_ctxt * ctxt, const uint8 *input0, size_t len) { const uint8 *input; size_t gaplen; @@ -314,7 +314,7 @@ sha1_loop(struct sha1_ctxt *ctxt, const uint8 *input0, size_t len) } void -sha1_result(struct sha1_ctxt *ctxt, uint8 *digest0) +sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0) { uint8 *digest; diff --git a/contrib/pgcrypto/sha1.h b/contrib/pgcrypto/sha1.h index c83bd7191a..03c6443ccc 100644 --- a/contrib/pgcrypto/sha1.h +++ b/contrib/pgcrypto/sha1.h @@ -1,4 +1,4 @@ -/* $Id: sha1.h,v 1.5 2001/08/21 00:42:41 momjian Exp $ */ +/* $Id: sha1.h,v 1.6 2001/10/25 05:49:20 momjian Exp $ */ /* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */ /* @@ -71,5 +71,4 @@ typedef struct sha1_ctxt SHA1_CTX; #define SHA1Final(x, y) sha1_result((y), (x)) #define SHA1_RESULTLEN (160/8) - #endif /* _NETINET6_SHA1_H_ */ diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index e88be90501..45e9229810 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.1 2001/10/01 01:52:38 ishii Exp $ + * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.2 2001/10/25 05:49:20 momjian Exp $ * * Copyright (c) 2001 Tatsuo Ishii * @@ -42,90 +42,91 @@ extern Datum pgstattuple(PG_FUNCTION_ARGS); Datum pgstattuple(PG_FUNCTION_ARGS) { - Name p = PG_GETARG_NAME(0); - - Relation rel; - HeapScanDesc scan; - HeapTuple tuple; - BlockNumber nblocks; - BlockNumber block = InvalidBlockNumber; - double table_len; - uint64 tuple_len = 0; - uint64 dead_tuple_len = 0; - uint32 tuple_count = 0; - uint32 dead_tuple_count = 0; - double tuple_percent; - double dead_tuple_percent; - - Buffer buffer = InvalidBuffer; - uint64 free_space = 0; /* free/reusable space in bytes */ - double free_percent; /* free/reusable space in % */ - - rel = heap_openr(NameStr(*p), NoLock); - nblocks = RelationGetNumberOfBlocks(rel); - scan = heap_beginscan(rel, false, SnapshotAny, 0, NULL); - - while ((tuple = heap_getnext(scan,0))) - { - if (HeapTupleSatisfiesNow(tuple->t_data)) + Name p = PG_GETARG_NAME(0); + + Relation rel; + HeapScanDesc scan; + HeapTuple tuple; + BlockNumber nblocks; + BlockNumber block = InvalidBlockNumber; + double table_len; + uint64 tuple_len = 0; + uint64 dead_tuple_len = 0; + uint32 tuple_count = 0; + uint32 dead_tuple_count = 0; + double tuple_percent; + double dead_tuple_percent; + + Buffer buffer = InvalidBuffer; + uint64 free_space = 0; /* free/reusable space in bytes */ + double free_percent; /* free/reusable space in % */ + + rel = heap_openr(NameStr(*p), NoLock); + nblocks = RelationGetNumberOfBlocks(rel); + scan = heap_beginscan(rel, false, SnapshotAny, 0, NULL); + + while ((tuple = heap_getnext(scan, 0))) { - tuple_len += tuple->t_len; - tuple_count++; + if (HeapTupleSatisfiesNow(tuple->t_data)) + { + tuple_len += tuple->t_len; + tuple_count++; + } + else + { + dead_tuple_len += tuple->t_len; + dead_tuple_count++; + } + + if (!BlockNumberIsValid(block) || + block != BlockIdGetBlockNumber(&tuple->t_self.ip_blkid)) + { + block = BlockIdGetBlockNumber(&tuple->t_self.ip_blkid); + buffer = ReadBuffer(rel, block); + free_space += PageGetFreeSpace((Page) BufferGetPage(buffer)); + ReleaseBuffer(buffer); + } } - else + heap_endscan(scan); + heap_close(rel, NoLock); + + table_len = (double) nblocks *BLCKSZ; + + if (nblocks == 0) { - dead_tuple_len += tuple->t_len; - dead_tuple_count++; + tuple_percent = 0.0; + dead_tuple_percent = 0.0; + free_percent = 0.0; } - - if (!BlockNumberIsValid(block) || - block != BlockIdGetBlockNumber(&tuple->t_self.ip_blkid)) + else { - block = BlockIdGetBlockNumber(&tuple->t_self.ip_blkid); - buffer = ReadBuffer(rel, block); - free_space += PageGetFreeSpace((Page)BufferGetPage(buffer)); - ReleaseBuffer(buffer); + tuple_percent = (double) tuple_len *100.0 / table_len; + dead_tuple_percent = (double) dead_tuple_len *100.0 / table_len; + free_percent = (double) free_space *100.0 / table_len; } - } - heap_endscan(scan); - heap_close(rel, NoLock); - - table_len = (double)nblocks*BLCKSZ; - - if (nblocks == 0) - { - tuple_percent = 0.0; - dead_tuple_percent = 0.0; - free_percent = 0.0; - } - else - { - tuple_percent = (double)tuple_len*100.0/table_len; - dead_tuple_percent = (double)dead_tuple_len*100.0/table_len; - free_percent = (double)free_space*100.0/table_len; - } - elog(NOTICE,"physical length: %.2fMB live tuples: %u (%.2fMB, %.2f%%) dead tuples: %u (%.2fMB, %.2f%%) free/reusable space: %.2fMB (%.2f%%) overhead: %.2f%%", + elog(NOTICE, "physical length: %.2fMB live tuples: %u (%.2fMB, %.2f%%) dead tuples: %u (%.2fMB, %.2f%%) free/reusable space: %.2fMB (%.2f%%) overhead: %.2f%%", - table_len/1024/1024, /* phsical length in MB */ + table_len / 1024 / 1024, /* phsical length in MB */ - tuple_count, /* number of live tuples */ - (double)tuple_len/1024/1024, /* live tuples in MB */ - tuple_percent, /* live tuples in % */ + tuple_count, /* number of live tuples */ + (double) tuple_len / 1024 / 1024, /* live tuples in MB */ + tuple_percent, /* live tuples in % */ - dead_tuple_count, /* number of dead tuples */ - (double)dead_tuple_len/1024/1024, /* dead tuples in MB */ - dead_tuple_percent, /* dead tuples in % */ + dead_tuple_count, /* number of dead tuples */ + (double) dead_tuple_len / 1024 / 1024, /* dead tuples in MB */ + dead_tuple_percent, /* dead tuples in % */ - (double)free_space/1024/1024, /* free/available space in MB */ + (double) free_space / 1024 / 1024, /* free/available space in + * MB */ - free_percent, /* free/available space in % */ + free_percent, /* free/available space in % */ - /* overhead in % */ - (nblocks == 0)?0.0: 100.0 - - tuple_percent - - dead_tuple_percent - - free_percent); + /* overhead in % */ + (nblocks == 0) ? 0.0 : 100.0 + - tuple_percent + - dead_tuple_percent + - free_percent); - PG_RETURN_FLOAT8(dead_tuple_percent); + PG_RETURN_FLOAT8(dead_tuple_percent); } diff --git a/contrib/rserv/rserv.c b/contrib/rserv/rserv.c index 02c71220d6..be4a136a1b 100644 --- a/contrib/rserv/rserv.c +++ b/contrib/rserv/rserv.c @@ -24,7 +24,6 @@ Datum _rserv_debug_(PG_FUNCTION_ARGS); HeapTuple _rserv_log_(void); int32 _rserv_sync_(int32); int32 _rserv_debug_(int32); - #endif static int debug = 0; @@ -44,7 +43,7 @@ _rserv_log_() char **args; /* argument: argnum */ Relation rel; /* triggered relation */ HeapTuple tuple; /* tuple to return */ - HeapTuple newtuple = NULL;/* tuple to return */ + HeapTuple newtuple = NULL; /* tuple to return */ TupleDesc tupdesc; /* tuple description */ int keynum; char *key; @@ -88,6 +87,7 @@ _rserv_log_() newtuple = CurrentTriggerData->tg_newtuple; #ifndef PG_FUNCTION_INFO_V1 + /* * Setting CurrentTriggerData to NULL prevents direct calls to trigger * functions in queries. Normally, trigger functions have to be called @@ -207,7 +207,6 @@ _rserv_sync_(int32 server) { #ifdef PG_FUNCTION_INFO_V1 int32 server = PG_GETARG_INT32(0); - #endif char sql[8192]; char buf[8192]; @@ -253,7 +252,6 @@ _rserv_debug_(int32 newval) { #ifdef PG_FUNCTION_INFO_V1 int32 newval = PG_GETARG_INT32(0); - #endif int32 oldval = debug; diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c index ca6263fc9e..cbbe024c03 100644 --- a/contrib/rtree_gist/rtree_gist.c +++ b/contrib/rtree_gist/rtree_gist.c @@ -1,13 +1,13 @@ /*------------------------------------------------------------------------- * * rtree_gist.c - * pg_amproc entries for GiSTs over 2-D boxes. + * pg_amproc entries for GiSTs over 2-D boxes. * This gives R-tree behavior, with Guttman's poly-time split algorithm. * * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.3 2001/10/01 17:53:11 tgl Exp $ + * $Header: /cvsroot/pgsql/contrib/rtree_gist/Attic/rtree_gist.c,v 1.4 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,9 +20,9 @@ #include "utils/geo_decls.h" #include "utils/elog.h" -typedef Datum (*RDF)(PG_FUNCTION_ARGS); -typedef Datum (*BINARY_UNION)(Datum, Datum, int*); -typedef float (*SIZE_BOX)(Datum); +typedef Datum (*RDF) (PG_FUNCTION_ARGS); +typedef Datum (*BINARY_UNION) (Datum, Datum, int *); +typedef float (*SIZE_BOX) (Datum); /* ** box ops @@ -34,24 +34,24 @@ PG_FUNCTION_INFO_V1(gbox_consistent); PG_FUNCTION_INFO_V1(gbox_penalty); PG_FUNCTION_INFO_V1(gbox_same); -Datum gbox_compress(PG_FUNCTION_ARGS); -Datum gbox_union(PG_FUNCTION_ARGS); -Datum gbox_picksplit(PG_FUNCTION_ARGS); -Datum gbox_consistent(PG_FUNCTION_ARGS); -Datum gbox_penalty(PG_FUNCTION_ARGS); -Datum gbox_same(PG_FUNCTION_ARGS); +Datum gbox_compress(PG_FUNCTION_ARGS); +Datum gbox_union(PG_FUNCTION_ARGS); +Datum gbox_picksplit(PG_FUNCTION_ARGS); +Datum gbox_consistent(PG_FUNCTION_ARGS); +Datum gbox_penalty(PG_FUNCTION_ARGS); +Datum gbox_same(PG_FUNCTION_ARGS); static bool gbox_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy); -static float size_box( Datum box ); +static float size_box(Datum box); /* -** Polygon ops +** Polygon ops */ PG_FUNCTION_INFO_V1(gpoly_compress); PG_FUNCTION_INFO_V1(gpoly_consistent); -Datum gpoly_compress(PG_FUNCTION_ARGS); -Datum gpoly_consistent(PG_FUNCTION_ARGS); +Datum gpoly_compress(PG_FUNCTION_ARGS); +Datum gpoly_consistent(PG_FUNCTION_ARGS); /* ** Common rtree-function (for all ops) @@ -60,7 +60,7 @@ static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strat PG_FUNCTION_INFO_V1(rtree_decompress); -Datum rtree_decompress(PG_FUNCTION_ARGS); +Datum rtree_decompress(PG_FUNCTION_ARGS); /************************************************** * Box ops @@ -75,21 +75,21 @@ Datum rtree_decompress(PG_FUNCTION_ARGS); Datum gbox_consistent(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); - BOX *query = (BOX*) PG_GETARG_POINTER(1); - StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); - - /* - ** if entry is not leaf, use gbox_internal_consistent, - ** else use gbox_leaf_consistent - */ - if ( ! (DatumGetPointer(entry->key) != NULL && query) ) + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + BOX *query = (BOX *) PG_GETARG_POINTER(1); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + + /* + * * if entry is not leaf, use gbox_internal_consistent, * else use + * gbox_leaf_consistent + */ + if (!(DatumGetPointer(entry->key) != NULL && query)) PG_RETURN_BOOL(FALSE); - if (GIST_LEAF(entry)) - PG_RETURN_BOOL(gbox_leaf_consistent((BOX *) DatumGetPointer(entry->key), query, strategy)); - else - PG_RETURN_BOOL(rtree_internal_consistent((BOX *) DatumGetPointer(entry->key), query, strategy)); + if (GIST_LEAF(entry)) + PG_RETURN_BOOL(gbox_leaf_consistent((BOX *) DatumGetPointer(entry->key), query, strategy)); + else + PG_RETURN_BOOL(rtree_internal_consistent((BOX *) DatumGetPointer(entry->key), query, strategy)); } @@ -100,30 +100,33 @@ gbox_consistent(PG_FUNCTION_ARGS) Datum gbox_union(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea*) PG_GETARG_POINTER(0); - int *sizep = (int*) PG_GETARG_POINTER(1); - int numranges, i; - BOX *cur, *pageunion; - - numranges = (VARSIZE(entryvec) - VARHDRSZ)/sizeof(GISTENTRY); - pageunion = (BOX *)palloc( sizeof(BOX) ); - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[0].key ); - memcpy( (void*)pageunion, (void*)cur, sizeof( BOX ) ); - - for (i = 1; i < numranges; i++) { - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[i].key ); - if ( pageunion->high.x < cur->high.x ) - pageunion->high.x = cur->high.x; - if ( pageunion->low.x > cur->low.x ) - pageunion->low.x = cur->low.x; - if ( pageunion->high.y < cur->high.y ) - pageunion->high.y = cur->high.y; - if ( pageunion->low.y > cur->low.y ) - pageunion->low.y = cur->low.y; - } - *sizep = sizeof(BOX); - - PG_RETURN_POINTER(pageunion); + bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + int *sizep = (int *) PG_GETARG_POINTER(1); + int numranges, + i; + BOX *cur, + *pageunion; + + numranges = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); + pageunion = (BOX *) palloc(sizeof(BOX)); + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[0].key); + memcpy((void *) pageunion, (void *) cur, sizeof(BOX)); + + for (i = 1; i < numranges; i++) + { + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[i].key); + if (pageunion->high.x < cur->high.x) + pageunion->high.x = cur->high.x; + if (pageunion->low.x > cur->low.x) + pageunion->low.x = cur->low.x; + if (pageunion->high.y < cur->high.y) + pageunion->high.y = cur->high.y; + if (pageunion->low.y > cur->low.y) + pageunion->low.y = cur->low.y; + } + *sizep = sizeof(BOX); + + PG_RETURN_POINTER(pageunion); } /* @@ -143,18 +146,19 @@ gbox_compress(PG_FUNCTION_ARGS) Datum gbox_penalty(PG_FUNCTION_ARGS) { - GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0); - GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1); - float *result = (float*) PG_GETARG_POINTER(2); - Datum ud; - float tmp1; - - ud = DirectFunctionCall2(rt_box_union, origentry->key, newentry->key); - tmp1 = size_box( ud ); - if (DatumGetPointer(ud) != NULL) pfree(DatumGetPointer(ud)); - - *result = tmp1 - size_box( origentry->key ); - PG_RETURN_POINTER(result); + GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); + GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1); + float *result = (float *) PG_GETARG_POINTER(2); + Datum ud; + float tmp1; + + ud = DirectFunctionCall2(rt_box_union, origentry->key, newentry->key); + tmp1 = size_box(ud); + if (DatumGetPointer(ud) != NULL) + pfree(DatumGetPointer(ud)); + + *result = tmp1 - size_box(origentry->key); + PG_RETURN_POINTER(result); } /* @@ -165,145 +169,183 @@ gbox_penalty(PG_FUNCTION_ARGS) Datum gbox_picksplit(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea*)PG_GETARG_POINTER(0); - GIST_SPLITVEC *v = (GIST_SPLITVEC*)PG_GETARG_POINTER(1); - OffsetNumber i; - OffsetNumber *listL, *listR, *listB, *listT; - BOX *unionL,*unionR,*unionB,*unionT; - int posL, posR, posB, posT; - BOX pageunion; - BOX *cur; - char direction=' '; - bool allisequal=true; - OffsetNumber maxoff; - int nbytes; - - posL = posR = posB = posT = 0; - maxoff = ((VARSIZE(entryvec) - VARHDRSZ)/sizeof(GISTENTRY)) - 1; - - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[FirstOffsetNumber].key ); - memcpy( (void*)&pageunion, (void*)cur, sizeof( BOX ) ); - - /* find MBR */ - for (i = OffsetNumberNext(FirstOffsetNumber); i <= maxoff; i = OffsetNumberNext(i)) { - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[i].key ); - if ( pageunion.high.x < cur->high.x ) - { allisequal=false; pageunion.high.x = cur->high.x; } - if ( pageunion.low.x > cur->low.x ) - { allisequal=false; pageunion.low.x = cur->low.x; } - if ( pageunion.high.y < cur->high.y ) - { allisequal=false; pageunion.high.y = cur->high.y; } - if ( pageunion.low.y > cur->low.y ) - { allisequal=false; pageunion.low.y = cur->low.y; } - } - - nbytes = (maxoff + 2) * sizeof(OffsetNumber); - listL = (OffsetNumber*)palloc( nbytes ); - listR = (OffsetNumber*)palloc( nbytes ); - unionL = (BOX*)palloc( sizeof(BOX) ); - unionR = (BOX*)palloc( sizeof(BOX) ); - if ( allisequal ) { - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[OffsetNumberNext(FirstOffsetNumber)].key ); - if ( memcmp( (void*)cur, (void*)&pageunion, sizeof( BOX ) ) == 0 ) { - v->spl_left = listL; - v->spl_right = listR; - v->spl_nleft = v->spl_nright = 0; - memcpy( (void*)unionL, (void*)&pageunion, sizeof( BOX ) ); - memcpy( (void*)unionR, (void*)&pageunion, sizeof( BOX ) ); - - for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - if (i <= (maxoff - FirstOffsetNumber + 1)/2) { - v->spl_left[ v->spl_nleft ] = i; - v->spl_nleft++; - } else { - v->spl_right[ v->spl_nright ] = i; - v->spl_nright++; - } + bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1); + OffsetNumber i; + OffsetNumber *listL, + *listR, + *listB, + *listT; + BOX *unionL, + *unionR, + *unionB, + *unionT; + int posL, + posR, + posB, + posT; + BOX pageunion; + BOX *cur; + char direction = ' '; + bool allisequal = true; + OffsetNumber maxoff; + int nbytes; + + posL = posR = posB = posT = 0; + maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 1; + + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[FirstOffsetNumber].key); + memcpy((void *) &pageunion, (void *) cur, sizeof(BOX)); + + /* find MBR */ + for (i = OffsetNumberNext(FirstOffsetNumber); i <= maxoff; i = OffsetNumberNext(i)) + { + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[i].key); + if (pageunion.high.x < cur->high.x) + { + allisequal = false; + pageunion.high.x = cur->high.x; } - v->spl_ldatum = BoxPGetDatum( unionL ); - v->spl_rdatum = BoxPGetDatum( unionR ); + if (pageunion.low.x > cur->low.x) + { + allisequal = false; + pageunion.low.x = cur->low.x; + } + if (pageunion.high.y < cur->high.y) + { + allisequal = false; + pageunion.high.y = cur->high.y; + } + if (pageunion.low.y > cur->low.y) + { + allisequal = false; + pageunion.low.y = cur->low.y; + } + } - PG_RETURN_POINTER( v ); + nbytes = (maxoff + 2) * sizeof(OffsetNumber); + listL = (OffsetNumber *) palloc(nbytes); + listR = (OffsetNumber *) palloc(nbytes); + unionL = (BOX *) palloc(sizeof(BOX)); + unionR = (BOX *) palloc(sizeof(BOX)); + if (allisequal) + { + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[OffsetNumberNext(FirstOffsetNumber)].key); + if (memcmp((void *) cur, (void *) &pageunion, sizeof(BOX)) == 0) + { + v->spl_left = listL; + v->spl_right = listR; + v->spl_nleft = v->spl_nright = 0; + memcpy((void *) unionL, (void *) &pageunion, sizeof(BOX)); + memcpy((void *) unionR, (void *) &pageunion, sizeof(BOX)); + + for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) + { + if (i <= (maxoff - FirstOffsetNumber + 1) / 2) + { + v->spl_left[v->spl_nleft] = i; + v->spl_nleft++; + } + else + { + v->spl_right[v->spl_nright] = i; + v->spl_nright++; + } + } + v->spl_ldatum = BoxPGetDatum(unionL); + v->spl_rdatum = BoxPGetDatum(unionR); + + PG_RETURN_POINTER(v); + } } - } - listB = (OffsetNumber*)palloc( nbytes ); - listT = (OffsetNumber*)palloc( nbytes ); - unionB = (BOX*)palloc( sizeof(BOX) ); - unionT = (BOX*)palloc( sizeof(BOX) ); + listB = (OffsetNumber *) palloc(nbytes); + listT = (OffsetNumber *) palloc(nbytes); + unionB = (BOX *) palloc(sizeof(BOX)); + unionT = (BOX *) palloc(sizeof(BOX)); #define ADDLIST( list, unionD, pos ) do { \ if ( pos ) { \ - if ( unionD->high.x < cur->high.x ) unionD->high.x = cur->high.x; \ - if ( unionD->low.x > cur->low.x ) unionD->low.x = cur->low.x; \ - if ( unionD->high.y < cur->high.y ) unionD->high.y = cur->high.y; \ - if ( unionD->low.y > cur->low.y ) unionD->low.y = cur->low.y; \ + if ( unionD->high.x < cur->high.x ) unionD->high.x = cur->high.x; \ + if ( unionD->low.x > cur->low.x ) unionD->low.x = cur->low.x; \ + if ( unionD->high.y < cur->high.y ) unionD->high.y = cur->high.y; \ + if ( unionD->low.y > cur->low.y ) unionD->low.y = cur->low.y; \ } else { \ - memcpy( (void*)unionD, (void*) cur, sizeof( BOX ) ); \ + memcpy( (void*)unionD, (void*) cur, sizeof( BOX ) ); \ } \ list[pos] = i; \ (pos)++; \ } while(0) - for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - cur = DatumGetBoxP( ((GISTENTRY *) VARDATA(entryvec))[i].key ); - if ( cur->low.x - pageunion.low.x < pageunion.high.x - cur->high.x ) - ADDLIST( listL, unionL, posL ); - else - ADDLIST( listR, unionR, posR ); - if ( cur->low.y - pageunion.low.y < pageunion.high.y - cur->high.y ) - ADDLIST( listB, unionB, posB ); - else - ADDLIST( listT, unionT, posT ); - } - - /* which split more optimal? */ - - if ( Max( posL, posR ) < Max( posB, posT ) ) { - direction = 'x'; - } else if ( Max( posL, posR ) > Max( posB, posT ) ) { - direction = 'y'; - } else { - Datum interLR = DirectFunctionCall2(rt_box_inter, - BoxPGetDatum(unionL), - BoxPGetDatum(unionR)); - Datum interBT = DirectFunctionCall2(rt_box_inter, - BoxPGetDatum(unionB), - BoxPGetDatum(unionT)); - float sizeLR, sizeBT; - - sizeLR = size_box( interLR ); - sizeBT = size_box( interBT ); - - if ( sizeLR < sizeBT ) + for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) + { + cur = DatumGetBoxP(((GISTENTRY *) VARDATA(entryvec))[i].key); + if (cur->low.x - pageunion.low.x < pageunion.high.x - cur->high.x) + ADDLIST(listL, unionL, posL); + else + ADDLIST(listR, unionR, posR); + if (cur->low.y - pageunion.low.y < pageunion.high.y - cur->high.y) + ADDLIST(listB, unionB, posB); + else + ADDLIST(listT, unionT, posT); + } + + /* which split more optimal? */ + + if (Max(posL, posR) < Max(posB, posT)) direction = 'x'; - else + else if (Max(posL, posR) > Max(posB, posT)) direction = 'y'; + else + { + Datum interLR = DirectFunctionCall2(rt_box_inter, + BoxPGetDatum(unionL), + BoxPGetDatum(unionR)); + Datum interBT = DirectFunctionCall2(rt_box_inter, + BoxPGetDatum(unionB), + BoxPGetDatum(unionT)); + float sizeLR, + sizeBT; + + sizeLR = size_box(interLR); + sizeBT = size_box(interBT); + + if (sizeLR < sizeBT) + direction = 'x'; + else + direction = 'y'; + } + + if (direction == 'x') + { + pfree(unionB); + pfree(listB); + pfree(unionT); + pfree(listT); + + v->spl_left = listL; + v->spl_right = listR; + v->spl_nleft = posL; + v->spl_nright = posR; + v->spl_ldatum = BoxPGetDatum(unionL); + v->spl_rdatum = BoxPGetDatum(unionR); + } + else + { + pfree(unionR); + pfree(listR); + pfree(unionL); + pfree(listL); + + v->spl_left = listB; + v->spl_right = listT; + v->spl_nleft = posB; + v->spl_nright = posT; + v->spl_ldatum = BoxPGetDatum(unionB); + v->spl_rdatum = BoxPGetDatum(unionT); } - if ( direction == 'x' ) { - pfree( unionB ); pfree( listB ); - pfree( unionT ); pfree( listT ); - - v->spl_left = listL; - v->spl_right = listR; - v->spl_nleft = posL; - v->spl_nright = posR; - v->spl_ldatum = BoxPGetDatum( unionL ); - v->spl_rdatum = BoxPGetDatum( unionR ); - } else { - pfree( unionR ); pfree( listR ); - pfree( unionL ); pfree( listL ); - - v->spl_left = listB; - v->spl_right = listT; - v->spl_nleft = posB; - v->spl_nright = posT; - v->spl_ldatum = BoxPGetDatum( unionB ); - v->spl_rdatum = BoxPGetDatum( unionT ); - } - - PG_RETURN_POINTER (v); + PG_RETURN_POINTER(v); } /* @@ -312,66 +354,71 @@ gbox_picksplit(PG_FUNCTION_ARGS) Datum gbox_same(PG_FUNCTION_ARGS) { - BOX *b1 = (BOX*) PG_GETARG_POINTER(0); - BOX *b2 = (BOX*) PG_GETARG_POINTER(1); - bool *result = (bool*) PG_GETARG_POINTER(2); - if ( b1 && b2 ) - *result = DatumGetBool( DirectFunctionCall2( box_same, PointerGetDatum(b1), PointerGetDatum(b2)) ); - else - *result = ( b1==NULL && b2==NULL ) ? TRUE : FALSE; - PG_RETURN_POINTER(result); + BOX *b1 = (BOX *) PG_GETARG_POINTER(0); + BOX *b2 = (BOX *) PG_GETARG_POINTER(1); + bool *result = (bool *) PG_GETARG_POINTER(2); + + if (b1 && b2) + *result = DatumGetBool(DirectFunctionCall2(box_same, PointerGetDatum(b1), PointerGetDatum(b2))); + else + *result = (b1 == NULL && b2 == NULL) ? TRUE : FALSE; + PG_RETURN_POINTER(result); } -/* +/* ** SUPPORT ROUTINES for boxes */ -static bool +static bool gbox_leaf_consistent(BOX *key, - BOX *query, - StrategyNumber strategy) + BOX *query, + StrategyNumber strategy) { - bool retval; - - switch(strategy) { - case RTLeftStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_left, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTOverLeftStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overleft, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTOverlapStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overlap, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTOverRightStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overright, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTRightStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_right, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTSameStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_same, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTContainsStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_contain, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTContainedByStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_contained, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - default: - retval = FALSE; - } - return(retval); + bool retval; + + switch (strategy) + { + case RTLeftStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_left, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverLeftStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overleft, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverlapStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverRightStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overright, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTRightStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_right, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTSameStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_same, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTContainsStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_contain, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTContainedByStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_contained, PointerGetDatum(key), PointerGetDatum(query))); + break; + default: + retval = FALSE; + } + return (retval); } -static float -size_box( Datum box ) { - if ( DatumGetPointer(box) != NULL ) { - float size; +static float +size_box(Datum box) +{ + if (DatumGetPointer(box) != NULL) + { + float size; - DirectFunctionCall2( rt_box_size, - box, PointerGetDatum( &size ) ); + DirectFunctionCall2(rt_box_size, + box, PointerGetDatum(&size)); return size; - } else + } + else return 0.0; } @@ -382,91 +429,97 @@ size_box( Datum box ) { Datum gpoly_compress(PG_FUNCTION_ARGS) { - GISTENTRY *entry=(GISTENTRY*)PG_GETARG_POINTER(0); - GISTENTRY *retval; + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + GISTENTRY *retval; - if ( entry->leafkey) { + if (entry->leafkey) + { retval = palloc(sizeof(GISTENTRY)); - if ( DatumGetPointer(entry->key) != NULL ) { - POLYGON *in; - BOX *r; + if (DatumGetPointer(entry->key) != NULL) + { + POLYGON *in; + BOX *r; + in = (POLYGON *) PG_DETOAST_DATUM(entry->key); - r = (BOX *) palloc( sizeof(BOX) ); - memcpy( (void*)r, (void*)&(in->boundbox), sizeof(BOX) ); - if ( in != (POLYGON *) DatumGetPointer(entry->key) ) - pfree( in ); + r = (BOX *) palloc(sizeof(BOX)); + memcpy((void *) r, (void *) &(in->boundbox), sizeof(BOX)); + if (in != (POLYGON *) DatumGetPointer(entry->key)) + pfree(in); gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page, entry->offset, sizeof(BOX), FALSE); - } else { + } + else + { gistentryinit(*retval, (Datum) 0, entry->rel, entry->page, - entry->offset, 0,FALSE); - } - } else { - retval = entry; + entry->offset, 0, FALSE); + } } - PG_RETURN_POINTER( retval ); + else + retval = entry; + PG_RETURN_POINTER(retval); } Datum gpoly_consistent(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); - POLYGON *query = (POLYGON*)PG_DETOAST_DATUM( PG_GETARG_POINTER(1) ); - StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); - bool result; - - /* - ** if entry is not leaf, use gbox_internal_consistent, - ** else use gbox_leaf_consistent - */ - if ( ! (DatumGetPointer(entry->key) != NULL && query) ) + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + POLYGON *query = (POLYGON *) PG_DETOAST_DATUM(PG_GETARG_POINTER(1)); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + bool result; + + /* + * * if entry is not leaf, use gbox_internal_consistent, * else use + * gbox_leaf_consistent + */ + if (!(DatumGetPointer(entry->key) != NULL && query)) PG_RETURN_BOOL(FALSE); - result = rtree_internal_consistent((BOX *) DatumGetPointer(entry->key), - &(query->boundbox), strategy); + result = rtree_internal_consistent((BOX *) DatumGetPointer(entry->key), + &(query->boundbox), strategy); - PG_FREE_IF_COPY(query,1); - PG_RETURN_BOOL( result ); + PG_FREE_IF_COPY(query, 1); + PG_RETURN_BOOL(result); } /***************************************** * Common rtree-function (for all ops) *****************************************/ -static bool +static bool rtree_internal_consistent(BOX *key, - BOX *query, - StrategyNumber strategy) + BOX *query, + StrategyNumber strategy) { - bool retval; - - switch(strategy) { - case RTLeftStrategyNumber: - case RTOverLeftStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overleft, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTOverlapStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overlap, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTOverRightStrategyNumber: - case RTRightStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_right, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTSameStrategyNumber: - case RTContainsStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_contain, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - case RTContainedByStrategyNumber: - retval = DatumGetBool( DirectFunctionCall2( box_overlap, PointerGetDatum(key), PointerGetDatum(query) ) ); - break; - default: - retval = FALSE; - } - return(retval); + bool retval; + + switch (strategy) + { + case RTLeftStrategyNumber: + case RTOverLeftStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overleft, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverlapStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverRightStrategyNumber: + case RTRightStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_right, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTSameStrategyNumber: + case RTContainsStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_contain, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTContainedByStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query))); + break; + default: + retval = FALSE; + } + return (retval); } /* diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 124299ab44..097304b638 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -138,7 +138,6 @@ seg_out(SEG * seg) if (seg->lower == seg->upper && seg->l_ext == seg->u_ext) { - /* * indicates that this interval was built by seg_in off a single * point @@ -219,7 +218,6 @@ gseg_consistent(GISTENTRY *entry, SEG * query, StrategyNumber strategy) { - /* * * if entry is not leaf, use gseg_internal_consistent, * else use * gseg_leaf_consistent @@ -253,7 +251,7 @@ gseg_union(bytea *entryvec, int *sizep) for (i = 1; i < numranges; i++) { out = gseg_binary_union(tmp, (SEG *) - DatumGetPointer(((GISTENTRY *) VARDATA(entryvec))[i].key), + DatumGetPointer(((GISTENTRY *) VARDATA(entryvec))[i].key), sizep); if (i > 1) pfree(tmp); @@ -267,13 +265,13 @@ gseg_union(bytea *entryvec, int *sizep) ** GiST Compress and Decompress methods for segments ** do not do anything. */ -GISTENTRY * +GISTENTRY * gseg_compress(GISTENTRY *entry) { return (entry); } -GISTENTRY * +GISTENTRY * gseg_decompress(GISTENTRY *entry) { return (entry); @@ -415,7 +413,6 @@ gseg_picksplit(bytea *entryvec, maxoff = OffsetNumberNext(maxoff); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - /* * If we've already decided where to place this item, just put it * on the right list. Otherwise, we need to figure out which page @@ -614,7 +611,7 @@ seg_overlap(SEG * a, SEG * b) ((a->upper >= b->upper) && (a->lower <= b->upper)) || ((b->upper >= a->upper) && (b->lower <= a->upper)) - ); + ); } /* seg_overleft -- is the right edge of (a) located to the left of the right edge of (b)? @@ -757,7 +754,6 @@ seg_size(SEG * a) int32 seg_cmp(SEG * a, SEG * b) { - /* * First compare on lower boundary position */ @@ -968,7 +964,6 @@ restore(char *result, float val, int n) { if (abs(exp) <= 4) { - /* * remove the decimal point from the mantyssa and write the * digits to the buf array @@ -989,7 +984,6 @@ restore(char *result, float val, int n) { if (dp - 10 + exp >= n) { - /* * the decimal point is behind the last significant * digit; the digits in between must be converted to diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index dcc9f54daf..441c1e884d 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -52,7 +52,7 @@ check_primary_key(PG_FUNCTION_ARGS) HeapTuple tuple = NULL; /* tuple to return */ TupleDesc tupdesc; /* tuple description */ EPlan *plan; /* prepared plan */ - Oid *argtypes = NULL;/* key types to prepare execution plan */ + Oid *argtypes = NULL; /* key types to prepare execution plan */ bool isnull; /* to know is some column NULL or not */ char ident[2 * NAMEDATALEN]; /* to identify myself */ int ret; @@ -235,10 +235,10 @@ check_foreign_key(PG_FUNCTION_ARGS) char *relname; /* referencing relation name */ Relation rel; /* triggered relation */ HeapTuple trigtuple = NULL; /* tuple to being changed */ - HeapTuple newtuple = NULL;/* tuple to return */ + HeapTuple newtuple = NULL; /* tuple to return */ TupleDesc tupdesc; /* tuple description */ EPlan *plan; /* prepared plan(s) */ - Oid *argtypes = NULL;/* key types to prepare execution plan */ + Oid *argtypes = NULL; /* key types to prepare execution plan */ bool isnull; /* to know is some column NULL or not */ bool isequal = true; /* are keys in both tuples equal (in * UPDATE) */ @@ -402,11 +402,11 @@ check_foreign_key(PG_FUNCTION_ARGS) /*--------- * For 'R'estrict action we construct SELECT query: * - * SELECT 1 + * SELECT 1 * FROM _referencing_relation_ * WHERE Fkey1 = $1 [AND Fkey2 = $2 [...]] * - * to check is tuple referenced or not. + * to check is tuple referenced or not. *--------- */ if (action == 'r') @@ -537,7 +537,6 @@ check_foreign_key(PG_FUNCTION_ARGS) */ for (r = 0; r < nrefs; r++) { - /* * For 'R'estrict we may to execute plan for one tuple only, for * other actions - for all tuples. diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c index 840782dd51..fdc6da1915 100644 --- a/contrib/string/string_io.c +++ b/contrib/string/string_io.c @@ -359,7 +359,6 @@ c_charin(unsigned char *str) { return (string_input(str, 1, 0, NULL)); } - #endif /* end of file */ diff --git a/contrib/string/string_io.h b/contrib/string/string_io.h index 556c33660c..b6a368698a 100644 --- a/contrib/string/string_io.h +++ b/contrib/string/string_io.h @@ -13,7 +13,6 @@ struct varlena *c_textin(unsigned char *str); int32 * c_charin(unsigned char *str) #endif - #endif /* diff --git a/contrib/tsearch/crc32.c b/contrib/tsearch/crc32.c index 61cb6ed3ed..dc93db727c 100644 --- a/contrib/tsearch/crc32.c +++ b/contrib/tsearch/crc32.c @@ -87,15 +87,17 @@ static const unsigned int crc32tab[256] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; -unsigned int crc32_sz(char * buf, int size){ +unsigned int +crc32_sz(char *buf, int size) +{ unsigned int crc = ~0; - char *p ; - int len, nr; + char *p; + int len, + nr; - len = 0 ; - nr=size; - for (len += nr, p = buf; nr--; ++p) { - _CRC32_(crc, *p) ; - } + len = 0; + nr = size; + for (len += nr, p = buf; nr--; ++p) + _CRC32_(crc, *p); return ~crc; } diff --git a/contrib/tsearch/crc32.h b/contrib/tsearch/crc32.h index c4f5ed703c..b08065d8c8 100644 --- a/contrib/tsearch/crc32.h +++ b/contrib/tsearch/crc32.h @@ -2,9 +2,8 @@ #define _CRC32_H /* Returns crc32 of data block */ -extern unsigned int crc32_sz(char * buf, int size); +extern unsigned int crc32_sz(char *buf, int size); /* Returns crc32 of null-terminated string */ #define crc32(buf) crc32_sz((buf),strlen(buf)) - #endif diff --git a/contrib/tsearch/deflex.h b/contrib/tsearch/deflex.h index 8c74595a68..7fbd84adf1 100644 --- a/contrib/tsearch/deflex.h +++ b/contrib/tsearch/deflex.h @@ -12,12 +12,12 @@ #define HOST 6 #define FLOAT 7 #define FINT 8 -#define PARTWORD 9 -#define NONLATINPARTWORD 10 -#define LATPARTWORD 11 -#define SPACE 12 -#define SYMTAG 13 -#define HTTP 14 +#define PARTWORD 9 +#define NONLATINPARTWORD 10 +#define LATPARTWORD 11 +#define SPACE 12 +#define SYMTAG 13 +#define HTTP 14 #define DEFISWORD 15 #define DEFISLATWORD 16 #define DEFISNONLATINWORD 17 @@ -25,6 +25,4 @@ #define FILEPATH 19 extern const char *descr[]; - #endif - diff --git a/contrib/tsearch/gistidx.h b/contrib/tsearch/gistidx.h index dc991ab0d7..f4576a1d24 100644 --- a/contrib/tsearch/gistidx.h +++ b/contrib/tsearch/gistidx.h @@ -9,7 +9,8 @@ * signature defines */ #define BITBYTE 8 -#define SIGLENINT 64 /* >121 => key will toast, so it will not work !!! */ +#define SIGLENINT 64 /* >121 => key will toast, so it will not + * work !!! */ #define SIGLEN ( sizeof(int4)*SIGLENINT ) #define SIGLENBIT (SIGLEN*BITBYTE) @@ -21,9 +22,9 @@ typedef char *BITVECP; a;\ } #define LOOPBIT(a) \ - for(i=0;i<SIGLENBIT;i++) {\ - a;\ - } + for(i=0;i<SIGLENBIT;i++) {\ + a;\ + } #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) #define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) @@ -38,27 +39,27 @@ typedef char *BITVECP; /* - * type of index key + * type of index key */ -typedef struct { - int4 len; - int4 flag; - char data[1]; -} GISTTYPE; +typedef struct +{ + int4 len; + int4 flag; + char data[1]; +} GISTTYPE; -#define ARRKEY 0x01 -#define SIGNKEY 0x02 -#define ALLISTRUE 0x04 +#define ARRKEY 0x01 +#define SIGNKEY 0x02 +#define ALLISTRUE 0x04 -#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) +#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) #define ISSIGNKEY(x) ( ((GISTTYPE*)x)->flag & SIGNKEY ) #define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) -#define GTHDRSIZE ( sizeof(int4)*2 ) +#define GTHDRSIZE ( sizeof(int4)*2 ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) #define GETARR(x) ( (int4*)( (char*)x+GTHDRSIZE ) ) -#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) +#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) #endif - diff --git a/contrib/tsearch/morph.c b/contrib/tsearch/morph.c index a31946ac86..3a66ecbbc6 100644 --- a/contrib/tsearch/morph.c +++ b/contrib/tsearch/morph.c @@ -3,7 +3,7 @@ * New dictionary is include in dict.h. For languages which * use latin charset it may be need to modify mapdict table. * Teodor Sigaev <teodor@stack.net> - */ + */ #include "postgres.h" #include "utils/elog.h" @@ -20,157 +20,183 @@ * All of this methods are optional, but * if all methods are NULL, then dictionary does nothing :) * Return value of lemmatize must be palloced or the same. - * Return value of init must be malloced in other case - * it will be free in end of transaction! + * Return value of init must be malloced in other case + * it will be free in end of transaction! */ -typedef struct { - char localename[LOCALE_NAME_BUFLEN]; +typedef struct +{ + char localename[LOCALE_NAME_BUFLEN]; /* init dictionary */ - void* (*init)(void); + void *(*init) (void); /* close dictionary */ - void (*close)(void*); + void (*close) (void *); /* find in dictionary */ - char* (*lemmatize)(void*,char*,int*); - int (*is_stoplemm)(void*,char*,int); - int (*is_stemstoplemm)(void*,char*,int); -} DICT; + char *(*lemmatize) (void *, char *, int *); + int (*is_stoplemm) (void *, char *, int); + int (*is_stemstoplemm) (void *, char *, int); +} DICT; /* insert all dictionaries */ #define DICT_BODY #include "dict.h" -#undef DICT_BODY +#undef DICT_BODY -/* fill dictionary's structure */ +/* fill dictionary's structure */ #define DICT_TABLE -DICT dicts[] = { +DICT dicts[] = { { - "C",NULL,NULL,NULL,NULL,NULL /* fake dictionary */ + "C", NULL, NULL, NULL, NULL, NULL /* fake dictionary */ } #include "dict.h" }; + #undef DICT_TABLE /* array for storing dictinary's objects (if needed) */ -void* dictobjs[ lengthof(dicts) ]; +void *dictobjs[ + lengthof(dicts)]; #define STOPLEXEM -2 #define BYLOCALE -1 -#define NODICT 0 -#define DEFAULTDICT 1 - +#define NODICT 0 +#define DEFAULTDICT 1 + #define MAXNDICT 2 -typedef int2 MAPDICT[MAXNDICT]; +typedef int2 MAPDICT[MAXNDICT]; + #define GETDICT(x,i) *( ((int2*)(x)) + (i) ) /* map dictionaries for lexem type */ static MAPDICT mapdict[] = { - {NODICT, NODICT}, /* not used */ - {DEFAULTDICT, NODICT}, /* LATWORD */ - {BYLOCALE, NODICT}, /* NONLATINWORD */ - {BYLOCALE, DEFAULTDICT}, /* UWORD */ - {NODICT, NODICT}, /* EMAIL */ - {NODICT, NODICT}, /* FURL */ - {NODICT, NODICT}, /* HOST */ - {NODICT, NODICT}, /* FLOAT */ - {NODICT, NODICT}, /* FINT */ - {BYLOCALE, DEFAULTDICT}, /* PARTWORD */ - {BYLOCALE, NODICT}, /* NONLATINPARTWORD */ - {DEFAULTDICT, NODICT}, /* LATPARTWORD */ - {STOPLEXEM, NODICT}, /* SPACE */ - {STOPLEXEM, NODICT}, /* SYMTAG */ - {STOPLEXEM, NODICT}, /* HTTP */ - {BYLOCALE, DEFAULTDICT}, /* DEFISWORD */ - {DEFAULTDICT, NODICT}, /* DEFISLATWORD */ - {BYLOCALE, NODICT}, /* DEFISNONLATINWORD */ - {NODICT, NODICT}, /* URI */ - {NODICT, NODICT} /* FILEPATH */ + {NODICT, NODICT}, /* not used */ + {DEFAULTDICT, NODICT}, /* LATWORD */ + {BYLOCALE, NODICT}, /* NONLATINWORD */ + {BYLOCALE, DEFAULTDICT}, /* UWORD */ + {NODICT, NODICT}, /* EMAIL */ + {NODICT, NODICT}, /* FURL */ + {NODICT, NODICT}, /* HOST */ + {NODICT, NODICT}, /* FLOAT */ + {NODICT, NODICT}, /* FINT */ + {BYLOCALE, DEFAULTDICT}, /* PARTWORD */ + {BYLOCALE, NODICT}, /* NONLATINPARTWORD */ + {DEFAULTDICT, NODICT}, /* LATPARTWORD */ + {STOPLEXEM, NODICT}, /* SPACE */ + {STOPLEXEM, NODICT}, /* SYMTAG */ + {STOPLEXEM, NODICT}, /* HTTP */ + {BYLOCALE, DEFAULTDICT}, /* DEFISWORD */ + {DEFAULTDICT, NODICT}, /* DEFISLATWORD */ + {BYLOCALE, NODICT}, /* DEFISNONLATINWORD */ + {NODICT, NODICT}, /* URI */ + {NODICT, NODICT} /* FILEPATH */ }; -static bool inited=false; +static bool inited = false; + +void +initmorph(void) +{ + int i, + j, + k; + MAPDICT *md; + bool needinit[lengthof(dicts)]; -void initmorph(void) { - int i,j,k; - MAPDICT *md; - bool needinit[ lengthof(dicts) ]; #ifdef USE_LOCALE - PG_LocaleCategories lc; + PG_LocaleCategories lc; - int bylocaledict = NODICT; + int bylocaledict = NODICT; #endif - if ( inited ) return; - for(i=1; i<lengthof(dicts);i++) + if (inited) + return; + for (i = 1; i < lengthof(dicts); i++) needinit[i] = false; - + #ifdef USE_LOCALE PGLC_current(&lc); - for(i=1;i<lengthof(dicts);i++) - if (strcmp( dicts[i].localename, lc.lang ) == 0) { + for (i = 1; i < lengthof(dicts); i++) + if (strcmp(dicts[i].localename, lc.lang) == 0) + { bylocaledict = i; break; } PGLC_free_categories(&lc); #endif - for(i=1; i<lengthof(mapdict);i++) { - k=0; + for (i = 1; i < lengthof(mapdict); i++) + { + k = 0; md = &mapdict[i]; - for(j=0;j<MAXNDICT;j++) { - GETDICT(md,k) = GETDICT(md,j); - if ( GETDICT(md,k) == NODICT ) { + for (j = 0; j < MAXNDICT; j++) + { + GETDICT(md, k) = GETDICT(md, j); + if (GETDICT(md, k) == NODICT) break; - } else if ( GETDICT(md,k) == BYLOCALE ) { + else if (GETDICT(md, k) == BYLOCALE) + { #ifdef USE_LOCALE - if ( bylocaledict == NODICT ) + if (bylocaledict == NODICT) continue; - GETDICT(md,k) = bylocaledict; + GETDICT(md, k) = bylocaledict; #else continue; #endif } - if ( GETDICT(md,k) >= (int2)lengthof(dicts) ) + if (GETDICT(md, k) >= (int2) lengthof(dicts)) continue; - needinit[ GETDICT(md,k) ] = true; - k++; + needinit[GETDICT(md, k)] = true; + k++; } - for(;k<MAXNDICT;k++) - if ( GETDICT(md,k) != STOPLEXEM ) - GETDICT(md,k) = NODICT; + for (; k < MAXNDICT; k++) + if (GETDICT(md, k) != STOPLEXEM) + GETDICT(md, k) = NODICT; } - for(i=1; i<lengthof(dicts);i++) - if ( needinit[i] && dicts[i].init ) - dictobjs[i] = (*(dicts[i].init))(); - + for (i = 1; i < lengthof(dicts); i++) + if (needinit[i] && dicts[i].init) + dictobjs[i] = (*(dicts[i].init)) (); + inited = true; return; } -char* lemmatize( char* word, int *len, int type ) { - int2 nd; - int i; - DICT *dict; +char * +lemmatize(char *word, int *len, int type) +{ + int2 nd; + int i; + DICT *dict; - for(i=0;i<MAXNDICT;i++) { - nd = GETDICT( &mapdict[type], i ); - if ( nd == NODICT ) { - /* there is no dictionary */ + for (i = 0; i < MAXNDICT; i++) + { + nd = GETDICT(&mapdict[type], i); + if (nd == NODICT) + { + /* there is no dictionary */ return word; - } else if ( nd == STOPLEXEM ) { + } + else if (nd == STOPLEXEM) + { /* word is stopword */ return NULL; - } else { - dict = &dicts[ nd ]; - if ( dict->is_stoplemm && (*(dict->is_stoplemm))(dictobjs[nd], word, *len) ) + } + else + { + dict = &dicts[nd]; + if (dict->is_stoplemm && (*(dict->is_stoplemm)) (dictobjs[nd], word, *len)) return NULL; - if ( dict->lemmatize ) { - int oldlen = *len; - char *newword = (*(dict->lemmatize))(dictobjs[nd], word, len); + if (dict->lemmatize) + { + int oldlen = *len; + char *newword = (*(dict->lemmatize)) (dictobjs[nd], word, len); + /* word is recognized by distionary */ - if ( newword != word || *len != oldlen ) { - if ( dict->is_stemstoplemm && - (*(dict->is_stemstoplemm))(dictobjs[nd], word, *len) ) { - if ( newword != word && newword) + if (newword != word || *len != oldlen) + { + if (dict->is_stemstoplemm && + (*(dict->is_stemstoplemm)) (dictobjs[nd], word, *len)) + { + if (newword != word && newword) pfree(newword); return NULL; } @@ -183,6 +209,8 @@ char* lemmatize( char* word, int *len, int type ) { return word; } -bool is_stoptype(int type) { - return ( GETDICT( &mapdict[type], 0 ) == STOPLEXEM ) ? true : false; +bool +is_stoptype(int type) +{ + return (GETDICT(&mapdict[type], 0) == STOPLEXEM) ? true : false; } diff --git a/contrib/tsearch/morph.h b/contrib/tsearch/morph.h index 1e8f361ed9..1c64227fae 100644 --- a/contrib/tsearch/morph.h +++ b/contrib/tsearch/morph.h @@ -1,9 +1,9 @@ #ifndef __MORPH_H__ #define __MORPH_H__ -void initmorph(void); +void initmorph(void); -char* lemmatize( char* word, int *len, int type ); +char *lemmatize(char *word, int *len, int type); -bool is_stoptype(int type); +bool is_stoptype(int type); #endif diff --git a/contrib/tsearch/parser.h b/contrib/tsearch/parser.h index 780cb587d5..0e43e675fb 100644 --- a/contrib/tsearch/parser.h +++ b/contrib/tsearch/parser.h @@ -1,11 +1,10 @@ #ifndef __PARSER_H__ #define __PARSER_H__ -char *token; -int tokenlen; -int tsearch_yylex(void); -void start_parse_str(char*, int); -void start_parse_fh(FILE*, int); -void end_parse(void); - +char *token; +int tokenlen; +int tsearch_yylex(void); +void start_parse_str(char *, int); +void start_parse_fh(FILE *, int); +void end_parse(void); #endif diff --git a/contrib/tsearch/query.c b/contrib/tsearch/query.c index 238432ea43..90687d38cf 100644 --- a/contrib/tsearch/query.c +++ b/contrib/tsearch/query.c @@ -31,112 +31,131 @@ #include "parser.h" PG_FUNCTION_INFO_V1(mqtxt_in); -Datum mqtxt_in(PG_FUNCTION_ARGS); +Datum mqtxt_in(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(qtxt_in); -Datum qtxt_in(PG_FUNCTION_ARGS); +Datum qtxt_in(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(qtxt_out); -Datum qtxt_out(PG_FUNCTION_ARGS); +Datum qtxt_out(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(execqtxt); -Datum execqtxt(PG_FUNCTION_ARGS); +Datum execqtxt(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(rexecqtxt); -Datum rexecqtxt(PG_FUNCTION_ARGS); +Datum rexecqtxt(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(querytree); -Datum querytree(PG_FUNCTION_ARGS); - -#define END 0 -#define ERR 1 -#define VAL 2 -#define OPR 3 -#define OPEN 4 -#define CLOSE 5 -#define VALTRUE 6 /* for stop words */ +Datum querytree(PG_FUNCTION_ARGS); + +#define END 0 +#define ERR 1 +#define VAL 2 +#define OPR 3 +#define OPEN 4 +#define CLOSE 5 +#define VALTRUE 6 /* for stop words */ #define VALFALSE 7 /* parser's states */ -#define WAITOPERAND 1 +#define WAITOPERAND 1 #define WAITOPERATOR 2 /* * node of query tree, also used * for storing polish notation in parser */ -typedef struct NODE { - int4 type; - int4 val; - int2 distance; - int2 length; - struct NODE *next; -} NODE; - -typedef struct { - char *buf; - int4 state; - int4 count; - /* reverse polish notation in list (for temprorary usage)*/ - NODE *str; +typedef struct NODE +{ + int4 type; + int4 val; + int2 distance; + int2 length; + struct NODE *next; +} NODE; + +typedef struct +{ + char *buf; + int4 state; + int4 count; + /* reverse polish notation in list (for temprorary usage) */ + NODE *str; /* number in str */ - int4 num; + int4 num; /* user-friendly operand */ - int4 lenop; - int4 sumlen; - char *op; - char *curop; + int4 lenop; + int4 sumlen; + char *op; + char *curop; /* state for value's parser */ - TI_IN_STATE valstate; -} QPRS_STATE; + TI_IN_STATE valstate; +} QPRS_STATE; /* * get token from query string */ -static int4 -gettoken_query( QPRS_STATE* state, int4* val, int4* lenval, char** strval ) { - while(1) { - switch(state->state) { - case WAITOPERAND: - if ( *(state->buf) == '!' ) { +static int4 +gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval) +{ + while (1) + { + switch (state->state) + { + case WAITOPERAND: + if (*(state->buf) == '!') + { (state->buf)++; - *val = (int4)'!'; + *val = (int4) '!'; return OPR; - } else if ( *(state->buf) == '(' ) { + } + else if (*(state->buf) == '(') + { state->count++; (state->buf)++; return OPEN; - } else if ( *(state->buf) != ' ' ) { + } + else if (*(state->buf) != ' ') + { state->valstate.prsbuf = state->buf; state->state = WAITOPERATOR; - if ( gettoken_txtidx( &(state->valstate) ) ) { + if (gettoken_txtidx(&(state->valstate))) + { *strval = state->valstate.word; *lenval = state->valstate.curpos - state->valstate.word; state->buf = state->valstate.prsbuf; return VAL; - } else + } + else elog(ERROR, "No operand"); } break; case WAITOPERATOR: - if ( *(state->buf) == '&' || *(state->buf) == '|' ) { + if (*(state->buf) == '&' || *(state->buf) == '|') + { state->state = WAITOPERAND; *val = (int4) *(state->buf); - (state->buf)++; + (state->buf)++; return OPR; - } else if ( *(state->buf) == ')' ) { + } + else if (*(state->buf) == ')') + { (state->buf)++; state->count--; - return ( state->count <0 ) ? ERR : CLOSE; - } else if ( *(state->buf) == '\0' ) { - return ( state->count ) ? ERR : END; - } else if ( *(state->buf) != ' ' ) + return (state->count < 0) ? ERR : CLOSE; + } + else if (*(state->buf) == '\0') + return (state->count) ? ERR : END; + else if (*(state->buf) != ' ') return ERR; break; - default: + default: return ERR; break; - } - (state->buf)++; + } + (state->buf)++; } return END; } @@ -145,16 +164,18 @@ gettoken_query( QPRS_STATE* state, int4* val, int4* lenval, char** strval ) { * push new one in polish notation reverse view */ static void -pushquery( QPRS_STATE *state, int4 type, int4 val, int4 distance, int4 lenval) { - NODE *tmp = (NODE*)palloc(sizeof(NODE)); - tmp->type=type; - tmp->val =val; - if ( distance>0xffff ) - elog(ERROR,"Value is too big"); - if ( lenval > 0xffff ) - elog(ERROR,"Operand is too long"); - tmp->distance=distance; - tmp->length=lenval; +pushquery(QPRS_STATE * state, int4 type, int4 val, int4 distance, int4 lenval) +{ + NODE *tmp = (NODE *) palloc(sizeof(NODE)); + + tmp->type = type; + tmp->val = val; + if (distance > 0xffff) + elog(ERROR, "Value is too big"); + if (lenval > 0xffff) + elog(ERROR, "Operand is too long"); + tmp->distance = distance; + tmp->length = lenval; tmp->next = state->str; state->str = tmp; state->num++; @@ -164,20 +185,23 @@ pushquery( QPRS_STATE *state, int4 type, int4 val, int4 distance, int4 lenval) { * This function is used for query_txt parsing */ static void -pushval_asis(QPRS_STATE *state, int type, char* strval, int lenval) { - if ( lenval>0xffff ) +pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval) +{ + if (lenval > 0xffff) elog(ERROR, "Word is too long"); - pushquery(state, type, crc32_sz( (uint8*)strval, lenval ), - state->curop - state->op, lenval); + pushquery(state, type, crc32_sz((uint8 *) strval, lenval), + state->curop - state->op, lenval); + + while (state->curop - state->op + lenval + 1 >= state->lenop) + { + int4 tmp = state->curop - state->op; - while ( state->curop - state->op + lenval + 1 >= state->lenop ) { - int4 tmp = state->curop - state->op; state->lenop *= 2; - state->op = (char*)repalloc( (void*)state->op, state->lenop ); + state->op = (char *) repalloc((void *) state->op, state->lenop); state->curop = state->op + tmp; } - memcpy( (void*)state->curop, (void*)strval, lenval ); + memcpy((void *) state->curop, (void *) strval, lenval); state->curop += lenval; *(state->curop) = '\0'; state->curop++; @@ -189,28 +213,34 @@ pushval_asis(QPRS_STATE *state, int type, char* strval, int lenval) { * This function is used for mquery_txt parsing */ static void -pushval_morph(QPRS_STATE *state, int typeval, char* strval, int lenval) { - int4 type, lenlemm; - int4 count = 0; - char *lemm; - - start_parse_str( strval, lenval ); - while( (type=tsearch_yylex()) != 0 ) { - if ( tokenlen>0xffff ) { +pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval) +{ + int4 type, + lenlemm; + int4 count = 0; + char *lemm; + + start_parse_str(strval, lenval); + while ((type = tsearch_yylex()) != 0) + { + if (tokenlen > 0xffff) + { end_parse(); elog(ERROR, "Word is too long"); } lenlemm = tokenlen; - lemm = lemmatize( token, &lenlemm, type ); - if ( lemm ) { - pushval_asis(state,VAL,lemm,lenlemm); - if ( lemm != token ) pfree(lemm); - } else { - pushval_asis(state,VALTRUE,0,0); + lemm = lemmatize(token, &lenlemm, type); + if (lemm) + { + pushval_asis(state, VAL, lemm, lenlemm); + if (lemm != token) + pfree(lemm); } - if ( count ) - pushquery(state, OPR, (int4)'&', 0,0); - count++; + else + pushval_asis(state, VALTRUE, 0, 0); + if (count) + pushquery(state, OPR, (int4) '&', 0, 0); + count++; } end_parse(); } @@ -219,100 +249,114 @@ pushval_morph(QPRS_STATE *state, int typeval, char* strval, int lenval) { /* * make polish notaion of query */ -static int4 -makepol(QPRS_STATE *state, void (*pushval)(QPRS_STATE*,int,char*,int)) { - int4 val,type; - int4 lenval; - char *strval; - int4 stack[STACKDEPTH]; - int4 lenstack=0; - - while( (type=gettoken_query(state, &val, &lenval, &strval))!=END ) { - switch(type) { +static int4 +makepol(QPRS_STATE * state, void (*pushval) (QPRS_STATE *, int, char *, int)) +{ + int4 val, + type; + int4 lenval; + char *strval; + int4 stack[STACKDEPTH]; + int4 lenstack = 0; + + while ((type = gettoken_query(state, &val, &lenval, &strval)) != END) + { + switch (type) + { case VAL: - (*pushval)(state, VAL, strval, lenval); - while ( lenstack && (stack[ lenstack-1 ] == (int4)'&' || - stack[ lenstack-1 ] == (int4)'!') ) { + (*pushval) (state, VAL, strval, lenval); + while (lenstack && (stack[lenstack - 1] == (int4) '&' || + stack[lenstack - 1] == (int4) '!')) + { lenstack--; - pushquery(state, OPR, stack[ lenstack ], 0,0); + pushquery(state, OPR, stack[lenstack], 0, 0); } break; case OPR: - if ( lenstack && val == (int4) '|' ) { - pushquery(state, OPR, val, 0,0); - } else { - if ( lenstack == STACKDEPTH ) - elog(ERROR,"Stack too short"); - stack[ lenstack ] = val; + if (lenstack && val == (int4) '|') + pushquery(state, OPR, val, 0, 0); + else + { + if (lenstack == STACKDEPTH) + elog(ERROR, "Stack too short"); + stack[lenstack] = val; lenstack++; } break; case OPEN: - if ( makepol( state, pushval ) == ERR ) return ERR; - if ( lenstack && (stack[ lenstack-1 ] == (int4)'&' || - stack[ lenstack-1 ] == (int4)'!') ) { + if (makepol(state, pushval) == ERR) + return ERR; + if (lenstack && (stack[lenstack - 1] == (int4) '&' || + stack[lenstack - 1] == (int4) '!')) + { lenstack--; - pushquery(state, OPR, stack[ lenstack ], 0,0); + pushquery(state, OPR, stack[lenstack], 0, 0); } break; case CLOSE: - while ( lenstack ) { + while (lenstack) + { lenstack--; - pushquery(state, OPR, stack[ lenstack ], 0,0); + pushquery(state, OPR, stack[lenstack], 0, 0); }; return END; break; case ERR: default: - elog(ERROR,"Syntax error"); + elog(ERROR, "Syntax error"); return ERR; - + } } - while (lenstack) { + while (lenstack) + { lenstack--; - pushquery(state, OPR, stack[ lenstack ],0,0); + pushquery(state, OPR, stack[lenstack], 0, 0); }; return END; } -typedef struct { - WordEntry *arrb; - WordEntry *arre; - char *values; - char *operand; -} CHKVAL; +typedef struct +{ + WordEntry *arrb; + WordEntry *arre; + char *values; + char *operand; +} CHKVAL; /* * compare 2 string values */ static int4 -ValCompare( CHKVAL *chkval, WordEntry *ptr, ITEM *item ) { - if ( ptr->len == item->length ) +ValCompare(CHKVAL * chkval, WordEntry * ptr, ITEM * item) +{ + if (ptr->len == item->length) return strncmp( - &(chkval->values[ ptr->pos ]), - &(chkval->operand[item->distance]), - item->length ); + &(chkval->values[ptr->pos]), + &(chkval->operand[item->distance]), + item->length); - return ( ptr->len > item->length ) ? 1 : -1; -} + return (ptr->len > item->length) ? 1 : -1; +} /* * is there value 'val' in array or not ? */ static bool -checkcondition_str( void *checkval, ITEM* val ) { - WordEntry *StopLow = ((CHKVAL*)checkval)->arrb; - WordEntry *StopHigh = ((CHKVAL*)checkval)->arre; - WordEntry *StopMiddle; - int difference; - - /* Loop invariant: StopLow <= val < StopHigh */ - - while (StopLow < StopHigh) { +checkcondition_str(void *checkval, ITEM * val) +{ + WordEntry *StopLow = ((CHKVAL *) checkval)->arrb; + WordEntry *StopHigh = ((CHKVAL *) checkval)->arre; + WordEntry *StopMiddle; + int difference; + + /* Loop invariant: StopLow <= val < StopHigh */ + + while (StopLow < StopHigh) + { StopMiddle = StopLow + (StopHigh - StopLow) / 2; - difference = ValCompare((CHKVAL*)checkval, StopMiddle, val); - if (difference == 0) + difference = ValCompare((CHKVAL *) checkval, StopMiddle, val); + if (difference == 0) return (true); else if (difference < 0) StopLow = StopMiddle + 1; @@ -320,27 +364,33 @@ checkcondition_str( void *checkval, ITEM* val ) { StopHigh = StopMiddle; } - return (false); + return (false); } /* * check for boolean condition */ bool -execute( ITEM* curitem, void *checkval, bool calcnot, bool (*chkcond)(void *checkval, ITEM *val )) { - if ( curitem->type == VAL ) { - return (*chkcond)( checkval, curitem ); - } else if ( curitem->val == (int4)'!' ) { - return ( calcnot ) ? - ( ( execute(curitem + 1, checkval, calcnot, chkcond) ) ? false : true ) - : true; - } else if ( curitem->val == (int4)'&' ) { - if ( execute(curitem + curitem->left, checkval, calcnot, chkcond) ) +execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) +{ + if (curitem->type == VAL) + return (*chkcond) (checkval, curitem); + else if (curitem->val == (int4) '!') + { + return (calcnot) ? + ((execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true) + : true; + } + else if (curitem->val == (int4) '&') + { + if (execute(curitem + curitem->left, checkval, calcnot, chkcond)) return execute(curitem + 1, checkval, calcnot, chkcond); else return false; - } else { /* |-operator */ - if ( execute(curitem + curitem->left, checkval, calcnot, chkcond) ) + } + else + { /* |-operator */ + if (execute(curitem + curitem->left, checkval, calcnot, chkcond)) return true; else return execute(curitem + 1, checkval, calcnot, chkcond); @@ -349,69 +399,79 @@ execute( ITEM* curitem, void *checkval, bool calcnot, bool (*chkcond)(void *chec } /* - * boolean operations + * boolean operations */ Datum -rexecqtxt(PG_FUNCTION_ARGS) { +rexecqtxt(PG_FUNCTION_ARGS) +{ return DirectFunctionCall2( - execqtxt, - PG_GETARG_DATUM(1), - PG_GETARG_DATUM(0) + execqtxt, + PG_GETARG_DATUM(1), + PG_GETARG_DATUM(0) ); } Datum -execqtxt(PG_FUNCTION_ARGS) { - txtidx *val = ( txtidx * )DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - QUERYTYPE *query = ( QUERYTYPE * )DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); - CHKVAL chkval; - bool result; - - if ( ! val->size ) { - PG_FREE_IF_COPY(val,0); - PG_FREE_IF_COPY(query,1); - PG_RETURN_BOOL( false ); +execqtxt(PG_FUNCTION_ARGS) +{ + txtidx *val = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + QUERYTYPE *query = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); + CHKVAL chkval; + bool result; + + if (!val->size) + { + PG_FREE_IF_COPY(val, 0); + PG_FREE_IF_COPY(query, 1); + PG_RETURN_BOOL(false); } chkval.arrb = ARRPTR(val); chkval.arre = chkval.arrb + val->size; chkval.values = STRPTR(val); - chkval.operand = GETOPERAND( query ); - result = execute( - GETQUERY(query), - &chkval, - true, - checkcondition_str - ); - - PG_FREE_IF_COPY(val,0); - PG_FREE_IF_COPY(query,1); - PG_RETURN_BOOL( result ); + chkval.operand = GETOPERAND(query); + result = execute( + GETQUERY(query), + &chkval, + true, + checkcondition_str + ); + + PG_FREE_IF_COPY(val, 0); + PG_FREE_IF_COPY(query, 1); + PG_RETURN_BOOL(result); } /* * find left operand in polish notation view */ static void -findoprnd( ITEM *ptr, int4 *pos ) { +findoprnd(ITEM * ptr, int4 *pos) +{ #ifdef BS_DEBUG - elog(NOTICE, ( ptr[*pos].type == OPR ) ? - "%d %c" : "%d %d ", *pos, ptr[*pos].val ); + elog(NOTICE, (ptr[*pos].type == OPR) ? + "%d %c" : "%d %d ", *pos, ptr[*pos].val); #endif - if ( ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE ) { + if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE) + { ptr[*pos].left = 0; (*pos)++; - } else if ( ptr[*pos].val == (int4)'!' ) { + } + else if (ptr[*pos].val == (int4) '!') + { ptr[*pos].left = 1; (*pos)++; - findoprnd( ptr, pos ); - } else { - ITEM *curitem = &ptr[*pos]; - int4 tmp = *pos; + findoprnd(ptr, pos); + } + else + { + ITEM *curitem = &ptr[*pos]; + int4 tmp = *pos; + (*pos)++; - findoprnd(ptr,pos); + findoprnd(ptr, pos); curitem->left = *pos - tmp; - findoprnd(ptr,pos); + findoprnd(ptr, pos); } } @@ -419,16 +479,20 @@ findoprnd( ITEM *ptr, int4 *pos ) { /* * input */ -static QUERYTYPE *queryin(char *buf, void (*pushval)(QPRS_STATE*,int,char*,int) ) { - QPRS_STATE state; - int4 i; - QUERYTYPE *query; - int4 commonlen; - ITEM *ptr; - NODE *tmp; - int4 pos=0; +static QUERYTYPE * +queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int)) +{ + QPRS_STATE state; + int4 i; + QUERYTYPE *query; + int4 commonlen; + ITEM *ptr; + NODE *tmp; + int4 pos = 0; + #ifdef BS_DEBUG - char pbuf[16384],*cur; + char pbuf[16384], + *cur; #endif /* init state */ @@ -436,62 +500,64 @@ static QUERYTYPE *queryin(char *buf, void (*pushval)(QPRS_STATE*,int,char*,int) state.state = WAITOPERAND; state.count = 0; state.num = 0; - state.str=NULL; + state.str = NULL; /* init value parser's state */ state.valstate.oprisdelim = true; - state.valstate.len=32; - state.valstate.word = (char*)palloc( state.valstate.len ); + state.valstate.len = 32; + state.valstate.word = (char *) palloc(state.valstate.len); /* init list of operand */ - state.sumlen=0; - state.lenop=64; - state.curop = state.op = (char*)palloc( state.lenop ); + state.sumlen = 0; + state.lenop = 64; + state.curop = state.op = (char *) palloc(state.lenop); *(state.curop) = '\0'; - + /* parse query & make polish notation (postfix, but in reverse order) */ - makepol( &state, pushval ); - pfree( state.valstate.word ); - if (!state.num) - elog( ERROR,"Empty query"); + makepol(&state, pushval); + pfree(state.valstate.word); + if (!state.num) + elog(ERROR, "Empty query"); /* make finish struct */ commonlen = COMPUTESIZE(state.num, state.sumlen); - query = (QUERYTYPE*) palloc( commonlen ); + query = (QUERYTYPE *) palloc(commonlen); query->len = commonlen; query->size = state.num; ptr = GETQUERY(query); /* set item in polish notation */ - for(i=0; i<state.num; i++ ) { - ptr[i].type = state.str->type; + for (i = 0; i < state.num; i++) + { + ptr[i].type = state.str->type; ptr[i].val = state.str->val; - ptr[i].distance = state.str->distance; + ptr[i].distance = state.str->distance; ptr[i].length = state.str->length; tmp = state.str->next; - pfree( state.str ); + pfree(state.str); state.str = tmp; } - /* set user friendly-operand view */ - memcpy( (void*)GETOPERAND(query), (void*)state.op, state.sumlen ); - pfree( state.op ); + /* set user friendly-operand view */ + memcpy((void *) GETOPERAND(query), (void *) state.op, state.sumlen); + pfree(state.op); - /* set left operand's position for every operator */ + /* set left operand's position for every operator */ pos = 0; - findoprnd( ptr, &pos ); + findoprnd(ptr, &pos); #ifdef BS_DEBUG cur = pbuf; *cur = '\0'; - for( i=0;i<query->size;i++ ) { - if ( ptr[i].type == OPR ) + for (i = 0; i < query->size; i++) + { + if (ptr[i].type == OPR) sprintf(cur, "%c(%d) ", ptr[i].val, ptr[i].left); - else - sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance ); - cur = strchr(cur,'\0'); + else + sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance); + cur = strchr(cur, '\0'); } - elog(NOTICE,"POR: %s", pbuf); + elog(NOTICE, "POR: %s", pbuf); #endif return query; @@ -501,59 +567,66 @@ static QUERYTYPE *queryin(char *buf, void (*pushval)(QPRS_STATE*,int,char*,int) * in without morphology */ Datum -qtxt_in(PG_FUNCTION_ARGS) { - PG_RETURN_POINTER( queryin((char*)PG_GETARG_POINTER(0),pushval_asis) ); +qtxt_in(PG_FUNCTION_ARGS) +{ + PG_RETURN_POINTER(queryin((char *) PG_GETARG_POINTER(0), pushval_asis)); } /* * in with morphology */ Datum -mqtxt_in(PG_FUNCTION_ARGS) { - QUERYTYPE *query; - ITEM* res; - int4 len; -#ifdef BS_DEBUG - ITEM *ptr; - int4 i; - char pbuf[16384],*cur; +mqtxt_in(PG_FUNCTION_ARGS) +{ + QUERYTYPE *query; + ITEM *res; + int4 len; + +#ifdef BS_DEBUG + ITEM *ptr; + int4 i; + char pbuf[16384], + *cur; #endif initmorph(); - query = queryin((char*)PG_GETARG_POINTER(0),pushval_morph); - res = clean_fakeval( GETQUERY(query), &len ); - if ( ! res ) { + query = queryin((char *) PG_GETARG_POINTER(0), pushval_morph); + res = clean_fakeval(GETQUERY(query), &len); + if (!res) + { pfree(query); PG_RETURN_NULL(); } - memcpy( (void*)GETQUERY(query), (void*)res, len*sizeof(ITEM) ); + memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(ITEM)); #ifdef BS_DEBUG cur = pbuf; *cur = '\0'; ptr = GETQUERY(query); - for( i=0;i<len;i++ ) { - if ( ptr[i].type == OPR ) + for (i = 0; i < len; i++) + { + if (ptr[i].type == OPR) sprintf(cur, "%c(%d) ", ptr[i].val, ptr[i].left); - else - sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance ); - cur = strchr(cur,'\0'); + else + sprintf(cur, "%d(%s) ", ptr[i].val, GETOPERAND(query) + ptr[i].distance); + cur = strchr(cur, '\0'); } - elog(NOTICE,"POR: %s", pbuf); + elog(NOTICE, "POR: %s", pbuf); #endif pfree(res); - PG_RETURN_POINTER( query ); + PG_RETURN_POINTER(query); } /* * out function */ -typedef struct { - ITEM *curpol; - char *buf; - char *cur; - char *op; - int4 buflen; -} INFIX; +typedef struct +{ + ITEM *curpol; + char *buf; + char *cur; + char *op; + int4 buflen; +} INFIX; #define RESIZEBUF(inf,addsize) \ while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ @@ -565,98 +638,117 @@ while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ } /* - * recursive walk on tree and print it in + * recursive walk on tree and print it in * infix (human-readable) view */ static void -infix(INFIX *in, bool first) { - if ( in->curpol->type == VAL ) { - char *op = in->op + in->curpol->distance; - RESIZEBUF(in, in->curpol->length*2 + 2); - *(in->cur) = '\''; in->cur++; - while( *op ) { - if ( *op == '\'' ) { - *(in->cur) = '\\'; in->cur++; +infix(INFIX * in, bool first) +{ + if (in->curpol->type == VAL) + { + char *op = in->op + in->curpol->distance; + + RESIZEBUF(in, in->curpol->length * 2 + 2); + *(in->cur) = '\''; + in->cur++; + while (*op) + { + if (*op == '\'') + { + *(in->cur) = '\\'; + in->cur++; } *(in->cur) = *op; - op++; in->cur++; - } - *(in->cur) = '\''; in->cur++; + op++; + in->cur++; + } + *(in->cur) = '\''; + in->cur++; *(in->cur) = '\0'; in->curpol++; - } else if ( in->curpol->val == (int4)'!' ) { - bool isopr = false; + } + else if (in->curpol->val == (int4) '!') + { + bool isopr = false; + RESIZEBUF(in, 1); *(in->cur) = '!'; in->cur++; *(in->cur) = '\0'; in->curpol++; - if ( in->curpol->type == OPR ) { + if (in->curpol->type == OPR) + { isopr = true; RESIZEBUF(in, 2); sprintf(in->cur, "( "); - in->cur = strchr( in->cur, '\0' ); - } - infix( in, isopr ); - if ( isopr ) { + in->cur = strchr(in->cur, '\0'); + } + infix(in, isopr); + if (isopr) + { RESIZEBUF(in, 2); sprintf(in->cur, " )"); - in->cur = strchr( in->cur, '\0' ); - } - } else { - int4 op = in->curpol->val; - INFIX nrm; - + in->cur = strchr(in->cur, '\0'); + } + } + else + { + int4 op = in->curpol->val; + INFIX nrm; + in->curpol++; - if ( op == (int4)'|' && ! first) { + if (op == (int4) '|' && !first) + { RESIZEBUF(in, 2); sprintf(in->cur, "( "); - in->cur = strchr( in->cur, '\0' ); + in->cur = strchr(in->cur, '\0'); } nrm.curpol = in->curpol; nrm.op = in->op; nrm.buflen = 16; - nrm.cur = nrm.buf = (char*)palloc( sizeof(char) * nrm.buflen ); - + nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); + /* get right operand */ - infix( &nrm, false ); - + infix(&nrm, false); + /* get & print left operand */ in->curpol = nrm.curpol; - infix( in, false ); + infix(in, false); - /* print operator & right operand*/ - RESIZEBUF(in, 3 + (nrm.cur - nrm.buf) ); + /* print operator & right operand */ + RESIZEBUF(in, 3 + (nrm.cur - nrm.buf)); sprintf(in->cur, " %c %s", op, nrm.buf); - in->cur = strchr( in->cur, '\0' ); - pfree( nrm.buf ); + in->cur = strchr(in->cur, '\0'); + pfree(nrm.buf); - if ( op == (int4)'|' && ! first) { + if (op == (int4) '|' && !first) + { RESIZEBUF(in, 2); sprintf(in->cur, " )"); - in->cur = strchr( in->cur, '\0' ); + in->cur = strchr(in->cur, '\0'); } } } Datum -qtxt_out(PG_FUNCTION_ARGS) { - QUERYTYPE *query = (QUERYTYPE*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - INFIX nrm; +qtxt_out(PG_FUNCTION_ARGS) +{ + QUERYTYPE *query = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + INFIX nrm; - if ( query->size == 0 ) - elog(ERROR,"Empty"); + if (query->size == 0) + elog(ERROR, "Empty"); nrm.curpol = GETQUERY(query); nrm.buflen = 32; - nrm.cur = nrm.buf = (char*)palloc( sizeof(char) * nrm.buflen ); + nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); *(nrm.cur) = '\0'; nrm.op = GETOPERAND(query); - infix( &nrm, true ); - - PG_FREE_IF_COPY(query,0); - PG_RETURN_POINTER( nrm.buf ); + infix(&nrm, true); + + PG_FREE_IF_COPY(query, 0); + PG_RETURN_POINTER(nrm.buf); } /* @@ -664,38 +756,42 @@ qtxt_out(PG_FUNCTION_ARGS) { * which will be executed in non-leaf pages in index */ Datum -querytree(PG_FUNCTION_ARGS) { - QUERYTYPE *query = (QUERYTYPE*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - INFIX nrm; - text *res; - ITEM *q; - int4 len; +querytree(PG_FUNCTION_ARGS) +{ + QUERYTYPE *query = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + INFIX nrm; + text *res; + ITEM *q; + int4 len; - if ( query->size == 0 ) - elog(ERROR,"Empty"); + if (query->size == 0) + elog(ERROR, "Empty"); q = clean_NOT(GETQUERY(query), &len); - if ( ! q ) { - res = (text*) palloc( 1 + VARHDRSZ ); + if (!q) + { + res = (text *) palloc(1 + VARHDRSZ); VARATT_SIZEP(res) = 1 + VARHDRSZ; - *((char*)VARDATA(res)) = 'T'; - } else { + *((char *) VARDATA(res)) = 'T'; + } + else + { nrm.curpol = q; nrm.buflen = 32; - nrm.cur = nrm.buf = (char*)palloc( sizeof(char) * nrm.buflen ); + nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); *(nrm.cur) = '\0'; nrm.op = GETOPERAND(query); - infix( &nrm, true ); + infix(&nrm, true); - res = (text*) palloc( nrm.cur-nrm.buf + VARHDRSZ ); - VARATT_SIZEP(res) = nrm.cur-nrm.buf + VARHDRSZ; - strncpy( VARDATA(res), nrm.buf, nrm.cur-nrm.buf ); + res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ); + VARATT_SIZEP(res) = nrm.cur - nrm.buf + VARHDRSZ; + strncpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf); pfree(q); } - PG_FREE_IF_COPY(query,0); + PG_FREE_IF_COPY(query, 0); - PG_RETURN_POINTER( res ); + PG_RETURN_POINTER(res); } diff --git a/contrib/tsearch/query.h b/contrib/tsearch/query.h index 96117e78c8..a5f8d7deb8 100644 --- a/contrib/tsearch/query.h +++ b/contrib/tsearch/query.h @@ -9,41 +9,43 @@ * item in polish notation with back link * to left operand */ -typedef struct ITEM { - int2 type; - int2 left; - int4 val; +typedef struct ITEM +{ + int2 type; + int2 left; + int4 val; /* user-friendly value */ - uint16 distance; - uint16 length; -} ITEM; + uint16 distance; + uint16 length; +} ITEM; /* *Storage: * (len)(size)(array of ITEM)(array of operand in user-friendly form) */ -typedef struct { - int4 len; - int4 size; - char data[1]; -} QUERYTYPE; +typedef struct +{ + int4 len; + int4 size; + char data[1]; +} QUERYTYPE; #define HDRSIZEQT ( 2*sizeof(int4) ) #define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) -#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) +#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) #define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) -#define END 0 -#define ERR 1 -#define VAL 2 -#define OPR 3 -#define OPEN 4 -#define CLOSE 5 -#define VALTRUE 6 /* for stop words */ -#define VALFALSE 7 +#define END 0 +#define ERR 1 +#define VAL 2 +#define OPR 3 +#define OPEN 4 +#define CLOSE 5 +#define VALTRUE 6 /* for stop words */ +#define VALFALSE 7 -bool execute( ITEM* curitem, void *checkval, - bool calcnot, bool (*chkcond)(void *checkval, ITEM* val )); +bool execute(ITEM * curitem, void *checkval, + bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)); #endif diff --git a/contrib/tsearch/rewrite.c b/contrib/tsearch/rewrite.c index 590b15e7ca..9ad7a0a86a 100644 --- a/contrib/tsearch/rewrite.c +++ b/contrib/tsearch/rewrite.c @@ -19,52 +19,63 @@ #include "query.h" #include "rewrite.h" -typedef struct NODE { - struct NODE *left; +typedef struct NODE +{ + struct NODE *left; struct NODE *right; - ITEM* valnode; -} NODE; + ITEM *valnode; +} NODE; /* * make query tree from plain view of query */ -static NODE* -maketree(ITEM *in) { - NODE *node = (NODE*)palloc(sizeof(NODE)); +static NODE * +maketree(ITEM * in) +{ + NODE *node = (NODE *) palloc(sizeof(NODE)); + node->valnode = in; node->right = node->left = NULL; - if ( in->type == OPR ) { - node->right = maketree( in + 1 ); - if ( in->val != (int4)'!' ) - node->left = maketree( in + in->left ); + if (in->type == OPR) + { + node->right = maketree(in + 1); + if (in->val != (int4) '!') + node->left = maketree(in + in->left); } return node; } -typedef struct { - ITEM* ptr; - int4 len; - int4 cur; -} PLAINTREE; +typedef struct +{ + ITEM *ptr; + int4 len; + int4 cur; +} PLAINTREE; static void -plainnode(PLAINTREE *state, NODE* node) { - if ( state->cur == state->len ) { +plainnode(PLAINTREE * state, NODE * node) +{ + if (state->cur == state->len) + { state->len *= 2; - state->ptr=(ITEM*)repalloc( (void*)state->ptr, state->len*sizeof(ITEM) ); + state->ptr = (ITEM *) repalloc((void *) state->ptr, state->len * sizeof(ITEM)); } - memcpy( (void*)&(state->ptr[state->cur]), (void*)node->valnode, sizeof(ITEM) ); - if ( node->valnode->type == VAL ) { + memcpy((void *) &(state->ptr[state->cur]), (void *) node->valnode, sizeof(ITEM)); + if (node->valnode->type == VAL) state->cur++; - } else if ( node->valnode->val == (int4)'!' ) { - state->ptr[state->cur].left=1; + else if (node->valnode->val == (int4) '!') + { + state->ptr[state->cur].left = 1; state->cur++; plainnode(state, node->right); - } else { - int4 cur = state->cur; + } + else + { + int4 cur = state->cur; + state->cur++; plainnode(state, node->right); - state->ptr[cur].left = state->cur - cur; + state->ptr[cur].left = state->cur - cur; plainnode(state, node->left); } pfree(node); @@ -73,75 +84,96 @@ plainnode(PLAINTREE *state, NODE* node) { /* * make plain view of tree from 'normal' view of tree */ -static ITEM* -plaintree(NODE *root, int4 *len) { +static ITEM * +plaintree(NODE * root, int4 *len) +{ PLAINTREE pl; - pl.cur=0; - pl.len=16; - if ( root && (root->valnode->type == VAL || root->valnode->type == OPR) ) { - pl.ptr = (ITEM*)palloc( pl.len*sizeof(ITEM) ); + + pl.cur = 0; + pl.len = 16; + if (root && (root->valnode->type == VAL || root->valnode->type == OPR)) + { + pl.ptr = (ITEM *) palloc(pl.len * sizeof(ITEM)); plainnode(&pl, root); - } else { - pl.ptr = NULL; } + else + pl.ptr = NULL; *len = pl.cur; - return pl.ptr; + return pl.ptr; } static void -freetree(NODE *node) { - if ( !node ) return; - if ( node->left ) freetree(node->left); - if ( node->right ) freetree(node->right); - pfree( node ); +freetree(NODE * node) +{ + if (!node) + return; + if (node->left) + freetree(node->left); + if (node->right) + freetree(node->right); + pfree(node); } /* * clean tree for ! operator. - * It's usefull for debug, but in + * It's usefull for debug, but in * other case, such view is used with search in index. * Operator ! always return TRUE */ -static NODE* -clean_NOT_intree( NODE* node ) { - if ( node->valnode->type == VAL ) +static NODE * +clean_NOT_intree(NODE * node) +{ + if (node->valnode->type == VAL) return node; - if ( node->valnode->val == (int4)'!' ) { + if (node->valnode->val == (int4) '!') + { freetree(node); return NULL; } /* operator & or | */ - if ( node->valnode->val == (int4)'|' ) { - if ( (node->left=clean_NOT_intree(node->left)) == NULL || - (node->right=clean_NOT_intree(node->right)) == NULL ) { + if (node->valnode->val == (int4) '|') + { + if ((node->left = clean_NOT_intree(node->left)) == NULL || + (node->right = clean_NOT_intree(node->right)) == NULL) + { freetree(node); return NULL; } - } else { - NODE *res = node; - node->left=clean_NOT_intree(node->left); - node->right=clean_NOT_intree(node->right); - if ( node->left == NULL && node->right == NULL ) { + } + else + { + NODE *res = node; + + node->left = clean_NOT_intree(node->left); + node->right = clean_NOT_intree(node->right); + if (node->left == NULL && node->right == NULL) + { pfree(node); res = NULL; - } else if ( node->left == NULL ) { + } + else if (node->left == NULL) + { res = node->right; pfree(node); - } else if ( node->right == NULL ) { + } + else if (node->right == NULL) + { res = node->left; pfree(node); - } + } return res; } - return node; + return node; } -ITEM* -clean_NOT(ITEM* ptr, int4 *len) { - NODE *root = maketree( ptr ); - return plaintree(clean_NOT_intree(root), len); +ITEM * +clean_NOT(ITEM * ptr, int4 *len) +{ + NODE *root = maketree(ptr); + + return plaintree(clean_NOT_intree(root), len); } #define V_UNKNOWN 0 @@ -149,86 +181,112 @@ clean_NOT(ITEM* ptr, int4 *len) { #define V_FALSE 2 /* - * Clean query tree from values which is always in + * Clean query tree from values which is always in * text (stopword) - */ -static NODE* -clean_fakeval_intree( NODE* node, char *result ) { - char lresult = V_UNKNOWN, rresult = V_UNKNOWN; - if ( node->valnode->type == VAL ) + */ +static NODE * +clean_fakeval_intree(NODE * node, char *result) +{ + char lresult = V_UNKNOWN, + rresult = V_UNKNOWN; + + if (node->valnode->type == VAL) return node; - else if ( node->valnode->type == VALTRUE ) { - pfree( node ); + else if (node->valnode->type == VALTRUE) + { + pfree(node); *result = V_TRUE; return NULL; - } - + } + - if ( node->valnode->val == (int4)'!' ) { - node->right = clean_fakeval_intree( node->right, &rresult ); - if ( ! node->right ) { - *result = ( rresult == V_TRUE ) ? V_FALSE : V_TRUE; + if (node->valnode->val == (int4) '!') + { + node->right = clean_fakeval_intree(node->right, &rresult); + if (!node->right) + { + *result = (rresult == V_TRUE) ? V_FALSE : V_TRUE; freetree(node); return NULL; } - } else if ( node->valnode->val == (int4)'|' ) { - NODE *res = node; - node->left =clean_fakeval_intree(node->left, &lresult); - node->right=clean_fakeval_intree(node->right,&rresult); - if ( lresult == V_TRUE || rresult == V_TRUE ) { + } + else if (node->valnode->val == (int4) '|') + { + NODE *res = node; + + node->left = clean_fakeval_intree(node->left, &lresult); + node->right = clean_fakeval_intree(node->right, &rresult); + if (lresult == V_TRUE || rresult == V_TRUE) + { freetree(node); - *result=V_TRUE; + *result = V_TRUE; return NULL; - } else if ( lresult == V_FALSE && rresult == V_FALSE ) { + } + else if (lresult == V_FALSE && rresult == V_FALSE) + { freetree(node); - *result=V_FALSE; + *result = V_FALSE; return NULL; - } else if ( lresult == V_FALSE ) { + } + else if (lresult == V_FALSE) + { res = node->right; pfree(node); - } else if ( rresult == V_FALSE ) { + } + else if (rresult == V_FALSE) + { res = node->left; pfree(node); } - return res; - } else { - NODE *res = node; - node->left =clean_fakeval_intree(node->left, &lresult); - node->right=clean_fakeval_intree(node->right,&rresult); - if ( lresult == V_FALSE || rresult == V_FALSE ) { + return res; + } + else + { + NODE *res = node; + + node->left = clean_fakeval_intree(node->left, &lresult); + node->right = clean_fakeval_intree(node->right, &rresult); + if (lresult == V_FALSE || rresult == V_FALSE) + { freetree(node); - *result=V_FALSE; + *result = V_FALSE; return NULL; - } else if ( lresult == V_TRUE && rresult == V_TRUE ) { + } + else if (lresult == V_TRUE && rresult == V_TRUE) + { freetree(node); - *result=V_TRUE; + *result = V_TRUE; return NULL; - } else if ( lresult == V_TRUE ) { + } + else if (lresult == V_TRUE) + { res = node->right; pfree(node); - } else if ( rresult == V_TRUE ) { + } + else if (rresult == V_TRUE) + { res = node->left; pfree(node); } - return res; + return res; } - return node; + return node; } -ITEM* -clean_fakeval(ITEM* ptr, int4 *len) { - NODE *root = maketree( ptr ); - char result = V_UNKNOWN; - NODE *resroot; - +ITEM * +clean_fakeval(ITEM * ptr, int4 *len) +{ + NODE *root = maketree(ptr); + char result = V_UNKNOWN; + NODE *resroot; + resroot = clean_fakeval_intree(root, &result); - if ( result != V_UNKNOWN ) { - elog(ERROR,"Your query contained only stopword(s), ignored"); + if (result != V_UNKNOWN) + { + elog(ERROR, "Your query contained only stopword(s), ignored"); *len = 0; return NULL; } - - return plaintree(resroot, len); -} - + return plaintree(resroot, len); +} diff --git a/contrib/tsearch/rewrite.h b/contrib/tsearch/rewrite.h index 863ff9b672..c53e1c6dac 100644 --- a/contrib/tsearch/rewrite.h +++ b/contrib/tsearch/rewrite.h @@ -1,7 +1,6 @@ #ifndef __REWRITE_H__ #define __REWRITE_H__ -ITEM* clean_NOT(ITEM* ptr, int4 *len); -ITEM* clean_fakeval(ITEM* ptr, int4 *len); - +ITEM *clean_NOT(ITEM * ptr, int4 *len); +ITEM *clean_fakeval(ITEM * ptr, int4 *len); #endif diff --git a/contrib/tsearch/txtidx.c b/contrib/tsearch/txtidx.c index e1abd54d3b..6e1fe0edae 100644 --- a/contrib/tsearch/txtidx.c +++ b/contrib/tsearch/txtidx.c @@ -17,9 +17,9 @@ #include "utils/pg_locale.h" -#include <ctype.h> /* tolower */ -#include "txtidx.h" -#include "query.h" +#include <ctype.h> /* tolower */ +#include "txtidx.h" +#include "query.h" #include "deflex.h" #include "parser.h" @@ -27,51 +27,58 @@ #include "morph.h" PG_FUNCTION_INFO_V1(txtidx_in); -Datum txtidx_in(PG_FUNCTION_ARGS); +Datum txtidx_in(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(txtidx_out); -Datum txtidx_out(PG_FUNCTION_ARGS); +Datum txtidx_out(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(txt2txtidx); -Datum txt2txtidx(PG_FUNCTION_ARGS); +Datum txt2txtidx(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(tsearch); -Datum tsearch(PG_FUNCTION_ARGS); +Datum tsearch(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(txtidxsize); -Datum txtidxsize(PG_FUNCTION_ARGS); +Datum txtidxsize(PG_FUNCTION_ARGS); /* * in/out text index type */ static char *BufferStr; static int -compareentry( const void * a, const void * b ) { - if ( ((WordEntry*)a)->len == ((WordEntry*)b)->len ) { - return strncmp( - &BufferStr[((WordEntry*)a)->pos], - &BufferStr[((WordEntry*)b)->pos], - ((WordEntry*)b)->len ); +compareentry(const void *a, const void *b) +{ + if (((WordEntry *) a)->len == ((WordEntry *) b)->len) + { + return strncmp( + &BufferStr[((WordEntry *) a)->pos], + &BufferStr[((WordEntry *) b)->pos], + ((WordEntry *) b)->len); } - return ( ((WordEntry*)a)->len > ((WordEntry*)b)->len ) ? 1 : -1; + return (((WordEntry *) a)->len > ((WordEntry *) b)->len) ? 1 : -1; } static int -uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) { - WordEntry *ptr, *res; +uniqueentry(WordEntry * a, int4 l, char *buf, int4 *outbuflen) +{ + WordEntry *ptr, + *res; res = a; *outbuflen = res->len; - if ( l == 1 ) + if (l == 1) return l; - ptr = a+1; + ptr = a + 1; BufferStr = buf; - qsort((void*)a, l, sizeof(int4), compareentry ); + qsort((void *) a, l, sizeof(int4), compareentry); *outbuflen = res->len; - while (ptr - a < l) { - if ( ! (ptr->len == res->len && - strncmp(&buf[ ptr->pos ], &buf[ res->pos ],res->len) == 0 ) ) { + while (ptr - a < l) + { + if (!(ptr->len == res->len && + strncmp(&buf[ptr->pos], &buf[res->pos], res->len) == 0)) + { res++; res->len = ptr->len; res->pos = ptr->pos; @@ -81,10 +88,10 @@ uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) { ptr++; } return res + 1 - a; -} +} #define WAITWORD 1 -#define WAITENDWORD 2 +#define WAITENDWORD 2 #define WAITNEXTCHAR 3 #define WAITENDCMPLX 4 @@ -92,81 +99,105 @@ uniqueentry( WordEntry* a, int4 l, char *buf, int4 *outbuflen ) { do { \ if ( state->curpos - state->word == state->len ) \ { \ - int4 clen = state->curpos - state->word; \ - state->len *= 2; \ - state->word = (char*)repalloc( (void*)state->word, state->len ); \ - state->curpos = state->word + clen; \ - } \ + int4 clen = state->curpos - state->word; \ + state->len *= 2; \ + state->word = (char*)repalloc( (void*)state->word, state->len ); \ + state->curpos = state->word + clen; \ + } \ } while (0) int4 -gettoken_txtidx( TI_IN_STATE *state ) { - int4 oldstate = 0; +gettoken_txtidx(TI_IN_STATE * state) +{ + int4 oldstate = 0; + state->curpos = state->word; state->state = WAITWORD; - while( 1 ) { - if ( state->state == WAITWORD ) { - if ( *(state->prsbuf) == '\0' ) { + while (1) + { + if (state->state == WAITWORD) + { + if (*(state->prsbuf) == '\0') return 0; - } else if ( *(state->prsbuf) == '\'' ) { - state->state = WAITENDCMPLX; - } else if ( *(state->prsbuf) == '\\' ) { + else if (*(state->prsbuf) == '\'') + state->state = WAITENDCMPLX; + else if (*(state->prsbuf) == '\\') + { state->state = WAITNEXTCHAR; oldstate = WAITENDWORD; - } else if ( state->oprisdelim && ISOPERATOR( *(state->prsbuf) ) ) { + } + else if (state->oprisdelim && ISOPERATOR(*(state->prsbuf))) elog(ERROR, "Syntax error"); - } else if ( *(state->prsbuf) != ' ' ) { + else if (*(state->prsbuf) != ' ') + { *(state->curpos) = *(state->prsbuf); state->curpos++; state->state = WAITENDWORD; } - } else if ( state->state == WAITNEXTCHAR ) { - if ( *(state->prsbuf) == '\0' ) { - elog(ERROR,"There is no escaped character"); - } else { + } + else if (state->state == WAITNEXTCHAR) + { + if (*(state->prsbuf) == '\0') + elog(ERROR, "There is no escaped character"); + else + { RESIZEPRSBUF; *(state->curpos) = *(state->prsbuf); state->curpos++; state->state = oldstate; } - } else if ( state->state == WAITENDWORD ) { - if ( *(state->prsbuf) == '\\' ) { + } + else if (state->state == WAITENDWORD) + { + if (*(state->prsbuf) == '\\') + { state->state = WAITNEXTCHAR; oldstate = WAITENDWORD; - } else if ( *(state->prsbuf) == ' ' || *(state->prsbuf) == '\0' || - ( state->oprisdelim && ISOPERATOR( *(state->prsbuf) ) ) ) { + } + else if (*(state->prsbuf) == ' ' || *(state->prsbuf) == '\0' || + (state->oprisdelim && ISOPERATOR(*(state->prsbuf)))) + { RESIZEPRSBUF; - if ( state->curpos == state->word ) + if (state->curpos == state->word) elog(ERROR, "Syntax error"); *(state->curpos) = '\0'; return 1; - } else { + } + else + { RESIZEPRSBUF; *(state->curpos) = *(state->prsbuf); state->curpos++; } - } else if ( state->state == WAITENDCMPLX ) { - if ( *(state->prsbuf) == '\'' ) { + } + else if (state->state == WAITENDCMPLX) + { + if (*(state->prsbuf) == '\'') + { RESIZEPRSBUF; *(state->curpos) = '\0'; - if ( state->curpos == state->word ) + if (state->curpos == state->word) elog(ERROR, "Syntax error"); state->prsbuf++; return 1; - } else if ( *(state->prsbuf) == '\\' ) { + } + else if (*(state->prsbuf) == '\\') + { state->state = WAITNEXTCHAR; oldstate = WAITENDCMPLX; - } else if ( *(state->prsbuf) == '\0' ) { - elog(ERROR,"Syntax error"); - } else { + } + else if (*(state->prsbuf) == '\0') + elog(ERROR, "Syntax error"); + else + { RESIZEPRSBUF; *(state->curpos) = *(state->prsbuf); state->curpos++; } - } else { + } + else elog(ERROR, "Inner bug :("); - } state->prsbuf++; } @@ -174,92 +205,111 @@ gettoken_txtidx( TI_IN_STATE *state ) { } Datum -txtidx_in(PG_FUNCTION_ARGS) { - char *buf = (char*)PG_GETARG_POINTER(0); +txtidx_in(PG_FUNCTION_ARGS) +{ + char *buf = (char *) PG_GETARG_POINTER(0); TI_IN_STATE state; - WordEntry *arr; - int4 len=0, totallen = 64; - txtidx *in; - char *tmpbuf, *cur; - int4 i,buflen = 256; + WordEntry *arr; + int4 len = 0, + totallen = 64; + txtidx *in; + char *tmpbuf, + *cur; + int4 i, + buflen = 256; state.prsbuf = buf; - state.len=32; - state.word = (char*)palloc( state.len ); + state.len = 32; + state.word = (char *) palloc(state.len); state.oprisdelim = false; - arr = (WordEntry*)palloc( sizeof(WordEntry) * totallen ); - cur = tmpbuf = (char*)palloc( buflen ); - while( gettoken_txtidx( &state ) ) { - if ( len == totallen ) { + arr = (WordEntry *) palloc(sizeof(WordEntry) * totallen); + cur = tmpbuf = (char *) palloc(buflen); + while (gettoken_txtidx(&state)) + { + if (len == totallen) + { totallen *= 2; - arr = (WordEntry*)repalloc( (void*)arr, sizeof(int4)*totallen ); + arr = (WordEntry *) repalloc((void *) arr, sizeof(int4) * totallen); } - while ( cur-tmpbuf + state.curpos - state.word >= buflen ) { - int4 dist = cur-tmpbuf; + while (cur - tmpbuf + state.curpos - state.word >= buflen) + { + int4 dist = cur - tmpbuf; + buflen *= 2; - tmpbuf = (char*)repalloc( (void*)tmpbuf, buflen ); - cur = tmpbuf+dist; + tmpbuf = (char *) repalloc((void *) tmpbuf, buflen); + cur = tmpbuf + dist; } - if ( state.curpos - state.word > 0xffff ) - elog(ERROR,"Word is too long"); + if (state.curpos - state.word > 0xffff) + elog(ERROR, "Word is too long"); arr[len].len = state.curpos - state.word; - if ( cur - tmpbuf > 0xffff ) - elog(ERROR,"Too long value"); + if (cur - tmpbuf > 0xffff) + elog(ERROR, "Too long value"); arr[len].pos = cur - tmpbuf; - memcpy( (void*)cur, (void*)state.word, arr[len].len ); + memcpy((void *) cur, (void *) state.word, arr[len].len); cur += arr[len].len; len++; } pfree(state.word); - if ( !len ) - elog(ERROR,"Void value"); + if (!len) + elog(ERROR, "Void value"); - len = uniqueentry( arr, len, tmpbuf, &buflen ); - totallen = CALCDATASIZE( len, buflen ); - in = (txtidx*)palloc( totallen ); + len = uniqueentry(arr, len, tmpbuf, &buflen); + totallen = CALCDATASIZE(len, buflen); + in = (txtidx *) palloc(totallen); in->len = totallen; in->size = len; cur = STRPTR(in); - for(i=0;i<len;i++) { - memcpy( (void*)cur, (void*)&tmpbuf[ arr[i].pos ], arr[i].len ); + for (i = 0; i < len; i++) + { + memcpy((void *) cur, (void *) &tmpbuf[arr[i].pos], arr[i].len); arr[i].pos = cur - STRPTR(in); cur += arr[i].len; } pfree(tmpbuf); - memcpy( (void*)ARRPTR(in), (void*)arr, sizeof(int4)*len ); - pfree( arr ); - PG_RETURN_POINTER( in ); + memcpy((void *) ARRPTR(in), (void *) arr, sizeof(int4) * len); + pfree(arr); + PG_RETURN_POINTER(in); } Datum -txtidxsize(PG_FUNCTION_ARGS) { - txtidx *in=(txtidx*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - int4 ret = in->size; - PG_FREE_IF_COPY(in,0); - PG_RETURN_INT32( ret ); +txtidxsize(PG_FUNCTION_ARGS) +{ + txtidx *in = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + int4 ret = in->size; + + PG_FREE_IF_COPY(in, 0); + PG_RETURN_INT32(ret); } Datum -txtidx_out(PG_FUNCTION_ARGS) { - txtidx *out=(txtidx*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - char *outbuf; - int4 i,j,lenbuf = STRSIZE(out) + 1 /* \0 */ + out->size*2 /* '' */ + out->size - 1 /* space */; - WordEntry *ptr = ARRPTR(out); - char *curin, *curout; - - curout = outbuf = (char*) palloc( lenbuf ); - for(i=0;i<out->size;i++) { +txtidx_out(PG_FUNCTION_ARGS) +{ + txtidx *out = (txtidx *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + char *outbuf; + int4 i, + j, + lenbuf = STRSIZE(out) + 1 /* \0 */ + out->size * 2 /* '' */ + out->size - 1 /* space */ ; + WordEntry *ptr = ARRPTR(out); + char *curin, + *curout; + + curout = outbuf = (char *) palloc(lenbuf); + for (i = 0; i < out->size; i++) + { curin = STRPTR(out) + ptr->pos; - if ( i!= 0 ) + if (i != 0) *curout++ = ' '; *curout++ = '\''; j = ptr->len; - while( j-- ) { - if ( *curin == '\'' ) { - int4 pos = curout - outbuf; - outbuf = (char*)repalloc((void*)outbuf, ++lenbuf ); + while (j--) + { + if (*curin == '\'') + { + int4 pos = curout - outbuf; + + outbuf = (char *) repalloc((void *) outbuf, ++lenbuf); curout = outbuf + pos; *curout++ = '\\'; } @@ -268,171 +318,198 @@ txtidx_out(PG_FUNCTION_ARGS) { *curout++ = '\''; ptr++; } - outbuf[ lenbuf-1 ] = '\0'; - PG_FREE_IF_COPY(out,0); - PG_RETURN_POINTER( outbuf ); + outbuf[lenbuf - 1] = '\0'; + PG_FREE_IF_COPY(out, 0); + PG_RETURN_POINTER(outbuf); } -typedef struct { - uint16 len; - char* word; -} WORD; +typedef struct +{ + uint16 len; + char *word; +} WORD; -typedef struct { - WORD *words; - int4 lenwords; - int4 curwords; -} PRSTEXT; +typedef struct +{ + WORD *words; + int4 lenwords; + int4 curwords; +} PRSTEXT; /* * Parse text to lexems */ static void -parsetext( PRSTEXT *prs, char *buf, int4 buflen ) { - int type,lenlemm; - char *ptr,*ptrw; - char *lemm; - - start_parse_str( buf, buflen ); - while( (type=tsearch_yylex()) != 0 ) { - if ( prs->curwords == prs->lenwords ) { +parsetext(PRSTEXT * prs, char *buf, int4 buflen) +{ + int type, + lenlemm; + char *ptr, + *ptrw; + char *lemm; + + start_parse_str(buf, buflen); + while ((type = tsearch_yylex()) != 0) + { + if (prs->curwords == prs->lenwords) + { prs->lenwords *= 2; - prs->words = (WORD*)repalloc( (void*)prs->words, prs->lenwords * sizeof(WORD) ); + prs->words = (WORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD)); } - if ( tokenlen>0xffff ) { + if (tokenlen > 0xffff) + { end_parse(); elog(ERROR, "Word is too long"); } lenlemm = tokenlen; - lemm = lemmatize( token, &lenlemm, type ); - - if ( ! lemm ) + lemm = lemmatize(token, &lenlemm, type); + + if (!lemm) continue; - if ( lemm != token ) { - prs->words[ prs->curwords ].len = lenlemm; - prs->words[ prs->curwords ].word = lemm; - } else { - prs->words[ prs->curwords ].len = lenlemm; - ptrw = prs->words[ prs->curwords ].word = (char*)palloc( lenlemm ); + if (lemm != token) + { + prs->words[prs->curwords].len = lenlemm; + prs->words[prs->curwords].word = lemm; + } + else + { + prs->words[prs->curwords].len = lenlemm; + ptrw = prs->words[prs->curwords].word = (char *) palloc(lenlemm); ptr = token; - while( ptr-token < lenlemm ) { - *ptrw = tolower( (unsigned char) *ptr ); - ptr++; ptrw++; + while (ptr - token < lenlemm) + { + *ptrw = tolower((unsigned char) *ptr); + ptr++; + ptrw++; } } - prs->curwords++; + prs->curwords++; } end_parse(); } static int -compareWORD( const void * a, const void * b ) { - if ( ((WORD*)a)->len == ((WORD*)b)->len ) - return strncmp( - ((WORD*)a)->word, - ((WORD*)b)->word, - ((WORD*)b)->len ); - return ( ((WORD*)a)->len > ((WORD*)b)->len ) ? 1 : -1; +compareWORD(const void *a, const void *b) +{ + if (((WORD *) a)->len == ((WORD *) b)->len) + return strncmp( + ((WORD *) a)->word, + ((WORD *) b)->word, + ((WORD *) b)->len); + return (((WORD *) a)->len > ((WORD *) b)->len) ? 1 : -1; } static int -uniqueWORD( WORD* a, int4 l ) { - WORD *ptr, *res; +uniqueWORD(WORD * a, int4 l) +{ + WORD *ptr, + *res; - if ( l == 1 ) + if (l == 1) return l; res = a; ptr = a + 1; - qsort((void*)a, l, sizeof(WORD), compareWORD ); + qsort((void *) a, l, sizeof(WORD), compareWORD); - while (ptr - a < l) { - if ( ! (ptr->len == res->len && - strncmp(ptr->word, res->word ,res->len) == 0 ) ) { + while (ptr - a < l) + { + if (!(ptr->len == res->len && + strncmp(ptr->word, res->word, res->len) == 0)) + { res++; - res->len = ptr->len; + res->len = ptr->len; res->word = ptr->word; - } else { - pfree(ptr->word); } + else + pfree(ptr->word); ptr++; } return res + 1 - a; -} +} /* * make value of txtidx */ static txtidx * -makevalue( PRSTEXT *prs ) { - int4 i, lenstr=0, totallen; - txtidx *in; - WordEntry *ptr; - char *str,*cur; - - prs->curwords = uniqueWORD( prs->words, prs->curwords ); - for(i=0;i<prs->curwords;i++) +makevalue(PRSTEXT * prs) +{ + int4 i, + lenstr = 0, + totallen; + txtidx *in; + WordEntry *ptr; + char *str, + *cur; + + prs->curwords = uniqueWORD(prs->words, prs->curwords); + for (i = 0; i < prs->curwords; i++) lenstr += prs->words[i].len; - totallen = CALCDATASIZE( prs->curwords, lenstr ); - in = (txtidx*)palloc( totallen ); + totallen = CALCDATASIZE(prs->curwords, lenstr); + in = (txtidx *) palloc(totallen); in->len = totallen; in->size = prs->curwords; ptr = ARRPTR(in); cur = str = STRPTR(in); - for(i=0;i<prs->curwords;i++) { + for (i = 0; i < prs->curwords; i++) + { ptr->len = prs->words[i].len; - if ( cur-str > 0xffff ) - elog(ERROR,"Value is too big"); - ptr->pos = cur-str; + if (cur - str > 0xffff) + elog(ERROR, "Value is too big"); + ptr->pos = cur - str; ptr++; - memcpy( (void*)cur, (void*)prs->words[i].word, prs->words[i].len ); + memcpy((void *) cur, (void *) prs->words[i].word, prs->words[i].len); pfree(prs->words[i].word); - cur += prs->words[i].len; + cur += prs->words[i].len; } pfree(prs->words); return in; } Datum -txt2txtidx(PG_FUNCTION_ARGS) { - text *in = (text*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); - PRSTEXT prs; - txtidx *out = NULL; - - prs.lenwords = 32; - prs.curwords = 0; - prs.words = (WORD*)palloc(sizeof(WORD)*prs.lenwords); +txt2txtidx(PG_FUNCTION_ARGS) +{ + text *in = (text *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0))); + PRSTEXT prs; + txtidx *out = NULL; + + prs.lenwords = 32; + prs.curwords = 0; + prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords); initmorph(); - parsetext( &prs, VARDATA(in), VARSIZE(in) - VARHDRSZ ); - PG_FREE_IF_COPY(in,0); - - if ( prs.curwords ) { - out = makevalue( &prs ); - PG_RETURN_POINTER( out ); + parsetext(&prs, VARDATA(in), VARSIZE(in) - VARHDRSZ); + PG_FREE_IF_COPY(in, 0); + + if (prs.curwords) + { + out = makevalue(&prs); + PG_RETURN_POINTER(out); } pfree(prs.words); PG_RETURN_NULL(); -} +} /* * Trigger */ Datum -tsearch(PG_FUNCTION_ARGS) { +tsearch(PG_FUNCTION_ARGS) +{ TriggerData *trigdata; Trigger *trigger; - Relation rel; - HeapTuple rettuple = NULL; - int numidxattr,i; - PRSTEXT prs; - Datum datum = (Datum)0; + Relation rel; + HeapTuple rettuple = NULL; + int numidxattr, + i; + PRSTEXT prs; + Datum datum = (Datum) 0; if (!CALLED_AS_TRIGGER(fcinfo)) @@ -448,63 +525,69 @@ tsearch(PG_FUNCTION_ARGS) { rettuple = trigdata->tg_trigtuple; else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) rettuple = trigdata->tg_newtuple; - else + else elog(ERROR, "TSearch: Unknown event"); trigger = trigdata->tg_trigger; rel = trigdata->tg_relation; - if ( trigger->tgnargs < 2 ) - elog(ERROR,"TSearch: format tsearch(txtidx_field, text_field1,...)"); + if (trigger->tgnargs < 2) + elog(ERROR, "TSearch: format tsearch(txtidx_field, text_field1,...)"); numidxattr = SPI_fnumber(rel->rd_att, trigger->tgargs[0]); - if ( numidxattr < 0 ) - elog(ERROR,"TSearch: Can not find txtidx_field"); + if (numidxattr < 0) + elog(ERROR, "TSearch: Can not find txtidx_field"); - prs.lenwords = 32; - prs.curwords = 0; - prs.words = (WORD*)palloc(sizeof(WORD)*prs.lenwords); + prs.lenwords = 32; + prs.curwords = 0; + prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords); initmorph(); - /* find all words in indexable column */ - for(i=1; i<trigger->tgnargs; i++) { - int4 numattr; - text *txt_toasted, *txt; - bool isnull; - Oid oidtype; + /* find all words in indexable column */ + for (i = 1; i < trigger->tgnargs; i++) + { + int4 numattr; + text *txt_toasted, + *txt; + bool isnull; + Oid oidtype; numattr = SPI_fnumber(rel->rd_att, trigger->tgargs[i]); oidtype = SPI_gettypeid(rel->rd_att, numattr); - if ( numattr<0 || ( ! ( oidtype==TEXTOID || oidtype==VARCHAROID ) ) ) { + if (numattr < 0 || (!(oidtype == TEXTOID || oidtype == VARCHAROID))) + { elog(NOTICE, "TSearch: can not find field '%s'", trigger->tgargs[i]); continue; } - txt_toasted = (text*)DatumGetPointer( SPI_getbinval(rettuple, rel->rd_att, numattr, &isnull ) ); - if ( isnull ) + txt_toasted = (text *) DatumGetPointer(SPI_getbinval(rettuple, rel->rd_att, numattr, &isnull)); + if (isnull) continue; - txt = (text*)DatumGetPointer( PG_DETOAST_DATUM( PointerGetDatum ( txt_toasted ) ) ); + txt = (text *) DatumGetPointer(PG_DETOAST_DATUM(PointerGetDatum(txt_toasted))); - parsetext( &prs, VARDATA(txt), VARSIZE(txt) - VARHDRSZ ); - if ( txt != txt_toasted ) + parsetext(&prs, VARDATA(txt), VARSIZE(txt) - VARHDRSZ); + if (txt != txt_toasted) pfree(txt); } /* make txtidx value */ - if (prs.curwords) { - datum = PointerGetDatum( makevalue( &prs ) ); - rettuple = SPI_modifytuple( rel, rettuple, 1, &numidxattr, - &datum, NULL ); + if (prs.curwords) + { + datum = PointerGetDatum(makevalue(&prs)); + rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr, + &datum, NULL); pfree(DatumGetPointer(datum)); - } else { - char nulls = 'n'; - pfree( prs.words ); - rettuple = SPI_modifytuple( rel, rettuple, 1, &numidxattr, - &datum, &nulls ); } - + else + { + char nulls = 'n'; + + pfree(prs.words); + rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr, + &datum, &nulls); + } + if (rettuple == NULL) elog(ERROR, "TSearch: %d returned by SPI_modifytuple", SPI_result); - return PointerGetDatum( rettuple ); + return PointerGetDatum(rettuple); } - diff --git a/contrib/tsearch/txtidx.h b/contrib/tsearch/txtidx.h index 9a586ce518..d33bdf9d6d 100644 --- a/contrib/tsearch/txtidx.h +++ b/contrib/tsearch/txtidx.h @@ -14,33 +14,34 @@ #include "utils/builtins.h" #include "storage/bufpage.h" -typedef struct { - uint16 len; - uint16 pos; -} WordEntry; - -typedef struct { - int4 len; - int4 size; - char data[1]; -} txtidx; - -#define DATAHDRSIZE (sizeof(int4)*2) -#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) -#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) -#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((txtidx*)x)->size ) ) -#define STRSIZE(x) ( ((txtidx*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((txtidx*)x)->size ) ) - -typedef struct { - char *prsbuf; - char *word; - char *curpos; - int4 len; - int4 state; - bool oprisdelim; -} TI_IN_STATE; - -int4 gettoken_txtidx( TI_IN_STATE *state ); - +typedef struct +{ + uint16 len; + uint16 pos; +} WordEntry; + +typedef struct +{ + int4 len; + int4 size; + char data[1]; +} txtidx; + +#define DATAHDRSIZE (sizeof(int4)*2) +#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) +#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) +#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((txtidx*)x)->size ) ) +#define STRSIZE(x) ( ((txtidx*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((txtidx*)x)->size ) ) + +typedef struct +{ + char *prsbuf; + char *word; + char *curpos; + int4 len; + int4 state; + bool oprisdelim; +} TI_IN_STATE; + +int4 gettoken_txtidx(TI_IN_STATE * state); #endif - diff --git a/contrib/userlock/user_locks.h b/contrib/userlock/user_locks.h index 82ecb3b9ea..526e864661 100644 --- a/contrib/userlock/user_locks.h +++ b/contrib/userlock/user_locks.h @@ -8,7 +8,6 @@ int user_write_unlock(unsigned int id1, unsigned int id2); int user_write_lock_oid(Oid oid); int user_write_unlock_oid(Oid oid); int user_unlock_all(void); - #endif /* diff --git a/contrib/xml/pgxml.c b/contrib/xml/pgxml.c index 4728903157..3939250e25 100644 --- a/contrib/xml/pgxml.c +++ b/contrib/xml/pgxml.c @@ -14,32 +14,39 @@ XML_Memory_Handling_Suite mhs; /* passthrough functions (palloc is a macro) */ -static void *pgxml_palloc(size_t size) +static void * +pgxml_palloc(size_t size) { - return palloc(size); + return palloc(size); } -static void *pgxml_repalloc(void *ptr, size_t size) +static void * +pgxml_repalloc(void *ptr, size_t size) { - return repalloc(ptr,size); + return repalloc(ptr, size); } -static void pgxml_pfree(void *ptr) +static void +pgxml_pfree(void *ptr) { - return pfree(ptr); + return pfree(ptr); } -static void pgxml_mhs_init() +static void +pgxml_mhs_init() { - mhs.malloc_fcn = pgxml_palloc; - mhs.realloc_fcn = pgxml_repalloc; - mhs.free_fcn = pgxml_pfree; + mhs.malloc_fcn = pgxml_palloc; + mhs.realloc_fcn = pgxml_repalloc; + mhs.free_fcn = pgxml_pfree; } -static void pgxml_handler_init() +static void +pgxml_handler_init() { - /* This code should set up the relevant handlers from user-supplied - settings. Quite how these settings are made is another matter :) */ + /* + * This code should set up the relevant handlers from user-supplied + * settings. Quite how these settings are made is another matter :) + */ } /* Returns true if document is well-formed */ @@ -49,31 +56,35 @@ PG_FUNCTION_INFO_V1(pgxml_parse); Datum pgxml_parse(PG_FUNCTION_ARGS) { - /* called as pgxml_parse(document) */ - XML_Parser p; - text *t = PG_GETARG_TEXT_P(0); /*document buffer */ - int32 docsize = VARSIZE(t) - VARHDRSZ; - - pgxml_mhs_init(); - - pgxml_handler_init(); - - p = XML_ParserCreate_MM(NULL,&mhs,NULL); - if (! p) { - elog(ERROR, "pgxml: Could not create expat parser"); - PG_RETURN_NULL(); /* seems appropriate if we couldn't parse */ - } - - if (! XML_Parse(p, (char *)VARDATA(t) , docsize, 1)) { - /* elog(NOTICE, "Parse error at line %d:%s", - XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); */ - XML_ParserFree(p); - PG_RETURN_BOOL(false); - } - - XML_ParserFree(p); - PG_RETURN_BOOL(true); + /* called as pgxml_parse(document) */ + XML_Parser p; + text *t = PG_GETARG_TEXT_P(0); /* document buffer */ + int32 docsize = VARSIZE(t) - VARHDRSZ; + + pgxml_mhs_init(); + + pgxml_handler_init(); + + p = XML_ParserCreate_MM(NULL, &mhs, NULL); + if (!p) + { + elog(ERROR, "pgxml: Could not create expat parser"); + PG_RETURN_NULL(); /* seems appropriate if we couldn't parse */ + } + + if (!XML_Parse(p, (char *) VARDATA(t), docsize, 1)) + { + /* + * elog(NOTICE, "Parse error at line %d:%s", + * XML_GetCurrentLineNumber(p), + * XML_ErrorString(XML_GetErrorCode(p))); + */ + XML_ParserFree(p); + PG_RETURN_BOOL(false); + } + + XML_ParserFree(p); + PG_RETURN_BOOL(true); } /* XPath handling functions */ @@ -81,83 +92,88 @@ pgxml_parse(PG_FUNCTION_ARGS) /* XPath support here is for a very skeletal kind of XPath! It was easy to program though... */ -/* This first is the core function that builds a result set. The +/* This first is the core function that builds a result set. The actual functions called by the user manipulate that result set in various ways. */ -static XPath_Results *build_xpath_results(text *doc, text *pathstr) +static XPath_Results * +build_xpath_results(text *doc, text *pathstr) { - XPath_Results *xpr; - char *res; - pgxml_udata *udata; - XML_Parser p; - int32 docsize; + XPath_Results *xpr; + char *res; + pgxml_udata *udata; + XML_Parser p; + int32 docsize; - xpr = (XPath_Results *) palloc((sizeof(XPath_Results))); - memset((void *)xpr, 0, sizeof(XPath_Results)); - xpr->rescount=0; + xpr = (XPath_Results *) palloc((sizeof(XPath_Results))); + memset((void *) xpr, 0, sizeof(XPath_Results)); + xpr->rescount = 0; - docsize=VARSIZE(doc)-VARHDRSZ; + docsize = VARSIZE(doc) - VARHDRSZ; - /* res isn't going to be the real return type, it is just a buffer */ + /* res isn't going to be the real return type, it is just a buffer */ - res = (char *) palloc(docsize); - memset((void *)res, 0, docsize); + res = (char *) palloc(docsize); + memset((void *) res, 0, docsize); - xpr->resbuf = res; + xpr->resbuf = res; - udata = (pgxml_udata *) palloc((sizeof(pgxml_udata))); - memset((void *)udata,0,sizeof(pgxml_udata)); + udata = (pgxml_udata *) palloc((sizeof(pgxml_udata))); + memset((void *) udata, 0, sizeof(pgxml_udata)); - udata->currentpath[0]='\0'; - udata->textgrab=0; + udata->currentpath[0] = '\0'; + udata->textgrab = 0; - udata->path= (char *) palloc(VARSIZE(pathstr)); - memcpy(udata->path, VARDATA(pathstr), VARSIZE(pathstr)-VARHDRSZ); + udata->path = (char *) palloc(VARSIZE(pathstr)); + memcpy(udata->path, VARDATA(pathstr), VARSIZE(pathstr) - VARHDRSZ); - udata->path[VARSIZE(pathstr)-VARHDRSZ]='\0'; + udata->path[VARSIZE(pathstr) - VARHDRSZ] = '\0'; - udata->resptr = res; - udata->reslen = 0; + udata->resptr = res; + udata->reslen = 0; - udata->xpres = xpr; + udata->xpres = xpr; - /* Now fire up the parser */ - pgxml_mhs_init(); + /* Now fire up the parser */ + pgxml_mhs_init(); - p = XML_ParserCreate_MM(NULL,&mhs,NULL); - if (! p) { - elog(ERROR, "pgxml: Could not create expat parser"); - pfree(xpr); - pfree(udata->path); - pfree(udata); - pfree(res); - return NULL; - } - XML_SetUserData(p, (void *)udata); - - /* Set the handlers */ - - XML_SetElementHandler(p, pgxml_starthandler, pgxml_endhandler); - XML_SetCharacterDataHandler(p, pgxml_charhandler); - - if (! XML_Parse(p, (char *)VARDATA(doc) , docsize, 1)) { - /* elog(NOTICE, "Parse error at line %d:%s", - XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); */ - XML_ParserFree(p); - pfree(xpr); - pfree(udata->path); - pfree(udata); - - return NULL; - } + p = XML_ParserCreate_MM(NULL, &mhs, NULL); + if (!p) + { + elog(ERROR, "pgxml: Could not create expat parser"); + pfree(xpr); + pfree(udata->path); + pfree(udata); + pfree(res); + return NULL; + } + XML_SetUserData(p, (void *) udata); + + /* Set the handlers */ + + XML_SetElementHandler(p, pgxml_starthandler, pgxml_endhandler); + XML_SetCharacterDataHandler(p, pgxml_charhandler); + + if (!XML_Parse(p, (char *) VARDATA(doc), docsize, 1)) + { + /* + * elog(NOTICE, "Parse error at line %d:%s", + * XML_GetCurrentLineNumber(p), + * XML_ErrorString(XML_GetErrorCode(p))); + */ + XML_ParserFree(p); + pfree(xpr); + pfree(udata->path); + pfree(udata); + + return NULL; + } - pfree(udata->path); - pfree(udata); - XML_ParserFree(p); - return xpr; + pfree(udata->path); + pfree(udata); + XML_ParserFree(p); + return xpr; } @@ -166,145 +182,166 @@ PG_FUNCTION_INFO_V1(pgxml_xpath); Datum pgxml_xpath(PG_FUNCTION_ARGS) { - /* called as pgxml_xpath(document,pathstr, index) for the moment*/ + /* called as pgxml_xpath(document,pathstr, index) for the moment */ + + XPath_Results *xpresults; + text *restext; - XPath_Results *xpresults; - text *restext; + text *t = PG_GETARG_TEXT_P(0); /* document buffer */ + text *t2 = PG_GETARG_TEXT_P(1); + int32 ind = PG_GETARG_INT32(2) - 1; - text *t = PG_GETARG_TEXT_P(0); /*document buffer */ - text *t2= PG_GETARG_TEXT_P(1); - int32 ind = PG_GETARG_INT32(2) - 1; + xpresults = build_xpath_results(t, t2); - xpresults = build_xpath_results(t,t2); + /* + * This needs to be changed depending on the mechanism for returning + * our set of results. + */ - /* This needs to be changed depending on the mechanism for returning - our set of results. */ + if (xpresults == NULL) /* parse error (not WF or parser failure) */ + PG_RETURN_NULL(); - if (xpresults==NULL) /*parse error (not WF or parser failure) */ - { - PG_RETURN_NULL(); - } + if (ind >= (xpresults->rescount)) + PG_RETURN_NULL(); - if (ind >= (xpresults->rescount)) - { - PG_RETURN_NULL(); - } - - restext = (text *) palloc(xpresults->reslens[ind]+VARHDRSZ); - memcpy(VARDATA(restext),xpresults->results[ind],xpresults->reslens[ind]); + restext = (text *) palloc(xpresults->reslens[ind] + VARHDRSZ); + memcpy(VARDATA(restext), xpresults->results[ind], xpresults->reslens[ind]); - VARATT_SIZEP(restext) = xpresults->reslens[ind]+VARHDRSZ; + VARATT_SIZEP(restext) = xpresults->reslens[ind] + VARHDRSZ; - pfree(xpresults->resbuf); - pfree(xpresults); + pfree(xpresults->resbuf); + pfree(xpresults); - PG_RETURN_TEXT_P(restext); + PG_RETURN_TEXT_P(restext); } -static void pgxml_pathcompare(void *userData) +static void +pgxml_pathcompare(void *userData) { - char *matchpos; - - matchpos=strstr(UD->currentpath, UD->path); - - if (matchpos == NULL) { /* Should we have more logic here ? */ - if (UD->textgrab) { - UD->textgrab=0; - pgxml_finalisegrabbedtext(userData); - } - return; - } - /* OK, we have a match of some sort. Now we need to check that - our match is anchored to the *end* of the string AND - that it is immediately preceded by a '/'*/ - /* This test wouldn't work if strlen (UD->path) overran the length - of the currentpath, but that's not possible because we got a match! */ - - if ((matchpos + strlen(UD->path))[0]=='\0') - { - if ((UD->path)[0]=='/') { - if (matchpos == UD->currentpath) { - UD->textgrab=1; + char *matchpos; + + matchpos = strstr(UD->currentpath, UD->path); + + if (matchpos == NULL) + { /* Should we have more logic here ? */ + if (UD->textgrab) + { + UD->textgrab = 0; + pgxml_finalisegrabbedtext(userData); + } + return; } - } else { - if ((matchpos-1)[0]=='/') { - UD->textgrab=1; + + /* + * OK, we have a match of some sort. Now we need to check that our + * match is anchored to the *end* of the string AND that it is + * immediately preceded by a '/' + */ + + /* + * This test wouldn't work if strlen (UD->path) overran the length of + * the currentpath, but that's not possible because we got a match! + */ + + if ((matchpos + strlen(UD->path))[0] == '\0') + { + if ((UD->path)[0] == '/') + { + if (matchpos == UD->currentpath) + UD->textgrab = 1; + } + else + { + if ((matchpos - 1)[0] == '/') + UD->textgrab = 1; + } } - } - } } -static void pgxml_starthandler(void *userData, const XML_Char *name, - const XML_Char **atts) +static void +pgxml_starthandler(void *userData, const XML_Char * name, + const XML_Char ** atts) { - char sepstr[]="/"; - - if ((strlen(name)+strlen(UD->currentpath))>MAXPATHLENGTH-2) { - elog(NOTICE,"Path too long"); - } else { - strncat(UD->currentpath,sepstr,1); - strcat(UD->currentpath, name); - } - if (UD->textgrab) - { - /* Depending on user preference, should we "reconstitute" - the element into the result text? - */ - } else { - pgxml_pathcompare(userData); - } + char sepstr[] = "/"; + + if ((strlen(name) + strlen(UD->currentpath)) > MAXPATHLENGTH - 2) + elog(NOTICE, "Path too long"); + else + { + strncat(UD->currentpath, sepstr, 1); + strcat(UD->currentpath, name); + } + if (UD->textgrab) + { + /* + * Depending on user preference, should we "reconstitute" the + * element into the result text? + */ + } + else + pgxml_pathcompare(userData); } -static void pgxml_endhandler(void *userData, const XML_Char *name) +static void +pgxml_endhandler(void *userData, const XML_Char * name) { - /* Start by removing the current element off the end of the - currentpath */ - - char *sepptr; - - sepptr=strrchr(UD->currentpath,'/'); - if (sepptr==NULL) { - elog(ERROR,"There's a problem..."); - sepptr=UD->currentpath; - } - if (strcmp(name, sepptr+1) !=0) { - elog(NOTICE,"Wanted [%s], got [%s]",sepptr,name); - /* unmatched entry, so do nothing */ - } else { - sepptr[0]='\0'; /* Chop that element off the end */ - } - - if (UD->textgrab) { - pgxml_pathcompare(userData); - } + /* + * Start by removing the current element off the end of the + * currentpath + */ + + char *sepptr; + + sepptr = strrchr(UD->currentpath, '/'); + if (sepptr == NULL) + { + elog(ERROR, "There's a problem..."); + sepptr = UD->currentpath; + } + if (strcmp(name, sepptr + 1) != 0) + { + elog(NOTICE, "Wanted [%s], got [%s]", sepptr, name); + /* unmatched entry, so do nothing */ + } + else + { + sepptr[0] = '\0'; /* Chop that element off the end */ + } + + if (UD->textgrab) + pgxml_pathcompare(userData); } -static void pgxml_charhandler(void *userData, const XML_Char *s, int len) +static void +pgxml_charhandler(void *userData, const XML_Char * s, int len) { - if (UD->textgrab) { - if (len>0) { - memcpy(UD->resptr,s,len); - UD->resptr += len; - UD->reslen += len; - } - } + if (UD->textgrab) + { + if (len > 0) + { + memcpy(UD->resptr, s, len); + UD->resptr += len; + UD->reslen += len; + } + } } + /* Should I be using PG list types here? */ -static void pgxml_finalisegrabbedtext(void *userData) +static void +pgxml_finalisegrabbedtext(void *userData) { - /* In res/reslen, we have a single result. */ - UD->xpres->results[UD->xpres->rescount]= UD->resptr - UD->reslen; - UD->xpres->reslens[UD->xpres->rescount]= UD->reslen; - UD->reslen=0; - UD->xpres->rescount++; - - /* This effectively concatenates all the results together but we - do know where one ends and the next begins */ + /* In res/reslen, we have a single result. */ + UD->xpres->results[UD->xpres->rescount] = UD->resptr - UD->reslen; + UD->xpres->reslens[UD->xpres->rescount] = UD->reslen; + UD->reslen = 0; + UD->xpres->rescount++; + + /* + * This effectively concatenates all the results together but we do + * know where one ends and the next begins + */ } - - - diff --git a/contrib/xml/pgxml.h b/contrib/xml/pgxml.h index 848264c23d..605031861d 100644 --- a/contrib/xml/pgxml.h +++ b/contrib/xml/pgxml.h @@ -5,12 +5,12 @@ static void *pgxml_repalloc(void *ptr, size_t size); static void pgxml_pfree(void *ptr); static void pgxml_mhs_init(); static void pgxml_handler_init(); -Datum pgxml_parse(PG_FUNCTION_ARGS); -Datum pgxml_xpath(PG_FUNCTION_ARGS); -static void pgxml_starthandler(void *userData, const XML_Char *name, - const XML_Char **atts); -static void pgxml_endhandler(void *userData, const XML_Char *name); -static void pgxml_charhandler(void *userData, const XML_Char *s, int len); +Datum pgxml_parse(PG_FUNCTION_ARGS); +Datum pgxml_xpath(PG_FUNCTION_ARGS); +static void pgxml_starthandler(void *userData, const XML_Char * name, + const XML_Char ** atts); +static void pgxml_endhandler(void *userData, const XML_Char * name); +static void pgxml_charhandler(void *userData, const XML_Char * s, int len); static void pgxml_pathcompare(void *userData); static void pgxml_finalisegrabbedtext(void *userData); @@ -18,43 +18,25 @@ static void pgxml_finalisegrabbedtext(void *userData); #define MAXRESULTS 100 -typedef struct { - int rescount; - char *results[MAXRESULTS]; - int32 reslens[MAXRESULTS]; - char *resbuf; /* pointer to the result buffer for pfree */ -} XPath_Results; +typedef struct +{ + int rescount; + char *results[MAXRESULTS]; + int32 reslens[MAXRESULTS]; + char *resbuf; /* pointer to the result buffer for pfree */ +} XPath_Results; -typedef struct { - char currentpath[MAXPATHLENGTH]; - char *path; - int textgrab; - char *resptr; - int32 reslen; - XPath_Results *xpres; -} pgxml_udata; +typedef struct +{ + char currentpath[MAXPATHLENGTH]; + char *path; + int textgrab; + char *resptr; + int32 reslen; + XPath_Results *xpres; +} pgxml_udata; #define UD ((pgxml_udata *) userData) - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/xml/pgxml_dom.c b/contrib/xml/pgxml_dom.c index b01368a52c..f2f9973b89 100644 --- a/contrib/xml/pgxml_dom.c +++ b/contrib/xml/pgxml_dom.c @@ -15,50 +15,57 @@ static void *pgxml_palloc(size_t size); static void *pgxml_repalloc(void *ptr, size_t size); static void pgxml_pfree(void *ptr); -static char *pgxml_pstrdup(const char* string); +static char *pgxml_pstrdup(const char *string); static void pgxml_parser_init(); -static xmlChar *pgxmlNodeSetToText(xmlNodeSetPtr nodeset, xmlDocPtr doc, - xmlChar *toptagname, xmlChar *septagname, +static xmlChar *pgxmlNodeSetToText(xmlNodeSetPtr nodeset, xmlDocPtr doc, + xmlChar * toptagname, xmlChar * septagname, int format); static xmlChar *pgxml_texttoxmlchar(text *textstring); -Datum pgxml_parse(PG_FUNCTION_ARGS); -Datum pgxml_xpath(PG_FUNCTION_ARGS); +Datum pgxml_parse(PG_FUNCTION_ARGS); +Datum pgxml_xpath(PG_FUNCTION_ARGS); /* memory handling passthrough functions (e.g. palloc, pstrdup are currently macros, and the others might become so...) */ -static void *pgxml_palloc(size_t size) +static void * +pgxml_palloc(size_t size) { - return palloc(size); + return palloc(size); } -static void *pgxml_repalloc(void *ptr, size_t size) +static void * +pgxml_repalloc(void *ptr, size_t size) { - return repalloc(ptr,size); + return repalloc(ptr, size); } -static void pgxml_pfree(void *ptr) +static void +pgxml_pfree(void *ptr) { - return pfree(ptr); + return pfree(ptr); } -static char *pgxml_pstrdup(const char *string) +static char * +pgxml_pstrdup(const char *string) { - return pstrdup(string); + return pstrdup(string); } -static void pgxml_parser_init() +static void +pgxml_parser_init() { - /* This code should also set parser settings from user-supplied - info. Quite how these settings are made is another matter :) */ + /* + * This code should also set parser settings from user-supplied info. + * Quite how these settings are made is another matter :) + */ - xmlMemSetup(pgxml_pfree, pgxml_palloc, pgxml_repalloc, pgxml_pstrdup); - xmlInitParser(); + xmlMemSetup(pgxml_pfree, pgxml_palloc, pgxml_repalloc, pgxml_pstrdup); + xmlInitParser(); } @@ -70,86 +77,98 @@ PG_FUNCTION_INFO_V1(pgxml_parse); Datum pgxml_parse(PG_FUNCTION_ARGS) { - /* called as pgxml_parse(document) */ - xmlDocPtr doctree; - text *t = PG_GETARG_TEXT_P(0); /*document buffer */ - int32 docsize = VARSIZE(t) - VARHDRSZ; - - pgxml_parser_init(); - - doctree = xmlParseMemory((char *) VARDATA(t), docsize); - if (doctree == NULL) { - /* xmlCleanupParser(); */ - PG_RETURN_BOOL(false); /* i.e. not well-formed */ - } - /* xmlCleanupParser(); */ - xmlFreeDoc(doctree); - PG_RETURN_BOOL(true); + /* called as pgxml_parse(document) */ + xmlDocPtr doctree; + text *t = PG_GETARG_TEXT_P(0); /* document buffer */ + int32 docsize = VARSIZE(t) - VARHDRSZ; + + pgxml_parser_init(); + + doctree = xmlParseMemory((char *) VARDATA(t), docsize); + if (doctree == NULL) + { + /* xmlCleanupParser(); */ + PG_RETURN_BOOL(false); /* i.e. not well-formed */ + } + /* xmlCleanupParser(); */ + xmlFreeDoc(doctree); + PG_RETURN_BOOL(true); } -static xmlChar -*pgxmlNodeSetToText(xmlNodeSetPtr nodeset, - xmlDocPtr doc, - xmlChar *toptagname, - xmlChar *septagname, - int format) +static xmlChar +* +pgxmlNodeSetToText(xmlNodeSetPtr nodeset, + xmlDocPtr doc, + xmlChar * toptagname, + xmlChar * septagname, + int format) { - /* Function translates a nodeset into a text representation */ - /* iterates over each node in the set and calls xmlNodeDump to write - it to an xmlBuffer -from which an xmlChar * string is returned. */ - /* each representation is surrounded by <tagname> ... </tagname> */ - /* if format==0, add a newline between nodes?? */ - - xmlBufferPtr buf; - xmlChar *result; - int i; - - buf =xmlBufferCreate(); - - if ((toptagname != NULL) && (xmlStrlen(toptagname)>0)) { - xmlBufferWriteChar(buf,"<"); - xmlBufferWriteCHAR(buf,toptagname); - xmlBufferWriteChar(buf,">"); - } - if (nodeset != NULL) { - for (i=0; i < nodeset->nodeNr; i++) { - if ((septagname != NULL) && (xmlStrlen(septagname)>0)) { - xmlBufferWriteChar(buf,"<"); - xmlBufferWriteCHAR(buf,septagname); - xmlBufferWriteChar(buf,">"); - } - xmlNodeDump(buf, doc, nodeset->nodeTab[i],1,(format==2)); - - if ((septagname != NULL) && (xmlStrlen(septagname)>0)) { - xmlBufferWriteChar(buf,"</"); - xmlBufferWriteCHAR(buf,septagname); - xmlBufferWriteChar(buf,">"); - } - if (format) { - xmlBufferWriteChar(buf,"\n"); - } - } - } - - if ((toptagname != NULL) && (xmlStrlen(toptagname)>0)) { - xmlBufferWriteChar(buf,"</"); - xmlBufferWriteCHAR(buf,toptagname); - xmlBufferWriteChar(buf,">"); - } - result = xmlStrdup(buf->content); - xmlBufferFree(buf); - return result; + /* Function translates a nodeset into a text representation */ + + /* + * iterates over each node in the set and calls xmlNodeDump to write + * it to an xmlBuffer -from which an xmlChar * string is returned. + */ + /* each representation is surrounded by <tagname> ... </tagname> */ + /* if format==0, add a newline between nodes?? */ + + xmlBufferPtr buf; + xmlChar *result; + int i; + + buf = xmlBufferCreate(); + + if ((toptagname != NULL) && (xmlStrlen(toptagname) > 0)) + { + xmlBufferWriteChar(buf, "<"); + xmlBufferWriteCHAR(buf, toptagname); + xmlBufferWriteChar(buf, ">"); + } + if (nodeset != NULL) + { + for (i = 0; i < nodeset->nodeNr; i++) + { + if ((septagname != NULL) && (xmlStrlen(septagname) > 0)) + { + xmlBufferWriteChar(buf, "<"); + xmlBufferWriteCHAR(buf, septagname); + xmlBufferWriteChar(buf, ">"); + } + xmlNodeDump(buf, doc, nodeset->nodeTab[i], 1, (format == 2)); + + if ((septagname != NULL) && (xmlStrlen(septagname) > 0)) + { + xmlBufferWriteChar(buf, "</"); + xmlBufferWriteCHAR(buf, septagname); + xmlBufferWriteChar(buf, ">"); + } + if (format) + xmlBufferWriteChar(buf, "\n"); + } + } + + if ((toptagname != NULL) && (xmlStrlen(toptagname) > 0)) + { + xmlBufferWriteChar(buf, "</"); + xmlBufferWriteCHAR(buf, toptagname); + xmlBufferWriteChar(buf, ">"); + } + result = xmlStrdup(buf->content); + xmlBufferFree(buf); + return result; } -static xmlChar *pgxml_texttoxmlchar(text *textstring) { - xmlChar *res; - int32 txsize; - - txsize=VARSIZE(textstring)-VARHDRSZ; - res = (xmlChar *) palloc(txsize+1); - memcpy((char *)res, VARDATA(textstring), txsize); - res[txsize]='\0'; - return res; +static xmlChar * +pgxml_texttoxmlchar(text *textstring) +{ + xmlChar *res; + int32 txsize; + + txsize = VARSIZE(textstring) - VARHDRSZ; + res = (xmlChar *) palloc(txsize + 1); + memcpy((char *) res, VARDATA(textstring), txsize); + res[txsize] = '\0'; + return res; } @@ -158,81 +177,86 @@ PG_FUNCTION_INFO_V1(pgxml_xpath); Datum pgxml_xpath(PG_FUNCTION_ARGS) { - xmlDocPtr doctree; - xmlXPathContextPtr ctxt; - xmlXPathObjectPtr res; - xmlChar *xpath, *xpresstr, *toptag, *septag; - xmlXPathCompExprPtr comppath; - - int32 docsize,ressize; - text *t, *xpres; - - t = PG_GETARG_TEXT_P(0); /*document buffer */ - xpath = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(1)); /* XPath expression */ - toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2)); - septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3)); - - docsize = VARSIZE(t) - VARHDRSZ; - - pgxml_parser_init(); - - doctree = xmlParseMemory((char *) VARDATA(t), docsize); - if (doctree == NULL) { /* not well-formed */ - PG_RETURN_NULL(); - } - - ctxt = xmlXPathNewContext(doctree); - ctxt->node = xmlDocGetRootElement(doctree); - - /* compile the path */ - comppath = xmlXPathCompile(xpath); - if (comppath == NULL) { - elog(NOTICE, "XPath syntax error"); - xmlFreeDoc(doctree); - pfree((void *) xpath); - PG_RETURN_NULL(); - } - - /* Now evaluate the path expression. */ - res = xmlXPathCompiledEval(comppath,ctxt); - xmlXPathFreeCompExpr(comppath); - - if (res==NULL) { - xmlFreeDoc(doctree); - pfree((void *)xpath); - PG_RETURN_NULL(); /* seems appropriate */ - } - /* now we dump this node, ?surrounding by tags? */ - /* To do this, we look first at the type */ - switch(res->type) { - case XPATH_NODESET: - xpresstr = pgxmlNodeSetToText(res->nodesetval, - doctree, - toptag, septag, 0); - break; - case XPATH_STRING: - xpresstr = xmlStrdup(res->stringval); - break; - default: - elog(NOTICE,"Unsupported XQuery result: %d",res->type); - xpresstr = xmlStrdup("<unsupported/>"); - } - - - /* Now convert this result back to text */ - ressize = strlen(xpresstr); - xpres = (text *) palloc(ressize+VARHDRSZ); - memcpy(VARDATA(xpres),xpresstr,ressize); - VARATT_SIZEP(xpres)=ressize + VARHDRSZ; - - /* Free various storage */ - xmlFreeDoc(doctree); - pfree((void *) xpath); - xmlFree(xpresstr); - - PG_RETURN_TEXT_P(xpres); + xmlDocPtr doctree; + xmlXPathContextPtr ctxt; + xmlXPathObjectPtr res; + xmlChar *xpath, + *xpresstr, + *toptag, + *septag; + xmlXPathCompExprPtr comppath; + + int32 docsize, + ressize; + text *t, + *xpres; + + t = PG_GETARG_TEXT_P(0); /* document buffer */ + xpath = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(1)); /* XPath expression */ + toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2)); + septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3)); + + docsize = VARSIZE(t) - VARHDRSZ; + + pgxml_parser_init(); + + doctree = xmlParseMemory((char *) VARDATA(t), docsize); + if (doctree == NULL) + { /* not well-formed */ + PG_RETURN_NULL(); + } + + ctxt = xmlXPathNewContext(doctree); + ctxt->node = xmlDocGetRootElement(doctree); + + /* compile the path */ + comppath = xmlXPathCompile(xpath); + if (comppath == NULL) + { + elog(NOTICE, "XPath syntax error"); + xmlFreeDoc(doctree); + pfree((void *) xpath); + PG_RETURN_NULL(); + } + + /* Now evaluate the path expression. */ + res = xmlXPathCompiledEval(comppath, ctxt); + xmlXPathFreeCompExpr(comppath); + + if (res == NULL) + { + xmlFreeDoc(doctree); + pfree((void *) xpath); + PG_RETURN_NULL(); /* seems appropriate */ + } + /* now we dump this node, ?surrounding by tags? */ + /* To do this, we look first at the type */ + switch (res->type) + { + case XPATH_NODESET: + xpresstr = pgxmlNodeSetToText(res->nodesetval, + doctree, + toptag, septag, 0); + break; + case XPATH_STRING: + xpresstr = xmlStrdup(res->stringval); + break; + default: + elog(NOTICE, "Unsupported XQuery result: %d", res->type); + xpresstr = xmlStrdup("<unsupported/>"); + } + + + /* Now convert this result back to text */ + ressize = strlen(xpresstr); + xpres = (text *) palloc(ressize + VARHDRSZ); + memcpy(VARDATA(xpres), xpresstr, ressize); + VARATT_SIZEP(xpres) = ressize + VARHDRSZ; + + /* Free various storage */ + xmlFreeDoc(doctree); + pfree((void *) xpath); + xmlFree(xpresstr); + + PG_RETURN_TEXT_P(xpres); } - - - - diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index ef6cedd92d..5b005b3163 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.73 2001/08/23 23:06:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.74 2001/10/25 05:49:20 momjian Exp $ * * NOTES * The old interface functions have been converted to macros @@ -241,7 +241,6 @@ nocachegetattr(HeapTuple tuple, } else { - /* * there's a null somewhere in the tuple */ @@ -347,7 +346,6 @@ nocachegetattr(HeapTuple tuple, (HeapTupleNoNulls(tuple) || !att_isnull(j, bp)) && (HeapTupleAllFixed(tuple) || att[j]->attlen > 0)); j++) { - /* * Fix me when going to a machine with more than a four-byte * word! @@ -546,7 +544,6 @@ heap_deformtuple(HeapTuple tuple, nulls[i] = ' '; } } - #endif /* ---------------- @@ -739,7 +736,7 @@ heap_freetuple(HeapTuple htup) * * This routine forms a HeapTuple by copying the given structure (tuple * data) and adding a generic header. Note that the tuple data is - * presumed to contain no null fields. It is typically only useful + * presumed to contain no null fields. It is typically only useful * for null-free system tables. * ---------------- */ @@ -771,7 +768,7 @@ heap_addheader(int natts, /* max domain index */ td->t_hoff = hoff; td->t_natts = natts; - td->t_infomask = HEAP_XMAX_INVALID; /* XXX sufficient? */ + td->t_infomask = HEAP_XMAX_INVALID; /* XXX sufficient? */ memcpy((char *) td + hoff, structure, structlen); diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 5c165e2c77..ad6e7cc4e5 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.54 2001/03/22 06:16:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.55 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,6 @@ index_formtuple(TupleDesc tupleDescriptor, #ifdef TOAST_INDEX_HACK Datum untoasted_value[INDEX_MAX_KEYS]; bool untoasted_free[INDEX_MAX_KEYS]; - #endif if (numberOfAttributes > INDEX_MAX_KEYS) @@ -338,7 +337,6 @@ nocache_index_getattr(IndexTuple tup, for (; j <= attnum; j++) { - /* * Fix me when going to a machine with more than a four-byte * word! diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index da95edfc1f..ea10330bf8 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.59 2001/03/22 06:16:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.60 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -197,7 +197,6 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) continue; if (OidIsValid(thisState->typoutput)) { - /* * If we have a toasted datum, forcibly detoast it here to * avoid memory leakage inside the type's output routine. @@ -306,7 +305,6 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) if (getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &typoutput, &typelem, &typisvarlena)) { - /* * If we have a toasted datum, forcibly detoast it here to * avoid memory leakage inside the type's output routine. @@ -401,7 +399,6 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) /* send # of bytes, and opaque data */ if (thisState->typisvarlena) { - /* * If we have a toasted datum, must detoast before sending. */ diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index 37e895479e..4b9d53df34 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.75 2001/06/25 21:11:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.76 2001/10/25 05:49:20 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -238,9 +238,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) Form_pg_attribute attr2 = tupdesc2->attrs[i]; /* - * We do not need to check every single field here: we can disregard - * attrelid, attnum (it was used to place the row in the attrs array) - * and everything derived from the column datatype. + * We do not need to check every single field here: we can + * disregard attrelid, attnum (it was used to place the row in the + * attrs array) and everything derived from the column datatype. */ if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0) return false; @@ -399,7 +399,6 @@ TupleDescInitEntry(TupleDesc desc, 0, 0, 0); if (!HeapTupleIsValid(tuple)) { - /* * here type info does not exist yet so we just fill the attribute * with dummy information and return false. @@ -585,7 +584,6 @@ BuildDescForRelation(List *schema, char *relname) typenameTypeId(typename), atttypmod, attdim, attisset)) { - /* * if TupleDescInitEntry() fails, it means there is no type in * the system catalogs. So now we check if the type name diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 4a702fe317..0c4e698f01 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.84 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.85 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,26 +36,26 @@ /* group flags ( in gistSplit ) */ #define LEFT_ADDED 0x01 -#define RIGHT_ADDED 0x02 +#define RIGHT_ADDED 0x02 #define BOTH_ADDED ( LEFT_ADDED | RIGHT_ADDED ) /* * This defines only for shorter code, used in gistgetadjusted * and gistadjsubkey only */ -#define FILLITEM(evp, isnullkey, okey, okeyb, rkey, rkeyb) do { \ - if ( isnullkey ) { \ - gistentryinit((evp), rkey, r, (Page) NULL , \ - (OffsetNumber) 0, rkeyb, FALSE); \ - } else { \ - gistentryinit((evp), okey, r, (Page) NULL, \ - (OffsetNumber) 0, okeyb, FALSE); \ - } \ +#define FILLITEM(evp, isnullkey, okey, okeyb, rkey, rkeyb) do { \ + if ( isnullkey ) { \ + gistentryinit((evp), rkey, r, (Page) NULL , \ + (OffsetNumber) 0, rkeyb, FALSE); \ + } else { \ + gistentryinit((evp), okey, r, (Page) NULL, \ + (OffsetNumber) 0, okeyb, FALSE); \ + } \ } while(0) #define FILLEV(isnull1, key1, key1b, isnull2, key2, key2b) do { \ - FILLITEM(*ev0p, isnull1, key1, key1b, key2, key2b); \ - FILLITEM(*ev1p, isnull2, key2, key2b, key1, key1b); \ + FILLITEM(*ev0p, isnull1, key1, key1b, key2, key2b); \ + FILLITEM(*ev1p, isnull2, key2, key2b, key1, key1b); \ } while(0); /* Working state for gistbuild and its callback */ @@ -69,11 +69,11 @@ typedef struct /* non-export function prototypes */ static void gistbuildCallback(Relation index, - HeapTuple htup, - Datum *attdata, - char *nulls, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *attdata, + char *nulls, + bool tupleIsAlive, + void *state); static void gistdoinsert(Relation r, IndexTuple itup, InsertIndexResult *res, @@ -103,14 +103,14 @@ static IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate); -static int gistfindgroup( GISTSTATE *giststate, - GISTENTRY *valvec, GIST_SPLITVEC * spl ); +static int gistfindgroup(GISTSTATE *giststate, + GISTENTRY *valvec, GIST_SPLITVEC *spl); static void gistadjsubkey(Relation r, - IndexTuple *itup, int *len, - GIST_SPLITVEC *v, - GISTSTATE *giststate); -static IndexTuple gistFormTuple( GISTSTATE *giststate, - Relation r, Datum attdata[], int datumsize[], bool isnull[] ); + IndexTuple *itup, int *len, + GIST_SPLITVEC *v, + GISTSTATE *giststate); +static IndexTuple gistFormTuple(GISTSTATE *giststate, + Relation r, Datum attdata[], int datumsize[], bool isnull[]); static IndexTuple *gistSplit(Relation r, Buffer buffer, IndexTuple *itup, @@ -124,6 +124,7 @@ static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate); static void gistdelete(Relation r, ItemPointer tid); + #ifdef GIST_PAGEADDITEM static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t); @@ -132,14 +133,15 @@ static void gistcentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, int b, bool l, bool isNull); -static void gistDeCompressAtt( GISTSTATE *giststate, Relation r, - IndexTuple tuple, Page p, OffsetNumber o, - GISTENTRY attdata[], bool decompvec[], bool isnull[] ); -static void gistFreeAtt( Relation r, GISTENTRY attdata[], bool decompvec[] ); -static void gistpenalty( GISTSTATE *giststate, int attno, +static void gistDeCompressAtt(GISTSTATE *giststate, Relation r, + IndexTuple tuple, Page p, OffsetNumber o, + GISTENTRY attdata[], bool decompvec[], bool isnull[]); +static void gistFreeAtt(Relation r, GISTENTRY attdata[], bool decompvec[]); +static void gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *key1, bool isNull1, - GISTENTRY *key2, bool isNull2, - float *penalty ); + GISTENTRY *key2, bool isNull2, + float *penalty); + #undef GISTDEBUG #ifdef GISTDEBUG @@ -182,7 +184,7 @@ gistbuild(PG_FUNCTION_ARGS) /* do the heap scan */ reltuples = IndexBuildHeapScan(heap, index, indexInfo, - gistbuildCallback, (void *) &buildstate); + gistbuildCallback, (void *) &buildstate); /* okay, all heap tuples are indexed */ @@ -208,7 +210,7 @@ gistbuild(PG_FUNCTION_ARGS) UpdateStats(irelid, buildstate.indtuples); } - freeGISTstate( &buildstate.giststate ); + freeGISTstate(&buildstate.giststate); #ifdef GISTDEBUG gist_dumptree(index, 0, GISTP_ROOT, 0); #endif @@ -227,28 +229,31 @@ gistbuildCallback(Relation index, bool tupleIsAlive, void *state) { - GISTBuildState *buildstate = (GISTBuildState *) state; + GISTBuildState *buildstate = (GISTBuildState *) state; IndexTuple itup; bool compvec[INDEX_MAX_KEYS]; GISTENTRY tmpcentry; int i; - /* GiST cannot index tuples with leading NULLs */ - if ( nulls[0] == 'n' ) - return; + /* GiST cannot index tuples with leading NULLs */ + if (nulls[0] == 'n') + return; /* immediately compress keys to normalize */ for (i = 0; i < buildstate->numindexattrs; i++) { - if ( nulls[i]=='n' ) { + if (nulls[i] == 'n') + { attdata[i] = (Datum) 0; compvec[i] = FALSE; - } else { + } + else + { gistcentryinit(&buildstate->giststate, i, &tmpcentry, attdata[i], - (Relation) NULL, (Page) NULL, (OffsetNumber) 0, - -1 /* size is currently bogus */ , TRUE, FALSE); + (Relation) NULL, (Page) NULL, (OffsetNumber) 0, + -1 /* size is currently bogus */ , TRUE, FALSE); if (attdata[i] != tmpcentry.key && - !( isAttByVal(&buildstate->giststate, i))) + !(isAttByVal(&buildstate->giststate, i))) compvec[i] = TRUE; else compvec[i] = FALSE; @@ -262,10 +267,10 @@ gistbuildCallback(Relation index, /* * Since we already have the index relation locked, we call - * gistdoinsert directly. Normal access method calls dispatch - * through gistinsert, which locks the relation for write. This - * is the right thing to do if you're inserting single tups, but - * not when you're initializing the whole index at once. + * gistdoinsert directly. Normal access method calls dispatch through + * gistinsert, which locks the relation for write. This is the right + * thing to do if you're inserting single tups, but not when you're + * initializing the whole index at once. */ gistdoinsert(index, itup, NULL, &buildstate->giststate); @@ -291,6 +296,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); #endif @@ -303,29 +309,33 @@ gistinsert(PG_FUNCTION_ARGS) /* * Since GIST is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking + * have acquired exclusive lock on index relation. We need no locking * here. */ - /* GiST cannot index tuples with leading NULLs */ - if ( nulls[0] == 'n' ) { + /* GiST cannot index tuples with leading NULLs */ + if (nulls[0] == 'n') + { res = NULL; PG_RETURN_POINTER(res); - } + } initGISTstate(&giststate, r); /* immediately compress keys to normalize */ for (i = 0; i < r->rd_att->natts; i++) { - if ( nulls[i]=='n' ) { + if (nulls[i] == 'n') + { datum[i] = (Datum) 0; compvec[i] = FALSE; - } else { + } + else + { gistcentryinit(&giststate, i, &tmpentry, datum[i], - (Relation) NULL, (Page) NULL, (OffsetNumber) 0, - -1 /* size is currently bogus */ , TRUE, FALSE ); - if (datum[i] != tmpentry.key && !( isAttByVal( &giststate, i))) + (Relation) NULL, (Page) NULL, (OffsetNumber) 0, + -1 /* size is currently bogus */ , TRUE, FALSE); + if (datum[i] != tmpentry.key && !(isAttByVal(&giststate, i))) compvec[i] = TRUE; else compvec[i] = FALSE; @@ -342,7 +352,7 @@ gistinsert(PG_FUNCTION_ARGS) if (compvec[i] == TRUE) pfree(DatumGetPointer(datum[i])); pfree(itup); - freeGISTstate( &giststate ); + freeGISTstate(&giststate); PG_RETURN_POINTER(res); } @@ -376,12 +386,12 @@ gistPageAddItem(GISTSTATE *giststate, * offset for insertion */ datum = index_getattr(itup, 1, r->rd_att, &IsNull); - gistdentryinit(giststate, 0,dentry, datum, + gistdentryinit(giststate, 0, dentry, datum, (Relation) 0, (Page) 0, (OffsetNumber) InvalidOffsetNumber, - ATTSIZE( datum, r, 1, IsNull ), + ATTSIZE(datum, r, 1, IsNull), FALSE, IsNull); - gistcentryinit(giststate, 0,&tmpcentry, dentry->key, r, page, + gistcentryinit(giststate, 0, &tmpcentry, dentry->key, r, page, offsetNumber, dentry->bytes, FALSE); *newtup = gist_tuple_replacekey(r, tmpcentry, itup); retval = PageAddItem(page, (Item) *newtup, IndexTupleSize(*newtup), @@ -392,7 +402,7 @@ gistPageAddItem(GISTSTATE *giststate, /* be tidy */ if (DatumGetPointer(tmpcentry.key) != NULL && tmpcentry.key != dentry->key && - tmpcentry.key != datum ) + tmpcentry.key != datum) pfree(DatumGetPointer(tmpcentry.key)); return (retval); } @@ -471,6 +481,7 @@ gistlayerinsert(Relation r, BlockNumber blkno, if (!(ret & SPLITED)) { IndexTuple newtup = gistgetadjusted(r, oldtup, (*itup)[0], giststate); + if (!newtup) { /* not need to update key */ @@ -492,8 +503,10 @@ gistlayerinsert(Relation r, BlockNumber blkno, if (gistnospace(page, (*itup), *len)) { /* no space for insertion */ - IndexTuple *itvec, *newitup; - int tlen,oldlen; + IndexTuple *itvec, + *newitup; + int tlen, + oldlen; ret |= SPLITED; itvec = gistreadbuffer(r, buffer, &tlen); @@ -503,9 +516,9 @@ gistlayerinsert(Relation r, BlockNumber blkno, (opaque->flags & F_LEAF) ? res : NULL); /* res only for * inserting in leaf */ ReleaseBuffer(buffer); - do - pfree( (*itup)[ oldlen-1 ] ); - while ( (--oldlen) > 0 ); + do + pfree((*itup)[oldlen - 1]); + while ((--oldlen) > 0); pfree((*itup)); pfree(itvec); *itup = newitup; @@ -539,7 +552,8 @@ gistlayerinsert(Relation r, BlockNumber blkno, * parent */ IndexTuple newtup = gistunion(r, (*itup), *len, giststate); - ItemPointerSet(&(newtup->t_tid), blkno, 1); + + ItemPointerSet(&(newtup->t_tid), blkno, 1); for (i = 0; i < *len; i++) pfree((*itup)[i]); @@ -560,10 +574,11 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup, { OffsetNumber l = InvalidOffsetNumber; int i; + #ifdef GIST_PAGEADDITEM GISTENTRY tmpdentry; IndexTuple newtup; - bool IsNull; + bool IsNull; #endif for (i = 0; i < len; i++) { @@ -573,13 +588,13 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup, off, LP_USED, &tmpdentry, &newtup); off = OffsetNumberNext(off); if (DatumGetPointer(tmpdentry.key) != NULL && - tmpdentry.key != index_getattr(itup[i], 1, r->rd_att, &IsNull)) + tmpdentry.key != index_getattr(itup[i], 1, r->rd_att, &IsNull)) pfree(DatumGetPointer(tmpdentry.key)); if (itup[i] != newtup) pfree(newtup); #else l = PageAddItem(page, (Item) itup[i], IndexTupleSize(itup[i]), - off, LP_USED); + off, LP_USED); if (l == InvalidOffsetNumber) elog(ERROR, "gist: failed to add index item to %s", RelationGetRelationName(r)); @@ -618,7 +633,7 @@ gistreadbuffer(Relation r, Buffer buffer, int *len /* out */ ) *len = maxoff; itvec = palloc(sizeof(IndexTuple) * maxoff); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) - itvec[i-1] = (IndexTuple) PageGetItem(p, PageGetItemId(p, i)); + itvec[i - 1] = (IndexTuple) PageGetItem(p, PageGetItemId(p, i)); return itvec; } @@ -639,74 +654,85 @@ gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen) * return union of itup vector */ static IndexTuple -gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) { +gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) +{ Datum attr[INDEX_MAX_KEYS]; - bool whatfree[INDEX_MAX_KEYS]; + bool whatfree[INDEX_MAX_KEYS]; char isnull[INDEX_MAX_KEYS]; bytea *evec; Datum datum; int datumsize, - i,j; + i, + j; GISTENTRY centry[INDEX_MAX_KEYS]; - bool *needfree; - IndexTuple newtup; - bool IsNull; - int reallen; + bool *needfree; + IndexTuple newtup; + bool IsNull; + int reallen; - needfree = (bool *) palloc((( len==1 ) ? 2 : len ) * sizeof(bool)); - evec = (bytea *) palloc((( len==1 ) ? 2 : len ) * sizeof(GISTENTRY) + VARHDRSZ); + needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool)); + evec = (bytea *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + VARHDRSZ); - for (j = 0; j < r->rd_att->natts; j++) { - reallen=0; - for (i = 0; i < len; i++) { - datum = index_getattr(itvec[i], j+1, giststate->tupdesc, &IsNull); - if ( IsNull ) continue; + for (j = 0; j < r->rd_att->natts; j++) + { + reallen = 0; + for (i = 0; i < len; i++) + { + datum = index_getattr(itvec[i], j + 1, giststate->tupdesc, &IsNull); + if (IsNull) + continue; gistdentryinit(giststate, j, &((GISTENTRY *) VARDATA(evec))[reallen], datum, - (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, - ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull); - if ( (!isAttByVal(giststate,j)) && - ((GISTENTRY *) VARDATA(evec))[reallen].key != datum ) + (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, + ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull); + if ((!isAttByVal(giststate, j)) && + ((GISTENTRY *) VARDATA(evec))[reallen].key != datum) needfree[reallen] = TRUE; else needfree[reallen] = FALSE; reallen++; } - if ( reallen == 0 ) { + if (reallen == 0) + { attr[j] = (Datum) 0; isnull[j] = 'n'; whatfree[j] = FALSE; - } else { - if ( reallen == 1 ) { + } + else + { + if (reallen == 1) + { VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ; - gistentryinit(((GISTENTRY *) VARDATA(evec))[1], - ((GISTENTRY *) VARDATA(evec))[0].key, r, (Page) NULL, - (OffsetNumber) 0, ((GISTENTRY *) VARDATA(evec))[0].bytes, FALSE); + gistentryinit(((GISTENTRY *) VARDATA(evec))[1], + ((GISTENTRY *) VARDATA(evec))[0].key, r, (Page) NULL, + (OffsetNumber) 0, ((GISTENTRY *) VARDATA(evec))[0].bytes, FALSE); - } else { - VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ; } + else + VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ; datum = FunctionCall2(&giststate->unionFn[j], - PointerGetDatum(evec), - PointerGetDatum(&datumsize)); - + PointerGetDatum(evec), + PointerGetDatum(&datumsize)); + for (i = 0; i < reallen; i++) - if ( needfree[i] ) + if (needfree[i]) pfree(DatumGetPointer(((GISTENTRY *) VARDATA(evec))[i].key)); gistcentryinit(giststate, j, ¢ry[j], datum, - (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, - datumsize, FALSE, FALSE); + (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, + datumsize, FALSE, FALSE); isnull[j] = ' '; - attr[j] = centry[j].key; - if ( !isAttByVal( giststate, j ) ) { + attr[j] = centry[j].key; + if (!isAttByVal(giststate, j)) + { whatfree[j] = TRUE; - if ( centry[j].key != datum ) + if (centry[j].key != datum) pfree(DatumGetPointer(datum)); - } else + } + else whatfree[j] = FALSE; } } @@ -716,7 +742,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) { newtup = (IndexTuple) index_formtuple(giststate->tupdesc, attr, isnull); for (j = 0; j < r->rd_att->natts; j++) - if ( whatfree[j] ) + if (whatfree[j]) pfree(DatumGetPointer(attr[j])); return newtup; @@ -732,7 +758,8 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis bytea *evec; Datum datum; int datumsize; - bool result, neednew = false; + bool result, + neednew = false; char isnull[INDEX_MAX_KEYS], whatfree[INDEX_MAX_KEYS]; Datum attr[INDEX_MAX_KEYS]; @@ -744,104 +771,125 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis bool olddec[INDEX_MAX_KEYS], adddec[INDEX_MAX_KEYS]; bool oldisnull[INDEX_MAX_KEYS], - addisnull[INDEX_MAX_KEYS]; + addisnull[INDEX_MAX_KEYS]; IndexTuple newtup = NULL; - int j; + int j; evec = (bytea *) palloc(2 * sizeof(GISTENTRY) + VARHDRSZ); VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ; ev0p = &((GISTENTRY *) VARDATA(evec))[0]; ev1p = &((GISTENTRY *) VARDATA(evec))[1]; - - gistDeCompressAtt( giststate, r, oldtup, (Page) NULL, - (OffsetNumber) 0, oldatt, olddec, oldisnull); - gistDeCompressAtt( giststate, r, addtup, (Page) NULL, - (OffsetNumber) 0, addatt, adddec, addisnull); + gistDeCompressAtt(giststate, r, oldtup, (Page) NULL, + (OffsetNumber) 0, oldatt, olddec, oldisnull); + + gistDeCompressAtt(giststate, r, addtup, (Page) NULL, + (OffsetNumber) 0, addatt, adddec, addisnull); + - - for( j=0; j<r->rd_att->natts; j++ ) { - if ( oldisnull[j] && addisnull[j] ) { + for (j = 0; j < r->rd_att->natts; j++) + { + if (oldisnull[j] && addisnull[j]) + { isnull[j] = 'n'; attr[j] = (Datum) 0; whatfree[j] = FALSE; - } else { + } + else + { FILLEV( - oldisnull[j], oldatt[j].key, oldatt[j].bytes, - addisnull[j], addatt[j].key, addatt[j].bytes - ); - + oldisnull[j], oldatt[j].key, oldatt[j].bytes, + addisnull[j], addatt[j].key, addatt[j].bytes + ); + datum = FunctionCall2(&giststate->unionFn[j], - PointerGetDatum(evec), - PointerGetDatum(&datumsize)); + PointerGetDatum(evec), + PointerGetDatum(&datumsize)); - if ( oldisnull[j] || addisnull[j] ) { - if ( oldisnull[j] ) + if (oldisnull[j] || addisnull[j]) + { + if (oldisnull[j]) neednew = true; - } else { + } + else + { FunctionCall3(&giststate->equalFn[j], - ev0p->key, - datum, - PointerGetDatum(&result)); - - if ( !result ) + ev0p->key, + datum, + PointerGetDatum(&result)); + + if (!result) neednew = true; } - if ( olddec[j] ) pfree( DatumGetPointer(oldatt[j].key) ); - if ( adddec[j] ) pfree( DatumGetPointer(addatt[j].key) ); + if (olddec[j]) + pfree(DatumGetPointer(oldatt[j].key)); + if (adddec[j]) + pfree(DatumGetPointer(addatt[j].key)); gistcentryinit(giststate, j, ¢ry[j], datum, - (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, - datumsize, FALSE, FALSE); - + (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, + datumsize, FALSE, FALSE); + isnull[j] = ' '; - attr[j] = centry[j].key; - if ( (!isAttByVal( giststate, j ) ) ) { + attr[j] = centry[j].key; + if ((!isAttByVal(giststate, j))) + { whatfree[j] = TRUE; - if ( centry[j].key != datum ) + if (centry[j].key != datum) pfree(DatumGetPointer(datum)); - } else + } + else whatfree[j] = FALSE; } - } + } pfree(evec); - if (neednew) { + if (neednew) + { /* need to update key */ newtup = (IndexTuple) index_formtuple(giststate->tupdesc, attr, isnull); newtup->t_tid = oldtup->t_tid; } - + for (j = 0; j < r->rd_att->natts; j++) - if ( whatfree[j] ) + if (whatfree[j]) pfree(DatumGetPointer(attr[j])); return newtup; } static void -gistunionsubkey( Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITVEC * spl ) { - int i,j,lr; +gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITVEC *spl) +{ + int i, + j, + lr; Datum *attr; - bool *needfree, IsNull; - int len, *attrsize; - OffsetNumber *entries; - bytea *evec; + bool *needfree, + IsNull; + int len, + *attrsize; + OffsetNumber *entries; + bytea *evec; Datum datum; - int datumsize; - int reallen; - bool *isnull; + int datumsize; + int reallen; + bool *isnull; - for(lr=0;lr<=1;lr++) { - if ( lr ) { + for (lr = 0; lr <= 1; lr++) + { + if (lr) + { attrsize = spl->spl_lattrsize; attr = spl->spl_lattr; len = spl->spl_nleft; entries = spl->spl_left; isnull = spl->spl_lisnull; - } else { + } + else + { attrsize = spl->spl_rattrsize; attr = spl->spl_rattr; len = spl->spl_nright; @@ -849,58 +897,64 @@ gistunionsubkey( Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLIT isnull = spl->spl_risnull; } - needfree = (bool *) palloc( (( len==1 ) ? 2 : len ) * sizeof(bool)); - evec = (bytea *) palloc( (( len==1 ) ? 2 : len ) * sizeof(GISTENTRY) + VARHDRSZ); - for (j = 1; j < r->rd_att->natts; j++) { + needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool)); + evec = (bytea *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + VARHDRSZ); + for (j = 1; j < r->rd_att->natts; j++) + { reallen = 0; - for (i = 0; i < len; i++) { - if ( spl->spl_idgrp[ entries[i] ] ) + for (i = 0; i < len; i++) + { + if (spl->spl_idgrp[entries[i]]) continue; - datum = index_getattr(itvec[ entries[i]-1 ], j+1, + datum = index_getattr(itvec[entries[i] - 1], j + 1, giststate->tupdesc, &IsNull); - if ( IsNull ) + if (IsNull) continue; gistdentryinit(giststate, j, &((GISTENTRY *) VARDATA(evec))[reallen], datum, (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, - ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull); - if ( (!isAttByVal( giststate, j )) && - ((GISTENTRY *) VARDATA(evec))[reallen].key != datum ) + ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull); + if ((!isAttByVal(giststate, j)) && + ((GISTENTRY *) VARDATA(evec))[reallen].key != datum) needfree[reallen] = TRUE; else needfree[reallen] = FALSE; reallen++; - - } - if ( reallen == 0 ) + + } + if (reallen == 0) { datum = (Datum) 0; datumsize = 0; isnull[j] = true; - } else { + } + else + { /* - * ((GISTENTRY *) VARDATA(evec))[0].bytes may be not defined, - * so form union with itself + * ((GISTENTRY *) VARDATA(evec))[0].bytes may be not + * defined, so form union with itself */ - if ( reallen == 1 ) { + if (reallen == 1) + { VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ; - memcpy( (void*) &((GISTENTRY *) VARDATA(evec))[1], - (void*) &((GISTENTRY *) VARDATA(evec))[0], - sizeof( GISTENTRY ) ); - } else + memcpy((void *) &((GISTENTRY *) VARDATA(evec))[1], + (void *) &((GISTENTRY *) VARDATA(evec))[0], + sizeof(GISTENTRY)); + } + else VARATT_SIZEP(evec) = reallen * sizeof(GISTENTRY) + VARHDRSZ; datum = FunctionCall2(&giststate->unionFn[j], - PointerGetDatum(evec), - PointerGetDatum(&datumsize)); + PointerGetDatum(evec), + PointerGetDatum(&datumsize)); isnull[j] = false; - } + } for (i = 0; i < reallen; i++) - if ( needfree[i] ) + if (needfree[i]) pfree(DatumGetPointer(((GISTENTRY *) VARDATA(evec))[i].key)); - + attr[j] = datum; attrsize[j] = datumsize; } @@ -910,51 +964,63 @@ gistunionsubkey( Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLIT } /* - * find group in vector with equial value + * find group in vector with equial value */ static int -gistfindgroup( GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC * spl ) { - int i,j,len; - int curid = 1; - bool result; - - /* - * first key is always not null (see gistinsert), - * so we may not check for nulls - */ - - for(i=0; i<spl->spl_nleft; i++) { - if ( spl->spl_idgrp[ spl->spl_left[i] ]) continue; +gistfindgroup(GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC *spl) +{ + int i, + j, + len; + int curid = 1; + bool result; + + /* + * first key is always not null (see gistinsert), so we may not check + * for nulls + */ + + for (i = 0; i < spl->spl_nleft; i++) + { + if (spl->spl_idgrp[spl->spl_left[i]]) + continue; len = 0; /* find all equal value in right part */ - for(j=0; j < spl->spl_nright; j++) { - if ( spl->spl_idgrp[ spl->spl_right[j] ]) continue; + for (j = 0; j < spl->spl_nright; j++) + { + if (spl->spl_idgrp[spl->spl_right[j]]) + continue; FunctionCall3(&giststate->equalFn[0], - valvec[ spl->spl_left[i] ].key, - valvec[ spl->spl_right[j] ].key, + valvec[spl->spl_left[i]].key, + valvec[spl->spl_right[j]].key, PointerGetDatum(&result)); - if ( result ) { - spl->spl_idgrp[ spl->spl_right[j] ] = curid; + if (result) + { + spl->spl_idgrp[spl->spl_right[j]] = curid; len++; } } /* find all other equal value in left part */ - if ( len ) { - /* add current val to list of equial values*/ - spl->spl_idgrp[ spl->spl_left[i] ]=curid; + if (len) + { + /* add current val to list of equial values */ + spl->spl_idgrp[spl->spl_left[i]] = curid; /* searching .. */ - for(j=i+1; j < spl->spl_nleft; j++) { - if ( spl->spl_idgrp[ spl->spl_left[j] ]) continue; + for (j = i + 1; j < spl->spl_nleft; j++) + { + if (spl->spl_idgrp[spl->spl_left[j]]) + continue; FunctionCall3(&giststate->equalFn[0], - valvec[ spl->spl_left[i] ].key, - valvec[ spl->spl_left[j] ].key, + valvec[spl->spl_left[i]].key, + valvec[spl->spl_left[j]].key, PointerGetDatum(&result)); - if ( result ) { - spl->spl_idgrp[ spl->spl_left[j] ] = curid; + if (result) + { + spl->spl_idgrp[spl->spl_left[j]] = curid; len++; } } - spl->spl_ngrp[curid] = len+1; + spl->spl_ngrp[curid] = len + 1; curid++; } } @@ -968,40 +1034,50 @@ gistfindgroup( GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC * spl ) { */ static void gistadjsubkey(Relation r, - IndexTuple *itup, /* contains compressed entry */ - int *len, - GIST_SPLITVEC *v, - GISTSTATE *giststate - ) { - int curlen; - OffsetNumber *curwpos; - bool decfree[INDEX_MAX_KEYS]; - GISTENTRY entry,identry[INDEX_MAX_KEYS], *ev0p, *ev1p; - float lpenalty, rpenalty; - bytea *evec; - int datumsize; - bool isnull[INDEX_MAX_KEYS]; - int i,j; + IndexTuple *itup, /* contains compressed entry */ + int *len, + GIST_SPLITVEC *v, + GISTSTATE *giststate +) +{ + int curlen; + OffsetNumber *curwpos; + bool decfree[INDEX_MAX_KEYS]; + GISTENTRY entry, + identry[INDEX_MAX_KEYS], + *ev0p, + *ev1p; + float lpenalty, + rpenalty; + bytea *evec; + int datumsize; + bool isnull[INDEX_MAX_KEYS]; + int i, + j; Datum datum; /* clear vectors */ curlen = v->spl_nleft; curwpos = v->spl_left; - for( i=0; i<v->spl_nleft;i++ ) - if ( v->spl_idgrp[ v->spl_left[i] ] == 0 ) { + for (i = 0; i < v->spl_nleft; i++) + if (v->spl_idgrp[v->spl_left[i]] == 0) + { *curwpos = v->spl_left[i]; curwpos++; - } else + } + else curlen--; v->spl_nleft = curlen; curlen = v->spl_nright; curwpos = v->spl_right; - for( i=0; i<v->spl_nright;i++ ) - if ( v->spl_idgrp[ v->spl_right[i] ] == 0 ) { + for (i = 0; i < v->spl_nright; i++) + if (v->spl_idgrp[v->spl_right[i]] == 0) + { *curwpos = v->spl_right[i]; curwpos++; - } else + } + else curlen--; v->spl_nright = curlen; @@ -1011,82 +1087,98 @@ gistadjsubkey(Relation r, ev1p = &((GISTENTRY *) VARDATA(evec))[1]; /* add equivalent tuple */ - for(i = 0; i< *len; i++) { - if ( v->spl_idgrp[ i+1 ]==0 ) /* already inserted */ + for (i = 0; i < *len; i++) + { + if (v->spl_idgrp[i + 1] == 0) /* already inserted */ continue; - gistDeCompressAtt( giststate, r, itup[i], (Page) NULL, (OffsetNumber) 0, - identry, decfree, isnull); + gistDeCompressAtt(giststate, r, itup[i], (Page) NULL, (OffsetNumber) 0, + identry, decfree, isnull); - v->spl_ngrp[ v->spl_idgrp[ i+1 ] ]--; - if ( v->spl_ngrp[ v->spl_idgrp[ i+1 ] ] == 0 && - (v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] & BOTH_ADDED) != BOTH_ADDED ) { + v->spl_ngrp[v->spl_idgrp[i + 1]]--; + if (v->spl_ngrp[v->spl_idgrp[i + 1]] == 0 && + (v->spl_grpflag[v->spl_idgrp[i + 1]] & BOTH_ADDED) != BOTH_ADDED) + { /* force last in group */ rpenalty = 1.0; - lpenalty = ( v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] & LEFT_ADDED ) ? 2.0 : 0.0; - } else { - /*where?*/ - for( j=1; j<r->rd_att->natts; j++ ) { - gistentryinit(entry,v->spl_lattr[j], r, (Page) NULL, - (OffsetNumber) 0, v->spl_lattrsize[j], FALSE); - gistpenalty( giststate, j, &entry, v->spl_lisnull[j], - &identry[j], isnull[j], &lpenalty); - - gistentryinit(entry,v->spl_rattr[j], r, (Page) NULL, - (OffsetNumber) 0, v->spl_rattrsize[j], FALSE); - gistpenalty( giststate, j, &entry, v->spl_risnull[j], - &identry[j], isnull[j], &rpenalty); - - if ( lpenalty != rpenalty ) + lpenalty = (v->spl_grpflag[v->spl_idgrp[i + 1]] & LEFT_ADDED) ? 2.0 : 0.0; + } + else + { + /* where? */ + for (j = 1; j < r->rd_att->natts; j++) + { + gistentryinit(entry, v->spl_lattr[j], r, (Page) NULL, + (OffsetNumber) 0, v->spl_lattrsize[j], FALSE); + gistpenalty(giststate, j, &entry, v->spl_lisnull[j], + &identry[j], isnull[j], &lpenalty); + + gistentryinit(entry, v->spl_rattr[j], r, (Page) NULL, + (OffsetNumber) 0, v->spl_rattrsize[j], FALSE); + gistpenalty(giststate, j, &entry, v->spl_risnull[j], + &identry[j], isnull[j], &rpenalty); + + if (lpenalty != rpenalty) break; } } /* add */ - if ( lpenalty < rpenalty ) { - v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] |= LEFT_ADDED; - v->spl_left[ v->spl_nleft ] = i+1; + if (lpenalty < rpenalty) + { + v->spl_grpflag[v->spl_idgrp[i + 1]] |= LEFT_ADDED; + v->spl_left[v->spl_nleft] = i + 1; v->spl_nleft++; - for( j=1; j<r->rd_att->natts; j++ ) { - if ( isnull[j] && v->spl_lisnull[j] ) { + for (j = 1; j < r->rd_att->natts; j++) + { + if (isnull[j] && v->spl_lisnull[j]) + { v->spl_lattr[j] = (Datum) 0; v->spl_lattrsize[j] = 0; - } else { + } + else + { FILLEV( - v->spl_lisnull[j], v->spl_lattr[j], v->spl_lattrsize[j], - isnull[j], identry[j].key, identry[j].bytes - ); + v->spl_lisnull[j], v->spl_lattr[j], v->spl_lattrsize[j], + isnull[j], identry[j].key, identry[j].bytes + ); datum = FunctionCall2(&giststate->unionFn[j], - PointerGetDatum(evec), - PointerGetDatum(&datumsize)); + PointerGetDatum(evec), + PointerGetDatum(&datumsize)); - if ( (!isAttByVal( giststate, j )) && !v->spl_lisnull[j] ) - pfree( DatumGetPointer(v->spl_lattr[j]) ); + if ((!isAttByVal(giststate, j)) && !v->spl_lisnull[j]) + pfree(DatumGetPointer(v->spl_lattr[j])); v->spl_lattr[j] = datum; v->spl_lattrsize[j] = datumsize; v->spl_lisnull[j] = false; } } - } else { - v->spl_grpflag[ v->spl_idgrp[ i+1 ] ] |= RIGHT_ADDED; - v->spl_right[ v->spl_nright ] = i+1; + } + else + { + v->spl_grpflag[v->spl_idgrp[i + 1]] |= RIGHT_ADDED; + v->spl_right[v->spl_nright] = i + 1; v->spl_nright++; - for( j=1; j<r->rd_att->natts; j++ ) { - if ( isnull[j] && v->spl_risnull[j] ) { + for (j = 1; j < r->rd_att->natts; j++) + { + if (isnull[j] && v->spl_risnull[j]) + { v->spl_rattr[j] = (Datum) 0; v->spl_rattrsize[j] = 0; - } else { + } + else + { FILLEV( - v->spl_risnull[j], v->spl_rattr[j], v->spl_rattrsize[j], - isnull[j], identry[j].key, identry[j].bytes - ); + v->spl_risnull[j], v->spl_rattr[j], v->spl_rattrsize[j], + isnull[j], identry[j].key, identry[j].bytes + ); datum = FunctionCall2(&giststate->unionFn[j], - PointerGetDatum(evec), - PointerGetDatum(&datumsize)); + PointerGetDatum(evec), + PointerGetDatum(&datumsize)); - if ( (!isAttByVal( giststate, j)) && !v->spl_risnull[j] ) - pfree( DatumGetPointer(v->spl_rattr[j]) ); + if ((!isAttByVal(giststate, j)) && !v->spl_risnull[j]) + pfree(DatumGetPointer(v->spl_rattr[j])); v->spl_rattr[j] = datum; v->spl_rattrsize[j] = datumsize; @@ -1094,8 +1186,8 @@ gistadjsubkey(Relation r, } } - } - gistFreeAtt( r, identry, decfree ); + } + gistFreeAtt(r, identry, decfree); } pfree(evec); } @@ -1125,11 +1217,12 @@ gistSplit(Relation r, GIST_SPLITVEC v; bytea *entryvec; bool *decompvec; - int i,j, + int i, + j, nlen; - int MaxGrpId = 1; + int MaxGrpId = 1; Datum datum; - bool IsNull; + bool IsNull; p = (Page) BufferGetPage(buffer); opaque = (GISTPageOpaque) PageGetSpecialPointer(p); @@ -1168,57 +1261,62 @@ gistSplit(Relation r, for (i = 1; i <= *len; i++) { datum = index_getattr(itup[i - 1], 1, giststate->tupdesc, &IsNull); - gistdentryinit(giststate, 0,&((GISTENTRY *) VARDATA(entryvec))[i], - datum, r, p, i, - ATTSIZE( datum, giststate->tupdesc, 1, IsNull ), FALSE, IsNull); - if ( (!isAttByVal(giststate,0)) && ((GISTENTRY *) VARDATA(entryvec))[i].key != datum ) + gistdentryinit(giststate, 0, &((GISTENTRY *) VARDATA(entryvec))[i], + datum, r, p, i, + ATTSIZE(datum, giststate->tupdesc, 1, IsNull), FALSE, IsNull); + if ((!isAttByVal(giststate, 0)) && ((GISTENTRY *) VARDATA(entryvec))[i].key != datum) decompvec[i] = TRUE; else decompvec[i] = FALSE; } - /* now let the user-defined picksplit function set up the split vector; - in entryvec have no null value!! */ + /* + * now let the user-defined picksplit function set up the split + * vector; in entryvec have no null value!! + */ FunctionCall2(&giststate->picksplitFn[0], PointerGetDatum(entryvec), PointerGetDatum(&v)); - /* compatibility with old code */ - if ( v.spl_left[ v.spl_nleft-1 ] == InvalidOffsetNumber ) - v.spl_left[ v.spl_nleft-1 ] = (OffsetNumber)*len; - if ( v.spl_right[ v.spl_nright-1 ] == InvalidOffsetNumber ) - v.spl_right[ v.spl_nright-1 ] = (OffsetNumber)*len; - - v.spl_lattr[0] = v.spl_ldatum; + /* compatibility with old code */ + if (v.spl_left[v.spl_nleft - 1] == InvalidOffsetNumber) + v.spl_left[v.spl_nleft - 1] = (OffsetNumber) *len; + if (v.spl_right[v.spl_nright - 1] == InvalidOffsetNumber) + v.spl_right[v.spl_nright - 1] = (OffsetNumber) *len; + + v.spl_lattr[0] = v.spl_ldatum; v.spl_rattr[0] = v.spl_rdatum; v.spl_lisnull[0] = false; v.spl_risnull[0] = false; - /* if index is multikey, then we must to try get smaller - * bounding box for subkey(s) - */ - if ( r->rd_att->natts > 1 ) { - v.spl_idgrp = (int*) palloc( sizeof(int) * (*len + 1) ); - MemSet((void*)v.spl_idgrp, 0, sizeof(int) * (*len + 1) ); - v.spl_grpflag = (char*) palloc( sizeof(char) * (*len + 1) ); - MemSet((void*)v.spl_grpflag, 0, sizeof(char) * (*len + 1) ); - v.spl_ngrp = (int*) palloc( sizeof(int) * (*len + 1) ); + /* + * if index is multikey, then we must to try get smaller bounding box + * for subkey(s) + */ + if (r->rd_att->natts > 1) + { + v.spl_idgrp = (int *) palloc(sizeof(int) * (*len + 1)); + MemSet((void *) v.spl_idgrp, 0, sizeof(int) * (*len + 1)); + v.spl_grpflag = (char *) palloc(sizeof(char) * (*len + 1)); + MemSet((void *) v.spl_grpflag, 0, sizeof(char) * (*len + 1)); + v.spl_ngrp = (int *) palloc(sizeof(int) * (*len + 1)); - MaxGrpId = gistfindgroup( giststate, (GISTENTRY *) VARDATA(entryvec), &v ); + MaxGrpId = gistfindgroup(giststate, (GISTENTRY *) VARDATA(entryvec), &v); /* form union of sub keys for each page (l,p) */ - gistunionsubkey( r, giststate, itup, &v ); + gistunionsubkey(r, giststate, itup, &v); - /* if possible, we insert equivalent tuples - * with control by penalty for a subkey(s) - */ - if ( MaxGrpId > 1 ) - gistadjsubkey( r,itup,len, &v, giststate ); + /* + * if possible, we insert equivalent tuples with control by + * penalty for a subkey(s) + */ + if (MaxGrpId > 1) + gistadjsubkey(r, itup, len, &v, giststate); - pfree( v.spl_idgrp ); - pfree( v.spl_grpflag ); - pfree( v.spl_ngrp ); - } + pfree(v.spl_idgrp); + pfree(v.spl_grpflag); + pfree(v.spl_ngrp); + } /* clean up the entry vector: its keys need to be deleted, too */ for (i = 1; i <= *len; i++) @@ -1231,11 +1329,11 @@ gistSplit(Relation r, lvectup = (IndexTuple *) palloc(sizeof(IndexTuple) * v.spl_nleft); rvectup = (IndexTuple *) palloc(sizeof(IndexTuple) * v.spl_nright); - for(i=0; i<v.spl_nleft;i++) - lvectup[i] = itup[ v.spl_left[i] - 1 ]; + for (i = 0; i < v.spl_nleft; i++) + lvectup[i] = itup[v.spl_left[i] - 1]; - for(i=0; i<v.spl_nright;i++) - rvectup[i] = itup[ v.spl_right[i] - 1 ]; + for (i = 0; i < v.spl_nright; i++) + rvectup[i] = itup[v.spl_right[i] - 1]; /* write on disk (may be need another split) */ @@ -1245,9 +1343,9 @@ gistSplit(Relation r, newtup = gistSplit(r, rightbuf, rvectup, &nlen, giststate, (res && rvectup[nlen - 1] == itup[*len - 1]) ? res : NULL); ReleaseBuffer(rightbuf); - for( j=1; j<r->rd_att->natts; j++ ) - if ( (!isAttByVal(giststate,j)) && !v.spl_risnull[j] ) - pfree( DatumGetPointer(v.spl_rattr[j]) ); + for (j = 1; j < r->rd_att->natts; j++) + if ((!isAttByVal(giststate, j)) && !v.spl_risnull[j]) + pfree(DatumGetPointer(v.spl_rattr[j])); } else { @@ -1261,7 +1359,7 @@ gistSplit(Relation r, nlen = 1; newtup = (IndexTuple *) palloc(sizeof(IndexTuple) * 1); - newtup[0] = gistFormTuple( giststate, r, v.spl_rattr, v.spl_rattrsize, v.spl_risnull ); + newtup[0] = gistFormTuple(giststate, r, v.spl_rattr, v.spl_rattrsize, v.spl_risnull); ItemPointerSet(&(newtup[0]->t_tid), rbknum, 1); } @@ -1275,9 +1373,9 @@ gistSplit(Relation r, (res && lvectup[llen - 1] == itup[*len - 1]) ? res : NULL); ReleaseBuffer(leftbuf); - for( j=1; j<r->rd_att->natts; j++ ) - if ( (!isAttByVal(giststate,j)) && !v.spl_lisnull[j] ) - pfree( DatumGetPointer(v.spl_lattr[j]) ); + for (j = 1; j < r->rd_att->natts; j++) + if ((!isAttByVal(giststate, j)) && !v.spl_lisnull[j]) + pfree(DatumGetPointer(v.spl_lattr[j])); newtup = gistjoinvector(newtup, &nlen, lntup, llen); pfree(lntup); @@ -1297,7 +1395,7 @@ gistSplit(Relation r, nlen += 1; newtup = (IndexTuple *) repalloc((void *) newtup, sizeof(IndexTuple) * nlen); - newtup[nlen - 1] = gistFormTuple( giststate, r, v.spl_lattr, v.spl_lattrsize, v.spl_lisnull ); + newtup[nlen - 1] = gistFormTuple(giststate, r, v.spl_lattr, v.spl_lattrsize, v.spl_lisnull); ItemPointerSet(&(newtup[nlen - 1]->t_tid), lbknum, 1); } @@ -1359,47 +1457,56 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */ Datum datum; float usize; OffsetNumber which; - float sum_grow, which_grow[INDEX_MAX_KEYS]; + float sum_grow, + which_grow[INDEX_MAX_KEYS]; GISTENTRY entry, identry[INDEX_MAX_KEYS]; - bool IsNull, decompvec[INDEX_MAX_KEYS], isnull[INDEX_MAX_KEYS]; - int j; + bool IsNull, + decompvec[INDEX_MAX_KEYS], + isnull[INDEX_MAX_KEYS]; + int j; maxoff = PageGetMaxOffsetNumber(p); *which_grow = -1.0; which = -1; - sum_grow=1; - gistDeCompressAtt( giststate, r, - it, (Page) NULL, (OffsetNumber) 0, - identry, decompvec, isnull ); + sum_grow = 1; + gistDeCompressAtt(giststate, r, + it, (Page) NULL, (OffsetNumber) 0, + identry, decompvec, isnull); for (i = FirstOffsetNumber; i <= maxoff && sum_grow; i = OffsetNumberNext(i)) { - IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i)); - sum_grow=0; - for (j=0; j<r->rd_att->natts; j++) { - datum = index_getattr(itup, j+1, giststate->tupdesc, &IsNull); - gistdentryinit(giststate, j, &entry, datum, r, p, i, ATTSIZE( datum, giststate->tupdesc, j+1, IsNull ), FALSE, IsNull); - gistpenalty( giststate, j, &entry, IsNull, &identry[j], isnull[j], &usize); - - if ( (!isAttByVal(giststate,j)) && entry.key != datum) + IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i)); + + sum_grow = 0; + for (j = 0; j < r->rd_att->natts; j++) + { + datum = index_getattr(itup, j + 1, giststate->tupdesc, &IsNull); + gistdentryinit(giststate, j, &entry, datum, r, p, i, ATTSIZE(datum, giststate->tupdesc, j + 1, IsNull), FALSE, IsNull); + gistpenalty(giststate, j, &entry, IsNull, &identry[j], isnull[j], &usize); + + if ((!isAttByVal(giststate, j)) && entry.key != datum) pfree(DatumGetPointer(entry.key)); - if ( which_grow[j]<0 || usize < which_grow[j] ) { + if (which_grow[j] < 0 || usize < which_grow[j]) + { which = i; which_grow[j] = usize; - if ( j<r->rd_att->natts-1 && i==FirstOffsetNumber ) which_grow[j+1]=-1; - sum_grow += which_grow[j]; - } else if ( which_grow[j] == usize ) { + if (j < r->rd_att->natts - 1 && i == FirstOffsetNumber) + which_grow[j + 1] = -1; + sum_grow += which_grow[j]; + } + else if (which_grow[j] == usize) sum_grow += usize; - } else { - sum_grow=1; + else + { + sum_grow = 1; break; } } } - gistFreeAtt( r, identry, decompvec ); + gistFreeAtt(r, identry, decompvec); return which; } @@ -1434,7 +1541,7 @@ gistdelete(Relation r, ItemPointer tid) /* * Since GIST is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking + * have acquired exclusive lock on index relation. We need no locking * here. */ @@ -1468,7 +1575,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1); void *callback_state = (void *) PG_GETARG_POINTER(2); IndexBulkDeleteResult *result; - BlockNumber num_pages; + BlockNumber num_pages; double tuples_removed; double num_index_tuples; RetrieveIndexResult res; @@ -1479,7 +1586,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) /* * Since GIST is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking + * have acquired exclusive lock on index relation. We need no locking * here. */ @@ -1542,7 +1649,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) void initGISTstate(GISTSTATE *giststate, Relation index) { - int i; + int i; if (index->rd_att->natts > INDEX_MAX_KEYS) elog(ERROR, "initGISTstate: numberOfAttributes %d > %d", @@ -1553,31 +1660,32 @@ initGISTstate(GISTSTATE *giststate, Relation index) for (i = 0; i < index->rd_att->natts; i++) { fmgr_info_copy(&(giststate->consistentFn[i]), - index_getprocinfo(index, i+1, GIST_CONSISTENT_PROC), + index_getprocinfo(index, i + 1, GIST_CONSISTENT_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->unionFn[i]), - index_getprocinfo(index, i+1, GIST_UNION_PROC), + index_getprocinfo(index, i + 1, GIST_UNION_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->compressFn[i]), - index_getprocinfo(index, i+1, GIST_COMPRESS_PROC), + index_getprocinfo(index, i + 1, GIST_COMPRESS_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->decompressFn[i]), - index_getprocinfo(index, i+1, GIST_DECOMPRESS_PROC), + index_getprocinfo(index, i + 1, GIST_DECOMPRESS_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->penaltyFn[i]), - index_getprocinfo(index, i+1, GIST_PENALTY_PROC), + index_getprocinfo(index, i + 1, GIST_PENALTY_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->picksplitFn[i]), - index_getprocinfo(index, i+1, GIST_PICKSPLIT_PROC), + index_getprocinfo(index, i + 1, GIST_PICKSPLIT_PROC), CurrentMemoryContext); fmgr_info_copy(&(giststate->equalFn[i]), - index_getprocinfo(index, i+1, GIST_EQUAL_PROC), + index_getprocinfo(index, i + 1, GIST_EQUAL_PROC), CurrentMemoryContext); } } void -freeGISTstate(GISTSTATE *giststate) { +freeGISTstate(GISTSTATE *giststate) +{ /* no work */ } @@ -1592,13 +1700,14 @@ freeGISTstate(GISTSTATE *giststate) { static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t) { - bool IsNull; - Datum datum = index_getattr(t, 1, r->rd_att, &IsNull); + bool IsNull; + Datum datum = index_getattr(t, 1, r->rd_att, &IsNull); /* * If new entry fits in index tuple, copy it in. To avoid worrying - * about null-value bitmask, pass it off to the general index_formtuple - * routine if either the previous or new value is NULL. + * about null-value bitmask, pass it off to the general + * index_formtuple routine if either the previous or new value is + * NULL. */ if (!IsNull && DatumGetPointer(entry.key) != NULL && (Size) entry.bytes <= ATTSIZE(datum, r, 1, IsNull)) @@ -1638,7 +1747,7 @@ gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, int b, bool l, bool isNull) { - if ( b && ! isNull ) + if (b && !isNull) { GISTENTRY *dep; @@ -1655,9 +1764,7 @@ gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, } } else - { gistentryinit(*e, (Datum) 0, r, pg, o, 0, l); - } } @@ -1686,92 +1793,103 @@ gistcentryinit(GISTSTATE *giststate, int nkey, } } else - { gistentryinit(*e, (Datum) 0, r, pg, o, 0, l); - } } static IndexTuple -gistFormTuple( GISTSTATE *giststate, Relation r, - Datum attdata[], int datumsize[], bool isnull[] ) +gistFormTuple(GISTSTATE *giststate, Relation r, + Datum attdata[], int datumsize[], bool isnull[]) { IndexTuple tup; - char isnullchar[INDEX_MAX_KEYS]; - bool whatfree[INDEX_MAX_KEYS]; - GISTENTRY centry[INDEX_MAX_KEYS]; - Datum compatt[INDEX_MAX_KEYS]; - int j; - - for (j = 0; j < r->rd_att->natts; j++) { - if ( isnull[j] ) { + char isnullchar[INDEX_MAX_KEYS]; + bool whatfree[INDEX_MAX_KEYS]; + GISTENTRY centry[INDEX_MAX_KEYS]; + Datum compatt[INDEX_MAX_KEYS]; + int j; + + for (j = 0; j < r->rd_att->natts; j++) + { + if (isnull[j]) + { isnullchar[j] = 'n'; compatt[j] = (Datum) 0; whatfree[j] = FALSE; - } else { + } + else + { gistcentryinit(giststate, j, ¢ry[j], attdata[j], - (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, - datumsize[j], FALSE, FALSE); + (Relation) NULL, (Page) NULL, (OffsetNumber) NULL, + datumsize[j], FALSE, FALSE); isnullchar[j] = ' '; compatt[j] = centry[j].key; - if ( !isAttByVal(giststate,j) ) { + if (!isAttByVal(giststate, j)) + { whatfree[j] = TRUE; - if ( centry[j].key != attdata[j] ) + if (centry[j].key != attdata[j]) pfree(DatumGetPointer(attdata[j])); - } else + } + else whatfree[j] = FALSE; } } tup = (IndexTuple) index_formtuple(giststate->tupdesc, compatt, isnullchar); for (j = 0; j < r->rd_att->natts; j++) - if ( whatfree[j] ) pfree(DatumGetPointer(compatt[j])); + if (whatfree[j]) + pfree(DatumGetPointer(compatt[j])); - return tup; -} + return tup; +} static void -gistDeCompressAtt( GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, - OffsetNumber o, GISTENTRY attdata[], bool decompvec[], bool isnull[] ) { - int i; - Datum datum; +gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, + OffsetNumber o, GISTENTRY attdata[], bool decompvec[], bool isnull[]) +{ + int i; + Datum datum; - for(i=0; i < r->rd_att->natts; i++ ) { - datum = index_getattr(tuple, i+1, giststate->tupdesc, &isnull[i]); + for (i = 0; i < r->rd_att->natts; i++) + { + datum = index_getattr(tuple, i + 1, giststate->tupdesc, &isnull[i]); gistdentryinit(giststate, i, &attdata[i], - datum, r, p, o, - ATTSIZE( datum, giststate->tupdesc, i+1, isnull[i] ), FALSE, isnull[i]); - if ( isAttByVal(giststate,i) ) + datum, r, p, o, + ATTSIZE(datum, giststate->tupdesc, i + 1, isnull[i]), FALSE, isnull[i]); + if (isAttByVal(giststate, i)) decompvec[i] = FALSE; - else { - if (attdata[i].key == datum || isnull[i] ) + else + { + if (attdata[i].key == datum || isnull[i]) decompvec[i] = FALSE; else decompvec[i] = TRUE; } } -} +} static void -gistFreeAtt( Relation r, GISTENTRY attdata[], bool decompvec[] ) { - int i; - for(i=0; i < r->rd_att->natts; i++ ) - if ( decompvec[i] ) - pfree( DatumGetPointer(attdata[i].key) ); +gistFreeAtt(Relation r, GISTENTRY attdata[], bool decompvec[]) +{ + int i; + + for (i = 0; i < r->rd_att->natts; i++) + if (decompvec[i]) + pfree(DatumGetPointer(attdata[i].key)); } static void -gistpenalty( GISTSTATE *giststate, int attno, - GISTENTRY *key1, bool isNull1, - GISTENTRY *key2, bool isNull2, float *penalty ){ - if ( giststate->penaltyFn[attno].fn_strict && ( isNull1 || isNull2 ) ) - *penalty=0.0; - else +gistpenalty(GISTSTATE *giststate, int attno, + GISTENTRY *key1, bool isNull1, + GISTENTRY *key2, bool isNull2, float *penalty) +{ + if (giststate->penaltyFn[attno].fn_strict && (isNull1 || isNull2)) + *penalty = 0.0; + else FunctionCall3(&giststate->penaltyFn[attno], - PointerGetDatum(key1), - PointerGetDatum(key2), - PointerGetDatum(penalty)); + PointerGetDatum(key1), + PointerGetDatum(key2), + PointerGetDatum(penalty)); } - + #ifdef GISTDEBUG static void gist_dumptree(Relation r, int level, BlockNumber blk, OffsetNumber coff) @@ -1816,7 +1934,6 @@ gist_dumptree(Relation r, int level, BlockNumber blk, OffsetNumber coff) ReleaseBuffer(buffer); pfree(pred); } - #endif /* defined GISTDEBUG */ void diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index be2d749845..ed92258e62 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.30 2001/08/22 18:24:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.31 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -251,7 +251,7 @@ gistindex_keytest(IndexTuple tuple, if (key[0].sk_flags & SK_ISNULL) return false; */ - gistdentryinit(giststate, key[0].sk_attno-1, &de, + gistdentryinit(giststate, key[0].sk_attno - 1, &de, datum, r, p, offset, IndexTupleSize(tuple) - sizeof(IndexTupleData), FALSE, isNull); @@ -271,9 +271,9 @@ gistindex_keytest(IndexTuple tuple, ObjectIdGetDatum(key[0].sk_procedure)); } - if ( de.key != datum && ! isAttByVal( giststate, key[0].sk_attno-1 ) ) - if ( DatumGetPointer(de.key) != NULL ) - pfree( DatumGetPointer(de.key) ); + if (de.key != datum && !isAttByVal(giststate, key[0].sk_attno - 1)) + if (DatumGetPointer(de.key) != NULL) + pfree(DatumGetPointer(de.key)); if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE)) return false; diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 2b65321b03..8623b8f643 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.39 2001/08/22 18:24:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.40 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -112,7 +112,7 @@ gistrescan(PG_FUNCTION_ARGS) s->keyData[i].sk_procedure = RelationGetGISTStrategy(s->relation, s->keyData[i].sk_attno, s->keyData[i].sk_procedure); - s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno-1]; + s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno - 1]; } } else @@ -137,13 +137,13 @@ gistrescan(PG_FUNCTION_ARGS) /*---------- * s->keyData[i].sk_procedure = - * index_getprocid(s->relation, 1, GIST_CONSISTENT_PROC); + * index_getprocid(s->relation, 1, GIST_CONSISTENT_PROC); *---------- */ s->keyData[i].sk_procedure = RelationGetGISTStrategy(s->relation, s->keyData[i].sk_attno, s->keyData[i].sk_procedure); - s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno-1]; + s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno - 1]; } } @@ -234,8 +234,8 @@ gistendscan(PG_FUNCTION_ARGS) { gistfreestack(p->s_stack); gistfreestack(p->s_markstk); - if ( p->giststate != NULL ) - freeGISTstate( p->giststate ); + if (p->giststate != NULL) + freeGISTstate(p->giststate); pfree(s->opaque); } @@ -383,7 +383,6 @@ adjustiptr(IndexScanDesc s, } else { - /* * remember that we're before the current * tuple diff --git a/src/backend/access/gist/giststrat.c b/src/backend/access/gist/giststrat.c index e0bae48a3c..db38191d6a 100644 --- a/src/backend/access/gist/giststrat.c +++ b/src/backend/access/gist/giststrat.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/Attic/giststrat.c,v 1.17 2001/05/30 19:53:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/Attic/giststrat.c,v 1.18 2001/10/25 05:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,5 +121,4 @@ RelationInvokeGISTStrategy(Relation r, return (RelationInvokeStrategy(r, &GISTEvaluationData, attnum, s, left, right)); } - #endif diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 9b0e6cf28e..177f3648f4 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.52 2001/07/15 22:48:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.53 2001/10/25 05:49:20 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -37,11 +37,11 @@ typedef struct } HashBuildState; static void hashbuildCallback(Relation index, - HeapTuple htup, - Datum *attdata, - char *nulls, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *attdata, + char *nulls, + bool tupleIsAlive, + void *state); /* @@ -80,7 +80,7 @@ hashbuild(PG_FUNCTION_ARGS) /* do the heap scan */ reltuples = IndexBuildHeapScan(heap, index, indexInfo, - hashbuildCallback, (void *) &buildstate); + hashbuildCallback, (void *) &buildstate); /* all done */ BuildingHash = false; @@ -121,7 +121,7 @@ hashbuildCallback(Relation index, bool tupleIsAlive, void *state) { - HashBuildState *buildstate = (HashBuildState *) state; + HashBuildState *buildstate = (HashBuildState *) state; IndexTuple itup; HashItem hitem; InsertIndexResult res; @@ -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); #endif @@ -176,14 +177,13 @@ hashinsert(PG_FUNCTION_ARGS) itup->t_tid = *ht_ctid; /* - * If the single index key is null, we don't insert it into the - * index. Hash tables support scans on '='. Relational algebra - * says that A = B returns null if either A or B is null. This - * means that no qualification used in an index scan could ever - * return true on a null attribute. It also means that indices - * can't be used by ISNULL or NOTNULL scans, but that's an - * artifact of the strategy map architecture chosen in 1986, not - * of the way nulls are handled here. + * If the single index key is null, we don't insert it into the index. + * Hash tables support scans on '='. Relational algebra says that A = + * B returns null if either A or B is null. This means that no + * qualification used in an index scan could ever return true on a + * null attribute. It also means that indices can't be used by ISNULL + * or NOTNULL scans, but that's an artifact of the strategy map + * architecture chosen in 1986, not of the way nulls are handled here. */ if (IndexTupleHasNulls(itup)) { @@ -262,7 +262,6 @@ hashrescan(PG_FUNCTION_ARGS) #ifdef NOT_USED /* XXX surely it's wrong to ignore this? */ bool fromEnd = PG_GETARG_BOOL(1); - #endif ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2); ItemPointer iptr; @@ -412,7 +411,7 @@ hashbulkdelete(PG_FUNCTION_ARGS) IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1); void *callback_state = (void *) PG_GETARG_POINTER(2); IndexBulkDeleteResult *result; - BlockNumber num_pages; + BlockNumber num_pages; double tuples_removed; double num_index_tuples; RetrieveIndexResult res; diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index 5439dce214..2f99e7426d 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.22 2001/03/07 21:20:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.23 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,13 +133,11 @@ _hash_insertonpg(Relation rel, while (PageGetFreeSpace(page) < itemsz) { - /* * no space on this page; check for an overflow page */ if (BlockNumberIsValid(pageopaque->hasho_nextblkno)) { - /* * ovfl page exists; go get it. if it doesn't have room, * we'll find out next pass through the loop test above. @@ -152,7 +150,6 @@ _hash_insertonpg(Relation rel, } else { - /* * we're at the end of the bucket chain and we haven't found a * page with enough room. allocate a new overflow page. @@ -184,7 +181,6 @@ _hash_insertonpg(Relation rel, if (res != NULL) { - /* * Increment the number of keys in the table. We switch lock * access type just for a moment to allow greater accessibility to diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index c9fb065dbd..e41c1bd0a3 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.30 2001/07/15 22:48:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.31 2001/10/25 05:49:21 momjian Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -208,7 +208,6 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp) } else { - /* * Free_bit addresses the last used bit. Bump it to address the * first available bit. diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index b8c520e3c0..0fff5a11e6 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.32 2001/07/15 22:48:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.33 2001/10/25 05:49:21 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -50,7 +50,7 @@ static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket * system catalogs anyway. * * Note that our page locks are actual lockmanager locks, not buffer - * locks (as are used by btree, for example). This is a good idea because + * locks (as are used by btree, for example). This is a good idea because * the algorithms are not deadlock-free, and we'd better be able to detect * and recover from deadlocks. * @@ -325,7 +325,7 @@ _hash_setpagelock(Relation rel, { switch (access) { - case HASH_WRITE: + case HASH_WRITE: LockPage(rel, blkno, ExclusiveLock); break; case HASH_READ: @@ -349,7 +349,7 @@ _hash_unsetpagelock(Relation rel, { switch (access) { - case HASH_WRITE: + case HASH_WRITE: UnlockPage(rel, blkno, ExclusiveLock); break; case HASH_READ: @@ -369,7 +369,7 @@ _hash_unsetpagelock(Relation rel, * It is safe to delete an item after acquiring a regular WRITE lock on * the page, because no other backend can hold a READ lock on the page, * and that means no other backend currently has an indexscan stopped on - * any item of the item being deleted. Our own backend might have such + * any item of the item being deleted. Our own backend might have such * an indexscan (in fact *will*, since that's how VACUUM found the item * in the first place), but _hash_adjscans will fix the scan position. */ @@ -532,7 +532,6 @@ _hash_splitpage(Relation rel, _hash_relbuf(rel, obuf, HASH_WRITE); if (!BlockNumberIsValid(oblkno)) { - /* * the old bucket is completely empty; of course, the new * bucket will be as well, but since it's a base bucket page @@ -559,7 +558,6 @@ _hash_splitpage(Relation rel, omaxoffnum = PageGetMaxOffsetNumber(opage); for (;;) { - /* * at each iteration through this loop, each of these variables * should be up-to-date: obuf opage oopaque ooffnum omaxoffnum @@ -572,7 +570,6 @@ _hash_splitpage(Relation rel, oblkno = oopaque->hasho_nextblkno; if (BlockNumberIsValid(oblkno)) { - /* * we ran out of tuples on this particular page, but we * have more overflow pages; re-init values. @@ -594,7 +591,6 @@ _hash_splitpage(Relation rel, } else { - /* * we're at the end of the bucket chain, so now we're * really done with everything. before quitting, call @@ -618,7 +614,6 @@ _hash_splitpage(Relation rel, if (bucket == nbucket) { - /* * insert the tuple into the new bucket. if it doesn't fit on * the current page in the new bucket, we must allocate a new @@ -695,7 +690,6 @@ _hash_splitpage(Relation rel, } else { - /* * the tuple stays on this page. we didn't move anything, so * we didn't delete anything and therefore we don't have to diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 27ca030118..6ea643dcaf 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.26 2001/03/23 04:49:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.27 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,6 @@ _hash_search(Relation rel, if (scankey == (ScanKey) NULL || (keyDatum = scankey[0].sk_argument) == (Datum) NULL) { - /* * If the scankey argument is NULL, all tuples will satisfy the * scan so we start the scan at the first bucket (bucket 0). diff --git a/src/backend/access/hash/hashstrat.c b/src/backend/access/hash/hashstrat.c index fc5df2372d..a765c2e2b1 100644 --- a/src/backend/access/hash/hashstrat.c +++ b/src/backend/access/hash/hashstrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.18 2001/05/30 19:53:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.19 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,6 @@ static StrategyEvaluationData HTEvaluationData = { (StrategyTransformMap) HTNegateCommute, HTEvaluationExpressions }; - #endif /* ---------------------------------------------------------------- @@ -68,7 +67,6 @@ _hash_getstrat(Relation rel, return strat; } - #endif #ifdef NOT_USED @@ -82,5 +80,4 @@ _hash_invokestrat(Relation rel, return (RelationInvokeStrategy(rel, &HTEvaluationData, attno, strat, left, right)); } - #endif diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index c64a19faa6..f73ca50285 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.125 2001/08/23 23:06:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.126 2001/10/25 05:49:21 momjian Exp $ * * * INTERFACE ROUTINES @@ -116,8 +116,8 @@ heapgettup(Relation relation, { ItemId lpp; Page dp; - BlockNumber page; - BlockNumber pages; + BlockNumber page; + BlockNumber pages; int lines; OffsetNumber lineoff; int linesleft; @@ -350,7 +350,7 @@ heapgettup(Relation relation, /* * return NULL if we've exhausted all the pages */ - if ((dir < 0) ? (page == 0) : (page+1 >= pages)) + if ((dir < 0) ? (page == 0) : (page + 1 >= pages)) { if (BufferIsValid(*buffer)) ReleaseBuffer(*buffer); @@ -429,9 +429,8 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, ( (Datum) NULL ) - ); + ); } - #endif /* defined(DISABLE_COMPLEX_MACRO) */ @@ -1045,12 +1044,13 @@ heap_insert(Relation relation, HeapTuple tup) if (relation->rd_rel->relhasoids) { /* - * If the object id of this tuple has already been assigned, trust the - * caller. There are a couple of ways this can happen. At initial db - * creation, the backend program sets oids for tuples. When we define - * an index, we set the oid. Finally, in the future, we may allow - * users to set their own object ids in order to support a persistent - * object store (objects need to contain pointers to one another). + * If the object id of this tuple has already been assigned, trust + * the caller. There are a couple of ways this can happen. At + * initial db creation, the backend program sets oids for tuples. + * When we define an index, we set the oid. Finally, in the + * future, we may allow users to set their own object ids in order + * to support a persistent object store (objects need to contain + * pointers to one another). */ if (!OidIsValid(tup->t_data->t_oid)) tup->t_data->t_oid = newoid(); @@ -1478,21 +1478,22 @@ l2: } /* - * Now, do we need a new page for the tuple, or not? This is a bit - * tricky since someone else could have added tuples to the page - * while we weren't looking. We have to recheck the available space - * after reacquiring the buffer lock. But don't bother to do that - * if the former amount of free space is still not enough; it's - * unlikely there's more free now than before. + * Now, do we need a new page for the tuple, or not? This is a + * bit tricky since someone else could have added tuples to the + * page while we weren't looking. We have to recheck the + * available space after reacquiring the buffer lock. But don't + * bother to do that if the former amount of free space is still + * not enough; it's unlikely there's more free now than before. * * What's more, if we need to get a new page, we will need to acquire - * buffer locks on both old and new pages. To avoid deadlock against - * some other backend trying to get the same two locks in the other - * order, we must be consistent about the order we get the locks in. - * We use the rule "lock the lower-numbered page of the relation - * first". To implement this, we must do RelationGetBufferForTuple - * while not holding the lock on the old page, and we must rely on it - * to get the locks on both pages in the correct order. + * buffer locks on both old and new pages. To avoid deadlock + * against some other backend trying to get the same two locks in + * the other order, we must be consistent about the order we get + * the locks in. We use the rule "lock the lower-numbered page of + * the relation first". To implement this, we must do + * RelationGetBufferForTuple while not holding the lock on the old + * page, and we must rely on it to get the locks on both pages in + * the correct order. */ if (newtupsize > pagefree) { @@ -1510,8 +1511,8 @@ l2: { /* * Rats, it doesn't fit anymore. We must now unlock and - * relock to avoid deadlock. Fortunately, this path should - * seldom be taken. + * relock to avoid deadlock. Fortunately, this path + * should seldom be taken. */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); newbuf = RelationGetBufferForTuple(relation, newtup->t_len, @@ -1534,9 +1535,9 @@ l2: pgstat_count_heap_update(&relation->pgstat_info); /* - * At this point newbuf and buffer are both pinned and locked, - * and newbuf has enough space for the new tuple. If they are - * the same buffer, only one pin is held. + * At this point newbuf and buffer are both pinned and locked, and + * newbuf has enough space for the new tuple. If they are the same + * buffer, only one pin is held. */ /* NO ELOG(ERROR) from here till changes are logged */ @@ -1865,12 +1866,14 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, * Note: xlhdr is declared to have adequate size and correct alignment * for an xl_heap_header. However the two tids, if present at all, * will be packed in with no wasted space after the xl_heap_header; - * they aren't necessarily aligned as implied by this struct declaration. + * they aren't necessarily aligned as implied by this struct + * declaration. */ - struct { - xl_heap_header hdr; - TransactionId tid1; - TransactionId tid2; + struct + { + xl_heap_header hdr; + TransactionId tid1; + TransactionId tid2; } xlhdr; int hsize = SizeOfHeapHeader; xl_heap_update xlrec; @@ -1972,7 +1975,7 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record) if (record->xl_len > SizeOfHeapClean) { - OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)]; + OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)]; OffsetNumber *unused = unbuf; char *unend; ItemId lp; @@ -2084,9 +2087,10 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record) if (redo) { - struct { + struct + { HeapTupleHeaderData hdr; - char data[MaxTupleSize]; + char data[MaxTupleSize]; } tbuf; HeapTupleHeader htup; xl_heap_header xlhdr; @@ -2251,9 +2255,10 @@ newsame:; if (redo) { - struct { + struct + { HeapTupleHeaderData hdr; - char data[MaxTupleSize]; + char data[MaxTupleSize]; } tbuf; xl_heap_header xlhdr; int hsize; diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 81a559b37e..44ecb3c8c7 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.42 2001/07/13 22:52:58 tgl Exp $ + * $Id: hio.c,v 1.43 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,7 +83,7 @@ RelationPutHeapTuple(Relation relation, * NOTE: it is unlikely, but not quite impossible, for otherBuffer to be the * same buffer we select for insertion of the new tuple (this could only * happen if space is freed in that page after heap_update finds there's not - * enough there). In that case, the page will be pinned and locked only once. + * enough there). In that case, the page will be pinned and locked only once. * * Note that we use LockPage(rel, 0) to lock relation for extension. * We can do this as long as in all other places we use page-level locking @@ -115,17 +115,19 @@ RelationGetBufferForTuple(Relation relation, Size len, if (otherBuffer != InvalidBuffer) otherBlock = BufferGetBlockNumber(otherBuffer); else - otherBlock = InvalidBlockNumber; /* just to keep compiler quiet */ + otherBlock = InvalidBlockNumber; /* just to keep compiler + * quiet */ /* * We first try to put the tuple on the same page we last inserted a * tuple on, as cached in the relcache entry. If that doesn't work, - * we ask the shared Free Space Map to locate a suitable page. Since + * we ask the shared Free Space Map to locate a suitable page. Since * the FSM's info might be out of date, we have to be prepared to loop * around and retry multiple times. (To insure this isn't an infinite - * loop, we must update the FSM with the correct amount of free space on - * each page that proves not to be suitable.) If the FSM has no record of - * a page with enough free space, we give up and extend the relation. + * loop, we must update the FSM with the correct amount of free space + * on each page that proves not to be suitable.) If the FSM has no + * record of a page with enough free space, we give up and extend the + * relation. */ targetBlock = relation->rd_targblock; @@ -137,6 +139,7 @@ RelationGetBufferForTuple(Relation relation, Size len, * target. */ targetBlock = GetPageWithFreeSpace(&relation->rd_node, len); + /* * If the FSM knows nothing of the rel, try the last page before * we give up and extend. This avoids one-tuple-per-page syndrome @@ -144,7 +147,7 @@ RelationGetBufferForTuple(Relation relation, Size len, */ if (targetBlock == InvalidBlockNumber) { - BlockNumber nblocks = RelationGetNumberOfBlocks(relation); + BlockNumber nblocks = RelationGetNumberOfBlocks(relation); if (nblocks > 0) targetBlock = nblocks - 1; @@ -154,9 +157,9 @@ RelationGetBufferForTuple(Relation relation, Size len, while (targetBlock != InvalidBlockNumber) { /* - * Read and exclusive-lock the target block, as well as the - * other block if one was given, taking suitable care with - * lock ordering and the possibility they are the same block. + * Read and exclusive-lock the target block, as well as the other + * block if one was given, taking suitable care with lock ordering + * and the possibility they are the same block. */ if (otherBuffer == InvalidBuffer) { @@ -184,9 +187,10 @@ RelationGetBufferForTuple(Relation relation, Size len, LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE); } + /* - * Now we can check to see if there's enough free space here. - * If so, we're done. + * Now we can check to see if there's enough free space here. If + * so, we're done. */ pageHeader = (Page) BufferGetPage(buffer); pageFreeSpace = PageGetFreeSpace(pageHeader); @@ -196,22 +200,22 @@ RelationGetBufferForTuple(Relation relation, Size len, relation->rd_targblock = targetBlock; return buffer; } + /* - * Not enough space, so we must give up our page locks and - * pin (if any) and prepare to look elsewhere. We don't care - * which order we unlock the two buffers in, so this can be - * slightly simpler than the code above. + * Not enough space, so we must give up our page locks and pin (if + * any) and prepare to look elsewhere. We don't care which order + * we unlock the two buffers in, so this can be slightly simpler + * than the code above. */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); if (otherBuffer == InvalidBuffer) - { ReleaseBuffer(buffer); - } else if (otherBlock != targetBlock) { LockBuffer(otherBuffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); } + /* * Update FSM as to condition of this page, and ask for another * page to try. @@ -225,9 +229,9 @@ RelationGetBufferForTuple(Relation relation, Size len, /* * Have to extend the relation. * - * We have to use a lock to ensure no one else is extending the - * rel at the same time, else we will both try to initialize the - * same new page. + * We have to use a lock to ensure no one else is extending the rel at + * the same time, else we will both try to initialize the same new + * page. */ if (!relation->rd_myxactonly) LockPage(relation, 0, ExclusiveLock); @@ -236,20 +240,21 @@ RelationGetBufferForTuple(Relation relation, Size len, * XXX This does an lseek - rather expensive - but at the moment it is * the only way to accurately determine how many blocks are in a * relation. Is it worth keeping an accurate file length in shared - * memory someplace, rather than relying on the kernel to do it for us? + * memory someplace, rather than relying on the kernel to do it for + * us? */ buffer = ReadBuffer(relation, P_NEW); /* - * Release the file-extension lock; it's now OK for someone else - * to extend the relation some more. + * Release the file-extension lock; it's now OK for someone else to + * extend the relation some more. */ if (!relation->rd_myxactonly) UnlockPage(relation, 0, ExclusiveLock); /* - * We can be certain that locking the otherBuffer first is OK, - * since it must have a lower page number. + * We can be certain that locking the otherBuffer first is OK, since + * it must have a lower page number. */ if (otherBuffer != InvalidBuffer) LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE); @@ -273,7 +278,7 @@ RelationGetBufferForTuple(Relation relation, Size len, * * XXX should we enter the new page into the free space map immediately, * or just keep it for this backend's exclusive use in the short run - * (until VACUUM sees it)? Seems to depend on whether you expect the + * (until VACUUM sees it)? Seems to depend on whether you expect the * current backend to make more insertions or not, which is probably a * good bet most of the time. So for now, don't add it to FSM yet. */ diff --git a/src/backend/access/heap/stats.c b/src/backend/access/heap/stats.c index 6dabf49e34..6f5dfbea14 100644 --- a/src/backend/access/heap/stats.c +++ b/src/backend/access/heap/stats.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.24 2001/03/22 06:16:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.25 2001/10/25 05:49:21 momjian Exp $ * * NOTES * initam should be moved someplace else. @@ -164,7 +164,6 @@ ResetHeapAccessStatistics() time(&stats->local_reset_timestamp); time(&stats->last_request_timestamp); } - #endif #ifdef NOT_USED @@ -200,7 +199,6 @@ GetHeapAccessStatistics() return stats; } - #endif #ifdef NOT_USED @@ -211,7 +209,6 @@ GetHeapAccessStatistics() void PrintHeapAccessStatistics(HeapAccessStatistics stats) { - /* * return nothing if stats aren't valid */ @@ -302,7 +299,6 @@ PrintHeapAccessStatistics(HeapAccessStatistics stats) printf("\n"); } - #endif #ifdef NOT_USED @@ -317,7 +313,6 @@ PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats) if (stats != NULL) pfree(stats); } - #endif /* ---------------------------------------------------------------- @@ -331,7 +326,6 @@ PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats) void initam(void) { - /* * initialize heap statistics. */ diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index dd881ca5f0..5ddefde8c7 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.24 2001/08/10 18:57:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.25 2001/10/25 05:49:21 momjian Exp $ * * * INTERFACE ROUTINES @@ -74,14 +74,13 @@ heap_tuple_toast_attrs(Relation rel, HeapTuple newtup, HeapTuple oldtup) * external storage (possibly still in compressed format). * ---------- */ -varattrib * +varattrib * heap_tuple_fetch_attr(varattrib *attr) { varattrib *result; if (VARATT_IS_EXTERNAL(attr)) { - /* * This is an external stored plain value */ @@ -89,7 +88,6 @@ heap_tuple_fetch_attr(varattrib *attr) } else { - /* * This is a plain value inside of the main tuple - why am I * called? @@ -108,7 +106,7 @@ heap_tuple_fetch_attr(varattrib *attr) * or external storage. * ---------- */ -varattrib * +varattrib * heap_tuple_untoast_attr(varattrib *attr) { varattrib *result; @@ -135,7 +133,6 @@ heap_tuple_untoast_attr(varattrib *attr) } else { - /* * This is an external stored plain value */ @@ -144,7 +141,6 @@ heap_tuple_untoast_attr(varattrib *attr) } else if (VARATT_IS_COMPRESSED(attr)) { - /* * This is a compressed value inside of the main tuple */ @@ -181,8 +177,8 @@ toast_raw_datum_size(Datum value) if (VARATT_IS_COMPRESSED(attr)) { /* - * va_rawsize shows the original data size, whether the datum - * is external or not. + * va_rawsize shows the original data size, whether the datum is + * external or not. */ result = attr->va_content.va_compressed.va_rawsize + VARHDRSZ; } @@ -301,7 +297,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) if (oldtup != NULL) { - /* * For UPDATE get the old and new values of this attribute */ @@ -324,7 +319,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) old_value->va_content.va_external.va_toastrelid != new_value->va_content.va_external.va_toastrelid) { - /* * The old external store value isn't needed any more * after the update @@ -334,7 +328,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } else { - /* * This attribute isn't changed by this update so we * reuse the original reference to the old value in @@ -348,7 +341,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } else { - /* * For INSERT simply get the new value */ @@ -372,7 +364,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) */ if (att[i]->attlen == -1) { - /* * If the table's attribute says PLAIN always, force it so. */ @@ -400,7 +391,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } else { - /* * Not a variable size attribute, plain storage always */ @@ -475,7 +465,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } else { - /* * incompressible data, ignore on subsequent compression * passes @@ -588,7 +577,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } else { - /* * incompressible data, ignore on subsequent compression * passes @@ -776,9 +764,10 @@ toast_save_datum(Relation rel, Datum value) Datum t_values[3]; char t_nulls[3]; varattrib *result; - struct { - struct varlena hdr; - char data[TOAST_MAX_CHUNK_SIZE]; + struct + { + struct varlena hdr; + char data[TOAST_MAX_CHUNK_SIZE]; } chunk_data; int32 chunk_size; int32 chunk_seq = 0; @@ -851,12 +840,12 @@ toast_save_datum(Relation rel, Datum value) heap_insert(toastrel, toasttup); /* - * Create the index entry. We cheat a little here by not using + * Create the index entry. We cheat a little here by not using * FormIndexDatum: this relies on the knowledge that the index * columns are the same as the initial columns of the table. * - * Note also that there had better not be any user-created index - * on the TOAST table, since we don't bother to update anything else. + * Note also that there had better not be any user-created index on + * the TOAST table, since we don't bother to update anything else. */ idxres = index_insert(toastidx, t_values, t_nulls, &(toasttup->t_self), @@ -916,8 +905,8 @@ toast_delete_datum(Relation rel, Datum value) toastidx = index_open(toastrel->rd_rel->reltoastidxid); /* - * Setup a scan key to fetch from the index by va_valueid - * (we don't particularly care whether we see them in sequence or not) + * Setup a scan key to fetch from the index by va_valueid (we don't + * particularly care whether we see them in sequence or not) */ ScanKeyEntryInitialize(&toastkey, (bits16) 0, @@ -1096,5 +1085,4 @@ toast_fetch_datum(varattrib *attr) return result; } - #endif /* TUPLE_TOASTER_ACTIVE */ diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 1115fb828b..b03690257c 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.28 2001/06/22 19:16:21 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.29 2001/10/25 05:49:21 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -240,5 +240,4 @@ IndexScanRestorePosition(IndexScanDesc scan) scan->flags = 0x0; /* XXX should have a symbolic name */ } - #endif diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 2a1d3294dd..8e1d5b8733 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.53 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.54 2001/10/25 05:49:21 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relationId @@ -241,9 +241,9 @@ index_beginscan(Relation relation, pgstat_initstats(&scan->xs_pgstat_info, relation); /* - * We want to look up the amgettuple procedure just once per scan, - * not once per index_getnext call. So do it here and save - * the fmgr info result in the scan descriptor. + * We want to look up the amgettuple procedure just once per scan, not + * once per index_getnext call. So do it here and save the fmgr info + * result in the scan descriptor. */ GET_SCAN_PROCEDURE(beginscan, amgettuple); fmgr_info(procedure, &scan->fn_getnext); @@ -342,8 +342,8 @@ index_getnext(IndexScanDesc scan, pgstat_count_index_scan(&scan->xs_pgstat_info); /* - * have the am's gettuple proc do all the work. - * index_beginscan already set up fn_getnext. + * have the am's gettuple proc do all the work. index_beginscan + * already set up fn_getnext. */ result = (RetrieveIndexResult) DatumGetPointer(FunctionCall2(&scan->fn_getnext, @@ -378,8 +378,8 @@ index_bulk_delete(Relation relation, result = (IndexBulkDeleteResult *) DatumGetPointer(OidFunctionCall3(procedure, PointerGetDatum(relation), - PointerGetDatum((Pointer) callback), - PointerGetDatum(callback_state))); + PointerGetDatum((Pointer) callback), + PointerGetDatum(callback_state))); return result; } diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c index 568581fc18..88d1757e4c 100644 --- a/src/backend/access/index/istrat.c +++ b/src/backend/access/index/istrat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.53 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.54 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,9 +120,9 @@ StrategyOperatorIsValid(StrategyOperator operator, StrategyNumber maxStrategy) { return (bool) - (PointerIsValid(operator) && - StrategyNumberIsInBounds(operator->strategy, maxStrategy) && - !(operator->flags & ~(SK_NEGATE | SK_COMMUTE))); + (PointerIsValid(operator) && + StrategyNumberIsInBounds(operator->strategy, maxStrategy) && + !(operator->flags & ~(SK_NEGATE | SK_COMMUTE))); } /* ---------------- @@ -196,7 +196,6 @@ StrategyEvaluationIsValid(StrategyEvaluation evaluation) } return true; } - #endif #ifdef NOT_USED @@ -255,7 +254,6 @@ StrategyTermEvaluate(StrategyTerm term, return result; } - #endif /* ---------------- @@ -453,7 +451,6 @@ RelationInvokeStrategy(Relation relation, /* not reached, just to make compiler happy */ return FALSE; } - #endif /* ---------------- @@ -552,7 +549,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, { for (attIndex = 0; attIndex < maxAttributeNumber; attIndex++) { - Oid opclass = operatorClassObjectId[attIndex]; + Oid opclass = operatorClassObjectId[attIndex]; RegProcedure *loc; StrategyNumber support; @@ -562,7 +559,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, { tuple = SearchSysCache(AMPROCNUM, ObjectIdGetDatum(opclass), - Int16GetDatum(support+1), + Int16GetDatum(support + 1), 0, 0); if (HeapTupleIsValid(tuple)) { @@ -581,7 +578,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, /* Now load the strategy information for the index operators */ for (attIndex = 0; attIndex < maxAttributeNumber; attIndex++) { - Oid opclass = operatorClassObjectId[attIndex]; + Oid opclass = operatorClassObjectId[attIndex]; StrategyMap map; StrategyNumber strategy; @@ -591,7 +588,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, for (strategy = 1; strategy <= maxStrategyNumber; strategy++) { - ScanKey mapentry = StrategyMapGetScanKeyEntry(map, strategy); + ScanKey mapentry = StrategyMapGetScanKeyEntry(map, strategy); tuple = SearchSysCache(AMOPSTRATEGY, ObjectIdGetDatum(opclass), @@ -643,5 +640,4 @@ IndexStrategyDisplay(IndexStrategy indexStrategy, } } } - #endif /* defined(ISTRATDEBUG) */ diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index b1affe2018..a4ba587053 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.42 2001/05/03 19:00:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.43 2001/10/25 05:49:21 momjian Exp $ * * NOTES * @@ -25,7 +25,7 @@ * NOTE: although any negative int32 is acceptable for reporting "<", * and any positive int32 is acceptable for reporting ">", routines * that work on 32-bit or wider datatypes can't just return "a - b". - * That could overflow and give the wrong answer. Also, one should not + * That could overflow and give the wrong answer. Also, one should not * return INT_MIN to report "<", since some callers will negate the result. * * NOTE: it is critical that the comparison function impose a total order diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index bc250cd48e..1d3a7e82ab 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.86 2001/09/29 23:49:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.87 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1100,7 +1100,7 @@ _bt_checksplitloc(FindSplitData *state, OffsetNumber firstright, * If we are not on the leaf level, we will be able to discard the key * data from the first item that winds up on the right page. */ - if (! state->is_leaf) + if (!state->is_leaf) rightfree += (int) firstrightitemsz - (int) (MAXALIGN(sizeof(BTItemData)) + sizeof(ItemIdData)); @@ -1115,7 +1115,8 @@ _bt_checksplitloc(FindSplitData *state, OffsetNumber firstright, { /* * On a rightmost page, try to equalize right free space with - * twice the left free space. See comments for _bt_findsplitloc. + * twice the left free space. See comments for + * _bt_findsplitloc. */ delta = (2 * leftfree) - rightfree; } @@ -1618,7 +1619,6 @@ _bt_fixlevel(Relation rel, Buffer buf, BlockNumber limit) for (;;) { - /* * Read up to 2 more child pages and look for pointers to them in * *saved* parent page diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 376274c562..2e6eb20cd4 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.53 2001/07/15 22:48:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.54 2001/10/25 05:49:21 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -153,7 +153,6 @@ _bt_getroot(Relation rel, int access) */ if (metad->btm_root == P_NONE) { - /* * Get, initialize, write, and leave a lock of the appropriate * type on the new root page. Since this is the first page in @@ -209,7 +208,6 @@ _bt_getroot(Relation rel, int access) } else { - /* * Metadata initialized by someone else. In order to * guarantee no deadlocks, we have to release the metadata @@ -237,7 +235,6 @@ _bt_getroot(Relation rel, int access) if (!P_ISROOT(rootopaque)) { - /* * It happened, but if root page splitter failed to create new * root page then we'll go in loop trying to call _bt_getroot @@ -402,7 +399,6 @@ _bt_wrtnorelbuf(Relation rel, Buffer buf) void _bt_pageinit(Page page, Size size) { - /* * Cargo_cult programming -- don't really need this to be zero, but * creating new pages is an infrequent occurrence and it makes me feel diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index b142645624..e49f06b1c3 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.82 2001/07/15 22:48:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.83 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,6 +37,7 @@ typedef struct bool haveDead; Relation heapRel; BTSpool *spool; + /* * spool2 is needed only when the index is an unique index. Dead * tuples are put into spool2 instead of spool in order to avoid @@ -58,11 +59,11 @@ bool FixBTree = true; static void _bt_restscan(IndexScanDesc scan); static void btbuildCallback(Relation index, - HeapTuple htup, - Datum *attdata, - char *nulls, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *attdata, + char *nulls, + bool tupleIsAlive, + void *state); /* @@ -134,6 +135,7 @@ btbuild(PG_FUNCTION_ARGS) if (buildstate.usefast) { buildstate.spool = _bt_spoolinit(index, indexInfo->ii_Unique); + /* * Different from spool, the uniqueness isn't checked for spool2. */ @@ -214,7 +216,7 @@ btbuildCallback(Relation index, bool tupleIsAlive, void *state) { - BTBuildState *buildstate = (BTBuildState *) state; + BTBuildState *buildstate = (BTBuildState *) state; IndexTuple itup; BTItem btitem; InsertIndexResult res; @@ -226,9 +228,9 @@ btbuildCallback(Relation index, btitem = _bt_formitem(itup); /* - * if we are doing bottom-up btree build, we insert the index into - * a spool file for subsequent processing. otherwise, we insert - * into the btree. + * if we are doing bottom-up btree build, we insert the index into a + * spool file for subsequent processing. otherwise, we insert into + * the btree. */ if (buildstate->usefast) { @@ -305,7 +307,6 @@ btgettuple(PG_FUNCTION_ARGS) if (ItemPointerIsValid(&(scan->currentItemData))) { - /* * Restore scan position using heap TID returned by previous call * to btgettuple(). _bt_restscan() re-grabs the read lock on the @@ -321,7 +322,7 @@ btgettuple(PG_FUNCTION_ARGS) * Save heap TID to use it in _bt_restscan. Then release the read * lock on the buffer so that we aren't blocking other backends. * - * NOTE: we do keep the pin on the buffer! This is essential to ensure + * NOTE: we do keep the pin on the buffer! This is essential to ensure * that someone else doesn't delete the index entry we are stopped on. */ if (res) @@ -362,7 +363,6 @@ btrescan(PG_FUNCTION_ARGS) #ifdef NOT_USED /* XXX surely it's wrong to ignore this? */ bool fromEnd = PG_GETARG_BOOL(1); - #endif ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2); ItemPointer iptr; @@ -547,7 +547,7 @@ btbulkdelete(PG_FUNCTION_ARGS) IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1); void *callback_state = (void *) PG_GETARG_POINTER(2); IndexBulkDeleteResult *result; - BlockNumber num_pages; + BlockNumber num_pages; double tuples_removed; double num_index_tuples; RetrieveIndexResult res; @@ -559,15 +559,16 @@ btbulkdelete(PG_FUNCTION_ARGS) num_index_tuples = 0; /* - * We use a standard IndexScanDesc scan object, but to speed up the loop, - * we skip most of the wrapper layers of index_getnext and instead call - * _bt_step directly. This implies holding buffer lock on a target page - * throughout the loop over the page's tuples. Initially, we have a read - * lock acquired by _bt_step when we stepped onto the page. If we find - * a tuple we need to delete, we trade in the read lock for an exclusive - * write lock; after that, we hold the write lock until we step off the - * page (fortunately, _bt_relbuf doesn't care which kind of lock it's - * releasing). This should minimize the amount of work needed per page. + * We use a standard IndexScanDesc scan object, but to speed up the + * loop, we skip most of the wrapper layers of index_getnext and + * instead call _bt_step directly. This implies holding buffer lock + * on a target page throughout the loop over the page's tuples. + * Initially, we have a read lock acquired by _bt_step when we stepped + * onto the page. If we find a tuple we need to delete, we trade in + * the read lock for an exclusive write lock; after that, we hold the + * write lock until we step off the page (fortunately, _bt_relbuf + * doesn't care which kind of lock it's releasing). This should + * minimize the amount of work needed per page. */ scan = index_beginscan(rel, false, 0, (ScanKey) NULL); so = (BTScanOpaque) scan->opaque; @@ -579,7 +580,7 @@ btbulkdelete(PG_FUNCTION_ARGS) if (res != NULL) { Buffer buf; - BlockNumber lockedBlock = InvalidBlockNumber; + BlockNumber lockedBlock = InvalidBlockNumber; pfree(res); /* we have the buffer pinned and locked */ @@ -589,11 +590,11 @@ btbulkdelete(PG_FUNCTION_ARGS) do { Page page; - BlockNumber blkno; + BlockNumber blkno; OffsetNumber offnum; BTItem btitem; IndexTuple itup; - ItemPointer htup; + ItemPointer htup; /* current is the next index tuple */ blkno = ItemPointerGetBlockNumber(current); @@ -607,9 +608,10 @@ 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 someone else might - * have inserted an item while we weren't holding the lock! + * lock for a really-exclusive write lock. Then, step + * back one and re-examine the item, because someone else + * might have inserted an item while we weren't holding + * the lock! */ if (blkno != lockedBlock) { @@ -632,8 +634,8 @@ btbulkdelete(PG_FUNCTION_ARGS) * We 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 + * For now, just hack the current-item index. Will need to + * be smarter when deletion includes removal of empty * index pages. */ current->ip_posid--; diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 86ff810845..c1a82f2b85 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.68 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.69 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -589,10 +589,10 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) /* * At this point we are positioned at the first item >= scan key, or - * possibly at the end of a page on which all the existing items are - * greater than the scan key and we know that everything on later pages - * is less than or equal to scan key. - * + * possibly at the end of a page on which all the existing items are + * greater than the scan key and we know that everything on later + * pages is less than or equal to scan key. + * * We could step forward in the latter case, but that'd be a waste of * time if we want to scan backwards. So, it's now time to examine * the scan strategy to find the exact place to start the scan. diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 2aca6bf7cf..4b327bff45 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -35,7 +35,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.60 2001/03/22 03:59:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.61 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -108,7 +108,7 @@ static void _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2); /* * create and initialize a spool structure */ -BTSpool * +BTSpool * _bt_spoolinit(Relation index, bool isunique) { BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); @@ -354,7 +354,6 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti) if (pgspc < btisz || pgspc < state->btps_full) { - /* * Item won't fit on this page, or we feel the page is full enough * already. Finish off the page and write it out. @@ -544,7 +543,6 @@ _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2) if (merge) { - /* * Another BTSpool for dead tuples exists. Now we have to merge * btspool and btspool2. diff --git a/src/backend/access/nbtree/nbtstrat.c b/src/backend/access/nbtree/nbtstrat.c index 4045496979..533af33681 100644 --- a/src/backend/access/nbtree/nbtstrat.c +++ b/src/backend/access/nbtree/nbtstrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.14 2001/05/30 19:53:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.15 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -134,5 +134,4 @@ _bt_invokestrat(Relation rel, return (RelationInvokeStrategy(rel, &BTEvaluationData, attno, strat, left, right)); } - #endif diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 86d2e3cf8f..55c4c32300 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.46 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.47 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -221,7 +221,6 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) /* We can short-circuit most of the work if there's just one key */ if (numberOfKeys == 1) { - /* * We don't use indices for 'A is null' and 'A is not null' * currently and 'A < = > <> NULL' will always fail - so qual is @@ -317,7 +316,6 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) } else { - /* * No "=" for this key, so we're done with required keys */ diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index 42878248b0..0e8305bdfb 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.65 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.66 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,9 +58,9 @@ typedef struct SPLITVEC /* for sorting tuples by cost, for picking split */ typedef struct SPLITCOST { - OffsetNumber offset_number; - float cost_differential; - bool choose_left; + OffsetNumber offset_number; + float cost_differential; + bool choose_left; } SPLITCOST; typedef struct RTSTATE @@ -79,11 +79,11 @@ typedef struct /* non-export function prototypes */ static void rtbuildCallback(Relation index, - HeapTuple htup, - Datum *attdata, - char *nulls, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *attdata, + char *nulls, + bool tupleIsAlive, + void *state); static InsertIndexResult rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate); static void rttighten(Relation r, RTSTACK *stk, Datum datum, int att_size, @@ -100,7 +100,7 @@ static OffsetNumber choose(Relation r, Page p, IndexTuple it, RTSTATE *rtstate); static int nospace(Page p, IndexTuple it); static void initRtstate(RTSTATE *rtstate, Relation index); -static int qsort_comp_splitcost(const void *a, const void *b); +static int qsort_comp_splitcost(const void *a, const void *b); /* @@ -178,7 +178,7 @@ rtbuildCallback(Relation index, bool tupleIsAlive, void *state) { - RTBuildState *buildstate = (RTBuildState *) state; + RTBuildState *buildstate = (RTBuildState *) state; IndexTuple itup; InsertIndexResult res; @@ -194,11 +194,11 @@ rtbuildCallback(Relation index, } /* - * Since we already have the index relation locked, we call - * rtdoinsert directly. Normal access method calls dispatch - * through rtinsert, which locks the relation for write. This is - * the right thing to do if you're inserting single tups, but not - * when you're initializing the whole index at once. + * Since we already have the index relation locked, we call rtdoinsert + * directly. Normal access method calls dispatch through rtinsert, + * which locks the relation for write. This is the right thing to do + * if you're inserting single tups, but not when you're initializing + * the whole index at once. */ res = rtdoinsert(index, itup, &buildstate->rtState); @@ -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); #endif @@ -249,7 +250,7 @@ rtinsert(PG_FUNCTION_ARGS) /* * Since rtree is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking + * have acquired exclusive lock on index relation. We need no locking * here. */ @@ -376,9 +377,8 @@ rttighten(Relation r, PointerGetDatum(&newd_size)); /* - * If newd_size == 0 we have degenerate rectangles, so we - * don't know if there was any change, so we have to - * assume there was. + * If newd_size == 0 we have degenerate rectangles, so we don't know + * if there was any change, so we have to assume there was. */ if ((newd_size == 0) || (newd_size != old_size)) { @@ -386,7 +386,6 @@ rttighten(Relation r, if (td->attrs[0]->attlen < 0) { - /* * This is an internal page, so 'oldud' had better be a union * (constant-length) key, too. (See comment below.) @@ -500,10 +499,10 @@ rtdosplit(Relation r, res = (InsertIndexResult) palloc(sizeof(InsertIndexResultData)); /* - * spl_left contains a list of the offset numbers of the - * tuples that will go to the left page. For each offset - * number, get the tuple item, then add the item to the - * left page. Similarly for the right side. + * spl_left contains a list of the offset numbers of the tuples that + * will go to the left page. For each offset number, get the tuple + * item, then add the item to the left page. Similarly for the right + * side. */ /* fill left node */ @@ -527,7 +526,7 @@ rtdosplit(Relation r, if (i == newitemoff) ItemPointerSet(&(res->pointerData), lbknum, leftoff); - spl_left++; /* advance in left split vector */ + spl_left++; /* advance in left split vector */ } /* fill right node */ @@ -551,7 +550,7 @@ rtdosplit(Relation r, if (i == newitemoff) ItemPointerSet(&(res->pointerData), rbknum, rightoff); - spl_right++; /* advance in right split vector */ + spl_right++; /* advance in right split vector */ } /* Make sure we consumed all of the split vectors, and release 'em */ @@ -764,9 +763,10 @@ rtpicksplit(Relation r, right_avail_space; int total_num_tuples, num_tuples_without_seeds, - max_after_split; /* in Guttman's lingo, (M - m) */ - float diff; /* diff between cost of putting tuple left or right */ - SPLITCOST *cost_vector; + max_after_split; /* in Guttman's lingo, (M - m) */ + float diff; /* diff between cost of putting tuple left + * or right */ + SPLITCOST *cost_vector; int n; /* @@ -852,7 +852,6 @@ rtpicksplit(Relation r, if (firsttime) { - /* * There is no possible split except to put the new item on its * own page. Since we still have to compute the union rectangles, @@ -885,25 +884,25 @@ rtpicksplit(Relation r, /* * Now split up the regions between the two seeds. * - * The cost_vector array will contain hints for determining where - * each tuple should go. Each record in the array will contain - * a boolean, choose_left, that indicates which node the tuple - * prefers to be on, and the absolute difference in cost between - * putting the tuple in its favored node and in the other node. + * The cost_vector array will contain hints for determining where each + * tuple should go. Each record in the array will contain a boolean, + * choose_left, that indicates which node the tuple prefers to be on, + * and the absolute difference in cost between putting the tuple in + * its favored node and in the other node. * * Later, we will sort the cost_vector in descending order by cost - * difference, and consider the tuples in that order for - * placement. That way, the tuples that *really* want to be in - * one node or the other get to choose first, and the tuples that - * don't really care choose last. + * difference, and consider the tuples in that order for placement. + * That way, the tuples that *really* want to be in one node or the + * other get to choose first, and the tuples that don't really care + * choose last. * - * First, build the cost_vector array. The new index tuple will - * also be handled in this loop, and represented in the array, - * with i==newitemoff. + * First, build the cost_vector array. The new index tuple will also be + * handled in this loop, and represented in the array, with + * i==newitemoff. * - * In the case of variable size tuples it is possible that we only - * have the two seeds and no other tuples, in which case we don't - * do any of this cost_vector stuff. + * In the case of variable size tuples it is possible that we only have + * the two seeds and no other tuples, in which case we don't do any of + * this cost_vector stuff. */ /* to keep compiler quiet */ @@ -943,21 +942,21 @@ rtpicksplit(Relation r, } /* - * Sort the array. The function qsort_comp_splitcost is - * set up "backwards", to provided descending order. + * Sort the array. The function qsort_comp_splitcost is set up + * "backwards", to provided descending order. */ qsort(cost_vector, num_tuples_without_seeds, sizeof(SPLITCOST), &qsort_comp_splitcost); } /* - * Now make the final decisions about where each tuple will go, - * and build the vectors to return in the SPLITVEC record. + * Now make the final decisions about where each tuple will go, and + * build the vectors to return in the SPLITVEC record. * - * The cost_vector array contains (descriptions of) all the - * tuples, in the order that we want to consider them, so we - * we just iterate through it and place each tuple in left - * or right nodes, according to the criteria described below. + * The cost_vector array contains (descriptions of) all the tuples, in + * the order that we want to consider them, so we we just iterate + * through it and place each tuple in left or right nodes, according + * to the criteria described below. */ left = v->spl_left; @@ -965,9 +964,9 @@ rtpicksplit(Relation r, right = v->spl_right; v->spl_nright = 0; - /* Place the seeds first. - * left avail space, left union, right avail space, and right - * union have already been adjusted for the seeds. + /* + * Place the seeds first. left avail space, left union, right avail + * space, and right union have already been adjusted for the seeds. */ *left++ = seed_1; @@ -983,8 +982,8 @@ rtpicksplit(Relation r, choose_left; /* - * We need to figure out which page needs the least - * enlargement in order to store the item. + * We need to figure out which page needs the least enlargement in + * order to store the item. */ i = cost_vector[n].offset_number; @@ -1019,22 +1018,22 @@ rtpicksplit(Relation r, * the new item.) * * Guttman's algorithm actually has two factors to consider (in - * order): 1. if one node has so many tuples already assigned to + * order): 1. if one node has so many tuples already assigned to * it that the other needs all the rest in order to satisfy the - * condition that neither node has fewer than m tuples, then - * that is decisive; 2. otherwise, choose the page that shows - * the smaller enlargement of its union area. + * condition that neither node has fewer than m tuples, then that + * is decisive; 2. otherwise, choose the page that shows the + * smaller enlargement of its union area. * - * I have chosen m = M/2, where M is the maximum number of - * tuples on a page. (Actually, this is only strictly - * true for fixed size tuples. For variable size tuples, - * there still might have to be only one tuple on a page, - * if it is really big. But even with variable size - * tuples we still try to get m as close as possible to M/2.) + * I have chosen m = M/2, where M is the maximum number of tuples on + * a page. (Actually, this is only strictly true for fixed size + * tuples. For variable size tuples, there still might have to be + * only one tuple on a page, if it is really big. But even with + * variable size tuples we still try to get m as close as possible + * to M/2.) * - * The question of which page shows the smaller enlargement of - * its union area has already been answered, and the answer - * stored in the choose_left field of the SPLITCOST record. + * The question of which page shows the smaller enlargement of its + * union area has already been answered, and the answer stored in + * the choose_left field of the SPLITCOST record. */ left_feasible = (left_avail_space >= item_1_sz && ((left_avail_space - item_1_sz) >= newitemsz || @@ -1045,10 +1044,10 @@ rtpicksplit(Relation r, if (left_feasible && right_feasible) { /* - * Both feasible, use Guttman's algorithm. - * First check the m condition described above, and if - * that doesn't apply, choose the page with the smaller - * enlargement of its union area. + * Both feasible, use Guttman's algorithm. First check the m + * condition described above, and if that doesn't apply, + * choose the page with the smaller enlargement of its union + * area. */ if (v->spl_nleft > max_after_split) choose_left = false; @@ -1064,7 +1063,7 @@ rtpicksplit(Relation r, else { elog(ERROR, "rtpicksplit: failed to find a workable page split"); - choose_left = false;/* keep compiler quiet */ + choose_left = false; /* keep compiler quiet */ } if (choose_left) @@ -1090,9 +1089,7 @@ rtpicksplit(Relation r, } if (num_tuples_without_seeds > 0) - { pfree(cost_vector); - } *left = *right = InvalidOffsetNumber; /* add ending sentinels */ @@ -1189,7 +1186,7 @@ rtbulkdelete(PG_FUNCTION_ARGS) IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(1); void *callback_state = (void *) PG_GETARG_POINTER(2); IndexBulkDeleteResult *result; - BlockNumber num_pages; + BlockNumber num_pages; double tuples_removed; double num_index_tuples; RetrieveIndexResult res; @@ -1200,7 +1197,7 @@ rtbulkdelete(PG_FUNCTION_ARGS) /* * Since rtree is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking + * have acquired exclusive lock on index relation. We need no locking * here. */ @@ -1279,9 +1276,10 @@ initRtstate(RTSTATE *rtstate, Relation index) static int qsort_comp_splitcost(const void *a, const void *b) { - float diff = - ((SPLITCOST *)a)->cost_differential - - ((SPLITCOST *)b)->cost_differential; + float diff = + ((SPLITCOST *) a)->cost_differential - + ((SPLITCOST *) b)->cost_differential; + if (diff < 0) return 1; else if (diff > 0) @@ -1342,7 +1340,6 @@ _rtdump(Relation r) ReleaseBuffer(buf); } } - #endif /* defined RTDEBUG */ void diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c index 1311cfdc29..c6883fd041 100644 --- a/src/backend/access/rtree/rtscan.c +++ b/src/backend/access/rtree/rtscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.38 2001/07/15 22:48:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.39 2001/10/25 05:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -380,7 +380,6 @@ adjustiptr(IndexScanDesc s, } else { - /* * remember that we're before the current * tuple diff --git a/src/backend/access/rtree/rtstrat.c b/src/backend/access/rtree/rtstrat.c index 74ee6a39a4..41de4a4e3e 100644 --- a/src/backend/access/rtree/rtstrat.c +++ b/src/backend/access/rtree/rtstrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.17 2001/05/30 19:53:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.18 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,7 @@ static StrategyExpression RTEvaluationExpressions[RTNStrategies] = { NULL, /* express overlap */ NULL, /* express overright */ NULL, /* express right */ - (StrategyExpression) RTEqualExpressionData, /* express same */ + (StrategyExpression) RTEqualExpressionData, /* express same */ NULL, /* express contains */ NULL /* express contained-by */ }; @@ -221,7 +221,6 @@ RelationInvokeRTStrategy(Relation r, return (RelationInvokeStrategy(r, &RTEvaluationData, attnum, s, left, right)); } - #endif RegProcedure diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index cd83da93ea..1436b32aa1 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.4 2001/09/29 04:02:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.5 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ /* * Defines for CLOG page and segment sizes. A page is the same BLCKSZ - * as is used everywhere else in Postgres. The CLOG segment size can be + * as is used everywhere else in Postgres. The CLOG segment size can be * chosen somewhat arbitrarily; we make it 1 million transactions by default, * or 256Kb. * @@ -48,15 +48,15 @@ /* We need two bits per xact, so four xacts fit in a byte */ #define CLOG_BITS_PER_XACT 2 -#define CLOG_XACTS_PER_BYTE 4 -#define CLOG_XACTS_PER_PAGE (CLOG_BLCKSZ * CLOG_XACTS_PER_BYTE) +#define CLOG_XACTS_PER_BYTE 4 +#define CLOG_XACTS_PER_PAGE (CLOG_BLCKSZ * CLOG_XACTS_PER_BYTE) #define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1) #define CLOG_XACTS_PER_SEGMENT 0x100000 #define CLOG_PAGES_PER_SEGMENT (CLOG_XACTS_PER_SEGMENT / CLOG_XACTS_PER_PAGE) #define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE) -#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) +#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) #define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE) #define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE) @@ -101,15 +101,15 @@ * the control lock. * * As with the regular buffer manager, it is possible for another process - * to re-dirty a page that is currently being written out. This is handled + * to re-dirty a page that is currently being written out. This is handled * by setting the page's state from WRITE_IN_PROGRESS to DIRTY. The writing * process must notice this and not mark the page CLEAN when it's done. * * XLOG interactions: this module generates an XLOG record whenever a new - * CLOG page is initialized to zeroes. Other writes of CLOG come from + * CLOG page is initialized to zeroes. Other writes of CLOG come from * recording of transaction commit or abort in xact.c, which generates its * own XLOG records for these events and will re-perform the status update - * on redo; so we need make no additional XLOG entry here. Also, the XLOG + * on redo; so we need make no additional XLOG entry here. Also, the XLOG * is guaranteed flushed through the XLOG commit record before we are called * to log a commit, so the WAL rule "write xlog before data" is satisfied * automatically for commits, and we don't really care for aborts. Therefore, @@ -120,11 +120,13 @@ typedef enum { - CLOG_PAGE_EMPTY, /* CLOG buffer is not in use */ - CLOG_PAGE_READ_IN_PROGRESS, /* CLOG page is being read in */ - CLOG_PAGE_CLEAN, /* CLOG page is valid and not dirty */ - CLOG_PAGE_DIRTY, /* CLOG page is valid but needs write */ - CLOG_PAGE_WRITE_IN_PROGRESS /* CLOG page is being written out in */ + CLOG_PAGE_EMPTY,/* CLOG buffer is not in use */ + CLOG_PAGE_READ_IN_PROGRESS, /* CLOG page is being read + * in */ + CLOG_PAGE_CLEAN,/* CLOG page is valid and not dirty */ + CLOG_PAGE_DIRTY,/* CLOG page is valid but needs write */ + CLOG_PAGE_WRITE_IN_PROGRESS /* CLOG page is being + * written out in */ } ClogPageStatus; /* @@ -134,14 +136,15 @@ typedef struct ClogCtlData { /* * Info for each buffer slot. Page number is undefined when status is - * EMPTY. lru_count is essentially the number of operations since last - * use of this page; the page with highest lru_count is the best candidate - * to replace. + * EMPTY. lru_count is essentially the number of operations since + * last use of this page; the page with highest lru_count is the best + * candidate to replace. */ char *page_buffer[NUM_CLOG_BUFFERS]; - ClogPageStatus page_status[NUM_CLOG_BUFFERS]; + ClogPageStatus page_status[NUM_CLOG_BUFFERS]; int page_number[NUM_CLOG_BUFFERS]; - unsigned int page_lru_count[NUM_CLOG_BUFFERS]; + unsigned int page_lru_count[NUM_CLOG_BUFFERS]; + /* * latest_page_number is the page number of the current end of the * CLOG; this is not critical data, since we use it only to avoid @@ -157,7 +160,7 @@ static ClogCtlData *ClogCtl = NULL; * The value is automatically inherited by backends via fork, and * doesn't need to be in shared memory. */ -static LWLockId ClogBufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */ +static LWLockId ClogBufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */ /* * ClogDir is set during CLOGShmemInit and does not change thereafter. @@ -166,7 +169,7 @@ static LWLockId ClogBufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */ */ static char ClogDir[MAXPGPATH]; -#define ClogFileName(path, seg) \ +#define ClogFileName(path, seg) \ snprintf(path, MAXPGPATH, "%s/%04X", ClogDir, seg) /* @@ -430,7 +433,7 @@ ReadCLOGPage(int pageno) LWLockAcquire(CLogControlLock, LW_EXCLUSIVE); Assert(ClogCtl->page_number[slotno] == pageno && - ClogCtl->page_status[slotno] == CLOG_PAGE_READ_IN_PROGRESS); + ClogCtl->page_status[slotno] == CLOG_PAGE_READ_IN_PROGRESS); ClogCtl->page_status[slotno] = CLOG_PAGE_CLEAN; @@ -447,7 +450,7 @@ ReadCLOGPage(int pageno) * * NOTE: only one write attempt is made here. Hence, it is possible that * the page is still dirty at exit (if someone else re-dirtied it during - * the write). However, we *do* attempt a fresh write even if the page + * the write). However, we *do* attempt a fresh write even if the page * is already being written; this is for checkpoints. * * Control lock must be held at entry, and will be held at exit. @@ -455,7 +458,7 @@ ReadCLOGPage(int pageno) static void WriteCLOGPage(int slotno) { - int pageno; + int pageno; /* Do nothing if page does not need writing */ if (ClogCtl->page_status[slotno] != CLOG_PAGE_DIRTY && @@ -489,11 +492,12 @@ WriteCLOGPage(int slotno) * update on this page will mark it dirty again. NB: we are assuming * that read/write of the page status field is atomic, since we change * the state while not holding control lock. However, we cannot set - * this state any sooner, or we'd possibly fool a previous writer - * into thinking he's successfully dumped the page when he hasn't. - * (Scenario: other writer starts, page is redirtied, we come along and - * set WRITE_IN_PROGRESS again, other writer completes and sets CLEAN - * because redirty info has been lost, then we think it's clean too.) + * this state any sooner, or we'd possibly fool a previous writer into + * thinking he's successfully dumped the page when he hasn't. + * (Scenario: other writer starts, page is redirtied, we come along + * and set WRITE_IN_PROGRESS again, other writer completes and sets + * CLEAN because redirty info has been lost, then we think it's clean + * too.) */ ClogCtl->page_status[slotno] = CLOG_PAGE_WRITE_IN_PROGRESS; @@ -523,7 +527,7 @@ WriteCLOGPage(int slotno) static void CLOGPhysicalReadPage(int pageno, int slotno) { - int segno = pageno / CLOG_PAGES_PER_SEGMENT; + int segno = pageno / CLOG_PAGES_PER_SEGMENT; int rpageno = pageno % CLOG_PAGES_PER_SEGMENT; int offset = rpageno * CLOG_BLCKSZ; char path[MAXPGPATH]; @@ -533,9 +537,9 @@ CLOGPhysicalReadPage(int pageno, int slotno) /* * In a crash-and-restart situation, it's possible for us to receive - * commands to set the commit status of transactions whose bits are - * in already-truncated segments of the commit log (see notes in - * CLOGPhysicalWritePage). Hence, if we are InRecovery, allow the + * commands to set the commit status of transactions whose bits are in + * already-truncated segments of the commit log (see notes in + * CLOGPhysicalWritePage). Hence, if we are InRecovery, allow the * case where the file doesn't exist, and return zeroes instead. */ fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); @@ -569,7 +573,7 @@ CLOGPhysicalReadPage(int pageno, int slotno) static void CLOGPhysicalWritePage(int pageno, int slotno) { - int segno = pageno / CLOG_PAGES_PER_SEGMENT; + int segno = pageno / CLOG_PAGES_PER_SEGMENT; int rpageno = pageno % CLOG_PAGES_PER_SEGMENT; int offset = rpageno * CLOG_BLCKSZ; char path[MAXPGPATH]; @@ -578,16 +582,17 @@ CLOGPhysicalWritePage(int pageno, int slotno) ClogFileName(path, segno); /* - * If the file doesn't already exist, we should create it. It is possible - * for this to need to happen when writing a page that's not first in - * its segment; we assume the OS can cope with that. (Note: it might seem - * that it'd be okay to create files only when ZeroCLOGPage is called for - * the first page of a segment. However, if after a crash and restart - * the REDO logic elects to replay the log from a checkpoint before the - * latest one, then it's possible that we will get commands to set - * transaction status of transactions that have already been truncated - * from the commit log. Easiest way to deal with that is to accept - * references to nonexistent files here and in CLOGPhysicalReadPage.) + * If the file doesn't already exist, we should create it. It is + * possible for this to need to happen when writing a page that's not + * first in its segment; we assume the OS can cope with that. (Note: + * it might seem that it'd be okay to create files only when + * ZeroCLOGPage is called for the first page of a segment. However, + * if after a crash and restart the REDO logic elects to replay the + * log from a checkpoint before the latest one, then it's possible + * that we will get commands to set transaction status of transactions + * that have already been truncated from the commit log. Easiest way + * to deal with that is to accept references to nonexistent files here + * and in CLOGPhysicalReadPage.) */ fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) @@ -649,16 +654,15 @@ SelectLRUCLOGPage(int pageno) } /* - * If we find any EMPTY slot, just select that one. - * Else locate the least-recently-used slot that isn't the - * latest CLOG page. + * If we find any EMPTY slot, just select that one. Else locate + * the least-recently-used slot that isn't the latest CLOG page. */ for (slotno = 0; slotno < NUM_CLOG_BUFFERS; slotno++) { if (ClogCtl->page_status[slotno] == CLOG_PAGE_EMPTY) return slotno; if (ClogCtl->page_lru_count[slotno] > bestcount && - ClogCtl->page_number[slotno] != ClogCtl->latest_page_number) + ClogCtl->page_number[slotno] != ClogCtl->latest_page_number) { bestslot = slotno; bestcount = ClogCtl->page_lru_count[slotno]; @@ -672,10 +676,10 @@ SelectLRUCLOGPage(int pageno) return bestslot; /* - * We need to do I/O. Normal case is that we have to write it out, - * but it's possible in the worst case to have selected a read-busy - * page. In that case we use ReadCLOGPage to wait for the read to - * complete. + * We need to do I/O. Normal case is that we have to write it + * out, but it's possible in the worst case to have selected a + * read-busy page. In that case we use ReadCLOGPage to wait for + * the read to complete. */ if (ClogCtl->page_status[bestslot] == CLOG_PAGE_READ_IN_PROGRESS) (void) ReadCLOGPage(ClogCtl->page_number[bestslot]); @@ -683,9 +687,9 @@ SelectLRUCLOGPage(int pageno) WriteCLOGPage(bestslot); /* - * Now loop back and try again. This is the easiest way of dealing - * with corner cases such as the victim page being re-dirtied while - * we wrote it. + * Now loop back and try again. This is the easiest way of + * dealing with corner cases such as the victim page being + * re-dirtied while we wrote it. */ } } @@ -736,6 +740,7 @@ CheckPointCLOG(void) for (slotno = 0; slotno < NUM_CLOG_BUFFERS; slotno++) { WriteCLOGPage(slotno); + /* * We cannot assert that the slot is clean now, since another * process might have re-dirtied it already. That's okay. @@ -782,13 +787,13 @@ ExtendCLOG(TransactionId newestXact) * Remove all CLOG segments before the one holding the passed transaction ID * * When this is called, we know that the database logically contains no - * reference to transaction IDs older than oldestXact. However, we must + * reference to transaction IDs older than oldestXact. However, we must * not truncate the CLOG until we have performed a checkpoint, to ensure * that no such references remain on disk either; else a crash just after * the truncation might leave us with a problem. Since CLOG segments hold * a large number of transactions, the opportunity to actually remove a * segment is fairly rare, and so it seems best not to do the checkpoint - * unless we have confirmed that there is a removable segment. Therefore + * unless we have confirmed that there is a removable segment. Therefore * we issue the checkpoint command here, not in higher-level code as might * seem cleaner. */ @@ -813,15 +818,16 @@ TruncateCLOG(TransactionId oldestXact) /* * Scan CLOG shared memory and remove any pages preceding the cutoff * page, to ensure we won't rewrite them later. (Any dirty pages - * should have been flushed already during the checkpoint, we're - * just being extra careful here.) + * should have been flushed already during the checkpoint, we're just + * being extra careful here.) */ LWLockAcquire(CLogControlLock, LW_EXCLUSIVE); restart:; + /* - * While we are holding the lock, make an important safety check: - * the planned cutoff point must be <= the current CLOG endpoint page. + * While we are holding the lock, make an important safety check: the + * planned cutoff point must be <= the current CLOG endpoint page. * Otherwise we have already wrapped around, and proceeding with the * truncation would risk removing the current CLOG segment. */ @@ -838,6 +844,7 @@ restart:; continue; if (!CLOGPagePrecedes(ClogCtl->page_number[slotno], cutoffPage)) continue; + /* * If page is CLEAN, just change state to EMPTY (expected case). */ @@ -846,6 +853,7 @@ restart:; ClogCtl->page_status[slotno] = CLOG_PAGE_EMPTY; continue; } + /* * Hmm, we have (or may have) I/O operations acting on the page, * so we've got to wait for them to finish and then start again. @@ -928,9 +936,11 @@ CLOGPagePrecedes(int page1, int page2) TransactionId xid1; TransactionId xid2; - xid1 = (TransactionId) page1 * CLOG_XACTS_PER_PAGE; + xid1 = (TransactionId) page1 *CLOG_XACTS_PER_PAGE; + xid1 += FirstNormalTransactionId; - xid2 = (TransactionId) page2 * CLOG_XACTS_PER_PAGE; + xid2 = (TransactionId) page2 *CLOG_XACTS_PER_PAGE; + xid2 += FirstNormalTransactionId; return TransactionIdPrecedes(xid1, xid2); @@ -966,8 +976,8 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record) if (info == CLOG_ZEROPAGE) { - int pageno; - int slotno; + int pageno; + int slotno; memcpy(&pageno, XLogRecGetData(record), sizeof(int)); @@ -993,7 +1003,7 @@ clog_desc(char *buf, uint8 xl_info, char *rec) if (info == CLOG_ZEROPAGE) { - int pageno; + int pageno; memcpy(&pageno, rec, sizeof(int)); sprintf(buf + strlen(buf), "zeropage: %d", pageno); diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 2a73c045b7..bb94fc27a1 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.48 2001/08/26 16:55:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.49 2001/10/25 05:49:22 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -32,7 +32,7 @@ static void TransactionLogUpdate(TransactionId transactionId, * ---------------- */ static TransactionId cachedTestXid = InvalidTransactionId; -static XidStatus cachedTestXidStatus; +static XidStatus cachedTestXidStatus; /* ---------------------------------------------------------------- @@ -56,8 +56,8 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */ XidStatus xidstatus; /* recorded status of xid */ /* - * Before going to the commit log manager, check our single item cache to - * see if we didn't just check the transaction status a moment ago. + * Before going to the commit log manager, check our single item cache + * to see if we didn't just check the transaction status a moment ago. */ if (TransactionIdEquals(transactionId, cachedTestXid)) return (status == cachedTestXidStatus); @@ -65,7 +65,7 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */ /* * Also, check to see if the transaction ID is a permanent one. */ - if (! TransactionIdIsNormal(transactionId)) + if (!TransactionIdIsNormal(transactionId)) { if (TransactionIdEquals(transactionId, BootstrapTransactionId)) return (status == TRANSACTION_STATUS_COMMITTED); @@ -77,18 +77,18 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */ /* * Get the status. */ - xidstatus = TransactionIdGetStatus(transactionId); - - /* - * DO NOT cache status for unfinished transactions! - */ - if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS) - { - TransactionIdStore(transactionId, &cachedTestXid); - cachedTestXidStatus = xidstatus; - } - - return (status == xidstatus); + xidstatus = TransactionIdGetStatus(transactionId); + + /* + * DO NOT cache status for unfinished transactions! + */ + if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS) + { + TransactionIdStore(transactionId, &cachedTestXid); + cachedTestXidStatus = xidstatus; + } + + return (status == xidstatus); } /* -------------------------------- @@ -197,7 +197,7 @@ TransactionIdIsInProgress(TransactionId transactionId) return TransactionLogTest(transactionId, TRANSACTION_STATUS_IN_PROGRESS); } -#endif /* NOT_USED */ +#endif /* NOT_USED */ /* -------------------------------- * TransactionId Commit @@ -246,7 +246,7 @@ TransactionIdPrecedes(TransactionId id1, TransactionId id2) { /* * If either ID is a permanent XID then we can just do unsigned - * comparison. If both are normal, do a modulo-2^31 comparison. + * comparison. If both are normal, do a modulo-2^31 comparison. */ int32 diff; diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 048080a180..5a56f47e06 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.46 2001/09/29 04:02:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.47 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ VariableCache ShmemVariableCache = NULL; TransactionId GetNewTransactionId(void) { - TransactionId xid; + TransactionId xid; /* * During bootstrap initialization, we return the special bootstrap @@ -48,32 +48,32 @@ GetNewTransactionId(void) TransactionIdAdvance(ShmemVariableCache->nextXid); /* - * If we have just allocated the first XID of a new page of the - * commit log, zero out that commit-log page before returning. - * We must do this while holding XidGenLock, else another xact could - * acquire and commit a later XID before we zero the page. Fortunately, - * a page of the commit log holds 32K or more transactions, so we don't - * have to do this very often. + * If we have just allocated the first XID of a new page of the commit + * log, zero out that commit-log page before returning. We must do + * this while holding XidGenLock, else another xact could acquire and + * commit a later XID before we zero the page. Fortunately, a page of + * the commit log holds 32K or more transactions, so we don't have to + * do this very often. */ ExtendCLOG(xid); /* - * Must set MyProc->xid before releasing XidGenLock. This ensures that - * when GetSnapshotData calls ReadNewTransactionId, all active XIDs - * before the returned value of nextXid are already present in the shared - * PROC array. Else we have a race condition. + * Must set MyProc->xid before releasing XidGenLock. This ensures + * that when GetSnapshotData calls ReadNewTransactionId, all active + * XIDs before the returned value of nextXid are already present in + * the shared PROC array. Else we have a race condition. * * XXX by storing xid into MyProc without acquiring SInvalLock, we are * relying on fetch/store of an xid to be atomic, else other backends - * 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 PROC 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. + * 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 PROC 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 PROC - * its own spinlock used only for fetching/storing that PROC's xid. + * A solution to the atomic-store problem would be to give each PROC its + * own spinlock used only for fetching/storing that PROC's xid. * (SInvalLock would then mean primarily that PROCs couldn't be added/ * removed while holding the lock.) */ @@ -91,7 +91,7 @@ GetNewTransactionId(void) TransactionId ReadNewTransactionId(void) { - TransactionId xid; + TransactionId xid; /* * During bootstrap initialization, we return the special bootstrap @@ -117,16 +117,16 @@ static Oid lastSeenOid = InvalidOid; Oid GetNewObjectId(void) { - Oid result; + Oid result; LWLockAcquire(OidGenLock, LW_EXCLUSIVE); /* * Check for wraparound of the OID counter. We *must* not return 0 * (InvalidOid); and as long as we have to check that, it seems a good - * idea to skip over everything below BootstrapObjectIdData too. (This - * basically just reduces the odds of OID collision right after a wrap - * occurs.) Note we are relying on unsigned comparison here. + * idea to skip over everything below BootstrapObjectIdData too. + * (This basically just reduces the odds of OID collision right after + * a wrap occurs.) Note we are relying on unsigned comparison here. */ if (ShmemVariableCache->nextOid < ((Oid) BootstrapObjectIdData)) { diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index cf9791a8e8..f4dc01adfd 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.112 2001/10/18 17:30:03 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.113 2001/10/25 05:49:22 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -300,7 +300,6 @@ IsTransactionState(void) */ return false; } - #endif /* -------------------------------- @@ -476,7 +475,6 @@ AtStart_Cache(void) static void AtStart_Locks(void) { - /* * at present, it is unknown to me what belongs here -cim 3/18/90 * @@ -492,7 +490,6 @@ AtStart_Locks(void) static void AtStart_Memory(void) { - /* * We shouldn't have any transaction contexts already. */ @@ -717,8 +714,8 @@ RecordTransactionAbort(void) recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_ABORT, &rdata); /* - * There's no need for XLogFlush here, since the default assumption - * would be that we aborted, anyway. + * There's no need for XLogFlush here, since the default + * assumption would be that we aborted, anyway. */ /* Mark the transaction aborted in clog */ @@ -756,7 +753,6 @@ AtAbort_Cache(void) static void AtAbort_Locks(void) { - /* * XXX What if ProcReleaseLocks() fails? (race condition?) * @@ -773,7 +769,6 @@ AtAbort_Locks(void) static void AtAbort_Memory(void) { - /* * Make sure we are in a valid context (not a child of * TransactionCommandContext...). Note that it is possible for this @@ -807,7 +802,6 @@ AtAbort_Memory(void) static void AtCleanup_Memory(void) { - /* * Now that we're "out" of a transaction, have the system allocate * things in the top memory context instead of per-transaction @@ -909,7 +903,6 @@ CurrentXactInProgress(void) { return CurrentTransactionState->state == TRANS_INPROGRESS; } - #endif /* -------------------------------- @@ -965,12 +958,11 @@ CommitTransaction(void) * this must be done _before_ releasing locks we hold and _after_ * RecordTransactionCommit. * - * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked - * by xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot - - * if xid 2' GetSnapshotData sees xid 1 as running then it must see - * xid 0 as running as well or it will see two tuple versions - one - * deleted by xid 1 and one inserted by xid 0. See notes in - * GetSnapshotData. + * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked by + * xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot - if + * xid 2' GetSnapshotData sees xid 1 as running then it must see xid 0 + * as running as well or it will see two tuple versions - one deleted + * by xid 1 and one inserted by xid 0. See notes in GetSnapshotData. */ if (MyProc != (PROC *) NULL) { @@ -1002,7 +994,7 @@ CommitTransaction(void) AtCommit_Memory(); AtEOXact_Files(); - SharedBufferChanged = false;/* safest place to do it */ + SharedBufferChanged = false; /* safest place to do it */ /* Count transaction commit in statistics collector */ pgstat_count_xact_commit(); @@ -1032,8 +1024,8 @@ AbortTransaction(void) /* * Release any LW locks we might be holding as quickly as possible. * (Regular locks, however, must be held till we finish aborting.) - * Releasing LW locks is critical since we might try to grab them again - * while cleaning up! + * Releasing LW locks is critical since we might try to grab them + * again while cleaning up! */ LWLockReleaseAll(); @@ -1105,7 +1097,7 @@ AbortTransaction(void) AtEOXact_Files(); AtAbort_Locks(); - SharedBufferChanged = false;/* safest place to do it */ + SharedBufferChanged = false; /* safest place to do it */ /* Count transaction abort in statistics collector */ pgstat_count_xact_rollback(); @@ -1155,7 +1147,6 @@ StartTransactionCommand(void) switch (s->blockState) { - /* * if we aren't in a transaction block, we just do our usual * start transaction. @@ -1238,7 +1229,6 @@ CommitTransactionCommand(void) switch (s->blockState) { - /* * if we aren't in a transaction block, we just do our usual * transaction commit @@ -1313,7 +1303,6 @@ AbortCurrentTransaction(void) switch (s->blockState) { - /* * if we aren't in a transaction block, we just do the basic * abort & cleanup transaction. @@ -1429,7 +1418,6 @@ EndTransactionBlock(void) */ if (s->blockState == TBLOCK_INPROGRESS) { - /* * here we are in a transaction block which should commit when we * get to the upcoming CommitTransactionCommand() so we set the @@ -1442,7 +1430,6 @@ EndTransactionBlock(void) if (s->blockState == TBLOCK_ABORT) { - /* * here, we are in a transaction block which aborted and since the * AbortTransaction() was already done, we do whatever is needed @@ -1480,7 +1467,6 @@ AbortTransactionBlock(void) */ if (s->blockState == TBLOCK_INPROGRESS) { - /* * here we were inside a transaction block something screwed up * inside the system so we enter the abort state, do the abort @@ -1502,7 +1488,6 @@ AbortTransactionBlock(void) AbortTransaction(); s->blockState = TBLOCK_ENDABORT; } - #endif /* -------------------------------- @@ -1527,7 +1512,6 @@ UserAbortTransactionBlock(void) if (s->blockState == TBLOCK_INPROGRESS) { - /* * here we were inside a transaction block and we got an abort * command from the user, so we move to the abort state, do the diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c index babe7c9a48..cde2713b0f 100644 --- a/src/backend/access/transam/xid.c +++ b/src/backend/access/transam/xid.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xid.c,v 1.33 2001/08/26 16:55:59 tgl Exp $ + * $Id: xid.c,v 1.34 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,7 @@ Datum xidout(PG_FUNCTION_ARGS) { TransactionId transactionId = PG_GETARG_TRANSACTIONID(0); + /* maximum 32 bit unsigned integer representation takes 10 chars */ char *str = palloc(11); @@ -64,7 +65,7 @@ xid_age(PG_FUNCTION_ARGS) TransactionId now = GetCurrentTransactionId(); /* Permanent XIDs are always infinitely old */ - if (! TransactionIdIsNormal(xid)) + if (!TransactionIdIsNormal(xid)) PG_RETURN_INT32(INT_MAX); PG_RETURN_INT32((int32) (now - xid)); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 057ee72d55..8c162ab3f6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, 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.78 2001/09/29 04:02:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.79 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,7 +97,7 @@ char XLOG_archive_dir[MAXPGPATH]; /* null string means * delete 'em */ /* - * XLOGfileslop is used in the code as the allowed "fuzz" in the number of + * XLOGfileslop is used in the code as the allowed "fuzz" in the number of * preallocated XLOG segments --- we try to have at least XLOGfiles advance * segments but no more than XLOGfiles+XLOGfileslop segments. This could * be made a separate GUC variable, but at present I think it's sufficient @@ -215,13 +215,13 @@ typedef struct XLogwrtRqst { XLogRecPtr Write; /* last byte + 1 to write out */ XLogRecPtr Flush; /* last byte + 1 to flush */ -} XLogwrtRqst; +} XLogwrtRqst; typedef struct XLogwrtResult { XLogRecPtr Write; /* last byte + 1 written out */ XLogRecPtr Flush; /* last byte + 1 flushed */ -} XLogwrtResult; +} XLogwrtResult; /* * Shared state data for XLogInsert. @@ -260,8 +260,9 @@ typedef struct XLogCtlData /* * These values do not change after startup, although the pointed-to - * pages and xlblocks values certainly do. Permission to read/write the - * pages and xlblocks values depends on WALInsertLock and WALWriteLock. + * pages and xlblocks values certainly do. Permission to read/write + * the pages and xlblocks values depends on WALInsertLock and + * WALWriteLock. */ char *pages; /* buffers for unwritten XLOG pages */ XLogRecPtr *xlblocks; /* 1st byte ptr-s + BLCKSZ */ @@ -428,8 +429,8 @@ static void XLogWrite(XLogwrtRqst WriteRqst); static int XLogFileInit(uint32 log, uint32 seg, bool *use_existent, bool use_lock); static bool InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath, - bool find_free, int max_advance, - bool use_lock); + bool find_free, int max_advance, + bool use_lock); static int XLogFileOpen(uint32 log, uint32 seg, bool econt); static void PreallocXlogFiles(XLogRecPtr endptr); static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr); @@ -621,8 +622,8 @@ begin:; SpinLockRelease_NoHoldoff(&XLogCtl->info_lck); /* - * If cache is half filled then try to acquire write lock and - * do XLogWrite. Ignore any fractional blocks in performing this check. + * If cache is half filled then try to acquire write lock and do + * XLogWrite. Ignore any fractional blocks in performing this check. */ LogwrtRqst.Write.xrecoff -= LogwrtRqst.Write.xrecoff % BLCKSZ; if (LogwrtRqst.Write.xlogid != LogwrtResult.Write.xlogid || @@ -939,9 +940,7 @@ AdvanceXLInsertBuffer(void) NewPageEndPtr.xrecoff = BLCKSZ; } else - { NewPageEndPtr.xrecoff += BLCKSZ; - } XLogCtl->xlblocks[nextidx] = NewPageEndPtr; NewPage = (XLogPageHeader) (XLogCtl->pages + nextidx * BLCKSZ); Insert->curridx = nextidx; @@ -956,7 +955,7 @@ AdvanceXLInsertBuffer(void) /* And fill the new page's header */ NewPage->xlp_magic = XLOG_PAGE_MAGIC; - /* NewPage->xlp_info = 0; */ /* done by memset */ + /* NewPage->xlp_info = 0; *//* done by memset */ NewPage->xlp_sui = ThisStartUpID; NewPage->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid; NewPage->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ; @@ -985,7 +984,6 @@ XLogWrite(XLogwrtRqst WriteRqst) while (XLByteLT(LogwrtResult.Write, WriteRqst.Write)) { - /* * Make sure we're not ahead of the insert process. This could * happen if we're passed a bogus WriteRqst.Write that is past the @@ -1004,7 +1002,6 @@ XLogWrite(XLogwrtRqst WriteRqst) if (!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg)) { - /* * Switch to new logfile segment. */ @@ -1114,7 +1111,6 @@ XLogWrite(XLogwrtRqst WriteRqst) if (XLByteLT(LogwrtResult.Flush, WriteRqst.Flush) && XLByteLT(LogwrtResult.Flush, LogwrtResult.Write)) { - /* * Could get here without iterating above loop, in which case we * might have no open file or the wrong one. However, we do not @@ -1174,11 +1170,11 @@ XLogFlush(XLogRecPtr record) if (XLOG_DEBUG) { elog(DEBUG, "XLogFlush%s%s: request %X/%X; write %X/%X; flush %X/%X\n", - (IsBootstrapProcessingMode()) ? "(bootstrap)" : "", - (InRedo) ? "(redo)" : "", - record.xlogid, record.xrecoff, - LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff, - LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff); + (IsBootstrapProcessingMode()) ? "(bootstrap)" : "", + (InRedo) ? "(redo)" : "", + record.xlogid, record.xrecoff, + LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff, + LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff); fflush(stderr); } @@ -1240,7 +1236,7 @@ XLogFlush(XLogRecPtr record) if (XLByteLT(LogwrtResult.Flush, record)) elog(STOP, "XLogFlush: request %X/%X is not satisfied --- flushed only to %X/%X", record.xlogid, record.xrecoff, - LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff); + LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff); } LWLockRelease(WALWriteLock); } @@ -1565,8 +1561,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 - * XLOGfiles + XLOGfileslop segments beyond the current + * a future log segment. We allow recycling segments up + * to XLOGfiles + XLOGfileslop segments beyond the current * XLOG location. */ if (InstallXLogFileSegment(endlogId, endlogSeg, path, @@ -1719,7 +1715,6 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer) if (readBuf == NULL) { - /* * First time through, permanently allocate readBuf. We do it * this way, rather than just making a static array, for two @@ -1767,7 +1762,7 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer) readFile = XLogFileOpen(readId, readSeg, (emode == LOG)); if (readFile < 0) goto next_record_is_invalid; - readOff = (uint32) (-1);/* force read to occur below */ + readOff = (uint32) (-1); /* force read to occur below */ } targetPageOff = ((RecPtr->xrecoff % XLogSegSize) / BLCKSZ) * BLCKSZ; @@ -2022,7 +2017,6 @@ WriteControlFile(void) #ifdef USE_LOCALE char *localeptr; - #endif /* @@ -2054,10 +2048,10 @@ WriteControlFile(void) "\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and" "\n\tre-initdb. For more information see the Administrator's Guide.", ControlFile->lc_collate); -#else /* not USE_LOCALE */ +#else /* not USE_LOCALE */ strcpy(ControlFile->lc_collate, "C"); strcpy(ControlFile->lc_ctype, "C"); -#endif /* not USE_LOCALE */ +#endif /* not USE_LOCALE */ /* Contents are protected with a CRC */ INIT_CRC64(ControlFile->crc); @@ -2156,7 +2150,7 @@ ReadControlFile(void) if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) elog(STOP, "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) @@ -2174,7 +2168,7 @@ ReadControlFile(void) #ifdef USE_LOCALE if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL) elog(STOP, - "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); @@ -2184,15 +2178,15 @@ ReadControlFile(void) "\twhich is not recognized by setlocale().\n" "\tIt looks like you need to initdb.", ControlFile->lc_ctype); -#else /* not USE_LOCALE */ +#else /* not USE_LOCALE */ if (strcmp(ControlFile->lc_collate, "C") != 0 || strcmp(ControlFile->lc_ctype, "C") != 0) elog(STOP, - "The database cluster was initialized with LC_COLLATE '%s' and\n" + "The database cluster was initialized with LC_COLLATE '%s' and\n" "\tLC_CTYPE '%s', but the server was compiled without locale support.\n" "\tIt looks like you need to initdb or recompile.", ControlFile->lc_collate, ControlFile->lc_ctype); -#endif /* not USE_LOCALE */ +#endif /* not USE_LOCALE */ } void @@ -2536,7 +2530,7 @@ StartupXLOG(void) { /* nextXid must be beyond record's xid */ if (TransactionIdFollowsOrEquals(record->xl_xid, - ShmemVariableCache->nextXid)) + ShmemVariableCache->nextXid)) { ShmemVariableCache->nextXid = record->xl_xid; TransactionIdAdvance(ShmemVariableCache->nextXid); @@ -2585,8 +2579,8 @@ StartupXLOG(void) Insert->PrevRecord = LastRec; /* - * If the next record will go to the new page - * then initialize for that one. + * If the next record will go to the new page then initialize for that + * one. */ if ((BLCKSZ - EndOfLog.xrecoff % BLCKSZ) < SizeOfXLogRecord) EndOfLog.xrecoff += (BLCKSZ - EndOfLog.xrecoff % BLCKSZ); @@ -2602,9 +2596,7 @@ StartupXLOG(void) NewPageEndPtr.xrecoff = BLCKSZ; } else - { NewPageEndPtr.xrecoff += BLCKSZ; - } XLogCtl->xlblocks[0] = NewPageEndPtr; Insert->currpage->xlp_magic = XLOG_PAGE_MAGIC; if (InRecovery) @@ -2621,9 +2613,10 @@ StartupXLOG(void) XLogCtl->xlblocks[0].xlogid = openLogId; XLogCtl->xlblocks[0].xrecoff = ((EndOfLog.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ; + /* * Tricky point here: readBuf contains the *last* block that the - * LastRec record spans, not the one it starts in. The last block + * LastRec record spans, not the one it starts in. The last block * is indeed the one we want to use. */ Assert(readOff == (XLogCtl->xlblocks[0].xrecoff - BLCKSZ) % XLogSegSize); @@ -2670,7 +2663,6 @@ StartupXLOG(void) if (InRecovery) { - /* * In case we had to use the secondary checkpoint, make sure that * it will still be shown as the secondary checkpoint after this @@ -2748,8 +2740,8 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, if (record->xl_rmid != RM_XLOG_ID) { elog(LOG, (whichChkpt == 1 ? - "invalid resource manager id in primary checkpoint record" : - "invalid resource manager id in secondary checkpoint record")); + "invalid resource manager id in primary checkpoint record" : + "invalid resource manager id in secondary checkpoint record")); return NULL; } if (record->xl_info != XLOG_CHECKPOINT_SHUTDOWN && @@ -2845,11 +2837,11 @@ CreateCheckPoint(bool shutdown) /* * The CheckpointLock can be held for quite a while, which is not good - * because we won't respond to a cancel/die request while waiting for an - * LWLock. (But the alternative of using a regular lock won't work for - * background checkpoint processes, which are not regular backends.) - * So, rather than use a plain LWLockAcquire, use this kluge to allow - * an interrupt to be accepted while we are waiting: + * because we won't respond to a cancel/die request while waiting for + * an LWLock. (But the alternative of using a regular lock won't work + * for background checkpoint processes, which are not regular + * backends.) So, rather than use a plain LWLockAcquire, use this + * kluge to allow an interrupt to be accepted while we are waiting: */ while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE)) { @@ -2996,7 +2988,8 @@ CreateCheckPoint(bool shutdown) * but watch out for case that undo = 0. * * Without UNDO support: just use the redo pointer. This allows xlog - * space to be freed much faster when there are long-running transactions. + * space to be freed much faster when there are long-running + * transactions. */ #ifdef NOT_USED if (ControlFile->checkPointCopy.undo.xrecoff != 0 && @@ -3230,7 +3223,6 @@ assign_xlog_sync_method(const char *method) if (sync_method != new_sync_method || open_sync_bit != new_sync_bit) { - /* * To ensure that no blocks escape unsynced, force an fsync on the * currently open log segment (if any). Also, if the open flag is @@ -3264,7 +3256,7 @@ issue_xlog_fsync(void) { switch (sync_method) { - case SYNC_METHOD_FSYNC: + case SYNC_METHOD_FSYNC: if (pg_fsync(openLogFile) != 0) elog(STOP, "fsync of log file %u, segment %u failed: %m", openLogId, openLogSeg); diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index 2394060a67..e49d543ac8 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.20 2001/10/05 17:28:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.21 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -247,7 +247,7 @@ _xl_remove_hash_entry(XLogRelDesc *rdesc) rdesc->moreRecently->lessRecently = rdesc->lessRecently; hentry = (XLogRelCacheEntry *) hash_search(_xlrelcache, - (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL); + (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL); if (hentry == NULL) elog(STOP, "_xl_remove_hash_entry: file was not found in cache"); @@ -304,9 +304,7 @@ XLogCloseRelationCache(void) hash_seq_init(&status, _xlrelcache); while ((hentry = (XLogRelCacheEntry *) hash_seq_search(&status)) != NULL) - { _xl_remove_hash_entry(hentry->rdesc); - } hash_destroy(_xlrelcache); diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 817ed4c8c8..076b31fb17 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.118 2001/10/19 17:03:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.119 2001/10/25 05:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -188,7 +188,7 @@ usage(void) { fprintf(stderr, gettext("Usage:\n" - " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n" + " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n" " -d debug mode\n" " -D datadir data directory\n" " -F turn off fsync\n" @@ -293,7 +293,7 @@ BootstrapMain(int argc, char *argv[]) { if (!potential_DataDir) { - fprintf(stderr, + fprintf(stderr, gettext("%s does not know where to find the database system data.\n" "You must specify the directory that contains the database system\n" "either by specifying the -D invocation option or by setting the\n" @@ -377,7 +377,7 @@ BootstrapMain(int argc, char *argv[]) case BS_XLOG_CHECKPOINT: if (IsUnderPostmaster) - InitDummyProcess(); /* needed to get LWLocks */ + InitDummyProcess(); /* needed to get LWLocks */ CreateDummyCaches(); CreateCheckPoint(false); SetRedoRecPtr(); @@ -996,7 +996,6 @@ FindStr(char *str, int length, hashnode *mderef) node = hashtable[CompHash(str, length)]; while (node != NULL) { - /* * We must differentiate between string constants that might have * the same value as a identifier and the identifier itself. diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 35352be16b..123dbdd247 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.51 2001/06/18 16:13:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.52 2001/10/25 05:49:22 momjian Exp $ * * NOTES * See acl.h. @@ -61,8 +61,7 @@ dumpacl(Acl *acl) DatumGetCString(DirectFunctionCall1(aclitemout, PointerGetDatum(aip + i)))); } - -#endif /* ACLDEBUG */ +#endif /* ACLDEBUG */ /* @@ -115,8 +114,8 @@ ExecuteGrantStmt(GrantStmt *stmt) relname); /* - * If there's no ACL, create a default using the - * pg_class.relowner field. + * If there's no ACL, create a default using the pg_class.relowner + * field. */ aclDatum = SysCacheGetAttr(RELNAME, tuple, Anum_pg_class_relacl, &isNull); @@ -133,10 +132,10 @@ ExecuteGrantStmt(GrantStmt *stmt) foreach(j, stmt->grantees) { - PrivGrantee *grantee = (PrivGrantee *)lfirst(j); + PrivGrantee *grantee = (PrivGrantee *) lfirst(j); char *granteeString; char *aclString; - AclItem aclitem; + AclItem aclitem; unsigned modechg; if (grantee->username) @@ -162,7 +161,8 @@ ExecuteGrantStmt(GrantStmt *stmt) { replaces[i] = ' '; nulls[i] = ' '; /* ignored if replaces[i]==' ' anyway */ - values[i] = (Datum) NULL; /* ignored if replaces[i]==' ' anyway */ + values[i] = (Datum) NULL; /* ignored if replaces[i]==' ' + * anyway */ } replaces[Anum_pg_class_relacl - 1] = 'r'; values[Anum_pg_class_relacl - 1] = PointerGetDatum(new_acl); @@ -175,6 +175,7 @@ ExecuteGrantStmt(GrantStmt *stmt) { /* keep the catalog indexes up to date */ Relation idescs[Num_pg_class_indices]; + CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); CatalogIndexInsert(idescs, Num_pg_class_indices, relation, newtuple); @@ -322,8 +323,8 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode) } /* - * "World" rights are applicable regardless of the passed-in ID, - * and since they're much the cheapest to check, check 'em first. + * "World" rights are applicable regardless of the passed-in ID, and + * since they're much the cheapest to check, check 'em first. */ if (aidat->ai_idtype != ACL_IDTYPE_WORLD) elog(ERROR, "aclcheck: first entry in ACL is not 'world' entry"); @@ -376,7 +377,7 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode) for (i = 1, aip = aidat + 1; /* skip world entry */ i < num && aip->ai_idtype == ACL_IDTYPE_UID; ++i, ++aip) - /* skip UID entry */; + /* skip UID entry */ ; for (; i < num && aip->ai_idtype == ACL_IDTYPE_GID; ++i, ++aip) diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 89d3072f7b..f78ac28693 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.178 2001/10/22 22:47:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.179 2001/10/25 05:49:22 momjian Exp $ * * * INTERFACE ROUTINES @@ -64,10 +64,10 @@ static void AddNewRelationTuple(Relation pg_class_desc, - Relation new_rel_desc, - Oid new_rel_oid, Oid new_type_oid, - char relkind, bool relhasoids, - char *temp_relname); + Relation new_rel_desc, + Oid new_rel_oid, Oid new_type_oid, + char relkind, bool relhasoids, + char *temp_relname); static void DeleteAttributeTuples(Relation rel); static void DeleteRelationTuple(Relation rel); static void DeleteTypeTuple(Relation rel); @@ -156,7 +156,7 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7}; Form_pg_attribute SystemAttributeDefinition(AttrNumber attno, bool relhasoids) { - if (attno >= 0 || attno < - (int) lengthof(SysAtt)) + if (attno >= 0 || attno < -(int) lengthof(SysAtt)) elog(ERROR, "SystemAttributeDefinition: invalid attribute number %d", attno); if (attno == ObjectIdAttributeNumber && !relhasoids) @@ -167,12 +167,12 @@ SystemAttributeDefinition(AttrNumber attno, bool relhasoids) /* * If the given name is a system attribute name, return a Form_pg_attribute - * pointer for a prototype definition. If not, return NULL. + * pointer for a prototype definition. If not, return NULL. */ Form_pg_attribute SystemAttributeByName(const char *attname, bool relhasoids) { - int j; + int j; for (j = 0; j < (int) lengthof(SysAtt); j++) { @@ -237,8 +237,8 @@ heap_create(char *relname, /* * Real ugly stuff to assign the proper relid in the relation - * descriptor follows. Note that only "bootstrapped" relations - * whose OIDs are hard-coded in pg_class.h need be listed here. + * descriptor follows. Note that only "bootstrapped" relations whose + * OIDs are hard-coded in pg_class.h need be listed here. */ if (relname && IsSystemRelationName(relname)) { @@ -541,7 +541,11 @@ AddNewAttributeTuples(Oid new_rel_oid, /* Fill in the correct relation OID in the copied tuple */ attStruct = (Form_pg_attribute) GETSTRUCT(tup); 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; */ @@ -613,7 +617,7 @@ AddNewRelationTuple(Relation pg_class_desc, case RELKIND_RELATION: case RELKIND_INDEX: case RELKIND_TOASTVALUE: - new_rel_reltup->relpages = 10; /* bogus estimates */ + new_rel_reltup->relpages = 10; /* bogus estimates */ new_rel_reltup->reltuples = 1000; break; case RELKIND_SEQUENCE: @@ -653,7 +657,6 @@ AddNewRelationTuple(Relation pg_class_desc, if (!IsIgnoringSystemIndexes()) { - /* * First, open the catalog indices and insert index tuples for the * new relation. @@ -1735,27 +1738,35 @@ AddRelationRawConstraints(Relation rel, { int i; int j; - bool success; + bool success; List *listptr2; + ccname = (char *) palloc(NAMEDATALEN); /* Loop until we find a non-conflicting constraint name */ /* What happens if this loops forever? */ j = numchecks + 1; - do { + do + { success = true; snprintf(ccname, NAMEDATALEN, "$%d", j); /* Check against old constraints */ for (i = 0; i < numoldchecks; i++) { - if (strcmp(oldchecks[i].ccname, ccname) == 0) { + if (strcmp(oldchecks[i].ccname, ccname) == 0) + { success = false; break; } } - /* Check against other new constraints, if the check hasn't already failed */ - if (success) { + + /* + * Check against other new constraints, if the check + * hasn't already failed + */ + if (success) + { foreach(listptr2, rawConstraints) { Constraint *cdef2 = (Constraint *) lfirst(listptr2); @@ -1765,7 +1776,8 @@ AddRelationRawConstraints(Relation rel, cdef2->raw_expr == NULL || cdef2->name == NULL) continue; - if (strcmp(cdef2->name, ccname) == 0) { + if (strcmp(cdef2->name, ccname) == 0) + { success = false; break; } @@ -1914,59 +1926,60 @@ RemoveRelCheck(Relation rel) int RemoveCheckConstraint(Relation rel, const char *constrName, bool inh) { - Oid relid; - Relation rcrel; - Relation relrel; - Relation inhrel; - Relation relidescs[Num_pg_class_indices]; - TupleDesc tupleDesc; - TupleConstr *oldconstr; - int numoldchecks; - int numchecks; - HeapScanDesc rcscan; - ScanKeyData key[2]; - HeapTuple rctup; - HeapTuple reltup; - Form_pg_class relStruct; - int rel_deleted = 0; - int all_deleted = 0; - - /* Find id of the relation */ - relid = RelationGetRelid(rel); - - /* Process child tables and remove constraints of the - same name. */ - if (inh) - { - List *child, - *children; - - /* This routine is actually in the planner */ - children = find_all_inheritors(relid); - - /* - * find_all_inheritors does the recursive search of the - * inheritance hierarchy, so all we have to do is process all - * of the relids in the list that it returns. - */ - foreach(child, children) - { - Oid childrelid = lfirsti(child); - - if (childrelid == relid) - continue; - inhrel = heap_open(childrelid, AccessExclusiveLock); - all_deleted += RemoveCheckConstraint(inhrel, constrName, false); - heap_close(inhrel, NoLock); - } - } + Oid relid; + Relation rcrel; + Relation relrel; + Relation inhrel; + Relation relidescs[Num_pg_class_indices]; + TupleDesc tupleDesc; + TupleConstr *oldconstr; + int numoldchecks; + int numchecks; + HeapScanDesc rcscan; + ScanKeyData key[2]; + HeapTuple rctup; + HeapTuple reltup; + Form_pg_class relStruct; + int rel_deleted = 0; + int all_deleted = 0; + + /* Find id of the relation */ + relid = RelationGetRelid(rel); + + /* + * Process child tables and remove constraints of the same name. + */ + if (inh) + { + List *child, + *children; + + /* This routine is actually in the planner */ + children = find_all_inheritors(relid); + + /* + * find_all_inheritors does the recursive search of the + * inheritance hierarchy, so all we have to do is process all of + * the relids in the list that it returns. + */ + foreach(child, children) + { + Oid childrelid = lfirsti(child); + + if (childrelid == relid) + continue; + inhrel = heap_open(childrelid, AccessExclusiveLock); + all_deleted += RemoveCheckConstraint(inhrel, constrName, false); + heap_close(inhrel, NoLock); + } + } /* Grab an exclusive lock on the pg_relcheck relation */ rcrel = heap_openr(RelCheckRelationName, RowExclusiveLock); /* - * Create two scan keys. We need to match on the oid of the table - * the CHECK is in and also we need to match the name of the CHECK + * Create two scan keys. We need to match on the oid of the table the + * CHECK is in and also we need to match the name of the CHECK * constraint. */ ScanKeyEntryInitialize(&key[0], 0, Anum_pg_relcheck_rcrelid, @@ -1979,14 +1992,15 @@ RemoveCheckConstraint(Relation rel, const char *constrName, bool inh) rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 2, key); /* - * Scan over the result set, removing any matching entries. Note - * that this has the side-effect of removing ALL CHECK constraints - * that share the specified constraint name. + * Scan over the result set, removing any matching entries. Note that + * this has the side-effect of removing ALL CHECK constraints that + * share the specified constraint name. */ - while (HeapTupleIsValid(rctup = heap_getnext(rcscan, 0))) { + while (HeapTupleIsValid(rctup = heap_getnext(rcscan, 0))) + { simple_heap_delete(rcrel, &rctup->t_self); ++rel_deleted; - ++all_deleted; + ++all_deleted; } /* Clean up after the scan */ @@ -2001,7 +2015,7 @@ RemoveCheckConstraint(Relation rel, const char *constrName, bool inh) * message, but for ALTER TABLE ADD ATTRIBUTE this'd be important.) */ - /* + /* * Get number of existing constraints. */ @@ -2020,7 +2034,7 @@ RemoveCheckConstraint(Relation rel, const char *constrName, bool inh) relrel = heap_openr(RelationRelationName, RowExclusiveLock); reltup = SearchSysCacheCopy(RELOID, - ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0); + ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0); if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup of relation %u failed", diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index b53eab8652..0afb9cf7e4 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.165 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.166 2001/10/25 05:49:22 momjian Exp $ * * * INTERFACE ROUTINES @@ -64,19 +64,19 @@ static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp); static TupleDesc BuildFuncTupleDesc(Oid funcOid, - Oid *classObjectId); + Oid *classObjectId); static TupleDesc ConstructTupleDescriptor(Relation heapRelation, - int numatts, AttrNumber *attNums, - Oid *classObjectId); + int numatts, AttrNumber *attNums, + Oid *classObjectId); static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); static Oid UpdateRelationRelation(Relation indexRelation, char *temp_relname); static void InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid); static void AppendAttributeTuples(Relation indexRelation, int numatts); static void UpdateIndexRelation(Oid indexoid, Oid heapoid, - IndexInfo *indexInfo, - Oid *classOids, - bool primary); + IndexInfo *indexInfo, + Oid *classOids, + bool primary); static Oid IndexGetRelation(Oid indexId); static bool activate_index(Oid indexId, bool activate, bool inplace); @@ -255,7 +255,7 @@ ConstructTupleDescriptor(Relation heapRelation, * here we are indexing on a system attribute (-1...-n) */ from = SystemAttributeDefinition(atnum, - heapRelation->rd_rel->relhasoids); + heapRelation->rd_rel->relhasoids); } else { @@ -319,11 +319,11 @@ ConstructTupleDescriptor(Relation heapRelation, elog(ERROR, "Type %u does not exist", keyType); typeTup = (Form_pg_type) GETSTRUCT(tuple); - to->atttypid = keyType; - to->atttypmod = -1; - to->attlen = typeTup->typlen; - to->attbyval = typeTup->typbyval; - to->attalign = typeTup->typalign; + to->atttypid = keyType; + to->atttypmod = -1; + to->attlen = typeTup->typlen; + to->attbyval = typeTup->typbyval; + to->attalign = typeTup->typalign; to->attstorage = typeTup->typstorage; ReleaseSysCache(tuple); @@ -405,14 +405,15 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid) * Fill in a copy of relevant pg_am entry */ indexRelation->rd_am = AccessMethodObjectIdGetForm(amoid, - CacheMemoryContext); + CacheMemoryContext); + /* - * Set up some additional fields of the index' pg_class entry. - * In particular, initialize knowledge of whether the index is shared. + * Set up some additional fields of the index' pg_class entry. In + * particular, initialize knowledge of whether the index is shared. */ indexRelation->rd_rel->relowner = GetUserId(); indexRelation->rd_rel->relam = amoid; - indexRelation->rd_rel->relisshared = + indexRelation->rd_rel->relisshared = IsSharedSystemRelationName(RelationGetPhysicalRelationName(indexRelation)); indexRelation->rd_rel->relkind = RELKIND_INDEX; indexRelation->rd_rel->relhasoids = false; @@ -521,10 +522,10 @@ AppendAttributeTuples(Relation indexRelation, int numatts) for (i = 0; i < numatts; i++) { /* - * There used to be very grotty code here to set these fields, - * but I think it's unnecessary. They should be set already. + * There used to be very grotty code here to set these fields, but + * I think it's unnecessary. They should be set already. */ - Assert(indexTupDesc->attrs[i]->attnum == i+1); + Assert(indexTupDesc->attrs[i]->attnum == i + 1); Assert(indexTupDesc->attrs[i]->attcacheoff == -1); new_tuple = heap_addheader(Natts_pg_attribute, @@ -592,7 +593,7 @@ UpdateIndexRelation(Oid indexoid, indexForm->indexrelid = indexoid; indexForm->indrelid = heapoid; indexForm->indproc = indexInfo->ii_FuncOid; - indexForm->indisclustered = false; /* not used */ + indexForm->indisclustered = false; /* not used */ indexForm->indisunique = indexInfo->ii_Unique; indexForm->indisprimary = primary; memcpy((char *) &indexForm->indpred, (char *) predText, predLen); @@ -678,7 +679,7 @@ index_create(char *heapRelationName, elog(ERROR, "must index at least one column"); if (heapRelationName && !allow_system_table_mods && - IsSystemRelationName(heapRelationName) && IsNormalProcessingMode()) + IsSystemRelationName(heapRelationName) && IsNormalProcessingMode()) elog(ERROR, "User-defined indexes on system catalogs are not supported"); /* @@ -700,7 +701,7 @@ index_create(char *heapRelationName, else indexTupDesc = ConstructTupleDescriptor(heapRelation, indexInfo->ii_NumKeyAttrs, - indexInfo->ii_KeyAttrNumbers, + indexInfo->ii_KeyAttrNumbers, classObjectId); if (istemp) @@ -825,12 +826,13 @@ index_drop(Oid indexId) * To drop an index safely, we must grab exclusive lock on its parent * table; otherwise there could be other backends using the index! * Exclusive lock on the index alone is insufficient because another - * backend might be in the midst of devising a query plan that will use - * the index. The parser and planner take care to hold an appropriate - * lock on the parent table while working, but having them hold locks on - * all the indexes too seems overly complex. We do grab exclusive lock - * on the index too, just to be safe. Both locks must be held till end of - * transaction, else other backends will still see this index in pg_index. + * backend might be in the midst of devising a query plan that will + * use the index. The parser and planner take care to hold an + * appropriate lock on the parent table while working, but having them + * hold locks on all the indexes too seems overly complex. We do grab + * exclusive lock on the index too, just to be safe. Both locks must + * be held till end of transaction, else other backends will still see + * this index in pg_index. */ heapId = IndexGetRelation(indexId); userHeapRelation = heap_open(heapId, AccessExclusiveLock); @@ -873,8 +875,8 @@ index_drop(Oid indexId) * ensure other backends update their relcache lists of indexes. So, * unconditionally do setRelhasindex(true). * - * Possible future improvement: skip the physical tuple update and - * just send out an invalidation message. + * Possible future improvement: skip the physical tuple update and just + * send out an invalidation message. */ setRelhasindex(heapId, true, false, InvalidOid); @@ -950,7 +952,7 @@ index_drop(Oid indexId) * just once per command, and then use it for (potentially) many tuples. * ---------------- */ -IndexInfo * +IndexInfo * BuildIndexInfo(HeapTuple indexTuple) { Form_pg_index indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); @@ -974,8 +976,8 @@ BuildIndexInfo(HeapTuple indexTuple) * Handle functional index. * * If we have a functional index then the number of attributes defined in - * the index must be 1 (the function's single return value). - * Otherwise it's same as number of keys. + * the index must be 1 (the function's single return value). Otherwise + * it's same as number of keys. */ ii->ii_FuncOid = indexStruct->indproc; @@ -1041,7 +1043,6 @@ FormIndexDatum(IndexInfo *indexInfo, if (OidIsValid(indexInfo->ii_FuncOid)) { - /* * Functional index --- compute the single index attribute */ @@ -1076,7 +1077,6 @@ FormIndexDatum(IndexInfo *indexInfo, } else { - /* * Plain index --- for each attribute we need from the heap tuple, * get the attribute and stick it into the datum and nullv arrays. @@ -1198,7 +1198,7 @@ IndexesAreActive(Oid relid, bool confirmCommitted) * set relhasindex of relation's pg_class entry * * If isprimary is TRUE, we are defining a primary index, so also set - * relhaspkey to TRUE. Otherwise, leave relhaspkey alone. + * relhaspkey to TRUE. Otherwise, leave relhaspkey alone. * * If reltoastidxid is not InvalidOid, also set reltoastidxid to that value. * This is only used for TOAST relations. @@ -1390,7 +1390,7 @@ UpdateStats(Oid relid, double reltuples) Relation pg_class; HeapTuple tuple; HeapTuple newtup; - BlockNumber relpages; + BlockNumber relpages; int i; Form_pg_class rd_rel; Relation idescs[Num_pg_class_indices]; @@ -1473,8 +1473,8 @@ UpdateStats(Oid relid, double reltuples) * when it is actually sizable. See also CREATE TABLE in heap.c. * * Note: this path is also taken during bootstrap, because bootstrap.c - * passes reltuples = 0 after loading a table. We have to estimate some - * number for reltuples based on the actual number of pages. + * passes reltuples = 0 after loading a table. We have to estimate + * some number for reltuples based on the actual number of pages. */ relpages = RelationGetNumberOfBlocks(whichRel); @@ -1492,7 +1492,7 @@ UpdateStats(Oid relid, double reltuples) reltuples = 1000; } else - reltuples = (double) relpages * NTUPLES_PER_PAGE(whichRel->rd_rel->relnatts); + reltuples = (double) relpages *NTUPLES_PER_PAGE(whichRel->rd_rel->relnatts); } /* @@ -1508,7 +1508,6 @@ UpdateStats(Oid relid, double reltuples) */ if (in_place_upd) { - /* * At bootstrap time, we don't need to worry about concurrency or * visibility of changes, so we cheat. Also cheat if REINDEX. @@ -1599,8 +1598,8 @@ index_build(Relation heapRelation, * build procedure does whatever cleanup is needed; in particular, it should * close the heap and index relations. * - * The total count of heap tuples is returned. This is for updating pg_class - * statistics. (It's annoying not to be able to do that here, but we can't + * The total count of heap tuples is returned. This is for updating pg_class + * statistics. (It's annoying not to be able to do that here, but we can't * do it until after the relation is closed.) Note that the index AM itself * must keep track of the number of index tuples; we don't do so here because * the AM might reject some of the tuples for its own reasons, such as being @@ -1658,7 +1657,8 @@ IndexBuildHeapScan(Relation heapRelation, /* * Ok, begin our scan of the base relation. We use SnapshotAny - * because we must retrieve all tuples and do our own time qual checks. + * because we must retrieve all tuples and do our own time qual + * checks. */ if (IsBootstrapProcessingMode()) { @@ -1673,7 +1673,7 @@ IndexBuildHeapScan(Relation heapRelation, scan = heap_beginscan(heapRelation, /* relation */ 0, /* start at end */ - snapshot, /* seeself */ + snapshot, /* seeself */ 0, /* number of keys */ (ScanKey) NULL); /* scan key */ @@ -1689,14 +1689,14 @@ IndexBuildHeapScan(Relation heapRelation, if (snapshot == SnapshotAny) { /* do our own time qual check */ - bool indexIt; - uint16 sv_infomask; + bool indexIt; + uint16 sv_infomask; /* - * HeapTupleSatisfiesVacuum may update tuple's hint status bits. - * We could possibly get away with not locking the buffer here, - * since caller should hold ShareLock on the relation, but let's - * be conservative about it. + * HeapTupleSatisfiesVacuum may update tuple's hint status + * bits. We could possibly get away with not locking the + * buffer here, since caller should hold ShareLock on the + * relation, but let's be conservative about it. */ LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); sv_infomask = heapTuple->t_data->t_infomask; @@ -1712,6 +1712,7 @@ IndexBuildHeapScan(Relation heapRelation, tupleIsAlive = true; break; case HEAPTUPLE_RECENTLY_DEAD: + /* * If tuple is recently deleted then we must index it * anyway to keep VACUUM from complaining. @@ -1720,32 +1721,36 @@ IndexBuildHeapScan(Relation heapRelation, tupleIsAlive = false; break; case HEAPTUPLE_INSERT_IN_PROGRESS: + /* - * Since caller should hold ShareLock or better, we should - * not see any tuples inserted by open transactions --- - * unless it's our own transaction. (Consider INSERT - * followed by CREATE INDEX within a transaction.) + * Since caller should hold ShareLock or better, we + * should not see any tuples inserted by open + * transactions --- unless it's our own transaction. + * (Consider INSERT followed by CREATE INDEX within a + * transaction.) */ - if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin)) + if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin)) elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress"); indexIt = true; tupleIsAlive = true; break; case HEAPTUPLE_DELETE_IN_PROGRESS: + /* - * Since caller should hold ShareLock or better, we should - * not see any tuples deleted by open transactions --- - * unless it's our own transaction. (Consider DELETE - * followed by CREATE INDEX within a transaction.) + * Since caller should hold ShareLock or better, we + * should not see any tuples deleted by open + * transactions --- unless it's our own transaction. + * (Consider DELETE followed by CREATE INDEX within a + * transaction.) */ - if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax)) + if (!TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax)) elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress"); indexIt = true; tupleIsAlive = false; break; default: elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result"); - indexIt = tupleIsAlive = false; /* keep compiler quiet */ + indexIt = tupleIsAlive = false; /* keep compiler quiet */ break; } @@ -1755,7 +1760,7 @@ IndexBuildHeapScan(Relation heapRelation, LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK); - if (! indexIt) + if (!indexIt) continue; } else @@ -1776,7 +1781,7 @@ IndexBuildHeapScan(Relation heapRelation, */ if (predicate != NIL) { - if (! tupleIsAlive) + if (!tupleIsAlive) continue; ExecStoreTuple(heapTuple, slot, InvalidBuffer, false); if (!ExecQual(predicate, econtext, false)) @@ -1785,7 +1790,7 @@ IndexBuildHeapScan(Relation heapRelation, /* * For the current heap tuple, extract all the attributes we use - * in this index, and note which are null. This also performs + * in this index, and note which are null. This also performs * evaluation of the function, if this is a functional index. */ FormIndexDatum(indexInfo, @@ -1797,8 +1802,8 @@ IndexBuildHeapScan(Relation heapRelation, /* * You'd think we should go ahead and build the index tuple here, - * but some index AMs want to do further processing on the - * data first. So pass the attdata and nulls arrays, instead. + * but some index AMs want to do further processing on the data + * first. So pass the attdata and nulls arrays, instead. */ /* Call the AM's callback routine to process the tuple */ @@ -1919,7 +1924,6 @@ reindex_index(Oid indexId, bool force, bool inplace) if (inplace) { - /* * Release any buffers associated with this index. If they're * dirty, they're just dropped without bothering to flush to disk. @@ -2002,11 +2006,12 @@ reindex_relation(Oid relid, bool force) upd_pg_class_inplace = true; /* - * Ensure to hold an exclusive lock throughout the - * transaction. The lock could be less intensive - * but now it's AccessExclusiveLock for simplicity. + * Ensure to hold an exclusive lock throughout the transaction. The + * lock could be less intensive but now it's AccessExclusiveLock for + * simplicity. */ rel = heap_open(relid, AccessExclusiveLock); + /* * ignore the indexes of the target system relation while processing * reindex. @@ -2045,8 +2050,9 @@ reindex_relation(Oid relid, bool force) else elog(ERROR, "the target relation %u is shared", relid); } + /* - * Continue to hold the lock. + * Continue to hold the lock. */ heap_close(rel, NoLock); @@ -2087,7 +2093,6 @@ reindex_relation(Oid relid, bool force) heap_close(indexRelation, AccessShareLock); if (reindexed) { - /* * Ok,we could use the reindexed indexes of the target system * relation now. @@ -2096,7 +2101,6 @@ reindex_relation(Oid relid, bool force) { if (!overwrite && relid == RelOid_pg_class) { - /* * For pg_class, relhasindex should be set to true here in * place. diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 119e125402..f037852bb5 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.39 2001/08/10 15:49:39 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.40 2001/10/25 05:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -167,7 +167,6 @@ AggregateCreate(char *aggName, } else { - /* * If no finalfn, aggregate result type is type of the state value */ diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 97e0b87b9c..efd98b546f 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.62 2001/10/22 19:34:13 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.63 2001/10/25 05:49:23 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -74,7 +74,7 @@ static void OperatorUpd(Oid baseId, Oid commId, Oid negId); static bool validOperatorName(const char *name) { - size_t len = strlen(name); + size_t len = strlen(name); /* Can't be empty or too long */ if (len == 0 || len >= NAMEDATALEN) @@ -90,20 +90,19 @@ validOperatorName(const char *name) return false; /* - * For SQL92 compatibility, '+' and '-' cannot be the - * last char of a multi-char operator unless the operator - * contains chars that are not in SQL92 operators. - * The idea is to lex '=-' as two operators, but not - * to forbid operator names like '?-' that could not be - * sequences of SQL92 operators. + * For SQL92 compatibility, '+' and '-' cannot be the last char of a + * multi-char operator unless the operator contains chars that are not + * in SQL92 operators. The idea is to lex '=-' as two operators, but + * not to forbid operator names like '?-' that could not be sequences + * of SQL92 operators. */ if (len > 1 && - (name[len-1] == '+' || - name[len-1] == '-')) + (name[len - 1] == '+' || + name[len - 1] == '-')) { - int ic; + int ic; - for (ic = len-2; ic >= 0; ic--) + for (ic = len - 2; ic >= 0; ic--) { if (strchr("~!@#^&|`?$%", name[ic])) break; @@ -143,7 +142,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, HeapScanDesc pg_operator_scan; Oid operatorObjectId; HeapTuple tup; - ScanKeyData opKey[3]; + ScanKeyData opKey[3]; /* * form scan key @@ -495,7 +494,7 @@ OperatorDef(char *operatorName, int nargs; NameData oname; TupleDesc tupDesc; - ScanKeyData opKey[3]; + ScanKeyData opKey[3]; operatorObjectId = OperatorGet(operatorName, leftTypeName, @@ -743,7 +742,6 @@ OperatorDef(char *operatorName, } else { - /* * self-linkage to this operator; will fix below. Note * that only self-linkage for commutation makes sense. @@ -867,7 +865,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) char nulls[Natts_pg_operator]; char replaces[Natts_pg_operator]; Datum values[Natts_pg_operator]; - ScanKeyData opKey[1]; + ScanKeyData opKey[1]; for (i = 0; i < Natts_pg_operator; ++i) { diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index e83d35edbf..016b9c1d98 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.61 2001/10/06 23:21:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.62 2001/10/25 05:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,7 +125,6 @@ ProcedureCreate(char *procedureName, if (languageObjectId == SQLlanguageId) { - /* * If this call is defining a set, check if the set is already * defined by looking to see whether this call's function text @@ -230,7 +229,7 @@ ProcedureCreate(char *procedureName, prosrc = procedureName; if (fmgr_internal_function(prosrc) == InvalidOid) elog(ERROR, - "there is no built-in function named \"%s\"", + "there is no built-in function named \"%s\"", prosrc); } @@ -246,7 +245,7 @@ ProcedureCreate(char *procedureName, if (languageObjectId == ClanguageId) { - void *libraryhandle; + void *libraryhandle; /* If link symbol is specified as "-", substitute procedure name */ if (strcmp(prosrc, "-") == 0) @@ -303,7 +302,7 @@ ProcedureCreate(char *procedureName, if (HeapTupleIsValid(oldtup)) { /* There is one; okay to replace it? */ - Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup); + Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup); if (!replace) elog(ERROR, "function %s already exists with same argument types", @@ -311,6 +310,7 @@ ProcedureCreate(char *procedureName, if (GetUserId() != oldproc->proowner && !superuser()) elog(ERROR, "ProcedureCreate: you do not have permission to replace function %s", procedureName); + /* * Not okay to change the return type of the existing proc, since * existing rules, views, etc may depend on the return type. @@ -321,8 +321,8 @@ ProcedureCreate(char *procedureName, "\n\tUse DROP FUNCTION first."); /* Okay, do it... */ - tup = heap_modifytuple(oldtup, rel, values, nulls, replaces); - simple_heap_update(rel, &tup->t_self, tup); + tup = heap_modifytuple(oldtup, rel, values, nulls, replaces); + simple_heap_update(rel, &tup->t_self, tup); ReleaseSysCache(oldtup); } @@ -412,8 +412,8 @@ checkretval(Oid rettype, 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.) */ typerelid = typeidTypeRelid(rettype); if (typerelid == InvalidOid) @@ -433,9 +433,9 @@ checkretval(Oid rettype, List *queryTreeList) /* * 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. + * 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) { diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index b79bd7068f..f14d06e0e2 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.64 2001/10/12 00:07:14 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.65 2001/10/25 05:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -318,13 +318,13 @@ TypeCreate(char *typeName, } /* - * validate size specifications: either positive (fixed-length) or - * -1 (variable-length). + * validate size specifications: either positive (fixed-length) or -1 + * (variable-length). */ - if (! (internalSize > 0 || internalSize == -1)) + if (!(internalSize > 0 || internalSize == -1)) elog(ERROR, "TypeCreate: invalid type internal size %d", internalSize); - if (! (externalSize > 0 || externalSize == -1)) + if (!(externalSize > 0 || externalSize == -1)) elog(ERROR, "TypeCreate: invalid type external size %d", externalSize); @@ -382,7 +382,6 @@ TypeCreate(char *typeName, if (!OidIsValid(procOid)) { - /* * For array types, the input procedures may take 3 args (data * value, element OID, atttypmod); the pg_proc argtype @@ -434,7 +433,7 @@ TypeCreate(char *typeName, */ if (defaultTypeValue) values[i] = DirectFunctionCall1(textin, - CStringGetDatum(defaultTypeValue)); + CStringGetDatum(defaultTypeValue)); else nulls[i] = 'n'; i++; /* 17 */ diff --git a/src/backend/commands/_deadcode/recipe.c b/src/backend/commands/_deadcode/recipe.c index 15a1d0a564..3cc26fa51c 100644 --- a/src/backend/commands/_deadcode/recipe.c +++ b/src/backend/commands/_deadcode/recipe.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.13 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.14 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -431,7 +431,6 @@ tg_replaceNumberedParam(Node *expression, { case T_Param: { - /* * the node is a parameter, substitute the entry from the * target list of the child that corresponds to the @@ -445,7 +444,6 @@ tg_replaceNumberedParam(Node *expression, if (p->param_tlist) { - /* * we have a parameter with an attribute like * $N.foo so replace it with a new var node @@ -506,7 +504,6 @@ tg_replaceNumberedParam(Node *expression, break; case T_Expr: { - /* * the node is an expression, we need to recursively call * ourselves until we find parameter nodes @@ -578,7 +575,6 @@ tg_rewriteParamsInExpr(Node *expression, QueryTreeList * inputQlist) { case T_Param: { - /* * the node is a parameter, substitute the entry from the * target list of the child that corresponds to the @@ -594,7 +590,6 @@ tg_rewriteParamsInExpr(Node *expression, QueryTreeList * inputQlist) if (p->param_tlist) { - /* * we have a parameter with an attribute like * $N.foo so match the resname "foo" against the @@ -634,7 +629,6 @@ tg_rewriteParamsInExpr(Node *expression, QueryTreeList * inputQlist) break; case T_Expr: { - /* * the node is an expression, we need to recursively call * ourselves until we find parameter nodes @@ -834,7 +828,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) { case TG_SQL: { - /* * for SQL ingredients, the SQL query is contained in * the 'src' field @@ -940,7 +933,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) } else if (n->nodeType == TG_EYE_NODE) { - /* * if we hit an eye, we need to stop and make what we have into a * subrecipe query block @@ -949,7 +941,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) } else if (n->nodeType == TG_TEE_NODE) { - /* * if we hit a tee, check to see if the parsing has been done for * this tee already by the other parent @@ -958,7 +949,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) rel = RelationNameGetRelation(n->nodeName); if (RelationIsValid(rel)) { - /* * this tee has already been visited, no need to do any * further processing @@ -1014,7 +1004,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) if (RelationIsValid(rel)) { - /* * for complex types, create new relation with the same * tuple descriptor as the output table type @@ -1028,7 +1017,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) } else { - /* * we have to create a relation with one attribute of the * simple base type. That attribute will have an attr @@ -1197,7 +1185,6 @@ replaceSeqScan(Plan *plan, Plan *parent, snode = (Scan *) plan; if (snode->scanrelid == rt_ind) { - /* * found the sequential scan that should be replaced with the * tplan. @@ -1328,5 +1315,4 @@ replaceTeeScans(Plan *plan, Query *parsetree, TeeInfo * teeInfo) } - #endif /* TIOGA */ diff --git a/src/backend/commands/_deadcode/recipe.h b/src/backend/commands/_deadcode/recipe.h index 7ac908fa7c..11dafaefa7 100644 --- a/src/backend/commands/_deadcode/recipe.h +++ b/src/backend/commands/_deadcode/recipe.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: recipe.h,v 1.3 2001/01/24 19:42:53 momjian Exp $ + * $Id: recipe.h,v 1.4 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,5 +16,4 @@ #include "nodes/parsenodes.h" extern void beginRecipe(RecipeStmt *stmt); - #endif /* RECIPE_H */ diff --git a/src/backend/commands/_deadcode/version.c b/src/backend/commands/_deadcode/version.c index 2b8b3b6345..3a5170e86a 100644 --- a/src/backend/commands/_deadcode/version.c +++ b/src/backend/commands/_deadcode/version.c @@ -10,7 +10,7 @@ * doesn't work! - jolly 8/19/95 * * - * $Id: version.c,v 1.26 2001/03/23 04:49:52 momjian Exp $ + * $Id: version.c,v 1.27 2001/10/25 05:49:27 momjian Exp $ * * NOTES * At the point the version is defined, 2 physical relations are created @@ -87,7 +87,6 @@ eval_as_new_xact(char *query) CommandCounterIncrement(); pg_exec_query(query); } - #endif /* * Define a version. @@ -129,7 +128,6 @@ DefineVersion(char *name, char *fromRelname, char *date) VersionReplace(name, saved_basename, saved_snapshot); VersionRetrieve(name, saved_basename, saved_snapshot); } - #endif /* @@ -162,7 +160,6 @@ VersionCreate(char *vname, char *bname) sprintf(query_buf, "CREATE TABLE %s_del (DOID oid)", vname); eval_as_new_xact(query_buf); } - #endif @@ -210,7 +207,6 @@ setAttrList(char *bname) return; } - #endif /* @@ -228,7 +224,6 @@ VersionAppend(char *vname, char *bname) eval_as_new_xact(rule_buf); } - #endif /* @@ -257,7 +252,6 @@ where _%s.oid !!= '%s_del.DOID'", /* printf("%s\n",rule_buf); */ } - #endif /* @@ -295,7 +289,6 @@ VersionDelete(char *vname, char *bname, char *snapshot) eval_as_new_xact(rule_buf); #endif /* OLD_REWRITE */ } - #endif /* @@ -349,5 +342,4 @@ VersionReplace(char *vname, char *bname, char *snapshot) /* printf("%s\n",rule_buf); */ } - #endif diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index e7a7d5c066..41c863a5ba 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.22 2001/07/05 19:33:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.23 2001/10/25 05:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,9 +37,11 @@ /* * Analysis algorithms supported */ -typedef enum { +typedef enum +{ ALG_MINIMAL = 1, /* Compute only most-common-values */ - ALG_SCALAR /* Compute MCV, histogram, sort correlation */ + ALG_SCALAR /* Compute MCV, histogram, sort + * correlation */ } AlgCode; /* @@ -70,7 +72,10 @@ typedef struct Oid eqfunc; /* and associated function */ Oid ltopr; /* '<' operator for datatype, if any */ - /* These fields are filled in by the actual statistics-gathering routine */ + /* + * These fields are filled in by the actual statistics-gathering + * routine + */ bool stats_valid; float4 stanullfrac; /* fraction of entries that are NULL */ int4 stawidth; /* average width */ @@ -101,7 +106,7 @@ typedef struct #define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0) -static int MESSAGE_LEVEL; +static int MESSAGE_LEVEL; /* context information for compare_scalars() */ static FmgrInfo *datumCmpFn; @@ -111,19 +116,19 @@ static int *datumCmpTupnoLink; static VacAttrStats *examine_attribute(Relation onerel, int attnum); static int acquire_sample_rows(Relation onerel, HeapTuple *rows, - int targrows, double *totalrows); + int targrows, double *totalrows); static double random_fract(void); static double init_selection_state(int n); static double select_next_random_record(double t, int n, double *stateptr); -static int compare_rows(const void *a, const void *b); -static int compare_scalars(const void *a, const void *b); -static int compare_mcvs(const void *a, const void *b); +static int compare_rows(const void *a, const void *b); +static int compare_scalars(const void *a, const void *b); +static int compare_mcvs(const void *a, const void *b); static void compute_minimal_stats(VacAttrStats *stats, - TupleDesc tupDesc, double totalrows, - HeapTuple *rows, int numrows); + TupleDesc tupDesc, double totalrows, + HeapTuple *rows, int numrows); static void compute_scalar_stats(VacAttrStats *stats, - TupleDesc tupDesc, double totalrows, - HeapTuple *rows, int numrows); + TupleDesc tupDesc, double totalrows, + HeapTuple *rows, int numrows); static void update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats); @@ -154,8 +159,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) * Begin a transaction for analyzing this relation. * * Note: All memory allocated during ANALYZE will live in - * TransactionCommandContext or a subcontext thereof, so it will - * all be released by transaction commit at the end of this routine. + * TransactionCommandContext or a subcontext thereof, so it will all + * be released by transaction commit at the end of this routine. */ StartTransactionCommand(); @@ -191,14 +196,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) ReleaseSysCache(tuple); /* - * Open the class, getting only a read lock on it, and check permissions. - * Permissions check should match vacuum's check! + * Open the class, getting only a read lock on it, and check + * permissions. Permissions check should match vacuum's check! */ onerel = heap_open(relid, AccessShareLock); - if (! (pg_ownercheck(GetUserId(), RelationGetRelationName(onerel), - RELNAME) || - (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared))) + if (!(pg_ownercheck(GetUserId(), RelationGetRelationName(onerel), + RELNAME) || + (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared))) { /* No need for a notice if we already complained during VACUUM */ if (!vacstmt->vacuum) @@ -238,7 +243,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) if (i >= attr_cnt) elog(ERROR, "ANALYZE: there is no attribute %s in %s", col, RelationGetRelationName(onerel)); - vacattrstats[tcnt] = examine_attribute(onerel, i+1); + vacattrstats[tcnt] = examine_attribute(onerel, i + 1); if (vacattrstats[tcnt] != NULL) tcnt++; } @@ -251,7 +256,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) tcnt = 0; for (i = 0; i < attr_cnt; i++) { - vacattrstats[tcnt] = examine_attribute(onerel, i+1); + vacattrstats[tcnt] = examine_attribute(onerel, i + 1); if (vacattrstats[tcnt] != NULL) tcnt++; } @@ -270,8 +275,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * Determine how many rows we need to sample, using the worst case - * from all analyzable columns. We use a lower bound of 100 rows - * to avoid possible overflow in Vitter's algorithm. + * from all analyzable columns. We use a lower bound of 100 rows to + * avoid possible overflow in Vitter's algorithm. */ targrows = 100; for (i = 0; i < attr_cnt; i++) @@ -289,8 +294,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * If we are running a standalone ANALYZE, update pages/tuples stats * in pg_class. We have the accurate page count from heap_beginscan, - * but only an approximate number of tuples; therefore, if we are - * part of VACUUM ANALYZE do *not* overwrite the accurate count already + * but only an approximate number of tuples; therefore, if we are part + * of VACUUM ANALYZE do *not* overwrite the accurate count already * inserted by VACUUM. */ if (!vacstmt->vacuum) @@ -300,7 +305,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) RelationGetForm(onerel)->relhasindex); /* - * Compute the statistics. Temporary results during the calculations + * Compute the statistics. Temporary results during the calculations * for each column are stored in a child context. The calc routines * are responsible to make sure that whatever they store into the * VacAttrStats structure is allocated in TransactionCommandContext. @@ -338,8 +343,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * Emit the completed stats rows into pg_statistic, replacing any - * previous statistics for the target columns. (If there are stats - * in pg_statistic for columns we didn't process, we leave them alone.) + * previous statistics for the target columns. (If there are + * stats in pg_statistic for columns we didn't process, we leave + * them alone.) */ update_attstats(relid, attr_cnt, vacattrstats); } @@ -364,7 +370,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) static VacAttrStats * examine_attribute(Relation onerel, int attnum) { - Form_pg_attribute attr = onerel->rd_att->attrs[attnum-1]; + Form_pg_attribute attr = onerel->rd_att->attrs[attnum - 1]; Operator func_operator; Oid oprrest; HeapTuple typtuple; @@ -396,8 +402,8 @@ examine_attribute(Relation onerel, int attnum) return NULL; /* - * If we have "=" then we're at least able to do the minimal algorithm, - * so start filling in a VacAttrStats struct. + * If we have "=" then we're at least able to do the minimal + * algorithm, so start filling in a VacAttrStats struct. */ stats = (VacAttrStats *) palloc(sizeof(VacAttrStats)); MemSet(stats, 0, sizeof(VacAttrStats)); @@ -424,15 +430,14 @@ examine_attribute(Relation onerel, int attnum) { oprrest = ((Form_pg_operator) GETSTRUCT(func_operator))->oprrest; if (oprrest == F_SCALARLTSEL) - { ltopr = oprid(func_operator); - } ReleaseSysCache(func_operator); } stats->ltopr = ltopr; /* - * Determine the algorithm to use (this will get more complicated later) + * Determine the algorithm to use (this will get more complicated + * later) */ if (OidIsValid(ltopr)) { @@ -474,7 +479,7 @@ examine_attribute(Relation onerel, int attnum) * acquire_sample_rows -- acquire a random sample of rows from the table * * Up to targrows rows are collected (if there are fewer than that many - * rows in the table, all rows are collected). When the table is larger + * rows in the table, all rows are collected). When the table is larger * than targrows, a truly random sample is collected: every row has an * equal chance of ending up in the final sample. * @@ -491,8 +496,8 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, int numrows = 0; HeapScanDesc scan; HeapTuple tuple; - ItemPointer lasttuple; - BlockNumber lastblock, + ItemPointer lasttuple; + BlockNumber lastblock, estblock; OffsetNumber lastoffset; int numest; @@ -501,6 +506,7 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, double rstate; Assert(targrows > 1); + /* * Do a simple linear scan until we reach the target number of rows. */ @@ -512,8 +518,9 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, break; } heap_endscan(scan); + /* - * If we ran out of tuples then we're done, no matter how few we + * If we ran out of tuples then we're done, no matter how few we * collected. No sort is needed, since they're already in order. */ if (!HeapTupleIsValid(tuple)) @@ -521,35 +528,40 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, *totalrows = (double) numrows; return numrows; } + /* * Otherwise, start replacing tuples in the sample until we reach the * end of the relation. This algorithm is from Jeff Vitter's paper - * (see full citation below). It works by repeatedly computing the number - * of the next tuple we want to fetch, which will replace a randomly - * chosen element of the reservoir (current set of tuples). At all times - * the reservoir is a true random sample of the tuples we've passed over - * so far, so when we fall off the end of the relation we're done. + * (see full citation below). It works by repeatedly computing the + * number of the next tuple we want to fetch, which will replace a + * randomly chosen element of the reservoir (current set of tuples). + * At all times the reservoir is a true random sample of the tuples + * we've passed over so far, so when we fall off the end of the + * relation we're done. * - * A slight difficulty is that since we don't want to fetch tuples or even - * pages that we skip over, it's not possible to fetch *exactly* the N'th - * tuple at each step --- we don't know how many valid tuples are on - * the skipped pages. We handle this by assuming that the average number - * of valid tuples/page on the pages already scanned over holds good for - * the rest of the relation as well; this lets us estimate which page - * the next tuple should be on and its position in the page. Then we - * fetch the first valid tuple at or after that position, being careful - * not to use the same tuple twice. This approach should still give a - * good random sample, although it's not perfect. + * A slight difficulty is that since we don't want to fetch tuples or + * even pages that we skip over, it's not possible to fetch *exactly* + * the N'th tuple at each step --- we don't know how many valid tuples + * are on the skipped pages. We handle this by assuming that the + * average number of valid tuples/page on the pages already scanned + * over holds good for the rest of the relation as well; this lets us + * estimate which page the next tuple should be on and its position in + * the page. Then we fetch the first valid tuple at or after that + * position, being careful not to use the same tuple twice. This + * approach should still give a good random sample, although it's not + * perfect. */ - lasttuple = &(rows[numrows-1]->t_self); + lasttuple = &(rows[numrows - 1]->t_self); lastblock = ItemPointerGetBlockNumber(lasttuple); lastoffset = ItemPointerGetOffsetNumber(lasttuple); + /* - * If possible, estimate tuples/page using only completely-scanned pages. + * If possible, estimate tuples/page using only completely-scanned + * pages. */ for (numest = numrows; numest > 0; numest--) { - if (ItemPointerGetBlockNumber(&(rows[numest-1]->t_self)) != lastblock) + if (ItemPointerGetBlockNumber(&(rows[numest - 1]->t_self)) != lastblock) break; } if (numest == 0) @@ -558,27 +570,25 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, estblock = lastblock + 1; } else - { estblock = lastblock; - } tuplesperpage = (double) numest / (double) estblock; t = (double) numrows; /* t is the # of records processed so far */ rstate = init_selection_state(targrows); for (;;) { - double targpos; - BlockNumber targblock; - Buffer targbuffer; - Page targpage; - OffsetNumber targoffset, - maxoffset; + double targpos; + BlockNumber targblock; + Buffer targbuffer; + Page targpage; + OffsetNumber targoffset, + maxoffset; t = select_next_random_record(t, targrows, &rstate); /* Try to read the t'th record in the table */ targpos = t / tuplesperpage; targblock = (BlockNumber) targpos; - targoffset = ((int) ((targpos - targblock) * tuplesperpage)) + + targoffset = ((int) ((targpos - targblock) * tuplesperpage)) + FirstOffsetNumber; /* Make sure we are past the last selected record */ if (targblock <= lastblock) @@ -588,19 +598,22 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, targoffset = lastoffset + 1; } /* Loop to find first valid record at or after given position */ - pageloop:; +pageloop:; + /* - * Have we fallen off the end of the relation? (We rely on + * Have we fallen off the end of the relation? (We rely on * heap_beginscan to have updated rd_nblocks.) */ if (targblock >= onerel->rd_nblocks) break; + /* - * We must maintain a pin on the target page's buffer to ensure that - * the maxoffset value stays good (else concurrent VACUUM might - * delete tuples out from under us). Hence, pin the page until we - * are done looking at it. We don't maintain a lock on the page, - * so tuples could get added to it, but we ignore such tuples. + * We must maintain a pin on the target page's buffer to ensure + * that the maxoffset value stays good (else concurrent VACUUM + * might delete tuples out from under us). Hence, pin the page + * until we are done looking at it. We don't maintain a lock on + * the page, so tuples could get added to it, but we ignore such + * tuples. */ targbuffer = ReadBuffer(onerel, targblock); if (!BufferIsValid(targbuffer)) @@ -632,7 +645,7 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, * Found a suitable tuple, so save it, replacing one old * tuple at random */ - int k = (int) (targrows * random_fract()); + int k = (int) (targrows * random_fract()); Assert(k >= 0 && k < targrows); heap_freetuple(rows[k]); @@ -667,13 +680,13 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, static double random_fract(void) { - long z; + long z; /* random() can produce endpoint values, try again if so */ do { z = random(); - } while (! (z > 0 && z < MAX_RANDOM_VALUE)); + } while (!(z > 0 && z < MAX_RANDOM_VALUE)); return (double) z / (double) MAX_RANDOM_VALUE; } @@ -702,7 +715,7 @@ static double init_selection_state(int n) { /* Initial value of W (for use when Algorithm Z is first applied) */ - return exp(- log(random_fract())/n); + return exp(-log(random_fract()) / n); } static double @@ -712,8 +725,8 @@ select_next_random_record(double t, int n, double *stateptr) if (t <= (22.0 * n)) { /* Process records using Algorithm X until t is large enough */ - double V, - quot; + double V, + quot; V = random_fract(); /* Generate V */ t += 1; @@ -728,21 +741,21 @@ select_next_random_record(double t, int n, double *stateptr) else { /* Now apply Algorithm Z */ - double W = *stateptr; - double term = t - (double) n + 1; - double S; + double W = *stateptr; + double term = t - (double) n + 1; + double S; for (;;) { - double numer, - numer_lim, - denom; - double U, - X, - lhs, - rhs, - y, - tmp; + double numer, + numer_lim, + denom; + double U, + X, + lhs, + rhs, + y, + tmp; /* Generate U and X */ U = random_fract(); @@ -750,15 +763,15 @@ select_next_random_record(double t, int n, double *stateptr) S = floor(X); /* S is tentatively set to floor(X) */ /* Test if U <= h(S)/cg(X) in the manner of (6.3) */ tmp = (t + 1) / term; - lhs = exp(log(((U * tmp * tmp) * (term + S))/(t + X))/n); - rhs = (((t + X)/(term + S)) * term)/t; + lhs = exp(log(((U * tmp * tmp) * (term + S)) / (t + X)) / n); + rhs = (((t + X) / (term + S)) * term) / t; if (lhs <= rhs) { - W = rhs/lhs; + W = rhs / lhs; break; } /* Test if U <= f(S)/cg(X) */ - y = (((U * (t + 1))/term) * (t + S + 1))/(t + X); + y = (((U * (t + 1)) / term) * (t + S + 1)) / (t + X); if ((double) n < S) { denom = t; @@ -774,8 +787,8 @@ select_next_random_record(double t, int n, double *stateptr) y *= numer / denom; denom -= 1; } - W = exp(- log(random_fract())/n); /* Generate W in advance */ - if (exp(log(y)/n) <= (t + X)/t) + W = exp(-log(random_fract()) / n); /* Generate W in advance */ + if (exp(log(y) / n) <= (t + X) / t) break; } t += S + 1; @@ -790,11 +803,11 @@ select_next_random_record(double t, int n, double *stateptr) static int compare_rows(const void *a, const void *b) { - HeapTuple ha = * (HeapTuple *) a; - HeapTuple hb = * (HeapTuple *) b; - BlockNumber ba = ItemPointerGetBlockNumber(&ha->t_self); + HeapTuple ha = *(HeapTuple *) a; + HeapTuple hb = *(HeapTuple *) b; + BlockNumber ba = ItemPointerGetBlockNumber(&ha->t_self); OffsetNumber oa = ItemPointerGetOffsetNumber(&ha->t_self); - BlockNumber bb = ItemPointerGetBlockNumber(&hb->t_self); + BlockNumber bb = ItemPointerGetBlockNumber(&hb->t_self); OffsetNumber ob = ItemPointerGetOffsetNumber(&hb->t_self); if (ba < bb) @@ -839,15 +852,18 @@ compute_minimal_stats(VacAttrStats *stats, FmgrInfo f_cmpeq; typedef struct { - Datum value; - int count; + Datum value; + int count; } TrackItem; TrackItem *track; int track_cnt, track_max; int num_mcv = stats->attr->attstattarget; - /* We track up to 2*n values for an n-element MCV list; but at least 10 */ + /* + * We track up to 2*n values for an n-element MCV list; but at least + * 10 + */ track_max = 2 * num_mcv; if (track_max < 10) track_max = 10; @@ -877,19 +893,20 @@ compute_minimal_stats(VacAttrStats *stats, /* * If it's a varlena field, add up widths for average width - * calculation. Note that if the value is toasted, we - * use the toasted width. We don't bother with this calculation - * if it's a fixed-width type. + * calculation. Note that if the value is toasted, we use the + * toasted width. We don't bother with this calculation if it's a + * fixed-width type. */ if (is_varlena) { total_width += VARSIZE(DatumGetPointer(value)); + /* * If the value is toasted, we want to detoast it just once to - * avoid repeated detoastings and resultant excess memory usage - * during the comparisons. Also, check to see if the value is - * excessively wide, and if so don't detoast at all --- just - * ignore the value. + * avoid repeated detoastings and resultant excess memory + * usage during the comparisons. Also, check to see if the + * value is excessively wide, and if so don't detoast at all + * --- just ignore the value. */ if (toast_raw_datum_size(value) > WIDTH_THRESHOLD) { @@ -920,10 +937,10 @@ compute_minimal_stats(VacAttrStats *stats, /* Found a match */ track[j].count++; /* This value may now need to "bubble up" in the track list */ - while (j > 0 && track[j].count > track[j-1].count) + while (j > 0 && track[j].count > track[j - 1].count) { - swapDatum(track[j].value, track[j-1].value); - swapInt(track[j].count, track[j-1].count); + swapDatum(track[j].value, track[j - 1].value); + swapInt(track[j].count, track[j - 1].count); j--; } } @@ -932,10 +949,10 @@ compute_minimal_stats(VacAttrStats *stats, /* No match. Insert at head of count-1 list */ if (track_cnt < track_max) track_cnt++; - for (j = track_cnt-1; j > firstcount1; j--) + for (j = track_cnt - 1; j > firstcount1; j--) { - track[j].value = track[j-1].value; - track[j].count = track[j-1].count; + track[j].value = track[j - 1].value; + track[j].count = track[j - 1].count; } if (firstcount1 < track_cnt) { @@ -948,8 +965,8 @@ compute_minimal_stats(VacAttrStats *stats, /* We can only compute valid stats if we found some non-null values. */ if (nonnull_cnt > 0) { - int nmultiple, - summultiple; + int nmultiple, + summultiple; stats->stats_valid = true; /* Do the simple null-frac and width stats */ @@ -977,9 +994,9 @@ compute_minimal_stats(VacAttrStats *stats, nmultiple == track_cnt) { /* - * Our track list includes every value in the sample, and every - * value appeared more than once. Assume the column has just - * these values. + * Our track list includes every value in the sample, and + * every value appeared more than once. Assume the column has + * just these values. */ stats->stadistinct = track_cnt; } @@ -994,12 +1011,12 @@ compute_minimal_stats(VacAttrStats *stats, * We assume (not very reliably!) that all the multiply-occurring * values are reflected in the final track[] list, and the other * nonnull values all appeared but once. (XXX this usually - * results in a drastic overestimate of ndistinct. Can we do + * results in a drastic overestimate of ndistinct. Can we do * any better?) *---------- */ - int f1 = nonnull_cnt - summultiple; - double term1; + int f1 = nonnull_cnt - summultiple; + double term1; if (f1 < 1) f1 = 1; @@ -1014,16 +1031,16 @@ compute_minimal_stats(VacAttrStats *stats, * a fixed value. */ if (stats->stadistinct > 0.1 * totalrows) - stats->stadistinct = - (stats->stadistinct / totalrows); + stats->stadistinct = -(stats->stadistinct / totalrows); /* * Decide how many values are worth storing as most-common values. * If we are able to generate a complete MCV list (all the values * in the sample will fit, and we think these are all the ones in - * the table), then do so. Otherwise, store only those values - * that are significantly more common than the (estimated) average. - * We set the threshold rather arbitrarily at 25% more than average, - * with at least 2 instances in the sample. + * the table), then do so. Otherwise, store only those values + * that are significantly more common than the (estimated) + * average. We set the threshold rather arbitrarily at 25% more + * than average, with at least 2 instances in the sample. */ if (track_cnt < track_max && toowide_cnt == 0 && stats->stadistinct > 0 && @@ -1034,12 +1051,12 @@ compute_minimal_stats(VacAttrStats *stats, } else { - double ndistinct = stats->stadistinct; - double avgcount, - mincount; + double ndistinct = stats->stadistinct; + double avgcount, + mincount; if (ndistinct < 0) - ndistinct = - ndistinct * totalrows; + ndistinct = -ndistinct * totalrows; /* estimate # of occurrences in sample of a typical value */ avgcount = (double) numrows / ndistinct; /* set minimum threshold count to store a value */ @@ -1062,8 +1079,8 @@ compute_minimal_stats(VacAttrStats *stats, if (num_mcv > 0) { MemoryContext old_context; - Datum *mcv_values; - float4 *mcv_freqs; + Datum *mcv_values; + float4 *mcv_freqs; /* Must copy the target values into TransactionCommandContext */ old_context = MemoryContextSwitchTo(TransactionCommandContext); @@ -1153,19 +1170,20 @@ compute_scalar_stats(VacAttrStats *stats, /* * If it's a varlena field, add up widths for average width - * calculation. Note that if the value is toasted, we - * use the toasted width. We don't bother with this calculation - * if it's a fixed-width type. + * calculation. Note that if the value is toasted, we use the + * toasted width. We don't bother with this calculation if it's a + * fixed-width type. */ if (is_varlena) { total_width += VARSIZE(DatumGetPointer(value)); + /* * If the value is toasted, we want to detoast it just once to - * avoid repeated detoastings and resultant excess memory usage - * during the comparisons. Also, check to see if the value is - * excessively wide, and if so don't detoast at all --- just - * ignore the value. + * avoid repeated detoastings and resultant excess memory + * usage during the comparisons. Also, check to see if the + * value is excessively wide, and if so don't detoast at all + * --- just ignore the value. */ if (toast_raw_datum_size(value) > WIDTH_THRESHOLD) { @@ -1185,11 +1203,11 @@ compute_scalar_stats(VacAttrStats *stats, /* We can only compute valid stats if we found some sortable values. */ if (values_cnt > 0) { - int ndistinct, /* # distinct values in sample */ - nmultiple, /* # that appear multiple times */ - num_hist, - dups_cnt; - int slot_idx = 0; + int ndistinct, /* # distinct values in sample */ + nmultiple, /* # that appear multiple times */ + num_hist, + dups_cnt; + int slot_idx = 0; /* Sort the collected values */ datumCmpFn = &f_cmpfn; @@ -1199,23 +1217,24 @@ compute_scalar_stats(VacAttrStats *stats, sizeof(ScalarItem), compare_scalars); /* - * Now scan the values in order, find the most common ones, - * and also accumulate ordering-correlation statistics. + * Now scan the values in order, find the most common ones, and + * also accumulate ordering-correlation statistics. * * To determine which are most common, we first have to count the - * number of duplicates of each value. The duplicates are adjacent - * in the sorted list, so a brute-force approach is to compare - * successive datum values until we find two that are not equal. - * However, that requires N-1 invocations of the datum comparison - * routine, which are completely redundant with work that was done - * during the sort. (The sort algorithm must at some point have - * compared each pair of items that are adjacent in the sorted order; - * otherwise it could not know that it's ordered the pair correctly.) - * We exploit this by having compare_scalars remember the highest - * tupno index that each ScalarItem has been found equal to. At the - * end of the sort, a ScalarItem's tupnoLink will still point to - * itself if and only if it is the last item of its group of - * duplicates (since the group will be ordered by tupno). + * number of duplicates of each value. The duplicates are + * adjacent in the sorted list, so a brute-force approach is to + * compare successive datum values until we find two that are not + * equal. However, that requires N-1 invocations of the datum + * comparison routine, which are completely redundant with work + * that was done during the sort. (The sort algorithm must at + * some point have compared each pair of items that are adjacent + * in the sorted order; otherwise it could not know that it's + * ordered the pair correctly.) We exploit this by having + * compare_scalars remember the highest tupno index that each + * ScalarItem has been found equal to. At the end of the sort, a + * ScalarItem's tupnoLink will still point to itself if and only + * if it is the last item of its group of duplicates (since the + * group will be ordered by tupno). */ corr_xysum = 0; ndistinct = 0; @@ -1225,7 +1244,8 @@ compute_scalar_stats(VacAttrStats *stats, { int tupno = values[i].tupno; - corr_xysum += (double) i * (double) tupno; + corr_xysum += (double) i *(double) tupno; + dups_cnt++; if (tupnoLink[tupno] == tupno) { @@ -1235,7 +1255,7 @@ compute_scalar_stats(VacAttrStats *stats, { nmultiple++; if (track_cnt < num_mcv || - dups_cnt > track[track_cnt-1].count) + dups_cnt > track[track_cnt - 1].count) { /* * Found a new item for the mcv list; find its @@ -1243,16 +1263,16 @@ compute_scalar_stats(VacAttrStats *stats, * Loop invariant is that j points at an empty/ * replaceable slot. */ - int j; + int j; if (track_cnt < num_mcv) track_cnt++; - for (j = track_cnt-1; j > 0; j--) + for (j = track_cnt - 1; j > 0; j--) { - if (dups_cnt <= track[j-1].count) + if (dups_cnt <= track[j - 1].count) break; - track[j].count = track[j-1].count; - track[j].first = track[j-1].first; + track[j].count = track[j - 1].count; + track[j].first = track[j - 1].first; } track[j].count = dups_cnt; track[j].first = i + 1 - dups_cnt; @@ -1278,8 +1298,8 @@ compute_scalar_stats(VacAttrStats *stats, else if (toowide_cnt == 0 && nmultiple == ndistinct) { /* - * Every value in the sample appeared more than once. Assume the - * column has just these values. + * Every value in the sample appeared more than once. Assume + * the column has just these values. */ stats->stadistinct = ndistinct; } @@ -1294,8 +1314,8 @@ compute_scalar_stats(VacAttrStats *stats, * Overwidth values are assumed to have been distinct. *---------- */ - int f1 = ndistinct - nmultiple + toowide_cnt; - double term1; + int f1 = ndistinct - nmultiple + toowide_cnt; + double term1; if (f1 < 1) f1 = 1; @@ -1310,19 +1330,20 @@ compute_scalar_stats(VacAttrStats *stats, * a fixed value. */ if (stats->stadistinct > 0.1 * totalrows) - stats->stadistinct = - (stats->stadistinct / totalrows); + stats->stadistinct = -(stats->stadistinct / totalrows); /* * Decide how many values are worth storing as most-common values. * If we are able to generate a complete MCV list (all the values * in the sample will fit, and we think these are all the ones in - * the table), then do so. Otherwise, store only those values - * that are significantly more common than the (estimated) average. - * We set the threshold rather arbitrarily at 25% more than average, - * with at least 2 instances in the sample. Also, we won't suppress - * values that have a frequency of at least 1/K where K is the - * intended number of histogram bins; such values might otherwise - * cause us to emit duplicate histogram bin boundaries. + * the table), then do so. Otherwise, store only those values + * that are significantly more common than the (estimated) + * average. We set the threshold rather arbitrarily at 25% more + * than average, with at least 2 instances in the sample. Also, + * we won't suppress values that have a frequency of at least 1/K + * where K is the intended number of histogram bins; such values + * might otherwise cause us to emit duplicate histogram bin + * boundaries. */ if (track_cnt == ndistinct && toowide_cnt == 0 && stats->stadistinct > 0 && @@ -1333,13 +1354,13 @@ compute_scalar_stats(VacAttrStats *stats, } else { - double ndistinct = stats->stadistinct; - double avgcount, - mincount, - maxmincount; + double ndistinct = stats->stadistinct; + double avgcount, + mincount, + maxmincount; if (ndistinct < 0) - ndistinct = - ndistinct * totalrows; + ndistinct = -ndistinct * totalrows; /* estimate # of occurrences in sample of a typical value */ avgcount = (double) numrows / ndistinct; /* set minimum threshold count to store a value */ @@ -1366,8 +1387,8 @@ compute_scalar_stats(VacAttrStats *stats, if (num_mcv > 0) { MemoryContext old_context; - Datum *mcv_values; - float4 *mcv_freqs; + Datum *mcv_values; + float4 *mcv_freqs; /* Must copy the target values into TransactionCommandContext */ old_context = MemoryContextSwitchTo(TransactionCommandContext); @@ -1402,8 +1423,8 @@ compute_scalar_stats(VacAttrStats *stats, if (num_hist >= 2) { MemoryContext old_context; - Datum *hist_values; - int nvals; + Datum *hist_values; + int nvals; /* Sort the MCV items into position order to speed next loop */ qsort((void *) track, num_mcv, @@ -1413,24 +1434,25 @@ compute_scalar_stats(VacAttrStats *stats, * Collapse out the MCV items from the values[] array. * * Note we destroy the values[] array here... but we don't need - * it for anything more. We do, however, still need values_cnt. - * nvals will be the number of remaining entries in values[]. + * it for anything more. We do, however, still need + * values_cnt. nvals will be the number of remaining entries + * in values[]. */ if (num_mcv > 0) { - int src, - dest; - int j; + int src, + dest; + int j; src = dest = 0; j = 0; /* index of next interesting MCV item */ while (src < values_cnt) { - int ncopy; + int ncopy; if (j < num_mcv) { - int first = track[j].first; + int first = track[j].first; if (src >= first) { @@ -1442,9 +1464,7 @@ compute_scalar_stats(VacAttrStats *stats, ncopy = first - src; } else - { ncopy = values_cnt - src; - } memmove(&values[dest], &values[src], ncopy * sizeof(ScalarItem)); src += ncopy; @@ -1461,7 +1481,7 @@ compute_scalar_stats(VacAttrStats *stats, hist_values = (Datum *) palloc(num_hist * sizeof(Datum)); for (i = 0; i < num_hist; i++) { - int pos; + int pos; pos = (i * (nvals - 1)) / (num_hist - 1); hist_values[i] = datumCopy(values[pos].value, @@ -1481,9 +1501,9 @@ compute_scalar_stats(VacAttrStats *stats, if (values_cnt > 1) { MemoryContext old_context; - float4 *corrs; - double corr_xsum, - corr_x2sum; + float4 *corrs; + double corr_xsum, + corr_x2sum; /* Must copy the target values into TransactionCommandContext */ old_context = MemoryContextSwitchTo(TransactionCommandContext); @@ -1499,9 +1519,10 @@ compute_scalar_stats(VacAttrStats *stats, * (values_cnt-1)*values_cnt*(2*values_cnt-1) / 6. *---------- */ - corr_xsum = (double) (values_cnt-1) * (double) values_cnt / 2.0; - corr_x2sum = (double) (values_cnt-1) * (double) values_cnt * - (double) (2*values_cnt-1) / 6.0; + corr_xsum = (double) (values_cnt - 1) * (double) values_cnt / 2.0; + corr_x2sum = (double) (values_cnt - 1) * (double) values_cnt * + (double) (2 * values_cnt - 1) / 6.0; + /* And the correlation coefficient reduces to */ corrs[0] = (values_cnt * corr_xysum - corr_xsum * corr_xsum) / (values_cnt * corr_x2sum - corr_xsum * corr_xsum); @@ -1521,7 +1542,7 @@ compute_scalar_stats(VacAttrStats *stats, * qsort comparator for sorting ScalarItems * * Aside from sorting the items, we update the datumCmpTupnoLink[] array - * whenever two ScalarItems are found to contain equal datums. The array + * whenever two ScalarItems are found to contain equal datums. The array * is indexed by tupno; for each ScalarItem, it contains the highest * tupno that that item's datum has been found to be equal to. This allows * us to avoid additional comparisons in compute_scalar_stats(). @@ -1573,7 +1594,7 @@ compare_mcvs(const void *a, const void *b) * Statistics are stored in several places: the pg_class row for the * relation has stats about the whole relation, and there is a * pg_statistic row for each (non-system) attribute that has ever - * been analyzed. The pg_class values are updated by VACUUM, not here. + * been analyzed. The pg_class values are updated by VACUUM, not here. * * pg_statistic rows are just added or updated normally. This means * that pg_statistic will probably contain some deleted rows at the @@ -1604,7 +1625,9 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) FmgrInfo out_function; HeapTuple stup, oldtup; - int i, k, n; + int i, + k, + n; Datum values[Natts_pg_statistic]; char nulls[Natts_pg_statistic]; char replaces[Natts_pg_statistic]; @@ -1626,22 +1649,22 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) } i = 0; - values[i++] = ObjectIdGetDatum(relid); /* starelid */ - values[i++] = Int16GetDatum(stats->attnum); /* staattnum */ - values[i++] = Float4GetDatum(stats->stanullfrac); /* stanullfrac */ - values[i++] = Int32GetDatum(stats->stawidth); /* stawidth */ - values[i++] = Float4GetDatum(stats->stadistinct); /* stadistinct */ + values[i++] = ObjectIdGetDatum(relid); /* starelid */ + values[i++] = Int16GetDatum(stats->attnum); /* staattnum */ + values[i++] = Float4GetDatum(stats->stanullfrac); /* stanullfrac */ + values[i++] = Int32GetDatum(stats->stawidth); /* stawidth */ + values[i++] = Float4GetDatum(stats->stadistinct); /* stadistinct */ for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ + values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ } for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ + values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ } for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int nnum = stats->numnumbers[k]; + int nnum = stats->numnumbers[k]; if (nnum > 0) { @@ -1653,7 +1676,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) /* XXX knows more than it should about type float4: */ arry = construct_array(numdatums, nnum, false, sizeof(float4), 'i'); - values[i++] = PointerGetDatum(arry); /* stanumbersN */ + values[i++] = PointerGetDatum(arry); /* stanumbersN */ } else { @@ -1663,7 +1686,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) } for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int ntxt = stats->numvalues[k]; + int ntxt = stats->numvalues[k]; if (ntxt > 0) { @@ -1676,20 +1699,20 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) * Convert data values to a text string to be inserted * into the text array. */ - Datum stringdatum; + Datum stringdatum; stringdatum = FunctionCall3(&out_function, stats->stavalues[k][n], - ObjectIdGetDatum(stats->attrtype->typelem), - Int32GetDatum(stats->attr->atttypmod)); + ObjectIdGetDatum(stats->attrtype->typelem), + Int32GetDatum(stats->attr->atttypmod)); txtdatums[n] = DirectFunctionCall1(textin, stringdatum); pfree(DatumGetPointer(stringdatum)); } /* XXX knows more than it should about type text: */ arry = construct_array(txtdatums, ntxt, false, -1, 'i'); - values[i++] = PointerGetDatum(arry); /* stavaluesN */ + values[i++] = PointerGetDatum(arry); /* stavaluesN */ } else { diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 6333efafc6..3195f5fc0b 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.80 2001/09/08 01:10:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.81 2001/10/25 05:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,7 +120,7 @@ static volatile int notifyInterruptOccurred = 0; /* True if we've registered an on_shmem_exit cleanup */ static bool unlistenExitRegistered = false; -bool Trace_notify = false; +bool Trace_notify = false; static void Async_UnlistenAll(void); @@ -153,13 +153,13 @@ Async_Notify(char *relname) elog(DEBUG, "Async_Notify: %s", relname); /* no point in making duplicate entries in the list ... */ - if (! AsyncExistsPendingNotify(relname)) + if (!AsyncExistsPendingNotify(relname)) { /* - * The name list needs to live until end of transaction, so - * store it in the top transaction context. + * The name list needs to live until end of transaction, so store + * it in the top transaction context. */ - MemoryContext oldcontext; + MemoryContext oldcontext; oldcontext = MemoryContextSwitchTo(TopTransactionContext); @@ -209,7 +209,7 @@ Async_Listen(char *relname, int pid) Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple); if (listener->listenerpid == pid && - strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) + strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) { alreadyListener = true; /* No need to scan the rest of the table */ @@ -310,13 +310,14 @@ Async_Unlisten(char *relname, int pid) Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple); if (listener->listenerpid == pid && - strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) + strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) { /* Found the matching tuple, delete it */ simple_heap_delete(lRel, &tuple->t_self); + /* - * We assume there can be only one match, so no need - * to scan the rest of the table + * We assume there can be only one match, so no need to scan + * the rest of the table */ break; } @@ -478,16 +479,16 @@ AtCommit_Notify(void) char *relname = NameStr(listener->relname); int32 listenerPID = listener->listenerpid; - if (! AsyncExistsPendingNotify(relname)) + if (!AsyncExistsPendingNotify(relname)) continue; if (listenerPID == MyProcPid) { /* - * Self-notify: no need to bother with table update. - * Indeed, we *must not* clear the notification field in - * this path, or we could lose an outside notify, which'd - * be bad for applications that ignore self-notify messages. + * Self-notify: no need to bother with table update. Indeed, + * we *must not* clear the notification field in this path, or + * we could lose an outside notify, which'd be bad for + * applications that ignore self-notify messages. */ if (Trace_notify) @@ -503,22 +504,20 @@ AtCommit_Notify(void) /* * If someone has already notified this listener, we don't - * bother modifying the table, but we do still send a - * SIGUSR2 signal, just in case that backend missed the - * earlier signal for some reason. It's OK to send the - * signal first, because the other guy can't read - * pg_listener until we unlock it. + * bother modifying the table, but we do still send a SIGUSR2 + * signal, just in case that backend missed the earlier signal + * for some reason. It's OK to send the signal first, because + * the other guy can't read pg_listener until we unlock it. */ if (kill(listenerPID, SIGUSR2) < 0) { /* - * Get rid of pg_listener entry if it refers to a PID - * that no longer exists. Presumably, that backend - * crashed without deleting its pg_listener entries. - * This code used to only delete the entry if - * errno==ESRCH, but as far as I can see we should - * just do it for any failure (certainly at least for - * EPERM too...) + * Get rid of pg_listener entry if it refers to a PID that + * no longer exists. Presumably, that backend crashed + * without deleting its pg_listener entries. This code + * used to only delete the entry if errno==ESRCH, but as + * far as I can see we should just do it for any failure + * (certainly at least for EPERM too...) */ simple_heap_delete(lRel, &lTuple->t_self); } @@ -610,7 +609,6 @@ Async_NotifyHandler(SIGNAL_ARGS) if (notifyInterruptEnabled) { - /* * I'm not sure whether some flavors of Unix might allow another * SIGUSR2 occurrence to recursively interrupt this routine. To @@ -641,7 +639,6 @@ Async_NotifyHandler(SIGNAL_ARGS) } else { - /* * In this path it is NOT SAFE to do much of anything, except * this: @@ -888,11 +885,11 @@ static void ClearPendingNotifies(void) { /* - * We used to have to explicitly deallocate the list members and nodes, - * because they were malloc'd. Now, since we know they are palloc'd - * in TopTransactionContext, we need not do that --- they'll go away - * automatically at transaction exit. We need only reset the list head - * pointer. + * We used to have to explicitly deallocate the list members and + * nodes, because they were malloc'd. Now, since we know they are + * palloc'd in TopTransactionContext, we need not do that --- they'll + * go away automatically at transaction exit. We need only reset the + * list head pointer. */ pendingNotifies = NIL; } diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 7d5d3e6cbd..469b4cd1ce 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.69 2001/08/21 16:36:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.70 2001/10/25 05:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -267,10 +267,9 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) LocalHeapTuple.t_datamcxt = NULL; LocalHeapTuple.t_data = NULL; heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer, - ScanDesc); + ScanDesc); if (LocalHeapTuple.t_data != NULL) { - /* * We must copy the tuple because heap_insert() will overwrite * the commit-status fields of the tuple it's handed, and the diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 5297f7481d..4d1792a1d3 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.145 2001/10/23 17:39:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.146 2001/10/25 05:49:24 momjian Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -32,7 +32,7 @@ #include "catalog/pg_type.h" #include "commands/command.h" #include "commands/trigger.h" -#include "commands/defrem.h" /* For add constraint unique, primary */ +#include "commands/defrem.h" /* For add constraint unique, primary */ #include "executor/execdefs.h" #include "executor/executor.h" #include "miscadmin.h" @@ -43,7 +43,7 @@ #include "parser/parse_expr.h" #include "parser/parse_oper.h" #include "parser/parse_relation.h" -#include "parser/analyze.h" /* For add constraint unique, primary */ +#include "parser/analyze.h" /* For add constraint unique, primary */ #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" @@ -137,8 +137,8 @@ PerformPortalFetch(char *name, * destination. This supports MOVE, for example, which will pass in * dest = None. * - * EXCEPTION: if the query's original dest is RemoteInternal (ie, it's - * a binary cursor) and the request is Remote, we do NOT override the + * EXCEPTION: if the query's original dest is RemoteInternal (ie, it's a + * binary cursor) and the request is Remote, we do NOT override the * original dest. This is necessary since a FETCH command will pass * dest = Remote, not knowing whether the cursor is binary or not. */ @@ -183,10 +183,11 @@ PerformPortalFetch(char *name, if (!portal->atEnd) { ExecutorRun(queryDesc, estate, EXEC_FOR, (long) count); + /* - * I use CMD_UPDATE, because no CMD_MOVE or the like - * exists, and I would like to provide the same - * kind of info as CMD_UPDATE + * I use CMD_UPDATE, because no CMD_MOVE or the like exists, + * and I would like to provide the same kind of info as + * CMD_UPDATE */ UpdateCommandInfo(CMD_UPDATE, 0, estate->es_processed); if (estate->es_processed > 0) @@ -200,10 +201,11 @@ PerformPortalFetch(char *name, if (!portal->atStart) { ExecutorRun(queryDesc, estate, EXEC_BACK, (long) count); + /* - * I use CMD_UPDATE, because no CMD_MOVE or the like - * exists, and I would like to provide the same - * kind of info as CMD_UPDATE + * I use CMD_UPDATE, because no CMD_MOVE or the like exists, + * and I would like to provide the same kind of info as + * CMD_UPDATE */ UpdateCommandInfo(CMD_UPDATE, 0, estate->es_processed); if (estate->es_processed > 0) @@ -356,8 +358,8 @@ AlterTableAddColumn(const char *relationName, /* * find_all_inheritors does the recursive search of the - * inheritance hierarchy, so all we have to do is process all - * of the relids in the list that it returns. + * inheritance hierarchy, so all we have to do is process all of + * the relids in the list that it returns. */ foreach(child, children) { @@ -382,12 +384,12 @@ AlterTableAddColumn(const char *relationName, * Implementation restrictions: because we don't touch the table rows, * the new column values will initially appear to be NULLs. (This * happens because the heap tuple access routines always check for - * attnum > # of attributes in tuple, and return NULL if so.) Therefore - * we can't support a DEFAULT value in SQL92-compliant fashion, and - * we also can't allow a NOT NULL constraint. + * attnum > # of attributes in tuple, and return NULL if so.) + * Therefore we can't support a DEFAULT value in SQL92-compliant + * fashion, and we also can't allow a NOT NULL constraint. * - * We do allow CHECK constraints, even though these theoretically - * could fail for NULL rows (eg, CHECK (newcol IS NOT NULL)). + * We do allow CHECK constraints, even though these theoretically could + * fail for NULL rows (eg, CHECK (newcol IS NOT NULL)). */ if (colDef->raw_default || colDef->cooked_default) elog(ERROR, "Adding columns with defaults is not implemented." @@ -512,8 +514,8 @@ AlterTableAddColumn(const char *relationName, /* * Add any CHECK constraints attached to the new column. * - * To do this we must re-open the rel so that its new attr list - * gets loaded into the relcache. + * To do this we must re-open the rel so that its new attr list gets + * loaded into the relcache. */ if (colDef->constraints != NIL) { @@ -1012,7 +1014,6 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup) return checkok; } - #endif /* _DROP_COLUMN_HACK__ */ /* @@ -1169,7 +1170,7 @@ AlterTableDropColumn(const char *relationName, heap_freetuple(reltup); heap_close(rel, NoLock); #else - elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented"); + elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented"); #endif /* _DROP_COLUMN_HACK__ */ } @@ -1183,8 +1184,8 @@ AlterTableAddConstraint(char *relationName, bool inh, List *newConstraints) { Relation rel; - Oid myrelid; - List *listptr; + Oid myrelid; + List *listptr; #ifndef NO_SECURITY if (!pg_ownercheck(GetUserId(), relationName, RELNAME)) @@ -1199,7 +1200,8 @@ AlterTableAddConstraint(char *relationName, rel = heap_openr(relationName, AccessExclusiveLock); myrelid = RelationGetRelid(rel); - if (inh) { + if (inh) + { List *child, *children; @@ -1208,8 +1210,8 @@ AlterTableAddConstraint(char *relationName, /* * find_all_inheritors does the recursive search of the - * inheritance hierarchy, so all we have to do is process all - * of the relids in the list that it returns. + * inheritance hierarchy, so all we have to do is process all of + * the relids in the list that it returns. */ foreach(child, children) { @@ -1229,372 +1231,418 @@ AlterTableAddConstraint(char *relationName, foreach(listptr, newConstraints) { - Node *newConstraint = lfirst(listptr); - - switch (nodeTag(newConstraint)) - { - case T_Constraint: - { - Constraint *constr = (Constraint *) newConstraint; + Node *newConstraint = lfirst(listptr); - switch (constr->contype) + switch (nodeTag(newConstraint)) + { + case T_Constraint: { - case CONSTR_CHECK: - { - ParseState *pstate; - bool successful = true; - HeapScanDesc scan; - ExprContext *econtext; - TupleTableSlot *slot; - HeapTuple tuple; - RangeTblEntry *rte; - List *qual; - Node *expr; - char *name; - - if (constr->name) - name = constr->name; - else - name = "<unnamed>"; - - /* - * We need to make a parse state and range - * table to allow us to transformExpr and - * fix_opids to get a version of the - * expression we can pass to ExecQual - */ - pstate = make_parsestate(NULL); - rte = addRangeTableEntry(pstate, relationName, NULL, - false, true); - addRTEtoQuery(pstate, rte, true, true); - - /* Convert the A_EXPR in raw_expr into an EXPR */ - expr = transformExpr(pstate, constr->raw_expr, - EXPR_COLUMN_FIRST); - - /* - * Make sure it yields a boolean result. - */ - if (exprType(expr) != BOOLOID) - elog(ERROR, "CHECK '%s' does not yield boolean result", - name); - - /* - * Make sure no outside relations are referred - * to. - */ - if (length(pstate->p_rtable) != 1) - elog(ERROR, "Only relation '%s' can be referenced in CHECK", - relationName); - - /* - * Might as well try to reduce any constant - * expressions. - */ - expr = eval_const_expressions(expr); - - /* And fix the opids */ - fix_opids(expr); - - qual = makeList1(expr); - - /* Make tuple slot to hold tuples */ - slot = MakeTupleTableSlot(); - ExecSetSlotDescriptor(slot, RelationGetDescr(rel), false); - /* Make an expression context for ExecQual */ - econtext = MakeExprContext(slot, CurrentMemoryContext); - - /* - * Scan through the rows now, checking the - * expression at each row. - */ - scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL); - - while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) + Constraint *constr = (Constraint *) newConstraint; + + switch (constr->contype) + { + case CONSTR_CHECK: { - ExecStoreTuple(tuple, slot, InvalidBuffer, false); - if (!ExecQual(qual, econtext, true)) + ParseState *pstate; + bool successful = true; + HeapScanDesc scan; + ExprContext *econtext; + TupleTableSlot *slot; + HeapTuple tuple; + RangeTblEntry *rte; + List *qual; + Node *expr; + char *name; + + if (constr->name) + name = constr->name; + else + name = "<unnamed>"; + + /* + * We need to make a parse state and range + * table to allow us to transformExpr and + * fix_opids to get a version of the + * expression we can pass to ExecQual + */ + pstate = make_parsestate(NULL); + rte = addRangeTableEntry(pstate, relationName, NULL, + false, true); + addRTEtoQuery(pstate, rte, true, true); + + /* + * Convert the A_EXPR in raw_expr into an + * EXPR + */ + expr = transformExpr(pstate, constr->raw_expr, + EXPR_COLUMN_FIRST); + + /* + * Make sure it yields a boolean result. + */ + if (exprType(expr) != BOOLOID) + elog(ERROR, "CHECK '%s' does not yield boolean result", + name); + + /* + * Make sure no outside relations are + * referred to. + */ + if (length(pstate->p_rtable) != 1) + elog(ERROR, "Only relation '%s' can be referenced in CHECK", + relationName); + + /* + * Might as well try to reduce any + * constant expressions. + */ + expr = eval_const_expressions(expr); + + /* And fix the opids */ + fix_opids(expr); + + qual = makeList1(expr); + + /* Make tuple slot to hold tuples */ + slot = MakeTupleTableSlot(); + ExecSetSlotDescriptor(slot, RelationGetDescr(rel), false); + /* Make an expression context for ExecQual */ + econtext = MakeExprContext(slot, CurrentMemoryContext); + + /* + * Scan through the rows now, checking the + * expression at each row. + */ + scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL); + + while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) { - successful = false; - break; + ExecStoreTuple(tuple, slot, InvalidBuffer, false); + if (!ExecQual(qual, econtext, true)) + { + successful = false; + break; + } + ResetExprContext(econtext); } - ResetExprContext(econtext); - } - heap_endscan(scan); + heap_endscan(scan); - FreeExprContext(econtext); - pfree(slot); + FreeExprContext(econtext); + pfree(slot); - if (!successful) - elog(ERROR, "AlterTableAddConstraint: rejected due to CHECK constraint %s", name); + if (!successful) + elog(ERROR, "AlterTableAddConstraint: rejected due to CHECK constraint %s", name); - /* - * Call AddRelationRawConstraints to do the - * real adding -- It duplicates some of the - * above, but does not check the validity of - * the constraint against tuples already in - * the table. - */ - AddRelationRawConstraints(rel, NIL, + /* + * Call AddRelationRawConstraints to do + * the real adding -- It duplicates some + * of the above, but does not check the + * validity of the constraint against + * tuples already in the table. + */ + AddRelationRawConstraints(rel, NIL, makeList1(constr)); - break; - } - case CONSTR_UNIQUE: - { - char *iname = constr->name; - bool istemp = is_temp_rel_name(relationName); - List *indexoidlist; - List *indexoidscan; - int num_keys; - bool index_found = false; - bool index_found_unique = false; - bool index_found_primary = false; - - /* If the constraint name is not specified, generate a name */ - if (iname == NULL) { - Oid indoid; - int pass = 0; - char *typename = palloc(NAMEDATALEN); - Ident *key; - - /* Assume that the length of the attr list is already > 0 */ - - /* Get the first attribute so we can use its name */ - key = (Ident *)lfirst(constr->keys); - - /* Initialise typename to 'key' */ - snprintf(typename, NAMEDATALEN, "key"); - - for (;;) - { - iname = makeObjectName(relationName, key->name, typename); - - /* Check for a conflict */ - indoid = RelnameFindRelid(iname); - - /* If the oid was not found, then we have a safe name */ - if ((!istemp && !OidIsValid(indoid)) || - (istemp && !is_temp_rel_name(iname))) - break; - - /* Found a conflict, so try a new name component */ - pfree(iname); - snprintf(typename, NAMEDATALEN, "key%d", ++pass); - } - } - - /* Need to check for unique key already on field(s) */ - - /* - * First we check for limited correctness of the - * constraint - */ - - /* Loop over all indices on the relation */ - indexoidlist = RelationGetIndexList(rel); - - foreach(indexoidscan, indexoidlist) - { - Oid indexoid = lfirsti(indexoidscan); - HeapTuple indexTuple; - Form_pg_index indexStruct; - List *keyl; - int i; - - indexTuple = SearchSysCache(INDEXRELID, - ObjectIdGetDatum(indexoid), - 0, 0, 0); - - if (!HeapTupleIsValid(indexTuple)) - elog(ERROR, "ALTER TABLE/ADD CONSTRAINT: Index \"%u\" not found", - indexoid); - indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); - - /* - * Make sure this index has the same number of - * keys as the constraint -- It obviously won't match otherwise. - */ - for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++) - ; - num_keys = length(constr->keys); - - if (i == num_keys) - { - /* Loop over each key in the constraint and check that there is a - corresponding key in the index. */ - int keys_matched = 0; - - i = 0; - foreach(keyl, constr->keys) - { - Ident *key = lfirst(keyl); - int keyno = indexStruct->indkey[i]; - - /* Look at key[i] in the index and check that it is over the same column - as key[i] in the constraint. This is to differentiate between (a,b) - and (b,a) */ - if (namestrcmp(attnumAttName(rel, keyno), - key->name) == 0) - keys_matched++; - else - break; - i++; - } - if (keys_matched == num_keys) { - index_found = true; - index_found_unique = indexStruct->indisunique; - index_found_primary = indexStruct->indisprimary; - } - } - ReleaseSysCache(indexTuple); - if (index_found_unique || index_found_primary) - break; - } - - freeList(indexoidlist); - - if (index_found_primary) - elog(ERROR, "Unique primary key already defined on relation \"%s\"", relationName); - else if (index_found_unique) - elog(ERROR, "Unique constraint already defined on the specified attributes in relation \"%s\"", relationName); - - /* If everything is ok, create the new index (constraint) */ - DefineIndex( - relationName, - iname, - "btree", - constr->keys, - true, - false, - NULL, - NIL); - - /* Issue notice */ - elog(NOTICE, "ALTER TABLE/ADD UNIQUE will create implicit index '%s' for table '%s'", - iname, relationName); - if (index_found) - elog(NOTICE, "Unique constraint supercedes existing index on relation \"%s\". Drop the existing index to remove redundancy.", relationName); - pfree(iname); - - break; - } - default: - elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented for that constraint type."); - } - break; - } - case T_FkConstraint: - { - FkConstraint *fkconstraint = (FkConstraint *) newConstraint; - Relation pkrel; - HeapScanDesc scan; - HeapTuple tuple; - Trigger trig; - List *list; - int count; - - if (is_temp_rel_name(fkconstraint->pktable_name) && - !is_temp_rel_name(relationName)) - elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint."); - - /* - * Grab an exclusive lock on the pk table, so that someone - * doesn't delete rows out from under us. - */ - - pkrel = heap_openr(fkconstraint->pktable_name, AccessExclusiveLock); - if (pkrel->rd_rel->relkind != RELKIND_RELATION) - elog(ERROR, "referenced table \"%s\" not a relation", - fkconstraint->pktable_name); - heap_close(pkrel, NoLock); - - /* - * First we check for limited correctness of the constraint. - * - * NOTE: we assume parser has already checked for existence - * of an appropriate unique index on the referenced relation, - * and that the column datatypes are comparable. - * - * Scan through each tuple, calling the RI_FKey_Match_Ins - * (insert trigger) as if that tuple had just been - * inserted. If any of those fail, it should elog(ERROR) - * and that's that. - */ - - trig.tgoid = 0; - if (fkconstraint->constr_name) - trig.tgname = fkconstraint->constr_name; - else - trig.tgname = "<unknown>"; - trig.tgfoid = 0; - trig.tgtype = 0; - trig.tgenabled = TRUE; - trig.tgisconstraint = TRUE; - trig.tginitdeferred = FALSE; - trig.tgdeferrable = FALSE; - - trig.tgargs = (char **) palloc( - sizeof(char *) * (4 + length(fkconstraint->fk_attrs) - + length(fkconstraint->pk_attrs))); + break; + } + case CONSTR_UNIQUE: + { + char *iname = constr->name; + bool istemp = is_temp_rel_name(relationName); + List *indexoidlist; + List *indexoidscan; + int num_keys; + bool index_found = false; + bool index_found_unique = false; + bool index_found_primary = false; + + /* + * If the constraint name is not + * specified, generate a name + */ + if (iname == NULL) + { + Oid indoid; + int pass = 0; + char *typename = palloc(NAMEDATALEN); + Ident *key; + + /* + * Assume that the length of the attr + * list is already > 0 + */ + + /* + * Get the first attribute so we can + * use its name + */ + key = (Ident *) lfirst(constr->keys); + + /* Initialise typename to 'key' */ + snprintf(typename, NAMEDATALEN, "key"); + + for (;;) + { + iname = makeObjectName(relationName, key->name, typename); + + /* Check for a conflict */ + indoid = RelnameFindRelid(iname); + + /* + * If the oid was not found, then + * we have a safe name + */ + if ((!istemp && !OidIsValid(indoid)) || + (istemp && !is_temp_rel_name(iname))) + break; + + /* + * Found a conflict, so try a new + * name component + */ + pfree(iname); + snprintf(typename, NAMEDATALEN, "key%d", ++pass); + } + } - if (fkconstraint->constr_name) - trig.tgargs[0] = fkconstraint->constr_name; - else - trig.tgargs[0] = "<unknown>"; - trig.tgargs[1] = (char *) relationName; - trig.tgargs[2] = fkconstraint->pktable_name; - trig.tgargs[3] = fkconstraint->match_type; - count = 4; - foreach(list, fkconstraint->fk_attrs) - { - Ident *fk_at = lfirst(list); + /* + * Need to check for unique key already on + * field(s) + */ - trig.tgargs[count] = fk_at->name; - count += 2; - } - count = 5; - foreach(list, fkconstraint->pk_attrs) - { - Ident *pk_at = lfirst(list); + /* + * First we check for limited correctness + * of the constraint + */ - trig.tgargs[count] = pk_at->name; - count += 2; - } - trig.tgnargs = count - 1; + /* Loop over all indices on the relation */ + indexoidlist = RelationGetIndexList(rel); - scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL); + foreach(indexoidscan, indexoidlist) + { + Oid indexoid = lfirsti(indexoidscan); + HeapTuple indexTuple; + Form_pg_index indexStruct; + List *keyl; + int i; + + indexTuple = SearchSysCache(INDEXRELID, + ObjectIdGetDatum(indexoid), + 0, 0, 0); + + if (!HeapTupleIsValid(indexTuple)) + elog(ERROR, "ALTER TABLE/ADD CONSTRAINT: Index \"%u\" not found", + indexoid); + indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); + + /* + * Make sure this index has the same + * number of keys as the constraint -- + * It obviously won't match otherwise. + */ + for (i = 0; i < INDEX_MAX_KEYS && indexStruct->indkey[i] != 0; i++) + ; + num_keys = length(constr->keys); + + if (i == num_keys) + { + /* + * Loop over each key in the + * constraint and check that there + * is a corresponding key in the + * index. + */ + int keys_matched = 0; + + i = 0; + foreach(keyl, constr->keys) + { + Ident *key = lfirst(keyl); + int keyno = indexStruct->indkey[i]; + + /* + * Look at key[i] in the index + * and check that it is over + * the same column as key[i] + * in the constraint. This is + * to differentiate between + * (a,b) and (b,a) + */ + if (namestrcmp(attnumAttName(rel, keyno), + key->name) == 0) + keys_matched++; + else + break; + i++; + } + if (keys_matched == num_keys) + { + index_found = true; + index_found_unique = indexStruct->indisunique; + index_found_primary = indexStruct->indisprimary; + } + } + ReleaseSysCache(indexTuple); + if (index_found_unique || index_found_primary) + break; + } - while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) + freeList(indexoidlist); + + if (index_found_primary) + elog(ERROR, "Unique primary key already defined on relation \"%s\"", relationName); + else if (index_found_unique) + elog(ERROR, "Unique constraint already defined on the specified attributes in relation \"%s\"", relationName); + + /* + * If everything is ok, create the new + * index (constraint) + */ + DefineIndex( + relationName, + iname, + "btree", + constr->keys, + true, + false, + NULL, + NIL); + + /* Issue notice */ + elog(NOTICE, "ALTER TABLE/ADD UNIQUE will create implicit index '%s' for table '%s'", + iname, relationName); + if (index_found) + elog(NOTICE, "Unique constraint supercedes existing index on relation \"%s\". Drop the existing index to remove redundancy.", relationName); + pfree(iname); + + break; + } + default: + elog(ERROR, "ALTER TABLE / ADD CONSTRAINT is not implemented for that constraint type."); + } + break; + } + case T_FkConstraint: { - /* Make a call to the check function */ - /* No parameters are passed, but we do set a context */ - FunctionCallInfoData fcinfo; - TriggerData trigdata; - - MemSet(&fcinfo, 0, sizeof(fcinfo)); - /* We assume RI_FKey_check_ins won't look at flinfo... */ - - trigdata.type = T_TriggerData; - trigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW; - trigdata.tg_relation = rel; - trigdata.tg_trigtuple = tuple; - trigdata.tg_newtuple = NULL; - trigdata.tg_trigger = &trig; - - fcinfo.context = (Node *) &trigdata; + FkConstraint *fkconstraint = (FkConstraint *) newConstraint; + Relation pkrel; + HeapScanDesc scan; + HeapTuple tuple; + Trigger trig; + List *list; + int count; + + if (is_temp_rel_name(fkconstraint->pktable_name) && + !is_temp_rel_name(relationName)) + elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint."); + + /* + * Grab an exclusive lock on the pk table, so that + * someone doesn't delete rows out from under us. + */ + + pkrel = heap_openr(fkconstraint->pktable_name, AccessExclusiveLock); + if (pkrel->rd_rel->relkind != RELKIND_RELATION) + elog(ERROR, "referenced table \"%s\" not a relation", + fkconstraint->pktable_name); + heap_close(pkrel, NoLock); + + /* + * First we check for limited correctness of the + * constraint. + * + * NOTE: we assume parser has already checked for + * existence of an appropriate unique index on the + * referenced relation, and that the column datatypes + * are comparable. + * + * Scan through each tuple, calling the RI_FKey_Match_Ins + * (insert trigger) as if that tuple had just been + * inserted. If any of those fail, it should + * elog(ERROR) and that's that. + */ + + trig.tgoid = 0; + if (fkconstraint->constr_name) + trig.tgname = fkconstraint->constr_name; + else + trig.tgname = "<unknown>"; + trig.tgfoid = 0; + trig.tgtype = 0; + trig.tgenabled = TRUE; + trig.tgisconstraint = TRUE; + trig.tginitdeferred = FALSE; + trig.tgdeferrable = FALSE; + + trig.tgargs = (char **) palloc( + sizeof(char *) * (4 + length(fkconstraint->fk_attrs) + + length(fkconstraint->pk_attrs))); - RI_FKey_check_ins(&fcinfo); + if (fkconstraint->constr_name) + trig.tgargs[0] = fkconstraint->constr_name; + else + trig.tgargs[0] = "<unknown>"; + trig.tgargs[1] = (char *) relationName; + trig.tgargs[2] = fkconstraint->pktable_name; + trig.tgargs[3] = fkconstraint->match_type; + count = 4; + foreach(list, fkconstraint->fk_attrs) + { + Ident *fk_at = lfirst(list); + + trig.tgargs[count] = fk_at->name; + count += 2; + } + count = 5; + foreach(list, fkconstraint->pk_attrs) + { + Ident *pk_at = lfirst(list); + + trig.tgargs[count] = pk_at->name; + count += 2; + } + trig.tgnargs = count - 1; + + scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL); + + while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) + { + /* Make a call to the check function */ + + /* + * No parameters are passed, but we do set a + * context + */ + FunctionCallInfoData fcinfo; + TriggerData trigdata; + + MemSet(&fcinfo, 0, sizeof(fcinfo)); + + /* + * We assume RI_FKey_check_ins won't look at + * flinfo... + */ + + trigdata.type = T_TriggerData; + trigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW; + trigdata.tg_relation = rel; + trigdata.tg_trigtuple = tuple; + trigdata.tg_newtuple = NULL; + trigdata.tg_trigger = &trig; + + fcinfo.context = (Node *) &trigdata; + + RI_FKey_check_ins(&fcinfo); + } + heap_endscan(scan); + + pfree(trig.tgargs); + break; } - heap_endscan(scan); - - pfree(trig.tgargs); - break; - } - default: - elog(ERROR, "ALTER TABLE / ADD CONSTRAINT unable to determine type of constraint passed"); - } + default: + elog(ERROR, "ALTER TABLE / ADD CONSTRAINT unable to determine type of constraint passed"); + } } /* Close rel, but keep lock till commit */ @@ -1614,7 +1662,7 @@ AlterTableDropConstraint(const char *relationName, bool inh, const char *constrName, int behavior) { - Relation rel; + Relation rel; int deleted; #ifndef NO_SECURITY @@ -1622,14 +1670,16 @@ AlterTableDropConstraint(const char *relationName, elog(ERROR, "ALTER TABLE: permission denied"); #endif - /* We don't support CASCADE yet - in fact, RESTRICT - * doesn't work to the spec either! */ + /* + * We don't support CASCADE yet - in fact, RESTRICT doesn't work to + * the spec either! + */ if (behavior == CASCADE) elog(ERROR, "ALTER TABLE / DROP CONSTRAINT does not support the CASCADE keyword"); /* - * Acquire an exclusive lock on the target relation for - * the duration of the operation. + * Acquire an exclusive lock on the target relation for the duration + * of the operation. */ rel = heap_openr(relationName, AccessExclusiveLock); @@ -1640,9 +1690,10 @@ AlterTableDropConstraint(const char *relationName, relationName); /* - * Since all we have is the name of the constraint, we have to look through - * all catalogs that could possibly contain a constraint for this relation. - * We also keep a count of the number of constraints removed. + * Since all we have is the name of the constraint, we have to look + * through all catalogs that could possibly contain a constraint for + * this relation. We also keep a count of the number of constraints + * removed. */ deleted = 0; @@ -1654,7 +1705,8 @@ AlterTableDropConstraint(const char *relationName, deleted += RemoveCheckConstraint(rel, constrName, inh); /* - * Now we remove NULL, UNIQUE, PRIMARY KEY and FOREIGN KEY constraints. + * Now we remove NULL, UNIQUE, PRIMARY KEY and FOREIGN KEY + * constraints. * * Unimplemented. */ @@ -1887,10 +1939,11 @@ AlterTableCreateToastTable(const char *relationName, bool silent) * Create unique index on chunk_id, chunk_seq. * * NOTE: the tuple toaster could actually function with a single-column - * index on chunk_id only. However, it couldn't be unique then. We - * want it to be unique as a check against the possibility of duplicate - * TOAST chunk OIDs. Too, the index might be a little more efficient this - * way, since btree isn't all that happy with large numbers of equal keys. + * index on chunk_id only. However, it couldn't be unique then. We + * want it to be unique as a check against the possibility of + * duplicate TOAST chunk OIDs. Too, the index might be a little more + * efficient this way, since btree isn't all that happy with large + * numbers of equal keys. */ indexInfo = makeNode(IndexInfo); @@ -1910,9 +1963,9 @@ AlterTableCreateToastTable(const char *relationName, bool silent) true, true); /* - * Update toast rel's pg_class entry to show that it has an index. - * The index OID is stored into the reltoastidxid field for - * easy access by the tuple toaster. + * Update toast rel's pg_class entry to show that it has an index. The + * index OID is stored into the reltoastidxid field for easy access by + * the tuple toaster. */ setRelhasindex(toast_relid, true, true, toast_idxid); @@ -1990,7 +2043,7 @@ needs_toast_table(Relation rel) MAXALIGN(data_length); return (tuple_length > TOAST_TUPLE_THRESHOLD); } - + /* * * LOCK TABLE @@ -1999,38 +2052,39 @@ needs_toast_table(Relation rel) void LockTableCommand(LockStmt *lockstmt) { - List *p; - Relation rel; - - /* Iterate over the list and open, lock, and close the relations - one at a time + List *p; + Relation rel; + + /* + * Iterate over the list and open, lock, and close the relations one + * at a time */ - foreach(p, lockstmt->rellist) - { - char* relname = strVal(lfirst(p)); - int aclresult; - - rel = heap_openr(relname, NoLock); - - if (rel->rd_rel->relkind != RELKIND_RELATION) - elog(ERROR, "LOCK TABLE: %s is not a table", - relname); - - if (lockstmt->mode == AccessShareLock) - aclresult = pg_aclcheck(relname, GetUserId(), - ACL_SELECT); - else - aclresult = pg_aclcheck(relname, GetUserId(), - ACL_UPDATE | ACL_DELETE); + foreach(p, lockstmt->rellist) + { + char *relname = strVal(lfirst(p)); + int aclresult; - if (aclresult != ACLCHECK_OK) - elog(ERROR, "LOCK TABLE: permission denied"); + rel = heap_openr(relname, NoLock); - LockRelation(rel, lockstmt->mode); - - heap_close(rel, NoLock); /* close rel, keep lock */ - } + if (rel->rd_rel->relkind != RELKIND_RELATION) + elog(ERROR, "LOCK TABLE: %s is not a table", + relname); + + if (lockstmt->mode == AccessShareLock) + aclresult = pg_aclcheck(relname, GetUserId(), + ACL_SELECT); + else + aclresult = pg_aclcheck(relname, GetUserId(), + ACL_UPDATE | ACL_DELETE); + + if (aclresult != ACLCHECK_OK) + elog(ERROR, "LOCK TABLE: permission denied"); + + LockRelation(rel, lockstmt->mode); + + heap_close(rel, NoLock); /* close rel, keep lock */ + } } diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 14e591288a..647cb55b7e 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1999-2001, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.33 2001/10/03 20:54:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.34 2001/10/25 05:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -332,9 +332,10 @@ CommentRelation(int reltype, char *relname, char *comment) elog(ERROR, "you are not permitted to comment on class '%s'", relname); /* - * Open the relation. We do this mainly to acquire a lock that ensures - * no one else drops the relation before we commit. (If they did, they'd - * fail to remove the entry we are about to make in pg_description.) + * Open the relation. We do this mainly to acquire a lock that + * ensures no one else drops the relation before we commit. (If they + * did, they'd fail to remove the entry we are about to make in + * pg_description.) * * heap_openr will complain if it's an index, so we must do this: */ diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index ce7ea9fd6d..7f1e288fab 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.141 2001/08/10 18:57:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.142 2001/10/25 05:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,6 @@ static StringInfoData attribute_buf; #ifdef MULTIBYTE static int client_encoding; static int server_encoding; - #endif @@ -209,7 +208,6 @@ CopyDonePeek(FILE *fp, int c, int pickup) { if (pickup) { - /* * We want to pick it up - just receive again into dummy * buffer @@ -240,8 +238,8 @@ CopyDonePeek(FILE *fp, int c, int pickup) * (<from> = TRUE means we are inserting into the table.) * * If <pipe> is false, transfer is between the table and the file named - * <filename>. Otherwise, transfer is between the table and our regular - * input/output stream. The latter could be either stdin/stdout or a + * <filename>. Otherwise, transfer is between the table and our regular + * input/output stream. The latter could be either stdin/stdout or a * socket, depending on whether we're running under Postmaster control. * * Iff <binary>, unload or reload in the binary format, as opposed to the @@ -257,7 +255,7 @@ CopyDonePeek(FILE *fp, int c, int pickup) * NULL values as <null_print>. * * When loading in the text format from an input stream (as opposed to - * a file), recognize a "." on a line by itself as EOF. Also recognize + * a file), recognize a "." on a line by itself as EOF. Also recognize * a stream EOF. When unloading in the text format to an output stream, * write a "." on a line by itself at the end of the data. * @@ -534,7 +532,6 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, } else { - /* * If we have a toasted datum, forcibly detoast it to * avoid memory leakage inside the type's output routine @@ -1197,7 +1194,6 @@ CopyAttributeOut(FILE *fp, char *server_string, char *delim) char *string_start; int mblen; int i; - #endif #ifdef MULTIBYTE diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 1c17714eb4..0c1e7268d7 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.80 2001/08/16 20:38:53 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.81 2001/10/25 05:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ static List *MergeAttributes(List *schema, List *supers, bool istemp, List **supOids, List **supconstr, bool *supHasOids); static bool change_varattnos_of_a_node(Node *node, const AttrNumber *newattno); static void StoreCatalogInheritance(Oid relationId, List *supers); -static int findAttrByName(const char *attributeName, List *schema); +static int findAttrByName(const char *attributeName, List *schema); static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass); @@ -74,7 +74,7 @@ DefineRelation(CreateStmt *stmt, char relkind) * including inherited attributes. */ schema = MergeAttributes(schema, stmt->inhRelnames, stmt->istemp, - &inheritOids, &old_constraints, &parentHasOids); + &inheritOids, &old_constraints, &parentHasOids); numberOfAttributes = length(schema); if (numberOfAttributes <= 0) @@ -305,7 +305,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, List *constraints = NIL; bool parentHasOids = false; bool have_bogus_defaults = false; - char *bogus_marker = "Bogus!"; /* marks conflicting defaults */ + char *bogus_marker = "Bogus!"; /* marks conflicting + * defaults */ int child_attno; /* @@ -329,6 +330,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, coldef->colname); } } + /* * Reject duplicate names in the list of parents, too. */ @@ -346,7 +348,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, /* * Scan the parents left-to-right, and merge their attributes to form - * a list of inherited attributes (inhSchema). Also check to see if + * a list of inherited attributes (inhSchema). Also check to see if * we need to inherit an OID column. */ child_attno = 0; @@ -387,7 +389,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, * the attributes of this parent table. (They are not the same * for parents after the first one.) */ - newattno = (AttrNumber *) palloc(tupleDesc->natts*sizeof(AttrNumber)); + newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber)); for (parent_attno = 1; parent_attno <= tupleDesc->natts; parent_attno++) @@ -420,8 +422,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, if (exist_attno > 0) { /* - * Yes, try to merge the two column definitions. - * They must have the same type and typmod. + * Yes, try to merge the two column definitions. They must + * have the same type and typmod. */ elog(NOTICE, "CREATE TABLE: merging multiple inherited definitions of attribute \"%s\"", attributeName); @@ -429,7 +431,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, if (strcmp(def->typename->name, attributeType) != 0 || def->typename->typmod != attribute->atttypmod) elog(ERROR, "CREATE TABLE: inherited attribute \"%s\" type conflict (%s and %s)", - attributeName, def->typename->name, attributeType); + attributeName, def->typename->name, attributeType); /* Merge of NOT NULL constraints = OR 'em together */ def->is_not_null |= attribute->attnotnull; /* Default and other constraints are handled below */ @@ -453,6 +455,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, inhSchema = lappend(inhSchema, def); newattno[parent_attno - 1] = ++child_attno; } + /* * Copy default if any */ @@ -474,15 +477,17 @@ MergeAttributes(List *schema, List *supers, bool istemp, } } Assert(this_default != NULL); + /* - * If default expr could contain any vars, we'd need to fix - * 'em, but it can't; so default is ready to apply to child. + * If default expr could contain any vars, we'd need to + * fix 'em, but it can't; so default is ready to apply to + * child. * - * If we already had a default from some prior parent, - * check to see if they are the same. If so, no problem; - * if not, mark the column as having a bogus default. - * Below, we will complain if the bogus default isn't - * overridden by the child schema. + * If we already had a default from some prior parent, check + * to see if they are the same. If so, no problem; if + * not, mark the column as having a bogus default. Below, + * we will complain if the bogus default isn't overridden + * by the child schema. */ Assert(def->raw_default == NULL); if (def->cooked_default == NULL) @@ -494,6 +499,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, } } } + /* * Now copy the constraints of this parent, adjusting attnos using * the completed newattno[] map @@ -555,8 +561,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, ColumnDef *def; /* - * Yes, try to merge the two column definitions. - * They must have the same type and typmod. + * Yes, try to merge the two column definitions. They must + * have the same type and typmod. */ elog(NOTICE, "CREATE TABLE: merging attribute \"%s\" with inherited definition", attributeName); @@ -564,7 +570,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, if (strcmp(def->typename->name, attributeType) != 0 || def->typename->typmod != newdef->typename->typmod) elog(ERROR, "CREATE TABLE: attribute \"%s\" type conflict (%s and %s)", - attributeName, def->typename->name, attributeType); + attributeName, def->typename->name, attributeType); /* Merge of NOT NULL constraints = OR 'em together */ def->is_not_null |= newdef->is_not_null; /* If new def has a default, override previous default */ @@ -630,7 +636,6 @@ change_varattnos_walker(Node *node, const AttrNumber *newattno) if (var->varlevelsup == 0 && var->varno == 1 && var->varattno > 0) { - /* * ??? the following may be a problem when the node is * multiply referenced though stringToNode() doesn't create @@ -783,7 +788,6 @@ again: } if (found) { - /* * found a later duplicate, so remove this entry. */ diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 88b01fd91e..92baacb72d 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.80 2001/09/06 04:57:28 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.81 2001/10/25 05:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ #include "utils/syscache.h" #ifdef MULTIBYTE -#include "mb/pg_wchar.h" /* encoding check */ +#include "mb/pg_wchar.h" /* encoding check */ #endif @@ -148,11 +148,12 @@ createdb(const char *dbname, const char *dbpath, #ifdef MULTIBYTE /* Some encodings are client only */ - if (!PG_VALID_BE_ENCODING( encoding )) + if (!PG_VALID_BE_ENCODING(encoding)) elog(ERROR, "CREATE DATABASE: invalid backend encoding"); #else Assert(encoding == 0); /* zero is PG_SQL_ASCII */ #endif + /* * Preassign OID for pg_database tuple, so that we can compute db * path. diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index 02b7b0c04b..334094fd47 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.62 2001/10/13 01:35:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.63 2001/10/25 05:49:25 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -64,7 +64,7 @@ static void case_translate_language_name(const char *input, char *output) { /* - * Translate the input language name to lower case, except if it's "C", + * Translate the input language name to lower case, except if it's "C", * translate to upper case. */ int i; @@ -85,8 +85,8 @@ compute_return_type(TypeName *returnType, char **prorettype_p, bool *returnsSet_p) { /* - * Examine the "returns" clause returnType of the CREATE FUNCTION statement - * and return information about it as *prorettype_p and *returnsSet. + * Examine the "returns" clause returnType of the CREATE FUNCTION statement + * and return information about it as *prorettype_p and *returnsSet. */ *prorettype_p = TypeNameToInternalName(returnType); *returnsSet_p = returnType->setof; @@ -100,26 +100,26 @@ compute_full_attributes(List *parameters, bool *canCache_p, bool *isStrict_p) { /*------------- - * Interpret the parameters *parameters and return their contents as - * *byte_pct_p, etc. + * Interpret the parameters *parameters and return their contents as + * *byte_pct_p, etc. * - * These parameters supply optional information about a function. - * All have defaults if not specified. + * These parameters supply optional information about a function. + * All have defaults if not specified. * - * Note: currently, only two of these parameters actually do anything: + * Note: currently, only two of these parameters actually do anything: * - * * canCache means the optimizer's constant-folder is allowed to - * pre-evaluate the function when all its inputs are constants. + * * canCache means the optimizer's constant-folder is allowed to + * pre-evaluate the function when all its inputs are constants. * - * * isStrict means the function should not be called when any NULL - * inputs are present; instead a NULL result value should be assumed. + * * isStrict means the function should not be called when any NULL + * inputs are present; instead a NULL result value should be assumed. * - * The other four parameters are not used anywhere. They used to be - * used in the "expensive functions" optimizer, but that's been dead code - * for a long time. + * The other four parameters are not used anywhere. They used to be + * used in the "expensive functions" optimizer, but that's been dead code + * for a long time. * - * Since canCache and isStrict are useful for any function, we now allow - * attributes to be supplied for all functions regardless of language. + * Since canCache and isStrict are useful for any function, we now allow + * attributes to be supplied for all functions regardless of language. *------------ */ List *pl; @@ -142,7 +142,6 @@ compute_full_attributes(List *parameters, *isStrict_p = true; else if (strcasecmp(param->defname, "trusted") == 0) { - /* * we don't have untrusted functions any more. The 4.2 * implementation is lousy anyway so I took it out. -ay 10/94 @@ -183,7 +182,6 @@ interpret_AS_clause(const char *languageName, const List *as, if (strcmp(languageName, "C") == 0) { - /* * For "C" language, store the file name in probin and, when * given, the link symbol name in prosrc. @@ -358,7 +356,7 @@ DefineOperator(char *oprName, List *parameters) { uint16 precedence = 0; /* operator precedence */ - bool canHash = false;/* operator hashes */ + bool canHash = false; /* operator hashes */ bool isLeftAssociative = true; /* operator is left * associative */ char *functionName = NULL; /* function for operator */ @@ -369,7 +367,7 @@ DefineOperator(char *oprName, char *negatorName = NULL; /* optional negator operator name */ char *restrictionName = NULL; /* optional restrict. sel. * procedure */ - char *joinName = NULL;/* optional join sel. procedure name */ + char *joinName = NULL; /* optional join sel. procedure name */ char *sortName1 = NULL; /* optional first sort operator */ char *sortName2 = NULL; /* optional second sort operator */ List *pl; @@ -534,8 +532,8 @@ DefineAggregate(char *aggName, List *parameters) void DefineType(char *typeName, List *parameters) { - int16 internalLength = -1; /* int2 */ - int16 externalLength = -1; /* int2 */ + int16 internalLength = -1; /* int2 */ + int16 externalLength = -1; /* int2 */ char *elemName = NULL; char *inputName = NULL; char *outputName = NULL; @@ -546,7 +544,7 @@ DefineType(char *typeName, List *parameters) char delimiter = DEFAULT_TYPDELIM; char *shadow_type; List *pl; - char alignment = 'i'; /* default alignment */ + char alignment = 'i'; /* default alignment */ char storage = 'p'; /* default TOAST storage method */ /* @@ -591,9 +589,10 @@ DefineType(char *typeName, List *parameters) char *a = defGetString(defel); /* - * Note: if argument was an unquoted identifier, parser will have - * applied xlateSqlType() to it, so be prepared to recognize - * translated type names as well as the nominal form. + * Note: if argument was an unquoted identifier, parser will + * have applied xlateSqlType() to it, so be prepared to + * recognize translated type names as well as the nominal + * form. */ if (strcasecmp(a, "double") == 0) alignment = 'd'; diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 91282ffc3f..c14d4ce3e5 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, 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.66 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.67 2001/10/25 05:49:25 momjian Exp $ * */ @@ -114,8 +114,8 @@ ExplainOneQuery(Query *query, bool verbose, bool analyze, CommandDest dest) struct timeval endtime; /* - * Set up the instrumentation for the top node. - * This will cascade during plan initialisation + * Set up the instrumentation for the top node. This will cascade + * during plan initialisation */ plan->instrument = InstrAlloc(); @@ -124,7 +124,7 @@ ExplainOneQuery(Query *query, bool verbose, bool analyze, CommandDest dest) CommandCounterIncrement(); gettimeofday(&endtime, NULL); - endtime.tv_sec -= starttime.tv_sec; + endtime.tv_sec -= starttime.tv_sec; endtime.tv_usec -= starttime.tv_usec; while (endtime.tv_usec < 0) { @@ -328,9 +328,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) plan->startup_cost, plan->total_cost, plan->plan_rows, plan->plan_width); - if ( plan->instrument && plan->instrument->nloops > 0 ) + if (plan->instrument && plan->instrument->nloops > 0) { - double nloops = plan->instrument->nloops; + double nloops = plan->instrument->nloops; appendStringInfo(str, " (actual time=%.2f..%.2f rows=%.0f loops=%.0f)", 1000.0 * plan->instrument->startup / nloops, @@ -442,7 +442,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) static StringInfo Explain_PlanToString(Plan *plan, ExplainState *es) { - StringInfo str = makeStringInfo(); + StringInfo str = makeStringInfo(); if (plan != NULL) explain_outNode(str, plan, 0, es); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index a02f399f12..f6eb6471c0 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.59 2001/10/24 09:28:31 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.60 2001/10/25 05:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,7 @@ static void NormIndexAttrs(IndexInfo *indexInfo, Oid *classOidP, char *accessMethodName, Oid accessMethodId); static Oid GetAttrOpClass(IndexElem *attribute, Oid attrType, char *accessMethodName, Oid accessMethodId); -static Oid GetDefaultOpClass(Oid attrType, Oid accessMethodId); +static Oid GetDefaultOpClass(Oid attrType, Oid accessMethodId); /* * DefineIndex @@ -97,7 +97,8 @@ DefineIndex(char *heapRelationName, heapRelationName); /* - * look up the access method, verify it can handle the requested features + * look up the access method, verify it can handle the requested + * features */ tuple = SearchSysCache(AMNAME, PointerGetDatum(accessMethodName), @@ -108,18 +109,18 @@ DefineIndex(char *heapRelationName, accessMethodId = tuple->t_data->t_oid; accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); - if (unique && ! accessMethodForm->amcanunique) + if (unique && !accessMethodForm->amcanunique) elog(ERROR, "DefineIndex: access method \"%s\" does not support UNIQUE indexes", accessMethodName); - if (numberOfAttributes > 1 && ! accessMethodForm->amcanmulticol) + if (numberOfAttributes > 1 && !accessMethodForm->amcanmulticol) elog(ERROR, "DefineIndex: access method \"%s\" does not support multi-column indexes", accessMethodName); ReleaseSysCache(tuple); /* - * Convert the partial-index predicate from parsetree form to - * an implicit-AND qual expression, for easier evaluation at runtime. + * Convert the partial-index predicate from parsetree form to an + * implicit-AND qual expression, for easier evaluation at runtime. * While we are at it, we reduce it to a canonical (CNF or DNF) form * to simplify the task of proving implications. */ @@ -196,7 +197,7 @@ DefineIndex(char *heapRelationName, * (via the given range table) only to the given base relation oid. * * This used to also constrain the form of the predicate to forms that - * indxpath.c could do something with. However, that seems overly + * indxpath.c could do something with. However, that seems overly * restrictive. One useful application of partial indexes is to apply * a UNIQUE constraint across a subset of a table, and in that scenario * any evaluatable predicate will work. So accept any predicate here @@ -208,11 +209,12 @@ CheckPredicate(List *predList, List *rangeTable, Oid baseRelOid) { if (length(rangeTable) != 1 || getrelid(1, rangeTable) != baseRelOid) elog(ERROR, - "Partial-index predicates may refer only to the base relation"); + "Partial-index predicates may refer only to the base relation"); /* * We don't currently support generation of an actual query plan for a - * predicate, only simple scalar expressions; hence these restrictions. + * predicate, only simple scalar expressions; hence these + * restrictions. */ if (contain_subplans((Node *) predList)) elog(ERROR, "Cannot use subselect in index predicate"); @@ -240,7 +242,7 @@ FuncIndexArgs(IndexInfo *indexInfo, List *arglist; int nargs = 0; int i; - FuncDetailCode fdresult; + FuncDetailCode fdresult; Oid funcid; Oid rettype; bool retset; @@ -309,9 +311,9 @@ FuncIndexArgs(IndexInfo *indexInfo, /* * Require that the function be marked cachable. Using a noncachable - * function for a functional index is highly questionable, since if you - * aren't going to get the same result for the same data every time, - * it's not clear what the index entries mean at all. + * function for a functional index is highly questionable, since if + * you aren't going to get the same result for the same data every + * time, it's not clear what the index entries mean at all. */ if (!func_iscachable(funcid)) elog(ERROR, "DefineIndex: index function must be marked iscachable"); @@ -431,11 +433,11 @@ GetDefaultOpClass(Oid attrType, Oid accessMethodId) * (either exactly or binary-compatibly, but prefer an exact match). * * We could find more than one binary-compatible match, in which case we - * require the user to specify which one he wants. If we find more than - * one exact match, then someone put bogus entries in pg_opclass. + * require the user to specify which one he wants. If we find more + * than one exact match, then someone put bogus entries in pg_opclass. * - * We could use an indexscan here, but since pg_opclass is small - * and a scan on opcamid won't be very selective, the indexscan would + * We could use an indexscan here, but since pg_opclass is small and a + * scan on opcamid won't be very selective, the indexscan would * probably actually be slower than heapscan. */ ScanKeyEntryInitialize(&entry[0], 0x0, @@ -612,7 +614,7 @@ ReindexDatabase(const char *dbname, bool force, bool all) if (strcmp(dbname, DatabaseName) != 0) elog(ERROR, "REINDEX DATABASE: Can be executed only on the currently open database."); - if (! (superuser() || is_dbadmin(MyDatabaseId))) + if (!(superuser() || is_dbadmin(MyDatabaseId))) elog(ERROR, "REINDEX DATABASE: Permission denied."); /* diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index 4e46f7f9d2..37a338ff96 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.63 2001/10/03 20:54:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.64 2001/10/25 05:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -227,7 +227,6 @@ AttributeAndRelationRemove(Oid typeOid) } heap_close(rel, RowExclusiveLock); } - #endif /* NOTYET */ /* diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 8d4b05567f..c65cfcc551 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.58 2001/10/08 18:40:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.59 2001/10/25 05:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -167,7 +167,8 @@ renameatt(char *relname, heap_freetuple(atttup); /* - * Update column names of indexes that refer to the column being renamed. + * Update column names of indexes that refer to the column being + * renamed. */ indexoidlist = RelationGetIndexList(targetrelation); @@ -177,9 +178,8 @@ renameatt(char *relname, HeapTuple indextup; /* - * First check to see if index is a functional index. - * If so, its column name is a function name and shouldn't - * be renamed here. + * First check to see if index is a functional index. If so, its + * column name is a function name and shouldn't be renamed here. */ indextup = SearchSysCache(INDEXRELID, ObjectIdGetDatum(indexoid), @@ -192,9 +192,10 @@ renameatt(char *relname, continue; } ReleaseSysCache(indextup); + /* - * Okay, look to see if any column name of the index matches - * the old attribute name. + * Okay, look to see if any column name of the index matches the + * old attribute name. */ atttup = SearchSysCacheCopy(ATTNAME, ObjectIdGetDatum(indexoid), @@ -206,20 +207,20 @@ renameatt(char *relname, /* * Update the (copied) attribute tuple. */ - StrNCpy(NameStr(((Form_pg_attribute) GETSTRUCT(atttup))->attname), - newattname, NAMEDATALEN); + StrNCpy(NameStr(((Form_pg_attribute) GETSTRUCT(atttup))->attname), + newattname, NAMEDATALEN); - simple_heap_update(attrelation, &atttup->t_self, atttup); + simple_heap_update(attrelation, &atttup->t_self, atttup); /* keep system catalog indices current */ - { - Relation irelations[Num_pg_attr_indices]; - - CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations); - CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup); - CatalogCloseIndices(Num_pg_attr_indices, irelations); - } - heap_freetuple(atttup); + { + Relation irelations[Num_pg_attr_indices]; + + CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations); + CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, atttup); + CatalogCloseIndices(Num_pg_attr_indices, irelations); + } + heap_freetuple(atttup); } freeList(indexoidlist); @@ -332,8 +333,8 @@ renamerel(const char *oldrelname, const char *newrelname) */ if (relkind == RELKIND_VIEW) { - char *oldrulename, - *newrulename; + char *oldrulename, + *newrulename; oldrulename = MakeRetrieveViewRuleName(oldrelname); newrulename = MakeRetrieveViewRuleName(newrelname); diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 80e17caaa8..10954912e7 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.64 2001/09/19 09:48:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.65 2001/10/25 05:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,9 +36,9 @@ #else #define SEQ_MAXVALUE ((int64) 0x7FFFFFFFFFFFFFFF) #endif -#else /* INT64_IS_BUSTED */ +#else /* INT64_IS_BUSTED */ #define SEQ_MAXVALUE ((int64) 0x7FFFFFFF) -#endif /* INT64_IS_BUSTED */ +#endif /* INT64_IS_BUSTED */ #define SEQ_MINVALUE (-SEQ_MAXVALUE) @@ -204,17 +204,17 @@ DefineSequence(CreateSeqStmt *seq) heap_insert(rel, tuple); /* - * After crash REDO of heap_insert above would re-init page and - * our magic number would be lost. We have to log sequence creation. - * This means two log records instead of one -:( + * After crash REDO of heap_insert above would re-init page and our + * magic number would be lost. We have to log sequence creation. This + * means two log records instead of one -:( */ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); START_CRIT_SECTION(); { - xl_seq_rec xlrec; - XLogRecPtr recptr; - XLogRecData rdata[2]; - Form_pg_sequence newseq = (Form_pg_sequence) GETSTRUCT(tuple); + xl_seq_rec xlrec; + XLogRecPtr recptr; + XLogRecData rdata[2]; + Form_pg_sequence newseq = (Form_pg_sequence) GETSTRUCT(tuple); /* We do not log first nextval call, so "advance" sequence here */ newseq->is_called = true; @@ -582,12 +582,12 @@ get_seq_name(text *seqin) if (strlen(seqname) >= NAMEDATALEN) { #ifdef MULTIBYTE - int len; + int len; - len = pg_mbcliplen(seqname, rawlen, NAMEDATALEN-1); + len = pg_mbcliplen(seqname, rawlen, NAMEDATALEN - 1); seqname[len] = '\0'; #else - seqname[NAMEDATALEN-1] = '\0'; + seqname[NAMEDATALEN - 1] = '\0'; #endif } @@ -658,7 +658,6 @@ init_sequence(char *caller, char *name) if (elm != (SeqTable) NULL) { - /* * We are using a seqtable entry left over from a previous xact; * must check for relid change. @@ -674,7 +673,6 @@ init_sequence(char *caller, char *name) } else { - /* * Time to make a new seqtable entry. These entries live as long * as the backend does, so we use plain malloc for them. @@ -713,7 +711,7 @@ CloseSequences(void) for (elm = seqtab; elm != (SeqTable) NULL; elm = elm->next) { rel = elm->rel; - if (rel != (Relation) NULL) /* opened in current xact */ + if (rel != (Relation) NULL) /* opened in current xact */ { elm->rel = (Relation) NULL; heap_close(rel, AccessShareLock); @@ -737,17 +735,17 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) { DefElem *defel = (DefElem *) lfirst(option); - if (strcmp(defel->defname, "increment")==0) + if (strcmp(defel->defname, "increment") == 0) increment_by = defel; - else if (strcmp(defel->defname, "start")==0) + else if (strcmp(defel->defname, "start") == 0) last_value = defel; - else if (strcmp(defel->defname, "maxvalue")==0) + else if (strcmp(defel->defname, "maxvalue") == 0) max_value = defel; - else if (strcmp(defel->defname, "minvalue")==0) + else if (strcmp(defel->defname, "minvalue") == 0) min_value = defel; - else if (strcmp(defel->defname, "cache")==0) + else if (strcmp(defel->defname, "cache") == 0) cache_value = defel; - else if (strcmp(defel->defname, "cycle")==0) + else if (strcmp(defel->defname, "cycle") == 0) { if (defel->arg != (Node *) NULL) elog(ERROR, "DefineSequence: CYCLE ??"); @@ -768,7 +766,7 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) if (new->increment_by > 0) new->max_value = SEQ_MAXVALUE; /* ascending seq */ else - new->max_value = -1; /* descending seq */ + new->max_value = -1; /* descending seq */ } else new->max_value = get_param(max_value); @@ -822,12 +820,12 @@ get_param(DefElem *def) return (int64) intVal(def->arg); /* - * Values too large for int4 will be represented as Float constants - * by the lexer. Accept these if they are valid int8 strings. + * Values too large for int4 will be represented as Float constants by + * the lexer. Accept these if they are valid int8 strings. */ if (IsA(def->arg, Float)) return DatumGetInt64(DirectFunctionCall1(int8in, - CStringGetDatum(strVal(def->arg)))); + CStringGetDatum(strVal(def->arg)))); /* Shouldn't get here unless parser messed up */ elog(ERROR, "DefineSequence: \"%s\" value must be integer", def->defname); diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index de98b33346..e108840d78 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.96 2001/08/23 23:06:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.97 2001/10/25 05:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,17 +34,17 @@ static void InsertTrigger(TriggerDesc *trigdesc, Trigger *trigger, int indx); static HeapTuple GetTupleForTrigger(EState *estate, - ResultRelInfo *relinfo, - ItemPointer tid, - TupleTableSlot **newSlot); + ResultRelInfo *relinfo, + ItemPointer tid, + TupleTableSlot **newSlot); static HeapTuple ExecCallTriggerFunc(TriggerData *trigdata, - FmgrInfo *finfo, - MemoryContext per_tuple_context); + FmgrInfo *finfo, + MemoryContext per_tuple_context); static void DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, - HeapTuple oldtup, HeapTuple newtup); + HeapTuple oldtup, HeapTuple newtup); static void DeferredTriggerExecute(DeferredTriggerEvent event, int itemno, - Relation rel, FmgrInfo *finfo, - MemoryContext per_tuple_context); + Relation rel, FmgrInfo *finfo, + MemoryContext per_tuple_context); void @@ -93,7 +93,6 @@ CreateTrigger(CreateTrigStmt *stmt) constrrelid = InvalidOid; else { - /* * NoLock is probably sufficient here, since we're only * interested in getting the relation's OID... @@ -849,8 +848,8 @@ ExecCallTriggerFunc(TriggerData *trigdata, MemoryContext oldContext; /* - * We cache fmgr lookup info, to avoid making the lookup - * again on each call. + * We cache fmgr lookup info, to avoid making the lookup again on each + * call. */ if (finfo->fn_oid == InvalidOid) fmgr_info(trigdata->tg_trigger->tgfoid, finfo); @@ -915,14 +914,14 @@ ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, LocTriggerData.tg_newtuple = NULL; for (i = 0; i < ntrigs; i++) { - Trigger *trigger = &trigdesc->triggers[tgindx[i]]; + Trigger *trigger = &trigdesc->triggers[tgindx[i]]; if (!trigger->tgenabled) continue; LocTriggerData.tg_trigtuple = oldtuple = newtuple; LocTriggerData.tg_trigger = trigger; newtuple = ExecCallTriggerFunc(&LocTriggerData, - relinfo->ri_TrigFunctions + tgindx[i], + relinfo->ri_TrigFunctions + tgindx[i], GetPerTupleMemoryContext(estate)); if (oldtuple != newtuple && oldtuple != trigtuple) heap_freetuple(oldtuple); @@ -978,14 +977,14 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo, LocTriggerData.tg_newtuple = NULL; for (i = 0; i < ntrigs; i++) { - Trigger *trigger = &trigdesc->triggers[tgindx[i]]; + Trigger *trigger = &trigdesc->triggers[tgindx[i]]; if (!trigger->tgenabled) continue; LocTriggerData.tg_trigtuple = trigtuple; LocTriggerData.tg_trigger = trigger; newtuple = ExecCallTriggerFunc(&LocTriggerData, - relinfo->ri_TrigFunctions + tgindx[i], + relinfo->ri_TrigFunctions + tgindx[i], GetPerTupleMemoryContext(estate)); if (newtuple == NULL) break; @@ -1055,7 +1054,7 @@ ExecBRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, LocTriggerData.tg_relation = relinfo->ri_RelationDesc; for (i = 0; i < ntrigs; i++) { - Trigger *trigger = &trigdesc->triggers[tgindx[i]]; + Trigger *trigger = &trigdesc->triggers[tgindx[i]]; if (!trigger->tgenabled) continue; @@ -1063,7 +1062,7 @@ ExecBRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, LocTriggerData.tg_newtuple = oldtuple = newtuple; LocTriggerData.tg_trigger = trigger; newtuple = ExecCallTriggerFunc(&LocTriggerData, - relinfo->ri_TrigFunctions + tgindx[i], + relinfo->ri_TrigFunctions + tgindx[i], GetPerTupleMemoryContext(estate)); if (oldtuple != newtuple && oldtuple != intuple) heap_freetuple(oldtuple); @@ -1130,8 +1129,8 @@ ltrmark:; else if (!(ItemPointerEquals(&(tuple.t_self), tid))) { TupleTableSlot *epqslot = EvalPlanQual(estate, - relinfo->ri_RangeTableIndex, - &(tuple.t_self)); + relinfo->ri_RangeTableIndex, + &(tuple.t_self)); if (!(TupIsNull(epqslot))) { @@ -1293,7 +1292,6 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate) static void deferredTriggerAddEvent(DeferredTriggerEvent event) { - /* * Since the event list could grow quite long, we keep track of the * list tail and append there, rather than just doing a stupid @@ -1359,7 +1357,7 @@ deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid) * single trigger function. * * Frequently, this will be fired many times in a row for triggers of - * a single relation. Therefore, we cache the open relation and provide + * a single relation. Therefore, we cache the open relation and provide * fmgr lookup cache space at the caller level. * * event: event currently being fired. @@ -1535,8 +1533,8 @@ deferredTriggerInvokeEvents(bool immediate_only) } /* - * 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) { @@ -1544,11 +1542,13 @@ deferredTriggerInvokeEvents(bool immediate_only) heap_close(rel, NoLock); if (finfo) pfree(finfo); + /* * 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. @@ -1667,7 +1667,6 @@ DeferredTriggerBeginXact(void) void DeferredTriggerEndQuery(void) { - /* * Ignore call if we aren't in a transaction. */ @@ -1688,7 +1687,6 @@ DeferredTriggerEndQuery(void) void DeferredTriggerEndXact(void) { - /* * Ignore call if we aren't in a transaction. */ @@ -1713,7 +1711,6 @@ DeferredTriggerEndXact(void) void DeferredTriggerAbortXact(void) { - /* * Ignore call if we aren't in a transaction. */ @@ -1751,7 +1748,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) { if (!IsTransactionBlock()) { - /* * ... outside of a transaction block * @@ -1779,7 +1775,6 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) } else { - /* * ... inside of a transaction block * @@ -2050,7 +2045,7 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, new_event->dte_n_items = ntriggers; for (i = 0; i < ntriggers; i++) { - Trigger *trigger = &trigdesc->triggers[tgindx[i]]; + Trigger *trigger = &trigdesc->triggers[tgindx[i]]; new_event->dte_item[i].dti_tgoid = trigger->tgoid; new_event->dte_item[i].dti_state = @@ -2090,7 +2085,7 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, */ for (i = 0; i < ntriggers; i++) { - Trigger *trigger = &trigdesc->triggers[tgindx[i]]; + Trigger *trigger = &trigdesc->triggers[tgindx[i]]; bool is_ri_trigger; bool key_unchanged; @@ -2125,7 +2120,6 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, if (key_unchanged) { - /* * The key hasn't changed, so no need later to invoke * the trigger at all. But remember other states from @@ -2138,7 +2132,6 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, if (prev_event->dte_event & TRIGGER_DEFERRED_ROW_INSERTED) { - /* * This is a row inserted during our * transaction. So any key value is considered @@ -2153,7 +2146,6 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, } else { - /* * This is a row, previously updated. So if * this key has been changed before, we still @@ -2172,7 +2164,6 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, } else { - /* * Bomb out if this key has been changed before. * Otherwise remember that we do so. diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 518b9942d1..a3103e7209 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.84 2001/09/19 09:48:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.85 2001/10/25 05:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ update_pg_pwd(PG_FUNCTION_ARGS) { /* * ExclusiveLock ensures no one modifies pg_shadow while we read it, - * and that only one backend rewrites the flat file at a time. It's + * and that only one backend rewrites the flat file at a time. It's * OK to allow normal reads of pg_shadow in parallel, however. */ Relation rel = heap_openr(ShadowRelationName, ExclusiveLock); @@ -199,15 +199,17 @@ CreateUser(CreateUserStmt *stmt) sysid_exists = false, havesysid = false; int max_id; - List *item, *option; - char *password = NULL; /* PostgreSQL user password */ - bool encrypt_password = Password_encryption; /* encrypt password? */ - char encrypted_password[MD5_PASSWD_LEN+1]; - int sysid = 0; /* PgSQL system id (valid if havesysid) */ - bool createdb = false; /* Can the user create databases? */ - bool createuser = false; /* Can this user create users? */ - List *groupElts = NIL; /* The groups the user is a member of */ - char *validUntil = NULL; /* The time the login is valid until */ + List *item, + *option; + char *password = NULL; /* PostgreSQL user password */ + bool encrypt_password = Password_encryption; /* encrypt password? */ + char encrypted_password[MD5_PASSWD_LEN + 1]; + int sysid = 0; /* PgSQL system id (valid if havesysid) */ + bool createdb = false; /* Can the user create databases? */ + bool createuser = false; /* Can this user create users? */ + List *groupElts = NIL; /* The groups the user is a member of */ + char *validUntil = NULL; /* The time the login is valid + * until */ DefElem *dpassword = NULL; DefElem *dsysid = NULL; DefElem *dcreatedb = NULL; @@ -218,11 +220,12 @@ CreateUser(CreateUserStmt *stmt) /* Extract options from the statement node tree */ foreach(option, stmt->options) { - DefElem *defel = (DefElem *) lfirst(option); + DefElem *defel = (DefElem *) lfirst(option); if (strcmp(defel->defname, "password") == 0 || strcmp(defel->defname, "encryptedPassword") == 0 || - strcmp(defel->defname, "unencryptedPassword") == 0) { + strcmp(defel->defname, "unencryptedPassword") == 0) + { if (dpassword) elog(ERROR, "CREATE USER: conflicting options"); dpassword = defel; @@ -231,33 +234,38 @@ CreateUser(CreateUserStmt *stmt) else if (strcmp(defel->defname, "unencryptedPassword") == 0) encrypt_password = false; } - else if (strcmp(defel->defname, "sysid") == 0) { + else if (strcmp(defel->defname, "sysid") == 0) + { if (dsysid) elog(ERROR, "CREATE USER: conflicting options"); dsysid = defel; } - else if (strcmp(defel->defname, "createdb") == 0) { + else if (strcmp(defel->defname, "createdb") == 0) + { if (dcreatedb) elog(ERROR, "CREATE USER: conflicting options"); dcreatedb = defel; } - else if (strcmp(defel->defname, "createuser") == 0) { + else if (strcmp(defel->defname, "createuser") == 0) + { if (dcreateuser) elog(ERROR, "CREATE USER: conflicting options"); dcreateuser = defel; } - else if (strcmp(defel->defname, "groupElts") == 0) { + else if (strcmp(defel->defname, "groupElts") == 0) + { if (dgroupElts) elog(ERROR, "CREATE USER: conflicting options"); dgroupElts = defel; } - else if (strcmp(defel->defname, "validUntil") == 0) { + else if (strcmp(defel->defname, "validUntil") == 0) + { if (dvalidUntil) elog(ERROR, "CREATE USER: conflicting options"); dvalidUntil = defel; } else - elog(ERROR,"CREATE USER: option \"%s\" not recognized", + elog(ERROR, "CREATE USER: option \"%s\" not recognized", defel->defname); } @@ -329,7 +337,7 @@ CreateUser(CreateUserStmt *stmt) elog(ERROR, "CREATE USER: sysid %d is already assigned", sysid); /* If no sysid given, use max existing id + 1 */ - if (! havesysid) + if (!havesysid) sysid = max_id + 1; /* @@ -355,7 +363,7 @@ CreateUser(CreateUserStmt *stmt) else { if (!EncryptMD5(password, stmt->user, strlen(stmt->user), - encrypted_password)) + encrypted_password)) elog(ERROR, "CREATE USER: password encryption failed"); new_record[Anum_pg_shadow_passwd - 1] = DirectFunctionCall1(textin, CStringGetDatum(encrypted_password)); @@ -438,26 +446,28 @@ AlterUser(AlterUserStmt *stmt) HeapTuple tuple, new_tuple; bool null; - List *option; - char *password = NULL; /* PostgreSQL user password */ - bool encrypt_password = Password_encryption; /* encrypt password? */ - char encrypted_password[MD5_PASSWD_LEN+1]; - int createdb = -1; /* Can the user create databases? */ - int createuser = -1; /* Can this user create users? */ - char *validUntil = NULL; /* The time the login is valid until */ + List *option; + char *password = NULL; /* PostgreSQL user password */ + bool encrypt_password = Password_encryption; /* encrypt password? */ + char encrypted_password[MD5_PASSWD_LEN + 1]; + int createdb = -1; /* Can the user create databases? */ + int createuser = -1; /* Can this user create users? */ + char *validUntil = NULL; /* The time the login is valid + * until */ DefElem *dpassword = NULL; DefElem *dcreatedb = NULL; DefElem *dcreateuser = NULL; DefElem *dvalidUntil = NULL; /* Extract options from the statement node tree */ - foreach(option,stmt->options) + foreach(option, stmt->options) { - DefElem *defel = (DefElem *) lfirst(option); + DefElem *defel = (DefElem *) lfirst(option); if (strcmp(defel->defname, "password") == 0 || strcmp(defel->defname, "encryptedPassword") == 0 || - strcmp(defel->defname, "unencryptedPassword") == 0) { + strcmp(defel->defname, "unencryptedPassword") == 0) + { if (dpassword) elog(ERROR, "ALTER USER: conflicting options"); dpassword = defel; @@ -466,23 +476,26 @@ AlterUser(AlterUserStmt *stmt) else if (strcmp(defel->defname, "unencryptedPassword") == 0) encrypt_password = false; } - else if (strcmp(defel->defname, "createdb") == 0) { + else if (strcmp(defel->defname, "createdb") == 0) + { if (dcreatedb) elog(ERROR, "ALTER USER: conflicting options"); dcreatedb = defel; } - else if (strcmp(defel->defname, "createuser") == 0) { + else if (strcmp(defel->defname, "createuser") == 0) + { if (dcreateuser) elog(ERROR, "ALTER USER: conflicting options"); dcreateuser = defel; } - else if (strcmp(defel->defname, "validUntil") == 0) { + else if (strcmp(defel->defname, "validUntil") == 0) + { if (dvalidUntil) elog(ERROR, "ALTER USER: conflicting options"); dvalidUntil = defel; } else - elog(ERROR,"ALTER USER: option \"%s\" not recognized", + elog(ERROR, "ALTER USER: option \"%s\" not recognized", defel->defname); } @@ -556,10 +569,10 @@ AlterUser(AlterUserStmt *stmt) /* * createuser (superuser) and catupd * - * XXX It's rather unclear how to handle catupd. It's probably - * best to keep it equal to the superuser status, otherwise you - * could end up with a situation where no existing superuser can - * alter the catalogs, including pg_shadow! + * XXX It's rather unclear how to handle catupd. It's probably best to + * keep it equal to the superuser status, otherwise you could end up + * with a situation where no existing superuser can alter the + * catalogs, including pg_shadow! */ if (createuser < 0) { @@ -588,7 +601,7 @@ AlterUser(AlterUserStmt *stmt) else { if (!EncryptMD5(password, stmt->user, strlen(stmt->user), - encrypted_password)) + encrypted_password)) elog(ERROR, "CREATE USER: password encryption failed"); new_record[Anum_pg_shadow_passwd - 1] = DirectFunctionCall1(textin, CStringGetDatum(encrypted_password)); @@ -719,7 +732,7 @@ DropUser(DropUserStmt *stmt) if (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0))) { - char *dbname; + char *dbname; datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null); @@ -847,20 +860,22 @@ CreateGroup(CreateGroupStmt *stmt) foreach(option, stmt->options) { - DefElem *defel = (DefElem *) lfirst(option); + DefElem *defel = (DefElem *) lfirst(option); - if (strcmp(defel->defname, "sysid") == 0) { + if (strcmp(defel->defname, "sysid") == 0) + { if (dsysid) elog(ERROR, "CREATE GROUP: conflicting options"); dsysid = defel; } - else if (strcmp(defel->defname, "userElts") == 0) { + else if (strcmp(defel->defname, "userElts") == 0) + { if (duserElts) elog(ERROR, "CREATE GROUP: conflicting options"); duserElts = defel; } else - elog(ERROR,"CREATE GROUP: option \"%s\" not recognized", + elog(ERROR, "CREATE GROUP: option \"%s\" not recognized", defel->defname); } @@ -900,7 +915,7 @@ CreateGroup(CreateGroupStmt *stmt) datum = heap_getattr(tuple, Anum_pg_group_grosysid, pg_group_dsc, &null); Assert(!null); - if (havesysid) /* customized id wanted */ + if (havesysid) /* customized id wanted */ sysid_exists = (DatumGetInt32(datum) == sysid); else { @@ -939,7 +954,7 @@ CreateGroup(CreateGroupStmt *stmt) userarray = palloc(ARR_OVERHEAD(1) + length(newlist) * sizeof(int32)); userarray->size = ARR_OVERHEAD(1) + length(newlist) * sizeof(int32); userarray->flags = 0; - ARR_NDIM(userarray) = 1;/* one dimensional array */ + ARR_NDIM(userarray) = 1; /* one dimensional array */ ARR_LBOUND(userarray)[0] = 1; /* axis starts at one */ ARR_DIMS(userarray)[0] = length(newlist); /* axis is this long */ /* fill the array */ @@ -1088,6 +1103,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) if (!member(v, newlist)) newlist = lappend(newlist, v); else + /* * we silently assume here that this error will only come * up in a ALTER GROUP statement diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 991af5d5f3..fa5770b0e8 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -4,7 +4,7 @@ * The postgres vacuum cleaner. * * This file includes the "full" version of VACUUM, as well as control code - * used by all three of full VACUUM, lazy VACUUM, and ANALYZE. See + * used by all three of full VACUUM, lazy VACUUM, and ANALYZE. See * vacuumlazy.c and analyze.c for the rest of the code for the latter two. * * @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.209 2001/09/04 19:12:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.210 2001/10/25 05:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -68,11 +68,11 @@ typedef VacPageData *VacPage; typedef struct VacPageListData { - BlockNumber empty_end_pages; /* Number of "empty" end-pages */ - int num_pages; /* Number of pages in pagedesc */ + BlockNumber empty_end_pages; /* Number of "empty" end-pages */ + int num_pages; /* Number of pages in pagedesc */ int num_allocated_pages; /* Number of allocated pages in * pagedesc */ - VacPage *pagedesc; /* Descriptions of pages */ + VacPage *pagedesc; /* Descriptions of pages */ } VacPageListData; typedef VacPageListData *VacPageList; @@ -96,7 +96,7 @@ typedef VTupleMoveData *VTupleMove; typedef struct VRelStats { - BlockNumber rel_pages; + BlockNumber rel_pages; double rel_tuples; Size min_tlen; Size max_tlen; @@ -122,32 +122,32 @@ static void vacuum_init(VacuumStmt *vacstmt); static void vacuum_shutdown(VacuumStmt *vacstmt); static VRelList getrels(Name VacRelP, const char *stmttype); static void vac_update_dbstats(Oid dbid, - TransactionId vacuumXID, - TransactionId frozenXID); + TransactionId vacuumXID, + TransactionId frozenXID); static void vac_truncate_clog(TransactionId vacuumXID, - TransactionId frozenXID); + TransactionId frozenXID); static void vacuum_rel(Oid relid, VacuumStmt *vacstmt); static void full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt); static void scan_heap(VRelStats *vacrelstats, Relation onerel, - VacPageList vacuum_pages, VacPageList fraged_pages); + VacPageList vacuum_pages, VacPageList fraged_pages); static void repair_frag(VRelStats *vacrelstats, Relation onerel, - VacPageList vacuum_pages, VacPageList fraged_pages, - int nindexes, Relation *Irel); + VacPageList vacuum_pages, VacPageList fraged_pages, + int nindexes, Relation *Irel); static void vacuum_heap(VRelStats *vacrelstats, Relation onerel, - VacPageList vacpagelist); + VacPageList vacpagelist); static void vacuum_page(Relation onerel, Buffer buffer, VacPage vacpage); static void vacuum_index(VacPageList vacpagelist, Relation indrel, - double num_tuples, int keep_tuples); + double num_tuples, int keep_tuples); static void scan_index(Relation indrel, double num_tuples); static bool tid_reaped(ItemPointer itemptr, void *state); static bool dummy_tid_reaped(ItemPointer itemptr, void *state); static void vac_update_fsm(Relation onerel, VacPageList fraged_pages, - BlockNumber rel_pages); + BlockNumber rel_pages); static VacPage copy_vac_page(VacPage vacpage); static void vpage_insert(VacPageList vacpagelist, VacPage vpnew); static void *vac_bsearch(const void *key, const void *base, - size_t nelem, size_t size, - int (*compar) (const void *, const void *)); + size_t nelem, size_t size, + int (*compar) (const void *, const void *)); static int vac_cmp_blk(const void *left, const void *right); static int vac_cmp_offno(const void *left, const void *right); static int vac_cmp_vtlinks(const void *left, const void *right); @@ -227,11 +227,11 @@ vacuum(VacuumStmt *vacstmt) vacuum_init(vacstmt); /* - * Process each selected relation. We are careful to process - * each relation in a separate transaction in order to avoid holding - * too many locks at one time. Also, if we are doing VACUUM ANALYZE, - * the ANALYZE part runs as a separate transaction from the VACUUM - * to further reduce locking. + * Process each selected relation. We are careful to process each + * relation in a separate transaction in order to avoid holding too + * many locks at one time. Also, if we are doing VACUUM ANALYZE, the + * ANALYZE part runs as a separate transaction from the VACUUM to + * further reduce locking. */ for (cur = vrl; cur != (VRelList) NULL; cur = cur->vrl_next) { @@ -271,21 +271,21 @@ vacuum_init(VacuumStmt *vacstmt) if (vacstmt->vacuum && vacstmt->vacrel == NULL) { /* - * 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. + * 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. * * 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. + * 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); @@ -316,11 +316,12 @@ vacuum_shutdown(VacuumStmt *vacstmt) } /* - * If we did a complete vacuum or analyze, then flush the init file that - * relcache.c uses to save startup time. The next backend startup will - * rebuild the init file with up-to-date information from pg_class. - * This lets the optimizer see the stats that we've collected for certain - * critical system indexes. See relcache.c for more details. + * If we did a complete vacuum or analyze, then flush the init file + * that relcache.c uses to save startup time. The next backend startup + * will rebuild the init file with up-to-date information from + * pg_class. This lets the optimizer see the stats that we've + * collected for certain critical system indexes. See relcache.c for + * more details. * * Ignore any failure to unlink the file, since it might not be there if * no backend has been started since the last vacuum. @@ -526,9 +527,10 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples, pgcform->relpages = (int32) num_pages; pgcform->reltuples = num_tuples; pgcform->relhasindex = hasindex; + /* - * If we have discovered that there are no indexes, then there's - * no primary key either. This could be done more thoroughly... + * If we have discovered that there are no indexes, then there's no + * primary key either. This could be done more thoroughly... */ if (!hasindex) pgcform->relhaspkey = false; @@ -606,7 +608,7 @@ vac_update_dbstats(Oid dbid, * seems to be in danger of wrapping around. * * The passed XIDs are simply the ones I just wrote into my pg_database - * entry. They're used to initialize the "min" calculations. + * entry. They're used to initialize the "min" calculations. * * This routine is shared by full and lazy VACUUM. Note that it is only * applied after a database-wide VACUUM operation. @@ -708,26 +710,27 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt) /* * Determine the type of lock we want --- hard exclusive lock for a * FULL vacuum, but just ShareUpdateExclusiveLock for concurrent - * vacuum. Either way, we can be sure that no other backend is vacuuming - * the same table. + * vacuum. Either way, we can be sure that no other backend is + * vacuuming the same table. */ lmode = vacstmt->full ? AccessExclusiveLock : ShareUpdateExclusiveLock; /* - * Open the class, get an appropriate lock on it, and check permissions. + * Open the class, get an appropriate lock on it, and check + * permissions. * * 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_ownercheck includes the superuser case. + * not a shared relation). pg_ownercheck includes the superuser case. * * Note we choose to treat permissions failure as a NOTICE and keep * trying to vacuum the rest of the DB --- is this appropriate? */ onerel = heap_open(relid, lmode); - if (! (pg_ownercheck(GetUserId(), RelationGetRelationName(onerel), - RELNAME) || - (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared))) + if (!(pg_ownercheck(GetUserId(), RelationGetRelationName(onerel), + RELNAME) || + (is_dbadmin(MyDatabaseId) && !onerel->rd_rel->relisshared))) { elog(NOTICE, "Skipping \"%s\" --- only table or database owner can VACUUM it", RelationGetRelationName(onerel)); @@ -773,9 +776,9 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt) /* * If the relation has a secondary toast rel, vacuum that too while we * still hold the session lock on the master table. Note however that - * "analyze" will not get done on the toast table. This is good, - * because the toaster always uses hardcoded index access and statistics - * are totally unimportant for toast relations. + * "analyze" will not get done on the toast table. This is good, + * because the toaster always uses hardcoded index access and + * statistics are totally unimportant for toast relations. */ if (toast_relid != InvalidOid) vacuum_rel(toast_relid, vacstmt); @@ -846,6 +849,7 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) vacrelstats->hasindex = true; #ifdef NOT_USED + /* * reindex in VACUUM is dangerous under WAL. ifdef out until it * becomes safe. @@ -945,7 +949,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, char *relname; VacPage vacpage, vacpagecopy; - BlockNumber empty_pages, + BlockNumber empty_pages, new_pages, changed_pages, empty_end_pages; @@ -1057,12 +1061,13 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin)) { case HEAPTUPLE_DEAD: - tupgone = true; /* we can delete the tuple */ + tupgone = true; /* we can delete the tuple */ break; case HEAPTUPLE_LIVE: + /* - * Tuple is good. Consider whether to replace its xmin - * value with FrozenTransactionId. + * Tuple is good. Consider whether to replace its + * xmin value with FrozenTransactionId. */ if (TransactionIdIsNormal(tuple.t_data->t_xmin) && TransactionIdPrecedes(tuple.t_data->t_xmin, @@ -1075,11 +1080,13 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, } break; case HEAPTUPLE_RECENTLY_DEAD: + /* - * If tuple is recently deleted then we must not remove - * it from relation. + * If tuple is recently deleted then we must not + * remove it from relation. */ nkeep += 1; + /* * If we do shrinking and this tuple is updated one * then remember it to construct updated tuple @@ -1103,18 +1110,20 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, } break; case HEAPTUPLE_INSERT_IN_PROGRESS: + /* - * This should not happen, since we hold exclusive lock - * on the relation; shouldn't we raise an error? + * This should not happen, since we hold exclusive + * lock on the relation; shouldn't we raise an error? */ elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation", relname, blkno, offnum, tuple.t_data->t_xmin); do_shrinking = false; break; case HEAPTUPLE_DELETE_IN_PROGRESS: + /* - * This should not happen, since we hold exclusive lock - * on the relation; shouldn't we raise an error? + * This should not happen, since we hold exclusive + * lock on the relation; shouldn't we raise an error? */ elog(NOTICE, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation", relname, blkno, offnum, tuple.t_data->t_xmax); @@ -1174,7 +1183,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, if (tuple.t_len > max_tlen) max_tlen = tuple.t_len; } - } /* scan along page */ + } /* scan along page */ if (tempPage != (Page) NULL) { @@ -1193,13 +1202,14 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, } free_size += vacpage->free; + /* * Add the page to fraged_pages if it has a useful amount of free - * space. "Useful" means enough for a minimal-sized tuple. - * But we don't know that accurately near the start of the relation, - * so add pages unconditionally if they have >= BLCKSZ/10 free space. + * space. "Useful" means enough for a minimal-sized tuple. But we + * don't know that accurately near the start of the relation, so + * add pages unconditionally if they have >= BLCKSZ/10 free space. */ - do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ/10); + do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ / 10); if (do_reap || do_frag) { @@ -1238,9 +1248,9 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, fraged_pages->empty_end_pages = empty_end_pages; /* - * Clear the fraged_pages list if we found we couldn't shrink. - * Else, remove any "empty" end-pages from the list, and compute - * usable free space = free space in remaining pages. + * Clear the fraged_pages list if we found we couldn't shrink. Else, + * remove any "empty" end-pages from the list, and compute usable free + * space = free space in remaining pages. */ if (do_shrinking) { @@ -1303,9 +1313,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, CommandId myCID; Buffer buf, cur_buffer; - BlockNumber nblocks, + BlockNumber nblocks, blkno; - BlockNumber last_move_dest_block = 0, + BlockNumber last_move_dest_block = 0, last_vacuum_block; Page page, ToPage = NULL; @@ -1355,7 +1365,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, resultRelInfo = makeNode(ResultRelInfo); resultRelInfo->ri_RangeTableIndex = 1; /* dummy */ resultRelInfo->ri_RelationDesc = onerel; - resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */ + resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */ ExecOpenIndices(resultRelInfo); @@ -1393,9 +1403,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* * Scan pages backwards from the last nonempty page, trying to move * tuples down to lower pages. Quit when we reach a page that we have - * moved any tuples onto, or the first page if we haven't moved anything, - * or when we find a page we cannot completely empty (this last condition - * is handled by "break" statements within the loop). + * moved any tuples onto, or the first page if we haven't moved + * anything, or when we find a page we cannot completely empty (this + * last condition is handled by "break" statements within the loop). * * NB: this code depends on the vacuum_pages and fraged_pages lists being * in order by blkno. @@ -1406,19 +1416,20 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, blkno--) { /* - * Forget fraged_pages pages at or after this one; they're no longer - * useful as move targets, since we only want to move down. Note - * that since we stop the outer loop at last_move_dest_block, pages - * removed here cannot have had anything moved onto them already. + * Forget fraged_pages pages at or after this one; they're no + * longer useful as move targets, since we only want to move down. + * Note that since we stop the outer loop at last_move_dest_block, + * pages removed here cannot have had anything moved onto them + * already. * - * Also note that we don't change the stored fraged_pages list, - * only our local variable num_fraged_pages; so the forgotten pages - * are still available to be loaded into the free space map later. + * Also note that we don't change the stored fraged_pages list, only + * our local variable num_fraged_pages; so the forgotten pages are + * still available to be loaded into the free space map later. */ while (num_fraged_pages > 0 && - fraged_pages->pagedesc[num_fraged_pages-1]->blkno >= blkno) + fraged_pages->pagedesc[num_fraged_pages - 1]->blkno >= blkno) { - Assert(fraged_pages->pagedesc[num_fraged_pages-1]->offsets_used == 0); + Assert(fraged_pages->pagedesc[num_fraged_pages - 1]->offsets_used == 0); --num_fraged_pages; } @@ -1534,7 +1545,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, * tuples to another places. */ if ((tuple.t_data->t_infomask & HEAP_UPDATED && - !TransactionIdPrecedes(tuple.t_data->t_xmin, OldestXmin)) || + !TransactionIdPrecedes(tuple.t_data->t_xmin, OldestXmin)) || (!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) && !(ItemPointerEquals(&(tuple.t_self), &(tuple.t_data->t_ctid))))) @@ -1581,7 +1592,6 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, ItemPointerGetOffsetNumber(&Ctid)); if (!ItemIdIsUsed(Citemid)) { - /* * This means that in the middle of chain there * was tuple updated by older (than OldestXmin) @@ -1652,7 +1662,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* All done ? */ if (!(tp.t_data->t_infomask & HEAP_UPDATED) || - TransactionIdPrecedes(tp.t_data->t_xmin, OldestXmin)) + TransactionIdPrecedes(tp.t_data->t_xmin, OldestXmin)) break; /* Well, try to find tuple with old row version */ @@ -2109,9 +2119,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* * We are not going to move any more tuples across pages, but we still * need to apply vacuum_page to compact free space in the remaining - * pages in vacuum_pages list. Note that some of these pages may also - * be in the fraged_pages list, and may have had tuples moved onto them; - * if so, we already did vacuum_page and needn't do it again. + * pages in vacuum_pages list. Note that some of these pages may also + * be in the fraged_pages list, and may have had tuples moved onto + * them; if so, we already did vacuum_page and needn't do it again. */ for (i = 0, curpage = vacuum_pages->pagedesc; i < vacuumed_pages; @@ -2132,15 +2142,15 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* - * Now scan all the pages that we moved tuples onto and update - * tuple status bits. This is not really necessary, but will save time - * for future transactions examining these tuples. + * Now scan all the pages that we moved tuples onto and update tuple + * status bits. This is not really necessary, but will save time for + * future transactions examining these tuples. * * XXX Notice that this code fails to clear HEAP_MOVED_OFF tuples from - * pages that were move source pages but not move dest pages. One also - * wonders whether it wouldn't be better to skip this step and let the - * tuple status updates happen someplace that's not holding an exclusive - * lock on the relation. + * pages that were move source pages but not move dest pages. One + * also wonders whether it wouldn't be better to skip this step and + * let the tuple status updates happen someplace that's not holding an + * exclusive lock on the relation. */ checked_moved = 0; for (i = 0, curpage = fraged_pages->pagedesc; @@ -2226,7 +2236,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (vacpage->blkno == (blkno - 1) && vacpage->offsets_free > 0) { - OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)]; + OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)]; OffsetNumber *unused = unbuf; int uncnt; @@ -2297,7 +2307,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (blkno < nblocks) { blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno); - onerel->rd_nblocks = blkno; /* update relcache immediately */ + onerel->rd_nblocks = blkno; /* update relcache immediately */ onerel->rd_targblock = InvalidBlockNumber; vacrelstats->rel_pages = blkno; /* set new number of blocks */ } @@ -2323,7 +2333,7 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages) { Buffer buf; VacPage *vacpage; - BlockNumber relblocks; + BlockNumber relblocks; int nblocks; int i; @@ -2363,7 +2373,7 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages) RelationGetRelationName(onerel), vacrelstats->rel_pages, relblocks); relblocks = smgrtruncate(DEFAULT_SMGR, onerel, relblocks); - onerel->rd_nblocks = relblocks; /* update relcache immediately */ + onerel->rd_nblocks = relblocks; /* update relcache immediately */ onerel->rd_targblock = InvalidBlockNumber; vacrelstats->rel_pages = relblocks; /* set new number of * blocks */ @@ -2377,7 +2387,7 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages) static void vacuum_page(Relation onerel, Buffer buffer, VacPage vacpage) { - OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)]; + OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)]; OffsetNumber *unused = unbuf; int uncnt; Page page = BufferGetPage(buffer); @@ -2420,8 +2430,8 @@ scan_index(Relation indrel, double num_tuples) /* * Even though we're not planning to delete anything, use the - * ambulkdelete call, so that the scan happens within the index AM - * for more speed. + * ambulkdelete call, so that the scan happens within the index AM for + * more speed. */ stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL); @@ -2439,13 +2449,13 @@ scan_index(Relation indrel, double num_tuples) vac_show_rusage(&ru0)); /* - * Check for tuple count mismatch. If the index is partial, then - * it's OK for it to have fewer tuples than the heap; else we got trouble. + * Check for tuple count mismatch. If the index is partial, then it's + * OK for it to have fewer tuples than the heap; else we got trouble. */ if (stats->num_index_tuples != num_tuples) { if (stats->num_index_tuples > num_tuples || - ! vac_is_partial_index(indrel)) + !vac_is_partial_index(indrel)) elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%.0f) IS NOT THE SAME AS HEAP' (%.0f).\ \n\tRecreate the index.", RelationGetRelationName(indrel), @@ -2493,13 +2503,13 @@ vacuum_index(VacPageList vacpagelist, Relation indrel, vac_show_rusage(&ru0)); /* - * Check for tuple count mismatch. If the index is partial, then - * it's OK for it to have fewer tuples than the heap; else we got trouble. + * Check for tuple count mismatch. If the index is partial, then it's + * OK for it to have fewer tuples than the heap; else we got trouble. */ if (stats->num_index_tuples != num_tuples + keep_tuples) { if (stats->num_index_tuples > num_tuples + keep_tuples || - ! vac_is_partial_index(indrel)) + !vac_is_partial_index(indrel)) elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%.0f) IS NOT THE SAME AS HEAP' (%.0f).\ \n\tRecreate the index.", RelationGetRelationName(indrel), @@ -2519,7 +2529,7 @@ vacuum_index(VacPageList vacpagelist, Relation indrel, static bool tid_reaped(ItemPointer itemptr, void *state) { - VacPageList vacpagelist = (VacPageList) state; + VacPageList vacpagelist = (VacPageList) state; OffsetNumber ioffno; OffsetNumber *voff; VacPage vp, @@ -2591,9 +2601,11 @@ vac_update_fsm(Relation onerel, VacPageList fraged_pages, { pages[i] = fraged_pages->pagedesc[i]->blkno; spaceAvail[i] = fraged_pages->pagedesc[i]->free; + /* - * fraged_pages may contain entries for pages that we later decided - * to truncate from the relation; don't enter them into the map! + * fraged_pages may contain entries for pages that we later + * decided to truncate from the relation; don't enter them into + * the map! */ if (pages[i] >= rel_pages) { @@ -2617,7 +2629,7 @@ copy_vac_page(VacPage vacpage) /* allocate a VacPageData entry */ newvacpage = (VacPage) palloc(sizeof(VacPageData) + - vacpage->offsets_free * sizeof(OffsetNumber)); + vacpage->offsets_free * sizeof(OffsetNumber)); /* fill it in */ if (vacpage->offsets_free > 0) @@ -2661,7 +2673,7 @@ vpage_insert(VacPageList vacpagelist, VacPage vpnew) /* * vac_bsearch: just like standard C library routine bsearch(), * except that we first test to see whether the target key is outside - * the range of the table entries. This case is handled relatively slowly + * the range of the table entries. This case is handled relatively slowly * by the normal binary search algorithm (ie, no faster than any other key) * but it occurs often enough in VACUUM to be worth optimizing. */ @@ -2802,14 +2814,15 @@ vac_is_partial_index(Relation indrel) Form_pg_index indexStruct; /* - * If the index's AM doesn't support nulls, it's partial for our purposes + * If the index's AM doesn't support nulls, it's partial for our + * purposes */ - if (! indrel->rd_am->amindexnulls) + if (!indrel->rd_am->amindexnulls) return true; /* Otherwise, look to see if there's a partial-index predicate */ cachetuple = SearchSysCache(INDEXRELID, - ObjectIdGetDatum(RelationGetRelid(indrel)), + ObjectIdGetDatum(RelationGetRelid(indrel)), 0, 0, 0); if (!HeapTupleIsValid(cachetuple)) elog(ERROR, "vac_is_partial_index: index %u not found", @@ -2888,9 +2901,9 @@ vac_show_rusage(VacRUsage *ru0) snprintf(result, sizeof(result), "CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec.", (int) (ru1.ru.ru_stime.tv_sec - ru0->ru.ru_stime.tv_sec), - (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000, + (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000, (int) (ru1.ru.ru_utime.tv_sec - ru0->ru.ru_utime.tv_sec), - (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000, + (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000, (int) (ru1.tv.tv_sec - ru0->tv.tv_sec), (int) (ru1.tv.tv_usec - ru0->tv.tv_usec) / 10000); diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 38405f6c6c..8431dcdb0f 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -18,8 +18,8 @@ * * We can limit the storage for page free space to MaxFSMPages entries, * since that's the most the free space map will be willing to remember - * anyway. If the relation has fewer than that many pages with free space, - * life is easy: just build an array of per-page info. If it has more, + * anyway. If the relation has fewer than that many pages with free space, + * life is easy: just build an array of per-page info. If it has more, * we store the free space info as a heap ordered by amount of free space, * so that we can discard the pages with least free space to ensure we never * have more than MaxFSMPages entries in all. The surviving page entries @@ -31,7 +31,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.8 2001/09/29 04:02:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.9 2001/10/25 05:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ * Space/time tradeoff parameters: do these need to be user-tunable? * * A page with less than PAGE_SPACE_THRESHOLD free space will be forgotten - * immediately, and not even passed to the free space map. Removing the + * immediately, and not even passed to the free space map. Removing the * uselessly small entries early saves cycles, and in particular reduces * the amount of time we spend holding the FSM lock when we finally call * MultiRecordFreeSpace. Since the FSM will ignore pages below its own @@ -74,21 +74,21 @@ typedef struct LVRelStats { /* Overall statistics about rel */ - BlockNumber rel_pages; + BlockNumber rel_pages; double rel_tuples; - BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */ + BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */ /* List of TIDs of tuples we intend to delete */ /* NB: this list is ordered by TID address */ - int num_dead_tuples; /* current # of entries */ - int max_dead_tuples; /* # slots allocated in array */ - ItemPointer dead_tuples; /* array of ItemPointerData */ + int num_dead_tuples; /* current # of entries */ + int max_dead_tuples; /* # slots allocated in array */ + ItemPointer dead_tuples; /* array of ItemPointerData */ /* Array or heap of per-page info about free space */ /* We use a simple array until it fills up, then convert to heap */ - bool fs_is_heap; /* are we using heap organization? */ - int num_free_pages; /* current # of entries */ - int max_free_pages; /* # slots allocated in arrays */ - BlockNumber *free_pages; /* array or heap of block numbers */ - Size *free_spaceavail; /* array or heap of available space */ + bool fs_is_heap; /* are we using heap organization? */ + int num_free_pages; /* current # of entries */ + int max_free_pages; /* # slots allocated in arrays */ + BlockNumber *free_pages; /* array or heap of block numbers */ + Size *free_spaceavail; /* array or heap of available space */ } LVRelStats; @@ -100,20 +100,20 @@ static TransactionId FreezeLimit; /* non-export function prototypes */ static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, - Relation *Irel, int nindexes); + Relation *Irel, int nindexes); static void lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats); static void lazy_scan_index(Relation indrel, LVRelStats *vacrelstats); static void lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats); -static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, - int tupindex, LVRelStats *vacrelstats); +static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, + int tupindex, LVRelStats *vacrelstats); static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats); static BlockNumber count_nondeletable_pages(Relation onerel, - LVRelStats *vacrelstats); + LVRelStats *vacrelstats); static void lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks); static void lazy_record_dead_tuple(LVRelStats *vacrelstats, - ItemPointer itemptr); + ItemPointer itemptr); static void lazy_record_free_space(LVRelStats *vacrelstats, - BlockNumber page, Size avail); + BlockNumber page, Size avail); static bool lazy_tid_reaped(ItemPointer itemptr, void *state); static bool dummy_tid_reaped(ItemPointer itemptr, void *state); static void lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats); @@ -136,7 +136,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) Relation *Irel; int nindexes; bool hasindex; - BlockNumber possibly_freeable; + BlockNumber possibly_freeable; /* initialize */ if (vacstmt->verbose) @@ -163,8 +163,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) /* * Optionally truncate the relation. * - * Don't even think about it unless we have a shot at releasing a - * goodly number of pages. Otherwise, the time taken isn't worth it. + * Don't even think about it unless we have a shot at releasing a goodly + * number of pages. Otherwise, the time taken isn't worth it. */ possibly_freeable = vacrelstats->rel_pages - vacrelstats->nonempty_pages; if (possibly_freeable > vacrelstats->rel_pages / REL_TRUNCATE_FRACTION) @@ -195,7 +195,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, blkno; HeapTupleData tuple; char *relname; - BlockNumber empty_pages, + BlockNumber empty_pages, changed_pages; double num_tuples, tups_vacuumed, @@ -231,8 +231,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, int prev_dead_count; /* - * If we are close to overrunning the available space for dead-tuple - * TIDs, pause and do a cycle of vacuuming before we tackle this page. + * If we are close to overrunning the available space for + * dead-tuple TIDs, pause and do a cycle of vacuuming before we + * tackle this page. */ if ((vacrelstats->max_dead_tuples - vacrelstats->num_dead_tuples) < MAX_TUPLES_PER_PAGE && vacrelstats->num_dead_tuples > 0) @@ -312,17 +313,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin)) { case HEAPTUPLE_DEAD: - tupgone = true; /* we can delete the tuple */ + tupgone = true; /* we can delete the tuple */ break; case HEAPTUPLE_LIVE: + /* - * Tuple is good. Consider whether to replace its xmin - * value with FrozenTransactionId. + * Tuple is good. Consider whether to replace its + * xmin value with FrozenTransactionId. * - * NB: Since we hold only a shared buffer lock here, - * we are assuming that TransactionId read/write - * is atomic. This is not the only place that makes - * such an assumption. It'd be possible to avoid the + * NB: Since we hold only a shared buffer lock here, we + * are assuming that TransactionId read/write is + * atomic. This is not the only place that makes such + * an assumption. It'd be possible to avoid the * assumption by momentarily acquiring exclusive lock, * but for the moment I see no need to. */ @@ -337,9 +339,10 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, } break; case HEAPTUPLE_RECENTLY_DEAD: + /* - * If tuple is recently deleted then we must not remove - * it from relation. + * If tuple is recently deleted then we must not + * remove it from relation. */ nkeep += 1; break; @@ -376,11 +379,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, num_tuples += 1; hastup = true; } - } /* scan along page */ + } /* scan along page */ /* - * If we remembered any tuples for deletion, then the page will - * be visited again by lazy_vacuum_heap, which will compute and + * If we remembered any tuples for deletion, then the page will be + * visited again by lazy_vacuum_heap, which will compute and * record its post-compaction free space. If not, then we're done * with this page, so remember its free space as-is. */ @@ -418,7 +421,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, /* Remove tuples from heap */ lazy_vacuum_heap(onerel, vacrelstats); } - else if (! did_vacuum_index) + else if (!did_vacuum_index) { /* Scan indexes just to update pg_class statistics about them */ for (i = 0; i < nindexes; i++) @@ -457,7 +460,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) tupindex = 0; while (tupindex < vacrelstats->num_dead_tuples) { - BlockNumber tblk; + BlockNumber tblk; Buffer buf; Page page; @@ -493,7 +496,7 @@ static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, int tupindex, LVRelStats *vacrelstats) { - OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)]; + OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)]; OffsetNumber *unused = unbuf; int uncnt; Page page = BufferGetPage(buffer); @@ -502,8 +505,8 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, START_CRIT_SECTION(); for (; tupindex < vacrelstats->num_dead_tuples; tupindex++) { - BlockNumber tblk; - OffsetNumber toff; + BlockNumber tblk; + OffsetNumber toff; tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]); if (tblk != blkno) @@ -542,10 +545,10 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) vac_init_rusage(&ru0); /* - * If the index is not partial, skip the scan, and just assume it - * has the same number of tuples as the heap. + * If the index is not partial, skip the scan, and just assume it has + * the same number of tuples as the heap. */ - if (! vac_is_partial_index(indrel)) + if (!vac_is_partial_index(indrel)) { vac_update_relstats(RelationGetRelid(indrel), RelationGetNumberOfBlocks(indrel), @@ -555,23 +558,23 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) } /* - * If index is unsafe for concurrent access, must lock it; - * but a shared lock should be sufficient. + * If index is unsafe for concurrent access, must lock it; but a + * shared lock should be sufficient. */ - if (! indrel->rd_am->amconcurrent) + if (!indrel->rd_am->amconcurrent) LockRelation(indrel, AccessShareLock); /* * Even though we're not planning to delete anything, use the - * ambulkdelete call, so that the scan happens within the index AM - * for more speed. + * ambulkdelete call, so that the scan happens within the index AM for + * more speed. */ stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL); /* * Release lock acquired above. */ - if (! indrel->rd_am->amconcurrent) + if (!indrel->rd_am->amconcurrent) UnlockRelation(indrel, AccessShareLock); if (!stats) @@ -610,7 +613,7 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats) /* * If index is unsafe for concurrent access, must lock it. */ - if (! indrel->rd_am->amconcurrent) + if (!indrel->rd_am->amconcurrent) LockRelation(indrel, AccessExclusiveLock); /* Do bulk deletion */ @@ -619,7 +622,7 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats) /* * Release lock acquired above. */ - if (! indrel->rd_am->amconcurrent) + if (!indrel->rd_am->amconcurrent) UnlockRelation(indrel, AccessExclusiveLock); /* now update statistics in pg_class */ @@ -644,8 +647,8 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats) static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) { - BlockNumber old_rel_pages = vacrelstats->rel_pages; - BlockNumber new_rel_pages; + BlockNumber old_rel_pages = vacrelstats->rel_pages; + BlockNumber new_rel_pages; BlockNumber *pages; Size *spaceavail; int n; @@ -656,12 +659,13 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) vac_init_rusage(&ru0); /* - * We need full exclusive lock on the relation in order to do truncation. - * If we can't get it, give up rather than waiting --- we don't want - * to block other backends, and we don't want to deadlock (which is - * quite possible considering we already hold a lower-grade lock). + * We need full exclusive lock on the relation in order to do + * truncation. If we can't get it, give up rather than waiting --- we + * don't want to block other backends, and we don't want to deadlock + * (which is quite possible considering we already hold a lower-grade + * lock). */ - if (! ConditionalLockRelation(onerel, AccessExclusiveLock)) + if (!ConditionalLockRelation(onerel, AccessExclusiveLock)) return; /* @@ -680,9 +684,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) /* * Scan backwards from the end to verify that the end pages actually - * contain nothing we need to keep. This is *necessary*, not optional, - * because other backends could have added tuples to these pages whilst - * we were vacuuming. + * contain nothing we need to keep. This is *necessary*, not + * optional, because other backends could have added tuples to these + * pages whilst we were vacuuming. */ new_rel_pages = count_nondeletable_pages(onerel, vacrelstats); @@ -710,9 +714,10 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) * Do the physical truncation. */ new_rel_pages = smgrtruncate(DEFAULT_SMGR, onerel, new_rel_pages); - onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */ + onerel->rd_nblocks = new_rel_pages; /* update relcache immediately */ onerel->rd_targblock = InvalidBlockNumber; - vacrelstats->rel_pages = new_rel_pages; /* save new number of blocks */ + vacrelstats->rel_pages = new_rel_pages; /* save new number of + * blocks */ /* * Drop free-space info for removed blocks; these must not get entered @@ -808,15 +813,16 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin)) { case HEAPTUPLE_DEAD: - tupgone = true; /* we can delete the tuple */ + tupgone = true; /* we can delete the tuple */ break; case HEAPTUPLE_LIVE: /* Shouldn't be necessary to re-freeze anything */ break; case HEAPTUPLE_RECENTLY_DEAD: + /* - * If tuple is recently deleted then we must not remove - * it from relation. + * If tuple is recently deleted then we must not + * remove it from relation. */ break; case HEAPTUPLE_INSERT_IN_PROGRESS: @@ -839,7 +845,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) hastup = true; break; /* can stop scanning */ } - } /* scan along page */ + } /* scan along page */ LockBuffer(buf, BUFFER_LOCK_UNLOCK); @@ -855,8 +861,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) /* * If we fall out of the loop, all the previously-thought-to-be-empty - * pages really are; we need not bother to look at the last known-nonempty - * page. + * pages really are; we need not bother to look at the last + * known-nonempty page. */ return vacrelstats->nonempty_pages; } @@ -907,9 +913,9 @@ lazy_record_dead_tuple(LVRelStats *vacrelstats, ItemPointer itemptr) { /* - * The array shouldn't overflow under normal behavior, - * but perhaps it could if we are given a really small VacuumMem. - * In that case, just forget the last few tuples. + * The array shouldn't overflow under normal behavior, but perhaps it + * could if we are given a really small VacuumMem. In that case, just + * forget the last few tuples. */ if (vacrelstats->num_dead_tuples < vacrelstats->max_dead_tuples) { @@ -960,29 +966,29 @@ lazy_record_free_space(LVRelStats *vacrelstats, */ /* If we haven't yet converted the array to heap organization, do it */ - if (! vacrelstats->fs_is_heap) + if (!vacrelstats->fs_is_heap) { /* * Scan backwards through the array, "sift-up" each value into its - * correct position. We can start the scan at n/2-1 since each entry - * above that position has no children to worry about. + * correct position. We can start the scan at n/2-1 since each + * entry above that position has no children to worry about. */ - int l = n / 2; + int l = n / 2; while (--l >= 0) { - BlockNumber R = pages[l]; + BlockNumber R = pages[l]; Size K = spaceavail[l]; int i; /* i is where the "hole" is */ i = l; for (;;) { - int j = 2*i + 1; + int j = 2 * i + 1; if (j >= n) break; - if (j+1 < n && spaceavail[j] > spaceavail[j+1]) + if (j + 1 < n && spaceavail[j] > spaceavail[j + 1]) j++; if (K <= spaceavail[j]) break; @@ -1001,20 +1007,20 @@ lazy_record_free_space(LVRelStats *vacrelstats, if (avail > spaceavail[0]) { /* - * Notionally, we replace the zero'th entry with the new data, - * and then sift-up to maintain the heap property. Physically, - * the new data doesn't get stored into the arrays until we find - * the right location for it. + * Notionally, we replace the zero'th entry with the new data, and + * then sift-up to maintain the heap property. Physically, the + * new data doesn't get stored into the arrays until we find the + * right location for it. */ - int i = 0; /* i is where the "hole" is */ + int i = 0; /* i is where the "hole" is */ for (;;) { - int j = 2*i + 1; + int j = 2 * i + 1; if (j >= n) break; - if (j+1 < n && spaceavail[j] > spaceavail[j+1]) + if (j + 1 < n && spaceavail[j] > spaceavail[j + 1]) j++; if (avail <= spaceavail[j]) break; @@ -1038,7 +1044,7 @@ static bool lazy_tid_reaped(ItemPointer itemptr, void *state) { LVRelStats *vacrelstats = (LVRelStats *) state; - ItemPointer res; + ItemPointer res; res = (ItemPointer) bsearch((void *) itemptr, (void *) vacrelstats->dead_tuples, @@ -1066,9 +1072,9 @@ static void lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats) { /* - * Since MultiRecordFreeSpace doesn't currently impose any restrictions - * on the ordering of the input, we can just pass it the arrays as-is, - * whether they are in heap or linear order. + * Since MultiRecordFreeSpace doesn't currently impose any + * restrictions on the ordering of the input, we can just pass it the + * arrays as-is, whether they are in heap or linear order. */ MultiRecordFreeSpace(&onerel->rd_node, 0, MaxBlockNumber, diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 9da6776074..4ed17e8fbe 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.54 2001/10/18 17:30:14 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.55 2001/10/25 05:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -334,9 +334,10 @@ set_default_datestyle(void) */ DBDate = strdup(DBDate); - /* Parse desired setting into DateStyle/EuroDates - * Use parse_datestyle_internal() to avoid any palloc() issues per above - * - thomas 2001-10-15 + /* + * Parse desired setting into DateStyle/EuroDates Use + * parse_datestyle_internal() to avoid any palloc() issues per above - + * thomas 2001-10-15 */ parse_datestyle_internal(DBDate); @@ -380,7 +381,7 @@ parse_timezone(List *args) foreach(arg, args) { - A_Const *p; + A_Const *p; Assert(IsA(arg, List)); p = lfirst(arg); @@ -394,24 +395,28 @@ parse_timezone(List *args) Interval *interval; interval = DatumGetIntervalP(DirectFunctionCall3(interval_in, - CStringGetDatum(p->val.val.str), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + CStringGetDatum(p->val.val.str), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); if (interval->month != 0) elog(ERROR, "SET TIME ZONE illegal INTERVAL; month not allowed"); CTimeZone = interval->time; } else if (strcmp(type->name, "float8") == 0) { - float8 time; + float8 time; time = DatumGetFloat8(DirectFunctionCall1(float8in, CStringGetDatum(p->val.val.str))); CTimeZone = time * 3600; } - /* We do not actually generate an integer constant in gram.y so this is not used... */ + + /* + * We do not actually generate an integer constant in gram.y + * so this is not used... + */ else if (strcmp(type->name, "int4") == 0) { - int32 time; + int32 time; time = p->val.val.ival; CTimeZone = time * 3600; @@ -462,11 +467,11 @@ parse_timezone(List *args) static bool show_timezone(void) { - char *tzn; + char *tzn; if (HasCTZSet) { - Interval interval; + Interval interval; interval.month = 0; interval.time = CTimeZone; @@ -474,9 +479,7 @@ show_timezone(void) tzn = DatumGetCString(DirectFunctionCall1(interval_out, IntervalPGetDatum(&interval))); } else - { tzn = getenv("TZ"); - } if (tzn != NULL) elog(NOTICE, "Time zone is '%s'", tzn); @@ -500,9 +503,7 @@ static bool reset_timezone(void) { if (HasCTZSet) - { HasCTZSet = false; - } /* no time zone has been set in this session? */ else if (defaultTZ == NULL) @@ -545,7 +546,7 @@ reset_timezone(void) static bool parse_XactIsoLevel(List *args) { - char *value; + char *value; if (args == NULL) return reset_XactIsoLevel(); @@ -603,8 +604,8 @@ reset_XactIsoLevel(void) static bool parse_random_seed(List *args) { - char *value; - double seed = 0; + char *value; + double seed = 0; if (args == NULL) return reset_random_seed(); @@ -648,9 +649,10 @@ reset_random_seed(void) static bool parse_client_encoding(List *args) { - char *value; + char *value; + #ifdef MULTIBYTE - int encoding; + int encoding; #endif if (args == NULL) @@ -679,7 +681,7 @@ parse_client_encoding(List *args) } #else if (value && - strcasecmp(value, pg_get_client_encoding_name()) != 0) + strcasecmp(value, pg_get_client_encoding_name()) != 0) elog(ERROR, "Client encoding %s is not supported", value); #endif return TRUE; @@ -766,14 +768,14 @@ SetPGVariable(const char *name, List *args) parse_random_seed(args); else { - /* For routines defined somewhere else, - * go ahead and extract the string argument - * to match the original interface definition. + /* + * For routines defined somewhere else, go ahead and extract the + * string argument to match the original interface definition. * Later, we can change this code too... */ - char *value; + char *value; - value = ((args != NULL)? ((A_Const *) lfirst(args))->val.val.str: NULL); + value = ((args != NULL) ? ((A_Const *) lfirst(args))->val.val.str : NULL); if (strcasecmp(name, "session_authorization") == 0) SetSessionAuthorization(value); diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 2bb9fd75a7..9d1254a4cb 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: view.c,v 1.57 2001/08/16 20:38:53 tgl Exp $ + * $Id: view.c,v 1.58 2001/10/25 05:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,7 +131,6 @@ DefineViewRules(char *viewName, Query *viewParse) RuleStmt *replace_rule; RuleStmt *append_rule; RuleStmt *delete_rule; - #endif retrieve_rule = FormViewRetrieveRule(viewName, viewParse); @@ -141,7 +140,6 @@ DefineViewRules(char *viewName, Query *viewParse) replace_rule = FormViewReplaceRule(viewName, viewParse); append_rule = FormViewAppendRule(viewName, viewParse); delete_rule = FormViewDeleteRule(viewName, viewParse); - #endif DefineQueryRewrite(retrieve_rule); @@ -229,7 +227,6 @@ UpdateRangeTableOfViewParse(char *viewName, Query *viewParse) void DefineView(char *viewName, Query *viewParse) { - /* * Create the "view" relation NOTE: if it already exists, the xact * will be aborted. @@ -264,7 +261,6 @@ DefineView(char *viewName, Query *viewParse) void RemoveView(char *viewName) { - /* * We just have to drop the relation; the associated rules will be * cleaned up automatically. diff --git a/src/backend/executor/_deadcode/nodeTee.c b/src/backend/executor/_deadcode/nodeTee.c index 5ec43e377e..dd7460634e 100644 --- a/src/backend/executor/_deadcode/nodeTee.c +++ b/src/backend/executor/_deadcode/nodeTee.c @@ -15,7 +15,7 @@ * ExecInitTee * ExecEndTee * - * $Id: nodeTee.c,v 1.10 2001/03/22 06:16:13 momjian Exp $ + * $Id: nodeTee.c,v 1.11 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -336,7 +336,6 @@ ExecTee(Tee * node, Plan *parent) slot = ExecProcNode(childNode, (Plan *) node); if (!TupIsNull(slot)) { - /* * heap_insert changes something... */ @@ -361,7 +360,6 @@ ExecTee(Tee * node, Plan *parent) teeState->tee_leftScanDesc : teeState->tee_rightScanDesc; { - /* * move the scandesc forward so we don't re-read this * tuple later diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index 6303613faa..af0e190d39 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execAmi.c,v 1.59 2001/09/18 01:59:06 tgl Exp $ + * $Id: execAmi.c,v 1.60 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -224,7 +224,6 @@ ExecCloseR(Plan *node) for (i = 0; i < numIndices; i++) { - /* * shut down each of the index scans and close each of the * index relations @@ -410,7 +409,7 @@ ExecMarkPos(Plan *node) { switch (nodeTag(node)) { - case T_SeqScan: + case T_SeqScan: ExecSeqMarkPos((SeqScan *) node); break; @@ -452,7 +451,7 @@ ExecRestrPos(Plan *node) { switch (nodeTag(node)) { - case T_SeqScan: + case T_SeqScan: ExecSeqRestrPos((SeqScan *) node); break; diff --git a/src/backend/executor/execFlatten.c b/src/backend/executor/execFlatten.c index 3be50c09bb..8d1eaea402 100644 --- a/src/backend/executor/execFlatten.c +++ b/src/backend/executor/execFlatten.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.14 2001/01/24 19:42:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.15 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,6 @@ #ifdef SETS_FIXED static bool FjoinBumpOuterNodes(TargetEntry *tlist, ExprContext *econtext, DatumPtr results, char *nulls); - #endif @@ -81,7 +80,6 @@ ExecEvalFjoin(TargetEntry *tlist, */ if (!fjNode->fj_initialized) { - /* * Initialize all of the Outer nodes */ @@ -127,7 +125,6 @@ ExecEvalFjoin(TargetEntry *tlist, } else { - /* * If we're already initialized, all we need to do is get the next * inner result and pair it up with the existing outer node result @@ -242,5 +239,4 @@ FjoinBumpOuterNodes(TargetEntry *tlist, } return false; } - #endif diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index 68dc74a3a8..1a11015498 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.28 2001/05/27 20:48:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.29 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -111,7 +111,6 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType, resjunk = resdom->resjunk; if (!resjunk) { - /* * make a copy of the resdom node, changing its resno. */ diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 6b1db391ee..6e1145ac77 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.148 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.149 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -287,7 +287,6 @@ ExecutorEnd(QueryDesc *queryDesc, EState *estate) static void ExecCheckQueryPerms(CmdType operation, Query *parseTree, Plan *plan) { - /* * Check RTEs in the query's primary rangetable. */ @@ -428,7 +427,6 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation) if (rte->checkForWrite) { - /* * Note: write access in a SELECT context means SELECT FOR UPDATE. * Right now we don't distinguish that from true update as far as @@ -521,7 +519,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) if (resultRelations != NIL) { - /* * Multiple result relations (due to inheritance) * parseTree->resultRelations identifies them all @@ -544,7 +541,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } else { - /* * Single result relation identified by * parseTree->resultRelation @@ -564,7 +560,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } else { - /* * if no result relation, then set state appropriately */ @@ -599,9 +594,9 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) /* * initialize the executor "tuple" table. We need slots for all the - * plan nodes, plus possibly output slots for the junkfilter(s). - * At this point we aren't sure if we need junkfilters, so just add - * slots for them unconditionally. + * plan nodes, plus possibly output slots for the junkfilter(s). At + * this point we aren't sure if we need junkfilters, so just add slots + * for them unconditionally. */ { int nSlots = ExecCountSlotsNode(plan); @@ -669,7 +664,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) if (junk_filter_needed) { - /* * If there are multiple result relations, each one needs its * own junk filter. Note this is only possible for @@ -694,7 +688,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) j = ExecInitJunkFilter(subplan->targetlist, ExecGetTupType(subplan), - ExecAllocTableSlot(estate->es_tupleTable)); + ExecAllocTableSlot(estate->es_tupleTable)); resultRelInfo->ri_junkFilter = j; resultRelInfo++; subplans = lnext(subplans); @@ -714,7 +708,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) j = ExecInitJunkFilter(plan->targetlist, tupType, - ExecAllocTableSlot(estate->es_tupleTable)); + ExecAllocTableSlot(estate->es_tupleTable)); estate->es_junkFilter = j; if (estate->es_result_relation_info) estate->es_result_relation_info->ri_junkFilter = j; @@ -741,13 +735,11 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) if (!parseTree->isPortal) { - /* * a select into table */ if (parseTree->into != NULL) { - /* * create the "into" relation */ @@ -1101,7 +1093,7 @@ lnext: ; newTuple = ExecRemoveJunk(junkfilter, slot); slot = ExecStoreTuple(newTuple, /* tuple to store */ - junkfilter->jf_resultSlot, /* dest slot */ + junkfilter->jf_resultSlot, /* dest slot */ InvalidBuffer, /* this tuple has no * buffer */ true); /* tuple should be pfreed */ @@ -1234,7 +1226,7 @@ ExecAppend(TupleTableSlot *slot, /* BEFORE ROW INSERT Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { HeapTuple newtuple; @@ -1245,7 +1237,6 @@ ExecAppend(TupleTableSlot *slot, if (newtuple != tuple) /* modified by Trigger(s) */ { - /* * Insert modified tuple into tuple table slot, replacing the * original. We assume that it was allocated in per-tuple @@ -1314,7 +1305,7 @@ ExecDelete(TupleTableSlot *slot, /* BEFORE ROW DELETE Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) { bool dodelete; @@ -1421,7 +1412,7 @@ ExecReplace(TupleTableSlot *slot, /* BEFORE ROW UPDATE Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) { HeapTuple newtuple; @@ -1433,7 +1424,6 @@ ExecReplace(TupleTableSlot *slot, if (newtuple != tuple) /* modified by Trigger(s) */ { - /* * Insert modified tuple into tuple table slot, replacing the * original. We assume that it was allocated in per-tuple @@ -1448,11 +1438,11 @@ ExecReplace(TupleTableSlot *slot, /* * Check the constraints of the tuple * - * If we generate a new candidate tuple after EvalPlanQual testing, - * we must loop back here and recheck constraints. (We don't need to - * redo triggers, however. If there are any BEFORE triggers then - * trigger.c will have done mark4update to lock the correct tuple, - * so there's no need to do them again.) + * If we generate a new candidate tuple after EvalPlanQual testing, we + * must loop back here and recheck constraints. (We don't need to + * redo triggers, however. If there are any BEFORE triggers then + * trigger.c will have done mark4update to lock the correct tuple, so + * there's no need to do them again.) */ lreplace:; if (resultRelationDesc->rd_att->constr) @@ -1483,7 +1473,7 @@ lreplace:; *tupleid = ctid; tuple = ExecRemoveJunk(estate->es_junkFilter, epqslot); slot = ExecStoreTuple(tuple, - estate->es_junkFilter->jf_resultSlot, + estate->es_junkFilter->jf_resultSlot, InvalidBuffer, true); goto lreplace; } @@ -1641,9 +1631,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) */ if (estate->es_result_relation_info != NULL && estate->es_result_relation_info->ri_RangeTableIndex == rti) - { relation = estate->es_result_relation_info->ri_RelationDesc; - } else { List *l; @@ -1724,7 +1712,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) *tid = tuple.t_self; /* - * Need to run a recheck subquery. Find or create a PQ stack entry. + * Need to run a recheck subquery. Find or create a PQ stack entry. */ epq = (evalPlanQual *) estate->es_evalPlanQual; rtsize = length(estate->es_range_table); @@ -1782,18 +1770,20 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) { newepq = (evalPlanQual *) palloc(sizeof(evalPlanQual)); newepq->free = NULL; + /* - * Each stack level has its own copy of the plan tree. This + * Each stack level has its own copy of the plan tree. This * is wasteful, but necessary as long as plan nodes point to - * exec state nodes rather than vice versa. Note that copyfuncs.c - * doesn't attempt to copy the exec state nodes, which is a good - * thing in this situation. + * exec state nodes rather than vice versa. Note that + * copyfuncs.c doesn't attempt to copy the exec state nodes, + * which is a good thing in this situation. */ newepq->plan = copyObject(estate->es_origPlan); + /* * Init stack level's EState. We share top level's copy of - * es_result_relations array and other non-changing status. - * We need our own tupletable, es_param_exec_vals, and other + * es_result_relations array and other non-changing status. We + * need our own tupletable, es_param_exec_vals, and other * changeable state. */ epqstate = &(newepq->estate); @@ -1805,11 +1795,12 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) sizeof(ParamExecData)); epqstate->es_tupleTable = NULL; epqstate->es_per_tuple_exprcontext = NULL; + /* - * Each epqstate must have its own es_evTupleNull state, - * but all the stack entries share es_evTuple state. This - * allows sub-rechecks to inherit the value being examined by - * an outer recheck. + * Each epqstate must have its own es_evTupleNull state, but + * all the stack entries share es_evTuple state. This allows + * sub-rechecks to inherit the value being examined by an + * outer recheck. */ epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool)); if (epq == NULL) @@ -1842,12 +1833,12 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) epqstate = &(epq->estate); /* - * Ok - we're requested for the same RTE. Unfortunately we still - * have to end and restart execution of the plan, because ExecReScan + * Ok - we're requested for the same RTE. Unfortunately we still have + * to end and restart execution of the plan, because ExecReScan * wouldn't ensure that upper plan nodes would reset themselves. We - * could make that work if insertion of the target tuple were integrated - * with the Param mechanism somehow, so that the upper plan nodes know - * that their children's outputs have changed. + * could make that work if insertion of the target tuple were + * integrated with the Param mechanism somehow, so that the upper plan + * nodes know that their children's outputs have changed. */ if (endNode) { @@ -1858,8 +1849,8 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) } /* - * free old RTE' tuple, if any, and store target tuple where relation's - * scan node will see it + * free old RTE' tuple, if any, and store target tuple where + * relation's scan node will see it */ if (epqstate->es_evTuple[rti - 1] != NULL) heap_freetuple(epqstate->es_evTuple[rti - 1]); diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index 0d66cd76c1..5cbd2ea562 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.27 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.28 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -267,9 +267,9 @@ ExecProcNode(Plan *node, Plan *parent) switch (nodeTag(node)) { - /* - * control nodes - */ + /* + * control nodes + */ case T_Result: result = ExecResult((Result *) node); break; @@ -473,9 +473,9 @@ ExecEndNode(Plan *node, Plan *parent) switch (nodeTag(node)) { - /* - * control nodes - */ + /* + * control nodes + */ case T_Result: ExecEndResult((Result *) node); break; diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index ea32b5ab1d..f78517b184 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.88 2001/09/21 00:11:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.89 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,9 +62,9 @@ static Datum ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull); static Datum ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + bool *isNull, ExprDoneCond *isDone); /*---------- @@ -126,7 +126,6 @@ ExecEvalArrayRef(ArrayRef *arrayRef, } else { - /* * Empty refexpr indicates we are doing an INSERT into an array * column. For now, we just take the refassgnexpr (which the @@ -339,9 +338,9 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) * the entire tuple; we give back a whole slot so that callers know * what the tuple looks like. * - * XXX this is a horrid crock: since the pointer to the slot might - * live longer than the current evaluation context, we are forced to - * copy the tuple and slot into a long-lived context --- we use + * XXX this is a horrid crock: since the pointer to the slot might live + * longer than the current evaluation context, we are forced to copy + * the tuple and slot into a long-lived context --- we use * TransactionCommandContext which should be safe enough. This * represents a serious memory leak if many such tuples are processed * in one command, however. We ought to redesign the representation @@ -434,7 +433,6 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull) matchFound = 0; if (paramList != NULL) { - /* * search for an entry in 'paramList' that matches the * `expression'. @@ -485,7 +483,6 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull) if (!matchFound) { - /* * ooops! we couldn't find this parameter in the parameter list. * Signal an error @@ -1128,28 +1125,28 @@ ExecEvalNullTest(NullTest *ntest, result = ExecEvalExpr(ntest->arg, econtext, isNull, isDone); switch (ntest->nulltesttype) - { - case IS_NULL: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(true); - } - else - return BoolGetDatum(false); - case IS_NOT_NULL: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(false); - } - else - return BoolGetDatum(true); - default: - elog(ERROR, "ExecEvalNullTest: unexpected nulltesttype %d", - (int) ntest->nulltesttype); - return (Datum) 0; /* keep compiler quiet */ - } + { + case IS_NULL: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(true); + } + else + return BoolGetDatum(false); + case IS_NOT_NULL: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(false); + } + else + return BoolGetDatum(true); + default: + elog(ERROR, "ExecEvalNullTest: unexpected nulltesttype %d", + (int) ntest->nulltesttype); + return (Datum) 0; /* keep compiler quiet */ + } } /* ---------------------------------------------------------------- @@ -1168,68 +1165,68 @@ ExecEvalBooleanTest(BooleanTest *btest, result = ExecEvalExpr(btest->arg, econtext, isNull, isDone); switch (btest->booltesttype) - { - case IS_TRUE: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(false); - } - else if (DatumGetBool(result)) - return BoolGetDatum(true); + { + case IS_TRUE: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(false); + } + else if (DatumGetBool(result)) + return BoolGetDatum(true); else - return BoolGetDatum(false); - case IS_NOT_TRUE: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(true); - } - else if (DatumGetBool(result)) - return BoolGetDatum(false); + return BoolGetDatum(false); + case IS_NOT_TRUE: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(true); + } + else if (DatumGetBool(result)) + return BoolGetDatum(false); else - return BoolGetDatum(true); - case IS_FALSE: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(false); - } - else if (DatumGetBool(result)) - return BoolGetDatum(false); + return BoolGetDatum(true); + case IS_FALSE: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(false); + } + else if (DatumGetBool(result)) + return BoolGetDatum(false); else - return BoolGetDatum(true); - case IS_NOT_FALSE: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(true); - } - else if (DatumGetBool(result)) - return BoolGetDatum(true); + return BoolGetDatum(true); + case IS_NOT_FALSE: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(true); + } + else if (DatumGetBool(result)) + return BoolGetDatum(true); else - return BoolGetDatum(false); - case IS_UNKNOWN: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(true); - } + return BoolGetDatum(false); + case IS_UNKNOWN: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(true); + } else - return BoolGetDatum(false); - case IS_NOT_UNKNOWN: - if (*isNull) - { - *isNull = false; - return BoolGetDatum(false); - } + return BoolGetDatum(false); + case IS_NOT_UNKNOWN: + if (*isNull) + { + *isNull = false; + return BoolGetDatum(false); + } else - return BoolGetDatum(true); - default: - elog(ERROR, "ExecEvalBooleanTest: unexpected booltesttype %d", - (int) btest->booltesttype); - return (Datum) 0; /* keep compiler quiet */ - } + return BoolGetDatum(true); + default: + elog(ERROR, "ExecEvalBooleanTest: unexpected booltesttype %d", + (int) btest->booltesttype); + return (Datum) 0; /* keep compiler quiet */ + } } /* ---------------------------------------------------------------- @@ -1409,15 +1406,15 @@ ExecEvalExpr(Node *expression, break; case T_NullTest: retDatum = ExecEvalNullTest((NullTest *) expression, - econtext, - isNull, - isDone); + econtext, + isNull, + isDone); break; case T_BooleanTest: retDatum = ExecEvalBooleanTest((BooleanTest *) expression, - econtext, - isNull, - isDone); + econtext, + isNull, + isDone); break; default: @@ -1665,7 +1662,7 @@ ExecTargetList(List *targetlist, * generating multiple tuples, when one or more tlist items return * sets. (We expect the caller to call us again if we return: * - * isDone = ExprMultipleResult.) + * isDone = ExprMultipleResult.) */ if (nodomains > NPREALLOCDOMAINS) { @@ -1774,13 +1771,11 @@ ExecTargetList(List *targetlist, if (haveDoneSets) { - /* * note: can't get here unless we verified isDone != NULL */ if (*isDone == ExprSingleResult) { - /* * all sets are done, so report that tlist expansion is * complete. @@ -1792,7 +1787,6 @@ ExecTargetList(List *targetlist, } else { - /* * We have some done and some undone sets. Restart the done * ones so that we can deliver a tuple (if possible). @@ -1815,7 +1809,6 @@ ExecTargetList(List *targetlist, if (itemIsDone[resind] == ExprEndResult) { - /* * Oh dear, this item is returning an empty * set. Guess we can't make a tuple after all. diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 51a05a6457..63aaa63858 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.17 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.18 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,6 @@ ExecScan(Scan *node, */ if (!qual || ExecQual(qual, econtext, false)) { - /* * Found a satisfactory scan tuple. * diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index b6f7b1ee6f..2c63acb8b6 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.48 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.49 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -241,10 +241,10 @@ ExecAllocTableSlot(TupleTable table) Assert(table != NULL); /* - * if our table is full we have to allocate a larger size table. - * Since ExecAllocTableSlot() is only called before the table is ever - * used to store tuples, we don't have to worry about the contents of - * the old table. If this changes, then we will have to preserve the + * if our table is full we have to allocate a larger size table. Since + * ExecAllocTableSlot() is only called before the table is ever used + * to store tuples, we don't have to worry about the contents of the + * old table. If this changes, then we will have to preserve the * contents. -cim 6/23/90 * * Unfortunately, we *cannot* do this. All of the nodes in the plan that @@ -347,7 +347,6 @@ ExecStoreTuple(HeapTuple tuple, Buffer buffer, bool shouldFree) { - /* * sanity checks */ @@ -407,7 +406,7 @@ ExecClearTuple(TupleTableSlot *slot) /* slot in which to store tuple */ slot->val = (HeapTuple) NULL; - slot->ttc_shouldFree = true;/* probably useless code... */ + slot->ttc_shouldFree = true; /* probably useless code... */ /* * Drop the pin on the referenced buffer, if there is one. diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 2c76c9b7d9..d710c82703 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.77 2001/07/16 05:06:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.78 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,7 +78,6 @@ ResetTupleCount(void) NTupleReplaced = 0; NIndexTupleProcessed = 0; } - #endif /* ---------------------------------------------------------------- @@ -117,7 +116,6 @@ DisplayTupleCount(FILE *statfp) (NTupleReplaced == 1) ? "" : "s"); fprintf(statfp, "\n"); } - #endif /* ---------------------------------------------------------------- @@ -504,26 +502,26 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo) /* * Open (and lock, if necessary) the index relation * - * If the index AM is not safe for concurrent updates, obtain - * an exclusive lock on the index to lock out other updaters as - * well as readers (index_beginscan places AccessShareLock). - * We will release this lock in ExecCloseIndices. + * If the index AM is not safe for concurrent updates, obtain an + * exclusive lock on the index to lock out other updaters as well + * as readers (index_beginscan places AccessShareLock). We will + * release this lock in ExecCloseIndices. * * If the index AM supports concurrent updates, we obtain no lock * here at all, which is a tad weird, but safe since any critical - * operation on the index (like deleting it) will acquire exclusive - * lock on the parent table. Perhaps someday we should acquire - * RowExclusiveLock on the index here? + * operation on the index (like deleting it) will acquire + * exclusive lock on the parent table. Perhaps someday we should + * acquire RowExclusiveLock on the index here? * * If there are multiple not-concurrent-safe indexes, all backends - * must lock the indexes in the same order or we will get deadlocks - * here during concurrent updates. This is guaranteed by - * RelationGetIndexList(), which promises to return the index list - * in OID order. + * must lock the indexes in the same order or we will get + * deadlocks here during concurrent updates. This is guaranteed + * by RelationGetIndexList(), which promises to return the index + * list in OID order. */ indexDesc = index_open(indexOid); - if (! indexDesc->rd_am->amconcurrent) + if (!indexDesc->rd_am->amconcurrent) LockRelation(indexDesc, AccessExclusiveLock); /* @@ -572,7 +570,7 @@ ExecCloseIndices(ResultRelInfo *resultRelInfo) continue; /* Drop lock, if one was acquired by ExecOpenIndices */ - if (! indexDescs[i]->rd_am->amconcurrent) + if (!indexDescs[i]->rd_am->amconcurrent) UnlockRelation(indexDescs[i], AccessExclusiveLock); index_close(indexDescs[i]); diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 73dd6937d7..fbe8e7f5bf 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.45 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.46 2001/10/25 05:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ */ typedef enum { - F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE + F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE } ExecStatus; typedef struct local_es @@ -201,7 +201,6 @@ init_sql_fcache(FmgrInfo *finfo) } else { - /* * This is a hack. We assume here that any function returning a * tuple returns it by reference. This needs to be fixed, since @@ -257,7 +256,6 @@ init_sql_fcache(FmgrInfo *finfo) static void postquel_start(execution_state *es) { - /* * Do nothing for utility commands. (create, destroy...) DZ - * 30-8-1996 @@ -274,7 +272,6 @@ postquel_getnext(execution_state *es) if (es->qd->operation == CMD_UTILITY) { - /* * Process a utility command. (create, destroy...) DZ - 30-8-1996 */ @@ -292,7 +289,6 @@ postquel_getnext(execution_state *es) static void postquel_end(execution_state *es) { - /* * Do nothing for utility commands. (create, destroy...) DZ - * 30-8-1996 @@ -417,7 +413,6 @@ postquel_execute(execution_state *es, */ if (fcache->returnsTuple) { - /* * XXX do we need to remove junk attrs from the result tuple? * Probably OK to leave them, as long as they are at the end. @@ -528,7 +523,6 @@ fmgr_sql(PG_FUNCTION_ARGS) */ if (es == (execution_state *) NULL) { - /* * Reset the execution states to start over again */ diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index 753efbcee9..e270f7c771 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -1,13 +1,13 @@ /*------------------------------------------------------------------------- * * instrument.c - * functions for instrumentation of plan execution + * functions for instrumentation of plan execution * * * Copyright (c) 2001, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.1 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.2 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,9 +22,9 @@ Instrumentation * InstrAlloc(void) { - Instrumentation *instr = palloc( sizeof(Instrumentation) ); + Instrumentation *instr = palloc(sizeof(Instrumentation)); - memset( instr, 0, sizeof(Instrumentation) ); + memset(instr, 0, sizeof(Instrumentation)); return instr; } @@ -47,7 +47,7 @@ void InstrStopNode(Instrumentation *instr, bool returnedTuple) { struct timeval endtime; - + if (!instr) return; @@ -56,10 +56,10 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple) elog(DEBUG, "InstrStopNode without start"); return; } - + gettimeofday(&endtime, NULL); - - instr->counter.tv_sec += endtime.tv_sec - instr->starttime.tv_sec; + + instr->counter.tv_sec += endtime.tv_sec - instr->starttime.tv_sec; instr->counter.tv_usec += endtime.tv_usec - instr->starttime.tv_usec; /* Normalize after each add to avoid overflow/underflow of tv_usec */ @@ -90,10 +90,10 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple) } /* Finish a run cycle for a plan node */ -void +void InstrEndLoop(Instrumentation *instr) { - double totaltime; + double totaltime; if (!instr) return; @@ -104,10 +104,10 @@ InstrEndLoop(Instrumentation *instr) /* Accumulate statistics */ totaltime = (double) instr->counter.tv_sec + - (double) instr->counter.tv_usec / 1000000.0; + (double) instr->counter.tv_usec / 1000000.0; instr->startup += instr->firsttuple; - instr->total += totaltime; + instr->total += totaltime; instr->ntuples += instr->tuplecount; instr->nloops += 1; diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 73f2b56cf3..90369c5a7a 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.77 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.78 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,6 @@ */ typedef struct AggStatePerAggData { - /* * These values are set up during ExecInitAgg() and do not change * thereafter: @@ -178,7 +177,6 @@ initialize_aggregate(AggStatePerAgg peraggstate) */ if (aggref->aggdistinct) { - /* * In case of rescan, maybe there could be an uncompleted sort * operation? Clean it up if so. @@ -228,7 +226,6 @@ advance_transition_function(AggStatePerAgg peraggstate, { if (isNull) { - /* * For a strict transfn, nothing happens at a NULL input * tuple; we just keep the prior transValue. However, if the @@ -243,7 +240,6 @@ advance_transition_function(AggStatePerAgg peraggstate, } if (peraggstate->noTransValue) { - /* * transValue has not been initialized. This is the first * non-NULL input value. We use it as the initial value for @@ -264,7 +260,6 @@ advance_transition_function(AggStatePerAgg peraggstate, } if (peraggstate->transValueIsNull) { - /* * Don't call a strict function with NULL inputs. Note it is * possible to get here despite the above tests, if the @@ -333,7 +328,6 @@ process_sorted_aggregate(AggState *aggstate, while (tuplesort_getdatum(peraggstate->sortstate, true, &newVal, &isNull)) { - /* * DISTINCT always suppresses nulls, per SQL spec, regardless of * the transition function's strictness. @@ -398,7 +392,6 @@ static void finalize_aggregate(AggStatePerAgg peraggstate, Datum *resultVal, bool *resultIsNull) { - /* * Apply the agg's finalfn if one is provided, else return transValue. */ @@ -757,7 +750,6 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) aggstate->numaggs = numaggs = length(aggstate->aggs); if (numaggs <= 0) { - /* * This used to be treated as an error, but we can't do that * anymore because constant-expression simplification could @@ -897,7 +889,6 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) */ if (peraggstate->transfn.fn_strict && peraggstate->initValueIsNull) { - /* * Note: use the type from the input expression here, not * aggform->aggbasetype, because the latter might be 0. @@ -913,7 +904,6 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) if (aggref->aggdistinct) { - /* * Note: use the type from the input expression here, not * aggform->aggbasetype, because the latter might be 0. @@ -947,8 +937,8 @@ int ExecCountSlotsAgg(Agg *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - AGG_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + AGG_NSLOTS; } void diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index f8bdbed6cc..41b05118e0 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.42 2001/05/15 00:33:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.43 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,7 +90,6 @@ exec_append_initialize_next(Append *node) if (whichplan < appendstate->as_firstplan) { - /* * if scanning in reverse, we start at the last scan in the list * and then proceed back to the first.. in any case we inform @@ -102,7 +101,6 @@ exec_append_initialize_next(Append *node) } else if (whichplan > appendstate->as_lastplan) { - /* * as above, end the scan if we go beyond the last scan in our * list.. @@ -112,7 +110,6 @@ exec_append_initialize_next(Append *node) } else { - /* * initialize the scan * @@ -182,12 +179,13 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent) node->appendstate = appendstate; /* - * Do we want to scan just one subplan? (Special case for EvalPlanQual) - * XXX pretty dirty way of determining that this case applies ... + * Do we want to scan just one subplan? (Special case for + * EvalPlanQual) XXX pretty dirty way of determining that this case + * applies ... */ if (node->isTarget && estate->es_evTuple != NULL) { - int tplan; + int tplan; tplan = estate->es_result_relation_info - estate->es_result_relations; Assert(tplan >= 0 && tplan < nplans); @@ -301,7 +299,6 @@ ExecProcAppend(Append *node) if (!TupIsNull(result)) { - /* * if the subplan gave us something then place a copy of whatever * we get into our result slot and return it. @@ -313,7 +310,6 @@ ExecProcAppend(Append *node) } else { - /* * .. go on to the "next" subplan in the appropriate direction and * try processing again (recursively) @@ -385,15 +381,17 @@ ExecReScanAppend(Append *node, ExprContext *exprCtxt, Plan *parent) Plan *subnode; subnode = (Plan *) nth(i, node->appendplans); + /* * ExecReScan doesn't know about my subplans, so I have to do * changed-parameter signaling myself. */ if (node->plan.chgParam != NULL) SetChangedParamList(subnode, node->plan.chgParam); + /* - * if chgParam of subnode is not null then plan will be re-scanned by - * first ExecProcNode. + * if chgParam of subnode is not null then plan will be re-scanned + * by first ExecProcNode. */ if (subnode->chgParam == NULL) { diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index 6dda57f6e9..e3aea3b789 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -15,7 +15,7 @@ * locate group boundaries. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.43 2001/03/22 06:16:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.44 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,6 @@ ExecGroupEveryTuple(Group *node) } else { - /* * Compare with first tuple and see if this tuple is of the * same group. @@ -133,7 +132,6 @@ ExecGroupEveryTuple(Group *node) grpstate->eqfunctions, econtext->ecxt_per_tuple_memory)) { - /* * No; save the tuple to return it next time, and return * NULL @@ -478,7 +476,7 @@ execTuplesMatch(HeapTuple tuple1, * Look up the equality functions needed for execTuplesMatch. * The result is a palloc'd array. */ -FmgrInfo * +FmgrInfo * execTuplesMatchPrepare(TupleDesc tupdesc, int numCols, AttrNumber *matchColIdx) diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index f387e5a759..bf9bf6eeb0 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.59 2001/08/13 19:50:11 tgl Exp $ + * $Id: nodeHash.c,v 1.60 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,6 @@ ExecHash(Hash *node) if (nbatch > 0) { - /* * Open temp files for inner batches, if needed. Note that file * buffers are palloc'd in regular executor context. @@ -165,8 +164,8 @@ int ExecCountSlotsHash(Hash *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - HASH_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + HASH_NSLOTS; } /* --------------------------------------------------------------- @@ -279,7 +278,6 @@ ExecHashTableCreate(Hash *node) if (nbatch > 0) { - /* * allocate and initialize the file arrays in hashCxt */ @@ -480,7 +478,6 @@ ExecHashTableInsert(HashJoinTable hashtable, */ if (bucketno < hashtable->nbuckets) { - /* * put the tuple in hash table */ @@ -506,7 +503,6 @@ ExecHashTableInsert(HashJoinTable hashtable, } else { - /* * put the tuple into a tmp file for other batches */ @@ -536,8 +532,8 @@ ExecHashGetBucket(HashJoinTable hashtable, MemoryContext oldContext; /* - * We reset the eval context each time to reclaim any memory leaked - * in the hashkey expression or hashFunc itself. + * We reset the eval context each time to reclaim any memory leaked in + * the hashkey expression or hashFunc itself. */ ResetExprContext(econtext); @@ -657,15 +653,15 @@ hashFunc(Datum key, int len, bool byVal) else { /* - * If this is a variable length type, then 'key' points to a "struct - * varlena" and len == -1. 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.) + * If this is a variable length type, then 'key' points to a + * "struct varlena" and len == -1. 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.) */ unsigned char *k; @@ -737,7 +733,6 @@ ExecHashTableReset(HashJoinTable hashtable, long ntuples) void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent) { - /* * if chgParam of subnode is not null then plan will be re-scanned by * first ExecProcNode. diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 12f6d58443..58e97b8adb 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.38 2001/03/22 06:16:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.39 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -148,7 +148,6 @@ ExecHashJoin(HashJoin *node) for (;;) { - /* * If we don't have an outer tuple, get the next one */ @@ -159,7 +158,6 @@ ExecHashJoin(HashJoin *node) hjstate); if (TupIsNull(outerTupleSlot)) { - /* * when the last batch runs out, clean up and exit */ @@ -193,7 +191,6 @@ ExecHashJoin(HashJoin *node) if (batch > 0) { - /* * Need to postpone this outer tuple to a later batch. * Save it in the corresponding outer-batch file. @@ -270,7 +267,6 @@ ExecHashJoin(HashJoin *node) if (!hjstate->hj_MatchedOuter && node->join.jointype == JOIN_LEFT) { - /* * We are doing an outer join and there were no join matches * for this outer tuple. Generate a fake join tuple with @@ -281,7 +277,6 @@ ExecHashJoin(HashJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification was satisfied so we project and return * the slot containing the result tuple using @@ -411,8 +406,8 @@ int ExecCountSlotsHashJoin(HashJoin *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - HASHJOIN_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + HASHJOIN_NSLOTS; } /* ---------------------------------------------------------------- @@ -565,7 +560,6 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) if (newbatch > 1) { - /* * We no longer need the previous outer batch file; close it right * away to free disk space. diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index ec26ed05cc..3c5ebc4c8b 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.62 2001/07/15 22:48:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.63 2001/10/25 05:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -222,7 +222,7 @@ IndexNext(IndexScan *node) qual = lnext(qual); } if (!prev_matches) - return slot;/* OK to return tuple */ + return slot; /* OK to return tuple */ /* Duplicate tuple, so drop it and loop back for another */ ExecClearTuple(slot); } @@ -337,7 +337,6 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent) if (econtext) { - /* * If we are being passed an outer tuple, save it for runtime key * calc @@ -377,7 +376,6 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent) run_keys = runtimeKeyInfo[i]; for (j = 0; j < n_keys; j++) { - /* * If we have a run-time key, then extract the run-time * expression and evaluate it with respect to the current @@ -703,10 +701,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) Expr *clause; /* one clause of index qual */ Oper *op; /* operator used in clause */ Node *leftop; /* expr on lhs of operator */ - Node *rightop;/* expr on rhs ... */ + Node *rightop; /* expr on rhs ... */ bits16 flags = 0; - int scanvar;/* which var identifies varattno */ + int scanvar; /* which var identifies varattno */ AttrNumber varattno = 0; /* att number used in scan */ Oid opid; /* operator id used in scan */ Datum scanvalue = 0; /* value used in scan (if const) */ @@ -772,7 +770,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) if (IsA(leftop, Var) &&var_is_rel((Var *) leftop)) { - /* * if the leftop is a "rel-var", then it means that it is * a var node which tells us which attribute to use for @@ -783,7 +780,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) } else if (IsA(leftop, Const)) { - /* * if the leftop is a const node then it means it * identifies the value to place in our scan key. @@ -820,7 +816,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) } else { - /* * otherwise, the leftop contains an expression evaluable * at runtime to figure out the value to place in our scan @@ -842,7 +837,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) if (IsA(rightop, Var) &&var_is_rel((Var *) rightop)) { - /* * here we make sure only one op identifies the * scan-attribute... @@ -861,7 +855,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) } else if (IsA(rightop, Const)) { - /* * if the rightop is a const node then it means it * identifies the value to place in our scan key. @@ -898,7 +891,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) } else { - /* * otherwise, the rightop contains an expression evaluable * at runtime to figure out the value to place in our scan @@ -1023,7 +1015,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) ExecOpenScanR(indexOid, /* relation */ numScanKeys[i], /* nkeys */ scanKeys[i], /* scan key */ - true, /* is index */ + true, /* is index */ direction, /* scan direction */ estate->es_snapshot, &(relationDescs[i]), /* return: rel desc */ @@ -1045,5 +1037,5 @@ int ExecCountSlotsIndexScan(IndexScan *node) { return ExecCountSlotsNode(outerPlan((Plan *) node)) + - ExecCountSlotsNode(innerPlan((Plan *) node)) + INDEXSCAN_NSLOTS; + ExecCountSlotsNode(innerPlan((Plan *) node)) + INDEXSCAN_NSLOTS; } diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index da0e669776..1ce376418d 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.7 2001/08/06 18:05:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.8 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,6 @@ ExecLimit(Limit *node) */ for (;;) { - /* * If we have reached the subplan EOF or the limit, just quit. * @@ -76,11 +75,11 @@ ExecLimit(Limit *node) * here is for position > netlimit not position >= netlimit. * * Similarly, when scanning backwards, we must re-fetch the last - * tuple in the offset region before we can return NULL. - * Otherwise we won't be correctly aligned to start going forward - * again. So, although you might think we can quit when position - * equals offset + 1, we have to fetch a subplan tuple first, and - * then exit when position = offset. + * tuple in the offset region before we can return NULL. Otherwise + * we won't be correctly aligned to start going forward again. + * So, although you might think we can quit when position equals + * offset + 1, we have to fetch a subplan tuple first, and then + * exit when position = offset. */ if (ScanDirectionIsForward(direction)) { @@ -101,7 +100,6 @@ ExecLimit(Limit *node) slot = ExecProcNode(outerPlan, (Plan *) node); if (TupIsNull(slot)) { - /* * We are at start or end of the subplan. Update local state * appropriately, but always return NULL. @@ -269,8 +267,8 @@ int ExecCountSlotsLimit(Limit *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - LIMIT_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + LIMIT_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index c4ec5c9a38..8578f02074 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.36 2001/05/27 20:42:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.37 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -185,8 +185,8 @@ int ExecCountSlotsMaterial(Material *node) { return ExecCountSlotsNode(outerPlan((Plan *) node)) + - ExecCountSlotsNode(innerPlan((Plan *) node)) + - MATERIAL_NSLOTS; + ExecCountSlotsNode(innerPlan((Plan *) node)) + + MATERIAL_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 9733bc47d5..8ac71b0cc9 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.45 2001/03/23 04:49:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.46 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -124,7 +124,6 @@ MJFormSkipQual(List *qualList, char *replaceopname) foreach(qualcdr, qualCopy) { - /* * first get the current (op .. ..) list */ @@ -321,7 +320,6 @@ ExecMergeTupleDump(MergeJoinState *mergestate) printf("******** \n"); } - #endif /* ---------------------------------------------------------------- @@ -431,7 +429,7 @@ ExecMergeJoin(MergeJoin *node) default: elog(ERROR, "ExecMergeJoin: unsupported join type %d", (int) node->join.jointype); - doFillOuter = false;/* keep compiler quiet */ + doFillOuter = false; /* keep compiler quiet */ doFillInner = false; break; } @@ -476,7 +474,6 @@ ExecMergeJoin(MergeJoin *node) */ for (;;) { - /* * get the current state of the join and do things accordingly. * Note: The join states are highlighted with 32-* comments for @@ -486,7 +483,6 @@ ExecMergeJoin(MergeJoin *node) switch (mergestate->mj_JoinState) { - /* * EXEC_MJ_INITIALIZE means that this is the first time * ExecMergeJoin() has been called and so we have to fetch @@ -505,7 +501,6 @@ ExecMergeJoin(MergeJoin *node) MJ_printf("ExecMergeJoin: outer subplan is empty\n"); if (doFillInner) { - /* * Need to emit right-join tuples for remaining * inner tuples. We set MatchedInner = true to @@ -526,7 +521,6 @@ ExecMergeJoin(MergeJoin *node) MJ_printf("ExecMergeJoin: inner subplan is empty\n"); if (doFillOuter) { - /* * Need to emit left-join tuples for all outer * tuples, including the one we just fetched. We @@ -632,7 +626,6 @@ ExecMergeJoin(MergeJoin *node) if (qualResult) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -669,7 +662,6 @@ ExecMergeJoin(MergeJoin *node) if (doFillInner && !mergestate->mj_MatchedInner) { - /* * Generate a fake join tuple with nulls for the outer * tuple, and return it if it passes the non-join @@ -686,7 +678,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -747,7 +738,6 @@ ExecMergeJoin(MergeJoin *node) if (doFillOuter && !mergestate->mj_MatchedOuter) { - /* * Generate a fake join tuple with nulls for the inner * tuple, and return it if it passes the non-join @@ -764,7 +754,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -805,7 +794,6 @@ ExecMergeJoin(MergeJoin *node) innerTupleSlot = mergestate->mj_InnerTupleSlot; if (doFillInner && !TupIsNull(innerTupleSlot)) { - /* * Need to emit right-join tuples for remaining * inner tuples. @@ -873,7 +861,6 @@ ExecMergeJoin(MergeJoin *node) if (qualResult) { - /* * the merge clause matched so now we restore the * inner scan position to the first mark, and loop @@ -915,7 +902,6 @@ ExecMergeJoin(MergeJoin *node) { if (doFillOuter) { - /* * Need to emit left-join tuples for remaining * outer tuples. @@ -1036,7 +1022,6 @@ ExecMergeJoin(MergeJoin *node) if (doFillOuter && !mergestate->mj_MatchedOuter) { - /* * Generate a fake join tuple with nulls for the inner * tuple, and return it if it passes the non-join @@ -1053,7 +1038,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -1094,7 +1078,6 @@ ExecMergeJoin(MergeJoin *node) innerTupleSlot = mergestate->mj_InnerTupleSlot; if (doFillInner && !TupIsNull(innerTupleSlot)) { - /* * Need to emit right-join tuples for remaining * inner tuples. @@ -1216,7 +1199,6 @@ ExecMergeJoin(MergeJoin *node) if (doFillInner && !mergestate->mj_MatchedInner) { - /* * Generate a fake join tuple with nulls for the outer * tuple, and return it if it passes the non-join @@ -1233,7 +1215,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -1274,7 +1255,6 @@ ExecMergeJoin(MergeJoin *node) outerTupleSlot = mergestate->mj_OuterTupleSlot; if (doFillOuter && !TupIsNull(outerTupleSlot)) { - /* * Need to emit left-join tuples for remaining * outer tuples. @@ -1304,7 +1284,6 @@ ExecMergeJoin(MergeJoin *node) if (!mergestate->mj_MatchedInner) { - /* * Generate a fake join tuple with nulls for the outer * tuple, and return it if it passes the non-join @@ -1321,7 +1300,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -1373,7 +1351,6 @@ ExecMergeJoin(MergeJoin *node) if (!mergestate->mj_MatchedOuter) { - /* * Generate a fake join tuple with nulls for the inner * tuple, and return it if it passes the non-join @@ -1390,7 +1367,6 @@ ExecMergeJoin(MergeJoin *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification succeeded. now form the desired * projection tuple and return the slot containing @@ -1579,8 +1555,8 @@ int ExecCountSlotsMergeJoin(MergeJoin *node) { return ExecCountSlotsNode(outerPlan((Plan *) node)) + - ExecCountSlotsNode(innerPlan((Plan *) node)) + - MERGEJOIN_NSLOTS; + ExecCountSlotsNode(innerPlan((Plan *) node)) + + MERGEJOIN_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index b695903887..e99b02fce4 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.24 2001/03/22 06:16:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.25 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -118,7 +118,6 @@ ExecNestLoop(NestLoop *node) for (;;) { - /* * If we don't have an outer tuple, get the next one and reset the * inner scan. @@ -174,7 +173,6 @@ ExecNestLoop(NestLoop *node) if (!nlstate->nl_MatchedOuter && node->join.jointype == JOIN_LEFT) { - /* * We are doing an outer join and there were no join * matches for this outer tuple. Generate a fake join @@ -187,7 +185,6 @@ ExecNestLoop(NestLoop *node) if (ExecQual(otherqual, econtext, false)) { - /* * qualification was satisfied so we project and * return the slot containing the result tuple using @@ -231,7 +228,6 @@ ExecNestLoop(NestLoop *node) if (otherqual == NIL || ExecQual(otherqual, econtext, false)) { - /* * qualification was satisfied so we project and return * the slot containing the result tuple using @@ -346,8 +342,8 @@ int ExecCountSlotsNestLoop(NestLoop *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - NESTLOOP_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + NESTLOOP_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeResult.c b/src/backend/executor/nodeResult.c index f9f325f637..5e59cb0c12 100644 --- a/src/backend/executor/nodeResult.c +++ b/src/backend/executor/nodeResult.c @@ -34,7 +34,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.19 2001/03/22 06:16:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.20 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,7 +125,6 @@ ExecResult(Result *node) if (outerPlan != NULL) { - /* * retrieve tuples from the outer plan until there are no * more. @@ -146,7 +145,6 @@ ExecResult(Result *node) } else { - /* * if we don't have an outer plan, then we are just generating * the results from a constant target list. Do it only once. diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index 48beffd792..1767379d67 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.31 2001/07/15 22:48:18 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.32 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -127,7 +127,6 @@ SeqNext(SeqScan *node) TupleTableSlot * ExecSeqScan(SeqScan *node) { - /* * use SeqNext as access method */ @@ -246,8 +245,8 @@ int ExecCountSlotsSeqScan(SeqScan *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - SEQSCAN_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + SEQSCAN_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c index 3072fe5f96..cd5d5b9122 100644 --- a/src/backend/executor/nodeSetOp.c +++ b/src/backend/executor/nodeSetOp.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.4 2001/03/22 06:16:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.5 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,6 @@ ExecSetOp(SetOp *node) if (TupIsNull(resultTupleSlot)) { - /* * First of group: save a copy in result slot, and reset * duplicate-counters for new group. @@ -118,7 +117,6 @@ ExecSetOp(SetOp *node) } else if (setopstate->subplan_done) { - /* * Reached end of input, so finish processing final group */ @@ -126,7 +124,6 @@ ExecSetOp(SetOp *node) } else { - /* * Else test if the new tuple and the previously saved tuple * match. @@ -144,7 +141,6 @@ ExecSetOp(SetOp *node) if (endOfGroup) { - /* * We've reached the end of the group containing resultTuple. * Decide how many copies (if any) to emit. This logic is @@ -187,7 +183,6 @@ ExecSetOp(SetOp *node) } else { - /* * Current tuple is member of same group as resultTuple. Count * it in the appropriate counter. @@ -294,8 +289,8 @@ int ExecCountSlotsSetOp(SetOp *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - SETOP_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + SETOP_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index a83a841142..82bb4cc3c9 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.34 2001/05/27 20:42:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.35 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -275,8 +275,8 @@ int ExecCountSlotsSort(Sort *node) { return ExecCountSlotsNode(outerPlan((Plan *) node)) + - ExecCountSlotsNode(innerPlan((Plan *) node)) + - SORT_NSLOTS; + ExecCountSlotsNode(innerPlan((Plan *) node)) + + SORT_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 6719df94e7..3aa30d25a3 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.31 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.32 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -257,7 +257,6 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull) if (!found) { - /* * deal with empty subplan result. result/isNull were previously * initialized correctly for all sublink types except EXPR and diff --git a/src/backend/executor/nodeSubqueryscan.c b/src/backend/executor/nodeSubqueryscan.c index 8c178ad0aa..edd4640ba4 100644 --- a/src/backend/executor/nodeSubqueryscan.c +++ b/src/backend/executor/nodeSubqueryscan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.10 2001/09/18 01:59:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.11 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ SubqueryNext(SubqueryScan *node) direction = estate->es_direction; /* - * We need not support EvalPlanQual here, since we are not scanning - * a real relation. + * We need not support EvalPlanQual here, since we are not scanning a + * real relation. */ /* @@ -92,7 +92,6 @@ SubqueryNext(SubqueryScan *node) TupleTableSlot * ExecSubqueryScan(SubqueryScan *node) { - /* * use SubqueryNext as access method */ @@ -181,8 +180,8 @@ ExecCountSlotsSubqueryScan(SubqueryScan *node) * The subplan has its own tuple table and must not be counted here! */ return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - SUBQUERYSCAN_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + SUBQUERYSCAN_NSLOTS; } /* ---------------------------------------------------------------- @@ -251,6 +250,7 @@ ExecSubqueryReScan(SubqueryScan *node, ExprContext *exprCtxt, Plan *parent) */ if (node->scan.plan.chgParam != NULL) SetChangedParamList(node->subplan, node->scan.plan.chgParam); + /* * if chgParam of subnode is not null then plan will be re-scanned by * first ExecProcNode. diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c index 404ed6a215..380632a78b 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.19 2001/09/29 07:57:06 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.20 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ #include "access/heapam.h" #include "parser/parsetree.h" -static int TidListCreate(List *, ExprContext *, ItemPointerData []); +static int TidListCreate(List *, ExprContext *, ItemPointerData[]); static TupleTableSlot *TidNext(TidScan *node); static int @@ -80,7 +80,7 @@ TidNext(TidScan *node) bool bBackward; int tidNumber; - ItemPointerData* tidList; + ItemPointerData *tidList; /* * extract necessary information from tid scan node @@ -233,7 +233,6 @@ TidNext(TidScan *node) TupleTableSlot * ExecTidScan(TidScan *node) { - /* * use TidNext as access method */ @@ -249,7 +248,7 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent) { EState *estate; TidScanState *tidstate; - ItemPointerData* tidList; + ItemPointerData *tidList; tidstate = node->tidstate; estate = node->scan.plan.state; @@ -357,7 +356,6 @@ ExecTidRestrPos(TidScan *node) tidstate = node->tidstate; tidstate->tss_TidPtr = tidstate->tss_MarkTidPtr; } - #endif /* ---------------------------------------------------------------- @@ -376,7 +374,7 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent) { TidScanState *tidstate; CommonScanState *scanstate; - ItemPointerData* tidList; + ItemPointerData *tidList; int numTids; int tidPtr; List *rangeTable; @@ -482,5 +480,5 @@ int ExecCountSlotsTidScan(TidScan *node) { return ExecCountSlotsNode(outerPlan((Plan *) node)) + - ExecCountSlotsNode(innerPlan((Plan *) node)) + TIDSCAN_NSLOTS; + ExecCountSlotsNode(innerPlan((Plan *) node)) + TIDSCAN_NSLOTS; } diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c index 2a139d8e1c..975dd84fe8 100644 --- a/src/backend/executor/nodeUnique.c +++ b/src/backend/executor/nodeUnique.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.32 2001/03/22 06:16:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.33 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,7 +61,6 @@ ExecUnique(Unique *node) */ for (;;) { - /* * fetch a tuple from the outer subplan */ @@ -186,8 +185,8 @@ int ExecCountSlotsUnique(Unique *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - UNIQUE_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + UNIQUE_NSLOTS; } /* ---------------------------------------------------------------- diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 73457491d6..e4c2dac40d 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.59 2001/10/23 17:38:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.60 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ static int _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount); static void _SPI_cursor_operation(Portal portal, bool forward, int count, - CommandDest dest); + CommandDest dest); static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location); @@ -51,7 +51,6 @@ static bool _SPI_checktuples(void); extern int ShowExecutorStats; extern void ResetUsage(void); extern void ShowUsage(void); - #endif /* =================== interface functions =================== */ @@ -298,7 +297,7 @@ SPI_saveplan(void *plan) int SPI_freeplan(void *plan) { - _SPI_plan *spiplan = (_SPI_plan *)plan; + _SPI_plan *spiplan = (_SPI_plan *) plan; if (plan == NULL) return SPI_ERROR_ARGUMENT; @@ -444,7 +443,7 @@ SPI_fnumber(TupleDesc tupdesc, char *fname) return res + 1; } - sysatt = SystemAttributeByName(fname, true /* "oid" will be accepted */); + sysatt = SystemAttributeByName(fname, true /* "oid" will be accepted */ ); if (sysatt != NULL) return sysatt->attnum; @@ -673,26 +672,26 @@ SPI_freetuptable(SPITupleTable *tuptable) Portal SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls) { - static int unnamed_portal_count = 0; - - _SPI_plan *spiplan = (_SPI_plan *)plan; - List *qtlist = spiplan->qtlist; - List *ptlist = spiplan->ptlist; - Query *queryTree; - Plan *planTree; - QueryDesc *queryDesc; - EState *eState; - TupleDesc attinfo; - MemoryContext oldcontext; - Portal portal; - char portalname[64]; - int k; + static int unnamed_portal_count = 0; + + _SPI_plan *spiplan = (_SPI_plan *) plan; + List *qtlist = spiplan->qtlist; + List *ptlist = spiplan->ptlist; + Query *queryTree; + Plan *planTree; + QueryDesc *queryDesc; + EState *eState; + TupleDesc attinfo; + MemoryContext oldcontext; + Portal portal; + char portalname[64]; + int k; /* Ensure that the plan contains only one regular SELECT query */ if (length(ptlist) != 1) elog(ERROR, "cannot open multi-query plan as cursor"); - queryTree = (Query *)lfirst(qtlist); - planTree = (Plan *)lfirst(ptlist); + queryTree = (Query *) lfirst(qtlist); + planTree = (Plan *) lfirst(ptlist); if (queryTree->commandType != CMD_SELECT) elog(ERROR, "plan in SPI_cursor_open() is not a SELECT"); @@ -712,7 +711,7 @@ SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls) { for (;;) { - unnamed_portal_count++; + unnamed_portal_count++; if (unnamed_portal_count < 0) unnamed_portal_count = 0; sprintf(portalname, "<unnamed cursor %d>", unnamed_portal_count); @@ -735,30 +734,31 @@ SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls) /* Switch to portals memory and copy the parsetree and plan to there */ oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); - queryTree = copyObject(queryTree); - planTree = copyObject(planTree); + queryTree = copyObject(queryTree); + planTree = copyObject(planTree); /* Modify the parsetree to be a cursor */ queryTree->isPortal = true; - queryTree->into = pstrdup(name); + queryTree->into = pstrdup(name); queryTree->isBinary = false; - + /* Create the QueryDesc object and the executor state */ queryDesc = CreateQueryDesc(queryTree, planTree, SPI); - eState = CreateExecutorState(); + eState = CreateExecutorState(); /* If the plan has parameters, put them into the executor state */ if (spiplan->nargs > 0) { - ParamListInfo paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) * - sizeof(ParamListInfoData)); + ParamListInfo paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) * + sizeof(ParamListInfoData)); + eState->es_param_list_info = paramLI; for (k = 0; k < spiplan->nargs; paramLI++, k++) { - paramLI->kind = PARAM_NUM; - paramLI->id = k + 1; - paramLI->isnull = (Nulls && Nulls[k] == 'n'); - paramLI->value = Values[k]; + paramLI->kind = PARAM_NUM; + paramLI->id = k + 1; + paramLI->isnull = (Nulls && Nulls[k] == 'n'); + paramLI->value = Values[k]; } paramLI->kind = PARAM_INVALID; } @@ -872,7 +872,7 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self) tuptable->vals = (HeapTuple *) palloc(tuptable->alloced * sizeof(HeapTuple)); tuptable->tupdesc = CreateTupleDescCopy(tupdesc); } - else + else { MemoryContextSwitchTo(tuptable->tuptabcxt); @@ -881,7 +881,7 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self) tuptable->free = 256; tuptable->alloced += tuptable->free; tuptable->vals = (HeapTuple *) repalloc(tuptable->vals, - tuptable->alloced * sizeof(HeapTuple)); + tuptable->alloced * sizeof(HeapTuple)); } } @@ -1171,12 +1171,12 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) */ static void _SPI_cursor_operation(Portal portal, bool forward, int count, - CommandDest dest) + CommandDest dest) { - QueryDesc *querydesc; - EState *estate; - MemoryContext oldcontext; - CommandDest olddest; + QueryDesc *querydesc; + EState *estate; + MemoryContext oldcontext; + CommandDest olddest; /* Check that the portal is valid */ if (!PortalIsValid(portal)) @@ -1193,8 +1193,8 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, /* Switch to the portals memory context */ oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); - querydesc = PortalGetQueryDesc(portal); - estate = PortalGetState(portal); + querydesc = PortalGetQueryDesc(portal); + estate = PortalGetState(portal); /* Save the queries command destination and set it to SPI (for fetch) */ /* or None (for move) */ @@ -1206,7 +1206,7 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, { if (!portal->atEnd) { - ExecutorRun(querydesc, estate, EXEC_FOR, (long)count); + ExecutorRun(querydesc, estate, EXEC_FOR, (long) count); _SPI_current->processed = estate->es_processed; if (estate->es_processed > 0) portal->atStart = false; @@ -1237,7 +1237,7 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, /* Put the result into place for access by caller */ SPI_processed = _SPI_current->processed; - SPI_tuptable = _SPI_current->tuptable; + SPI_tuptable = _SPI_current->tuptable; /* Pop the SPI stack */ _SPI_end_call(true); @@ -1278,7 +1278,6 @@ _SPI_begin_call(bool execmem) static int _SPI_end_call(bool procmem) { - /* * We' returning to procedure where _SPI_curid == _SPI_connected - 1 */ diff --git a/src/backend/lib/bit.c b/src/backend/lib/bit.c index 57da3522c4..41c799fb5a 100644 --- a/src/backend/lib/bit.c +++ b/src/backend/lib/bit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.13 2001/03/22 03:59:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.14 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,14 +22,14 @@ void BitArraySetBit(BitArray bitArray, BitIndex bitIndex) { bitArray[bitIndex / BITS_PER_BYTE] |= - (1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE))); + (1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE))); } void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex) { bitArray[bitIndex / BITS_PER_BYTE] &= - ~(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE))); + ~(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE))); } bool diff --git a/src/backend/lib/lispsort.c b/src/backend/lib/lispsort.c index a3c89b201e..f06448b578 100644 --- a/src/backend/lib/lispsort.c +++ b/src/backend/lib/lispsort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.14 2001/01/24 19:42:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.15 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,5 +55,4 @@ lisp_qsort(List *the_list, /* the list to be sorted */ return output; } - #endif diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index f4b4294eaa..1745f0f9ca 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.c,v 1.28 2001/03/22 06:16:13 momjian Exp $ + * $Id: stringinfo.c,v 1.29 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,7 +106,6 @@ appendStringInfo(StringInfo str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index b6d1e6166f..44fb1f390c 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.69 2001/10/18 22:44:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.70 2001/10/25 05:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,22 +45,22 @@ char *pg_krb_server_keyfile; #ifdef USE_PAM #include <security/pam_appl.h> - -#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */ -static int CheckPAMAuth(Port *port, char *user, char *password); -static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr); +#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */ + +static int CheckPAMAuth(Port *port, char *user, char *password); +static int pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, + struct pam_response ** resp, void *appdata_ptr); static struct pam_conv pam_passw_conv = { - &pam_passwd_conv_proc, - NULL + &pam_passwd_conv_proc, + NULL }; -static char * pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */ -static Port * pam_port_cludge; /* Workaround for passing "Port - * *port" into pam_passwd_conv_proc */ -#endif /* USE_PAM */ +static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */ +static Port *pam_port_cludge; /* Workaround for passing "Port *port" + * into pam_passwd_conv_proc */ +#endif /* USE_PAM */ #ifdef KRB4 /*---------------------------------------------------------------- @@ -429,13 +429,13 @@ auth_failed(Port *port, int status) const char *authmethod = "Unknown auth method:"; /* - * If we failed due to EOF from client, just quit; there's no point - * in trying to send a message to the client, and not much point in + * If we failed due to EOF from client, just quit; there's no point in + * trying to send a message to the client, and not much point in * logging the failure in the postmaster log. (Logging the failure * might be desirable, were it not for the fact that libpq closes the * connection unceremoniously if challenged for a password when it - * hasn't got one to send. We'll get a useless log entry for - * every psql connection under password auth, even if it's perfectly + * hasn't got one to send. We'll get a useless log entry for every + * psql connection under password auth, even if it's perfectly * successful, if we log STATUS_EOF events.) */ if (status == STATUS_EOF) @@ -467,7 +467,7 @@ auth_failed(Port *port, int status) case uaPAM: authmethod = "PAM"; break; -#endif /* USE_PAM */ +#endif /* USE_PAM */ } elog(FATAL, "%s authentication failed for user \"%s\"", @@ -483,7 +483,7 @@ auth_failed(Port *port, int status) void ClientAuthentication(Port *port) { - int status = STATUS_ERROR; + int status = STATUS_ERROR; /* * Get the authentication method to use for this frontend/database @@ -507,25 +507,26 @@ ClientAuthentication(Port *port) switch (port->auth_method) { case uaReject: - /* - * This could have come from an explicit "reject" entry in - * pg_hba.conf, but more likely it means there was no - * matching entry. Take pity on the poor user and issue a - * helpful error message. NOTE: this is not a security - * breach, because all the info reported here is known at - * the frontend and must be assumed known to bad guys. - * We're merely helping out the less clueful good guys. - */ - { - const char *hostinfo = "localhost"; - 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", - hostinfo, port->user, port->database); - break; - } + /* + * This could have come from an explicit "reject" entry in + * pg_hba.conf, but more likely it means there was no matching + * entry. Take pity on the poor user and issue a helpful + * error message. NOTE: this is not a security breach, + * because all the info reported here is known at the frontend + * and must be assumed known to bad guys. We're merely helping + * out the less clueful good guys. + */ + { + const char *hostinfo = "localhost"; + + 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", + hostinfo, port->user, port->database); + break; + } case uaKrb4: sendAuthRequest(port, AUTH_REQ_KRB4); @@ -539,23 +540,27 @@ ClientAuthentication(Port *port) case uaIdent: #if !defined(SO_PEERCRED) && (defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))) + /* - * If we are doing ident on unix-domain sockets, - * use SCM_CREDS only if it is defined and SO_PEERCRED isn't. + * If we are doing ident on unix-domain sockets, use SCM_CREDS + * only if it is defined and SO_PEERCRED isn't. */ #if defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED) + /* - * Receive credentials on next message receipt, BSD/OS, NetBSD. - * We need to set this before the client sends the next packet. + * Receive credentials on next message receipt, BSD/OS, + * NetBSD. We need to set this before the client sends the + * next packet. */ { - int on = 1; + int on = 1; + if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0) elog(FATAL, "pg_local_sendauth: can't do setsockopt: %s\n", strerror(errno)); } #endif - if (port->raddr.sa.sa_family == AF_UNIX) + if (port->raddr.sa.sa_family == AF_UNIX) sendAuthRequest(port, AUTH_REQ_SCM_CREDS); #endif status = authident(port); @@ -569,8 +574,8 @@ ClientAuthentication(Port *port) case uaCrypt: sendAuthRequest(port, AUTH_REQ_CRYPT); status = recv_and_check_password_packet(port); - break; - + break; + case uaPassword: sendAuthRequest(port, AUTH_REQ_PASSWORD); status = recv_and_check_password_packet(port); @@ -581,7 +586,7 @@ ClientAuthentication(Port *port) pam_port_cludge = port; status = CheckPAMAuth(port, port->user, ""); break; -#endif /* USE_PAM */ +#endif /* USE_PAM */ case uaTrust: status = STATUS_OK; @@ -609,13 +614,9 @@ sendAuthRequest(Port *port, AuthRequest areq) /* Add the salt for encrypted passwords. */ if (areq == AUTH_REQ_MD5) - { pq_sendbytes(&buf, port->md5Salt, 4); - } else if (areq == AUTH_REQ_CRYPT) - { pq_sendbytes(&buf, port->cryptSalt, 2); - } pq_endmessage(&buf); pq_flush(); @@ -628,53 +629,60 @@ sendAuthRequest(Port *port, AuthRequest areq) */ static int -pam_passwd_conv_proc (int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) +pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, struct pam_response ** resp, void *appdata_ptr) { StringInfoData buf; - int32 len; + int32 len; - if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) { - switch(msg[0]->msg_style) { + if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) + { + switch (msg[0]->msg_style) + { case PAM_ERROR_MSG: - snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'\n", msg[0]->msg); + snprintf(PQerrormsg, PQERRORMSG_LENGTH, + "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'\n", msg[0]->msg); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return PAM_CONV_ERR; default: snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'\n", - msg[0]->msg_style, msg[0]->msg); + "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'\n", + msg[0]->msg_style, msg[0]->msg); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return PAM_CONV_ERR; } } - if (!appdata_ptr) { - /* Workaround for Solaris 2.6 where the PAM library is broken - * and does not pass appdata_ptr to the conversation routine + if (!appdata_ptr) + { + /* + * Workaround for Solaris 2.6 where the PAM library is broken and + * does not pass appdata_ptr to the conversation routine */ appdata_ptr = pam_passwd; } - /* Password wasn't passed to PAM the first time around - let's go - * ask the client to send a password, which we then stuff into - * PAM. + /* + * Password wasn't passed to PAM the first time around - let's go ask + * the client to send a password, which we then stuff into PAM. */ - if(strlen(appdata_ptr) == 0) { + if (strlen(appdata_ptr) == 0) + { sendAuthRequest(pam_port_cludge, AUTH_REQ_PASSWORD); - if (pq_eof() == EOF || pq_getint(&len, 4) == EOF) { - return PAM_CONV_ERR; /* client didn't want to send password */ + if (pq_eof() == EOF || pq_getint(&len, 4) == EOF) + { + return PAM_CONV_ERR; /* client didn't want to send password */ } - initStringInfo(&buf); - pq_getstr(&buf); - if (DebugLvl > 5) + initStringInfo(&buf); + pq_getstr(&buf); + if (DebugLvl > 5) fprintf(stderr, "received PAM packet with len=%d, pw=%s\n", - len, buf.data); + len, buf.data); - if(strlen(buf.data) == 0) { + if (strlen(buf.data) == 0) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: no password\n"); fputs(PQerrormsg, stderr); return PAM_CONV_ERR; @@ -682,17 +690,19 @@ pam_passwd_conv_proc (int num_msg, const struct pam_message **msg, struct pam_re appdata_ptr = buf.data; } - /* Explicitly not using palloc here - PAM will free this memory in + /* + * Explicitly not using palloc here - PAM will free this memory in * pam_end() */ *resp = calloc(num_msg, sizeof(struct pam_response)); - if (!*resp) { + if (!*resp) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: Out of memory!\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); - if(buf.data) + if (buf.data) pfree(buf.data); - return PAM_CONV_ERR; + return PAM_CONV_ERR; } (*resp)[0].resp = strdup((char *) appdata_ptr); @@ -708,101 +718,108 @@ pam_passwd_conv_proc (int num_msg, const struct pam_message **msg, struct pam_re static int CheckPAMAuth(Port *port, char *user, char *password) { - int retval; + int retval; pam_handle_t *pamh = NULL; /* - * Apparently, Solaris 2.6 is broken, and needs ugly static - * variable workaround + * Apparently, Solaris 2.6 is broken, and needs ugly static variable + * workaround */ pam_passwd = password; - /* Set the application data portion of the conversation struct - * This is later used inside the PAM conversation to pass the - * password to the authentication module. + /* + * Set the application data portion of the conversation struct This is + * later used inside the PAM conversation to pass the password to the + * authentication module. */ - pam_passw_conv.appdata_ptr = (char*) password; /* from password above, not allocated */ + pam_passw_conv.appdata_ptr = (char *) password; /* from password above, + * not allocated */ /* Optionally, one can set the service name in pg_hba.conf */ - if(port->auth_arg[0] == '\0') { + if (port->auth_arg[0] == '\0') retval = pam_start(PGSQL_PAM_SERVICE, "pgsql@", &pam_passw_conv, &pamh); - } else { + else retval = pam_start(port->auth_arg, "pgsql@", &pam_passw_conv, &pamh); - } - if (retval != PAM_SUCCESS) { + if (retval != PAM_SUCCESS) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: Failed to create PAM authenticator: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: Failed to create PAM authenticator: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - pam_passwd = NULL; /* Unset pam_passwd */ + pqdebug("%s", PQerrormsg); + pam_passwd = NULL; /* Unset pam_passwd */ return STATUS_ERROR; } - if (retval == PAM_SUCCESS) { + if (retval == PAM_SUCCESS) retval = pam_set_item(pamh, PAM_USER, user); - } else { + else + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - pam_passwd = NULL; /* Unset pam_passwd */ + pqdebug("%s", PQerrormsg); + pam_passwd = NULL; /* Unset pam_passwd */ return STATUS_ERROR; } - if (retval == PAM_SUCCESS) { + if (retval == PAM_SUCCESS) retval = pam_set_item(pamh, PAM_CONV, &pam_passw_conv); - } else { + else + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - pam_passwd = NULL; /* Unset pam_passwd */ + pqdebug("%s", PQerrormsg); + pam_passwd = NULL; /* Unset pam_passwd */ return STATUS_ERROR; } - if (retval == PAM_SUCCESS) { + if (retval == PAM_SUCCESS) retval = pam_authenticate(pamh, 0); - } else { + else + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: pam_authenticate failed: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: pam_authenticate failed: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - pam_passwd = NULL; /* Unset pam_passwd */ + pqdebug("%s", PQerrormsg); + pam_passwd = NULL; /* Unset pam_passwd */ return STATUS_ERROR; } - if (retval == PAM_SUCCESS) { + if (retval == PAM_SUCCESS) retval = pam_acct_mgmt(pamh, 0); - } else { + else + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: pam_acct_mgmt failed: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: pam_acct_mgmt failed: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - pam_passwd = NULL; /* Unset pam_passwd */ + pqdebug("%s", PQerrormsg); + pam_passwd = NULL; /* Unset pam_passwd */ return STATUS_ERROR; } - if (retval == PAM_SUCCESS) { + if (retval == PAM_SUCCESS) + { retval = pam_end(pamh, retval); - if(retval != PAM_SUCCESS) { + if (retval != PAM_SUCCESS) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "CheckPAMAuth: Failed to release PAM authenticator: '%s'\n", - pam_strerror(pamh, retval)); + "CheckPAMAuth: Failed to release PAM authenticator: '%s'\n", + pam_strerror(pamh, retval)); fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); + pqdebug("%s", PQerrormsg); } - pam_passwd = NULL; /* Unset pam_passwd */ + pam_passwd = NULL; /* Unset pam_passwd */ return (retval == PAM_SUCCESS ? STATUS_OK : STATUS_ERROR); - } else { - return STATUS_ERROR; } + else + return STATUS_ERROR; } - -#endif /* USE_PAM */ +#endif /* USE_PAM */ /* @@ -819,7 +836,7 @@ recv_and_check_password_packet(Port *port) return STATUS_EOF; /* client didn't want to send password */ initStringInfo(&buf); - if (pq_getstr(&buf) == EOF) /* receive password */ + if (pq_getstr(&buf) == EOF) /* receive password */ { pfree(buf.data); return STATUS_EOF; @@ -903,7 +920,7 @@ map_old_to_new(Port *port, UserAuth old, int status) case uaReject: #ifdef USE_PAM case uaPAM: -#endif /* USE_PAM */ +#endif /* USE_PAM */ status = STATUS_ERROR; break; diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 1d6b80a264..e2aaba3232 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Dec 17, 1997 - Todd A. Brandys * Orignal Version Completed. * - * $Id: crypt.c,v 1.38 2001/09/21 20:31:45 tgl Exp $ + * $Id: crypt.c,v 1.39 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,6 @@ crypt_loadpwdfile(void) */ while (fgets(buffer, 256, pwd_file) != NULL) { - /* * We must remove the return char at the end of the string, as * this will affect the correct parsing of the password entry. @@ -281,8 +280,8 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) if (isMD5(passwd) && port->auth_method != uaMD5) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "Password is stored MD5 encrypted. " - "'password' and 'crypt' auth methods cannot be used.\n"); + "Password is stored MD5 encrypted. " + "'password' and 'crypt' auth methods cannot be used.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -295,11 +294,11 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) switch (port->auth_method) { case uaMD5: - crypt_pwd = palloc(MD5_PASSWD_LEN+1); + crypt_pwd = palloc(MD5_PASSWD_LEN + 1); if (isMD5(passwd)) { if (!EncryptMD5(passwd + strlen("md5"), - (char *)port->md5Salt, + (char *) port->md5Salt, sizeof(port->md5Salt), crypt_pwd)) { pfree(crypt_pwd); @@ -308,7 +307,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) } else { - char *crypt_pwd2 = palloc(MD5_PASSWD_LEN+1); + char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1); if (!EncryptMD5(passwd, port->user, strlen(port->user), crypt_pwd2)) @@ -328,12 +327,13 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) } break; case uaCrypt: - { - char salt[3]; - StrNCpy(salt, port->cryptSalt,3); - crypt_pwd = crypt(passwd, salt); - break; - } + { + char salt[3]; + + StrNCpy(salt, port->cryptSalt, 3); + crypt_pwd = crypt(passwd, salt); + break; + } default: crypt_pwd = passwd; break; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index b23710a8f6..6aafdc0913 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.74 2001/09/26 19:57:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.75 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,14 +45,14 @@ /* * These variables hold the pre-parsed contents of the hba and ident * configuration files. Each is a list of sublists, one sublist for - * each (non-empty, non-comment) line of the file. Each sublist's + * each (non-empty, non-comment) line of the file. Each sublist's * first item is an integer line number (so we can give somewhat-useful * location info in error messages). Remaining items are palloc'd strings, * one string per token on the line. Note there will always be at least * one token, since blank lines are not entered in the data structure. */ static List *hba_lines = NIL; /* pre-parsed contents of hba file */ -static List *ident_lines = NIL; /* pre-parsed contents of ident file */ +static List *ident_lines = NIL; /* pre-parsed contents of ident file */ /* @@ -67,13 +67,13 @@ 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. + * 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. */ static void next_token(FILE *fp, char *buf, const int bufsz) @@ -89,8 +89,8 @@ next_token(FILE *fp, char *buf, const int bufsz) { /* * build a token in buf of next characters up to EOF, eol, or - * blank. If the token gets too long, we still parse it correctly, - * but the excess characters are not stored into *buf. + * blank. If the token gets too long, we still parse it + * correctly, but the excess characters are not stored into *buf. */ while (c != EOF && c != '\n' && !isblank(c)) { @@ -98,9 +98,10 @@ next_token(FILE *fp, char *buf, const int bufsz) *buf++ = c; c = getc(fp); } + /* - * Put back the char right after the token (critical in case it - * is eol, since we need to detect end-of-line at next call). + * Put back the char right after the token (critical in case it is + * eol, since we need to detect end-of-line at next call). */ if (c != EOF) ungetc(c, fp); @@ -120,7 +121,7 @@ read_to_eol(FILE *file) /* - * Read the given file and create a list of line sublists. + * Read the given file and create a list of line sublists. */ static List * tokenize_file(FILE *file) @@ -182,11 +183,12 @@ free_lines(List **lines) { if (*lines) { - List *line, *token; + List *line, + *token; foreach(line, *lines) { - List *ln = lfirst(line); + List *ln = lfirst(line); /* free the pstrdup'd tokens (don't try it on the line number) */ foreach(token, lnext(ln)) @@ -203,15 +205,15 @@ free_lines(List **lines) /* - * Scan the rest of a host record (after the mask field) - * and return the interpretation of it as *userauth_p, auth_arg, and - * *error_p. line points to the next token of the line. + * Scan the rest of a host record (after the mask field) + * and return the interpretation of it as *userauth_p, auth_arg, and + * *error_p. line points to the next token of the line. */ static void parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg, bool *error_p) { - char *token; + char *token; if (!line) *error_p = true; @@ -261,21 +263,21 @@ parse_hba_auth(List *line, UserAuth *userauth_p, char *auth_arg, /* - * Process one line from the hba config file. + * Process one line from the hba config file. * - * See if it applies to a connection from a host with IP address port->raddr - * to a database named port->database. If so, return *found_p true - * and fill in the auth arguments into the appropriate port fields. - * If not, leave *found_p as it was. If the record has a syntax error, - * return *error_p true, after issuing a message to stderr. If no error, - * leave *error_p as it was. + * See if it applies to a connection from a host with IP address port->raddr + * to a database named port->database. If so, return *found_p true + * and fill in the auth arguments into the appropriate port fields. + * If not, leave *found_p as it was. If the record has a syntax error, + * return *error_p true, after issuing a message to stderr. If no error, + * leave *error_p as it was. */ static void parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) { int line_number; - char *token; - char *db; + char *token; + char *db; Assert(line != NIL); line_number = lfirsti(line); @@ -319,7 +321,8 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) } else if (strcmp(token, "host") == 0 || strcmp(token, "hostssl") == 0) { - struct in_addr file_ip_addr, mask; + struct in_addr file_ip_addr, + mask; if (strcmp(token, "hostssl") == 0) { @@ -401,17 +404,17 @@ hba_syntax: /* - * Scan the (pre-parsed) hba file line by line, looking for a match + * Scan the (pre-parsed) hba file line by line, looking for a match * to the port's connection request. */ static bool check_hba(hbaPort *port) { - bool found_entry = false; - bool error = false; - List *line; + bool found_entry = false; + bool error = false; + List *line; - foreach (line, hba_lines) + foreach(line, hba_lines) { parse_hba(lfirst(line), port, &found_entry, &error); if (found_entry || error) @@ -447,10 +450,11 @@ load_hba(void) if (hba_lines) free_lines(&hba_lines); + /* - * The name of old config file that better not exist. - * Fail if config file by old name exists. - * Put together the full pathname to the old config file. + * The name of old config file that better not exist. Fail if config + * file by old name exists. Put together the full pathname to the old + * config file. */ bufsize = (strlen(DataDir) + strlen(OLD_CONF_FILE) + 2) * sizeof(char); old_conf_file = (char *) palloc(bufsize); @@ -461,10 +465,10 @@ load_hba(void) /* Old config file exists. Tell this guy he needs to upgrade. */ close(fd); snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "A file exists by the name used for host-based authentication " - "in prior releases of Postgres (%s). The name and format of " - "the configuration file have changed, so this file should be " - "converted.\n", old_conf_file); + "A file exists by the name used for host-based authentication " + "in prior releases of Postgres (%s). The name and format of " + "the configuration file have changed, so this file should be " + "converted.\n", old_conf_file); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } @@ -502,7 +506,7 @@ load_hba(void) /* * Process one line from the ident config file. * - * Take the line and compare it to the needed map, pg_user and ident_user. + * Take the line and compare it to the needed map, pg_user and ident_user. * *found_p and *error_p are set according to our results. */ static void @@ -510,10 +514,10 @@ parse_ident_usermap(List *line, const char *usermap_name, const char *pg_user, const char *ident_user, bool *found_p, bool *error_p) { int line_number; - char *token; - char *file_map; - char *file_pguser; - char *file_ident_user; + char *token; + char *file_map; + char *file_pguser; + char *file_ident_user; *found_p = false; *error_p = false; @@ -562,32 +566,33 @@ ident_syntax: /* - * Scan the (pre-parsed) ident usermap file line by line, looking for a match + * Scan the (pre-parsed) ident usermap file line by line, looking for a match * - * See if the user with ident username "ident_user" is allowed to act - * as Postgres user "pguser" according to usermap "usermap_name". + * See if the user with ident username "ident_user" is allowed to act + * as Postgres user "pguser" according to usermap "usermap_name". * - * Special case: For usermap "sameuser", don't look in the usermap - * file. That's an implied map where "pguser" must be identical to - * "ident_user" in order to be authorized. + * Special case: For usermap "sameuser", don't look in the usermap + * file. That's an implied map where "pguser" must be identical to + * "ident_user" in order to be authorized. * - * Iff authorized, return true. + * Iff authorized, return true. */ static bool check_ident_usermap(const char *usermap_name, const char *pg_user, const char *ident_user) { - List *line; - bool found_entry = false, error = false; + List *line; + bool found_entry = false, + error = false; if (usermap_name[0] == '\0') { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "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 " - "authentication.\n"); + "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 " + "authentication.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); found_entry = false; @@ -619,9 +624,9 @@ check_ident_usermap(const char *usermap_name, static void load_ident(void) { - FILE *file; /* The map file we have to read */ - char *map_file; /* The name of the map file we have to - * read */ + FILE *file; /* The map file we have to read */ + char *map_file; /* The name of the map file we have to + * read */ int bufsize; if (ident_lines) @@ -652,16 +657,17 @@ 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 username, return true - * and store the username at *ident_user. If it's anything else, + * Parse the string "*ident_response" as a response from a query to an Ident + * server. If it's a normal response indicating a username, return true + * and store the username at *ident_user. If it's anything else, * return false. */ static bool interpret_ident_response(char *ident_response, char *ident_user) { - char *cursor = ident_response; /* Cursor into *ident_response */ + char *cursor = ident_response; /* Cursor into + * *ident_response */ /* * Ident's response, in the telnet tradition, should end in crlf @@ -735,14 +741,14 @@ interpret_ident_response(char *ident_response, /* - * Talk to the ident server on host "remote_ip_addr" and find out who - * owns the tcp connection from his port "remote_port" to port - * "local_port_addr" on host "local_ip_addr". Return the username the - * ident server gives as "*ident_user". + * Talk to the ident server on host "remote_ip_addr" and find out who + * owns the tcp connection from his port "remote_port" to port + * "local_port_addr" on host "local_ip_addr". Return the username the + * ident server gives as "*ident_user". * - * IP addresses and port numbers are in network byte order. + * IP addresses and port numbers are in network byte order. * - * But iff we're unable to get the information from ident, return false. + * But iff we're unable to get the information from ident, return false. */ static bool ident_inet(const struct in_addr remote_ip_addr, @@ -755,14 +761,14 @@ ident_inet(const struct in_addr remote_ip_addr, * talk to Ident */ rc; /* Return code from a locally called * function */ - bool ident_return; + bool ident_return; sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock_fd == -1) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "Failed to create socket on which to talk to Ident server. " - "socket() returned errno = %s (%d)\n", strerror(errno), errno); + "Failed to create socket on which to talk to Ident server. " + "socket() returned errno = %s (%d)\n", strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); ident_return = false; @@ -799,10 +805,10 @@ ident_inet(const struct in_addr remote_ip_addr, { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "Unable to connect to Ident server on the host which is " - "trying to connect to Postgres " - "(IP address %s, Port %d). " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); + "trying to connect to Postgres " + "(IP address %s, Port %d). " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); ident_return = false; @@ -818,11 +824,11 @@ ident_inet(const struct in_addr remote_ip_addr, if (rc < 0) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "Unable to send query to Ident server on the host which is " - "trying to connect to Postgres (Host %s, Port %d)," - "even though we successfully connected to it. " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); + "Unable to send query to Ident server on the host which is " + "trying to connect to Postgres (Host %s, Port %d)," + "even though we successfully connected to it. " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); ident_return = false; @@ -836,13 +842,13 @@ ident_inet(const struct in_addr remote_ip_addr, if (rc < 0) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "Unable to receive response from Ident server " - "on the host which is " - "trying to connect to Postgres (Host %s, Port %d)," - "even though we successfully sent our query to it. " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, - strerror(errno), errno); + "Unable to receive response from Ident server " + "on the host which is " + "trying to connect to Postgres (Host %s, Port %d)," + "even though we successfully sent our query to it. " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, + strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); ident_return = false; @@ -861,18 +867,18 @@ ident_inet(const struct in_addr remote_ip_addr, } /* - * Ask kernel about the credentials of the connecting process and - * determine the symbolic name of the corresponding user. + * Ask kernel about the credentials of the connecting process and + * determine the symbolic name of the corresponding user. * - * Returns either true and the username put into "ident_user", - * or false if we were unable to determine the username. + * Returns either true and the username put into "ident_user", + * or false if we were unable to determine the username. */ static bool ident_unix(int sock, char *ident_user) { #if defined(SO_PEERCRED) /* Linux style: use getsockopt(SO_PEERCRED) */ - struct ucred peercred; + struct ucred peercred; ACCEPT_TYPE_ARG3 so_len = sizeof(peercred); struct passwd *pass; @@ -894,13 +900,13 @@ ident_unix(int sock, char *ident_user) if (pass == NULL) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "ident_unix: unknown local user with uid %d\n", peercred.uid); + "ident_unix: unknown local user with uid %d\n", peercred.uid); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return false; } - StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX+1); + StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1); return true; @@ -910,36 +916,40 @@ ident_unix(int sock, char *ident_user) /* Credentials structure */ #ifdef HAVE_STRUCT_CMSGCRED typedef struct cmsgcred Cred; + #define cruid cmcred_uid #elif HAVE_STRUCT_FCRED typedef struct fcred Cred; + #define cruid fc_uid #elif HAVE_STRUCT_SOCKCRED typedef struct sockcred Cred; + #define cruid sc_uid #endif - Cred *cred; + Cred *cred; /* Compute size without padding */ - char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))]; /*for NetBSD*/ + char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))]; /* for NetBSD */ + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; struct iovec iov; - char buf; + char buf; struct passwd *pw; memset(&msg, 0, sizeof(msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = (char *)cmsg; + msg.msg_control = (char *) cmsg; msg.msg_controllen = sizeof(cmsgmem); memset(cmsg, 0, sizeof(cmsgmem)); /* - * The one character which is received here is not meaningful; - * its purposes is only to make sure that recvmsg() blocks - * long enough for the other side to send its credentials. + * The one character which is received here is not meaningful; its + * purposes is only to make sure that recvmsg() blocks long enough for + * the other side to send its credentials. */ iov.iov_base = &buf; iov.iov_len = 1; @@ -956,20 +966,20 @@ ident_unix(int sock, char *ident_user) return false; } - cred = (Cred *)CMSG_DATA(cmsg); + cred = (Cred *) CMSG_DATA(cmsg); pw = getpwuid(cred->cruid); if (pw == NULL) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "ident_unix: unknown local user with uid %d\n", - cred->cruid); + "ident_unix: unknown local user with uid %d\n", + cred->cruid); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return false; } - StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX+1); + StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1); return true; @@ -980,17 +990,16 @@ ident_unix(int sock, char *ident_user) pqdebug("%s", PQerrormsg); return false; - #endif } /* - * Determine the username of the initiator of the connection described - * by "port". Then look in the usermap file under the usermap - * port->auth_arg and see if that user is equivalent to Postgres user - * port->user. + * Determine the username of the initiator of the connection described + * by "port". Then look in the usermap file under the usermap + * port->auth_arg and see if that user is equivalent to Postgres user + * port->user. * - * Return STATUS_OK if yes, STATUS_ERROR if no match (or couldn't get info). + * Return STATUS_OK if yes, STATUS_ERROR if no match (or couldn't get info). */ int authident(hbaPort *port) @@ -1022,13 +1031,13 @@ authident(hbaPort *port) /* - * Determine what authentication method should be used when accessing database - * "database" from frontend "raddr", user "user". Return the method and - * an optional argument (stored in fields of *port), and STATUS_OK. + * Determine what authentication method should be used when accessing database + * "database" from frontend "raddr", user "user". Return the method and + * an optional argument (stored in fields of *port), and STATUS_OK. * - * Note that STATUS_ERROR indicates a problem with the hba config file. - * If the file is OK but does not contain any entry matching the request, - * we return STATUS_OK and method = uaReject. + * Note that STATUS_ERROR indicates a problem with the hba config file. + * If the file is OK but does not contain any entry matching the request, + * we return STATUS_OK and method = uaReject. */ int hba_getauthmethod(hbaPort *port) @@ -1252,5 +1261,4 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir) pfree((struct CharsetItem *) ChArray[i]); } } - -#endif /* CYR_RECODE */ +#endif /* CYR_RECODE */ diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index c47abc71ce..b0fc834eb0 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -1,16 +1,16 @@ /* - * md5.c + * md5.c * - * Implements the MD5 Message-Digest Algorithm as specified in - * RFC 1321. This implementation is a simple one, in that it - * needs every input byte to be buffered before doing any - * calculations. I do not expect this file to be used for - * general purpose MD5'ing of large amounts of data, only for - * generating hashed passwords from limited input. + * Implements the MD5 Message-Digest Algorithm as specified in + * RFC 1321. This implementation is a simple one, in that it + * needs every input byte to be buffered before doing any + * calculations. I do not expect this file to be used for + * general purpose MD5'ing of large amounts of data, only for + * generating hashed passwords from limited input. * - * Sverre H. Huseby <sverrehu@online.no> + * Sverre H. Huseby <sverrehu@online.no> * - * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.8 2001/09/29 19:49:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.9 2001/10/25 05:49:30 momjian Exp $ */ #include "postgres.h" @@ -32,15 +32,17 @@ /* * The returned array is allocated using malloc. the caller should free it - * when it is no longer needed. + * when it is no longer needed. */ static uint8 * createPaddedCopyWithLength(uint8 *b, uint32 *l) { - uint8 *ret; - uint32 q; - uint32 len, newLen448; - uint32 len_high, len_low; /* 64-bit value split into 32-bit sections */ + uint8 *ret; + uint32 q; + uint32 len, + newLen448; + uint32 len_high, + len_low; /* 64-bit value split into 32-bit sections */ len = ((b == NULL) ? 0 : *l); newLen448 = len + 64 - (len % 64) - 8; @@ -93,7 +95,10 @@ createPaddedCopyWithLength(uint8 *b, uint32 *l) static void doTheRounds(uint32 X[16], uint32 state[4]) { - uint32 a, b, c, d; + uint32 a, + b, + c, + d; a = state[0]; b = state[1]; @@ -101,76 +106,76 @@ doTheRounds(uint32 X[16], uint32 state[4]) d = state[3]; /* round 1 */ - a = b + ROT_LEFT((a + F(b, c, d) + X[ 0] + 0xd76aa478), 7); /* 1 */ - d = a + ROT_LEFT((d + F(a, b, c) + X[ 1] + 0xe8c7b756), 12); /* 2 */ - c = d + ROT_LEFT((c + F(d, a, b) + X[ 2] + 0x242070db), 17); /* 3 */ - b = c + ROT_LEFT((b + F(c, d, a) + X[ 3] + 0xc1bdceee), 22); /* 4 */ - a = b + ROT_LEFT((a + F(b, c, d) + X[ 4] + 0xf57c0faf), 7); /* 5 */ - d = a + ROT_LEFT((d + F(a, b, c) + X[ 5] + 0x4787c62a), 12); /* 6 */ - c = d + ROT_LEFT((c + F(d, a, b) + X[ 6] + 0xa8304613), 17); /* 7 */ - b = c + ROT_LEFT((b + F(c, d, a) + X[ 7] + 0xfd469501), 22); /* 8 */ - a = b + ROT_LEFT((a + F(b, c, d) + X[ 8] + 0x698098d8), 7); /* 9 */ - d = a + ROT_LEFT((d + F(a, b, c) + X[ 9] + 0x8b44f7af), 12); /* 10 */ - c = d + ROT_LEFT((c + F(d, a, b) + X[10] + 0xffff5bb1), 17); /* 11 */ - b = c + ROT_LEFT((b + F(c, d, a) + X[11] + 0x895cd7be), 22); /* 12 */ - a = b + ROT_LEFT((a + F(b, c, d) + X[12] + 0x6b901122), 7); /* 13 */ - d = a + ROT_LEFT((d + F(a, b, c) + X[13] + 0xfd987193), 12); /* 14 */ - c = d + ROT_LEFT((c + F(d, a, b) + X[14] + 0xa679438e), 17); /* 15 */ - b = c + ROT_LEFT((b + F(c, d, a) + X[15] + 0x49b40821), 22); /* 16 */ + a = b + ROT_LEFT((a + F(b, c, d) + X[0] + 0xd76aa478), 7); /* 1 */ + d = a + ROT_LEFT((d + F(a, b, c) + X[1] + 0xe8c7b756), 12); /* 2 */ + c = d + ROT_LEFT((c + F(d, a, b) + X[2] + 0x242070db), 17); /* 3 */ + b = c + ROT_LEFT((b + F(c, d, a) + X[3] + 0xc1bdceee), 22); /* 4 */ + a = b + ROT_LEFT((a + F(b, c, d) + X[4] + 0xf57c0faf), 7); /* 5 */ + d = a + ROT_LEFT((d + F(a, b, c) + X[5] + 0x4787c62a), 12); /* 6 */ + c = d + ROT_LEFT((c + F(d, a, b) + X[6] + 0xa8304613), 17); /* 7 */ + b = c + ROT_LEFT((b + F(c, d, a) + X[7] + 0xfd469501), 22); /* 8 */ + a = b + ROT_LEFT((a + F(b, c, d) + X[8] + 0x698098d8), 7); /* 9 */ + d = a + ROT_LEFT((d + F(a, b, c) + X[9] + 0x8b44f7af), 12); /* 10 */ + c = d + ROT_LEFT((c + F(d, a, b) + X[10] + 0xffff5bb1), 17); /* 11 */ + b = c + ROT_LEFT((b + F(c, d, a) + X[11] + 0x895cd7be), 22); /* 12 */ + a = b + ROT_LEFT((a + F(b, c, d) + X[12] + 0x6b901122), 7); /* 13 */ + d = a + ROT_LEFT((d + F(a, b, c) + X[13] + 0xfd987193), 12); /* 14 */ + c = d + ROT_LEFT((c + F(d, a, b) + X[14] + 0xa679438e), 17); /* 15 */ + b = c + ROT_LEFT((b + F(c, d, a) + X[15] + 0x49b40821), 22); /* 16 */ /* round 2 */ - a = b + ROT_LEFT((a + G(b, c, d) + X[ 1] + 0xf61e2562), 5); /* 17 */ - d = a + ROT_LEFT((d + G(a, b, c) + X[ 6] + 0xc040b340), 9); /* 18 */ - c = d + ROT_LEFT((c + G(d, a, b) + X[11] + 0x265e5a51), 14); /* 19 */ - b = c + ROT_LEFT((b + G(c, d, a) + X[ 0] + 0xe9b6c7aa), 20); /* 20 */ - a = b + ROT_LEFT((a + G(b, c, d) + X[ 5] + 0xd62f105d), 5); /* 21 */ - d = a + ROT_LEFT((d + G(a, b, c) + X[10] + 0x02441453), 9); /* 22 */ - c = d + ROT_LEFT((c + G(d, a, b) + X[15] + 0xd8a1e681), 14); /* 23 */ - b = c + ROT_LEFT((b + G(c, d, a) + X[ 4] + 0xe7d3fbc8), 20); /* 24 */ - a = b + ROT_LEFT((a + G(b, c, d) + X[ 9] + 0x21e1cde6), 5); /* 25 */ - d = a + ROT_LEFT((d + G(a, b, c) + X[14] + 0xc33707d6), 9); /* 26 */ - c = d + ROT_LEFT((c + G(d, a, b) + X[ 3] + 0xf4d50d87), 14); /* 27 */ - b = c + ROT_LEFT((b + G(c, d, a) + X[ 8] + 0x455a14ed), 20); /* 28 */ - a = b + ROT_LEFT((a + G(b, c, d) + X[13] + 0xa9e3e905), 5); /* 29 */ - d = a + ROT_LEFT((d + G(a, b, c) + X[ 2] + 0xfcefa3f8), 9); /* 30 */ - c = d + ROT_LEFT((c + G(d, a, b) + X[ 7] + 0x676f02d9), 14); /* 31 */ - b = c + ROT_LEFT((b + G(c, d, a) + X[12] + 0x8d2a4c8a), 20); /* 32 */ + a = b + ROT_LEFT((a + G(b, c, d) + X[1] + 0xf61e2562), 5); /* 17 */ + d = a + ROT_LEFT((d + G(a, b, c) + X[6] + 0xc040b340), 9); /* 18 */ + c = d + ROT_LEFT((c + G(d, a, b) + X[11] + 0x265e5a51), 14); /* 19 */ + b = c + ROT_LEFT((b + G(c, d, a) + X[0] + 0xe9b6c7aa), 20); /* 20 */ + a = b + ROT_LEFT((a + G(b, c, d) + X[5] + 0xd62f105d), 5); /* 21 */ + d = a + ROT_LEFT((d + G(a, b, c) + X[10] + 0x02441453), 9); /* 22 */ + c = d + ROT_LEFT((c + G(d, a, b) + X[15] + 0xd8a1e681), 14); /* 23 */ + b = c + ROT_LEFT((b + G(c, d, a) + X[4] + 0xe7d3fbc8), 20); /* 24 */ + a = b + ROT_LEFT((a + G(b, c, d) + X[9] + 0x21e1cde6), 5); /* 25 */ + d = a + ROT_LEFT((d + G(a, b, c) + X[14] + 0xc33707d6), 9); /* 26 */ + c = d + ROT_LEFT((c + G(d, a, b) + X[3] + 0xf4d50d87), 14); /* 27 */ + b = c + ROT_LEFT((b + G(c, d, a) + X[8] + 0x455a14ed), 20); /* 28 */ + a = b + ROT_LEFT((a + G(b, c, d) + X[13] + 0xa9e3e905), 5); /* 29 */ + d = a + ROT_LEFT((d + G(a, b, c) + X[2] + 0xfcefa3f8), 9); /* 30 */ + c = d + ROT_LEFT((c + G(d, a, b) + X[7] + 0x676f02d9), 14); /* 31 */ + b = c + ROT_LEFT((b + G(c, d, a) + X[12] + 0x8d2a4c8a), 20); /* 32 */ /* round 3 */ - a = b + ROT_LEFT((a + H(b, c, d) + X[ 5] + 0xfffa3942), 4); /* 33 */ - d = a + ROT_LEFT((d + H(a, b, c) + X[ 8] + 0x8771f681), 11); /* 34 */ - c = d + ROT_LEFT((c + H(d, a, b) + X[11] + 0x6d9d6122), 16); /* 35 */ - b = c + ROT_LEFT((b + H(c, d, a) + X[14] + 0xfde5380c), 23); /* 36 */ - a = b + ROT_LEFT((a + H(b, c, d) + X[ 1] + 0xa4beea44), 4); /* 37 */ - d = a + ROT_LEFT((d + H(a, b, c) + X[ 4] + 0x4bdecfa9), 11); /* 38 */ - c = d + ROT_LEFT((c + H(d, a, b) + X[ 7] + 0xf6bb4b60), 16); /* 39 */ - b = c + ROT_LEFT((b + H(c, d, a) + X[10] + 0xbebfbc70), 23); /* 40 */ - a = b + ROT_LEFT((a + H(b, c, d) + X[13] + 0x289b7ec6), 4); /* 41 */ - d = a + ROT_LEFT((d + H(a, b, c) + X[ 0] + 0xeaa127fa), 11); /* 42 */ - c = d + ROT_LEFT((c + H(d, a, b) + X[ 3] + 0xd4ef3085), 16); /* 43 */ - b = c + ROT_LEFT((b + H(c, d, a) + X[ 6] + 0x04881d05), 23); /* 44 */ - a = b + ROT_LEFT((a + H(b, c, d) + X[ 9] + 0xd9d4d039), 4); /* 45 */ - d = a + ROT_LEFT((d + H(a, b, c) + X[12] + 0xe6db99e5), 11); /* 46 */ - c = d + ROT_LEFT((c + H(d, a, b) + X[15] + 0x1fa27cf8), 16); /* 47 */ - b = c + ROT_LEFT((b + H(c, d, a) + X[ 2] + 0xc4ac5665), 23); /* 48 */ + a = b + ROT_LEFT((a + H(b, c, d) + X[5] + 0xfffa3942), 4); /* 33 */ + d = a + ROT_LEFT((d + H(a, b, c) + X[8] + 0x8771f681), 11); /* 34 */ + c = d + ROT_LEFT((c + H(d, a, b) + X[11] + 0x6d9d6122), 16); /* 35 */ + b = c + ROT_LEFT((b + H(c, d, a) + X[14] + 0xfde5380c), 23); /* 36 */ + a = b + ROT_LEFT((a + H(b, c, d) + X[1] + 0xa4beea44), 4); /* 37 */ + d = a + ROT_LEFT((d + H(a, b, c) + X[4] + 0x4bdecfa9), 11); /* 38 */ + c = d + ROT_LEFT((c + H(d, a, b) + X[7] + 0xf6bb4b60), 16); /* 39 */ + b = c + ROT_LEFT((b + H(c, d, a) + X[10] + 0xbebfbc70), 23); /* 40 */ + a = b + ROT_LEFT((a + H(b, c, d) + X[13] + 0x289b7ec6), 4); /* 41 */ + d = a + ROT_LEFT((d + H(a, b, c) + X[0] + 0xeaa127fa), 11); /* 42 */ + c = d + ROT_LEFT((c + H(d, a, b) + X[3] + 0xd4ef3085), 16); /* 43 */ + b = c + ROT_LEFT((b + H(c, d, a) + X[6] + 0x04881d05), 23); /* 44 */ + a = b + ROT_LEFT((a + H(b, c, d) + X[9] + 0xd9d4d039), 4); /* 45 */ + d = a + ROT_LEFT((d + H(a, b, c) + X[12] + 0xe6db99e5), 11); /* 46 */ + c = d + ROT_LEFT((c + H(d, a, b) + X[15] + 0x1fa27cf8), 16); /* 47 */ + b = c + ROT_LEFT((b + H(c, d, a) + X[2] + 0xc4ac5665), 23); /* 48 */ /* round 4 */ - a = b + ROT_LEFT((a + I(b, c, d) + X[ 0] + 0xf4292244), 6); /* 49 */ - d = a + ROT_LEFT((d + I(a, b, c) + X[ 7] + 0x432aff97), 10); /* 50 */ - c = d + ROT_LEFT((c + I(d, a, b) + X[14] + 0xab9423a7), 15); /* 51 */ - b = c + ROT_LEFT((b + I(c, d, a) + X[ 5] + 0xfc93a039), 21); /* 52 */ - a = b + ROT_LEFT((a + I(b, c, d) + X[12] + 0x655b59c3), 6); /* 53 */ - d = a + ROT_LEFT((d + I(a, b, c) + X[ 3] + 0x8f0ccc92), 10); /* 54 */ - c = d + ROT_LEFT((c + I(d, a, b) + X[10] + 0xffeff47d), 15); /* 55 */ - b = c + ROT_LEFT((b + I(c, d, a) + X[ 1] + 0x85845dd1), 21); /* 56 */ - a = b + ROT_LEFT((a + I(b, c, d) + X[ 8] + 0x6fa87e4f), 6); /* 57 */ - d = a + ROT_LEFT((d + I(a, b, c) + X[15] + 0xfe2ce6e0), 10); /* 58 */ - c = d + ROT_LEFT((c + I(d, a, b) + X[ 6] + 0xa3014314), 15); /* 59 */ - b = c + ROT_LEFT((b + I(c, d, a) + X[13] + 0x4e0811a1), 21); /* 60 */ - a = b + ROT_LEFT((a + I(b, c, d) + X[ 4] + 0xf7537e82), 6); /* 61 */ - d = a + ROT_LEFT((d + I(a, b, c) + X[11] + 0xbd3af235), 10); /* 62 */ - c = d + ROT_LEFT((c + I(d, a, b) + X[ 2] + 0x2ad7d2bb), 15); /* 63 */ - b = c + ROT_LEFT((b + I(c, d, a) + X[ 9] + 0xeb86d391), 21); /* 64 */ + a = b + ROT_LEFT((a + I(b, c, d) + X[0] + 0xf4292244), 6); /* 49 */ + d = a + ROT_LEFT((d + I(a, b, c) + X[7] + 0x432aff97), 10); /* 50 */ + c = d + ROT_LEFT((c + I(d, a, b) + X[14] + 0xab9423a7), 15); /* 51 */ + b = c + ROT_LEFT((b + I(c, d, a) + X[5] + 0xfc93a039), 21); /* 52 */ + a = b + ROT_LEFT((a + I(b, c, d) + X[12] + 0x655b59c3), 6); /* 53 */ + d = a + ROT_LEFT((d + I(a, b, c) + X[3] + 0x8f0ccc92), 10); /* 54 */ + c = d + ROT_LEFT((c + I(d, a, b) + X[10] + 0xffeff47d), 15); /* 55 */ + b = c + ROT_LEFT((b + I(c, d, a) + X[1] + 0x85845dd1), 21); /* 56 */ + a = b + ROT_LEFT((a + I(b, c, d) + X[8] + 0x6fa87e4f), 6); /* 57 */ + d = a + ROT_LEFT((d + I(a, b, c) + X[15] + 0xfe2ce6e0), 10); /* 58 */ + c = d + ROT_LEFT((c + I(d, a, b) + X[6] + 0xa3014314), 15); /* 59 */ + b = c + ROT_LEFT((b + I(c, d, a) + X[13] + 0x4e0811a1), 21); /* 60 */ + a = b + ROT_LEFT((a + I(b, c, d) + X[4] + 0xf7537e82), 6); /* 61 */ + d = a + ROT_LEFT((d + I(a, b, c) + X[11] + 0xbd3af235), 10); /* 62 */ + c = d + ROT_LEFT((c + I(d, a, b) + X[2] + 0x2ad7d2bb), 15); /* 63 */ + b = c + ROT_LEFT((b + I(c, d, a) + X[9] + 0xeb86d391), 21); /* 64 */ state[0] += a; state[1] += b; @@ -181,11 +186,15 @@ doTheRounds(uint32 X[16], uint32 state[4]) static int calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16]) { - register uint32 i, j, k, newI; - uint32 l; - uint8 *input; + register uint32 i, + j, + k, + newI; + uint32 l; + uint8 *input; register uint32 *wbp; - uint32 workBuff[16], state[4]; + uint32 workBuff[16], + state[4]; l = len; @@ -197,11 +206,13 @@ calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16]) if ((input = createPaddedCopyWithLength(b, &l)) == NULL) return 0; - for (i = 0;;) { + for (i = 0;;) + { if ((newI = i + 16 * 4) > l) break; k = i + 3; - for (j = 0; j < 16; j++) { + for (j = 0; j < 16; j++) + { wbp = (workBuff + j); *wbp = input[k--]; *wbp <<= 8; @@ -218,7 +229,8 @@ calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16]) free(input); j = 0; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) + { k = state[i]; sum[j++] = (k & 0xff); k >>= 8; @@ -235,9 +247,11 @@ static void bytesToHex(uint8 b[16], char *s) { static char *hex = "0123456789abcdef"; - int q, w; + int q, + w; - for (q = 0, w = 0; q < 16; q++) { + for (q = 0, w = 0; q < 16; q++) + { s[w++] = hex[(b[q] >> 4) & 0x0F]; s[w++] = hex[b[q] & 0x0F]; } @@ -245,39 +259,39 @@ bytesToHex(uint8 b[16], char *s) } /* - * PUBLIC FUNCTIONS + * PUBLIC FUNCTIONS */ /* - * md5_hash + * md5_hash * - * Calculates the MD5 sum of the bytes in a buffer. + * Calculates the MD5 sum of the bytes in a buffer. * - * SYNOPSIS #include "crypt.h" - * int md5_hash(const void *buff, size_t len, char *hexsum) + * SYNOPSIS #include "crypt.h" + * int md5_hash(const void *buff, size_t len, char *hexsum) * - * INPUT buff the buffer containing the bytes that you want - * the MD5 sum of. - * len number of bytes in the buffer. + * INPUT buff the buffer containing the bytes that you want + * the MD5 sum of. + * len number of bytes in the buffer. * - * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of - * hexadecimal digits. an MD5 sum is 16 bytes long. - * each byte is represented by two heaxadecimal - * characters. you thus need to provide an array - * of 33 characters, including the trailing '\0'. + * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of + * hexadecimal digits. an MD5 sum is 16 bytes long. + * each byte is represented by two heaxadecimal + * characters. you thus need to provide an array + * of 33 characters, including the trailing '\0'. * - * RETURNS 0 on failure (out of memory for internal buffers) or - * non-zero on success. + * RETURNS 0 on failure (out of memory for internal buffers) or + * non-zero on success. * - * STANDARDS MD5 is described in RFC 1321. + * STANDARDS MD5 is described in RFC 1321. * - * AUTHOR Sverre H. Huseby <sverrehu@online.no> + * AUTHOR Sverre H. Huseby <sverrehu@online.no> * */ bool md5_hash(const void *buff, size_t len, char *hexsum) { - uint8 sum[16]; + uint8 sum[16]; if (!calculateDigestFromBuffer((uint8 *) buff, len, sum)) return false; @@ -297,19 +311,20 @@ md5_hash(const void *buff, size_t len, char *hexsum) * * Returns TRUE if okay, FALSE on error (out of memory). */ -bool EncryptMD5(const char *passwd, const char *salt, size_t salt_len, - char *buf) +bool +EncryptMD5(const char *passwd, const char *salt, size_t salt_len, + char *buf) { - size_t passwd_len = strlen(passwd); - char *crypt_buf = palloc(passwd_len + salt_len); - bool ret; - + size_t passwd_len = strlen(passwd); + char *crypt_buf = palloc(passwd_len + salt_len); + bool ret; + /* - * Place salt at the end because it may be known by users - * trying to crack the MD5 output. - */ + * Place salt at the end because it may be known by users trying to + * crack the MD5 output. + */ strcpy(crypt_buf, passwd); - memcpy(crypt_buf+passwd_len, salt, salt_len); + memcpy(crypt_buf + passwd_len, salt, salt_len); strcpy(buf, "md5"); ret = md5_hash(crypt_buf, passwd_len + salt_len, buf + 3); diff --git a/src/backend/libpq/password.c b/src/backend/libpq/password.c index 4dde3afe99..96415ae4e7 100644 --- a/src/backend/libpq/password.c +++ b/src/backend/libpq/password.c @@ -2,7 +2,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: password.c,v 1.39 2001/08/17 15:44:17 momjian Exp $ + * $Id: password.c,v 1.40 2001/10/25 05:49:30 momjian Exp $ * */ @@ -78,9 +78,9 @@ verify_password(const Port *port, const char *user, const char *password) /* * If the password is empty or "+" then we use the regular * pg_shadow passwords. If we use crypt then we have to use - * pg_shadow passwords no matter what. This is because - * the current code needs non-encrypted passwords to - * encrypt with a random salt. + * pg_shadow passwords no matter what. This is because the + * current code needs non-encrypted passwords to encrypt with + * a random salt. */ if (port->auth_method == uaMD5 || port->auth_method == uaCrypt || diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index b588f09a07..8ea425a701 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -29,7 +29,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.c,v 1.121 2001/08/07 15:55:16 tgl Exp $ + * $Id: pqcomm.c,v 1.122 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -347,9 +347,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, #endif /* HAVE_UNIX_SOCKETS */ /* - * Select appropriate accept-queue length limit. PG_SOMAXCONN is - * only intended to provide a clamp on the request on platforms where - * an overly large request provokes a kernel error (are there any?). + * Select appropriate accept-queue length limit. PG_SOMAXCONN is only + * intended to provide a clamp on the request on platforms where an + * overly large request provokes a kernel error (are there any?). */ maxconn = MaxBackends * 2; if (maxconn > PG_SOMAXCONN) @@ -401,6 +401,7 @@ StreamConnection(int server_fd, Port *port) } #ifdef SCO_ACCEPT_BUG + /* * UnixWare 7+ and OpenServer 5.0.4 are known to have this bug, but it * shouldn't hurt to catch it for all versions of those platforms. @@ -701,8 +702,8 @@ pq_flush(void) int pq_eof(void) { - char x; - int res; + char x; + int res; res = recv(MyProcPort->sock, &x, 1, MSG_PEEK); diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index 6719017c6d..a0ea85f41f 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -16,7 +16,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.c,v 1.17 2001/04/16 01:46:57 tgl Exp $ + * $Id: pqformat.c,v 1.18 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,7 +90,6 @@ #else #error BYTE_ORDER not defined as anything understood - #endif #endif #endif @@ -309,7 +308,6 @@ pq_getstr(StringInfo s) #ifdef MULTIBYTE char *p; - #endif result = pq_getstring(s); diff --git a/src/backend/libpq/util.c b/src/backend/libpq/util.c index a80dc8781f..4ddf17d59b 100644 --- a/src/backend/libpq/util.c +++ b/src/backend/libpq/util.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.17 2001/01/24 19:42:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.18 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,6 @@ pqdebug(char *fmt, char *msg) if (PQtracep) { - /* * if nothing else was suggested default to stderr */ diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 43d9b6433d..be5896e375 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.47 2001/10/22 19:41:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.48 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,11 +67,9 @@ main(int argc, char *argv[]) #if defined(__alpha) #ifdef NOFIXADE int buffer[] = {SSIN_UACPROC, UAC_SIGBUS}; - #endif /* NOFIXADE */ #ifdef NOPRINTADE int buffer[] = {SSIN_UACPROC, UAC_NOPRINT}; - #endif /* NOPRINTADE */ #endif /* __alpha */ @@ -86,7 +84,6 @@ main(int argc, char *argv[]) (unsigned long) NULL) < 0) fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"), argv[0], strerror(errno)); #endif - #endif /* NOFIXADE || NOPRINTADE */ #ifdef __BEOS__ @@ -107,16 +104,16 @@ main(int argc, char *argv[]) * affected if init_ps_display overwrites the original argv[]. * * (NB: do NOT think to remove the copying of argv[], even though - * postmaster.c finishes looking at argv[] long before we ever consider - * changing the ps display. On some platforms, getopt() keeps pointers - * into the argv array, and will get horribly confused when it is - * re-called to analyze a subprocess' argument string if the argv storage - * has been clobbered meanwhile.) + * postmaster.c finishes looking at argv[] long before we ever + * consider changing the ps display. On some platforms, getopt() + * keeps pointers into the argv array, and will get horribly confused + * when it is re-called to analyze a subprocess' argument string if + * the argv storage has been clobbered meanwhile.) * * On some platforms, save_ps_display_args moves the environment strings - * to make extra room. Therefore this should be done as early as - * possible during startup, to avoid entanglements with code that might - * save a getenv() result pointer. + * to make extra room. Therefore this should be done as early as + * possible during startup, to avoid entanglements with code that + * might save a getenv() result pointer. */ save_ps_display_args(argc, argv); @@ -135,8 +132,9 @@ main(int argc, char *argv[]) #endif /* - * Skip permission checks if we're just trying to do --help or --version; - * otherwise root will get unhelpful failure messages from initdb. + * Skip permission checks if we're just trying to do --help or + * --version; otherwise root will get unhelpful failure messages from + * initdb. */ if (!(argc > 1 && (strcmp(argv[1], "--help") == 0 || @@ -154,11 +152,11 @@ main(int argc, char *argv[]) if (geteuid() == 0) { fprintf(stderr, gettext( - "\"root\" execution of the PostgreSQL server is not permitted.\n\n" - "The server must be started under an unprivileged user id to prevent\n" - "a possible system security compromise. See the documentation for\n" - "more information on how to properly start the server.\n\n" - )); + "\"root\" execution of the PostgreSQL server is not permitted.\n\n" + "The server must be started under an unprivileged user id to prevent\n" + "a possible system security compromise. See the documentation for\n" + "more information on how to properly start the server.\n\n" + )); exit(1); } #endif /* __BEOS__ */ @@ -166,11 +164,11 @@ main(int argc, char *argv[]) /* * Also make sure that real and effective uids are the same. * Executing Postgres as a setuid program from a root shell is a - * security hole, since on many platforms a nefarious subroutine could - * setuid back to root if real uid is root. (Since nobody actually - * uses Postgres as a setuid program, trying to actively fix this - * situation seems more trouble than it's worth; we'll just expend the - * effort to check for it.) + * security hole, since on many platforms a nefarious subroutine + * could setuid back to root if real uid is root. (Since nobody + * actually uses Postgres as a setuid program, trying to actively + * fix this situation seems more trouble than it's worth; we'll + * just expend the effort to check for it.) */ if (getuid() != geteuid()) { diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index abf5c08d27..620054380a 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.158 2001/10/18 17:30:14 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.159 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -782,7 +782,6 @@ _copyConst(Const *from) if (from->constbyval || from->constisnull) { - /* * passed by value so just copy the datum. Also, don't try to copy * struct when value is null! @@ -792,7 +791,6 @@ _copyConst(Const *from) } else { - /* * not passed by value. datum contains a pointer. */ @@ -1024,7 +1022,7 @@ _copyCaseWhen(CaseWhen *from) static NullTest * _copyNullTest(NullTest *from) { - NullTest *newnode = makeNode(NullTest); + NullTest *newnode = makeNode(NullTest); /* * copy remainder of node @@ -1180,7 +1178,6 @@ _copyIndexOptInfo(IndexOptInfo *from) static void CopyPathFields(Path *from, Path *newnode) { - /* * Modify the next line, since it causes the copying to cycle (i.e. * the parent points right back here! -- JMH, 7/7/92. Old version: @@ -1780,8 +1777,8 @@ _copyQuery(Query *from) /* * We do not copy the planner internal fields: base_rel_list, - * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. - * Not entirely clear if this is right? + * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. Not + * entirely clear if this is right? */ return newnode; @@ -1892,7 +1889,7 @@ _copyAlterTableStmt(AlterTableStmt *from) static GrantStmt * _copyGrantStmt(GrantStmt *from) { - GrantStmt *newnode = makeNode(GrantStmt); + GrantStmt *newnode = makeNode(GrantStmt); newnode->is_grant = from->is_grant; Node_Copy(from, newnode, relnames); @@ -2426,7 +2423,7 @@ _copyLockStmt(LockStmt *from) LockStmt *newnode = makeNode(LockStmt); Node_Copy(from, newnode, rellist); - + newnode->mode = from->mode; return newnode; @@ -2536,7 +2533,6 @@ copyObject(void *from) switch (nodeTag(from)) { - /* * PLAN NODES */ diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 64e27f1780..0a48a194df 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -20,7 +20,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.106 2001/10/18 17:30:14 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.107 2001/10/25 05:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,7 +87,6 @@ _equalFjoin(Fjoin *a, Fjoin *b) static bool _equalExpr(Expr *a, Expr *b) { - /* * We do not examine typeOid, since the optimizer often doesn't bother * to set it in created nodes, and it is logically a derivative of the @@ -351,7 +350,6 @@ _equalJoinExpr(JoinExpr *a, JoinExpr *b) static bool _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b) { - /* * We treat RelOptInfos as equal if they refer to the same base rels * joined in the same order. Is this appropriate/sufficient? @@ -362,7 +360,6 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b) static bool _equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b) { - /* * We treat IndexOptInfos as equal if they refer to the same index. Is * this sufficient? @@ -515,11 +512,12 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b) return false; if (a->ispusheddown != b->ispusheddown) return false; + /* * We ignore eval_cost, this_selec, left/right_pathkey, and * left/right_bucketsize, since they may not be set yet, and should be - * derivable from the clause anyway. Probably it's not really necessary - * to compare any of these remaining fields ... + * derivable from the clause anyway. Probably it's not really + * necessary to compare any of these remaining fields ... */ if (!equal(a->subclauseindices, b->subclauseindices)) return false; @@ -622,9 +620,9 @@ _equalQuery(Query *a, Query *b) /* * We do not check the internal-to-the-planner fields: base_rel_list, - * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. - * They might not be set yet, and in any case they should be derivable - * from the other fields. + * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. They + * might not be set yet, and in any case they should be derivable from + * the other fields. */ return true; } @@ -773,7 +771,7 @@ _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b) { return equalstr(a->username, b->username) && equalstr(a->groupname, b->groupname); -} +} static bool _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b) diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 42dd9a2dab..94b18d3752 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.14 2001/03/22 03:59:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.15 2001/10/25 05:49:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,7 +70,7 @@ bool var_is_rel(Var *var) { return (bool) - !(var_is_inner(var) || var_is_outer(var)); + !(var_is_inner(var) || var_is_outer(var)); } /***************************************************************************** @@ -114,5 +114,4 @@ non_null(Expr *c) else return false; } - #endif diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 5b30fd2a21..417082b39b 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.145 2001/08/21 16:36:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.146 2001/10/25 05:49:31 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -218,7 +218,6 @@ _outQuery(StringInfo str, Query *node) if (node->utilityStmt) { - /* * Hack to make up for lack of outfuncs for utility-stmt nodes */ @@ -1271,7 +1270,7 @@ _outValue(StringInfo str, Value *value) { switch (value->type) { - case T_Integer: + case T_Integer: appendStringInfo(str, " %ld ", value->val.ival); break; case T_Float: diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 9834769562..0e33a99d53 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.48 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.49 2001/10/25 05:49:31 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -215,7 +215,7 @@ print_expr(Node *expr, List *rtable) outputstr = DatumGetCString(OidFunctionCall3(typoutput, c->constvalue, - ObjectIdGetDatum(typelem), + ObjectIdGetDatum(typelem), Int32GetDatum(-1))); printf("%s", outputstr); pfree(outputstr); @@ -322,7 +322,7 @@ plannode_type(Plan *p) { switch (nodeTag(p)) { - case T_Plan: + case T_Plan: return "PLAN"; case T_Result: return "RESULT"; diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index 14a492b476..3a09732255 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.30 2001/03/22 17:41:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.31 2001/10/25 05:49:31 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -220,17 +220,17 @@ nodeTokenType(char *token, int length) * us. We know the token will end at a character that strtol will * stop at, so we do not need to modify the string. */ - long val; - char *endptr; + long val; + char *endptr; errno = 0; val = strtol(token, &endptr, 10); if (endptr != token + length || errno == ERANGE #ifdef HAVE_LONG_INT_64 - /* if long > 32 bits, check for overflow of int4 */ + /* if long > 32 bits, check for overflow of int4 */ || val != (long) ((int32) val) #endif - ) + ) return T_Float; return T_Integer; } diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index b3e3105da6..26fbebea77 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.112 2001/07/03 16:52:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.113 2001/10/25 05:49:31 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -129,7 +129,6 @@ _readQuery(void) local_node->utilityStmt = NULL; else { - /* * Hack to make up for lack of readfuncs for utility-stmt nodes * @@ -868,8 +867,8 @@ _readCaseWhen(void) static NullTest * _readNullTest(void) { - NullTest *local_node; - char *token; + NullTest *local_node; + char *token; int length; local_node = makeNode(NullTest); @@ -893,8 +892,8 @@ _readNullTest(void) static BooleanTest * _readBooleanTest(void) { - BooleanTest *local_node; - char *token; + BooleanTest *local_node; + char *token; int length; local_node = makeNode(BooleanTest); diff --git a/src/backend/optimizer/geqo/geqo_erx.c b/src/backend/optimizer/geqo/geqo_erx.c index 576ff5daa0..748f3f31df 100644 --- a/src/backend/optimizer/geqo/geqo_erx.c +++ b/src/backend/optimizer/geqo/geqo_erx.c @@ -3,7 +3,7 @@ * geqo_erx.c * edge recombination crossover [ER] * -* $Id: geqo_erx.c,v 1.15 1999/07/16 04:59:08 momjian Exp $ +* $Id: geqo_erx.c,v 1.16 2001/10/25 05:49:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,7 +110,6 @@ gimme_edge_table(Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table) for (index1 = 0; index1 < num_gene; index1++) { - /* * presume the tour is circular, i.e. 1->2, 2->3, 3->1 this * operaton maps n back to 1 @@ -201,7 +200,6 @@ gimme_tour(Edge *edge_table, Gene *new_gene, int num_gene) for (i = 1; i < num_gene; i++) { - /* * as each point is entered into the tour, remove it from the edge * table diff --git a/src/backend/optimizer/geqo/geqo_main.c b/src/backend/optimizer/geqo/geqo_main.c index 61543985c5..496207d2a8 100644 --- a/src/backend/optimizer/geqo/geqo_main.c +++ b/src/backend/optimizer/geqo/geqo_main.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_main.c,v 1.28 2001/06/03 14:53:56 petere Exp $ + * $Id: geqo_main.c,v 1.29 2001/10/25 05:49:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,16 +82,13 @@ geqo(Query *root, int number_of_rels, List *initial_rels) Edge *edge_table; /* list of edges */ int edge_failures = 0; float difference; - #endif #if defined(CX) || defined(PX) || defined(OX1) || defined(OX2) City *city_table; /* list of cities */ - #endif #if defined(CX) int cycle_diffs = 0; int mutations = 0; - #endif /* set GA parameters */ diff --git a/src/backend/optimizer/path/_deadcode/predmig.c b/src/backend/optimizer/path/_deadcode/predmig.c index 462f1dc24e..604de4b273 100644 --- a/src/backend/optimizer/path/_deadcode/predmig.c +++ b/src/backend/optimizer/path/_deadcode/predmig.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.10 2001/03/22 06:16:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.11 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -244,7 +244,6 @@ xfunc_llel_chains(Stream root, Stream bottom) if (is_clause(tmpstream) && get_pathptr(pathstream) != get_pathptr(tmpstream)) { - /* * * If restriction moved above a Join after sort, we pull it * * up in the join plan. * If restriction moved down, we @@ -470,7 +469,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom) get_groupup((Stream) get_downstream(temp))) && get_grouprank(parent) < get_grouprank(temp)) { - progress = true;/* we formed a new group */ + progress = true; /* we formed a new group */ set_groupup(temp, true); set_groupcost(temp, get_groupcost(temp) + @@ -485,7 +484,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom) } -/* ------------------- UTILITY FUNCTIONS ------------------------- */ +/* ------------------- UTILITY FUNCTIONS ------------------------- */ /* ** xfunc_free_stream diff --git a/src/backend/optimizer/path/_deadcode/xfunc.c b/src/backend/optimizer/path/_deadcode/xfunc.c index 82258d7baf..07866a9e4d 100644 --- a/src/backend/optimizer/path/_deadcode/xfunc.c +++ b/src/backend/optimizer/path/_deadcode/xfunc.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.16 2001/03/22 06:16:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.17 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -237,7 +237,6 @@ xfunc_shouldpull(Query *queryInfo, } else if (maxrank != -(MAXFLOAT)) { - /* * * we've left an expensive restriction below a join. Since * * we may pullup this restriction in predmig.c, we'd best * @@ -656,7 +655,6 @@ xfunc_width(LispValue clause) } else if (IsA(clause, Iter)) { - /* * * An Iter returns a setof things, so return the width of a * single * thing. * Note: THIS MAY NOT WORK RIGHT WHEN AGGS GET @@ -668,7 +666,6 @@ xfunc_width(LispValue clause) } else if (fast_is_clause(clause)) { - /* * * get function associated with this Oper, and treat this as * a * Func @@ -689,7 +686,6 @@ xfunc_width(LispValue clause) if (get_func_tlist(func) != LispNil) { - /* * this function has a projection on it. Get the length of * the projected attribute @@ -1150,7 +1146,6 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */ tle = tlistentry_member((Var) clause, get_targetlist(rel)); if (tle == LispNil) { - /* * * The attribute we need is not in the target list, * so we * have to add it. * diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index ebc303d465..15f29847d3 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.79 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.80 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,10 +38,10 @@ static void set_base_rel_pathlists(Query *root); static void set_plain_rel_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte); static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel, - Index rti, RangeTblEntry *rte, - List *inheritlist); + Index rti, RangeTblEntry *rte, + List *inheritlist); static void set_subquery_pathlist(Query *root, RelOptInfo *rel, - Index rti, RangeTblEntry *rte); + Index rti, RangeTblEntry *rte); static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels); @@ -160,7 +160,7 @@ set_plain_rel_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte) * Build access paths for a inheritance tree rooted at rel * * inheritlist is a list of RT indexes of all tables in the inheritance tree, - * including a duplicate of the parent itself. Note we will not come here + * including a duplicate of the parent itself. Note we will not come here * unless there's at least one child in addition to the parent. * * NOTE: the passed-in rel and RTE will henceforth represent the appended @@ -192,9 +192,9 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel, elog(ERROR, "SELECT FOR UPDATE is not supported for inherit queries"); /* - * The executor will check the parent table's access permissions when it - * examines the parent's inheritlist entry. There's no need to check - * twice, so turn off access check bits in the original RTE. + * The executor will check the parent table's access permissions when + * it examines the parent's inheritlist entry. There's no need to + * check twice, so turn off access check bits in the original RTE. */ rte->checkForRead = false; rte->checkForWrite = false; @@ -230,8 +230,8 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel, /* * Copy the parent's targetlist and restriction quals to the * child, with attribute-number adjustment as needed. We don't - * bother to copy the join quals, since we can't do any joining - * of the individual tables. + * bother to copy the join quals, since we can't do any joining of + * the individual tables. */ childrel->targetlist = (List *) adjust_inherited_attrs((Node *) rel->targetlist, @@ -282,32 +282,32 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel, /* * If there are any restriction clauses that have been attached to the - * subquery relation, consider pushing them down to become HAVING quals - * of the subquery itself. (Not WHERE clauses, since they may refer to - * subquery outputs that are aggregate results. But planner.c will - * transfer them into the subquery's WHERE if they do not.) This - * transformation is useful because it may allow us to generate a better - * plan for the subquery than evaluating all the subquery output rows - * and then filtering them. + * subquery relation, consider pushing them down to become HAVING + * quals of the subquery itself. (Not WHERE clauses, since they may + * refer to subquery outputs that are aggregate results. But + * planner.c will transfer them into the subquery's WHERE if they do + * not.) This transformation is useful because it may allow us to + * generate a better plan for the subquery than evaluating all the + * subquery output rows and then filtering them. * * There are several cases where we cannot push down clauses: * * 1. If the subquery contains set ops (UNION/INTERSECT/EXCEPT) we do not - * push down any qual clauses, since the planner doesn't support quals at - * the top level of a setop. (With suitable analysis we could try to push - * the quals down into the component queries of the setop, but getting it - * right seems nontrivial. Work on this later.) + * push down any qual clauses, since the planner doesn't support quals + * at the top level of a setop. (With suitable analysis we could try + * to push the quals down into the component queries of the setop, but + * getting it right seems nontrivial. Work on this later.) * * 2. If the subquery has a LIMIT clause or a DISTINCT ON clause, we must * not push down any quals, since that could change the set of rows * returned. (Actually, we could push down quals into a DISTINCT ON - * subquery if they refer only to DISTINCT-ed output columns, but checking - * that seems more work than it's worth. In any case, a plain DISTINCT is - * safe to push down past.) + * subquery if they refer only to DISTINCT-ed output columns, but + * checking that seems more work than it's worth. In any case, a + * plain DISTINCT is safe to push down past.) * * 3. 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). + * 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. @@ -337,22 +337,23 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel, else { /* - * We need to replace Vars in the clause (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 clause should have been replaced with - * Params, so they need no work. + * We need to replace Vars in the clause (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 clause should have been + * replaced with Params, so they need no work. */ clause = ResolveNew(clause, rti, 0, subquery->targetList, CMD_SELECT, 0); subquery->havingQual = make_and_qual(subquery->havingQual, clause); + /* * 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. + * 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. */ } } @@ -412,7 +413,6 @@ make_fromexpr_rel(Query *root, FromExpr *from) if (levels_needed == 1) { - /* * Single jointree node, so we're done. */ @@ -420,7 +420,6 @@ make_fromexpr_rel(Query *root, FromExpr *from) } else { - /* * Consider the different orders in which we could join the rels, * using either GEQO or regular optimizer. @@ -552,7 +551,7 @@ print_restrictclauses(Query *root, List *clauses) static void print_path(Query *root, Path *path, int indent) { - const char *ptype; + const char *ptype; bool join; int i; @@ -650,7 +649,7 @@ debug_print_rel(Query *root, RelOptInfo *rel) foreach(l, rel->joininfo) { - JoinInfo *j = (JoinInfo *) lfirst(l); + JoinInfo *j = (JoinInfo *) lfirst(l); printf("\tjoininfo ("); print_relids(j->unjoined_relids); @@ -669,5 +668,4 @@ debug_print_rel(Query *root, RelOptInfo *rel) printf("\n"); fflush(stdout); } - #endif /* OPTIMIZER_DEBUG */ diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index 36d8f229f1..fc509c4d94 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.46 2001/06/25 21:11:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.47 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ typedef struct RangeQueryClause } RangeQueryClause; static void addRangeClause(RangeQueryClause **rqlist, Node *clause, - bool varonleft, bool isLTsel, Selectivity s2); + bool varonleft, bool isLTsel, Selectivity s2); /**************************************************************************** @@ -212,7 +212,6 @@ clauselist_selectivity(Query *root, { if (s2 < -0.01) { - /* * No data available --- use a default estimate that * is small, but not real small. @@ -221,7 +220,6 @@ clauselist_selectivity(Query *root, } else { - /* * It's just roundoff error; use a small positive * value @@ -275,7 +273,6 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause, for (rqelem = *rqlist; rqelem; rqelem = rqelem->next) { - /* * We use full equal() here because the "var" might be a function * of one or more attributes of the same relation... @@ -386,7 +383,6 @@ clause_selectivity(Query *root, if (rte->subquery) { - /* * XXX not smart about subquery references... any way to * do better? @@ -395,7 +391,6 @@ clause_selectivity(Query *root, } else { - /* * A Var at the top of a clause must be a bool Var. This * is equivalent to the clause reln.attribute = 't', so we @@ -405,7 +400,7 @@ clause_selectivity(Query *root, BooleanEqualOperator, makeList2(var, MAKEBOOLCONST(true, - false)), + false)), varRelid); } } @@ -436,7 +431,6 @@ clause_selectivity(Query *root, } else if (or_clause(clause)) { - /* * Selectivities for an 'or' clause are computed as s1+s2 - s1*s2 * to account for the probable overlap of selected tuple sets. XXX @@ -461,7 +455,6 @@ clause_selectivity(Query *root, if (varRelid != 0) { - /* * If we are considering a nestloop join then all clauses are * restriction clauses, since we are only interested in the @@ -471,7 +464,6 @@ clause_selectivity(Query *root, } else { - /* * Otherwise, it's a join if there's more than one relation * used. @@ -482,19 +474,18 @@ clause_selectivity(Query *root, if (is_join_clause) { /* Estimate selectivity for a join clause. */ - s1 = join_selectivity(root, opno, + s1 = join_selectivity(root, opno, ((Expr *) clause)->args); } else { /* Estimate selectivity for a restriction clause. */ - s1 = restriction_selectivity(root, opno, - ((Expr *) clause)->args, varRelid); + s1 = restriction_selectivity(root, opno, + ((Expr *) clause)->args, varRelid); } } else if (is_funcclause(clause)) { - /* * This is not an operator, so we guess at the selectivity. THIS * IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE @@ -504,7 +495,6 @@ clause_selectivity(Query *root, } else if (is_subplan(clause)) { - /* * Just for the moment! FIX ME! - vadim 02/04/98 */ diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 73d72a03cb..4cfddf9e6c 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.78 2001/08/21 16:36:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.79 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -271,10 +271,10 @@ cost_index(Path *path, Query *root, * * When the index ordering is exactly correlated with the table ordering * (just after a CLUSTER, for example), the number of pages fetched should - * be just sT. What's more, these will be sequential fetches, not the - * random fetches that occur in the uncorrelated case. So, depending on + * be just sT. What's more, these will be sequential fetches, not the + * random fetches that occur in the uncorrelated case. So, depending on * the extent of correlation, we should estimate the actual I/O cost - * somewhere between s * T * 1.0 and PF * random_cost. We currently + * somewhere between s * T * 1.0 and PF * random_cost. We currently * interpolate linearly between these two endpoints based on the * correlation squared (XXX is that appropriate?). * @@ -301,7 +301,7 @@ cost_index(Path *path, Query *root, } else { - double lim; + double lim; lim = (2.0 * T * b) / (2.0 * T - b); if (tuples_fetched <= lim) @@ -317,18 +317,19 @@ cost_index(Path *path, Query *root, } /* - * min_IO_cost corresponds to the perfectly correlated case (csquared=1), - * max_IO_cost to the perfectly uncorrelated case (csquared=0). Note - * that we just charge random_page_cost per page in the uncorrelated - * case, rather than using cost_nonsequential_access, since we've already - * accounted for caching effects by using the Mackert model. + * min_IO_cost corresponds to the perfectly correlated case + * (csquared=1), max_IO_cost to the perfectly uncorrelated case + * (csquared=0). Note that we just charge random_page_cost per page + * in the uncorrelated case, rather than using + * cost_nonsequential_access, since we've already accounted for + * caching effects by using the Mackert model. */ min_IO_cost = ceil(indexSelectivity * T); max_IO_cost = pages_fetched * random_page_cost; /* - * Now interpolate based on estimated index order correlation - * to get total disk I/O cost for main table accesses. + * Now interpolate based on estimated index order correlation to get + * total disk I/O cost for main table accesses. */ csquared = indexCorrelation * indexCorrelation; @@ -337,14 +338,14 @@ cost_index(Path *path, Query *root, /* * Estimate CPU costs per tuple. * - * Normally the indexquals will be removed from the list of - * restriction clauses that we have to evaluate as qpquals, so we - * should subtract their costs from baserestrictcost. XXX For a lossy - * index, not all the quals will be removed and so we really shouldn't - * subtract their costs; but detecting that seems more expensive than - * it's worth. Also, if we are doing a join then some of the indexquals - * are join clauses and shouldn't be subtracted. Rather than work out - * exactly how much to subtract, we don't subtract anything. + * Normally the indexquals will be removed from the list of restriction + * clauses that we have to evaluate as qpquals, so we should subtract + * their costs from baserestrictcost. XXX For a lossy index, not all + * the quals will be removed and so we really shouldn't subtract their + * costs; but detecting that seems more expensive than it's worth. + * Also, if we are doing a join then some of the indexquals are join + * clauses and shouldn't be subtracted. Rather than work out exactly + * how much to subtract, we don't subtract anything. */ cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost; @@ -501,11 +502,11 @@ cost_nestloop(Path *path, Query *root, /* * NOTE: clearly, we must pay both outer and inner paths' startup_cost - * before we can start returning tuples, so the join's startup cost - * is their sum. What's not so clear is whether the inner path's + * before we can start returning tuples, so the join's startup cost is + * their sum. What's not so clear is whether the inner path's * startup_cost must be paid again on each rescan of the inner path. - * This is not true if the inner path is materialized, but probably - * is true otherwise. Since we don't yet have clean handling of the + * This is not true if the inner path is materialized, but probably is + * true otherwise. Since we don't yet have clean handling of the * decision whether to materialize a path, we can't tell here which * will happen. As a compromise, charge 50% of the inner startup cost * for each restart. @@ -615,9 +616,9 @@ 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. 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. 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_path->parent->rows + inner_path->parent->rows); @@ -625,7 +626,7 @@ cost_mergejoin(Path *path, Query *root, /* * For each tuple that gets through the mergejoin proper, we charge * cpu_tuple_cost plus the cost of evaluating additional restriction - * clauses that are to be applied at the join. It's OK to use an + * clauses that are to be applied at the join. It's OK to use an * approximate selectivity here, since in most cases this is a minor * component of the cost. */ @@ -685,8 +686,8 @@ cost_hashjoin(Path *path, Query *root, run_cost += cpu_operator_cost * outer_path->parent->rows; /* - * Determine bucketsize fraction for inner relation. First we have - * to figure out which side of the hashjoin clause is the inner side. + * Determine bucketsize fraction for inner relation. First we have to + * figure out which side of the hashjoin clause is the inner side. */ Assert(length(hashclauses) == 1); Assert(IsA(lfirst(hashclauses), RestrictInfo)); @@ -696,9 +697,9 @@ cost_hashjoin(Path *path, Query *root, right = get_rightop(restrictinfo->clause); /* - * Since we tend to visit the same clauses over and over when - * planning a large query, we cache the bucketsize estimate in - * the RestrictInfo node to avoid repeated lookups of statistics. + * Since we tend to visit the same clauses over and over when planning + * a large query, we cache the bucketsize estimate in the RestrictInfo + * node to avoid repeated lookups of statistics. */ if (intMember(right->varno, inner_path->parent->relids)) { @@ -726,9 +727,9 @@ cost_hashjoin(Path *path, Query *root, /* * The number of tuple comparisons needed is the number of outer - * tuples times the typical number of tuples in a hash bucket, - * which is the inner relation size times its bucketsize fraction. - * We charge one cpu_operator_cost per tuple comparison. + * tuples times the typical number of tuples in a hash bucket, which + * is the inner relation size times its bucketsize fraction. We charge + * one cpu_operator_cost per tuple comparison. */ run_cost += cpu_operator_cost * outer_path->parent->rows * ceil(inner_path->parent->rows * innerbucketsize); @@ -736,7 +737,7 @@ cost_hashjoin(Path *path, Query *root, /* * For each tuple that gets through the hashjoin proper, we charge * cpu_tuple_cost plus the cost of evaluating additional restriction - * clauses that are to be applied at the join. It's OK to use an + * clauses that are to be applied at the join. It's OK to use an * approximate selectivity here, since in most cases this is a minor * component of the cost. */ @@ -792,11 +793,11 @@ cost_hashjoin(Path *path, Query *root, * distribution, so this will have to do for now. * * We can get the number of buckets the executor will use for the given - * input relation. If the data were perfectly distributed, with the same + * input relation. If the data were perfectly distributed, with the same * number of tuples going into each available bucket, then the bucketsize * fraction would be 1/nbuckets. But this happy state of affairs will occur * only if (a) there are at least nbuckets distinct data values, and (b) - * we have a not-too-skewed data distribution. Otherwise the buckets will + * we have a not-too-skewed data distribution. Otherwise the buckets will * be nonuniformly occupied. If the other relation in the join has a key * distribution similar to this one's, then the most-loaded buckets are * exactly those that will be probed most often. Therefore, the "average" @@ -828,8 +829,8 @@ estimate_hash_bucketsize(Query *root, Var *var) int nnumbers; /* - * Lookup info about var's relation and attribute; - * if none available, return default estimate. + * Lookup info about var's relation and attribute; if none available, + * return default estimate. */ if (!IsA(var, Var)) return 0.1; @@ -891,12 +892,13 @@ estimate_hash_bucketsize(Query *root, Var *var) avgfreq = (1.0 - stats->stanullfrac) / ndistinct; /* - * Adjust ndistinct to account for restriction clauses. Observe we are - * assuming that the data distribution is affected uniformly by the - * restriction clauses! + * Adjust ndistinct to account for restriction clauses. Observe we + * are assuming that the data distribution is affected uniformly by + * the restriction clauses! * * XXX Possibly better way, but much more expensive: multiply by - * selectivity of rel's restriction clauses that mention the target Var. + * selectivity of rel's restriction clauses that mention the target + * Var. */ ndistinct *= rel->rows / rel->tuples; @@ -929,7 +931,8 @@ estimate_hash_bucketsize(Query *root, Var *var) } /* - * Adjust estimated bucketsize upward to account for skewed distribution. + * Adjust estimated bucketsize upward to account for skewed + * distribution. */ if (avgfreq > 0.0 && mcvfreq > avgfreq) estfract *= mcvfreq / avgfreq; @@ -1084,19 +1087,20 @@ cost_qual_eval_walker(Node *node, Cost *total) static Selectivity approx_selectivity(Query *root, List *quals) { - Selectivity total = 1.0; + Selectivity total = 1.0; List *l; foreach(l, quals) { Node *qual = (Node *) lfirst(l); - Selectivity selec; + Selectivity selec; /* * RestrictInfo nodes contain a this_selec field reserved for this * routine's use, so that it's not necessary to evaluate the qual - * clause's selectivity more than once. If the clause's selectivity - * hasn't been computed yet, the field will contain -1. + * clause's selectivity more than once. If the clause's + * selectivity hasn't been computed yet, the field will contain + * -1. */ if (qual && IsA(qual, RestrictInfo)) { @@ -1254,7 +1258,7 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel, * NB: this works best on base relations because it prefers to look at * real Vars. It will fail to make use of pg_statistic info when applied * to a subquery relation, even if the subquery outputs are simple vars - * that we could have gotten info for. Is it worth trying to be smarter + * that we could have gotten info for. Is it worth trying to be smarter * about subqueries? */ static void @@ -1266,15 +1270,15 @@ set_rel_width(Query *root, RelOptInfo *rel) foreach(tllist, rel->targetlist) { TargetEntry *tle = (TargetEntry *) lfirst(tllist); - int32 item_width; + int32 item_width; /* * If it's a Var, try to get statistical info from pg_statistic. */ if (tle->expr && IsA(tle->expr, Var)) { - Var *var = (Var *) tle->expr; - Oid relid; + Var *var = (Var *) tle->expr; + Oid relid; relid = getrelid(var->varno, root->rtable); if (relid != InvalidOid) @@ -1287,6 +1291,7 @@ set_rel_width(Query *root, RelOptInfo *rel) } } } + /* * Not a Var, or can't find statistics for it. Estimate using * just the type info. diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index f30097ec28..71e6c3faf5 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.111 2001/08/21 16:36:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.112 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -288,7 +288,6 @@ match_index_orclauses(RelOptInfo *rel, if (restriction_is_or_clause(restrictinfo)) { - /* * Add this index to the subclause index list for each * subclause that it matches. @@ -444,9 +443,10 @@ extract_or_indexqual_conditions(RelOptInfo *rel, Oid *classes = index->classlist; /* - * Extract relevant indexclauses in indexkey order. This is essentially - * just like group_clauses_by_indexkey() except that the input and - * output are lists of bare clauses, not of RestrictInfo nodes. + * Extract relevant indexclauses in indexkey order. This is + * essentially just like group_clauses_by_indexkey() except that the + * input and output are lists of bare clauses, not of RestrictInfo + * nodes. */ do { @@ -459,7 +459,7 @@ extract_or_indexqual_conditions(RelOptInfo *rel, { foreach(item, orsubclause->args) { - Expr *subsubclause = (Expr *) lfirst(item); + Expr *subsubclause = (Expr *) lfirst(item); if (match_clause_to_indexkey(rel, index, curIndxKey, curClass, @@ -470,9 +470,7 @@ extract_or_indexqual_conditions(RelOptInfo *rel, else if (match_clause_to_indexkey(rel, index, curIndxKey, curClass, orsubclause, false)) - { clausegroup = makeList1(orsubclause); - } /* * If we found no clauses for this indexkey in the OR subclause @@ -492,8 +490,8 @@ extract_or_indexqual_conditions(RelOptInfo *rel, } /* - * If still no clauses match this key, we're done; we don't want to - * look at keys to its right. + * If still no clauses match this key, we're done; we don't want + * to look at keys to its right. */ if (clausegroup == NIL) break; @@ -744,7 +742,6 @@ match_clause_to_indexkey(RelOptInfo *rel, if (!join) { - /* * Not considering joins, so check for clauses of the form: * (indexkey operator constant) or (constant operator indexkey). @@ -782,7 +779,6 @@ match_clause_to_indexkey(RelOptInfo *rel, } else { - /* * Check for an indexqual that could be handled by a nestloop * join. We need the index key to be compared against an @@ -921,7 +917,6 @@ indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left) { if (new_op != expr_op) { - /* * OK, we found a binary-compatible operator of the same name; * now does it match the index? @@ -1144,7 +1139,7 @@ static const StrategyNumber * and a "simple clause" restriction. * * We have two strategies for determining whether one simple clause - * implies another. A simple and general way is to see if they are + * implies another. A simple and general way is to see if they are * equal(); this works for any kind of expression. (Actually, there * is an implied assumption that the functions in the expression are * cachable, ie dependent only on their input arguments --- but this @@ -1187,8 +1182,8 @@ pred_test_simple_clause(Expr *predicate, Node *clause) return true; /* - * Can't do anything more unless they are both binary opclauses with - * a Var on the left and a Const on the right. + * Can't do anything more unless they are both binary opclauses with a + * Var on the left and a Const on the right. */ if (!is_opclause((Node *) predicate)) return false; @@ -1223,8 +1218,8 @@ pred_test_simple_clause(Expr *predicate, Node *clause) /* * 1. Find a "btree" strategy number for the pred_op * - * The following assumes that any given operator will only be in a - * single btree operator class. This is true at least for all the + * The following assumes that any given operator will only be in a single + * btree operator class. This is true at least for all the * pre-defined operator classes. If it isn't true, then whichever * operator class happens to be returned first for the given operator * will be used to find the associated strategy numbers for the test. @@ -1237,7 +1232,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause) relation = heap_openr(AccessMethodOperatorRelationName, AccessShareLock); scan = heap_beginscan(relation, false, SnapshotNow, 1, entry); - + while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) { aform = (Form_pg_amop) GETSTRUCT(tuple); @@ -1246,7 +1241,11 @@ pred_test_simple_clause(Expr *predicate, Node *clause) /* Get the predicate operator's btree strategy number (1 to 5) */ pred_strategy = (StrategyNumber) aform->amopstrategy; Assert(pred_strategy >= 1 && pred_strategy <= 5); - /* Remember which operator class this strategy number came from */ + + /* + * Remember which operator class this strategy number came + * from + */ opclass_id = aform->amopclaid; break; } @@ -1457,8 +1456,8 @@ index_innerjoin(Query *root, RelOptInfo *rel, IndexOptInfo *index, /* * Note that we are making a pathnode for a single-scan indexscan; - * therefore, both indexinfo and indexqual should be single-element - * lists. + * therefore, both indexinfo and indexqual should be + * single-element lists. */ pathnode->indexinfo = makeList1(index); pathnode->indexqual = makeList1(indexquals); @@ -1516,7 +1515,6 @@ match_index_to_operand(int indexkey, RelOptInfo *rel, IndexOptInfo *index) { - /* * Ignore any RelabelType node above the indexkey. This is needed to * be able to apply indexscanning in binary-compatible-operator cases. @@ -1528,7 +1526,6 @@ match_index_to_operand(int indexkey, if (index->indproc == InvalidOid) { - /* * Simple index. */ @@ -1860,7 +1857,6 @@ expand_indexqual_conditions(List *indexquals) switch (expr_op) { - /* * LIKE and regex operators are not members of any index * opclass, so if we find one in an indexqual list we can @@ -2065,17 +2061,17 @@ prefix_quals(Var *leftop, Oid expr_op, /* * Given a leftop and a rightop, and a inet-class sup/sub operator, * generate suitable indexqual condition(s). expr_op is the original - * operator. + * operator. */ static List * network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop) { - bool is_eq; - char *opr1name; - Datum opr1right; - Datum opr2right; - Oid opr1oid; - Oid opr2oid; + bool is_eq; + char *opr1name; + Datum opr1right; + Datum opr2right; + Oid opr1oid; + Oid opr2oid; List *result; Oid datatype; Oper *op; @@ -2084,30 +2080,30 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop) switch (expr_op) { case OID_INET_SUB_OP: - datatype = INETOID; - is_eq = false; + datatype = INETOID; + is_eq = false; break; case OID_INET_SUBEQ_OP: - datatype = INETOID; - is_eq = true; + datatype = INETOID; + is_eq = true; break; case OID_CIDR_SUB_OP: - datatype = CIDROID; - is_eq = false; + datatype = CIDROID; + is_eq = false; break; case OID_CIDR_SUBEQ_OP: - datatype = CIDROID; - is_eq = true; + datatype = CIDROID; + is_eq = true; break; default: elog(ERROR, "network_prefix_quals: unexpected operator %u", expr_op); return NIL; - } + } /* - * create clause "key >= network_scan_first( rightop )", or ">" - * if the operator disallows equality. + * create clause "key >= network_scan_first( rightop )", or ">" if the + * operator disallows equality. */ opr1name = is_eq ? ">=" : ">"; @@ -2116,11 +2112,11 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop) elog(ERROR, "network_prefix_quals: no %s operator for type %u", opr1name, datatype); - opr1right = network_scan_first( rightop ); + opr1right = network_scan_first(rightop); op = makeOper(opr1oid, InvalidOid, BOOLOID); - expr = make_opclause(op, leftop, - (Var *) makeConst(datatype, -1, opr1right, + expr = make_opclause(op, leftop, + (Var *) makeConst(datatype, -1, opr1right, false, false, false, false)); result = makeList1(expr); @@ -2131,11 +2127,11 @@ network_prefix_quals(Var *leftop, Oid expr_op, Datum rightop) elog(ERROR, "network_prefix_quals: no <= operator for type %u", datatype); - opr2right = network_scan_last( rightop ); + opr2right = network_scan_last(rightop); op = makeOper(opr2oid, InvalidOid, BOOLOID); - expr = make_opclause(op, leftop, - (Var *) makeConst(datatype, -1, opr2right, + expr = make_opclause(op, leftop, + (Var *) makeConst(datatype, -1, opr2right, false, false, false, false)); result = lappend(result, expr); diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 5a0734224f..15bb56757d 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.65 2001/06/05 05:26:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.66 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,6 @@ static void match_unsorted_inner(Query *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, List *restrictlist, List *mergeclause_list, JoinType jointype); - #endif static void hash_inner_and_outer(Query *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, @@ -297,9 +296,9 @@ match_unsorted_outer(Query *root, /* * Nestloop only supports inner and left joins. Also, if we are doing * a right or full join, we must use *all* the mergeclauses as join - * clauses, else we will not have a valid plan. (Although these two flags - * are currently inverses, keep them separate for clarity and possible - * future changes.) + * clauses, else we will not have a valid plan. (Although these two + * flags are currently inverses, keep them separate for clarity and + * possible future changes.) */ switch (jointype) { @@ -316,7 +315,7 @@ match_unsorted_outer(Query *root, default: elog(ERROR, "match_unsorted_outer: unexpected join type %d", (int) jointype); - nestjoinOK = false; /* keep compiler quiet */ + nestjoinOK = false; /* keep compiler quiet */ useallclauses = false; break; } @@ -350,12 +349,11 @@ match_unsorted_outer(Query *root, if (nestjoinOK) { - /* * Always consider a nestloop join with this outer and * cheapest-total-cost inner. Consider nestloops using the - * cheapest-startup-cost inner as well, and the best - * innerjoin indexpath. + * cheapest-startup-cost inner as well, and the best innerjoin + * indexpath. */ add_path(joinrel, (Path *) create_nestloop_path(root, @@ -494,7 +492,6 @@ match_unsorted_outer(Query *root, /* Found a cheap (or even-cheaper) sorted path */ if (innerpath != cheapest_total_inner) { - /* * Avoid rebuilding clause list if we already made * one; saves memory in big join trees... @@ -526,6 +523,7 @@ match_unsorted_outer(Query *root, } cheapest_startup_inner = innerpath; } + /* * Don't consider truncated sortkeys if we need all clauses. */ @@ -576,7 +574,7 @@ match_unsorted_inner(Query *root, default: elog(ERROR, "match_unsorted_inner: unexpected join type %d", (int) jointype); - useallclauses = false; /* keep compiler quiet */ + useallclauses = false; /* keep compiler quiet */ break; } @@ -673,7 +671,6 @@ match_unsorted_inner(Query *root, } } } - #endif /* diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 8c805e0e3e..745a1eb0b5 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.54 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.55 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels) if (old_rel->joininfo != NIL) { - /* * Note that if all available join clauses for this rel * require more than one other rel, we will fail to make any @@ -84,7 +83,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels) } else { - /* * Oops, we have a relation that is not joined to any other * relation. Cartesian product time. @@ -195,7 +193,6 @@ make_rels_by_joins(Query *root, int level, List **joinrels) */ if (result_rels == NIL) { - /* * This loop is just like the first one, except we always call * make_rels_by_clauseless_joins(). diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index 889a3afee1..b713dc8ad8 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.44 2001/06/05 17:13:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.45 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,7 +175,7 @@ best_or_subclause_indices(Query *root, pathnode->indexinfo = lappend(pathnode->indexinfo, best_indexinfo); pathnode->indexqual = lappend(pathnode->indexqual, best_indexqual); - if (slist == subclauses) /* first scan? */ + if (slist == subclauses)/* first scan? */ pathnode->path.startup_cost = best_startup_cost; pathnode->path.total_cost += best_total_cost; @@ -202,7 +202,7 @@ best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclause, List *indices, - IndexOptInfo **retIndexInfo, /* return value */ + IndexOptInfo **retIndexInfo, /* return value */ List **retIndexQual, /* return value */ Cost *retStartupCost, /* return value */ Cost *retTotalCost) /* return value */ diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 9e964290e6..c7e13f2850 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.33 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.34 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,7 +109,6 @@ add_equijoined_keys(Query *root, RestrictInfo *restrictinfo) if (item1here || item2here) { - /* * If find both in same equivalence set, no need to do any * more @@ -318,7 +317,7 @@ compare_pathkeys(List *keys1, List *keys2) if (key1 == NIL && key2 == NIL) return PATHKEYS_EQUAL; if (key1 != NIL) - return PATHKEYS_BETTER1;/* key1 is longer */ + return PATHKEYS_BETTER1; /* key1 is longer */ return PATHKEYS_BETTER2; /* key2 is longer */ } @@ -368,7 +367,7 @@ compare_noncanonical_pathkeys(List *keys1, List *keys2) if (key1 == NIL && key2 == NIL) return PATHKEYS_EQUAL; if (key1 != NIL) - return PATHKEYS_BETTER1;/* key1 is longer */ + return PATHKEYS_BETTER1; /* key1 is longer */ return PATHKEYS_BETTER2; /* key2 is longer */ } @@ -382,8 +381,8 @@ pathkeys_contained_in(List *keys1, List *keys2) { switch (compare_pathkeys(keys1, keys2)) { - case PATHKEYS_EQUAL: - case PATHKEYS_BETTER2: + case PATHKEYS_EQUAL: + case PATHKEYS_BETTER2: return true; default: break; @@ -400,8 +399,8 @@ noncanonical_pathkeys_contained_in(List *keys1, List *keys2) { switch (compare_noncanonical_pathkeys(keys1, keys2)) { - case PATHKEYS_EQUAL: - case PATHKEYS_BETTER2: + case PATHKEYS_EQUAL: + case PATHKEYS_BETTER2: return true; default: break; @@ -632,7 +631,6 @@ build_join_pathkeys(Query *root, RelOptInfo *joinrel, List *outer_pathkeys) { - /* * This used to be quite a complex bit of code, but now that all * pathkey sublists start out life canonicalized, we don't have to do diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 8756fcc020..30ddd8437c 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.109 2001/09/21 04:06:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.110 2001/10/25 05:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,14 +57,14 @@ static HashJoin *create_hashjoin_plan(HashPath *best_path, List *tlist, Plan *outer_plan, List *outer_tlist, Plan *inner_plan, List *inner_tlist); static void fix_indxqual_references(List *indexquals, IndexPath *index_path, - List **fixed_indexquals, - List **recheck_indexquals); + List **fixed_indexquals, + List **recheck_indexquals); static void fix_indxqual_sublist(List *indexqual, int baserelid, - IndexOptInfo *index, - List **fixed_quals, List **recheck_quals); + IndexOptInfo *index, + List **fixed_quals, List **recheck_quals); static Node *fix_indxqual_operand(Node *node, int baserelid, - IndexOptInfo *index, - Oid *opclass); + IndexOptInfo *index, + Oid *opclass); static List *switch_outer(List *clauses); static void copy_path_costsize(Plan *dest, Path *src); static void copy_plan_costsize(Plan *dest, Plan *src); @@ -410,9 +410,9 @@ create_indexscan_plan(Query *root, /* * The qpqual list must contain all restrictions not automatically - * handled by the index. Normally the predicates in the indxqual - * are checked fully by the index, but if the index is "lossy" for - * a particular operator (as signaled by the amopreqcheck flag in + * handled by the index. Normally the predicates in the indxqual are + * checked fully by the index, but if the index is "lossy" for a + * particular operator (as signaled by the amopreqcheck flag in * pg_amop), then we need to double-check that predicate in qpqual, * because the index may return more tuples than match the predicate. * @@ -453,19 +453,19 @@ create_indexscan_plan(Query *root, /* * The executor needs a copy with the indexkey on the left of each - * clause and with index attr numbers substituted for table ones. - * This pass also looks for "lossy" operators. + * clause and with index attr numbers substituted for table ones. This + * pass also looks for "lossy" operators. */ fix_indxqual_references(indxqual, best_path, &fixed_indxqual, &recheck_indxqual); /* - * If there were any "lossy" operators, need to add back the appropriate - * qual clauses to the qpqual. When there is just one indexscan being - * performed (ie, we have simple AND semantics), we can just add the - * lossy clauses themselves to qpqual. If we have OR-of-ANDs, we'd - * better add the entire original indexqual to make sure that the - * semantics are correct. + * If there were any "lossy" operators, need to add back the + * appropriate qual clauses to the qpqual. When there is just one + * indexscan being performed (ie, we have simple AND semantics), we + * can just add the lossy clauses themselves to qpqual. If we have + * OR-of-ANDs, we'd better add the entire original indexqual to make + * sure that the semantics are correct. */ if (recheck_indxqual != NIL) { @@ -589,7 +589,6 @@ create_nestloop_plan(NestPath *best_path, if (IsA(inner_plan, IndexScan)) { - /* * An index is being used to reduce the number of tuples scanned * in the inner relation. If there are join clauses being used @@ -657,7 +656,6 @@ create_nestloop_plan(NestPath *best_path, } else if (IsA_Join(inner_plan)) { - /* * Materialize the inner join for speed reasons. * @@ -900,7 +898,7 @@ create_hashjoin_plan(HashPath *best_path, * left. (Someday the executor might not need this, but for now it does.) * * If the indexable operator is marked 'amopreqcheck' in pg_amop, then * the index is "lossy" for this operator: it may return more tuples than - * actually satisfy the operator condition. For each such operator, we + * actually satisfy the operator condition. For each such operator, we * must add (the original form of) the indexqual clause to the "qpquals" * of the indexscan node, where the operator will be re-evaluated to * ensure it passes. @@ -922,7 +920,7 @@ create_hashjoin_plan(HashPath *best_path, */ static void fix_indxqual_references(List *indexquals, IndexPath *index_path, - List **fixed_indexquals, List **recheck_indexquals) + List **fixed_indexquals, List **recheck_indexquals) { List *fixed_quals = NIL; List *recheck_quals = NIL; @@ -992,7 +990,7 @@ fix_indxqual_sublist(List *indexqual, int baserelid, IndexOptInfo *index, /* * Check to see if the indexkey is on the right; if so, commute - * the clause. The indexkey should be the side that refers to + * the clause. The indexkey should be the side that refers to * (only) the base relation. */ leftvarnos = pull_varnos((Node *) lfirst(newclause->args)); @@ -1022,8 +1020,8 @@ fix_indxqual_sublist(List *indexqual, int baserelid, IndexOptInfo *index, fixed_qual = lappend(fixed_qual, newclause); /* - * Finally, check to see if index is lossy for this operator. - * If so, add (a copy of) original form of clause to recheck list. + * Finally, check to see if index is lossy for this operator. If + * so, add (a copy of) original form of clause to recheck list. */ if (op_requires_recheck(newopno, opclass)) recheck_qual = lappend(recheck_qual, @@ -1038,7 +1036,6 @@ static Node * fix_indxqual_operand(Node *node, int baserelid, IndexOptInfo *index, Oid *opclass) { - /* * Remove any binary-compatible relabeling of the indexkey */ @@ -1088,7 +1085,7 @@ fix_indxqual_operand(Node *node, int baserelid, IndexOptInfo *index, * the returned varattno must be 1. */ Assert(index->indproc != InvalidOid); - Assert(is_funcclause(node)); /* not a very thorough check, but easy */ + Assert(is_funcclause(node)); /* not a very thorough check, but easy */ /* classlist[0] is the only class of a functional index */ *opclass = index->classlist[0]; @@ -1119,7 +1116,6 @@ switch_outer(List *clauses) Assert(op && IsA(op, Var)); if (var_is_outer(op)) { - /* * Duplicate just enough of the structure to allow commuting * the clause without changing the original list. Could use @@ -1899,5 +1895,4 @@ generate_fjoin(List *tlist) return newTlist; return tlist; /* do nothing for now - ay 10/94 */ } - #endif diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index ff2e13ec97..4c7e281866 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.64 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.65 2001/10/25 05:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ static void add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, Relids join_relids); static void add_vars_to_targetlist(Query *root, List *vars); static bool qual_is_redundant(Query *root, RestrictInfo *restrictinfo, - List *restrictlist); + List *restrictlist); static void check_mergejoinable(RestrictInfo *restrictinfo); static void check_hashjoinable(RestrictInfo *restrictinfo); @@ -312,10 +312,10 @@ mark_baserels_for_outer_join(Query *root, Relids rels, Relids outerrels) /* * Presently the executor cannot support FOR UPDATE marking of - * rels appearing on the nullable side of an outer join. - * (It's somewhat unclear what that would mean, anyway: what should - * we mark when a result row is generated from no element of the - * nullable relation?) So, complain if target rel is FOR UPDATE. + * rels appearing on the nullable side of an outer join. (It's + * somewhat unclear what that would mean, anyway: what should we + * mark when a result row is generated from no element of the + * nullable relation?) So, complain if target rel is FOR UPDATE. * It's sufficient to make this check once per rel, so do it only * if rel wasn't already known nullable. */ @@ -411,9 +411,9 @@ distribute_qual_to_rels(Query *root, Node *clause, * outerjoinset list of each baserel will show exactly those outer * joins that are below the qual in the join tree. * - * If the qual came from implied-equality deduction, we can evaluate - * the qual at its natural semantic level. - * + * If the qual came from implied-equality deduction, we can evaluate the + * qual at its natural semantic level. + * */ if (isdeduced) { @@ -488,12 +488,13 @@ distribute_qual_to_rels(Query *root, Node *clause, /* * If the clause was deduced from implied equality, check to see - * whether it is redundant with restriction clauses we already have - * for this rel. Note we cannot apply this check to user-written - * clauses, since we haven't found the canonical pathkey sets yet - * while processing user clauses. (NB: no comparable check is done - * in the join-clause case; redundancy will be detected when the - * join clause is moved into a join rel's restriction list.) + * whether it is redundant with restriction clauses we already + * have for this rel. Note we cannot apply this check to + * user-written clauses, since we haven't found the canonical + * pathkey sets yet while processing user clauses. (NB: no + * comparable check is done in the join-clause case; redundancy + * will be detected when the join clause is moved into a join + * rel's restriction list.) */ if (!isdeduced || !qual_is_redundant(root, restrictinfo, rel->baserestrictinfo)) @@ -537,7 +538,6 @@ distribute_qual_to_rels(Query *root, Node *clause, } else { - /* * 'clause' references no rels, and therefore we have no place to * attach it. Shouldn't get here if callers are working properly. @@ -551,8 +551,8 @@ distribute_qual_to_rels(Query *root, Node *clause, * the two sides represent equivalent PathKeyItems for path keys: any * path that is sorted by one side will also be sorted by the other * (as soon as the two rels are joined, that is). Record the key - * equivalence for future use. (We can skip this for a deduced clause, - * since the keys are already known equivalent in that case.) + * equivalence for future use. (We can skip this for a deduced + * clause, since the keys are already known equivalent in that case.) */ if (can_be_equijoin && restrictinfo->mergejoinoperator != InvalidOid && !isdeduced) @@ -681,7 +681,6 @@ process_implied_equality(Query *root, Node *item1, Node *item2, eq_operator = compatible_oper("=", ltype, rtype, true); if (!HeapTupleIsValid(eq_operator)) { - /* * Would it be safe to just not add the equality to the query if * we have no suitable equality operator for the combination of @@ -735,12 +734,12 @@ qual_is_redundant(Query *root, RestrictInfo *restrictinfo, List *restrictlist) { - List *oldquals; - List *olditem; - Node *newleft; - Node *newright; - List *equalvars; - bool someadded; + List *oldquals; + List *olditem; + Node *newleft; + Node *newright; + List *equalvars; + bool someadded; /* * Set cached pathkeys. NB: it is okay to do this now because this @@ -752,6 +751,7 @@ qual_is_redundant(Query *root, /* If different, say "not redundant" (should never happen) */ if (restrictinfo->left_pathkey != restrictinfo->right_pathkey) return false; + /* * Scan existing quals to find those referencing same pathkeys. * Usually there will be few, if any, so build a list of just the @@ -772,24 +772,26 @@ qual_is_redundant(Query *root, } if (oldquals == NIL) return false; + /* * Now, we want to develop a list of Vars that are known equal to the - * left side of the new qual. We traverse the old-quals list repeatedly - * to transitively expand the Vars list. If at any point we find we - * can reach the right-side Var of the new qual, we are done. We give - * up when we can't expand the equalvars list any more. + * left side of the new qual. We traverse the old-quals list + * repeatedly to transitively expand the Vars list. If at any point + * we find we can reach the right-side Var of the new qual, we are + * done. We give up when we can't expand the equalvars list any more. */ newleft = (Node *) get_leftop(restrictinfo->clause); newright = (Node *) get_rightop(restrictinfo->clause); equalvars = makeList1(newleft); - do { + do + { someadded = false; foreach(olditem, oldquals) { RestrictInfo *oldrinfo = (RestrictInfo *) lfirst(olditem); - Node *oldleft = (Node *) get_leftop(oldrinfo->clause); - Node *oldright = (Node *) get_rightop(oldrinfo->clause); - Node *newguy = NULL; + Node *oldleft = (Node *) get_leftop(oldrinfo->clause); + Node *oldright = (Node *) get_rightop(oldrinfo->clause); + Node *newguy = NULL; if (member(oldleft, equalvars)) newguy = oldright; @@ -801,6 +803,7 @@ qual_is_redundant(Query *root, return true; /* we proved new clause is redundant */ equalvars = lcons(newguy, equalvars); someadded = true; + /* * Remove this qual from list, since we don't need it anymore. * Note this doesn't break the foreach() loop, since lremove diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index b5a77ea623..57c9b963c7 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.66 2001/06/05 05:26:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.67 2001/10/25 05:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -137,7 +137,6 @@ query_planner(Query *root, */ if (constant_quals || IsA(subplan, Append)) { - /* * The result node will also be responsible for evaluating the * originally requested tlist. @@ -148,7 +147,6 @@ query_planner(Query *root, } else { - /* * Replace the toplevel plan node's flattened target list with the * targetlist given by my caller, so that expressions are diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 48e41686e9..d870b2786f 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.109 2001/10/18 16:11:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.110 2001/10/25 05:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -210,7 +210,7 @@ subquery_planner(Query *parse, double tuple_fraction) * grouping_planner. */ if (parse->resultRelation && - (lst = expand_inherted_rtentry(parse, parse->resultRelation, false)) + (lst = expand_inherted_rtentry(parse, parse->resultRelation, false)) != NIL) plan = inheritance_planner(parse, lst); else @@ -277,8 +277,8 @@ pull_up_subqueries(Query *parse, Node *jtnode) * Is this a subquery RTE, and if so, is the subquery simple * enough to pull up? (If not, do nothing at this node.) * - * 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. + * 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. */ if (subquery && is_simple_subquery(subquery) && !contain_whole_tuple_var((Node *) parse, varno, 0)) @@ -370,12 +370,13 @@ pull_up_subqueries(Query *parse, Node *jtnode) /* * At the moment, we can't pull up subqueries that are inside the - * nullable side of an outer join, because substituting their target - * list entries for upper Var references wouldn't do the right thing - * (the entries wouldn't go to NULL when they're supposed to). - * Suppressing the pullup is an ugly, performance-losing hack, but - * I see no alternative for now. Find a better way to handle this - * when we redesign query trees --- tgl 4/30/01. + * nullable side of an outer join, because substituting their + * target list entries for upper Var references wouldn't do the + * right thing (the entries wouldn't go to NULL when they're + * supposed to). Suppressing the pullup is an ugly, + * performance-losing hack, but I see no alternative for now. + * Find a better way to handle this when we redesign query trees + * --- tgl 4/30/01. */ switch (j->jointype) { @@ -392,6 +393,7 @@ pull_up_subqueries(Query *parse, Node *jtnode) j->rarg = pull_up_subqueries(parse, j->rarg); break; case JOIN_UNION: + /* * This is where we fail if upper levels of planner * haven't rewritten UNION JOIN as an Append ... @@ -418,7 +420,6 @@ pull_up_subqueries(Query *parse, Node *jtnode) static bool is_simple_subquery(Query *subquery) { - /* * Let's just make sure it's a valid subselect ... */ @@ -545,7 +546,6 @@ preprocess_jointree(Query *parse, Node *jtnode) /* Now, is it a FromExpr? */ if (child && IsA(child, FromExpr)) { - /* * Yes, so do we want to merge it into parent? Always do * so if child has just one element (since that doesn't @@ -596,7 +596,6 @@ preprocess_jointree(Query *parse, Node *jtnode) static Node * preprocess_expression(Query *parse, Node *expr, int kind) { - /* * Simplify constant expressions. * @@ -632,7 +631,6 @@ preprocess_expression(Query *parse, Node *expr, int kind) if (kind != EXPRKIND_WHERE && (parse->groupClause != NIL || parse->hasAggs)) { - /* * Check for ungrouped variables passed to subplans. Note we * do NOT do this for subplans in WHERE (or JOIN/ON); it's @@ -776,7 +774,6 @@ grouping_planner(Query *parse, double tuple_fraction) if (parse->setOperations) { - /* * Construct the plan for set operations. The result will not * need any work except perhaps a top-level sort and/or LIMIT. @@ -946,12 +943,12 @@ grouping_planner(Query *parse, double tuple_fraction) if (parse->limitCount != NULL) { /* - * A LIMIT clause limits the absolute number of tuples returned. - * However, if it's not a constant LIMIT then we have to punt; - * for lack of a better idea, assume 10% of the plan's result - * is wanted. + * A LIMIT clause limits the absolute number of tuples + * returned. However, if it's not a constant LIMIT then we + * have to punt; for lack of a better idea, assume 10% of the + * plan's result is wanted. */ - double limit_fraction = 0.0; + double limit_fraction = 0.0; if (IsA(parse->limitCount, Const)) { @@ -959,9 +956,9 @@ grouping_planner(Query *parse, double tuple_fraction) int32 count = DatumGetInt32(limitc->constvalue); /* - * A NULL-constant LIMIT represents "LIMIT ALL", which - * we treat the same as no limit (ie, expect to - * retrieve all the tuples). + * A NULL-constant LIMIT represents "LIMIT ALL", which we + * treat the same as no limit (ie, expect to retrieve all + * the tuples). */ if (!limitc->constisnull && count > 0) { @@ -996,9 +993,10 @@ grouping_planner(Query *parse, double tuple_fraction) { /* * If we have absolute limits from both caller and LIMIT, - * use the smaller value; if one is fractional and the other - * absolute, treat the fraction as a fraction of the absolute - * value; else we can multiply the two fractions together. + * use the smaller value; if one is fractional and the + * other absolute, treat the fraction as a fraction of the + * absolute value; else we can multiply the two fractions + * together. */ if (tuple_fraction >= 1.0) { @@ -1040,7 +1038,6 @@ grouping_planner(Query *parse, double tuple_fraction) if (parse->groupClause) { - /* * In GROUP BY mode, we have the little problem that we don't * really know how many input tuples will be needed to make a @@ -1069,7 +1066,6 @@ grouping_planner(Query *parse, double tuple_fraction) } else if (parse->hasAggs) { - /* * Ungrouped aggregate will certainly want all the input * tuples. @@ -1078,7 +1074,6 @@ grouping_planner(Query *parse, double tuple_fraction) } else if (parse->distinctClause) { - /* * SELECT DISTINCT, like GROUP, will absorb an unpredictable * number of input tuples per output tuple. Handle the same @@ -1147,7 +1142,6 @@ grouping_planner(Query *parse, double tuple_fraction) } else { - /* * We will need to do an explicit sort by the GROUP BY clause. * make_groupplan will do the work, but set current_pathkeys @@ -1346,7 +1340,6 @@ make_groupplan(Query *parse, if (!is_presorted) { - /* * The Sort node always just takes a copy of the subplan's tlist * plus ordering information. (This might seem inefficient if the diff --git a/src/backend/optimizer/prep/prepkeyset.c b/src/backend/optimizer/prep/prepkeyset.c index 180637d099..6ff40fdb08 100644 --- a/src/backend/optimizer/prep/prepkeyset.c +++ b/src/backend/optimizer/prep/prepkeyset.c @@ -216,5 +216,4 @@ inspectOpNode(Expr *expr) secondExpr = lsecond(expr->args); return (firstExpr && secondExpr && nodeTag(firstExpr) == T_Var && nodeTag(secondExpr) == T_Const); } - #endif /* ENABLE_KEY_SET_QUERY */ diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index 2dc92deca1..a7773040d7 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.29 2001/03/22 03:59:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.30 2001/10/25 05:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -157,7 +157,6 @@ canonicalize_qual(Expr *qual, bool removeAndFlag) */ if (cnfok) { - /* * Normalize into conjunctive normal form, and clean up the * result. @@ -166,7 +165,6 @@ canonicalize_qual(Expr *qual, bool removeAndFlag) } else if (dnfok) { - /* * Normalize into disjunctive normal form, and clean up the * result. @@ -260,7 +258,6 @@ dnfify(Expr *qual) return newqual; } - #endif /*-------------------- @@ -539,7 +536,6 @@ push_nots(Expr *qual) } else if (not_clause((Node *) qual)) { - /* * Another 'not' cancels this 'not', so eliminate the 'not' and * stop negating this branch. But search the subexpression for @@ -549,7 +545,6 @@ push_nots(Expr *qual) } else { - /* * We don't know how to negate anything else, place a 'not' at * this level. @@ -959,7 +954,6 @@ count_bool_nodes(Expr *qual, } else if (contain_subplans((Node *) qual)) { - /* * charge extra for subexpressions containing sub-SELECTs, to * discourage us from rearranging them in a way that might diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 737f624b5a..2e335b808b 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.43 2001/09/06 02:07:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.44 2001/10/25 05:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,6 @@ preprocess_targetlist(List *tlist, Index result_relation, List *range_table) { - /* * Sanity check: if there is a result relation, it'd better be a real * relation not a subquery. Else parser or rewriter messed up. @@ -175,7 +174,6 @@ expand_targetlist(List *tlist, int command_type, if (new_tle == NULL) { - /* * Didn't find a matching tlist entry, so make one. * @@ -203,7 +201,8 @@ expand_targetlist(List *tlist, int command_type, /* * Set attributes are represented as OIDs no * matter what the set element type is, and - * the element type's default is irrelevant too. + * the element type's default is irrelevant + * too. */ hasdefault = false; typedefault = (Datum) 0; @@ -335,7 +334,6 @@ process_matched_tle(TargetEntry *src_tle, if (prior_tle == NULL) { - /* * Normal case where this is the first assignment to the * attribute. diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index dbbe004aef..6949217dec 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.66 2001/08/14 17:12:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.67 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -275,7 +275,7 @@ generate_nonunion_plan(SetOperationStmt *op, Query *parse, * * The tlist for an Append plan isn't important as far as the Append is * concerned, but we must make it look real anyway for the benefit of - * the next plan level up. In fact, it has to be real enough that the + * the next plan level up. In fact, it has to be real enough that the * flag column is shown as a variable not a constant, else setrefs.c * will get confused. */ @@ -358,7 +358,7 @@ recurse_union_children(Node *setOp, Query *parse, * * colTypes: column datatypes for non-junk columns * flag: -1 if no flag column needed, 0 or 1 to create a const flag column, - * 2 to create a variable flag column + * 2 to create a variable flag column * hack_constants: true to copy up constants (see comments in code) * input_tlist: targetlist of this node's input node * refnames_tlist: targetlist to take column names from @@ -538,7 +538,7 @@ find_all_inheritors(Oid parentrel) * If not, return NIL. * * When dup_parent is false, the initially given RT index is part of the - * returned list (if any). When dup_parent is true, the given RT index + * returned list (if any). When dup_parent is true, the given RT index * is *not* in the returned list; a duplicate RTE will be made for the * parent table. * @@ -571,6 +571,7 @@ expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent) return NIL; /* Scan for all members of inheritance set */ inhOIDs = find_all_inheritors(parentOID); + /* * Check that there's at least one descendant, else treat as no-child * case. This could happen despite above has_subclass() check, if @@ -582,7 +583,7 @@ expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent) if (dup_parent) inhRTIs = NIL; else - inhRTIs = makeListi1(rti); /* include original RTE in result */ + inhRTIs = makeListi1(rti); /* include original RTE in result */ foreach(l, inhOIDs) { @@ -728,10 +729,10 @@ adjust_inherited_attrs_mutator(Node *node, /* * BUT: although we don't need to recurse into subplans, we do need to * make sure that they are copied, not just referenced as - * expression_tree_mutator will do by default. Otherwise we'll have the - * same subplan node referenced from each arm of the inheritance APPEND - * plan, which will cause trouble in the executor. This is a kluge - * that should go away when we redesign querytrees. + * expression_tree_mutator will do by default. Otherwise we'll have + * the same subplan node referenced from each arm of the inheritance + * APPEND plan, which will cause trouble in the executor. This is a + * kluge that should go away when we redesign querytrees. */ if (is_subplan(node)) { diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 0bf06c5286..c92581082b 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.88 2001/07/31 20:16:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.89 2001/10/25 05:49:34 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -354,7 +354,6 @@ make_ands_explicit(List *andclauses) List * make_ands_implicit(Expr *clause) { - /* * NB: because the parser sets the qual field to NULL in a query that * has no WHERE clause, we must consider a NULL input clause as TRUE, @@ -526,7 +525,6 @@ void check_subplans_for_ungrouped_vars(Node *clause, Query *query) { - /* * No special setup needed; context for walker is just the Query * pointer @@ -555,7 +553,6 @@ check_subplans_for_ungrouped_vars_walker(Node *node, */ if (is_subplan(node)) { - /* * The args list of the subplan node represents attributes from * outside passed into the sublink. @@ -686,7 +683,6 @@ contain_noncachable_functions_walker(Node *node, void *context) bool is_pseudo_constant_clause(Node *clause) { - /* * We could implement this check in one recursive scan. But since the * check for noncachable functions is both moderately expensive and @@ -746,7 +742,7 @@ pull_constant_clauses(List *quals, List **constantQual) static bool sortgroupref_is_present(Index sortgroupref, List *clauselist) { - List *clause; + List *clause; foreach(clause, clauselist) { @@ -765,20 +761,21 @@ sortgroupref_is_present(Index sortgroupref, List *clauselist) bool has_distinct_on_clause(Query *query) { - List *targetList; + List *targetList; /* Is there a DISTINCT clause at all? */ if (query->distinctClause == NIL) return false; + /* - * If the DISTINCT list contains all the nonjunk targetlist items, - * and nothing else (ie, no junk tlist items), then it's a simple + * If the DISTINCT list contains all the nonjunk targetlist items, and + * nothing else (ie, no junk tlist items), then it's a simple * DISTINCT, else it's DISTINCT ON. We do not require the lists to be * in the same order (since the parser may have adjusted the DISTINCT - * clause ordering to agree with ORDER BY). Furthermore, a non-DISTINCT - * junk tlist item that is in the sortClause is also evidence of - * DISTINCT ON, since we don't allow ORDER BY on junk tlist items when - * plain DISTINCT is used. + * clause ordering to agree with ORDER BY). Furthermore, a + * non-DISTINCT junk tlist item that is in the sortClause is also + * evidence of DISTINCT ON, since we don't allow ORDER BY on junk + * tlist items when plain DISTINCT is used. * * This code assumes that the DISTINCT list is valid, ie, all its entries * match some entry of the tlist. @@ -1155,7 +1152,6 @@ eval_const_expressions_mutator(Node *node, void *context) } if (IsA(node, RelabelType)) { - /* * If we can simplify the input to a constant, then we don't need * the RelabelType node anymore: just change the type field of the @@ -1272,7 +1268,6 @@ eval_const_expressions_mutator(Node *node, void *context) } if (IsA(node, Iter)) { - /* * The argument of an Iter is normally a function call. We must * not try to eliminate the function, but we can try to simplify @@ -1423,7 +1418,6 @@ simplify_op_or_func(Expr *expr, List *args) */ if (proisstrict && has_null_input) { - /* * It's strict and has NULL input, so must produce NULL output. * Return a NULL constant of the right type. @@ -1871,7 +1865,6 @@ expression_tree_mutator(Node *node, Node *(*mutator) (), void *context) { - /* * The mutator has already decided not to modify the current node, but * we must call the mutator for any sub-nodes. @@ -1933,7 +1926,6 @@ expression_tree_mutator(Node *node, } else { - /* * for other Expr node types, just transform args * list, linking to original oper node (OK?) @@ -2026,8 +2018,8 @@ expression_tree_mutator(Node *node, break; case T_NullTest: { - NullTest *ntest = (NullTest *) node; - NullTest *newnode; + NullTest *ntest = (NullTest *) node; + NullTest *newnode; FLATCOPY(newnode, ntest, NullTest); MUTATE(newnode->arg, ntest->arg, Node *); @@ -2046,7 +2038,6 @@ expression_tree_mutator(Node *node, break; case T_SubLink: { - /* * A "bare" SubLink (note we will not come here if we * found a SUBPLAN_EXPR node above it). Transform the @@ -2062,7 +2053,6 @@ expression_tree_mutator(Node *node, break; case T_List: { - /* * We assume the mutator isn't interested in the list * nodes per se, so just invoke it on each list element. @@ -2083,7 +2073,6 @@ expression_tree_mutator(Node *node, break; case T_TargetEntry: { - /* * We mutate the expression, but not the resdom, by * default. diff --git a/src/backend/optimizer/util/joininfo.c b/src/backend/optimizer/util/joininfo.c index ec98dbcb24..f12c9b70ba 100644 --- a/src/backend/optimizer/util/joininfo.c +++ b/src/backend/optimizer/util/joininfo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.29 2001/03/22 03:59:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.30 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ joininfo_member(List *join_relids, List *joininfo_list) * Returns a joininfo node. * */ -JoinInfo * +JoinInfo * find_joininfo_node(RelOptInfo *this_rel, Relids join_relids) { JoinInfo *joininfo = joininfo_member(join_relids, diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 1377fc06a4..c86ee45008 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.75 2001/07/16 05:06:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.76 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -325,7 +325,7 @@ create_seqscan_path(Query *root, RelOptInfo *rel) * * Returns the new path node. */ -IndexPath * +IndexPath * create_index_path(Query *root, RelOptInfo *rel, IndexOptInfo *index, @@ -363,8 +363,8 @@ create_index_path(Query *root, pathnode->rows = rel->rows; /* - * Not sure if this is necessary, but it should help if the - * statistics are too far off + * Not sure if this is necessary, but it should help if the statistics + * are too far off */ if (index->indpred && index->tuples < pathnode->rows) pathnode->rows = index->tuples; diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 6d609853aa..86ebb09ff6 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.68 2001/08/21 16:36:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.69 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,8 +115,8 @@ find_secondary_indexes(Oid relationObjectId) info = makeNode(IndexOptInfo); /* - * Need to make these arrays large enough to be sure there is - * room for a terminating 0 at the end of each one. + * Need to make these arrays large enough to be sure there is room + * for a terminating 0 at the end of each one. */ info->classlist = (Oid *) palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1)); info->indexkeys = (int *) palloc(sizeof(int) * (INDEX_MAX_KEYS + 1)); @@ -125,7 +125,7 @@ find_secondary_indexes(Oid relationObjectId) /* Extract info from the pg_index tuple */ info->indexoid = index->indexrelid; info->indproc = index->indproc; /* functional index ?? */ - if (VARSIZE(&index->indpred) > VARHDRSZ) /* partial index ?? */ + if (VARSIZE(&index->indpred) > VARHDRSZ) /* partial index ?? */ { char *predString; @@ -210,7 +210,7 @@ find_secondary_indexes(Oid relationObjectId) * This code executes registered procedures stored in the * operator relation, by calling the function manager. * - * varRelid is either 0 or a rangetable index. See clause_selectivity() + * varRelid is either 0 or a rangetable index. See clause_selectivity() * for details about its meaning. */ Selectivity @@ -223,8 +223,8 @@ restriction_selectivity(Query *root, float8 result; /* - * if the oprrest procedure is missing for whatever reason, - * use a selectivity of 0.5 + * if the oprrest procedure is missing for whatever reason, use a + * selectivity of 0.5 */ if (!oprrest) return (Selectivity) 0.5; @@ -257,8 +257,8 @@ join_selectivity(Query *root, float8 result; /* - * if the oprjoin procedure is missing for whatever reason, - * use a selectivity of 0.5 + * if the oprjoin procedure is missing for whatever reason, use a + * selectivity of 0.5 */ if (!oprjoin) return (Selectivity) 0.5; @@ -365,10 +365,10 @@ has_unique_index(RelOptInfo *rel, AttrNumber attno) IndexOptInfo *index = (IndexOptInfo *) lfirst(ilist); /* - * Note: ignore functional and partial indexes, since they - * don't allow us to conclude that all attr values are distinct. - * Also, a multicolumn unique index doesn't allow us to conclude - * that just the specified attr is unique. + * Note: ignore functional and partial indexes, since they don't + * allow us to conclude that all attr values are distinct. Also, a + * multicolumn unique index doesn't allow us to conclude that just + * the specified attr is unique. */ if (index->unique && index->nkeys == 1 && diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 3b85f321df..457826f5d3 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.34 2001/10/18 16:11:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.35 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,9 +26,9 @@ static RelOptInfo *make_base_rel(Query *root, int relid); static List *new_join_tlist(List *tlist, int first_resdomno); static List *build_joinrel_restrictlist(Query *root, - RelOptInfo *joinrel, - RelOptInfo *outer_rel, - RelOptInfo *inner_rel); + RelOptInfo *joinrel, + RelOptInfo *outer_rel, + RelOptInfo *inner_rel); static void build_joinrel_joinlist(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel); @@ -154,7 +154,7 @@ make_base_rel(Query *root, int relid) if (relationObjectId != InvalidOid) { /* Plain relation --- retrieve statistics from the system catalogs */ - bool indexed; + bool indexed; get_relation_info(relationObjectId, &indexed, &rel->pages, &rel->tuples); @@ -270,7 +270,6 @@ build_join_rel(Query *root, if (joinrel) { - /* * Yes, so we only need to figure the restrictlist for this * particular pair of component relations. @@ -437,9 +436,9 @@ build_joinrel_restrictlist(Query *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel) { - List *result = NIL; - List *rlist; - List *item; + List *result = NIL; + List *rlist; + List *item; /* * Collect all the clauses that syntactically belong at this level. @@ -453,9 +452,9 @@ build_joinrel_restrictlist(Query *root, * Eliminate duplicate and redundant clauses. * * We must eliminate duplicates, since we will see many of the same - * clauses arriving from both input relations. Also, if a clause is - * a mergejoinable clause, it's possible that it is redundant with - * previous clauses (see optimizer/README for discussion). We detect + * clauses arriving from both input relations. Also, if a clause is a + * mergejoinable clause, it's possible that it is redundant with + * previous clauses (see optimizer/README for discussion). We detect * that case and omit the redundant clause from the result list. * * We can detect redundant mergejoinable clauses very cheaply by using @@ -463,8 +462,9 @@ build_joinrel_restrictlist(Query *root, * equijoined variables in question. All the members of a pathkey set * that are in the left relation have already been forced to be equal; * likewise for those in the right relation. So, we need to have only - * one clause that checks equality between any set member on the left and - * any member on the right; by transitivity, all the rest are then equal. + * one clause that checks equality between any set member on the left + * and any member on the right; by transitivity, all the rest are then + * equal. */ foreach(item, rlist) { @@ -477,8 +477,8 @@ build_joinrel_restrictlist(Query *root, /* check for redundant merge clauses */ if (rinfo->mergejoinoperator != InvalidOid) { - bool redundant = false; - List *olditem; + bool redundant = false; + List *olditem; cache_mergeclause_pathkeys(root, rinfo); diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index 9d5d6c080e..0d30586fce 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.50 2001/03/22 03:59:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.51 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,6 @@ matching_tlist_expr(Node *node, List *targetlist) return (Node *) NULL; } - #endif /* diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index 9b620c80f5..2521ffb2b6 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.32 2001/05/09 23:13:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.33 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ typedef struct static bool pull_varnos_walker(Node *node, pull_varnos_context *context); static bool contain_var_reference_walker(Node *node, - contain_var_reference_context *context); + contain_var_reference_context *context); static bool contain_var_clause_walker(Node *node, void *context); static bool pull_var_clause_walker(Node *node, pull_var_clause_context *context); @@ -55,7 +55,7 @@ static bool pull_var_clause_walker(Node *node, * * NOTE: this is used on not-yet-planned expressions. It may therefore find * bare SubLinks, and if so it needs to recurse into them to look for uplevel - * references to the desired rtable level! But when we find a completed + * references to the desired rtable level! But when we find a completed * SubPlan, we only need to look at the parameters passed to the subplan. */ List * @@ -96,7 +96,6 @@ pull_varnos_walker(Node *node, pull_varnos_context *context) } if (is_subplan(node)) { - /* * Already-planned subquery. Examine the args list (parameters to * be passed to subquery), as well as the "oper" list which is @@ -137,7 +136,7 @@ pull_varnos_walker(Node *node, pull_varnos_context *context) * * NOTE: this is used on not-yet-planned expressions. It may therefore find * bare SubLinks, and if so it needs to recurse into them to look for uplevel - * references to the desired rtable entry! But when we find a completed + * references to the desired rtable entry! But when we find a completed * SubPlan, we only need to look at the parameters passed to the subplan. */ bool @@ -180,7 +179,6 @@ contain_var_reference_walker(Node *node, } if (is_subplan(node)) { - /* * Already-planned subquery. Examine the args list (parameters to * be passed to subquery), as well as the "oper" list which is diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 6e89abefe8..9f95300e35 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.203 2001/10/23 17:39:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.204 2001/10/25 05:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,15 +77,15 @@ static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt); static Query *transformCreateStmt(ParseState *pstate, CreateStmt *stmt); static Query *transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt); static void transformColumnDefinition(ParseState *pstate, - CreateStmtContext *cxt, - ColumnDef *column); + CreateStmtContext *cxt, + ColumnDef *column); static void transformTableConstraint(ParseState *pstate, - CreateStmtContext *cxt, - Constraint *constraint); + CreateStmtContext *cxt, + Constraint *constraint); static void transformIndexConstraints(ParseState *pstate, - CreateStmtContext *cxt); + CreateStmtContext *cxt); static void transformFKConstraints(ParseState *pstate, - CreateStmtContext *cxt); + CreateStmtContext *cxt); static Node *transformTypeRefs(ParseState *pstate, Node *stmt); static void transformTypeRefsList(ParseState *pstate, List *l); @@ -97,7 +97,7 @@ static void transformColumnType(ParseState *pstate, ColumnDef *column); static void transformFkeyCheckAttrs(FkConstraint *fkconstraint, Oid *pktypoid); static void transformFkeyGetPrimaryKey(FkConstraint *fkconstraint, Oid *pktypoid); static bool relationHasPrimaryKey(char *relname); -static Oid transformFkeyGetColType(CreateStmtContext *cxt, char *colname); +static Oid transformFkeyGetColType(CreateStmtContext *cxt, char *colname); static void release_pstate_resources(ParseState *pstate); static FromExpr *makeFromExpr(List *fromlist, Node *quals); @@ -170,7 +170,6 @@ transformStmt(ParseState *pstate, Node *parseTree) switch (nodeTag(parseTree)) { - /* * Non-optimizable statements */ @@ -197,8 +196,8 @@ transformStmt(ParseState *pstate, Node *parseTree) * insert these into the actual query tree. - thomas * 2000-03-08 * - * Outer loop is over targetlist to make it easier to - * skip junk targetlist entries. + * Outer loop is over targetlist to make it easier to skip + * junk targetlist entries. */ if (n->aliases != NIL) { @@ -214,14 +213,15 @@ transformStmt(ParseState *pstate, Node *parseTree) Assert(IsA(te, TargetEntry)); rd = te->resdom; Assert(IsA(rd, Resdom)); - if (rd->resjunk) /* junk columns don't get aliases */ + if (rd->resjunk) /* junk columns don't get + * aliases */ continue; id = (Ident *) lfirst(aliaslist); Assert(IsA(id, Ident)); rd->resname = pstrdup(id->name); aliaslist = lnext(aliaslist); if (aliaslist == NIL) - break; /* done assigning aliases */ + break; /* done assigning aliases */ } if (aliaslist != NIL) @@ -466,7 +466,6 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) } else { - /* * For INSERT ... VALUES, transform the given list of values to * form a targetlist for the INSERT. @@ -548,7 +547,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) te = makeTargetEntry(makeResdom(attrno, thisatt->atttypid, thisatt->atttypmod, - pstrdup(NameStr(thisatt->attname)), + pstrdup(NameStr(thisatt->attname)), false), stringToNode(defval[ndef].adbin)); qry->targetList = lappend(qry->targetList, te); @@ -828,16 +827,16 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, CreateSeqStmt *sequence; /* - * Create appropriate constraints for SERIAL. We do - * this in full, rather than shortcutting, so that we - * will detect any conflicting constraints the user - * wrote (like a different DEFAULT). + * Create appropriate constraints for SERIAL. We do this in full, + * rather than shortcutting, so that we will detect any + * conflicting constraints the user wrote (like a different + * DEFAULT). */ sname = makeObjectName(cxt->relname, column->colname, "seq"); /* - * Create an expression tree representing the function - * call nextval('"sequencename"') + * Create an expression tree representing the function call + * nextval('"sequencename"') */ qstring = palloc(strlen(sname) + 2 + 1); sprintf(qstring, "\"%s\"", sname); @@ -860,7 +859,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, constraint = makeNode(Constraint); constraint->contype = CONSTR_UNIQUE; - constraint->name = NULL; /* assign later */ + constraint->name = NULL; /* assign later */ column->constraints = lappend(column->constraints, constraint); constraint = makeNode(Constraint); @@ -868,9 +867,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, column->constraints = lappend(column->constraints, constraint); /* - * Build a CREATE SEQUENCE command to create the - * sequence object, and add it to the list of things - * to be done before this CREATE/ALTER TABLE. + * Build a CREATE SEQUENCE command to create the sequence object, + * and add it to the list of things to be done before this + * CREATE/ALTER TABLE. */ sequence = makeNode(CreateSeqStmt); sequence->seqname = pstrdup(sname); @@ -878,7 +877,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, sequence->options = NIL; elog(NOTICE, "%s will create implicit sequence '%s' for SERIAL column '%s.%s'", - cxt->stmtType, sequence->seqname, cxt->relname, column->colname); + cxt->stmtType, sequence->seqname, cxt->relname, column->colname); cxt->blist = lappend(cxt->blist, sequence); } @@ -893,10 +892,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, constraint = lfirst(clist); /* - * If this column constraint is a FOREIGN KEY - * constraint, then we fill in the current attributes - * name and throw it into the list of FK constraints - * to be processed later. + * If this column constraint is a FOREIGN KEY constraint, then we + * fill in the current attributes name and throw it into the list + * of FK constraints to be processed later. */ if (IsA(constraint, FkConstraint)) { @@ -1041,9 +1039,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) List *indexlist = NIL; /* - * Run through the constraints that need to generate an index. - * For PRIMARY KEY, mark each column as NOT NULL and create an index. - * For UNIQUE, create an index as for PRIMARY KEY, but do not insist on + * Run through the constraints that need to generate an index. For + * PRIMARY KEY, mark each column as NOT NULL and create an index. For + * UNIQUE, create an index as for PRIMARY KEY, but do not insist on * NOT NULL. */ foreach(listptr, cxt->ixconstraints) @@ -1083,8 +1081,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) index->whereClause = NULL; /* - * Make sure referenced keys exist. If we are making a - * PRIMARY KEY index, also make sure they are NOT NULL. + * Make sure referenced keys exist. If we are making a PRIMARY + * KEY index, also make sure they are NOT NULL. */ foreach(keys, constraint->keys) { @@ -1112,9 +1110,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) else if (SystemAttributeByName(key->name, cxt->hasoids) != NULL) { /* - * column will be a system column in the new table, - * so accept it. System columns can't ever be null, - * so no need to worry about PRIMARY/NOT NULL constraint. + * column will be a system column in the new table, so + * accept it. System columns can't ever be null, so no + * need to worry about PRIMARY/NOT NULL constraint. */ found = true; } @@ -1181,6 +1179,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) if (HeapTupleIsValid(atttuple)) { found = true; + /* * We require pre-existing column to be already marked * NOT NULL. @@ -1275,8 +1274,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) * Finally, select unique names for all not-previously-named indices, * and display notice messages. * - * XXX in ALTER TABLE case, we fail to consider name collisions - * against pre-existing indexes. + * XXX in ALTER TABLE case, we fail to consider name collisions against + * pre-existing indexes. */ foreach(indexlist, cxt->alist) { @@ -1307,9 +1306,9 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) List *fk_attr; List *pk_attr; Ident *id; - Oid pktypoid[INDEX_MAX_KEYS]; - Oid fktypoid[INDEX_MAX_KEYS]; - int i; + Oid pktypoid[INDEX_MAX_KEYS]; + Oid fktypoid[INDEX_MAX_KEYS]; + int i; if (cxt->fkconstraints == NIL) return; @@ -1320,7 +1319,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) foreach(fkclist, cxt->fkconstraints) { FkConstraint *fkconstraint = (FkConstraint *) lfirst(fkclist); - int attnum; + int attnum; List *fkattrs; /* @@ -1329,12 +1328,12 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) if (fkconstraint->constr_name == NULL) fkconstraint->constr_name = "<unnamed>"; - for (attnum=0; attnum<INDEX_MAX_KEYS; attnum++) + for (attnum = 0; attnum < INDEX_MAX_KEYS; attnum++) pktypoid[attnum] = fktypoid[attnum] = InvalidOid; /* - * Look up the referencing attributes to make sure they exist - * (or will exist) in this table, and remember their type OIDs. + * Look up the referencing attributes to make sure they exist (or + * will exist) in this table, and remember their type OIDs. */ attnum = 0; foreach(fkattrs, fkconstraint->fk_attrs) @@ -1361,7 +1360,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) /* Use the to-be-created primary key */ List *attr; - attnum=0; + attnum = 0; foreach(attr, cxt->pkey->indexParams) { IndexElem *ielem = lfirst(attr); @@ -1376,7 +1375,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) elog(ERROR, "Can only have %d keys in a foreign key", INDEX_MAX_KEYS); pktypoid[attnum++] = transformFkeyGetColType(cxt, - ielem->name); + ielem->name); } } else @@ -1410,7 +1409,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) if (length(ind->indexParams) != length(fkconstraint->pk_attrs)) continue; - attnum=0; + attnum = 0; foreach(pkattrs, fkconstraint->pk_attrs) { Ident *pkattr = lfirst(pkattrs); @@ -1433,14 +1432,17 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) elog(ERROR, "Can only have %d keys in a foreign key", INDEX_MAX_KEYS); pktypoid[attnum++] = transformFkeyGetColType(cxt, - pkattr->name); + pkattr->name); } if (found) break; } if (!found) { - /* In ALTER TABLE case, such an index may already exist */ + /* + * In ALTER TABLE case, such an index may already + * exist + */ if (OidIsValid(cxt->relOid)) transformFkeyCheckAttrs(fkconstraint, pktypoid); else @@ -1454,12 +1456,13 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) for (i = 0; i < INDEX_MAX_KEYS && fktypoid[i] != 0; i++) { /* - * fktypoid[i] is the foreign key table's i'th element's type oid - * pktypoid[i] is the primary key table's i'th element's type oid - * We let oper() do our work for us, including elog(ERROR) if the - * types don't compare with = + * fktypoid[i] is the foreign key table's i'th element's type + * oid pktypoid[i] is the primary key table's i'th element's + * type oid We let oper() do our work for us, including + * elog(ERROR) if the types don't compare with = */ - Operator o=oper("=", fktypoid[i], pktypoid[i], false); + Operator o = oper("=", fktypoid[i], pktypoid[i], false); + ReleaseSysCache(o); } @@ -1492,7 +1495,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) fk_trigger->args = lappend(fk_trigger->args, makeString(cxt->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable_name)); + makeString(fkconstraint->pktable_name)); fk_trigger->args = lappend(fk_trigger->args, makeString(fkconstraint->match_type)); fk_attr = fkconstraint->fk_attrs; @@ -1519,8 +1522,8 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) fkactions = lappend(fkactions, (Node *) fk_trigger); /* - * Build a CREATE CONSTRAINT TRIGGER statement for the ON - * DELETE action fired on the PK table !!! + * Build a CREATE CONSTRAINT TRIGGER statement for the ON DELETE + * action fired on the PK table !!! */ fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt); fk_trigger->trigname = fkconstraint->constr_name; @@ -1569,7 +1572,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) fk_trigger->args = lappend(fk_trigger->args, makeString(cxt->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable_name)); + makeString(fkconstraint->pktable_name)); fk_trigger->args = lappend(fk_trigger->args, makeString(fkconstraint->match_type)); fk_attr = fkconstraint->fk_attrs; @@ -1591,8 +1594,8 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) fkactions = lappend(fkactions, (Node *) fk_trigger); /* - * Build a CREATE CONSTRAINT TRIGGER statement for the ON - * UPDATE action fired on the PK table !!! + * Build a CREATE CONSTRAINT TRIGGER statement for the ON UPDATE + * action fired on the PK table !!! */ fk_trigger = (CreateTrigStmt *) makeNode(CreateTrigStmt); fk_trigger->trigname = fkconstraint->constr_name; @@ -1641,7 +1644,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) fk_trigger->args = lappend(fk_trigger->args, makeString(cxt->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable_name)); + makeString(fkconstraint->pktable_name)); fk_trigger->args = lappend(fk_trigger->args, makeString(fkconstraint->match_type)); fk_attr = fkconstraint->fk_attrs; @@ -1664,9 +1667,9 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) } /* - * Attach completed list of extra actions to cxt->alist. We cannot - * do this earlier, because we assume above that cxt->alist still - * holds only IndexStmts. + * Attach completed list of extra actions to cxt->alist. We cannot do + * this earlier, because we assume above that cxt->alist still holds + * only IndexStmts. */ cxt->alist = nconc(cxt->alist, fkactions); } @@ -1688,11 +1691,11 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) if (stmt->whereClause) { /* - * Put the parent table into the rtable so that the WHERE clause can - * refer to its fields without qualification. Note that this only - * works if the parent table already exists --- so we can't easily - * support predicates on indexes created implicitly by CREATE TABLE. - * Fortunately, that's not necessary. + * Put the parent table into the rtable so that the WHERE clause + * can refer to its fields without qualification. Note that this + * only works if the parent table already exists --- so we can't + * easily support predicates on indexes created implicitly by + * CREATE TABLE. Fortunately, that's not necessary. */ rte = addRangeTableEntry(pstate, stmt->relname, NULL, false, true); @@ -1849,8 +1852,8 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt) /* * We cannot support utility-statement actions (eg NOTIFY) - * with nonempty rule WHERE conditions, because there's no - * way to make the utility action execute conditionally. + * with nonempty rule WHERE conditions, because there's no way + * to make the utility action execute conditionally. */ if (top_subqry->commandType == CMD_UTILITY && stmt->whereClause != NULL) @@ -2041,7 +2044,8 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) * The tree of set operations is converted into the setOperations field of * the top-level Query. */ -static Query *transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) +static Query * +transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) { Query *qry = makeNode(Query); SelectStmt *leftmostSelect; @@ -2481,7 +2485,6 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) if (resnode->resjunk) { - /* * Resjunk nodes need no additional processing, but be sure * they have names and resnos that do not match any target @@ -2518,7 +2521,7 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) /* * The only subtypes that currently require parse transformation - * handling are 'A'dd column and Add 'C'onstraint. These largely + * handling are 'A'dd column and Add 'C'onstraint. These largely * re-use code from CREATE TABLE. */ switch (stmt->subtype) @@ -2532,8 +2535,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) PointerGetDatum(stmt->relname), 0, 0, 0); cxt.hasoids = SearchSysCacheExists(ATTNUM, - ObjectIdGetDatum(cxt.relOid), - Int16GetDatum(ObjectIdAttributeNumber), + ObjectIdGetDatum(cxt.relOid), + Int16GetDatum(ObjectIdAttributeNumber), 0, 0); cxt.columns = NIL; cxt.ckconstraints = NIL; @@ -2564,8 +2567,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) PointerGetDatum(stmt->relname), 0, 0, 0); cxt.hasoids = SearchSysCacheExists(ATTNUM, - ObjectIdGetDatum(cxt.relOid), - Int16GetDatum(ObjectIdAttributeNumber), + ObjectIdGetDatum(cxt.relOid), + Int16GetDatum(ObjectIdAttributeNumber), 0, 0); cxt.columns = NIL; cxt.ckconstraints = NIL; @@ -2612,48 +2615,46 @@ transformTypeRefs(ParseState *pstate, Node *stmt) switch (nodeTag(stmt)) { case T_ProcedureStmt: - { - ProcedureStmt *ps = (ProcedureStmt *) stmt; + { + ProcedureStmt *ps = (ProcedureStmt *) stmt; - transformTypeRefsList(pstate, ps->argTypes); - transformTypeRef(pstate, (TypeName *) ps->returnType); - transformTypeRefsList(pstate, ps->withClause); - } - break; + transformTypeRefsList(pstate, ps->argTypes); + transformTypeRef(pstate, (TypeName *) ps->returnType); + transformTypeRefsList(pstate, ps->withClause); + } + break; case T_CommentStmt: - { - CommentStmt *cs = (CommentStmt *) stmt; + { + CommentStmt *cs = (CommentStmt *) stmt; - transformTypeRefsList(pstate, cs->objlist); - } - break; + transformTypeRefsList(pstate, cs->objlist); + } + break; case T_RemoveFuncStmt: - { - RemoveFuncStmt *rs = (RemoveFuncStmt *) stmt; + { + RemoveFuncStmt *rs = (RemoveFuncStmt *) stmt; - transformTypeRefsList(pstate, rs->args); - } - break; + transformTypeRefsList(pstate, rs->args); + } + break; case T_DefineStmt: - { - DefineStmt *ds = (DefineStmt *) stmt; - List *ele; - - foreach(ele, ds->definition) { - DefElem *de = (DefElem *) lfirst(ele); + DefineStmt *ds = (DefineStmt *) stmt; + List *ele; - if (de->arg != NULL - && IsA(de->arg, TypeName)) + foreach(ele, ds->definition) { - transformTypeRef(pstate, (TypeName *) de->arg); + DefElem *de = (DefElem *) lfirst(ele); + + if (de->arg != NULL + && IsA(de->arg, TypeName)) + transformTypeRef(pstate, (TypeName *) de->arg); } } - } - break; + break; default: elog(ERROR, "Unsupported type %d in transformTypeRefs", @@ -2674,7 +2675,7 @@ transformTypeRefsList(ParseState *pstate, List *l) foreach(ele, l) { - Node *elem = lfirst(ele); + Node *elem = lfirst(ele); if (elem && IsA(elem, TypeName)) transformTypeRef(pstate, (TypeName *) elem); @@ -2687,16 +2688,16 @@ transformTypeRefsList(ParseState *pstate, List *l) static void transformTypeRef(ParseState *pstate, TypeName *tn) { - Attr *att; - Node *n; - Var *v; - char *tyn; + Attr *att; + Node *n; + Var *v; + char *tyn; if (tn->attrname == NULL) return; att = makeAttr(tn->name, tn->attrname); n = transformExpr(pstate, (Node *) att, EXPR_COLUMN_FIRST); - if (! IsA(n, Var)) + if (!IsA(n, Var)) elog(ERROR, "unsupported expression in %%TYPE"); v = (Var *) n; tyn = typeidTypeName(v->vartype); @@ -2841,7 +2842,7 @@ transformFkeyCheckAttrs(FkConstraint *fkconstraint, Oid *pktypoid) { /* go through the fkconstraint->pk_attrs list */ List *attrl; - int attnum = 0; + int attnum = 0; foreach(attrl, fkconstraint->pk_attrs) { @@ -2893,7 +2894,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint, Oid *pktypoid) HeapTuple indexTuple = NULL; Form_pg_index indexStruct = NULL; int i; - int attnum=0; + int attnum = 0; /* * Open the referenced table @@ -3022,7 +3023,7 @@ transformFkeyGetColType(CreateStmtContext *cxt, char *colname) if (strcmp(col->colname, colname) == 0) { - char *buff = TypeNameToInternalName(col->typename); + char *buff = TypeNameToInternalName(col->typename); result = typenameTypeId(buff); if (!OidIsValid(result)) @@ -3231,7 +3232,6 @@ transformColumnType(ParseState *pstate, ColumnDef *column) */ if (typeTypeRelid(ctype) != InvalidOid) { - /* * (Eventually add in here that the set can only contain one * element.) diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 3c621ddc69..d6ad0a07ea 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.45 2001/08/09 18:28:17 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.46 2001/10/25 05:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -240,7 +240,6 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, void agg_error(char *caller, char *aggname, Oid basetypeID) { - /* * basetypeID that is Invalid (zero) means aggregate over all types. * (count) diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index e8ba26295e..61904439e7 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.82 2001/08/09 18:28:17 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.83 2001/10/25 05:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -179,7 +179,7 @@ interpretInhOption(InhOption inhOpt) { switch (inhOpt) { - case INH_NO: + case INH_NO: return false; case INH_YES: return true; @@ -288,9 +288,9 @@ transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars) result = transformExpr(pstate, result, EXPR_COLUMN_FIRST); /* - * We expect the result to yield bool directly, otherwise complain. - * We could try coerce_to_boolean() here, but it seems likely that an - * "=" operator that doesn't return bool is wrong anyway. + * We expect the result to yield bool directly, otherwise complain. We + * could try coerce_to_boolean() here, but it seems likely that an "=" + * operator that doesn't return bool is wrong anyway. */ if (exprType(result) != BOOLOID) elog(ERROR, "JOIN/USING clause must return type boolean, not type %s", @@ -328,7 +328,7 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, /* This part is just like transformWhereClause() */ result = transformExpr(pstate, j->quals, EXPR_COLUMN_FIRST); - if (! coerce_to_boolean(pstate, &result)) + if (!coerce_to_boolean(pstate, &result)) elog(ERROR, "JOIN/ON clause must return type boolean, not type %s", format_type_be(exprType(result))); @@ -608,7 +608,6 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels) if (j->using) { - /* * JOIN/USING (or NATURAL JOIN, as transformed above). * Transform the list into an explicit ON-condition, and @@ -734,7 +733,6 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels) */ if (j->alias) { - /* * If a column alias list is specified, substitute the alias * names into my output-column list @@ -775,7 +773,7 @@ transformWhereClause(ParseState *pstate, Node *clause) qual = transformExpr(pstate, clause, EXPR_COLUMN_FIRST); - if (! coerce_to_boolean(pstate, &qual)) + if (!coerce_to_boolean(pstate, &qual)) elog(ERROR, "WHERE clause must return type boolean, not type %s", format_type_be(exprType(qual))); @@ -840,13 +838,12 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause) * an expression. *---------- */ - if (IsA(node, Ident) && ((Ident *) node)->indirection == NIL) + if (IsA(node, Ident) &&((Ident *) node)->indirection == NIL) { char *name = ((Ident *) node)->name; if (clause == GROUP_CLAUSE) { - /* * In GROUP BY, we must prefer a match against a FROM-clause * column to one against the targetlist. Look to see if there diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index e1e218f27e..e81edb3efc 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.63 2001/10/04 17:52:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.64 2001/10/25 05:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,6 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, } else if (inputTypeId == UNKNOWNOID && IsA(node, Const)) { - /* * Input is a string constant with previously undetermined type. * Apply the target type's typinput function to it to produce a @@ -90,7 +89,6 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, } else if (IS_BINARY_COMPATIBLE(inputTypeId, targetTypeId)) { - /* * We don't really need to do a conversion, but we do need to * attach a RelabelType node so that the expression will be seen @@ -118,7 +116,6 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, } else { - /* * Otherwise, find the appropriate type conversion function * (caller should have determined that there is one), and generate @@ -240,7 +237,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids) oid_array[0] = inputTypeId; ftup = SearchSysCache(PROCNAME, - PointerGetDatum(typeidTypeName(targetTypeId)), + PointerGetDatum(typeidTypeName(targetTypeId)), Int32GetDatum(1), PointerGetDatum(oid_array), 0); @@ -324,7 +321,7 @@ coerce_type_typmod(ParseState *pstate, Node *node, * (AND, OR, NOT, etc). * * If successful, update *pnode to be the transformed argument (if any - * transformation is needed), and return TRUE. If fail, return FALSE. + * transformation is needed), and return TRUE. If fail, return FALSE. * (The caller must check for FALSE and emit a suitable error message.) */ bool @@ -336,7 +333,7 @@ coerce_to_boolean(ParseState *pstate, Node **pnode) if (inputTypeId == BOOLOID) return true; /* no work */ targetTypeId = BOOLOID; - if (! can_coerce_type(1, &inputTypeId, &targetTypeId)) + if (!can_coerce_type(1, &inputTypeId, &targetTypeId)) return false; /* fail, but let caller choose error msg */ *pnode = coerce_type(pstate, *pnode, inputTypeId, targetTypeId, -1); return true; @@ -384,7 +381,6 @@ select_common_type(List *typeids, const char *context) } else if (TypeCategory(ntype) != pcategory) { - /* * both types in different categories? then not much * hope... @@ -396,7 +392,6 @@ select_common_type(List *typeids, const char *context) && !IsPreferredType(pcategory, ptype) && can_coerce_type(1, &ptype, &ntype)) { - /* * new one is preferred and can convert? then take it... */ diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 5db1ab867f..333333b040 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.103 2001/10/08 21:46:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.104 2001/10/25 05:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,11 +40,11 @@ bool Transform_null_equals = false; static Node *parser_typecast_constant(Value *expr, TypeName *typename); static Node *parser_typecast_expression(ParseState *pstate, - Node *expr, TypeName *typename); + Node *expr, TypeName *typename); static Node *transformAttr(ParseState *pstate, Attr *att, int precedence); static Node *transformIdent(ParseState *pstate, Ident *ident, int precedence); static Node *transformIndirection(ParseState *pstate, Node *basenode, - List *indirection); + List *indirection); /* @@ -159,16 +159,18 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) case OP: { /* - * Special-case "foo = NULL" and "NULL = foo" for - * compatibility with standards-broken products - * (like Microsoft's). Turn these into IS NULL exprs. + * Special-case "foo = NULL" and "NULL = foo" + * for compatibility with standards-broken + * products (like Microsoft's). Turn these + * into IS NULL exprs. */ if (Transform_null_equals && strcmp(a->opname, "=") == 0 && (exprIsNullConstant(a->lexpr) || exprIsNullConstant(a->rexpr))) { - NullTest *n = makeNode(NullTest); + NullTest *n = makeNode(NullTest); + n->nulltesttype = IS_NULL; if (exprIsNullConstant(a->lexpr)) @@ -183,11 +185,11 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) else { Node *lexpr = transformExpr(pstate, - a->lexpr, - precedence); + a->lexpr, + precedence); Node *rexpr = transformExpr(pstate, - a->rexpr, - precedence); + a->rexpr, + precedence); result = (Node *) make_op(a->opname, lexpr, @@ -205,12 +207,12 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) precedence); Expr *expr = makeNode(Expr); - if (! coerce_to_boolean(pstate, &lexpr)) + if (!coerce_to_boolean(pstate, &lexpr)) elog(ERROR, "left-hand side of AND is type '%s', not '%s'", format_type_be(exprType(lexpr)), format_type_be(BOOLOID)); - if (! coerce_to_boolean(pstate, &rexpr)) + if (!coerce_to_boolean(pstate, &rexpr)) elog(ERROR, "right-hand side of AND is type '%s', not '%s'", format_type_be(exprType(rexpr)), format_type_be(BOOLOID)); @@ -231,12 +233,12 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) precedence); Expr *expr = makeNode(Expr); - if (! coerce_to_boolean(pstate, &lexpr)) + if (!coerce_to_boolean(pstate, &lexpr)) elog(ERROR, "left-hand side of OR is type '%s', not '%s'", format_type_be(exprType(lexpr)), format_type_be(BOOLOID)); - if (! coerce_to_boolean(pstate, &rexpr)) + if (!coerce_to_boolean(pstate, &rexpr)) elog(ERROR, "right-hand side of OR is type '%s', not '%s'", format_type_be(exprType(rexpr)), format_type_be(BOOLOID)); @@ -254,7 +256,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) precedence); Expr *expr = makeNode(Expr); - if (! coerce_to_boolean(pstate, &rexpr)) + if (!coerce_to_boolean(pstate, &rexpr)) elog(ERROR, "argument to NOT is type '%s', not '%s'", format_type_be(exprType(rexpr)), format_type_be(BOOLOID)); @@ -315,7 +317,6 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) if (sublink->subLinkType == EXISTS_SUBLINK) { - /* * EXISTS needs no lefthand or combining operator. * These fields should be NIL already, but make sure. @@ -456,7 +457,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) } neww->expr = transformExpr(pstate, warg, precedence); - if (! coerce_to_boolean(pstate, &neww->expr)) + if (!coerce_to_boolean(pstate, &neww->expr)) elog(ERROR, "WHEN clause must have a boolean result"); /* @@ -541,11 +542,11 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) case T_BooleanTest: { - BooleanTest *b = (BooleanTest *) expr; + BooleanTest *b = (BooleanTest *) expr; b->arg = transformExpr(pstate, b->arg, precedence); - if (! coerce_to_boolean(pstate, &b->arg)) + if (!coerce_to_boolean(pstate, &b->arg)) { const char *clausename; @@ -572,7 +573,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) default: elog(ERROR, "transformExpr: unexpected booltesttype %d", (int) b->booltesttype); - clausename = NULL; /* keep compiler quiet */ + clausename = NULL; /* keep compiler quiet */ } elog(ERROR, "Argument of %s must be boolean", @@ -645,7 +646,7 @@ transformIdent(ParseState *pstate, Ident *ident, int precedence) * appear */ if (ident->indirection == NIL && - refnameRangeOrJoinEntry(pstate, ident->name, &sublevels_up) != NULL) + refnameRangeOrJoinEntry(pstate, ident->name, &sublevels_up) != NULL) { ident->isRel = TRUE; result = (Node *) ident; @@ -1023,7 +1024,6 @@ TypeNameToInternalName(TypeName *typename) Assert(typename->attrname == NULL); if (typename->arrayBounds != NIL) { - /* * By convention, the name of an array type is the name of its * element type with "_" prepended. diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index fc85ca8952..f6d94e5c55 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.111 2001/10/04 22:06:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.112 2001/10/25 05:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,16 +106,16 @@ ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int precedence) } /* - * parse function + * parse function * - * This code is confusing because the database can accept - * relation.column, column.function, or relation.column.function. + * This code is confusing because the database can accept + * relation.column, column.function, or relation.column.function. * In these cases, funcname is the last parameter, and fargs are - * the rest. + * the rest. * - * It can also be called as func(col) or func(col,col). - * In this case, Funcname is the part before parens, and fargs - * are the part in parens. + * It can also be called as func(col) or func(col,col). + * In this case, Funcname is the part before parens, and fargs + * are the part in parens. * * FYI, projection is choosing column from a table. * @@ -146,10 +146,10 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, Expr *expr; /* - * Most of the rest of the parser just assumes that functions do - * not have more than FUNC_MAX_ARGS parameters. We have to test - * here to protect against array overruns, etc. Of course, this - * may not be a function, but the test doesn't hurt. + * Most of the rest of the parser just assumes that functions do not + * have more than FUNC_MAX_ARGS parameters. We have to test here to + * protect against array overruns, etc. Of course, this may not be a + * function, but the test doesn't hurt. */ if (nargs > FUNC_MAX_ARGS) elog(ERROR, "Cannot pass more than %d arguments to a function", @@ -165,15 +165,15 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, /* * test for relation.column * - * check for projection methods: if function takes one argument, and - * that argument is a relation, param, or PQ function returning a - * complex * type, then the function could be a projection. + * check for projection methods: if function takes one argument, and that + * argument is a relation, param, or PQ function returning a complex * + * type, then the function could be a projection. */ /* We only have one parameter, and it's not got aggregate decoration */ if (nargs == 1 && !must_be_agg) { /* Is it a plain Relation name from the parser? */ - if (IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel) + if (IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel) { Ident *ident = (Ident *) first_arg; @@ -188,7 +188,6 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, } else if (ISCOMPLEX(exprType(first_arg))) { - /* * Attempt to handle projection of a complex argument. If * ParseComplexProjection can't handle the projection, we have @@ -231,7 +230,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (nargs != 1) elog(ERROR, "Aggregate functions may only have one parameter"); /* Agg's argument can't be a relation name, either */ - if (IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel) + if (IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel) elog(ERROR, "Aggregate functions cannot be applied to relation names"); could_be_agg = true; } @@ -239,7 +238,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, { /* Try to parse as an aggregate if above-mentioned checks are OK */ could_be_agg = (nargs == 1) && - !(IsA(first_arg, Ident) && ((Ident *) first_arg)->isRel); + !(IsA(first_arg, Ident) &&((Ident *) first_arg)->isRel); } if (could_be_agg) @@ -295,7 +294,6 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (must_be_agg) { - /* * No matching agg, but we had '*' or DISTINCT, so a plain * function could not have been meant. @@ -318,7 +316,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, { Node *arg = lfirst(i); - if (IsA(arg, Ident) && ((Ident *) arg)->isRel) + if (IsA(arg, Ident) &&((Ident *) arg)->isRel) { RangeTblEntry *rte; int vnum; @@ -339,9 +337,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, rte = (RangeTblEntry *) rteorjoin; else if (IsA(rteorjoin, JoinExpr)) { - /* - * The relation name refers to a join. We can't support + * The relation name refers to a join. We can't support * functions on join tuples (since we don't have a named * type for the join tuples), so error out. */ @@ -360,8 +357,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, else { /* - * There are multiple arguments, so it must be a function - * call. + * There are multiple arguments, so it must be a + * function call. */ elog(ERROR, "Cannot pass result of join %s to a function", refname); @@ -378,24 +375,26 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, vnum = RTERangeTablePosn(pstate, rte, &sublevels_up); /* - * The parameter to be passed to the function is the whole tuple - * from the relation. We build a special VarNode to reflect - * this -- it has varno set to the correct range table entry, - * but has varattno == 0 to signal that the whole tuple is the - * argument. Also, it has typmod set to sizeof(Pointer) to - * signal that the runtime representation will be a pointer - * not an Oid. + * The parameter to be passed to the function is the whole + * tuple from the relation. We build a special VarNode to + * reflect this -- it has varno set to the correct range table + * entry, but has varattno == 0 to signal that the whole tuple + * is the argument. Also, it has typmod set to + * sizeof(Pointer) to signal that the runtime representation + * will be a pointer not an Oid. */ if (rte->relname == NULL) { /* - * RTE is a subselect; must fail for lack of a specific type + * RTE is a subselect; must fail for lack of a specific + * type */ if (nargs == 1) { /* - * Here, we probably have an unrecognized attribute of a - * sub-select; again can't tell if it was x.f or f(x) + * Here, we probably have an unrecognized attribute of + * a sub-select; again can't tell if it was x.f or + * f(x) */ elog(ERROR, "No such attribute or function %s.%s", refname, funcname); @@ -449,14 +448,14 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, } else { - FuncDetailCode fdresult; + FuncDetailCode fdresult; /* * 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, @@ -464,8 +463,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (fdresult == FUNCDETAIL_COERCION) { /* - * We can do it as a trivial coercion. - * coerce_type can handle these cases, so why duplicate code... + * We can do it as a trivial coercion. coerce_type can handle + * these cases, so why duplicate code... */ return coerce_type(pstate, lfirst(fargs), oid_array[0], rettype, -1); @@ -1019,7 +1018,6 @@ func_select_candidate(int nargs, } else { - /* * Remember conflict, but keep going (might find * STRING) @@ -1101,7 +1099,7 @@ func_select_candidate(int nargs, * (exact match) is as quick as possible. * * If an exact match isn't found: - * 1) check for possible interpretation as a trivial type coercion + * 1) check for possible interpretation as a trivial type coercion * 2) get a vector of all possible input arg type arrays constructed * from the superclasses of the original input arg types * 3) get a list of all possible argument type arrays to the function @@ -1145,23 +1143,24 @@ func_get_detail(char *funcname, * that this is really a type-coercion request: a single-argument * function call where the function name is a type name. If so, * and if we can do the coercion trivially (no run-time function - * call needed), then go ahead and treat the "function call" as - * a coercion. This interpretation needs to be given higher - * priority than interpretations involving a type coercion followed - * by a function call, otherwise we can produce surprising results. - * For example, we want "text(varchar)" to be interpreted as a - * trivial coercion, not as "text(name(varchar))" which the code - * below this point is entirely capable of selecting. + * call needed), then go ahead and treat the "function call" as a + * coercion. This interpretation needs to be given higher + * priority than interpretations involving a type coercion + * followed by a function call, otherwise we can produce + * surprising results. For example, we want "text(varchar)" to be + * interpreted as a trivial coercion, not as "text(name(varchar))" + * which the code below this point is entirely capable of + * selecting. * - * "Trivial" coercions are ones that involve binary-compatible - * types and ones that are coercing a previously-unknown-type - * literal constant to a specific type. + * "Trivial" coercions are ones that involve binary-compatible types + * and ones that are coercing a previously-unknown-type literal + * constant to a specific type. * * NB: it's important that this code stays in sync with what * coerce_type can do, because the caller will try to apply * coerce_type if we return FUNCDETAIL_COERCION. If we return - * that result for something coerce_type can't handle, we'll - * cause infinite recursion between this module and coerce_type! + * that result for something coerce_type can't handle, we'll cause + * infinite recursion between this module and coerce_type! */ if (nargs == 1) { @@ -1627,7 +1626,6 @@ ParseComplexProjection(ParseState *pstate, } case T_Var: { - /* * The argument is a set, so this is either a projection * or a function call on this set. diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 8625af7b96..d03c6b6403 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.55 2001/08/09 18:28:18 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.56 2001/10/25 05:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -235,7 +235,7 @@ make_var(ParseState *pstate, RangeTblEntry *rte, int attrno) * forceSlice If true, treat subscript as array slice in all cases * assignFrom NULL for array fetch, else transformed expression for source. */ -ArrayRef * +ArrayRef * transformArraySubscripts(ParseState *pstate, Node *arrayBase, Oid arrayType, @@ -467,7 +467,7 @@ make_const(Value *value) case T_String: val = DirectFunctionCall1(textin, CStringGetDatum(strVal(value))); - typeid = UNKNOWNOID;/* will be coerced later */ + typeid = UNKNOWNOID; /* will be coerced later */ typelen = -1; /* variable len */ typebyval = false; break; diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 8fb8856658..15a39dc84b 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.50 2001/08/09 18:28:18 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.51 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -481,7 +481,6 @@ oper_select_candidate(int nargs, } else { - /* * Remember conflict, but keep going (might find * STRING) @@ -835,7 +834,6 @@ right_oper(char *op, Oid arg) unary_op_error(op, arg, FALSE); else { - /* * We must run oper_select_candidate even if only one * candidate, otherwise we may falsely return a @@ -892,7 +890,6 @@ left_oper(char *op, Oid arg) unary_op_error(op, arg, TRUE); else { - /* * We must run oper_select_candidate even if only one * candidate, otherwise we may falsely return a @@ -957,11 +954,11 @@ unary_op_error(char *op, Oid arg, bool is_left_op) { if (is_left_op) elog(ERROR, "Unable to identify a prefix operator '%s' for type '%s'" - "\n\tYou may need to add parentheses or an explicit cast", + "\n\tYou may need to add parentheses or an explicit cast", op, format_type_be(arg)); else elog(ERROR, "Unable to identify a postfix operator '%s' for type '%s'" - "\n\tYou may need to add parentheses or an explicit cast", + "\n\tYou may need to add parentheses or an explicit cast", op, format_type_be(arg)); } } diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 10861bf273..388ddf1d1f 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.58 2001/10/23 17:39:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.59 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -967,7 +967,7 @@ specialAttNum(char *a) { Form_pg_attribute sysatt; - sysatt = SystemAttributeByName(a, true /* "oid" will be accepted */); + sysatt = SystemAttributeByName(a, true /* "oid" will be accepted */ ); if (sysatt != NULL) return sysatt->attnum; return InvalidAttrNumber; diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 801dde811c..b4375d67d8 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.74 2001/10/08 21:48:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.75 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ static List *ExpandAllTables(ParseState *pstate); static char *FigureColname(Node *node); -static int FigureColnameInternal(Node *node, char **name); +static int FigureColnameInternal(Node *node, char **name); /* @@ -57,8 +57,8 @@ transformTargetEntry(ParseState *pstate, if (expr == NULL) expr = transformExpr(pstate, node, EXPR_COLUMN_FIRST); - if (IsA(expr, Ident) && ((Ident *)expr)->isRel) - elog(ERROR,"You can't use relation names alone in the target list, try relation.*."); + if (IsA(expr, Ident) &&((Ident *) expr)->isRel) + elog(ERROR, "You can't use relation names alone in the target list, try relation.*."); type_id = exprType(expr); type_mod = exprTypmod(expr); @@ -104,7 +104,6 @@ transformTargetList(ParseState *pstate, List *targetlist) if (att->relname != NULL && strcmp(att->relname, "*") == 0) { - /* * Target item is a single '*', expand all tables (eg. * SELECT * FROM emp) @@ -115,7 +114,6 @@ transformTargetList(ParseState *pstate, List *targetlist) else if (att->attrs != NIL && strcmp(strVal(lfirst(att->attrs)), "*") == 0) { - /* * Target item is relation.*, expand that table (eg. * SELECT emp.*, dname FROM emp, dept) @@ -221,7 +219,6 @@ updateTargetListEntry(ParseState *pstate, if (pstate->p_is_insert) { - /* * The command is INSERT INTO table (arraycol[subscripts]) ... * so there is not really a source array value to work with. @@ -234,7 +231,6 @@ updateTargetListEntry(ParseState *pstate, } else { - /* * Build a Var for the array to be updated. */ @@ -253,7 +249,6 @@ updateTargetListEntry(ParseState *pstate, } else { - /* * For normal non-subscripted target column, do type checking and * coercion. But accept InvalidOid, which indicates the source is @@ -347,7 +342,6 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) if (cols == NIL) { - /* * Generate default column list for INSERT. */ @@ -373,7 +367,6 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) } else { - /* * Do initial validation of user-supplied INSERT column list. */ @@ -461,7 +454,7 @@ ExpandAllTables(ParseState *pstate) static char * FigureColname(Node *node) { - char *name = NULL; + char *name = NULL; FigureColnameInternal(node, &name); if (name != NULL) @@ -473,7 +466,7 @@ FigureColname(Node *node) static int FigureColnameInternal(Node *node, char **name) { - int strength = 0; + int strength = 0; if (node == NULL) return strength; @@ -506,7 +499,7 @@ FigureColnameInternal(Node *node, char **name) return 1; } break; - case T_TypeCast: + case T_TypeCast: strength = FigureColnameInternal(((TypeCast *) node)->arg, name); if (strength <= 1) diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index ed010a46ed..732974a96f 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.36 2001/10/09 04:15:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.37 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -139,7 +139,6 @@ typeTypElem(Type typ) return typtup->typelem; } - #endif #ifdef NOT_USED @@ -153,7 +152,6 @@ typeInfunc(Type typ) return typtup->typinput; } - #endif #ifdef NOT_USED @@ -167,7 +165,6 @@ typeOutfunc(Type typ) return typtup->typoutput; } - #endif /* Given a type structure and a string, returns the internal form of @@ -207,7 +204,6 @@ typeidOutfunc(Oid type_id) ReleaseSysCache(typeTuple); return outfunc; } - #endif /* return a type name, given a typeid */ @@ -279,12 +275,12 @@ typenameTypeId(char *s) void parseTypeString(const char *str, Oid *type_id, int32 *typmod) { - char *buf; - List *raw_parsetree_list; + char *buf; + List *raw_parsetree_list; SelectStmt *stmt; - ResTarget *restarget; - A_Const *aconst; - TypeName *typename; + ResTarget *restarget; + A_Const *aconst; + TypeName *typename; buf = (char *) palloc(strlen(str) + 16); sprintf(buf, "SELECT (NULL::%s)", str); diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index 11f1fa6df3..7808705b37 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.49 2001/03/22 03:59:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.50 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,6 @@ #if defined(FLEX_SCANNER) extern void DeleteBuffer(void); - #endif /* FLEX_SCANNER */ char *parseString; /* the char* which holds the string to be diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index 66baed8840..3ee00fed6c 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.20 2001/01/24 19:43:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.21 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,6 @@ scanstr(char *s) { if (s[i] == '\'') { - /* * Note: if scanner is working right, unescaped quotes can * only appear in pairs, so there should be another character. diff --git a/src/backend/port/beos/sem.c b/src/backend/port/beos/sem.c index 3b829817ee..6609f1dde0 100644 --- a/src/backend/port/beos/sem.c +++ b/src/backend/port/beos/sem.c @@ -121,7 +121,6 @@ semctl(int semId, int semNum, int flag, union semun semun) TRACEDBGP("->semctl nmbre %d", Address[0]); for (i = 0; i < Address[0]; i++) { - /* * Make sure to have ownership of the semaphore (if created by * another team) @@ -294,7 +293,6 @@ semop(int semId, struct sembuf * sops, int nsops) /* For each sem in the pool, check the operation to perform */ if (sops[i].sem_op < 0) { - /* * Try acuiring the semaphore till we are not inteerupted by a * signal diff --git a/src/backend/port/beos/shm.c b/src/backend/port/beos/shm.c index 56e44d3853..7903ce74ad 100644 --- a/src/backend/port/beos/shm.c +++ b/src/backend/port/beos/shm.c @@ -48,7 +48,6 @@ shmat(int memId, int m1, int m2) if (ainfo.team == teinfo.team) { - /* * the area is already in our address space, just return the * address @@ -57,7 +56,6 @@ shmat(int memId, int m1, int m2) } else { - /* * the area is not in our address space, clone it before and * return the address diff --git a/src/backend/port/beos/support.c b/src/backend/port/beos/support.c index 936c151e86..996615e6fa 100644 --- a/src/backend/port/beos/support.c +++ b/src/backend/port/beos/support.c @@ -116,19 +116,17 @@ beos_dl_open(char *filename) } void -beos_dl_sym(image_id im,char* symname,void** fptr) +beos_dl_sym(image_id im, char *symname, void **fptr) { /* Send command '3' (get symbol) to the support server */ write_port(beos_dl_port_in, 3, symname, strlen(symname) + 1); - write_port(beos_dl_port_in, im, NULL,0); + write_port(beos_dl_port_in, im, NULL, 0); /* Read sym address */ - read_port(beos_dl_port_out, (int32*)(fptr), NULL, 0); + read_port(beos_dl_port_out, (int32 *) (fptr), NULL, 0); - if (fptr==NULL) - { + if (fptr == NULL) elog(NOTICE, "loading symbol '%s' failed ", symname); - } } status_t @@ -149,7 +147,6 @@ beos_startup(int argc, char **argv) { if (strlen(argv[0]) >= 10 && !strcmp(argv[0] + strlen(argv[0]) - 10, "postmaster")) { - /* * We are in the postmaster, create the protection semaphore for * shared mem remapping @@ -180,13 +177,13 @@ beos_startup(int argc, char **argv) * server */ read_port(port_in, &opcode, datas, 4000); - + switch (opcode) { image_id addon; image_info info_im; area_info info_ar; - void * fpt; + void *fpt; /* Load Add-On */ case 1: @@ -226,32 +223,32 @@ beos_startup(int argc, char **argv) break; /* Cleanup and exit */ case 3: - + /* read image Id on the input port */ - read_port(port_in, &addon,NULL,0); + read_port(port_in, &addon, NULL, 0); /* Loading symbol */ - fpt=NULL; - - - if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK); - { + fpt = NULL; + + if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK); + { /* - * Sometime the loader return B_OK for an inexistant function - * with an invalid address !!! Check that the return address - * is in the image range - */ + * Sometime the loader return B_OK for an + * inexistant function with an invalid address !!! + * Check that the return address is in the image + * range + */ get_image_info(addon, &info_im); if ((fpt < info_im.text) ||(fpt >= (info_im.text +info_im.text_size))) - fpt=NULL; + fpt = NULL; } /* Send back fptr of data segment */ - write_port(port_out, (int32)(fpt),NULL,0); + write_port(port_out, (int32) (fpt), NULL, 0); break; - + default: /* Free system resources */ delete_port(port_in); diff --git a/src/backend/port/darwin/sem.c b/src/backend/port/darwin/sem.c index 83fc1bf118..abb52c0b90 100644 --- a/src/backend/port/darwin/sem.c +++ b/src/backend/port/darwin/sem.c @@ -10,7 +10,7 @@ * - this required changing sem_info from containig an array of sem_t to an array of sem_t* * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/darwin/Attic/sem.c,v 1.4 2001/09/07 00:27:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/darwin/Attic/sem.c,v 1.5 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,10 +47,9 @@ struct sem_set_info key_t key; int nsems; sem_t *sem[SEMMAX]; /* array of POSIX semaphores */ - struct sem semV[SEMMAX]; /* array of System V semaphore - * structures */ - struct pending_ops pendingOps[SEMMAX]; /* array of pending - * operations */ + struct sem semV[SEMMAX]; /* array of System V semaphore structures */ + struct pending_ops pendingOps[SEMMAX]; /* array of pending + * operations */ }; struct sem_info @@ -58,7 +57,7 @@ struct sem_info sem_t *sem; int nsets; /* there are actually nsets of these: */ - struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */ + struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */ }; static struct sem_info *SemInfo = (struct sem_info *) - 1; @@ -171,7 +170,7 @@ semget(key_t key, int nsems, int semflg) shm_unlink(SHM_INFO_NAME); /* The size may only be set once. Ignore errors. */ nsets = PROC_SEM_MAP_ENTRIES(MaxBackends); - sem_info_size = sizeof(struct sem_info) + (nsets-1) * sizeof(struct sem_set_info); + sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info); ftruncate(fd, sem_info_size); SemInfo = mmap(NULL, sem_info_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); @@ -260,13 +259,13 @@ semget(key_t key, int nsems, int semflg) /* Currently sem_init always returns -1. */ #ifdef NOT_USED - if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 ) { - int semnum1; + if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1) + { + int semnum1; - for( semnum1 = 0; semnum1 < semnum; semnum1++ ) { - sem_close( SemInfo->set[semid].sem[semnum1] ); - } - sem_post( SemInfo->sem ); + for (semnum1 = 0; semnum1 < semnum; semnum1++) + sem_close(SemInfo->set[semid].sem[semnum1]); + sem_post(SemInfo->sem); return -1; } #endif diff --git a/src/backend/port/dynloader/aix.c b/src/backend/port/dynloader/aix.c index 44ae28d67d..46ef63a766 100644 --- a/src/backend/port/dynloader/aix.c +++ b/src/backend/port/dynloader/aix.c @@ -537,7 +537,6 @@ readExports(ModulePtr mp) symname = ls->l_offset + lhp->l_stoff + ldbuf; else { - /* * The l_name member is not zero terminated, we must copy the * first SYMNMLEN chars and make sure we have a zero byte at @@ -608,5 +607,4 @@ findMain(void) free(buf); return ret; } - #endif /* HAVE_DLOPEN */ diff --git a/src/backend/port/dynloader/aix.h b/src/backend/port/dynloader/aix.h index a0320727f3..203e56264a 100644 --- a/src/backend/port/dynloader/aix.h +++ b/src/backend/port/dynloader/aix.h @@ -1,5 +1,5 @@ /* - * $Id: aix.h,v 1.6 2001/05/14 21:45:53 petere Exp $ + * $Id: aix.h,v 1.7 2001/10/25 05:49:40 momjian Exp $ * * @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52 * This is an unpublished work copyright (c) 1992 HELIOS Software GmbH @@ -51,9 +51,7 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* HAVE_DLOPEN */ #include "utils/dynamic_loader.h" @@ -62,5 +60,4 @@ extern "C" #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/beos.c b/src/backend/port/dynloader/beos.c index 0a0f5fbef8..f91ffe1804 100644 --- a/src/backend/port/dynloader/beos.c +++ b/src/backend/port/dynloader/beos.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.8 2001/08/07 16:56:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/beos.c,v 1.9 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,7 @@ pg_dlsym(void *handle, char *funcname) /* Checking that "Handle" is valid */ if ((handle) && ((*(int *) (handle)) >= 0)) { - beos_dl_sym(*((int *) (handle)),funcname,(void **) &fpt); + beos_dl_sym(*((int *) (handle)), funcname, (void **) &fpt); return fpt; } elog(NOTICE, "add-on not loaded correctly"); diff --git a/src/backend/port/dynloader/beos.h b/src/backend/port/dynloader/beos.h index bec6743dca..dadf5f71b1 100644 --- a/src/backend/port/dynloader/beos.h +++ b/src/backend/port/dynloader/beos.h @@ -7,12 +7,11 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: beos.h,v 1.4 2001/01/24 19:43:04 momjian Exp $ + * $Id: beos.h,v 1.5 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef PORT_PROTOS_H #define PORT_PROTOS_H - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/bsdi.c b/src/backend/port/dynloader/bsdi.c index bfa7ec9e77..c16af323a1 100644 --- a/src/backend/port/dynloader/bsdi.c +++ b/src/backend/port/dynloader/bsdi.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dynloader/bsdi.c,v 1.15 2001/05/30 18:32:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/bsdi.c,v 1.16 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -94,5 +94,4 @@ pg_dlerror() { return dld_strerror(dld_errno); } - -#endif /* not HAVE_DLOPEN */ +#endif /* not HAVE_DLOPEN */ diff --git a/src/backend/port/dynloader/bsdi.h b/src/backend/port/dynloader/bsdi.h index 2ea466317c..7d38de8277 100644 --- a/src/backend/port/dynloader/bsdi.h +++ b/src/backend/port/dynloader/bsdi.h @@ -24,7 +24,7 @@ #define pg_dlclose dlclose #define pg_dlerror dlerror -#else /* not HAVE_DLOPEN */ +#else /* not HAVE_DLOPEN */ #define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname))) #define pg_dlclose(handle) \ @@ -32,7 +32,5 @@ do { \ dld_unlink_by_file(handle, 1); \ free(handle); \ } while (0) - -#endif /* not HAVE_DLOPEN */ - +#endif /* not HAVE_DLOPEN */ #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/dgux.h b/src/backend/port/dynloader/dgux.h index 15fb78a90b..8246906702 100644 --- a/src/backend/port/dynloader/dgux.h +++ b/src/backend/port/dynloader/dgux.h @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dgux.h,v 1.10 2001/05/14 21:45:53 petere Exp $ + * $Id: dgux.h,v 1.11 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/freebsd.c b/src/backend/port/dynloader/freebsd.c index c2a2e31f27..74f0b005e5 100644 --- a/src/backend/port/dynloader/freebsd.c +++ b/src/backend/port/dynloader/freebsd.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; - #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/src/backend/port/dynloader/freebsd.h b/src/backend/port/dynloader/freebsd.h index ce5069f876..c7e36525ac 100644 --- a/src/backend/port/dynloader/freebsd.h +++ b/src/backend/port/dynloader/freebsd.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: freebsd.h,v 1.10 2001/05/15 16:55:27 petere Exp $ + * $Id: freebsd.h,v 1.11 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,5 +43,4 @@ char *BSD44_derived_dlerror(void); void *BSD44_derived_dlopen(const char *filename, int num); void *BSD44_derived_dlsym(void *handle, const char *name); void BSD44_derived_dlclose(void *handle); - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/hpux.c b/src/backend/port/dynloader/hpux.c index 967967e026..7cc539b14a 100644 --- a/src/backend/port/dynloader/hpux.c +++ b/src/backend/port/dynloader/hpux.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dynloader/hpux.c,v 1.18 2001/03/22 03:59:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/hpux.c,v 1.19 2001/10/25 05:49:40 momjian Exp $ * * NOTES * all functions are defined here -- it's impossible to trace the @@ -28,7 +28,6 @@ void * pg_dlopen(char *filename) { - /* * Use BIND_IMMEDIATE so that undefined symbols cause a failure return * from shl_load(), rather than an abort() later on when we attempt to diff --git a/src/backend/port/dynloader/irix5.h b/src/backend/port/dynloader/irix5.h index a4a5d134b6..f5e53bfc1b 100644 --- a/src/backend/port/dynloader/irix5.h +++ b/src/backend/port/dynloader/irix5.h @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/linux.c b/src/backend/port/dynloader/linux.c index 7de38938cf..796f22d3f2 100644 --- a/src/backend/port/dynloader/linux.c +++ b/src/backend/port/dynloader/linux.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.18 2001/01/24 19:43:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.19 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -107,5 +107,4 @@ pg_dlerror() return dld_strerror(dld_errno); #endif } - #endif diff --git a/src/backend/port/dynloader/linux.h b/src/backend/port/dynloader/linux.h index 290771cfc0..2077a6a676 100644 --- a/src/backend/port/dynloader/linux.h +++ b/src/backend/port/dynloader/linux.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: linux.h,v 1.13 2001/10/25 01:29:37 momjian Exp $ + * $Id: linux.h,v 1.14 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,16 +31,13 @@ do { \ dld_unlink_by_file(handle, 1); \ free(handle); \ } while (0) - #endif -#else /* HAVE_DLOPEN */ +#else /* HAVE_DLOPEN */ #define pg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL) #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - -#endif /* HAVE_DLOPEN */ - +#endif /* HAVE_DLOPEN */ #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/netbsd.c b/src/backend/port/dynloader/netbsd.c index f2fd6666a2..dc28e3e9c4 100644 --- a/src/backend/port/dynloader/netbsd.c +++ b/src/backend/port/dynloader/netbsd.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; - #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/src/backend/port/dynloader/netbsd.h b/src/backend/port/dynloader/netbsd.h index a1b48fa830..85cdfa3a85 100644 --- a/src/backend/port/dynloader/netbsd.h +++ b/src/backend/port/dynloader/netbsd.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: netbsd.h,v 1.5 2001/05/15 16:55:27 petere Exp $ + * $Id: netbsd.h,v 1.6 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,5 +43,4 @@ char *BSD44_derived_dlerror(void); void *BSD44_derived_dlopen(const char *filename, int num); void *BSD44_derived_dlsym(void *handle, const char *name); void BSD44_derived_dlclose(void *handle); - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/nextstep.h b/src/backend/port/dynloader/nextstep.h index d86c2c5cea..510243a1ac 100644 --- a/src/backend/port/dynloader/nextstep.h +++ b/src/backend/port/dynloader/nextstep.h @@ -22,5 +22,4 @@ char *next_dlerror(void); #define pg_dlerror next_dlerror /* port.c */ - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/openbsd.c b/src/backend/port/dynloader/openbsd.c index f2fd6666a2..dc28e3e9c4 100644 --- a/src/backend/port/dynloader/openbsd.c +++ b/src/backend/port/dynloader/openbsd.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; - #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/src/backend/port/dynloader/openbsd.h b/src/backend/port/dynloader/openbsd.h index 557003a5a0..899f213011 100644 --- a/src/backend/port/dynloader/openbsd.h +++ b/src/backend/port/dynloader/openbsd.h @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: openbsd.h,v 1.6 2001/06/20 18:33:31 petere Exp $ + * $Id: openbsd.h,v 1.7 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ char *BSD44_derived_dlerror(void); void *BSD44_derived_dlopen(const char *filename, int num); void *BSD44_derived_dlsym(void *handle, const char *name); void BSD44_derived_dlclose(void *handle); - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/osf.h b/src/backend/port/dynloader/osf.h index 61961b02d6..e24ae4f85d 100644 --- a/src/backend/port/dynloader/osf.h +++ b/src/backend/port/dynloader/osf.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: osf.h,v 1.3 2001/05/14 21:45:53 petere Exp $ + * $Id: osf.h,v 1.4 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ #define pg_dlsym(h, f) ((PGFunction) dlsym(h, f)) #define pg_dlclose(h) dlclose(h) #define pg_dlerror() dlerror() - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/sco.h b/src/backend/port/dynloader/sco.h index 70ead4fa8d..577706d27e 100644 --- a/src/backend/port/dynloader/sco.h +++ b/src/backend/port/dynloader/sco.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sco.h,v 1.8 2001/05/14 21:45:53 petere Exp $ + * $Id: sco.h,v 1.9 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ #define pg_dlerror dlerror /* port.c */ - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/solaris.h b/src/backend/port/dynloader/solaris.h index e4b81f435f..ca920923c4 100644 --- a/src/backend/port/dynloader/solaris.h +++ b/src/backend/port/dynloader/solaris.h @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/solaris.h,v 1.4 2001/05/14 21:45:53 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/solaris.h,v 1.5 2001/10/25 05:49:40 momjian Exp $ */ #ifndef DYNLOADER_SOLARIS_H #define DYNLOADER_SOLARIS_H @@ -10,5 +10,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* DYNLOADER_SOLARIS_H */ diff --git a/src/backend/port/dynloader/sunos4.h b/src/backend/port/dynloader/sunos4.h index 49040c1dea..fee5f00a3b 100644 --- a/src/backend/port/dynloader/sunos4.h +++ b/src/backend/port/dynloader/sunos4.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sunos4.h,v 1.8 2001/05/14 21:45:53 petere Exp $ + * $Id: sunos4.h,v 1.9 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/svr4.h b/src/backend/port/dynloader/svr4.h index 96c39ea2ec..af3d6d54f9 100644 --- a/src/backend/port/dynloader/svr4.h +++ b/src/backend/port/dynloader/svr4.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: svr4.h,v 1.8 2001/05/14 21:45:53 petere Exp $ + * $Id: svr4.h,v 1.9 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* DYNLOADER_H */ diff --git a/src/backend/port/dynloader/ultrix4.h b/src/backend/port/dynloader/ultrix4.h index 817398d7f4..68504d0ac2 100644 --- a/src/backend/port/dynloader/ultrix4.h +++ b/src/backend/port/dynloader/ultrix4.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: ultrix4.h,v 1.7 2001/01/24 19:43:04 momjian Exp $ + * $Id: ultrix4.h,v 1.8 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,9 +55,9 @@ typedef struct ScnInfo typedef enum { - DL_NEEDRELOC, /* still need relocation */ - DL_RELOCATED, /* no relocation necessary */ - DL_INPROG /* relocation in progress */ + DL_NEEDRELOC, /* still need relocation */ + DL_RELOCATED, /* no relocation necessary */ + DL_INPROG /* relocation in progress */ } dlRStatus; typedef struct JmpTbl @@ -120,5 +120,4 @@ extern char *dl_error( /* void */ ); extern char **dl_undefinedSymbols( /* int *count */ ); extern void dl_printAllSymbols( /* void *handle */ ); extern void dl_setLibraries( /* char *libs */ ); - #endif /* _DL_HEADER_ */ diff --git a/src/backend/port/dynloader/univel.h b/src/backend/port/dynloader/univel.h index 83f0e2c82a..694d87c3fa 100644 --- a/src/backend/port/dynloader/univel.h +++ b/src/backend/port/dynloader/univel.h @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/unixware.h b/src/backend/port/dynloader/unixware.h index 5c1b04cc69..0d0b80721d 100644 --- a/src/backend/port/dynloader/unixware.h +++ b/src/backend/port/dynloader/unixware.h @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/win.h b/src/backend/port/dynloader/win.h index d0d33189b7..0bc8cdb062 100644 --- a/src/backend/port/dynloader/win.h +++ b/src/backend/port/dynloader/win.h @@ -30,5 +30,4 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/inet_aton.c b/src/backend/port/inet_aton.c index 81f20da967..8f7c4e255a 100644 --- a/src/backend/port/inet_aton.c +++ b/src/backend/port/inet_aton.c @@ -1,4 +1,4 @@ -/* $Id: inet_aton.c,v 1.19 2001/08/24 14:07:49 petere Exp $ +/* $Id: inet_aton.c,v 1.20 2001/10/25 05:49:40 momjian Exp $ * * This inet_aton() function was taken from the GNU C library and * incorporated into Postgres for those systems which do not have this @@ -67,7 +67,6 @@ inet_aton(const char *cp, struct in_addr * addr) for (;;) { - /* * Collect number up to ``.''. Values are specified as for C: * 0x=hex, 0=octal, other=decimal. @@ -100,7 +99,6 @@ inet_aton(const char *cp, struct in_addr * addr) } if (*cp == '.') { - /* * Internet format: a.b.c.d a.b.c (with c treated as * 16-bits) a.b (with b treated as 24 bits) diff --git a/src/backend/port/isinf.c b/src/backend/port/isinf.c index f589f47816..f660b8a443 100644 --- a/src/backend/port/isinf.c +++ b/src/backend/port/isinf.c @@ -1,4 +1,4 @@ -/* $Id: isinf.c,v 1.16 2001/08/24 14:07:49 petere Exp $ */ +/* $Id: isinf.c,v 1.17 2001/10/25 05:49:40 momjian Exp $ */ #include "c.h" @@ -42,7 +42,6 @@ double x; #else int fpclass = fp_class_d(x); - #endif if (fpclass == FP_POS_INF) @@ -64,7 +63,6 @@ isinf(double x) return -1; return 0; } - #endif #endif @@ -80,5 +78,4 @@ isinf(double x) return -1; return 0; } - #endif diff --git a/src/backend/port/nextstep/port.c b/src/backend/port/nextstep/port.c index 6ef1b126f4..8f6deeb44f 100644 --- a/src/backend/port/nextstep/port.c +++ b/src/backend/port/nextstep/port.c @@ -55,5 +55,4 @@ getcwd(char *buf, size_t size) { return getwd(buf); } - #endif diff --git a/src/backend/port/qnx4/ipc.h b/src/backend/port/qnx4/ipc.h index 3f1206d31f..291347de35 100644 --- a/src/backend/port/qnx4/ipc.h +++ b/src/backend/port/qnx4/ipc.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.3 2001/03/18 18:32:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/ipc.h,v 1.4 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ /* Control Commands. */ #define IPC_RMID 0 /* remove identifier */ #define IPC_STAT 1 /* get shm status */ - #endif /* _SYS_IPC_H */ diff --git a/src/backend/port/qnx4/sem.c b/src/backend/port/qnx4/sem.c index a25ba759ee..ed70d45229 100644 --- a/src/backend/port/qnx4/sem.c +++ b/src/backend/port/qnx4/sem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.7 2001/09/07 00:27:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.c,v 1.8 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,10 +48,9 @@ struct sem_set_info key_t key; int nsems; sem_t sem[SEMMAX]; /* array of POSIX semaphores */ - struct sem semV[SEMMAX]; /* array of System V semaphore - * structures */ - struct pending_ops pendingOps[SEMMAX]; /* array of pending - * operations */ + struct sem semV[SEMMAX]; /* array of System V semaphore structures */ + struct pending_ops pendingOps[SEMMAX]; /* array of pending + * operations */ }; struct sem_info @@ -59,21 +58,21 @@ struct sem_info sem_t sem; int nsets; /* there are actually nsets of these: */ - struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */ + struct sem_set_info set[1]; /* VARIABLE LENGTH ARRAY */ }; static struct sem_info *SemInfo = (struct sem_info *) - 1; /* ---------------------------------------------------------------- * semclean - remove the shared memory file on exit - * only called by the process which created the shm file + * only called by the process which created the shm file * ---------------------------------------------------------------- */ static void -semclean( void ) +semclean(void) { - remove( "/dev/shmem/" SHM_INFO_NAME ); + remove("/dev/shmem/" SHM_INFO_NAME); } int @@ -175,30 +174,31 @@ semget(key_t key, int nsems, int semflg) return fd; /* The size may only be set once. Ignore errors. */ nsets = PROC_SEM_MAP_ENTRIES(MaxBackends); - sem_info_size = sizeof(struct sem_info) + (nsets-1) * sizeof(struct sem_set_info); + sem_info_size = sizeof(struct sem_info) + (nsets - 1) * sizeof(struct sem_set_info); ltrunc(fd, sem_info_size, SEEK_SET); - if ( fstat( fd, &statbuf ) ) /* would be strange : the only doc'ed */ - { /* error is EBADF */ - close( fd ); + if (fstat(fd, &statbuf))/* would be strange : the only doc'ed */ + { /* error is EBADF */ + close(fd); + return -1; + } + + /* + * size is rounded by proc to the next __PAGESIZE + */ + if (statbuf.st_size != + (((sem_info_size / __PAGESIZE) + 1) * __PAGESIZE)) + { + fprintf(stderr, + "Found a pre-existing shared memory block for the semaphore memory\n" + "of a different size (%ld instead %ld). Make sure that all executables\n" + "are from the same release or remove the file \"/dev/shmem/%s\"\n" + "left by a previous version.\n", + (long) statbuf.st_size, + (long) sem_info_size, + SHM_INFO_NAME); + errno = EACCES; return -1; } - /* - * size is rounded by proc to the next __PAGESIZE - */ - if ( statbuf.st_size != - (((sem_info_size/__PAGESIZE)+1) * __PAGESIZE) ) - { - fprintf( stderr, - "Found a pre-existing shared memory block for the semaphore memory\n" - "of a different size (%ld instead %ld). Make sure that all executables\n" - "are from the same release or remove the file \"/dev/shmem/%s\"\n" - "left by a previous version.\n", - (long) statbuf.st_size, - (long) sem_info_size, - SHM_INFO_NAME); - errno = EACCES; - return -1; - } SemInfo = mmap(NULL, sem_info_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (SemInfo == MAP_FAILED) @@ -212,7 +212,7 @@ semget(key_t key, int nsems, int semflg) SemInfo->set[semid].key = -1; /* create semaphore for locking */ sem_init(&SemInfo->sem, 1, 1); - on_proc_exit( semclean, 0 ); + on_proc_exit(semclean, 0); } } @@ -269,13 +269,13 @@ semget(key_t key, int nsems, int semflg) sem_init(&SemInfo->set[semid].sem[semnum], 1, 0); /* Currently sem_init always returns -1. */ #ifdef NOT_USED - if( sem_init( &SemInfo->set[semid].sem[semnum], 1, 0 ) == -1 ) { - int semnum1; + if (sem_init(&SemInfo->set[semid].sem[semnum], 1, 0) == -1) + { + int semnum1; - for( semnum1 = 0; semnum1 < semnum; semnum1++ ) { - sem_destroy( &SemInfo->set[semid].sem[semnum1] ); - } - sem_post( &SemInfo->sem ); + for (semnum1 = 0; semnum1 < semnum; semnum1++) + sem_destroy(&SemInfo->set[semid].sem[semnum1]); + sem_post(&SemInfo->sem); return -1; } #endif diff --git a/src/backend/port/qnx4/sem.h b/src/backend/port/qnx4/sem.h index c9fd18a05a..3ac7f6ff17 100644 --- a/src/backend/port/qnx4/sem.h +++ b/src/backend/port/qnx4/sem.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.3 2000/04/12 17:15:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/sem.h,v 1.4 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* _SYS_SEM_H */ diff --git a/src/backend/port/qnx4/shm.c b/src/backend/port/qnx4/shm.c index 466c4b4b40..cf42be4d85 100644 --- a/src/backend/port/qnx4/shm.c +++ b/src/backend/port/qnx4/shm.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.6 2001/08/24 14:07:49 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.c,v 1.7 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,8 +48,8 @@ static int shm_getinfobyaddr(const void *addr, struct shm_info * info); static char * keytoname(key_t key, char *name) { - sprintf( name,"PgShm%x", key ); - return name; + sprintf(name, "PgShm%x", key); + return name; } static int @@ -182,51 +182,53 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) { struct shm_info info; char name[NAME_MAX + 1]; - int result; - int fd; - struct stat statbuf; + int result; + int fd; + struct stat statbuf; - - switch( cmd ) - { - case IPC_RMID : - if (shm_getinfo(shmid, &info) == -1) - { - errno = EACCES; - return -1; - } - close( info.shmid ); - keytoname(info.key, name); - return shm_unlink( name ); - - case IPC_STAT : - /* - * we have to open it first. stat() does no prefix tracking - * -> the call would go to fsys instead of proc - */ - keytoname(shmid, name); - fd = shm_open( name, 0, MODE ); - if ( fd >= 0 ) - { - result = fstat( fd, &statbuf ); - /* - * if the file exists, subtract 2 from linkcount : - * one for our own open and one for the dir entry - */ - if ( ! result ) - buf->shm_nattch = statbuf.st_nlink-2; - close( fd ); - return result; - } - else + + switch (cmd) { - /* - * if there's no entry for this key it doesn't matter - * the next shmget() would get a different shm anyway - */ - buf->shm_nattch = 0; - return 0; - } + case IPC_RMID: + if (shm_getinfo(shmid, &info) == -1) + { + errno = EACCES; + return -1; + } + close(info.shmid); + keytoname(info.key, name); + return shm_unlink(name); + + case IPC_STAT: + + /* + * we have to open it first. stat() does no prefix tracking -> + * the call would go to fsys instead of proc + */ + keytoname(shmid, name); + fd = shm_open(name, 0, MODE); + if (fd >= 0) + { + result = fstat(fd, &statbuf); + + /* + * if the file exists, subtract 2 from linkcount : one for + * our own open and one for the dir entry + */ + if (!result) + buf->shm_nattch = statbuf.st_nlink - 2; + close(fd); + return result; + } + else + { + /* + * if there's no entry for this key it doesn't matter the + * next shmget() would get a different shm anyway + */ + buf->shm_nattch = 0; + return 0; + } } errno = EINVAL; return -1; @@ -258,13 +260,13 @@ shmget(key_t key, size_t size, int flags) info.key = key; info.size = size; info.addr = NULL; - if (shm_putinfo(&info) == -1) { - close( info.shmid ); - if ( (oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) ) { - shm_unlink( name ); - } + if (shm_putinfo(&info) == -1) + { + close(info.shmid); + if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) + shm_unlink(name); return -1; - } + } } /* The size may only be set once. Ignore errors. */ diff --git a/src/backend/port/qnx4/shm.h b/src/backend/port/qnx4/shm.h index 40fc9caa26..47d8a37658 100644 --- a/src/backend/port/qnx4/shm.h +++ b/src/backend/port/qnx4/shm.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.3 2001/03/18 18:32:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/shm.h,v 1.4 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* _SYS_SHM_H */ diff --git a/src/backend/port/qnx4/tstsem.c b/src/backend/port/qnx4/tstsem.c index 571a6def25..bd35e5706c 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.5 2001/08/24 14:07:49 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.6 2001/10/25 05:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,9 +40,9 @@ sig_handler(int sig_no) printf("semval = %d\n", i); } -void on_proc_exit( void (*function)(), Datum arg ) +void on_proc_exit(void (*function) (), Datum arg) { - atexit( function ); + atexit(function); } int main(int argc, char **argv) diff --git a/src/backend/port/snprintf.c b/src/backend/port/snprintf.c index bfd7705a2a..047e94fcfa 100644 --- a/src/backend/port/snprintf.c +++ b/src/backend/port/snprintf.c @@ -50,7 +50,6 @@ typedef unsigned long long ulong_long; #else typedef long long_long; typedef unsigned long ulong_long; - #endif /* @@ -75,7 +74,7 @@ typedef unsigned long ulong_long; * causing nast effects. **************************************************************/ -/*static char _id[] = "$Id: snprintf.c,v 1.30 2001/02/10 02:31:26 tgl Exp $";*/ +/*static char _id[] = "$Id: snprintf.c,v 1.31 2001/10/25 05:49:40 momjian Exp $";*/ static char *end; static int SnprfOverflow; diff --git a/src/backend/port/strcasecmp.c b/src/backend/port/strcasecmp.c index 32c21cb7c8..5bb34f8549 100644 --- a/src/backend/port/strcasecmp.c +++ b/src/backend/port/strcasecmp.c @@ -1,4 +1,4 @@ -/* $Id: strcasecmp.c,v 1.7 2001/01/24 19:43:03 momjian Exp $ */ +/* $Id: strcasecmp.c,v 1.8 2001/10/25 05:49:40 momjian Exp $ */ /* * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group @@ -15,7 +15,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; - #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/src/backend/port/strtol.c b/src/backend/port/strtol.c index 4e72275529..e6a7fb6d7b 100644 --- a/src/backend/port/strtol.c +++ b/src/backend/port/strtol.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; - #endif /* LIBC_SCCS and not lint */ #include <limits.h> diff --git a/src/backend/port/strtoul.c b/src/backend/port/strtoul.c index 0359791bd3..9481ccc4a0 100644 --- a/src/backend/port/strtoul.c +++ b/src/backend/port/strtoul.c @@ -33,7 +33,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93"; - #endif /* LIBC_SCCS and not lint */ #include <limits.h> diff --git a/src/backend/port/sunos4/float.h b/src/backend/port/sunos4/float.h index 5c138211c9..438deaf6ad 100644 --- a/src/backend/port/sunos4/float.h +++ b/src/backend/port/sunos4/float.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: float.h,v 1.6 2001/01/24 19:43:04 momjian Exp $ + * $Id: float.h,v 1.7 2001/10/25 05:49:40 momjian Exp $ * * NOTES * These come straight out of ANSI X3.159-1989 (p.18) and @@ -27,5 +27,4 @@ #define DBL_DIG 15 #define DBL_MIN 2.2250738585072014e-308 #define DBL_MAX 1.7976931348623157e+308 - #endif /* FLOAT_H */ diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 6aae169202..b77c129ddf 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.13 2001/10/22 19:41:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.14 2001/10/25 05:49:40 momjian Exp $ * ---------- */ #include "postgres.h" @@ -53,70 +53,70 @@ * GUC parameters * ---------- */ -bool pgstat_collect_startcollector = true; -bool pgstat_collect_resetonpmstart = true; -bool pgstat_collect_querystring = false; -bool pgstat_collect_tuplelevel = false; -bool pgstat_collect_blocklevel = false; +bool pgstat_collect_startcollector = true; +bool pgstat_collect_resetonpmstart = true; +bool pgstat_collect_querystring = false; +bool pgstat_collect_tuplelevel = false; +bool pgstat_collect_blocklevel = false; /* ---------- * Local data * ---------- */ -static int pgStatSock = -1; -static int pgStatPipe[2]; -static struct sockaddr_in pgStatAddr; -static int pgStatPmPipe[2] = { -1, -1 }; +static int pgStatSock = -1; +static int pgStatPipe[2]; +static struct sockaddr_in pgStatAddr; +static int pgStatPmPipe[2] = {-1, -1}; -static int pgStatRunning = 0; -static int pgStatPid; +static int pgStatRunning = 0; +static int pgStatPid; -static long pgStatNumMessages = 0; +static long pgStatNumMessages = 0; -static bool pgStatRunningInCollector = FALSE; -static int pgStatTabstatAlloc = 0; -static int pgStatTabstatUsed = 0; -static PgStat_MsgTabstat **pgStatTabstatMessages = NULL; -static int pgStatXactCommit = 0; -static int pgStatXactRollback = 0; +static bool pgStatRunningInCollector = FALSE; +static int pgStatTabstatAlloc = 0; +static int pgStatTabstatUsed = 0; +static PgStat_MsgTabstat **pgStatTabstatMessages = NULL; +static int pgStatXactCommit = 0; +static int pgStatXactRollback = 0; -static TransactionId pgStatDBHashXact = InvalidTransactionId; -static HTAB *pgStatDBHash = NULL; -static HTAB *pgStatBeDead = NULL; -static PgStat_StatBeEntry *pgStatBeTable = NULL; -static int pgStatNumBackends = 0; +static TransactionId pgStatDBHashXact = InvalidTransactionId; +static HTAB *pgStatDBHash = NULL; +static HTAB *pgStatBeDead = NULL; +static PgStat_StatBeEntry *pgStatBeTable = NULL; +static int pgStatNumBackends = 0; -static char pgStat_tmpfname[MAXPGPATH]; -static char pgStat_fname[MAXPGPATH]; +static char pgStat_tmpfname[MAXPGPATH]; +static char pgStat_fname[MAXPGPATH]; /* ---------- * Local function forward declarations * ---------- */ -static void pgstat_main(void); -static void pgstat_recvbuffer(void); -static void pgstat_die(SIGNAL_ARGS); - -static int pgstat_add_backend(PgStat_MsgHdr *msg); -static void pgstat_sub_backend(int procpid); -static void pgstat_drop_database(Oid databaseid); -static void pgstat_write_statsfile(void); -static void pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, - PgStat_StatBeEntry **betab, - int *numbackends); - -static void pgstat_setheader(PgStat_MsgHdr *hdr, int mtype); -static void pgstat_send(void *msg, int len); - -static void pgstat_recv_bestart(PgStat_MsgBestart *msg, int len); -static void pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len); -static void pgstat_recv_activity(PgStat_MsgActivity *msg, int len); -static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len); -static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len); -static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len); -static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len); +static void pgstat_main(void); +static void pgstat_recvbuffer(void); +static void pgstat_die(SIGNAL_ARGS); + +static int pgstat_add_backend(PgStat_MsgHdr *msg); +static void pgstat_sub_backend(int procpid); +static void pgstat_drop_database(Oid databaseid); +static void pgstat_write_statsfile(void); +static void pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, + PgStat_StatBeEntry **betab, + int *numbackends); + +static void pgstat_setheader(PgStat_MsgHdr *hdr, int mtype); +static void pgstat_send(void *msg, int len); + +static void pgstat_recv_bestart(PgStat_MsgBestart *msg, int len); +static void pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len); +static void pgstat_recv_activity(PgStat_MsgActivity *msg, int len); +static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len); +static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len); +static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len); +static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len); /* ------------------------------------------------------------ @@ -141,21 +141,20 @@ pgstat_init(void) * Force start of collector daemon if something to collect */ if (pgstat_collect_querystring || pgstat_collect_tuplelevel || - pgstat_collect_blocklevel) + pgstat_collect_blocklevel) pgstat_collect_startcollector = true; /* * Initialize the filenames for the status reports. */ - snprintf(pgStat_tmpfname, MAXPGPATH, - PGSTAT_STAT_TMPFILE, DataDir, getpid()); - snprintf(pgStat_fname, MAXPGPATH, - PGSTAT_STAT_FILENAME, DataDir); + snprintf(pgStat_tmpfname, MAXPGPATH, + PGSTAT_STAT_TMPFILE, DataDir, getpid()); + snprintf(pgStat_fname, MAXPGPATH, + PGSTAT_STAT_FILENAME, DataDir); /* - * If we don't have to start a collector or should reset the - * collected statistics on postmaster start, simply remove the - * file. + * If we don't have to start a collector or should reset the collected + * statistics on postmaster start, simply remove the file. */ if (!pgstat_collect_startcollector || pgstat_collect_resetonpmstart) unlink(pgStat_fname); @@ -176,21 +175,21 @@ pgstat_init(void) } /* - * Bind it to a kernel assigned port on localhost and - * get the assigned port via getsockname(). + * Bind it to a kernel assigned port on localhost and get the assigned + * port via getsockname(). */ - pgStatAddr.sin_family = AF_INET; - pgStatAddr.sin_port = htons(0); + pgStatAddr.sin_family = AF_INET; + pgStatAddr.sin_port = htons(0); inet_aton("127.0.0.1", &(pgStatAddr.sin_addr)); alen = sizeof(pgStatAddr); - if (bind(pgStatSock, (struct sockaddr *)&pgStatAddr, alen) < 0) + if (bind(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0) { perror("PGSTAT: bind(2)"); close(pgStatSock); pgStatSock = -1; return -1; } - if (getsockname(pgStatSock, (struct sockaddr *)&pgStatAddr, &alen) < 0) + if (getsockname(pgStatSock, (struct sockaddr *) & pgStatAddr, &alen) < 0) { perror("PGSTAT: getsockname(2)"); close(pgStatSock); @@ -199,12 +198,12 @@ pgstat_init(void) } /* - * Connect the socket to its own address. This saves a few cycles - * by not having to respecify the target address on every send. - * This also provides a kernel-level check that only packets from - * this same address will be received. + * Connect the socket to its own address. This saves a few cycles by + * not having to respecify the target address on every send. This also + * provides a kernel-level check that only packets from this same + * address will be received. */ - if (connect(pgStatSock, (struct sockaddr *)&pgStatAddr, alen) < 0) + if (connect(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0) { perror("PGSTAT: connect(2)"); close(pgStatSock); @@ -262,8 +261,8 @@ pgstat_start(void) */ if (pgStatSock < 0) { - fprintf(stderr, - "PGSTAT: suppress collector startup due to missing socket\n"); + fprintf(stderr, + "PGSTAT: suppress collector startup due to missing socket\n"); return 0; } @@ -279,7 +278,7 @@ pgstat_start(void) beos_before_backend_startup(); #endif - switch ((pgStatPid = (int)fork())) + switch ((pgStatPid = (int) fork())) { case -1: #ifdef __BEOS__ @@ -367,15 +366,15 @@ pgstat_close_sockets(void) void pgstat_beterm(int pid) { - PgStat_MsgBeterm msg; + PgStat_MsgBeterm msg; if (!pgstat_collect_startcollector || pgStatSock < 0) return; - msg.m_hdr.m_type = PGSTAT_MTYPE_BETERM; - msg.m_hdr.m_backendid = 0; - msg.m_hdr.m_procpid = pid; - msg.m_hdr.m_databaseid = 0; + msg.m_hdr.m_type = PGSTAT_MTYPE_BETERM; + msg.m_hdr.m_backendid = 0; + msg.m_hdr.m_procpid = pid; + msg.m_hdr.m_databaseid = 0; pgstat_send(&msg, sizeof(msg)); } @@ -383,7 +382,7 @@ pgstat_beterm(int pid) /* ------------------------------------------------------------ * Public functions used by backends follow - *------------------------------------------------------------ + *------------------------------------------------------------ */ @@ -397,7 +396,7 @@ pgstat_beterm(int pid) void pgstat_bestart(void) { - PgStat_MsgBestart msg; + PgStat_MsgBestart msg; if (!pgstat_collect_startcollector || pgStatSock < 0) return; @@ -418,8 +417,8 @@ pgstat_bestart(void) void pgstat_report_activity(char *what) { - PgStat_MsgActivity msg; - int len; + PgStat_MsgActivity msg; + int len; if (!pgstat_collect_querystring || pgStatSock < 0) return; @@ -427,10 +426,10 @@ pgstat_report_activity(char *what) len = strlen(what); if (len >= PGSTAT_ACTIVITY_SIZE) len = PGSTAT_ACTIVITY_SIZE - 1; - + memcpy(msg.m_what, what, len); msg.m_what[len] = '\0'; - len += offsetof(PgStat_MsgActivity, m_what) + 1; + len += offsetof(PgStat_MsgActivity, m_what) +1; pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_ACTIVITY); pgstat_send(&msg, len); @@ -447,33 +446,33 @@ pgstat_report_activity(char *what) void pgstat_report_tabstat(void) { - int i; - int n; - int len; + int i; + int n; + int len; if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel && - !pgstat_collect_blocklevel) + !pgstat_collect_blocklevel) return; if (pgStatSock < 0) return; /* - * For each message buffer used during the last query - * set the header fields and send it out. + * For each message buffer used during the last query set the header + * fields and send it out. */ for (i = 0; i < pgStatTabstatUsed; i++) { n = pgStatTabstatMessages[i]->m_nentries; len = offsetof(PgStat_MsgTabstat, m_entry[n]); - pgStatTabstatMessages[i]->m_xact_commit = pgStatXactCommit; + pgStatTabstatMessages[i]->m_xact_commit = pgStatXactCommit; pgStatTabstatMessages[i]->m_xact_rollback = pgStatXactRollback; - pgStatXactCommit = 0; + pgStatXactCommit = 0; pgStatXactRollback = 0; - pgstat_setheader(&pgStatTabstatMessages[i]->m_hdr, - PGSTAT_MTYPE_TABSTAT); + pgstat_setheader(&pgStatTabstatMessages[i]->m_hdr, + PGSTAT_MTYPE_TABSTAT); pgstat_send(pgStatTabstatMessages[i], len); } @@ -490,28 +489,28 @@ pgstat_report_tabstat(void) int pgstat_vacuum_tabstat(void) { - Relation dbrel; - HeapScanDesc dbscan; - HeapTuple dbtup; - Oid *dbidlist; - int dbidalloc; - int dbidused; - HASH_SEQ_STATUS hstat; - PgStat_StatDBEntry *dbentry; - PgStat_StatTabEntry *tabentry; - HeapTuple reltup; - int nobjects = 0; - PgStat_MsgTabpurge msg; - int len; - int i; + Relation dbrel; + HeapScanDesc dbscan; + HeapTuple dbtup; + Oid *dbidlist; + int dbidalloc; + int dbidused; + HASH_SEQ_STATUS hstat; + PgStat_StatDBEntry *dbentry; + PgStat_StatTabEntry *tabentry; + HeapTuple reltup; + int nobjects = 0; + PgStat_MsgTabpurge msg; + int len; + int i; if (pgStatSock < 0) return 0; /* - * We don't vacuum inside of transaction blocks, because - * a possible later rollback might reactivate objects we - * didn't find because of earlier destruction in the xact. + * We don't vacuum inside of transaction blocks, because a possible + * later rollback might reactivate objects we didn't find because of + * earlier destruction in the xact. */ if (IsTransactionBlock()) return 0; @@ -522,7 +521,7 @@ pgstat_vacuum_tabstat(void) */ if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId())) { - pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, + pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, &pgStatBeTable, &pgStatNumBackends); pgStatDBHashXact = GetCurrentTransactionId(); } @@ -530,9 +529,9 @@ pgstat_vacuum_tabstat(void) /* * Lookup our own database entry */ - dbentry = (PgStat_StatDBEntry *)hash_search(pgStatDBHash, - (void *) &MyDatabaseId, - HASH_FIND, NULL); + dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, + (void *) &MyDatabaseId, + HASH_FIND, NULL); if (dbentry == NULL) return -1; @@ -547,17 +546,16 @@ pgstat_vacuum_tabstat(void) /* * Check for all tables if they still exist. */ - hash_seq_init(&hstat, dbentry->tables); + hash_seq_init(&hstat, dbentry->tables); while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&hstat)) != NULL) { /* - * Check if this relation is still alive by - * looking up it's pg_class tuple in the - * system catalog cache. + * Check if this relation is still alive by looking up it's + * pg_class tuple in the system catalog cache. */ reltup = SearchSysCache(RELOID, - ObjectIdGetDatum(tabentry->tableid), - 0, 0, 0); + ObjectIdGetDatum(tabentry->tableid), + 0, 0, 0); if (HeapTupleIsValid(reltup)) { ReleaseSysCache(reltup); @@ -600,7 +598,7 @@ pgstat_vacuum_tabstat(void) */ dbidalloc = 256; dbidused = 0; - dbidlist = (Oid *)palloc(sizeof(Oid) * dbidalloc); + dbidlist = (Oid *) palloc(sizeof(Oid) * dbidalloc); dbrel = heap_openr(DatabaseRelationName, AccessShareLock); dbscan = heap_beginscan(dbrel, 0, SnapshotNow, 0, NULL); @@ -609,8 +607,8 @@ pgstat_vacuum_tabstat(void) if (dbidused >= dbidalloc) { dbidalloc *= 2; - dbidlist = (Oid *)repalloc((char *)dbidlist, - sizeof(Oid) * dbidalloc); + dbidlist = (Oid *) repalloc((char *) dbidlist, + sizeof(Oid) * dbidalloc); } dbidlist[dbidused++] = dbtup->t_data->t_oid; } @@ -618,13 +616,13 @@ pgstat_vacuum_tabstat(void) heap_close(dbrel, AccessShareLock); /* - * Search the database hash table for dead databases and - * tell the collector to drop them as well. + * Search the database hash table for dead databases and tell the + * collector to drop them as well. */ hash_seq_init(&hstat, pgStatDBHash); while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL) { - Oid dbid = dbentry->databaseid; + Oid dbid = dbentry->databaseid; for (i = 0; i < dbidused; i++) { @@ -645,7 +643,7 @@ pgstat_vacuum_tabstat(void) /* * Free the dbid list. */ - pfree((char *)dbidlist); + pfree((char *) dbidlist); /* * Tell the caller how many removeable objects we found @@ -666,7 +664,7 @@ pgstat_vacuum_tabstat(void) static void pgstat_drop_database(Oid databaseid) { - PgStat_MsgDropdb msg; + PgStat_MsgDropdb msg; if (pgStatSock < 0) return; @@ -687,7 +685,7 @@ pgstat_drop_database(Oid databaseid) void pgstat_reset_counters(void) { - PgStat_MsgResetcounter msg; + PgStat_MsgResetcounter msg; if (pgStatSock < 0) return; @@ -709,7 +707,7 @@ pgstat_reset_counters(void) void pgstat_ping(void) { - PgStat_MsgDummy msg; + PgStat_MsgDummy msg; if (pgStatSock < 0) return; @@ -731,18 +729,18 @@ pgstat_ping(void) void pgstat_initstats(PgStat_Info *stats, Relation rel) { - PgStat_TableEntry *useent = NULL; - Oid rel_id = rel->rd_id; - int mb; - int i; + PgStat_TableEntry *useent = NULL; + Oid rel_id = rel->rd_id; + int mb; + int i; /* * Initialize data not to count at all. */ - stats->tabentry = NULL; - stats->no_stats = FALSE; - stats->heap_scan_counted = FALSE; - stats->index_scan_counted = FALSE; + stats->tabentry = NULL; + stats->no_stats = FALSE; + stats->heap_scan_counted = FALSE; + stats->index_scan_counted = FALSE; if (!pgstat_collect_startcollector || pgStatSock < 0) { @@ -757,7 +755,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) { pgStatTabstatAlloc = 4; pgStatTabstatMessages = (PgStat_MsgTabstat **) - malloc(sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc); + malloc(sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc); if (pgStatTabstatMessages == NULL) { perror("PGSTATBE: malloc(2)"); @@ -766,7 +764,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) for (i = 0; i < pgStatTabstatAlloc; i++) { pgStatTabstatMessages[i] = (PgStat_MsgTabstat *) - malloc(sizeof(PgStat_MsgTabstat)); + malloc(sizeof(PgStat_MsgTabstat)); if (pgStatTabstatMessages[i] == NULL) { perror("PGSTATBE: malloc(2)"); @@ -784,14 +782,14 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) { if (pgStatTabstatMessages[mb]->m_entry[i].t_id == rel_id) { - stats->tabentry = (void *)&(pgStatTabstatMessages[mb]->m_entry[i]); + stats->tabentry = (void *) &(pgStatTabstatMessages[mb]->m_entry[i]); return; } } if (pgStatTabstatMessages[mb]->m_nentries >= PGSTAT_NUM_TABENTRIES) continue; - + /* * Not found, but found a message buffer with an empty slot * instead. Fine, let's use this one. @@ -800,7 +798,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) useent = &pgStatTabstatMessages[mb]->m_entry[i]; memset(useent, 0, sizeof(PgStat_TableEntry)); useent->t_id = rel_id; - stats->tabentry = (void *)useent; + stats->tabentry = (void *) useent; return; } @@ -811,7 +809,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) { pgStatTabstatAlloc += 4; pgStatTabstatMessages = (PgStat_MsgTabstat **) - realloc(pgStatTabstatMessages, + realloc(pgStatTabstatMessages, sizeof(PgStat_MsgTabstat *) * pgStatTabstatAlloc); if (pgStatTabstatMessages == NULL) { @@ -822,7 +820,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) for (i = pgStatTabstatUsed; i < pgStatTabstatAlloc; i++) { pgStatTabstatMessages[i] = (PgStat_MsgTabstat *) - malloc(sizeof(PgStat_MsgTabstat)); + malloc(sizeof(PgStat_MsgTabstat)); if (pgStatTabstatMessages[i] == NULL) { pgStatTabstatAlloc -= 4; @@ -840,7 +838,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) useent = &pgStatTabstatMessages[mb]->m_entry[0]; memset(useent, 0, sizeof(PgStat_TableEntry)); useent->t_id = rel_id; - stats->tabentry = (void *)useent; + stats->tabentry = (void *) useent; return; } @@ -855,15 +853,15 @@ void pgstat_count_xact_commit(void) { if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel && - !pgstat_collect_blocklevel) + !pgstat_collect_blocklevel) return; pgStatXactCommit++; /* - * If there was no relation activity yet, just make - * one existing message buffer used without slots, - * causing the next report to tell new xact-counters. + * If there was no relation activity yet, just make one existing + * message buffer used without slots, causing the next report to tell + * new xact-counters. */ if (pgStatTabstatAlloc > 0) { @@ -886,15 +884,15 @@ void pgstat_count_xact_rollback(void) { if (!pgstat_collect_querystring && !pgstat_collect_tuplelevel && - !pgstat_collect_blocklevel) + !pgstat_collect_blocklevel) return; pgStatXactRollback++; /* - * If there was no relation activity yet, just make - * one existing message buffer used without slots, - * causing the next report to tell new xact-counters. + * If there was no relation activity yet, just make one existing + * message buffer used without slots, causing the next report to tell + * new xact-counters. */ if (pgStatTabstatAlloc > 0) { @@ -919,16 +917,16 @@ pgstat_count_xact_rollback(void) PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid) { - PgStat_StatDBEntry *dbentry; + PgStat_StatDBEntry *dbentry; /* * If not done for this transaction, read the statistics collector - * stats file into some hash tables. Be careful with the read_statsfile() - * call below! + * stats file into some hash tables. Be careful with the + * read_statsfile() call below! */ if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId())) { - pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, + pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, &pgStatBeTable, &pgStatNumBackends); pgStatDBHashXact = GetCurrentTransactionId(); } @@ -958,17 +956,17 @@ pgstat_fetch_stat_dbentry(Oid dbid) PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid) { - PgStat_StatDBEntry *dbentry; - PgStat_StatTabEntry *tabentry; + PgStat_StatDBEntry *dbentry; + PgStat_StatTabEntry *tabentry; /* * If not done for this transaction, read the statistics collector - * stats file into some hash tables. Be careful with the read_statsfile() - * call below! + * stats file into some hash tables. Be careful with the + * read_statsfile() call below! */ if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId())) { - pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, + pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, &pgStatBeTable, &pgStatNumBackends); pgStatDBHashXact = GetCurrentTransactionId(); } @@ -1011,7 +1009,7 @@ pgstat_fetch_stat_beentry(int beid) { if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId())) { - pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, + pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, &pgStatBeTable, &pgStatNumBackends); pgStatDBHashXact = GetCurrentTransactionId(); } @@ -1035,7 +1033,7 @@ pgstat_fetch_stat_numbackends(void) { if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId())) { - pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, + pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId, &pgStatBeTable, &pgStatNumBackends); pgStatDBHashXact = GetCurrentTransactionId(); } @@ -1060,11 +1058,11 @@ pgstat_fetch_stat_numbackends(void) static void pgstat_setheader(PgStat_MsgHdr *hdr, int mtype) { - hdr->m_type = mtype; - hdr->m_backendid = MyBackendId; - hdr->m_procpid = MyProcPid; - hdr->m_databaseid = MyDatabaseId; - hdr->m_userid = GetSessionUserId(); + hdr->m_type = mtype; + hdr->m_backendid = MyBackendId; + hdr->m_procpid = MyProcPid; + hdr->m_databaseid = MyDatabaseId; + hdr->m_userid = GetSessionUserId(); } @@ -1080,7 +1078,7 @@ pgstat_send(void *msg, int len) if (pgStatSock < 0) return; - ((PgStat_MsgHdr *)msg)->m_size = len; + ((PgStat_MsgHdr *) msg)->m_size = len; send(pgStatSock, msg, len, 0); /* We deliberately ignore any error from send() */ @@ -1089,7 +1087,7 @@ pgstat_send(void *msg, int len) /* ------------------------------------------------------------ * Local functions implementing the statistics collector itself follow - *------------------------------------------------------------ + *------------------------------------------------------------ */ @@ -1104,21 +1102,20 @@ static void pgstat_main(void) { PgStat_Msg msg; - fd_set rfds; - int readPipe; - int pmPipe = pgStatPmPipe[0]; - int maxfd; - int nready; - int len = 0; - struct timeval timeout; - struct timeval next_statwrite; - bool need_statwrite; - HASHCTL hash_ctl; - - /* - * Close the writing end of the postmaster pipe, so we'll see - * it closing when the postmaster terminates and can terminate - * as well. + fd_set rfds; + int readPipe; + int pmPipe = pgStatPmPipe[0]; + int maxfd; + int nready; + int len = 0; + struct timeval timeout; + struct timeval next_statwrite; + bool need_statwrite; + HASHCTL hash_ctl; + + /* + * Close the writing end of the postmaster pipe, so we'll see it + * closing when the postmaster terminates and can terminate as well. */ close(pgStatPmPipe[1]); pgStatPmPipe[1] = -1; @@ -1142,15 +1139,16 @@ pgstat_main(void) pqsignal(SIGWINCH, SIG_DFL); /* - * Start a buffering process to read from the socket, so - * we have a little more time to process incoming messages. + * Start a buffering process to read from the socket, so we have a + * little more time to process incoming messages. * * NOTE: the process structure is: postmaster is parent of buffer process - * is parent of collector process. This way, the buffer can detect + * is parent of collector process. This way, the buffer can detect * collector failure via SIGCHLD, whereas otherwise it wouldn't notice - * collector failure until it tried to write on the pipe. That would mean - * that after the postmaster started a new collector, we'd have two buffer - * processes competing to read from the UDP socket --- not good. + * collector failure until it tried to write on the pipe. That would + * mean that after the postmaster started a new collector, we'd have + * two buffer processes competing to read from the UDP socket --- not + * good. */ if (pipe(pgStatPipe) < 0) { @@ -1178,8 +1176,8 @@ pgstat_main(void) } /* - * In the child we can have default SIGCHLD handling (in case we - * want to call system() here...) + * In the child we can have default SIGCHLD handling (in case we want + * to call system() here...) */ pqsignal(SIGCHLD, SIG_DFL); @@ -1196,8 +1194,8 @@ pgstat_main(void) need_statwrite = TRUE; /* - * Read in an existing statistics stats file or initialize the - * stats to zero. + * Read in an existing statistics stats file or initialize the stats + * to zero. */ pgStatRunningInCollector = TRUE; pgstat_read_statsfile(&pgStatDBHash, InvalidOid, NULL, NULL); @@ -1206,14 +1204,14 @@ pgstat_main(void) * Create the dead backend hashtable */ memset(&hash_ctl, 0, sizeof(hash_ctl)); - hash_ctl.keysize = sizeof(int); + hash_ctl.keysize = sizeof(int); hash_ctl.entrysize = sizeof(PgStat_StatBeDead); - hash_ctl.hash = tag_hash; + hash_ctl.hash = tag_hash; pgStatBeDead = hash_create("Dead Backends", PGSTAT_BE_HASH_SIZE, &hash_ctl, HASH_ELEM | HASH_FUNCTION); if (pgStatBeDead == NULL) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: Creation of dead backend hash table failed\n"); exit(1); } @@ -1221,8 +1219,8 @@ pgstat_main(void) /* * Create the known backends table */ - pgStatBeTable = (PgStat_StatBeEntry *)malloc( - sizeof(PgStat_StatBeEntry) * MaxBackends); + pgStatBeTable = (PgStat_StatBeEntry *) malloc( + sizeof(PgStat_StatBeEntry) * MaxBackends); if (pgStatBeTable == NULL) { perror("PGSTAT: Allocation of backend table failed"); @@ -1233,29 +1231,29 @@ pgstat_main(void) readPipe = pgStatPipe[0]; /* - * Process incoming messages and handle all the reporting stuff - * until there are no more messages. + * Process incoming messages and handle all the reporting stuff until + * there are no more messages. */ for (;;) { /* - * If we need to write the status file again (there have - * been changes in the statistics since we wrote it last) - * calculate the timeout until we have to do so. + * If we need to write the status file again (there have been + * changes in the statistics since we wrote it last) calculate the + * timeout until we have to do so. */ if (need_statwrite) { gettimeofday(&timeout, NULL); timeout.tv_usec = next_statwrite.tv_usec - timeout.tv_usec; - timeout.tv_sec = next_statwrite.tv_sec - timeout.tv_sec; + timeout.tv_sec = next_statwrite.tv_sec - timeout.tv_sec; if (timeout.tv_usec < 0) { - timeout.tv_sec -= 1; + timeout.tv_sec -= 1; timeout.tv_usec += 1000000; } if (timeout.tv_sec < 0) { - timeout.tv_sec = 0; + timeout.tv_sec = 0; timeout.tv_usec = 0; } } @@ -1275,7 +1273,7 @@ pgstat_main(void) /* * Now wait for something to do. */ - nready = select(maxfd + 1, &rfds, NULL, NULL, + nready = select(maxfd + 1, &rfds, NULL, NULL, (need_statwrite) ? &timeout : NULL); if (nready < 0) { @@ -1286,8 +1284,8 @@ pgstat_main(void) } /* - * If there are no descriptors ready, our timeout for writing - * the stats file happened. + * If there are no descriptors ready, our timeout for writing the + * stats file happened. */ if (nready == 0) { @@ -1303,14 +1301,14 @@ pgstat_main(void) if (FD_ISSET(readPipe, &rfds)) { /* - * We may need to issue multiple read calls in case the - * buffer process didn't write the message in a single write, - * which is possible since it dumps its buffer bytewise. - * In any case, we'd need two reads since we don't know the - * message length initially. + * We may need to issue multiple read calls in case the buffer + * process didn't write the message in a single write, which + * is possible since it dumps its buffer bytewise. In any + * case, we'd need two reads since we don't know the message + * length initially. */ - int nread = 0; - int targetlen = sizeof(PgStat_MsgHdr); /* initial */ + int nread = 0; + int targetlen = sizeof(PgStat_MsgHdr); /* initial */ while (nread < targetlen) { @@ -1335,15 +1333,16 @@ pgstat_main(void) targetlen > (int) sizeof(msg)) { /* - * Bogus message length implies that we got out - * of sync with the buffer process somehow. - * Abort so that we can restart both processes. + * Bogus message length implies that we got out of + * sync with the buffer process somehow. Abort so + * that we can restart both processes. */ fprintf(stderr, "PGSTAT: bogus message length\n"); exit(1); } } } + /* * EOF on the pipe implies that the buffer process exited. * Fall out of outer loop. @@ -1352,7 +1351,8 @@ pgstat_main(void) break; /* - * Distribute the message to the specific function handling it. + * Distribute the message to the specific function handling + * it. */ switch (msg.msg_hdr.m_type) { @@ -1360,31 +1360,31 @@ pgstat_main(void) break; case PGSTAT_MTYPE_BESTART: - pgstat_recv_bestart((PgStat_MsgBestart *)&msg, nread); + pgstat_recv_bestart((PgStat_MsgBestart *) &msg, nread); break; case PGSTAT_MTYPE_BETERM: - pgstat_recv_beterm((PgStat_MsgBeterm *)&msg, nread); + pgstat_recv_beterm((PgStat_MsgBeterm *) &msg, nread); break; case PGSTAT_MTYPE_TABSTAT: - pgstat_recv_tabstat((PgStat_MsgTabstat *)&msg, nread); + pgstat_recv_tabstat((PgStat_MsgTabstat *) &msg, nread); break; case PGSTAT_MTYPE_TABPURGE: - pgstat_recv_tabpurge((PgStat_MsgTabpurge *)&msg, nread); + pgstat_recv_tabpurge((PgStat_MsgTabpurge *) &msg, nread); break; case PGSTAT_MTYPE_ACTIVITY: - pgstat_recv_activity((PgStat_MsgActivity *)&msg, nread); + pgstat_recv_activity((PgStat_MsgActivity *) &msg, nread); break; case PGSTAT_MTYPE_DROPDB: - pgstat_recv_dropdb((PgStat_MsgDropdb *)&msg, nread); + pgstat_recv_dropdb((PgStat_MsgDropdb *) &msg, nread); break; case PGSTAT_MTYPE_RESETCOUNTER: - pgstat_recv_resetcounter((PgStat_MsgResetcounter *)&msg, + pgstat_recv_resetcounter((PgStat_MsgResetcounter *) &msg, nread); break; @@ -1398,15 +1398,14 @@ pgstat_main(void) pgStatNumMessages++; /* - * If this is the first message after we wrote the stats - * file the last time, setup the timeout that it'd be - * written. + * If this is the first message after we wrote the stats file + * the last time, setup the timeout that it'd be written. */ if (!need_statwrite) { gettimeofday(&next_statwrite, NULL); next_statwrite.tv_usec += ((PGSTAT_STAT_INTERVAL) * 1000); - next_statwrite.tv_sec += (next_statwrite.tv_usec / 1000000); + next_statwrite.tv_sec += (next_statwrite.tv_usec / 1000000); next_statwrite.tv_usec %= 1000000; need_statwrite = TRUE; } @@ -1414,21 +1413,22 @@ pgstat_main(void) /* * Note that we do NOT check for postmaster exit inside the loop; - * only EOF on the buffer pipe causes us to fall out. This ensures - * we don't exit prematurely if there are still a few messages in - * the buffer or pipe at postmaster shutdown. + * only EOF on the buffer pipe causes us to fall out. This + * ensures we don't exit prematurely if there are still a few + * messages in the buffer or pipe at postmaster shutdown. */ } /* - * Okay, we saw EOF on the buffer pipe, so there are no more messages to - * process. If the buffer process quit because of postmaster shutdown, - * we want to save the final stats to reuse at next startup. But if the - * buffer process failed, it seems best not to (there may even now be a - * new collector firing up, and we don't want it to read a partially- - * rewritten stats file). We can tell whether the postmaster is still - * alive by checking to see if the postmaster pipe is still open. If it - * is read-ready (ie, EOF), the postmaster must have quit. + * Okay, we saw EOF on the buffer pipe, so there are no more messages + * to process. If the buffer process quit because of postmaster + * shutdown, we want to save the final stats to reuse at next startup. + * But if the buffer process failed, it seems best not to (there may + * even now be a new collector firing up, and we don't want it to read + * a partially- rewritten stats file). We can tell whether the + * postmaster is still alive by checking to see if the postmaster pipe + * is still open. If it is read-ready (ie, EOF), the postmaster must + * have quit. */ if (FD_ISSET(pmPipe, &rfds)) pgstat_write_statsfile(); @@ -1447,23 +1447,23 @@ pgstat_main(void) static void pgstat_recvbuffer(void) { - fd_set rfds; - fd_set wfds; - int writePipe = pgStatPipe[1]; - int pmPipe = pgStatPmPipe[0]; - int maxfd; - int nready; - int len; - int xfr; - int frm; - PgStat_Msg input_buffer; - char *msgbuffer; - int msg_send = 0; /* next send index in buffer */ - int msg_recv = 0; /* next receive index */ - int msg_have = 0; /* number of bytes stored */ - struct sockaddr_in fromaddr; - int fromlen; - bool overflow = false; + fd_set rfds; + fd_set wfds; + int writePipe = pgStatPipe[1]; + int pmPipe = pgStatPmPipe[0]; + int maxfd; + int nready; + int len; + int xfr; + int frm; + PgStat_Msg input_buffer; + char *msgbuffer; + int msg_send = 0; /* next send index in buffer */ + int msg_recv = 0; /* next receive index */ + int msg_have = 0; /* number of bytes stored */ + struct sockaddr_in fromaddr; + int fromlen; + bool overflow = false; /* * Identify myself via ps @@ -1472,11 +1472,11 @@ pgstat_recvbuffer(void) set_ps_display(""); /* - * We want to die if our child collector process does. There are two ways - * we might notice that it has died: receive SIGCHLD, or get a write - * failure on the pipe leading to the child. We can set SIGPIPE to kill - * us here. Our SIGCHLD handler was already set up before we forked (must - * do it that way, else it's a race condition). + * We want to die if our child collector process does. There are two + * ways we might notice that it has died: receive SIGCHLD, or get a + * write failure on the pipe leading to the child. We can set SIGPIPE + * to kill us here. Our SIGCHLD handler was already set up before we + * forked (must do it that way, else it's a race condition). */ pqsignal(SIGPIPE, SIG_DFL); PG_SETMASK(&UnBlockSig); @@ -1511,8 +1511,8 @@ pgstat_recvbuffer(void) maxfd = -1; /* - * As long as we have buffer space we add the socket - * to the read descriptor set. + * As long as we have buffer space we add the socket to the read + * descriptor set. */ if (msg_have <= (int) (PGSTAT_RECVBUFFERSZ - sizeof(PgStat_Msg))) { @@ -1530,9 +1530,9 @@ pgstat_recvbuffer(void) } /* - * If we have messages to write out, we add the pipe - * to the write descriptor set. Otherwise, we check if - * the postmaster might have terminated. + * If we have messages to write out, we add the pipe to the write + * descriptor set. Otherwise, we check if the postmaster might + * have terminated. */ if (msg_have > 0) { @@ -1566,7 +1566,7 @@ pgstat_recvbuffer(void) if (FD_ISSET(pgStatSock, &rfds)) { fromlen = sizeof(fromaddr); - len = recvfrom(pgStatSock, + len = recvfrom(pgStatSock, &input_buffer, sizeof(PgStat_Msg), 0, (struct sockaddr *) &fromaddr, &fromlen); if (len < 0) @@ -1591,14 +1591,14 @@ pgstat_recvbuffer(void) * The source address of the packet must be our own socket. * This ensures that only real hackers or our own backends * tell us something. (This should be redundant with a - * kernel-level check due to having used connect(), but - * let's do it anyway.) + * kernel-level check due to having used connect(), but let's + * do it anyway.) */ if (fromaddr.sin_addr.s_addr != pgStatAddr.sin_addr.s_addr) continue; if (fromaddr.sin_port != pgStatAddr.sin_port) continue; - + /* * O.K. - we accept this message. Copy it to the circular * msgbuffer. @@ -1627,13 +1627,13 @@ pgstat_recvbuffer(void) * pipe. We may or may not be able to write all that we have. * * NOTE: if what we have is less than PIPE_BUF bytes but more than - * the space available in the pipe buffer, most kernels will refuse - * to write any of it, and will return EAGAIN. This means we will - * busy-loop until the situation changes (either because the collector - * caught up, or because more data arrives so that we have more than - * PIPE_BUF bytes buffered). This is not good, but is there any way - * around it? We have no way to tell when the collector has - * caught up... + * the space available in the pipe buffer, most kernels will + * refuse to write any of it, and will return EAGAIN. This means + * we will busy-loop until the situation changes (either because + * the collector caught up, or because more data arrives so that + * we have more than PIPE_BUF bytes buffered). This is not good, + * but is there any way around it? We have no way to tell when + * the collector has caught up... */ if (FD_ISSET(writePipe, &wfds)) { @@ -1664,9 +1664,9 @@ pgstat_recvbuffer(void) continue; /* - * If the pipe from the postmaster is ready for reading, - * the kernel must have closed it on exit() (the postmaster - * never really writes to it). So we've done our job. + * If the pipe from the postmaster is ready for reading, the + * kernel must have closed it on exit() (the postmaster never + * really writes to it). So we've done our job. */ if (FD_ISSET(pmPipe, &rfds)) exit(0); @@ -1689,10 +1689,10 @@ pgstat_die(SIGNAL_ARGS) static int pgstat_add_backend(PgStat_MsgHdr *msg) { - PgStat_StatDBEntry *dbentry; - PgStat_StatBeEntry *beentry; - PgStat_StatBeDead *deadbe; - bool found; + PgStat_StatDBEntry *dbentry; + PgStat_StatBeEntry *beentry; + PgStat_StatBeDead *deadbe; + bool found; /* * Check that the backend ID is valid @@ -1710,19 +1710,19 @@ pgstat_add_backend(PgStat_MsgHdr *msg) if (beentry->databaseid != InvalidOid) { /* - * If the slot contains the PID of this backend, - * everything is fine and we got nothing to do. + * If the slot contains the PID of this backend, everything is + * fine and we got nothing to do. */ if (beentry->procpid == msg->m_procpid) return 0; } /* - * Lookup if this backend is known to be dead. This can be caused - * due to messages arriving in the wrong order - i.e. Postmaster's - * BETERM message might have arrived before we received all the - * backends stats messages, or even a new backend with the same - * backendid was faster in sending his BESTART. + * Lookup if this backend is known to be dead. This can be caused due + * to messages arriving in the wrong order - i.e. Postmaster's BETERM + * message might have arrived before we received all the backends + * stats messages, or even a new backend with the same backendid was + * faster in sending his BESTART. * * If the backend is known to be dead, we ignore this add. */ @@ -1733,8 +1733,8 @@ pgstat_add_backend(PgStat_MsgHdr *msg) return 1; /* - * Backend isn't known to be dead. If it's slot is currently used, - * we have to kick out the old backend. + * Backend isn't known to be dead. If it's slot is currently used, we + * have to kick out the old backend. */ if (beentry->databaseid != InvalidOid) pgstat_sub_backend(beentry->procpid); @@ -1743,17 +1743,17 @@ pgstat_add_backend(PgStat_MsgHdr *msg) * Put this new backend into the slot. */ beentry->databaseid = msg->m_databaseid; - beentry->procpid = msg->m_procpid; - beentry->userid = msg->m_userid; + beentry->procpid = msg->m_procpid; + beentry->userid = msg->m_userid; MemSet(beentry->activity, 0, PGSTAT_ACTIVITY_SIZE); /* * Lookup or create the database entry for this backends DB. */ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, - (void *) &(msg->m_databaseid), + (void *) &(msg->m_databaseid), HASH_ENTER, &found); - if (dbentry == NULL) + if (dbentry == NULL) { fprintf(stderr, "PGSTAT: DB hash table out of memory - abort\n"); exit(1); @@ -1764,20 +1764,20 @@ pgstat_add_backend(PgStat_MsgHdr *msg) */ if (!found) { - HASHCTL hash_ctl; + HASHCTL hash_ctl; - dbentry->tables = NULL; - dbentry->n_xact_commit = 0; - dbentry->n_xact_rollback = 0; - dbentry->n_blocks_fetched = 0; - dbentry->n_blocks_hit = 0; - dbentry->n_connects = 0; - dbentry->destroy = 0; + dbentry->tables = NULL; + dbentry->n_xact_commit = 0; + dbentry->n_xact_rollback = 0; + dbentry->n_blocks_fetched = 0; + dbentry->n_blocks_hit = 0; + dbentry->n_connects = 0; + dbentry->destroy = 0; memset(&hash_ctl, 0, sizeof(hash_ctl)); - hash_ctl.keysize = sizeof(Oid); + hash_ctl.keysize = sizeof(Oid); hash_ctl.entrysize = sizeof(PgStat_StatTabEntry); - hash_ctl.hash = tag_hash; + hash_ctl.hash = tag_hash; dbentry->tables = hash_create("Per-database table", PGSTAT_TAB_HASH_SIZE, &hash_ctl, @@ -1785,7 +1785,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg) if (dbentry->tables == NULL) { fprintf(stderr, "PGSTAT: failed to initialize hash table for " - "new database entry\n"); + "new database entry\n"); exit(1); } } @@ -1808,13 +1808,13 @@ pgstat_add_backend(PgStat_MsgHdr *msg) static void pgstat_sub_backend(int procpid) { - int i; - PgStat_StatBeDead *deadbe; - bool found; + int i; + PgStat_StatBeDead *deadbe; + bool found; /* - * Search in the known-backends table for the slot containing - * this PID. + * Search in the known-backends table for the slot containing this + * PID. */ for (i = 0; i < MaxBackends; i++) { @@ -1823,22 +1823,21 @@ pgstat_sub_backend(int procpid) { /* * That's him. Add an entry to the known to be dead backends. - * Due to possible misorder in the arrival of UDP packets - * it's possible that even if we know the backend is dead, - * there could still be messages queued that arrive later. - * Those messages must not cause our number of backends - * statistics to get screwed up, so we remember for a couple - * of seconds that this PID is dead and ignore them (only - * the counting of backends, not the table access stats they - * sent). + * Due to possible misorder in the arrival of UDP packets it's + * possible that even if we know the backend is dead, there + * could still be messages queued that arrive later. Those + * messages must not cause our number of backends statistics + * to get screwed up, so we remember for a couple of seconds + * that this PID is dead and ignore them (only the counting of + * backends, not the table access stats they sent). */ deadbe = (PgStat_StatBeDead *) hash_search(pgStatBeDead, (void *) &procpid, - HASH_ENTER, &found); + HASH_ENTER, &found); if (deadbe == NULL) { fprintf(stderr, "PGSTAT: dead backend hash table out of memory " - "- abort\n"); + "- abort\n"); exit(1); } if (!found) @@ -1856,8 +1855,8 @@ pgstat_sub_backend(int procpid) } /* - * No big problem if not found. This can happen if UDP messages - * arrive out of order here. + * No big problem if not found. This can happen if UDP messages arrive + * out of order here. */ } @@ -1871,17 +1870,16 @@ pgstat_sub_backend(int procpid) static void pgstat_write_statsfile(void) { - HASH_SEQ_STATUS hstat; - HASH_SEQ_STATUS tstat; - PgStat_StatDBEntry *dbentry; - PgStat_StatTabEntry *tabentry; - PgStat_StatBeDead *deadbe; - FILE *fpout; - int i; + HASH_SEQ_STATUS hstat; + HASH_SEQ_STATUS tstat; + PgStat_StatDBEntry *dbentry; + PgStat_StatTabEntry *tabentry; + PgStat_StatBeDead *deadbe; + FILE *fpout; + int i; /* - * Open the statistics temp file to write out - * the current values. + * Open the statistics temp file to write out the current values. */ fpout = fopen(pgStat_tmpfname, PG_BINARY_W); if (fpout == NULL) @@ -1899,8 +1897,8 @@ pgstat_write_statsfile(void) while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL) { /* - * If this database is marked destroyed, count down and do - * so if it reaches 0. + * If this database is marked destroyed, count down and do so if + * it reaches 0. */ if (dbentry->destroy > 0) { @@ -1909,15 +1907,16 @@ pgstat_write_statsfile(void) if (dbentry->tables != NULL) hash_destroy(dbentry->tables); - if (hash_search(pgStatDBHash, + if (hash_search(pgStatDBHash, (void *) &(dbentry->databaseid), HASH_REMOVE, NULL) == NULL) { fprintf(stderr, "PGSTAT: database hash table corrupted " - "during cleanup - abort\n"); + "during cleanup - abort\n"); exit(1); } } + /* * Don't include statistics for it. */ @@ -1937,8 +1936,8 @@ pgstat_write_statsfile(void) while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&tstat)) != NULL) { /* - * If table entry marked for destruction, same as above - * for the database entry. + * If table entry marked for destruction, same as above for + * the database entry. */ if (tabentry->destroy > 0) { @@ -1949,9 +1948,9 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { fprintf(stderr, "PGSTAT: tables hash table for " - "database %d corrupted during " - "cleanup - abort\n", - dbentry->databaseid); + "database %d corrupted during " + "cleanup - abort\n", + dbentry->databaseid); exit(1); } } @@ -1959,13 +1958,13 @@ pgstat_write_statsfile(void) } /* - * At least we think this is still a life table. Print - * it's access stats. + * At least we think this is still a life table. Print it's + * access stats. */ fputc('T', fpout); fwrite(tabentry, sizeof(PgStat_StatTabEntry), 1, fpout); } - + /* * Mark the end of this DB */ @@ -1989,8 +1988,8 @@ pgstat_write_statsfile(void) } /* - * No more output to be done. Close the temp file and - * replace the old pgstat.stat with it's content. + * No more output to be done. Close the temp file and replace the old + * pgstat.stat with it's content. */ fputc('E', fpout); if (fclose(fpout) < 0) @@ -2006,7 +2005,7 @@ pgstat_write_statsfile(void) if (rename(pgStat_tmpfname, pgStat_fname) < 0) { fprintf(stderr, "PGSTAT: Cannot rename temp stats file\n" - "PGSTAT: "); + "PGSTAT: "); perror(pgStat_fname); fflush(stderr); } @@ -2019,8 +2018,8 @@ pgstat_write_statsfile(void) while ((deadbe = (PgStat_StatBeDead *) hash_seq_search(&hstat)) != NULL) { /* - * Count down the destroy delay and remove entries where - * it reaches 0. + * Count down the destroy delay and remove entries where it + * reaches 0. */ if (--(deadbe->destroy) <= 0) { @@ -2029,7 +2028,7 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { fprintf(stderr, "PGSTAT: dead backend hash table corrupted " - "during cleanup - abort\n"); + "during cleanup - abort\n"); exit(1); } } @@ -2046,28 +2045,27 @@ pgstat_write_statsfile(void) * ---------- */ static void -pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, - PgStat_StatBeEntry **betab, int *numbackends) +pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, + PgStat_StatBeEntry **betab, int *numbackends) { - PgStat_StatDBEntry *dbentry; - PgStat_StatDBEntry dbbuf; - PgStat_StatTabEntry *tabentry; - PgStat_StatTabEntry tabbuf; - HASHCTL hash_ctl; - HTAB *tabhash = NULL; - FILE *fpin; - int maxbackends = 0; - int havebackends = 0; - bool found; - MemoryContext use_mcxt; - int mcxt_flags; - - /* - * If running in the collector we use the DynaHashCxt - * memory context. If running in a backend, we use the - * TopTransactionContext instead, so the caller must only know the - * last XactId when this call happened to know if his tables are - * still valid or already gone! + PgStat_StatDBEntry *dbentry; + PgStat_StatDBEntry dbbuf; + PgStat_StatTabEntry *tabentry; + PgStat_StatTabEntry tabbuf; + HASHCTL hash_ctl; + HTAB *tabhash = NULL; + FILE *fpin; + int maxbackends = 0; + int havebackends = 0; + bool found; + MemoryContext use_mcxt; + int mcxt_flags; + + /* + * If running in the collector we use the DynaHashCxt memory context. + * If running in a backend, we use the TopTransactionContext instead, + * so the caller must only know the last XactId when this call + * happened to know if his tables are still valid or already gone! */ if (pgStatRunningInCollector) { @@ -2084,12 +2082,12 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, * Create the DB hashtable */ memset(&hash_ctl, 0, sizeof(hash_ctl)); - hash_ctl.keysize = sizeof(Oid); + hash_ctl.keysize = sizeof(Oid); hash_ctl.entrysize = sizeof(PgStat_StatDBEntry); - hash_ctl.hash = tag_hash; - hash_ctl.hcxt = use_mcxt; - *dbhash = hash_create("Databases hash", PGSTAT_DB_HASH_SIZE, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | mcxt_flags); + hash_ctl.hash = tag_hash; + hash_ctl.hcxt = use_mcxt; + *dbhash = hash_create("Databases hash", PGSTAT_DB_HASH_SIZE, &hash_ctl, + HASH_ELEM | HASH_FUNCTION | mcxt_flags); if (pgStatDBHash == NULL) { if (pgStatRunningInCollector) @@ -2097,12 +2095,12 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, fprintf(stderr, "PGSTAT: Creation of DB hash table failed\n"); exit(1); } - elog(ERROR, "PGSTAT: Creation of DB hash table failed"); + elog(ERROR, "PGSTAT: Creation of DB hash table failed"); } /* - * Initialize the number of known backends to zero, just in case we - * do a silent error return below. + * Initialize the number of known backends to zero, just in case we do + * a silent error return below. */ if (numbackends != NULL) *numbackends = 0; @@ -2111,39 +2109,39 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, /* * Try to open the status file. If it doesn't exist, the backends - * simply return zero for anything and the collector simply - * starts from scratch with empty counters. + * simply return zero for anything and the collector simply starts + * from scratch with empty counters. */ if ((fpin = fopen(pgStat_fname, PG_BINARY_R)) == NULL) return; /* - * We found an existing collector stats file. Read it and put - * all the hashtable entries into place. + * We found an existing collector stats file. Read it and put all the + * hashtable entries into place. */ for (;;) { switch (fgetc(fpin)) { - /* - * 'D' A PgStat_StatDBEntry struct describing a database - * follows. Subsequently, zero to many 'T' entries will - * follow until a 'd' is encountered. - */ + /* + * 'D' A PgStat_StatDBEntry struct describing a database + * follows. Subsequently, zero to many 'T' entries will + * follow until a 'd' is encountered. + */ case 'D': if (fread(&dbbuf, 1, sizeof(dbbuf), fpin) != sizeof(dbbuf)) { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } @@ -2153,8 +2151,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, * Add to the DB hash */ dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash, - (void *) &dbbuf.databaseid, - HASH_ENTER, &found); + (void *) &dbbuf.databaseid, + HASH_ENTER, &found); if (dbentry == NULL) { if (pgStatRunningInCollector) @@ -2172,24 +2170,24 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } } memcpy(dbentry, &dbbuf, sizeof(PgStat_StatDBEntry)); - dbentry->tables = NULL; - dbentry->destroy = 0; - dbentry->n_backends = 0; + dbentry->tables = NULL; + dbentry->destroy = 0; + dbentry->n_backends = 0; /* * Don't collect tables if not the requested DB @@ -2199,27 +2197,27 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, memset(&hash_ctl, 0, sizeof(hash_ctl)); - hash_ctl.keysize = sizeof(Oid); + hash_ctl.keysize = sizeof(Oid); hash_ctl.entrysize = sizeof(PgStat_StatTabEntry); - hash_ctl.hash = tag_hash; - hash_ctl.hcxt = use_mcxt; + hash_ctl.hash = tag_hash; + hash_ctl.hcxt = use_mcxt; dbentry->tables = hash_create("Per-database table", PGSTAT_TAB_HASH_SIZE, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | mcxt_flags); + HASH_ELEM | HASH_FUNCTION | mcxt_flags); if (dbentry->tables == NULL) { if (pgStatRunningInCollector) { fprintf(stderr, "PGSTAT: failed to initialize " - "hash table for new database entry\n"); + "hash table for new database entry\n"); exit(1); } else { fclose(fpin); elog(ERROR, "PGSTAT: failed to initialize " - "hash table for new database entry\n"); + "hash table for new database entry\n"); } } @@ -2230,30 +2228,30 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, tabhash = dbentry->tables; break; - /* - * 'd' End of this database. - */ + /* + * 'd' End of this database. + */ case 'd': tabhash = NULL; break; - /* - * 'T' A PgStat_StatTabEntry follows. - */ + /* + * 'T' A PgStat_StatTabEntry follows. + */ case 'T': if (fread(&tabbuf, 1, sizeof(tabbuf), fpin) != sizeof(tabbuf)) { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } @@ -2266,8 +2264,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, break; tabentry = (PgStat_StatTabEntry *) hash_search(tabhash, - (void *) &tabbuf.tableid, - HASH_ENTER, &found); + (void *) &tabbuf.tableid, + HASH_ENTER, &found); if (tabentry == NULL) { if (pgStatRunningInCollector) @@ -2286,15 +2284,15 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } @@ -2303,9 +2301,9 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, memcpy(tabentry, &tabbuf, sizeof(tabbuf)); break; - /* - * 'M' The maximum number of backends to expect follows. - */ + /* + * 'M' The maximum number of backends to expect follows. + */ case 'M': if (betab == NULL || numbackends == NULL) { @@ -2313,19 +2311,19 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, return; } if (fread(&maxbackends, 1, sizeof(maxbackends), fpin) != - sizeof(maxbackends)) + sizeof(maxbackends)) { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } @@ -2337,21 +2335,21 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, } /* - * Allocate space (in TopTransactionContext too) for - * the backend table. + * Allocate space (in TopTransactionContext too) for the + * backend table. */ if (use_mcxt == NULL) - *betab = (PgStat_StatBeEntry *)malloc( - sizeof(PgStat_StatBeEntry) * maxbackends); + *betab = (PgStat_StatBeEntry *) malloc( + sizeof(PgStat_StatBeEntry) * maxbackends); else - *betab = (PgStat_StatBeEntry *)MemoryContextAlloc( - use_mcxt, - sizeof(PgStat_StatBeEntry) * maxbackends); + *betab = (PgStat_StatBeEntry *) MemoryContextAlloc( + use_mcxt, + sizeof(PgStat_StatBeEntry) * maxbackends); break; - /* - * 'B' A PgStat_StatBeEntry follows. - */ + /* + * 'B' A PgStat_StatBeEntry follows. + */ case 'B': if (betab == NULL || numbackends == NULL) { @@ -2363,24 +2361,25 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, fclose(fpin); return; } + /* * Read it directly into the table. */ - if (fread(&(*betab)[havebackends], 1, - sizeof(PgStat_StatBeEntry), fpin) != - sizeof(PgStat_StatBeEntry)) + if (fread(&(*betab)[havebackends], 1, + sizeof(PgStat_StatBeEntry), fpin) != + sizeof(PgStat_StatBeEntry)) { if (pgStatRunningInCollector) { - fprintf(stderr, + fprintf(stderr, "PGSTAT: corrupted pgstat.stat file\n"); fclose(fpin); return; } else { - elog(NOTICE, - "PGSTAT: corrupted pgstat.stat file"); + elog(NOTICE, + "PGSTAT: corrupted pgstat.stat file"); fclose(fpin); return; } @@ -2389,9 +2388,9 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, /* * Count backends per database here. */ - dbentry = (PgStat_StatDBEntry *)hash_search(*dbhash, - (void *) &((*betab)[havebackends].databaseid), - HASH_FIND, NULL); + dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash, + (void *) &((*betab)[havebackends].databaseid), + HASH_FIND, NULL); if (dbentry) dbentry->n_backends++; @@ -2405,9 +2404,9 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, } break; - /* - * 'E' The EOF marker of a complete stats file. - */ + /* + * 'E' The EOF marker of a complete stats file. + */ case 'E': fclose(fpin); return; @@ -2468,13 +2467,13 @@ static void pgstat_recv_activity(PgStat_MsgActivity *msg, int len) { /* - * Here we check explicitly for 0 return, since we don't - * want to mangle the activity of an active backend by - * a delayed packed from a dead one. + * Here we check explicitly for 0 return, since we don't want to + * mangle the activity of an active backend by a delayed packed from a + * dead one. */ if (pgstat_add_backend(&msg->m_hdr) != 0) return; - + strncpy(pgStatBeTable[msg->m_hdr.m_backendid - 1].activity, msg->m_what, PGSTAT_ACTIVITY_SIZE); } @@ -2489,11 +2488,11 @@ pgstat_recv_activity(PgStat_MsgActivity *msg, int len) static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) { - PgStat_TableEntry *tabmsg = &(msg->m_entry[0]); - PgStat_StatDBEntry *dbentry; - PgStat_StatTabEntry *tabentry; - int i; - bool found; + PgStat_TableEntry *tabmsg = &(msg->m_entry[0]); + PgStat_StatDBEntry *dbentry; + PgStat_StatTabEntry *tabentry; + int i; + bool found; /* * Make sure the backend is counted for. @@ -2505,20 +2504,20 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) * Lookup the database in the hashtable. */ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, - (void *) &(msg->m_hdr.m_databaseid), - HASH_FIND, NULL); + (void *) &(msg->m_hdr.m_databaseid), + HASH_FIND, NULL); if (!dbentry) return; /* - * If the database is marked for destroy, this is a delayed - * UDP packet and not worth being counted. + * If the database is marked for destroy, this is a delayed UDP packet + * and not worth being counted. */ if (dbentry->destroy > 0) return; - dbentry->n_xact_commit += (PgStat_Counter)(msg->m_xact_commit); - dbentry->n_xact_rollback += (PgStat_Counter)(msg->m_xact_rollback); + dbentry->n_xact_commit += (PgStat_Counter) (msg->m_xact_commit); + dbentry->n_xact_rollback += (PgStat_Counter) (msg->m_xact_rollback); /* * Process all table entries in the message. @@ -2526,29 +2525,29 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) for (i = 0; i < msg->m_nentries; i++) { tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables, - (void *) &(tabmsg[i].t_id), - HASH_ENTER, &found); + (void *) &(tabmsg[i].t_id), + HASH_ENTER, &found); if (tabentry == NULL) { fprintf(stderr, "PGSTAT: tables hash table out of memory for " - "database %d - abort\n", dbentry->databaseid); + "database %d - abort\n", dbentry->databaseid); exit(1); } if (!found) { /* - * If it's a new table entry, initialize counters - * to the values we just got. + * If it's a new table entry, initialize counters to the + * values we just got. */ - tabentry->numscans = tabmsg[i].t_numscans; - tabentry->tuples_returned = tabmsg[i].t_tuples_returned; - tabentry->tuples_fetched = tabmsg[i].t_tuples_fetched; - tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted; - tabentry->tuples_updated = tabmsg[i].t_tuples_updated; - tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted; - tabentry->blocks_fetched = tabmsg[i].t_blocks_fetched; - tabentry->blocks_hit = tabmsg[i].t_blocks_hit; + tabentry->numscans = tabmsg[i].t_numscans; + tabentry->tuples_returned = tabmsg[i].t_tuples_returned; + tabentry->tuples_fetched = tabmsg[i].t_tuples_fetched; + tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted; + tabentry->tuples_updated = tabmsg[i].t_tuples_updated; + tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted; + tabentry->blocks_fetched = tabmsg[i].t_blocks_fetched; + tabentry->blocks_hit = tabmsg[i].t_blocks_hit; tabentry->destroy = 0; } @@ -2557,21 +2556,21 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) /* * Otherwise add the values to the existing entry. */ - tabentry->numscans += tabmsg[i].t_numscans; - tabentry->tuples_returned += tabmsg[i].t_tuples_returned; - tabentry->tuples_fetched += tabmsg[i].t_tuples_fetched; - tabentry->tuples_inserted += tabmsg[i].t_tuples_inserted; - tabentry->tuples_updated += tabmsg[i].t_tuples_updated; - tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted; - tabentry->blocks_fetched += tabmsg[i].t_blocks_fetched; - tabentry->blocks_hit += tabmsg[i].t_blocks_hit; + tabentry->numscans += tabmsg[i].t_numscans; + tabentry->tuples_returned += tabmsg[i].t_tuples_returned; + tabentry->tuples_fetched += tabmsg[i].t_tuples_fetched; + tabentry->tuples_inserted += tabmsg[i].t_tuples_inserted; + tabentry->tuples_updated += tabmsg[i].t_tuples_updated; + tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted; + tabentry->blocks_fetched += tabmsg[i].t_blocks_fetched; + tabentry->blocks_hit += tabmsg[i].t_blocks_hit; } /* * And add the block IO to the database entry. */ - dbentry->n_blocks_fetched += tabmsg[i].t_blocks_fetched; - dbentry->n_blocks_hit += tabmsg[i].t_blocks_hit; + dbentry->n_blocks_fetched += tabmsg[i].t_blocks_fetched; + dbentry->n_blocks_hit += tabmsg[i].t_blocks_hit; } } @@ -2585,9 +2584,9 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) { - PgStat_StatDBEntry *dbentry; - PgStat_StatTabEntry *tabentry; - int i; + PgStat_StatDBEntry *dbentry; + PgStat_StatTabEntry *tabentry; + int i; /* * Make sure the backend is counted for. @@ -2599,14 +2598,14 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) * Lookup the database in the hashtable. */ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, - (void *) &(msg->m_hdr.m_databaseid), - HASH_FIND, NULL); + (void *) &(msg->m_hdr.m_databaseid), + HASH_FIND, NULL); if (!dbentry) return; /* - * If the database is marked for destroy, this is a delayed - * UDP packet and the tables will go away at DB destruction. + * If the database is marked for destroy, this is a delayed UDP packet + * and the tables will go away at DB destruction. */ if (dbentry->destroy > 0) return; @@ -2617,8 +2616,8 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) for (i = 0; i < msg->m_nentries; i++) { tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables, - (void *) &(msg->m_tableid[i]), - HASH_FIND, NULL); + (void *) &(msg->m_tableid[i]), + HASH_FIND, NULL); if (tabentry) tabentry->destroy = PGSTAT_DESTROY_COUNT; } @@ -2634,7 +2633,7 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len) { - PgStat_StatDBEntry *dbentry; + PgStat_StatDBEntry *dbentry; /* * Make sure the backend is counted for. @@ -2646,8 +2645,8 @@ pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len) * Lookup the database in the hashtable. */ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, - (void *) &(msg->m_databaseid), - HASH_FIND, NULL); + (void *) &(msg->m_databaseid), + HASH_FIND, NULL); if (!dbentry) return; @@ -2667,8 +2666,8 @@ pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len) static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) { - HASHCTL hash_ctl; - PgStat_StatDBEntry *dbentry; + HASHCTL hash_ctl; + PgStat_StatDBEntry *dbentry; /* * Make sure the backend is counted for. @@ -2680,8 +2679,8 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) * Lookup the database in the hashtable. */ dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, - (void *) &(msg->m_hdr.m_databaseid), - HASH_FIND, NULL); + (void *) &(msg->m_hdr.m_databaseid), + HASH_FIND, NULL); if (!dbentry) return; @@ -2692,18 +2691,18 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) if (dbentry->tables != NULL) hash_destroy(dbentry->tables); - dbentry->tables = NULL; - dbentry->n_xact_commit = 0; - dbentry->n_xact_rollback = 0; - dbentry->n_blocks_fetched = 0; - dbentry->n_blocks_hit = 0; - dbentry->n_connects = 0; - dbentry->destroy = 0; + dbentry->tables = NULL; + dbentry->n_xact_commit = 0; + dbentry->n_xact_rollback = 0; + dbentry->n_blocks_fetched = 0; + dbentry->n_blocks_hit = 0; + dbentry->n_connects = 0; + dbentry->destroy = 0; memset(&hash_ctl, 0, sizeof(hash_ctl)); - hash_ctl.keysize = sizeof(Oid); + hash_ctl.keysize = sizeof(Oid); hash_ctl.entrysize = sizeof(PgStat_StatTabEntry); - hash_ctl.hash = tag_hash; + hash_ctl.hash = tag_hash; dbentry->tables = hash_create("Per-database table", PGSTAT_TAB_HASH_SIZE, &hash_ctl, @@ -2711,9 +2710,7 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) if (dbentry->tables == NULL) { fprintf(stderr, "PGSTAT: failed to reinitialize hash table for " - "database entry\n"); + "database entry\n"); exit(1); } } - - diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 08a6ce22c1..1659f09752 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.251 2001/10/22 19:41:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.252 2001/10/25 05:49:40 momjian Exp $ * * NOTES * @@ -116,6 +116,7 @@ sigset_t UnBlockSig, BlockSig, AuthBlockSig; + #else int UnBlockSig, BlockSig, @@ -223,6 +224,7 @@ static unsigned int random_seed = 0; extern char *optarg; extern int optind, opterr; + #ifdef HAVE_INT_OPTRESET extern int optreset; #endif @@ -245,9 +247,12 @@ static void usage(const char *); static int ServerLoop(void); static int BackendStartup(Port *port); static int ProcessStartupPacket(Port *port, bool SSLdone); -static void processCancelRequest(Port *port, void *pkt); +static void processCancelRequest(Port *port, void *pkt); static int initMasks(fd_set *rmask, fd_set *wmask); -enum CAC_state { CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY }; +enum CAC_state +{ + CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY +}; static enum CAC_state canAcceptConnections(void); static long PostmasterRandom(void); static void RandomSalt(char *cryptSalt, char *md5Salt); @@ -255,7 +260,8 @@ static void SignalChildren(int signal); static int CountChildren(void); static bool CreateOptsFile(int argc, char *argv[]); static pid_t SSDataBase(int xlop); -static void postmaster_error(const char *fmt, ...) +static void +postmaster_error(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); @@ -278,14 +284,14 @@ checkDataDir(const char *checkdir) if (checkdir == NULL) { fprintf(stderr, gettext( - "%s does not know where to find the database system data.\n" - "You must specify the directory that contains the database system\n" - "either by specifying the -D invocation option or by setting the\n" - "PGDATA environment variable.\n\n"), + "%s does not know where to find the database system data.\n" + "You must specify the directory that contains the database system\n" + "either by specifying the -D invocation option or by setting the\n" + "PGDATA environment variable.\n\n"), progname); ExitPostmaster(2); } - + /* * Check if the directory has group or world access. If so, reject. */ @@ -311,9 +317,9 @@ checkDataDir(const char *checkdir) if (fp == NULL) { fprintf(stderr, gettext( - "%s does not find the database system.\n" - "Expected to find it in the PGDATA directory \"%s\",\n" - "but unable to open file \"%s\": %s\n\n"), + "%s does not find the database system.\n" + "Expected to find it in the PGDATA directory \"%s\",\n" + "but unable to open file \"%s\": %s\n\n"), progname, checkdir, path, strerror(errno)); ExitPostmaster(2); } @@ -464,6 +470,7 @@ PostmasterMain(int argc, char *argv[]) /* already done above */ break; case 'd': + /* * Turn on debugging for the postmaster and the backend * servers descended from it. @@ -583,9 +590,8 @@ PostmasterMain(int argc, char *argv[]) } /* - * Now that we are done processing the postmaster arguments, - * reset getopt(3) library so that it will work correctly in - * subprocesses. + * Now that we are done processing the postmaster arguments, reset + * getopt(3) library so that it will work correctly in subprocesses. */ optind = 1; #ifdef HAVE_INT_OPTRESET @@ -649,8 +655,9 @@ PostmasterMain(int argc, char *argv[]) ExitPostmaster(1); /* - * Remove old temporary files. At this point there can be no other - * Postgres processes running in this directory, so this should be safe. + * Remove old temporary files. At this point there can be no other + * Postgres processes running in this directory, so this should be + * safe. */ RemovePgTempFiles(); @@ -725,9 +732,9 @@ PostmasterMain(int argc, char *argv[]) /* * Reset whereToSendOutput from Debug (its starting state) to None. * This prevents elog from sending messages to stderr unless the - * syslog/stderr switch permits. We don't do this until the postmaster - * is fully launched, since startup failures may as well be reported - * to stderr. + * syslog/stderr switch permits. We don't do this until the + * postmaster is fully launched, since startup failures may as well be + * reported to stderr. */ whereToSendOutput = None; @@ -938,8 +945,8 @@ ServerLoop(void) } /* - * New connection pending on our well-known port's socket? - * If so, fork a child process to deal with it. + * New connection pending on our well-known port's socket? If so, + * fork a child process to deal with it. */ #ifdef HAVE_UNIX_SOCKETS @@ -950,9 +957,10 @@ ServerLoop(void) if (port) { BackendStartup(port); + /* - * We no longer need the open socket or port structure - * in this process + * We no longer need the open socket or port structure in + * this process */ StreamClose(port->sock); ConnFree(port); @@ -967,9 +975,10 @@ ServerLoop(void) if (port) { BackendStartup(port); + /* - * We no longer need the open socket or port structure - * in this process + * We no longer need the open socket or port structure in + * this process */ StreamClose(port->sock); ConnFree(port); @@ -1083,7 +1092,7 @@ ProcessStartupPacket(Port *port, bool SSLdone) { elog(DEBUG, "failed to send SSL negotiation response: %s", strerror(errno)); - return STATUS_ERROR; /* close the connection */ + return STATUS_ERROR; /* close the connection */ } #ifdef USE_SSL @@ -1131,8 +1140,7 @@ ProcessStartupPacket(Port *port, bool SSLdone) /* * Truncate given database and user names to length of a Postgres - * name. This avoids lookup failures when overlength names are - * given. + * name. This avoids lookup failures when overlength names are given. */ if ((int) sizeof(port->database) >= NAMEDATALEN) port->database[NAMEDATALEN - 1] = '\0'; @@ -1241,14 +1249,15 @@ canAcceptConnections(void) return CAC_STARTUP; if (FatalError) return CAC_RECOVERY; + /* * Don't start too many children. * - * We allow more connections than we can have backends here because - * some might still be authenticating; they might fail auth, or some - * existing backend might exit before the auth cycle is completed. - * The exact MaxBackends limit is enforced when a new backend tries - * to join the shared-inval backend array. + * We allow more connections than we can have backends here because some + * might still be authenticating; they might fail auth, or some + * existing backend might exit before the auth cycle is completed. The + * exact MaxBackends limit is enforced when a new backend tries to + * join the shared-inval backend array. */ if (CountChildren() >= 2 * MaxBackends) return CAC_TOOMANY; @@ -1340,7 +1349,6 @@ ClosePostmasterPorts(bool pgstat_too) static void reset_shared(unsigned short port) { - /* * Reset assignment of shared mem and semaphore IPC keys. Doing this * means that in normal cases we'll assign the same keys on each @@ -1529,8 +1537,10 @@ static void reaper(SIGNAL_ARGS) { int save_errno = errno; + #ifdef HAVE_WAITPID int status; /* backend exit status */ + #else union wait status; /* backend exit status */ #endif @@ -1552,9 +1562,10 @@ reaper(SIGNAL_ARGS) { exitstatus = status.w_status; #endif + /* - * Check if this child was the statistics collector. If - * so, start a new one. + * Check if this child was the statistics collector. If so, start + * a new one. */ if (pgstat_ispgstat(pid)) { @@ -1843,8 +1854,8 @@ BackendStartup(Port *port) MyCancelKey = PostmasterRandom(); /* - * Make room for backend data structure. Better before the fork() - * so we can handle failure cleanly. + * Make room for backend data structure. Better before the fork() so + * we can handle failure cleanly. */ bn = (Backend *) malloc(sizeof(Backend)); if (!bn) @@ -1873,7 +1884,7 @@ BackendStartup(Port *port) if (pid == 0) /* child */ { - int status; + int status; free(bn); #ifdef __BEOS__ @@ -2001,10 +2012,11 @@ DoBackend(Port *port) /* * Initialize libpq and enable reporting of elog errors to the client. - * Must do this now because authentication uses libpq to send messages. + * Must do this now because authentication uses libpq to send + * messages. */ pq_init(); /* initialize libpq to talk to client */ - whereToSendOutput = Remote; /* now safe to elog to client */ + whereToSendOutput = Remote; /* now safe to elog to client */ /* * We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT @@ -2016,9 +2028,9 @@ DoBackend(Port *port) * * PreAuthDelay is a debugging aid for investigating problems in the * authentication cycle: it can be set in postgresql.conf to allow - * time to attach to the newly-forked backend with a debugger. - * (See also the -W backend switch, which we allow clients to pass - * through PGOPTIONS, but it is not honored until after authentication.) + * time to attach to the newly-forked backend with a debugger. (See + * also the -W backend switch, which we allow clients to pass through + * PGOPTIONS, but it is not honored until after authentication.) */ pqsignal(SIGTERM, authdie); pqsignal(SIGQUIT, authdie); @@ -2028,7 +2040,7 @@ DoBackend(Port *port) if (PreAuthDelay > 0) sleep(PreAuthDelay); - if (! enable_sigalrm_interrupt(AuthenticationTimeout * 1000)) + if (!enable_sigalrm_interrupt(AuthenticationTimeout * 1000)) elog(FATAL, "DoBackend: Unable to set timer for auth timeout"); /* @@ -2042,7 +2054,8 @@ DoBackend(Port *port) /* * Now that we have the user and database name, we can set the process - * title for ps. It's good to do this as early as possible in startup. + * title for ps. It's good to do this as early as possible in + * startup. * * But first, we need the remote host name. */ @@ -2101,10 +2114,10 @@ DoBackend(Port *port) ClientAuthentication(port); /* might not return, if failure */ /* - * Done with authentication. Disable timeout, and prevent SIGTERM/SIGQUIT - * again until backend startup is complete. + * Done with authentication. Disable timeout, and prevent + * SIGTERM/SIGQUIT again until backend startup is complete. */ - if (! disable_sigalrm_interrupt()) + if (!disable_sigalrm_interrupt()) elog(FATAL, "DoBackend: Unable to disable timer for auth timeout"); PG_SETMASK(&BlockSig); @@ -2294,14 +2307,15 @@ RandomSalt(char *cryptSalt, char *md5Salt) cryptSalt[0] = CharRemap(rand % 62); cryptSalt[1] = CharRemap(rand / 62); + /* - * It's okay to reuse the first random value for one of the MD5 salt bytes, - * since only one of the two salts will be sent to the client. After that - * we need to compute more random bits. + * It's okay to reuse the first random value for one of the MD5 salt + * bytes, since only one of the two salts will be sent to the client. + * After that we need to compute more random bits. * * We use % 255, sacrificing one possible byte value, so as to ensure - * that all bits of the random() value participate in the result. While - * at it, add one to avoid generating any null bytes. + * that all bits of the random() value participate in the result. + * While at it, add one to avoid generating any null bytes. */ md5Salt[0] = (rand % 255) + 1; rand = PostmasterRandom(); @@ -2391,7 +2405,6 @@ InitSSL(void) ExitPostmaster(1); } } - #endif /* @@ -2428,7 +2441,8 @@ SSDataBase(int xlop) beos_backend_startup(); #endif - IsUnderPostmaster = true; /* we are a postmaster subprocess now */ + IsUnderPostmaster = true; /* we are a postmaster subprocess + * now */ /* Lose the postmaster's on-exit routines and port connections */ on_exit_reset(); @@ -2487,7 +2501,7 @@ SSDataBase(int xlop) beos_backend_startup_failed(); #endif - switch(xlop) + switch (xlop) { case BS_XLOG_STARTUP: elog(DEBUG, "could not launch startup process (fork failure): %s", @@ -2585,9 +2599,9 @@ CreateOptsFile(int argc, char *argv[]) static void -postmaster_error(const char *fmt, ...) +postmaster_error(const char *fmt,...) { - va_list ap; + va_list ap; fprintf(stderr, "%s: ", progname); va_start(ap, fmt); diff --git a/src/backend/regex/engine.c b/src/backend/regex/engine.c index 2d7f4ee92d..79b71415ed 100644 --- a/src/backend/regex/engine.c +++ b/src/backend/regex/engine.c @@ -87,15 +87,15 @@ struct match states empty; /* empty set of states */ }; -static int matcher(struct re_guts * g, pg_wchar * string, size_t nmatch, +static int matcher(struct re_guts * g, pg_wchar *string, size_t nmatch, regmatch_t *pmatch, int eflags); -static pg_wchar *dissect(struct match * m, pg_wchar * start, pg_wchar * stop, +static pg_wchar *dissect(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst); -static pg_wchar *backref(struct match * m, pg_wchar * start, pg_wchar * stop, +static pg_wchar *backref(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst, sopno lev); -static pg_wchar *fast(struct match * m, pg_wchar * start, pg_wchar * stop, +static pg_wchar *fast(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst); -static pg_wchar *slow(struct match * m, pg_wchar * start, pg_wchar * stop, +static pg_wchar *slow(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst); static states step(struct re_guts * g, sopno start, sopno stop, states bef, int ch, states aft); @@ -117,13 +117,12 @@ static states step(struct re_guts * g, sopno start, #endif #ifdef REDEBUG -static void print(struct match * m, pg_wchar * caption, states st, int ch, +static void print(struct match * m, pg_wchar *caption, states st, int ch, FILE *d); -static void at(struct match * m, pg_wchar * title, pg_wchar * start, - pg_wchar * stop, sopno startst, sopno stopst); +static void at(struct match * m, pg_wchar *title, pg_wchar *start, + pg_wchar *stop, sopno startst, sopno stopst); static pg_wchar *pchar(int ch); static int pg_isprint(int c); - #endif #ifdef REDEBUG @@ -145,7 +144,7 @@ do { \ * matcher - the actual matching engine */ static int /* 0 success, REG_NOMATCH failure */ -matcher(struct re_guts * g, pg_wchar * string, size_t nmatch, +matcher(struct re_guts * g, pg_wchar *string, size_t nmatch, regmatch_t *pmatch, int eflags) { pg_wchar *endp; @@ -331,7 +330,7 @@ matcher(struct re_guts * g, pg_wchar * string, size_t nmatch, * dissect - figure out what matched what, no back references */ static pg_wchar * /* == stop (success) always */ -dissect(struct match * m, pg_wchar * start, pg_wchar * stop, +dissect(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst) { int i; @@ -527,7 +526,7 @@ dissect(struct match * m, pg_wchar * start, pg_wchar * stop, * lev is PLUS nesting level */ static pg_wchar * /* == stop (success) or NULL (failure) */ -backref(struct match * m, pg_wchar * start, pg_wchar * stop, +backref(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst, sopno lev) { int i; @@ -686,7 +685,7 @@ backref(struct match * m, pg_wchar * start, pg_wchar * stop, return dp; /* that one missed, try next one */ if (OP(m->g->strip[esub]) == O_CH) - return NULL;/* there is none */ + return NULL; /* there is none */ esub++; assert(OP(m->g->strip[esub]) == OOR2); ssub = esub + 1; @@ -734,7 +733,7 @@ backref(struct match * m, pg_wchar * start, pg_wchar * stop, * fast - step through the string at top speed */ static pg_wchar * /* where tentative match ended, or NULL */ -fast(struct match * m, pg_wchar * start, pg_wchar * stop, +fast(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst) { states st = m->st; @@ -823,7 +822,7 @@ fast(struct match * m, pg_wchar * start, pg_wchar * stop, * slow - step through the string more deliberately */ static pg_wchar * /* where it ended */ -slow(struct match * m, pg_wchar * start, pg_wchar * stop, +slow(struct match * m, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst) { states st = m->st; @@ -1029,7 +1028,7 @@ step(struct re_guts * g, * print - print a set of states */ static void -print(struct match * m, pg_wchar * caption, states st, +print(struct match * m, pg_wchar *caption, states st, int ch, FILE *d) { struct re_guts *g = m->g; @@ -1055,7 +1054,7 @@ print(struct match * m, pg_wchar * caption, states st, * at - print current situation */ static void -at(struct match * m, pg_wchar * title, pg_wchar * start, pg_wchar * stop, +at(struct match * m, pg_wchar *title, pg_wchar *start, pg_wchar *stop, sopno startst, sopno stopst) { if (!(m->eflags & REG_TRACE)) @@ -1097,7 +1096,6 @@ pg_isprint(int c) return (isprint((unsigned char) c)); #endif } - #endif #endif diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 837a12c27c..3b433b20f4 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -88,7 +88,6 @@ static unsigned char othercase(int ch); #else static char othercase(int ch); - #endif static void bothcases(struct parse * p, int ch); static void ordinary(struct parse * p, int ch); @@ -173,7 +172,6 @@ pg95_regcomp(regex_t *preg, const char *pattern, int cflags) #ifdef MULTIBYTE pg_wchar *wcp; - #endif #ifdef REDEBUG @@ -724,7 +722,6 @@ p_bracket(struct parse * p) #ifdef MULTIBYTE pg_wchar sp1[] = {'[', ':', '<', ':', ']', ']'}; pg_wchar sp2[] = {'[', ':', '>', ':', ']', ']'}; - #endif /* Dept of Truly Sickening Special-Case Kludges */ @@ -930,7 +927,7 @@ p_b_eclass(struct parse * p, cset *cs) /* * p_b_symbol - parse a character or [..]ed multicharacter collating symbol */ -static pg_wchar /* value of symbol */ +static pg_wchar /* value of symbol */ p_b_symbol(struct parse * p) { pg_wchar value; @@ -1020,7 +1017,7 @@ bothcases(struct parse * p, int ch) pg_wchar *oldend = p->end; pg_wchar bracket[3]; - assert(othercase(ch) != ch);/* p_bracket() would recurse */ + assert(othercase(ch) != ch); /* p_bracket() would recurse */ p->next = bracket; p->end = bracket + 2; bracket[0] = ch; @@ -1110,7 +1107,7 @@ repeat(struct parse * p, case REP(0, N): /* as x{1,n}? */ case REP(0, INF): /* as x{1,}? */ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start);/* offset is wrong... */ + INSERT(OCH_, start); /* offset is wrong... */ repeat(p, start + 1, 1, to); ASTERN(OOR1, start); AHEAD(start); /* ... fix it */ diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index b1733a9d40..4767730441 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -126,7 +126,7 @@ do { \ do { \ free((m)->space); \ } while (0) - + #define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) #define onestate int #define INIT(o, n) ((o) = (n)) @@ -157,7 +157,6 @@ pg95_regexec(const regex_t *preg, const char *string, size_t nmatch, #ifdef MULTIBYTE pg_wchar *str; int sts; - #endif #ifdef REDEBUG diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 3b3d209d46..f3e2306a00 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.97 2001/07/09 23:50:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.98 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,10 +33,10 @@ static Query *rewriteRuleAction(Query *parsetree, - Query *rule_action, - Node *rule_qual, - int rt_index, - CmdType event); + Query *rule_action, + Node *rule_qual, + int rt_index, + CmdType event); static List *adjustJoinTreeList(Query *parsetree, bool removert, int rt_index); static void markQueryForUpdate(Query *qry, bool skipOldNew); static List *matchLocks(CmdType event, RuleLock *rulelocks, @@ -92,16 +92,16 @@ rewriteRuleAction(Query *parsetree, PRS2_OLD_VARNO + rt_length, rt_index, 0); /* - * Generate expanded rtable consisting of main parsetree's rtable - * plus rule action's rtable; this becomes the complete rtable for the - * rule action. Some of the entries may be unused after we finish - * rewriting, but if we tried to clean those out we'd have a much harder - * job to adjust RT indexes in the query's Vars. It's OK to have unused - * RT entries, since planner will ignore them. + * Generate expanded rtable consisting of main parsetree's rtable plus + * rule action's rtable; this becomes the complete rtable for the rule + * action. Some of the entries may be unused after we finish + * rewriting, but if we tried to clean those out we'd have a much + * harder job to adjust RT indexes in the query's Vars. It's OK to + * have unused RT entries, since planner will ignore them. * * NOTE: because planner will destructively alter rtable, we must ensure - * that rule action's rtable is separate and shares no substructure with - * the main rtable. Hence do a deep copy here. + * that rule action's rtable is separate and shares no substructure + * with the main rtable. Hence do a deep copy here. */ sub_action->rtable = nconc((List *) copyObject(parsetree->rtable), sub_action->rtable); @@ -118,8 +118,8 @@ rewriteRuleAction(Query *parsetree, * joined twice, however, so avoid keeping it if the rule action * mentions it. * - * As above, the action's jointree must not share substructure with - * the main parsetree's. + * As above, the action's jointree must not share substructure with the + * main parsetree's. */ if (sub_action->jointree != NULL) { @@ -129,7 +129,7 @@ rewriteRuleAction(Query *parsetree, keeporig = (!rangeTableEntry_used((Node *) sub_action->jointree, rt_index, 0)) && (rangeTableEntry_used(rule_qual, rt_index, 0) || - rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); + rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); newjointree = adjustJoinTreeList(parsetree, !keeporig, rt_index); sub_action->jointree->fromlist = nconc(newjointree, sub_action->jointree->fromlist); @@ -139,8 +139,8 @@ rewriteRuleAction(Query *parsetree, * We copy the qualifications of the parsetree to the action and vice * versa. So force hasSubLinks if one of them has it. If this is not * right, the flag will get cleared later, but we mustn't risk having - * it not set when it needs to be. (XXX this should probably be handled - * by AddQual and friends, not here...) + * it not set when it needs to be. (XXX this should probably be + * handled by AddQual and friends, not here...) */ if (parsetree->hasSubLinks) sub_action->hasSubLinks = TRUE; @@ -313,7 +313,6 @@ ApplyRetrieveRule(Query *parsetree, */ if (intMember(rt_index, parsetree->rowMarks)) { - /* * Remove the view from the list of rels that will actually be * marked FOR UPDATE by the executor. It will still be access- @@ -482,10 +481,10 @@ fireRIRrules(Query *parsetree) rel = heap_openr(rte->relname, lockmode); /* - * Check to see if relation's OID matches the RTE. If not, the RTE - * actually refers to an older relation that had the same name. - * Eventually we might want to reparse the referencing rule, but - * for now all we can do is punt. + * Check to see if relation's OID matches the RTE. If not, the + * RTE actually refers to an older relation that had the same + * name. Eventually we might want to reparse the referencing rule, + * but for now all we can do is punt. */ if (RelationGetRelid(rel) != rte->relid) elog(ERROR, "Relation \"%s\" with OID %u no longer exists", @@ -771,8 +770,8 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) /* * Check to see if relation's OID matches the RTE. If not, the RTE * actually refers to an older relation that had the same name. - * Eventually we might want to reparse the referencing rule, but - * for now all we can do is punt. + * Eventually we might want to reparse the referencing rule, but for + * now all we can do is punt. */ if (RelationGetRelid(rt_entry_relation) != rt_entry->relid) elog(ERROR, "Relation \"%s\" with OID %u no longer exists", @@ -845,12 +844,13 @@ deepRewriteQuery(Query *parsetree) } /* - * For INSERTs, the original query is done first; for UPDATE/DELETE, it is - * done last. This is needed because update and delete rule actions might - * not do anything if they are invoked after the update or delete is - * performed. The command counter increment between the query execution - * makes the deleted (and maybe the updated) tuples disappear so the scans - * for them in the rule actions cannot find them. + * For INSERTs, the original query is done first; for UPDATE/DELETE, + * it is done last. This is needed because update and delete rule + * actions might not do anything if they are invoked after the update + * or delete is performed. The command counter increment between the + * query execution makes the deleted (and maybe the updated) tuples + * disappear so the scans for them in the rule actions cannot find + * them. */ if (parsetree->commandType == CMD_INSERT) { @@ -860,6 +860,7 @@ deepRewriteQuery(Query *parsetree) */ if (qual_products != NIL) rewritten = nconc(qual_products, rewritten); + /* * Add the unmodified original query, if no INSTEAD rule was seen. */ @@ -874,6 +875,7 @@ deepRewriteQuery(Query *parsetree) */ if (qual_products != NIL) rewritten = nconc(rewritten, qual_products); + /* * Add the unmodified original query, if no INSTEAD rule was seen. */ diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 238897d58e..63e0ced180 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.58 2001/09/07 20:52:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.59 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,6 @@ static bool checkExprHasSubLink_walker(Node *node, void *context); bool checkExprHasAggs(Node *node) { - /* * If a Query is passed, examine it --- but we will not recurse into * sub-Queries. @@ -74,7 +73,6 @@ checkExprHasAggs_walker(Node *node, void *context) bool checkExprHasSubLink(Node *node) { - /* * If a Query is passed, examine it --- but we will not recurse into * sub-Queries. @@ -596,13 +594,13 @@ AddQual(Query *parsetree, Node *qual) * There's noplace to put the qual on a utility statement. * * If it's a NOTIFY, silently ignore the qual; this means that the - * NOTIFY will execute, whether or not there are any qualifying rows. - * While clearly wrong, this is much more useful than refusing to - * execute the rule at all, and extra NOTIFY events are harmless for - * typical uses of NOTIFY. + * NOTIFY will execute, whether or not there are any qualifying + * rows. While clearly wrong, this is much more useful than + * refusing to execute the rule at all, and extra NOTIFY events + * are harmless for typical uses of NOTIFY. * - * If it isn't a NOTIFY, error out, since unconditional execution - * of other utility stmts is unlikely to be wanted. (This case is + * If it isn't a NOTIFY, error out, since unconditional execution of + * other utility stmts is unlikely to be wanted. (This case is * not currently allowed anyway, but keep the test for safety.) */ if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) @@ -680,7 +678,6 @@ AddNotHavingQual(Query *parsetree, Node *havingQual) AddHavingQual(parsetree, notqual); } - #endif void @@ -733,7 +730,6 @@ FindMatchingTLEntry(List *tlist, char *e_attname) } return NULL; } - #endif @@ -999,5 +995,4 @@ HandleRIRAttributeRule(Query *parsetree, query_tree_mutator(parsetree, HandleRIRAttributeRule_mutator, (void *) &context, true); } - #endif /* NOT_USED */ diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 322c45b031..cd0453c573 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.45 2001/10/01 05:36:13 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.46 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -183,8 +183,8 @@ InitBufferPool(void) /* * link the buffers into a circular, doubly-linked list to - * initialize free list, and initialize the buffer headers. - * Still don't know anything about replacement strategy in this file. + * initialize free list, and initialize the buffer headers. Still + * don't know anything about replacement strategy in this file. */ for (i = 0; i < Data_Descriptors; block += BLCKSZ, buf++, i++) { diff --git a/src/backend/storage/buffer/buf_table.c b/src/backend/storage/buffer/buf_table.c index d54d5e6915..eb4ce0330c 100644 --- a/src/backend/storage/buffer/buf_table.c +++ b/src/backend/storage/buffer/buf_table.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.24 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.25 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,7 +61,7 @@ InitBufTable(void) BufferDesc * BufTableLookup(BufferTag *tagPtr) { - BufferLookupEnt *result; + BufferLookupEnt *result; if (tagPtr->blockNum == P_NEW) return NULL; @@ -80,7 +80,7 @@ BufTableLookup(BufferTag *tagPtr) bool BufTableDelete(BufferDesc *buf) { - BufferLookupEnt *result; + BufferLookupEnt *result; /* * buffer not initialized or has been removed from table already. @@ -116,7 +116,7 @@ BufTableDelete(BufferDesc *buf) bool BufTableInsert(BufferDesc *buf) { - BufferLookupEnt *result; + BufferLookupEnt *result; bool found; /* cannot insert it twice */ @@ -152,5 +152,4 @@ DBG_LookupListCheck(int nlookup) hash_stats("Shared", SharedBufHash); } - #endif diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 86c2c478f4..0a74896e95 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.117 2001/09/29 04:02:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.118 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,9 +88,9 @@ extern void AbortBufferIO(void); #define BUFFER_IS_BROKEN(buf) ((buf->flags & BM_IO_ERROR) && !(buf->flags & BM_DIRTY)) static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum, - bool bufferLockHeld); + bool bufferLockHeld); static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, - bool *foundPtr); + bool *foundPtr); static int ReleaseBufferWithBufferLock(Buffer buffer); static int BufferReplace(BufferDesc *bufHdr); void PrintBufferDescs(void); @@ -173,6 +173,7 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum, blockNum = reln->rd_nblocks = smgrnblocks(DEFAULT_SMGR, reln); reln->rd_nblocks++; } + /* * lookup the buffer. IO_IN_PROGRESS is set if the requested * block is not currently in memory. @@ -198,12 +199,14 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum, /* That is, we're done if we expected to be able to find it ... */ if (!isExtend) return BufferDescriptorGetBuffer(bufHdr); + /* - * If we found a buffer when we were expecting to extend the relation, - * the implication is that a buffer was already created for the next - * page position, but then smgrextend failed to write the page. - * We'd better try the smgrextend again. But since BufferAlloc - * won't have done StartBufferIO, we must do that first. + * If we found a buffer when we were expecting to extend the + * relation, the implication is that a buffer was already created + * for the next page position, but then smgrextend failed to write + * the page. We'd better try the smgrextend again. But since + * BufferAlloc won't have done StartBufferIO, we must do that + * first. */ if (!isLocalBuf) { @@ -308,7 +311,6 @@ BufferAlloc(Relation reln, buf = BufTableLookup(&newTag); if (buf != NULL) { - /* * Found it. Now, (a) pin the buffer so no one steals it from the * buffer pool, (b) check IO_IN_PROGRESS, someone may be faulting @@ -326,7 +328,6 @@ BufferAlloc(Relation reln, } if (BUFFER_IS_BROKEN(buf)) { - /* * I couldn't understand the following old comment. If there's * no IO for the buffer and the buffer is BROKEN,it should be @@ -481,7 +482,6 @@ BufferAlloc(Relation reln, buf2 = BufTableLookup(&newTag); if (buf2 != NULL) { - /* * Found it. Someone has already done what we're about to * do. We'll just handle this as if it were found in the @@ -853,9 +853,9 @@ WaitIO(BufferDesc *buf) /* * Changed to wait until there's no IO - Inoue 01/13/2000 * - * Note this is *necessary* because an error abort in the process - * doing I/O could release the io_in_progress_lock prematurely. - * See AbortBufferIO. + * Note this is *necessary* because an error abort in the process doing + * I/O could release the io_in_progress_lock prematurely. See + * AbortBufferIO. */ while ((buf->flags & BM_IO_IN_PROGRESS) != 0) { @@ -930,7 +930,7 @@ ResetBufferPool(bool isCommit) { BufferDesc *buf = &BufferDescriptors[i]; - PrivateRefCount[i] = 1; /* make sure we release shared pin */ + PrivateRefCount[i] = 1; /* make sure we release shared pin */ LWLockAcquire(BufMgrLock, LW_EXCLUSIVE); UnpinBuffer(buf); LWLockRelease(BufMgrLock); @@ -1090,9 +1090,9 @@ BlockNumber RelationGetNumberOfBlocks(Relation relation) { /* - * relation->rd_nblocks should be accurate already if the relation - * is myxactonly. (XXX how safe is that really?) Don't call smgr - * on a view, either. + * relation->rd_nblocks should be accurate already if the relation is + * myxactonly. (XXX how safe is that really?) Don't call smgr on a + * view, either. */ if (relation->rd_rel->relkind == RELKIND_VIEW) relation->rd_nblocks = 0; @@ -1147,7 +1147,6 @@ DropRelationBuffers(Relation rel) recheck: if (RelFileNodeEquals(bufHdr->tag.rnode, rel->rd_node)) { - /* * If there is I/O in progress, better wait till it's done; * don't want to delete the relation out from under someone @@ -1231,7 +1230,6 @@ DropRelFileNodeBuffers(RelFileNode rnode) recheck: if (RelFileNodeEquals(bufHdr->tag.rnode, rnode)) { - /* * If there is I/O in progress, better wait till it's done; * don't want to delete the relation out from under someone @@ -1307,7 +1305,6 @@ recheck: */ if (bufHdr->tag.rnode.tblNode == dbid) { - /* * If there is I/O in progress, better wait till it's done; * don't want to delete the database out from under someone @@ -1428,7 +1425,6 @@ BufferPoolBlowaway() BufTableDelete(&BufferDescriptors[i - 1]); } } - #endif /* --------------------------------------------------------------------- @@ -1681,7 +1677,6 @@ refcount = %ld, file: %s, line: %d\n", PrivateRefCount[buffer - 1], file, line); } } - #endif #ifdef NOT_USED @@ -1701,7 +1696,6 @@ refcount = %ld, file: %s, line: %d\n", PrivateRefCount[buffer - 1], file, line); } } - #endif #ifdef NOT_USED @@ -1742,7 +1736,6 @@ refcount = %ld, file: %s, line: %d\n", } return b; } - #endif #ifdef BMTRACE @@ -1888,7 +1881,6 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo, kill(getpid(), SIGILL); } - #endif /* BMTRACE */ /* @@ -1943,7 +1935,7 @@ UnlockBuffers(void) for (i = 0; i < NBuffers; i++) { - bits8 buflocks = BufferLocks[i]; + bits8 buflocks = BufferLocks[i]; if (buflocks == 0) continue; @@ -1960,9 +1952,11 @@ UnlockBuffers(void) if (buflocks & BL_PIN_COUNT_LOCK) { LWLockAcquire(BufMgrLock, LW_EXCLUSIVE); + /* - * Don't complain if flag bit not set; it could have been reset - * but we got a cancel/die interrupt before getting the signal. + * Don't complain if flag bit not set; it could have been + * reset but we got a cancel/die interrupt before getting the + * signal. */ if ((buf->flags & BM_PIN_COUNT_WAITER) != 0 && buf->wait_backend_id == MyBackendId) @@ -1992,13 +1986,9 @@ LockBuffer(Buffer buffer, int mode) buf = &(BufferDescriptors[buffer - 1]); if (mode == BUFFER_LOCK_UNLOCK) - { LWLockRelease(buf->cntx_lock); - } else if (mode == BUFFER_LOCK_SHARE) - { LWLockAcquire(buf->cntx_lock, LW_SHARED); - } else if (mode == BUFFER_LOCK_EXCLUSIVE) { LWLockAcquire(buf->cntx_lock, LW_EXCLUSIVE); @@ -2012,9 +2002,7 @@ LockBuffer(Buffer buffer, int mode) buf->cntxDirty = true; } else - { elog(ERROR, "LockBuffer: unknown lock mode %d", mode); - } } /* @@ -2163,7 +2151,6 @@ InitBufferIO(void) { InProgressBuf = (BufferDesc *) 0; } - #endif /* @@ -2180,11 +2167,11 @@ AbortBufferIO(void) if (buf) { /* - * Since LWLockReleaseAll has already been called, - * we're not holding the buffer's io_in_progress_lock. - * We have to re-acquire it so that we can use TerminateBufferIO. - * Anyone who's executing WaitIO on the buffer will be in a busy spin - * until we succeed in doing this. + * Since LWLockReleaseAll has already been called, we're not + * holding the buffer's io_in_progress_lock. We have to re-acquire + * it so that we can use TerminateBufferIO. Anyone who's executing + * WaitIO on the buffer will be in a busy spin until we succeed in + * doing this. */ LWLockAcquire(buf->io_in_progress_lock, LW_EXCLUSIVE); diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index f8ac2e287c..073d3ae4fc 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.25 2001/09/29 04:02:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.26 2001/10/25 05:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,7 +91,7 @@ AddBufferToFreelist(BufferDesc *bf) void PinBuffer(BufferDesc *buf) { - int b = BufferDescriptorGetBuffer(buf) - 1; + int b = BufferDescriptorGetBuffer(buf) - 1; if (buf->refcount == 0) { @@ -129,7 +129,6 @@ refcount = %ld, file: %s, line: %d\n", PrivateRefCount[buffer - 1], file, line); } } - #endif #undef UnpinBuffer @@ -143,7 +142,7 @@ refcount = %ld, file: %s, line: %d\n", void UnpinBuffer(BufferDesc *buf) { - int b = BufferDescriptorGetBuffer(buf) - 1; + int b = BufferDescriptorGetBuffer(buf) - 1; IsNotInQueue(buf); Assert(buf->refcount > 0); @@ -186,7 +185,6 @@ refcount = %ld, file: %s, line: %d\n", PrivateRefCount[buffer - 1], file, line); } } - #endif /* @@ -277,7 +275,6 @@ DBG_FreeListCheck(int nfree) printf("\tfree list corrupted: %d-th buffer is %d\n", nfree, buf->buf_id); } - #endif #ifdef NOT_USED @@ -312,5 +309,4 @@ PrintBufferFreeList() buf = &(BufferDescriptors[buf->freeNext]); } } - #endif diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index 2ce6d31c38..bb8b8f39a7 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.10 2001/03/22 03:59:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.11 2001/10/25 05:49:41 momjian Exp $ * * NOTES: * @@ -135,7 +135,7 @@ extendBufFile(BufFile *file) * multiple temporary files if more than MAX_PHYSICAL_FILESIZE bytes are * written to it). */ -BufFile * +BufFile * BufFileCreateTemp(void) { BufFile *file; @@ -158,12 +158,11 @@ BufFileCreateTemp(void) * to attach a BufFile to a non-temporary file. Note that BufFiles created * in this way CANNOT be expanded into multiple files. */ -BufFile * +BufFile * BufFileCreate(File file) { return makeBufFile(file); } - #endif /* @@ -254,7 +253,6 @@ BufFileDumpBuffer(BufFile *file) */ while (wpos < file->nbytes) { - /* * Advance to next component file if necessary and possible. */ @@ -489,7 +487,6 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence) newOffset >= file->curOffset && newOffset <= file->curOffset + file->nbytes) { - /* * Seek is to a point within existing buffer; we can just adjust * pos-within-buffer, without flushing buffer. Note this is OK @@ -575,5 +572,4 @@ BufFileTellBlock(BufFile *file) blknum += file->curFile * RELSEG_SIZE; return blknum; } - #endif diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index c2db3c8dea..3c6722863e 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.84 2001/09/30 18:57:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.85 2001/10/25 05:49:41 momjian Exp $ * * NOTES: * @@ -92,7 +92,7 @@ * far beyond what they can really support. This GUC parameter limits what * we will believe. */ -int max_files_per_process = 1000; +int max_files_per_process = 1000; /* Debugging.... */ @@ -122,7 +122,7 @@ typedef struct vfd #define FD_TEMPORARY (1 << 1)/* should be unlinked when closed */ File nextFree; /* link to next free VFD, if in freelist */ - File lruMoreRecently;/* doubly linked recency-of-use list */ + File lruMoreRecently; /* doubly linked recency-of-use list */ File lruLessRecently; long seekPos; /* current logical file position */ char *fileName; /* name of file, or NULL for unused VFD */ @@ -307,16 +307,16 @@ pg_nofile(void) elog(DEBUG, "pg_nofile: sysconf(_SC_OPEN_MAX) failed; using %ld", no_files); } -#else /* !HAVE_SYSCONF */ +#else /* !HAVE_SYSCONF */ #ifdef NOFILE no_files = (long) NOFILE; #else no_files = (long) max_files_per_process; #endif -#endif /* HAVE_SYSCONF */ +#endif /* HAVE_SYSCONF */ /* - * Some platforms return hopelessly optimistic values. Apply a + * Some platforms return hopelessly optimistic values. Apply a * configurable upper limit. */ if (no_files > (long) max_files_per_process) @@ -355,7 +355,6 @@ _dump_lru(void) sprintf(buf + strlen(buf), "LEAST"); elog(DEBUG, buf); } - #endif /* FDDEBUG */ static void @@ -497,7 +496,6 @@ ReleaseLruFile(void) if (nfile > 0) { - /* * There are opened files and so there should be at least one used * vfd in the ring. @@ -537,7 +535,6 @@ AllocateVfd(void) if (VfdCache[0].nextFree == 0) { - /* * The free list is empty so it is time to increase the size of * the array. We choose to double it each time this happens. @@ -550,8 +547,8 @@ AllocateVfd(void) newCacheSize = 32; /* - * Be careful not to clobber VfdCache ptr if realloc fails; - * we will need it during proc_exit cleanup! + * Be careful not to clobber VfdCache ptr if realloc fails; we + * will need it during proc_exit cleanup! */ newVfdCache = (Vfd *) realloc(VfdCache, sizeof(Vfd) * newCacheSize); if (newVfdCache == NULL) @@ -624,9 +621,7 @@ filepath(const char *filename) sprintf(buf, "%s/%s", DatabasePath, filename); } else - { buf = pstrdup(filename); - } #ifdef FILEDEBUG printf("filepath: path is %s\n", buf); @@ -657,7 +652,6 @@ FileAccess(File file) } else if (VfdCache[0].lruLessRecently != file) { - /* * We now know that the file is open and that it is not the last * one accessed, so we need to move it to the head of the Lru @@ -682,7 +676,6 @@ FileInvalidate(File file) if (!FileIsNotOpen(file)) LruDelete(file); } - #endif static File @@ -798,15 +791,15 @@ OpenTemporaryFile(void) 0600); if (file <= 0) { - char *dirpath; + char *dirpath; /* - * We might need to create the pg_tempfiles subdirectory, if - * no one has yet done so. + * We might need to create the pg_tempfiles subdirectory, if no + * one has yet done so. * * Don't check for error from mkdir; it could fail if someone else - * just did the same thing. If it doesn't work then we'll bomb out - * on the second create attempt, instead. + * just did the same thing. If it doesn't work then we'll bomb + * out on the second create attempt, instead. */ dirpath = filepath(PG_TEMP_FILES_DIR); mkdir(dirpath, S_IRWXU); @@ -1009,7 +1002,6 @@ FileTell(File file) file, VfdCache[file].fileName)); return VfdCache[file].seekPos; } - #endif int @@ -1077,7 +1069,6 @@ FileSync(File file) } else { - /* * We don't use FileAccess() because we don't want to force the * file to the front of the LRU ring; we aren't expecting to @@ -1275,17 +1266,17 @@ AtEOXact_Files(void) void RemovePgTempFiles(void) { - char db_path[MAXPGPATH]; - char temp_path[MAXPGPATH]; - char rm_path[MAXPGPATH]; + char db_path[MAXPGPATH]; + char temp_path[MAXPGPATH]; + char rm_path[MAXPGPATH]; DIR *db_dir; DIR *temp_dir; - struct dirent *db_de; - struct dirent *temp_de; + struct dirent *db_de; + struct dirent *temp_de; /* - * Cycle through pg_tempfiles for all databases - * and remove old temp files. + * Cycle through pg_tempfiles for all databases and remove old temp + * files. */ snprintf(db_path, sizeof(db_path), "%s/base", DataDir); if ((db_dir = opendir(db_path)) != NULL) @@ -1317,14 +1308,12 @@ RemovePgTempFiles(void) if (strncmp(temp_de->d_name, PG_TEMP_FILE_PREFIX, strlen(PG_TEMP_FILE_PREFIX)) == 0) - { unlink(rm_path); - } else { /* - * would prefer to use elog here, but it's not - * up and running during postmaster startup... + * would prefer to use elog here, but it's not up + * and running during postmaster startup... */ fprintf(stderr, "Unexpected file found in temporary-files directory: %s\n", diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c index b51b1fb230..1956b92d68 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.7 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.8 2001/10/25 05:49:42 momjian Exp $ * * * NOTES: @@ -19,13 +19,13 @@ * These currently work as follows: * * The number of distinct relations tracked is limited by a configuration - * variable (MaxFSMRelations). When this would be exceeded, we discard the - * least frequently used relation. A previously-unknown relation is always + * variable (MaxFSMRelations). When this would be exceeded, we discard the + * least frequently used relation. A previously-unknown relation is always * entered into the map with useCount 1 on first reference, even if this * causes an existing entry with higher useCount to be discarded. This may * cause a little bit of thrashing among the bottom entries in the list, * but if we didn't do it then there'd be no way for a relation not in the - * map to get in once the map is full. Note we allow a relation to be in the + * map to get in once the map is full. Note we allow a relation to be in the * map even if no pages are currently stored for it: this allows us to track * its useCount & threshold, which may eventually go high enough to give it * priority for page storage. @@ -89,13 +89,14 @@ struct FSMHeader */ struct FSMRelation { - RelFileNode key; /* hash key (must be first) */ + RelFileNode key; /* hash key (must be first) */ FSMRelation *nextRel; /* next rel in useCount order */ FSMRelation *priorRel; /* prior rel in useCount order */ int useCount; /* use count for prioritizing rels */ Size threshold; /* minimum amount of free space to keep */ int nextPage; /* index (from 0) to start next search at */ - int numPages; /* total number of pages we have info about */ + int numPages; /* total number of pages we have info + * about */ int numChunks; /* number of FSMChunks allocated to rel */ FSMChunk *relChunks; /* linked list of page info chunks */ }; @@ -109,21 +110,22 @@ struct FSMRelation * to the freelist; but there's no point in doing the compaction before that. */ -#define CHUNKPAGES 32 /* each chunk can store this many pages */ +#define CHUNKPAGES 32 /* each chunk can store this many pages */ struct FSMChunk { FSMChunk *next; /* linked-list link */ int numPages; /* number of pages described here */ - BlockNumber pages[CHUNKPAGES]; /* page numbers within relation */ - ItemLength bytes[CHUNKPAGES]; /* free space available on each page */ + BlockNumber pages[CHUNKPAGES]; /* page numbers within relation */ + ItemLength bytes[CHUNKPAGES]; /* free space available on each + * page */ }; -int MaxFSMRelations; /* these are set by guc.c */ -int MaxFSMPages; +int MaxFSMRelations; /* these are set by guc.c */ +int MaxFSMPages; -static FSMHeader *FreeSpaceMap; /* points to FSMHeader in shared memory */ +static FSMHeader *FreeSpaceMap; /* points to FSMHeader in shared memory */ static FSMRelation *lookup_fsm_rel(RelFileNode *rel); @@ -134,16 +136,16 @@ static void unlink_fsm_rel(FSMRelation *fsmrel); static void free_chunk_chain(FSMChunk *fchunk); static BlockNumber find_free_space(FSMRelation *fsmrel, Size spaceNeeded); static void fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, - Size spaceAvail); + Size spaceAvail); static bool lookup_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, - FSMChunk **outChunk, int *outChunkRelIndex); + FSMChunk **outChunk, int *outChunkRelIndex); static bool insert_fsm_page_entry(FSMRelation *fsmrel, - BlockNumber page, Size spaceAvail, - FSMChunk *chunk, int chunkRelIndex); + BlockNumber page, Size spaceAvail, + FSMChunk *chunk, int chunkRelIndex); static bool push_fsm_page_entry(BlockNumber page, Size spaceAvail, - FSMChunk *chunk, int chunkRelIndex); + FSMChunk *chunk, int chunkRelIndex); static void delete_fsm_page_entry(FSMRelation *fsmrel, FSMChunk *chunk, - int chunkRelIndex); + int chunkRelIndex); static void compact_fsm_page_list(FSMRelation *fsmrel); static void acquire_fsm_free_space(void); @@ -241,32 +243,34 @@ FreeSpaceShmemSize(void) * will turn out to have too little space available by the time the caller * gets a lock on it. In that case, the caller should report the actual * amount of free space available on that page (via RecordFreeSpace) and - * then try again. If InvalidBlockNumber is returned, extend the relation. + * then try again. If InvalidBlockNumber is returned, extend the relation. */ BlockNumber GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded) { FSMRelation *fsmrel; - BlockNumber freepage; + BlockNumber freepage; LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); + /* * We always add a rel to the hashtable when it is inquired about. */ fsmrel = create_fsm_rel(rel); + /* - * Adjust the threshold towards the space request. This essentially + * Adjust the threshold towards the space request. This essentially * implements an exponential moving average with an equivalent period * of about 63 requests. Ignore silly requests, however, to ensure * that the average stays in bounds. * * In theory, if the threshold increases here we should immediately - * delete any pages that fall below the new threshold. In practice - * it seems OK to wait until we have a need to compact space. + * delete any pages that fall below the new threshold. In practice it + * seems OK to wait until we have a need to compact space. */ if (spaceNeeded > 0 && spaceNeeded < BLCKSZ) { - int cur_avg = (int) fsmrel->threshold; + int cur_avg = (int) fsmrel->threshold; cur_avg += ((int) spaceNeeded - cur_avg) / 32; fsmrel->threshold = (Size) cur_avg; @@ -293,6 +297,7 @@ RecordFreeSpace(RelFileNode *rel, BlockNumber page, Size spaceAvail) AssertArg(spaceAvail < BLCKSZ); LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); + /* * We choose not to add rels to the hashtable unless they've been * inquired about with GetPageWithFreeSpace. Also, a Record operation @@ -315,27 +320,29 @@ RecordAndGetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded) { FSMRelation *fsmrel; - BlockNumber freepage; + BlockNumber freepage; /* Sanity check: ensure spaceAvail will fit into ItemLength */ AssertArg(oldSpaceAvail < BLCKSZ); LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); + /* * We always add a rel to the hashtable when it is inquired about. */ fsmrel = create_fsm_rel(rel); + /* * Adjust the threshold towards the space request, same as in * GetPageWithFreeSpace. * - * Note that we do this before storing data for oldPage, which means - * this isn't exactly equivalent to Record followed by Get; but it - * seems appropriate to adjust the threshold first. + * Note that we do this before storing data for oldPage, which means this + * isn't exactly equivalent to Record followed by Get; but it seems + * appropriate to adjust the threshold first. */ if (spaceNeeded > 0 && spaceNeeded < BLCKSZ) { - int cur_avg = (int) fsmrel->threshold; + int cur_avg = (int) fsmrel->threshold; cur_avg += ((int) spaceNeeded - cur_avg) / 32; fsmrel->threshold = (Size) cur_avg; @@ -356,7 +363,7 @@ RecordAndGetPageWithFreeSpace(RelFileNode *rel, * pages in that page number range (inclusive). This allows obsolete info * to be discarded. Second, if nPages > 0, record the page numbers and free * space amounts in the given arrays. As with RecordFreeSpace, the FSM is at - * liberty to discard some of the information. However, it *must* discard + * liberty to discard some of the information. However, it *must* discard * previously stored info in the minPage..maxPage range (for example, this * case is used to remove info about deleted pages during relation truncation). */ @@ -390,7 +397,7 @@ MultiRecordFreeSpace(RelFileNode *rel, done = false; while (chunk && !done) { - int numPages = chunk->numPages; + int numPages = chunk->numPages; for (; chunkRelIndex < numPages; chunkRelIndex++) { @@ -407,22 +414,23 @@ MultiRecordFreeSpace(RelFileNode *rel, /* Now compact out the zeroed entries */ compact_fsm_page_list(fsmrel); } + /* * Add new entries, if appropriate. * * XXX we could probably be smarter about this than doing it - * completely separately for each one. FIXME later. + * completely separately for each one. FIXME later. * - * One thing we can do is short-circuit the process entirely if - * a page (a) has too little free space to be recorded, and (b) - * is within the minPage..maxPage range --- then we deleted any - * old entry above, and we aren't going to make a new one. - * This is particularly useful since in most cases, all the passed - * pages will in fact be in the minPage..maxPage range. + * One thing we can do is short-circuit the process entirely if a + * page (a) has too little free space to be recorded, and (b) is + * within the minPage..maxPage range --- then we deleted any old + * entry above, and we aren't going to make a new one. This is + * particularly useful since in most cases, all the passed pages + * will in fact be in the minPage..maxPage range. */ for (i = 0; i < nPages; i++) { - BlockNumber page = pages[i]; + BlockNumber page = pages[i]; Size avail = spaceAvail[i]; if (avail >= fsmrel->threshold || @@ -470,7 +478,7 @@ FreeSpaceMapForgetDatabase(Oid dbid) LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); for (fsmrel = FreeSpaceMap->relList; fsmrel; fsmrel = nextrel) { - nextrel = fsmrel->nextRel; /* in case we delete it */ + nextrel = fsmrel->nextRel; /* in case we delete it */ if (fsmrel->key.tblNode == dbid) delete_fsm_rel(fsmrel); } @@ -525,7 +533,7 @@ create_fsm_rel(RelFileNode *rel) { /* New hashtable entry, initialize it (hash_search set the key) */ fsmrel->useCount = 1; - fsmrel->threshold = BLCKSZ/2; /* starting point for new entry */ + fsmrel->threshold = BLCKSZ / 2; /* starting point for new entry */ fsmrel->nextPage = 0; fsmrel->numPages = 0; fsmrel->numChunks = 0; @@ -533,6 +541,7 @@ create_fsm_rel(RelFileNode *rel) /* Discard lowest-priority existing rel, if we are over limit */ if (FreeSpaceMap->numRels >= MaxFSMRelations) delete_fsm_rel(FreeSpaceMap->relListTail); + /* * Add new entry in front of any others with useCount 1 (since it * is more recently used than them). @@ -545,18 +554,16 @@ create_fsm_rel(RelFileNode *rel) } else { - int myCount; + int myCount; /* Existing entry, advance its useCount */ - if (++(fsmrel->useCount) >= INT_MAX/2) + if (++(fsmrel->useCount) >= INT_MAX / 2) { /* When useCounts threaten to overflow, reduce 'em all 2X */ for (oldrel = FreeSpaceMap->relList; oldrel != NULL; oldrel = oldrel->nextRel) - { oldrel->useCount >>= 1; - } } /* If warranted, move it up the priority list */ oldrel = fsmrel->priorRel; @@ -665,7 +672,7 @@ free_chunk_chain(FSMChunk *fchunk) /* * Look to see if a page with at least the specified amount of space is - * available in the given FSMRelation. If so, return its page number, + * available in the given FSMRelation. If so, return its page number, * and advance the nextPage counter so that the next inquiry will return * a different page if possible. Return InvalidBlockNumber if no success. */ @@ -699,7 +706,7 @@ find_free_space(FSMRelation *fsmrel, Size spaceNeeded) /* Check the next page */ if ((Size) curChunk->bytes[chunkRelIndex] >= spaceNeeded) { - fsmrel->nextPage = pageIndex+1; + fsmrel->nextPage = pageIndex + 1; return curChunk->pages[chunkRelIndex]; } /* Advance pageIndex and chunkRelIndex, wrapping around if needed */ @@ -739,12 +746,12 @@ fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail) /* * No existing entry; add one if spaceAvail exceeds threshold. * - * CORNER CASE: if we have to do acquire_fsm_free_space then - * our own threshold will increase, possibly meaning that we - * shouldn't store the page after all. Loop to redo the test - * if that happens. The loop also covers the possibility that - * acquire_fsm_free_space must be executed more than once to - * free any space (ie, thresholds must be more than doubled). + * CORNER CASE: if we have to do acquire_fsm_free_space then our own + * threshold will increase, possibly meaning that we shouldn't + * store the page after all. Loop to redo the test if that + * happens. The loop also covers the possibility that + * acquire_fsm_free_space must be executed more than once to free + * any space (ie, thresholds must be more than doubled). */ while (spaceAvail >= fsmrel->threshold) { @@ -755,6 +762,7 @@ fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail) acquire_fsm_free_space(); if (spaceAvail < fsmrel->threshold) break; + /* * Need to redo the lookup since our own page list may well * have lost entries, so position is not correct anymore. @@ -784,10 +792,10 @@ lookup_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, for (chunk = fsmrel->relChunks; chunk; chunk = chunk->next) { - int numPages = chunk->numPages; + int numPages = chunk->numPages; /* Can skip the chunk quickly if page must be after last in chunk */ - if (numPages > 0 && page <= chunk->pages[numPages-1]) + if (numPages > 0 && page <= chunk->pages[numPages - 1]) { for (chunkRelIndex = 0; chunkRelIndex < numPages; chunkRelIndex++) { @@ -801,9 +809,10 @@ lookup_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, /* Should not get here, given above test */ Assert(false); } + /* - * If we are about to fall off the end, and there's space available - * in the end chunk, return a pointer to it. + * If we are about to fall off the end, and there's space + * available in the end chunk, return a pointer to it. */ if (chunk->next == NULL && numPages < CHUNKPAGES) { @@ -812,6 +821,7 @@ lookup_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, return false; } } + /* * Adding the page would require a new chunk (or, perhaps, compaction * of available free space --- not my problem here). @@ -838,7 +848,7 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail, { /* No free space within chunk list, so need another chunk */ 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; @@ -870,10 +880,11 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail, 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. + * 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. */ compact_fsm_page_list(fsmrel); if (lookup_fsm_page_entry(fsmrel, page, &newChunk, &newChunkRelIndex)) @@ -892,7 +903,7 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail, /* * Auxiliary routine for insert_fsm_page_entry: try to push entries to the - * right to insert at chunk/chunkRelIndex. Return TRUE if successful. + * right to insert at chunk/chunkRelIndex. Return TRUE if successful. * Note that the FSMRelation's own fields are not updated. */ static bool @@ -906,17 +917,17 @@ push_fsm_page_entry(BlockNumber page, Size spaceAvail, if (chunk->next == NULL) return false; /* no space */ /* try to push chunk's last item to next chunk */ - if (! push_fsm_page_entry(chunk->pages[CHUNKPAGES-1], - chunk->bytes[CHUNKPAGES-1], - chunk->next, 0)) + if (!push_fsm_page_entry(chunk->pages[CHUNKPAGES - 1], + chunk->bytes[CHUNKPAGES - 1], + chunk->next, 0)) return false; /* successfully pushed it */ chunk->numPages--; } for (i = chunk->numPages; i > chunkRelIndex; i--) { - chunk->pages[i] = chunk->pages[i-1]; - chunk->bytes[i] = chunk->bytes[i-1]; + chunk->pages[i] = chunk->pages[i - 1]; + chunk->bytes[i] = chunk->bytes[i - 1]; } chunk->numPages++; chunk->pages[chunkRelIndex] = page; @@ -939,12 +950,12 @@ delete_fsm_page_entry(FSMRelation *fsmrel, FSMChunk *chunk, int chunkRelIndex) lim = --chunk->numPages; for (i = chunkRelIndex; i < lim; i++) { - chunk->pages[i] = chunk->pages[i+1]; - chunk->bytes[i] = chunk->bytes[i+1]; + chunk->pages[i] = chunk->pages[i + 1]; + chunk->bytes[i] = chunk->bytes[i + 1]; } /* Compact the whole list if a chunk can be freed */ fsmrel->numPages--; - if (fsmrel->numPages <= (fsmrel->numChunks-1) * CHUNKPAGES) + if (fsmrel->numPages <= (fsmrel->numChunks - 1) * CHUNKPAGES) compact_fsm_page_list(fsmrel); } @@ -971,7 +982,7 @@ compact_fsm_page_list(FSMRelation *fsmrel) while (srcChunk != NULL) { - int srcPages = srcChunk->numPages; + int srcPages = srcChunk->numPages; while (srcIndex < srcPages) { @@ -1069,7 +1080,7 @@ DumpFreeSpace(void) nChunks = nPages = 0; for (chunk = fsmrel->relChunks; chunk; chunk = chunk->next) { - int numPages = chunk->numPages; + int numPages = chunk->numPages; nChunks++; for (chunkRelIndex = 0; chunkRelIndex < numPages; chunkRelIndex++) @@ -1105,5 +1116,4 @@ DumpFreeSpace(void) fprintf(stderr, "DumpFreeSpace: %d chunks in list, but numFreeChunks = %d\n", nChunks, FreeSpaceMap->numFreeChunks); } - #endif /* FREESPACE_DEBUG */ diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index 1eb28a48cd..d083d071bd 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.71 2001/10/01 23:26:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.72 2001/10/25 05:49:42 momjian Exp $ * * NOTES * @@ -114,7 +114,6 @@ static int on_proc_exit_index, void proc_exit(int code) { - /* * Once we set this flag, we are committed to exit. Any elog() will * NOT send control back to the main loop, but right back here. @@ -275,7 +274,6 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, if (semId < 0) { - /* * Fail quietly if error indicates a collision with existing set. * One would expect EEXIST, given that we said IPC_EXCL, but @@ -592,7 +590,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) "\nThis error usually means that PostgreSQL's request for a shared memory\n" "segment exceeded your kernel's SHMMAX parameter. You can either\n" "reduce the request size or reconfigure the kernel with larger SHMMAX.\n" - "To reduce the request size (currently %u bytes), reduce\n" + "To reduce the request size (currently %u bytes), reduce\n" "PostgreSQL's shared_buffers parameter (currently %d) and/or\n" "its max_connections parameter (currently %d).\n" "\n" @@ -607,8 +605,8 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) else if (errno == ENOMEM) fprintf(stderr, "\nThis error usually means that PostgreSQL's request for a shared\n" - "memory segment exceeded available memory or swap space.\n" - "To reduce the request size (currently %u bytes), reduce\n" + "memory segment exceeded available memory or swap space.\n" + "To reduce the request size (currently %u bytes), reduce\n" "PostgreSQL's shared_buffers parameter (currently %d) and/or\n" "its max_connections parameter (currently %d).\n" "\n" @@ -623,7 +621,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) "It occurs either if all available shared memory IDs have been taken,\n" "in which case you need to raise the SHMMNI parameter in your kernel,\n" "or because the system's overall limit for shared memory has been\n" - "reached. If you cannot increase the shared memory limit,\n" + "reached. If you cannot increase the shared memory limit,\n" "reduce PostgreSQL's shared memory request (currently %u bytes),\n" "by reducing its shared_buffers parameter (currently %d) and/or\n" "its max_connections parameter (currently %d).\n" @@ -710,7 +708,6 @@ SharedMemoryIsInUse(IpcMemoryKey shmKey, IpcMemoryId shmId) */ if (shmctl(shmId, IPC_STAT, &shmStat) < 0) { - /* * EINVAL actually has multiple possible causes documented in the * shmctl man page, but we assume it must mean the segment no @@ -748,7 +745,7 @@ PrivateMemoryCreate(uint32 size) fprintf(stderr, "PrivateMemoryCreate: malloc(%u) failed\n", size); proc_exit(1); } - MemSet(memAddress, 0, size);/* keep Purify quiet */ + MemSet(memAddress, 0, size); /* keep Purify quiet */ /* Register on-exit routine to release storage */ on_shmem_exit(PrivateMemoryDelete, PointerGetDatum(memAddress)); diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 7dac93f3a0..cf841a614d 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.43 2001/09/29 04:02:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.44 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,8 +83,8 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int maxBackends) InitShmemAllocation(seghdr); /* - * Now initialize LWLocks, which do shared memory allocation and - * are needed for InitShmemIndex. + * Now initialize LWLocks, which do shared memory allocation and are + * needed for InitShmemIndex. */ CreateLWLocks(); diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 32f2cf98a1..3304ec67c5 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.61 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.62 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,8 +97,9 @@ InitShmemAllocation(void *seghdr) ShmemEnd = ShmemBase + shmhdr->totalsize; /* - * Initialize the spinlock used by ShmemAlloc. We have to do the - * space allocation the hard way, since ShmemAlloc can't be called yet. + * Initialize the spinlock used by ShmemAlloc. We have to do the + * space allocation the hard way, since ShmemAlloc can't be called + * yet. */ ShmemLock = (slock_t *) (((char *) shmhdr) + shmhdr->freeoffset); shmhdr->freeoffset += MAXALIGN(sizeof(slock_t)); @@ -234,7 +235,7 @@ InitShmemIndex(void) * table at once. */ HTAB * -ShmemInitHash(const char *name, /* table string name for shmem index */ +ShmemInitHash(const char *name, /* table string name for shmem index */ long init_size, /* initial table size */ long max_size, /* max size of the table */ HASHCTL *infoP, /* info about key and bucket size */ @@ -256,7 +257,7 @@ ShmemInitHash(const char *name, /* table string name for shmem index */ /* look it up in the shmem index */ location = ShmemInitStruct(name, - sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT), + sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT), &found); /* @@ -267,8 +268,8 @@ ShmemInitHash(const char *name, /* table string name for shmem index */ return NULL; /* - * if it already exists, attach to it rather than allocate and initialize - * new space + * if it already exists, attach to it rather than allocate and + * initialize new space */ if (found) hash_flags |= HASH_ATTACH; diff --git a/src/backend/storage/ipc/shmqueue.c b/src/backend/storage/ipc/shmqueue.c index b840596a6f..4f67788742 100644 --- a/src/backend/storage/ipc/shmqueue.c +++ b/src/backend/storage/ipc/shmqueue.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.16 2001/03/22 03:59:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.17 2001/10/25 05:49:42 momjian Exp $ * * NOTES * @@ -33,7 +33,6 @@ #define SHMQUEUE_DEBUG_ELOG NOTICE static void dumpQ(SHM_QUEUE *q, char *s); - #endif @@ -59,7 +58,6 @@ SHMQueueIsDetached(SHM_QUEUE *queue) Assert(SHM_PTR_VALID(queue)); return (queue)->prev == INVALID_OFFSET; } - #endif /* @@ -152,7 +150,6 @@ SHMQueueInsertAfter(SHM_QUEUE *queue, SHM_QUEUE *elem) dumpQ(queue, "in SHMQueueInsertAfter: end"); #endif } - #endif /* NOT_USED */ /*-------------------- @@ -256,5 +253,4 @@ dumpQ(SHM_QUEUE *q, char *s) strcat(buf, elem); elog(SHMQUEUE_DEBUG_ELOG, "%s: %s", s, buf); } - #endif /* SHMQUEUE_DEBUG */ diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index 4a3b1114a9..1d1e9076d7 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.42 2001/09/29 15:29:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.43 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ CreateSharedInvalidationState(int maxBackends) void InitBackendSharedInvalidationState(void) { - int flag; + int flag; LWLockAcquire(SInvalLock, LW_EXCLUSIVE); flag = SIBackendInit(shmInvalBuffer); @@ -75,8 +75,8 @@ SendSharedInvalidMessage(SharedInvalidationMessage *msg) */ void ReceiveSharedInvalidMessages( - void (*invalFunction) (SharedInvalidationMessage *msg), - void (*resetFunction) (void)) + void (*invalFunction) (SharedInvalidationMessage *msg), + void (*resetFunction) (void)) { SharedInvalidationMessage data; int getResult; @@ -85,19 +85,19 @@ ReceiveSharedInvalidMessages( for (;;) { /* - * We can run SIGetDataEntry in parallel with other backends running - * SIGetDataEntry for themselves, since each instance will modify - * only fields of its own backend's ProcState, and no instance will - * look at fields of other backends' ProcStates. We express this - * by grabbing SInvalLock in shared mode. Note that this is not - * exactly the normal (read-only) interpretation of a shared lock! - * Look closely at the interactions before allowing SInvalLock to - * be grabbed in shared mode for any other reason! + * We can run SIGetDataEntry in parallel with other backends + * running SIGetDataEntry for themselves, since each instance will + * modify only fields of its own backend's ProcState, and no + * instance will look at fields of other backends' ProcStates. We + * express this by grabbing SInvalLock in shared mode. Note that + * this is not exactly the normal (read-only) interpretation of a + * shared lock! Look closely at the interactions before allowing + * SInvalLock to be grabbed in shared mode for any other reason! * - * 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 PROC structures. + * 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 PROC structures. */ LWLockAcquire(SInvalLock, LW_SHARED); getResult = SIGetDataEntry(shmInvalBuffer, MyBackendId, &data); @@ -209,6 +209,7 @@ TransactionIdIsInProgress(TransactionId xid) if (pOffset != INVALID_OFFSET) { PROC *proc = (PROC *) MAKE_PTR(pOffset); + /* Fetch xid just once - see GetNewTransactionId */ TransactionId pxid = proc->xid; @@ -233,7 +234,7 @@ TransactionIdIsInProgress(TransactionId xid) * then only backends running in my own database are considered. * * This is used by VACUUM to decide which deleted tuples must be preserved - * in a table. allDbs = TRUE is needed for shared relations, but allDbs = + * in a table. allDbs = TRUE is needed for shared relations, but allDbs = * FALSE is sufficient for non-shared relations, since only backends in my * own database could ever see the tuples in them. * @@ -331,7 +332,7 @@ GetSnapshotData(bool serializable) /*-------------------- * Unfortunately, we have to call ReadNewTransactionId() after acquiring * SInvalLock above. It's not good because ReadNewTransactionId() does - * LWLockAcquire(XidGenLock), but *necessary*. We need to be sure that + * LWLockAcquire(XidGenLock), but *necessary*. We need to be sure that * no transactions exit the set of currently-running transactions * between the time we fetch xmax and the time we finish building our * snapshot. Otherwise we could have a situation like this: @@ -364,18 +365,19 @@ GetSnapshotData(bool serializable) if (pOffset != INVALID_OFFSET) { PROC *proc = (PROC *) MAKE_PTR(pOffset); + /* Fetch xid just once - see GetNewTransactionId */ TransactionId xid = proc->xid; /* * Ignore my own proc (dealt with my xid above), procs not - * 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. + * 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. */ if (proc == MyProc || - ! TransactionIdIsNormal(xid) || + !TransactionIdIsNormal(xid) || TransactionIdFollowsOrEquals(xid, snapshot->xmax)) continue; diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 6072cd3945..c3efe50270 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.89 2001/08/10 20:52:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.90 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -416,9 +416,10 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) bool neednextpage; bytea *datafield; bool pfreeit; - struct { - struct varlena hdr; - char data[LOBLKSIZE]; + struct + { + struct varlena hdr; + char data[LOBLKSIZE]; } workbuf; char *workb = VARATT_DATA(&workbuf.hdr); HeapTuple newtup; @@ -462,7 +463,6 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) while (nwritten < nbytes) { - /* * If possible, get next pre-existing page of the LO. We assume * the indexscan will deliver these in order --- but there may be @@ -491,7 +491,6 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) */ if (olddata != NULL && olddata->pageno == pageno) { - /* * Update an existing page with fresh data. * @@ -558,7 +557,6 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) } else { - /* * Write a brand new page. * diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index 7a550ea346..e7a0c6e855 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.6 2001/09/30 00:45:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.7 2001/10/25 05:49:42 momjian Exp $ * * Interface: * @@ -58,7 +58,6 @@ static bool TopoSort(LOCK *lock, EDGE *constraints, int nConstraints, #ifdef DEBUG_DEADLOCK static void PrintLockQueue(LOCK *lock, const char *info); - #endif @@ -499,7 +498,6 @@ FindLockCycleRecurse(PROC *checkProc, /* This proc soft-blocks checkProc */ if (FindLockCycleRecurse(proc, softEdges, nSoftEdges)) { - /* * Add this edge to the list of soft edges in the * cycle @@ -533,7 +531,6 @@ FindLockCycleRecurse(PROC *checkProc, /* This proc soft-blocks checkProc */ if (FindLockCycleRecurse(proc, softEdges, nSoftEdges)) { - /* * Add this edge to the list of soft edges in the * cycle @@ -759,5 +756,4 @@ PrintLockQueue(LOCK *lock, const char *info) printf("\n"); fflush(stdout); } - #endif diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index 659c3381e0..ef4fa5f849 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.51 2001/09/27 16:29:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.52 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -332,9 +332,9 @@ void XactLockTableWait(TransactionId xid) { LOCKTAG tag; - TransactionId myxid = GetCurrentTransactionId(); + TransactionId myxid = GetCurrentTransactionId(); - Assert(! TransactionIdEquals(xid, myxid)); + Assert(!TransactionIdEquals(xid, myxid)); MemSet(&tag, 0, sizeof(tag)); tag.relId = XactLockTableId; diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 8c569710d0..a33b633d2d 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.100 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.101 2001/10/25 05:49:42 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -42,7 +42,7 @@ /* This configuration variable is used to set the lock table size */ -int max_locks_per_xact; /* set by guc.c */ +int max_locks_per_xact; /* set by guc.c */ #define NLOCKENTS(maxBackends) (max_locks_per_xact * (maxBackends)) @@ -54,15 +54,15 @@ static void LockCountMyLocks(SHMEM_OFFSET lockOffset, PROC *proc, static char *lock_mode_names[] = { - "INVALID", - "AccessShareLock", - "RowShareLock", - "RowExclusiveLock", - "ShareUpdateExclusiveLock", - "ShareLock", - "ShareRowExclusiveLock", - "ExclusiveLock", - "AccessExclusiveLock" + "INVALID", + "AccessShareLock", + "RowShareLock", + "RowExclusiveLock", + "ShareUpdateExclusiveLock", + "ShareLock", + "ShareRowExclusiveLock", + "ExclusiveLock", + "AccessExclusiveLock" }; @@ -96,10 +96,10 @@ inline static bool LOCK_DEBUG_ENABLED(const LOCK *lock) { return - (((LOCK_LOCKMETHOD(*lock) == DEFAULT_LOCKMETHOD && Trace_locks) - || (LOCK_LOCKMETHOD(*lock) == USER_LOCKMETHOD && Trace_userlocks)) - && (lock->tag.relId >= (Oid) Trace_lock_oidmin)) - || (Trace_lock_table && (lock->tag.relId == Trace_lock_table)); + (((LOCK_LOCKMETHOD(*lock) == DEFAULT_LOCKMETHOD && Trace_locks) + || (LOCK_LOCKMETHOD(*lock) == USER_LOCKMETHOD && Trace_userlocks)) + && (lock->tag.relId >= (Oid) Trace_lock_oidmin)) + || (Trace_lock_table && (lock->tag.relId == Trace_lock_table)); } @@ -132,7 +132,7 @@ HOLDER_PRINT(const char *where, const HOLDER *holderP) || (HOLDER_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(DEBUG, "%s: holder(%lx) lock(%lx) tbl(%d) proc(%lx) xid(%u) hold(%d,%d,%d,%d,%d,%d,%d)=%d", where, MAKE_OFFSET(holderP), holderP->tag.lock, @@ -147,7 +147,6 @@ HOLDER_PRINT(const char *where, const HOLDER *holderP) #define LOCK_PRINT(where, lock, type) #define HOLDER_PRINT(where, holderP) - #endif /* not LOCK_DEBUG */ @@ -647,9 +646,11 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, else { Assert(status == STATUS_FOUND); + /* * We can't acquire the lock immediately. If caller specified no - * blocking, remove the holder entry and return FALSE without waiting. + * blocking, remove the holder entry and return FALSE without + * waiting. */ if (dontWait) { @@ -911,7 +912,6 @@ WaitOnLock(LOCKMETHOD lockmethod, LOCKMODE lockmode, lock, holder) != STATUS_OK) { - /* * We failed as a result of a deadlock, see HandleDeadLock(). Quit * now. Removal of the holder and lock objects, if no longer @@ -1114,7 +1114,6 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, if (lock->nRequested == 0) { - /* * if there's no one waiting in the queue, we just released the * last lock on this object. Delete it from the lock table. @@ -1464,5 +1463,4 @@ DumpAllLocks(void) elog(DEBUG, "DumpAllLocks: holder->tag.lock = NULL"); } } - #endif /* LOCK_DEBUG */ diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 5fdcc11f59..7c268937c3 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -6,7 +6,7 @@ * Lightweight locks are intended primarily to provide mutual exclusion of * access to shared-memory data structures. Therefore, they offer both * exclusive and shared lock modes (to support read/write and read-only - * access to a shared object). There are few other frammishes. User-level + * access to a shared object). There are few other frammishes. User-level * locking should be done with the full lock manager --- which depends on * an LWLock to protect its shared state. * @@ -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.1 2001/09/29 04:02:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.2 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,8 +43,9 @@ typedef struct LWLock * the array. */ static LWLock *LWLockArray = NULL; + /* shared counter for dynamic allocation of LWLockIds */ -static int *LWLockCounter; +static int *LWLockCounter; /* @@ -55,8 +56,8 @@ static int *LWLockCounter; */ #define MAX_SIMUL_LWLOCKS 100 -static int num_held_lwlocks = 0; -static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS]; +static int num_held_lwlocks = 0; +static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS]; #ifdef LOCK_DEBUG @@ -71,9 +72,9 @@ PRINT_LWDEBUG(const char *where, LWLockId lockid, const LWLock *lock) (int) lock->exclusive, lock->shared, lock->head); } -#else /* not LOCK_DEBUG */ +#else /* not LOCK_DEBUG */ #define PRINT_LWDEBUG(a,b,c) -#endif /* LOCK_DEBUG */ +#endif /* LOCK_DEBUG */ /* @@ -82,13 +83,13 @@ PRINT_LWDEBUG(const char *where, LWLockId lockid, const LWLock *lock) int NumLWLocks(void) { - int numLocks; + int numLocks; /* - * Possibly this logic should be spread out among the affected modules, - * the same way that shmem space estimation is done. But for now, - * there are few enough users of LWLocks that we can get away with - * just keeping the knowledge here. + * Possibly this logic should be spread out among the affected + * modules, the same way that shmem space estimation is done. But for + * now, there are few enough users of LWLocks that we can get away + * with just keeping the knowledge here. */ /* Predefined LWLocks */ @@ -112,8 +113,8 @@ NumLWLocks(void) int LWLockShmemSize(void) { - int numLocks = NumLWLocks(); - uint32 spaceLocks; + int numLocks = NumLWLocks(); + uint32 spaceLocks; /* Allocate the LWLocks plus space for shared allocation counter. */ spaceLocks = numLocks * sizeof(LWLock) + 2 * sizeof(int); @@ -129,10 +130,10 @@ LWLockShmemSize(void) void CreateLWLocks(void) { - int numLocks = NumLWLocks(); - uint32 spaceLocks = LWLockShmemSize(); - LWLock *lock; - int id; + int numLocks = NumLWLocks(); + uint32 spaceLocks = LWLockShmemSize(); + LWLock *lock; + int id; /* Allocate space */ LWLockArray = (LWLock *) ShmemAlloc(spaceLocks); @@ -184,8 +185,8 @@ LWLockAssign(void) void LWLockAcquire(LWLockId lockid, LWLockMode mode) { - LWLock *lock = LWLockArray + lockid; - bool mustwait; + LWLock *lock = LWLockArray + lockid; + bool mustwait; PRINT_LWDEBUG("LWLockAcquire", lockid, lock); @@ -229,13 +230,13 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) if (mustwait) { /* Add myself to wait queue */ - PROC *proc = MyProc; - int extraWaits = 0; + PROC *proc = MyProc; + int extraWaits = 0; /* - * If we don't have a PROC structure, there's no way to wait. - * This should never occur, since MyProc should only be null - * during shared memory initialization. + * If we don't have a PROC structure, there's no way to wait. This + * should never occur, since MyProc should only be null during + * shared memory initialization. */ if (proc == NULL) elog(FATAL, "LWLockAcquire: can't wait without a PROC structure"); @@ -256,13 +257,13 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * Wait until awakened. * * 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 granted the LWLock. If so, loop back - * and wait again. Once we've gotten the lock, 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. + * 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 granted the LWLock. + * If so, loop back and wait again. Once we've gotten the lock, + * 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. */ for (;;) { @@ -272,6 +273,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) break; extraWaits++; } + /* * The awakener already updated the lock struct's state, so we * don't need to do anything more to it. Just need to fix the @@ -301,8 +303,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) { - LWLock *lock = LWLockArray + lockid; - bool mustwait; + LWLock *lock = LWLockArray + lockid; + bool mustwait; PRINT_LWDEBUG("LWLockConditionalAcquire", lockid, lock); @@ -367,18 +369,18 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) void LWLockRelease(LWLockId lockid) { - LWLock *lock = LWLockArray + lockid; - PROC *head; - PROC *proc; - int i; + LWLock *lock = LWLockArray + lockid; + PROC *head; + PROC *proc; + int i; PRINT_LWDEBUG("LWLockRelease", lockid, lock); /* - * Remove lock from list of locks held. Usually, but not always, - * it will be the latest-acquired lock; so search array backwards. + * Remove lock from list of locks held. Usually, but not always, it + * will be the latest-acquired lock; so search array backwards. */ - for (i = num_held_lwlocks; --i >= 0; ) + for (i = num_held_lwlocks; --i >= 0;) { if (lockid == held_lwlocks[i]) break; @@ -387,7 +389,7 @@ LWLockRelease(LWLockId lockid) elog(ERROR, "LWLockRelease: lock %d is not held", (int) lockid); num_held_lwlocks--; for (; i < num_held_lwlocks; i++) - held_lwlocks[i] = held_lwlocks[i+1]; + held_lwlocks[i] = held_lwlocks[i + 1]; /* Acquire mutex. Time spent holding mutex should be short! */ SpinLockAcquire_NoHoldoff(&lock->mutex); @@ -402,8 +404,8 @@ LWLockRelease(LWLockId lockid) } /* - * See if I need to awaken any waiters. If I released a non-last shared - * hold, there cannot be anything to do. + * See if I need to awaken any waiters. If I released a non-last + * shared hold, there cannot be anything to do. */ head = lock->head; if (head != NULL) @@ -411,14 +413,12 @@ LWLockRelease(LWLockId lockid) if (lock->exclusive == 0 && lock->shared == 0) { /* - * Remove the to-be-awakened PROCs from the queue, and update the - * lock state to show them as holding the lock. + * Remove the to-be-awakened PROCs from the queue, and update + * the lock state to show them as holding the lock. */ proc = head; if (proc->lwExclusive) - { lock->exclusive++; - } else { lock->shared++; @@ -465,10 +465,10 @@ LWLockRelease(LWLockId lockid) /* * LWLockReleaseAll - release all currently-held locks * - * Used to clean up after elog(ERROR). An important difference between this + * Used to clean up after elog(ERROR). An important difference between this * function and retail LWLockRelease calls is that InterruptHoldoffCount is * unchanged by this operation. This is necessary since InterruptHoldoffCount - * has been set to an appropriate level earlier in error recovery. We could + * has been set to an appropriate level earlier in error recovery. We could * decrement it below zero if we allow it to drop for each released lock! */ void @@ -478,6 +478,6 @@ LWLockReleaseAll(void) { HOLD_INTERRUPTS(); /* match the upcoming RESUME_INTERRUPTS */ - LWLockRelease(held_lwlocks[num_held_lwlocks-1]); + LWLockRelease(held_lwlocks[num_held_lwlocks - 1]); } } diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 5b88e22bd9..503312b53d 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.112 2001/10/01 18:16:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.113 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -127,8 +127,8 @@ InitProcGlobal(int maxBackends) * besides those used for regular backends. */ Assert(maxBackends > 0); - semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends+1); - procGlobalSize = sizeof(PROC_HDR) + (semMapEntries-1) * sizeof(SEM_MAP_ENTRY); + semMapEntries = PROC_SEM_MAP_ENTRIES(maxBackends + 1); + procGlobalSize = sizeof(PROC_HDR) + (semMapEntries - 1) *sizeof(SEM_MAP_ENTRY); /* Create or attach to the ProcGlobal shared structure */ ProcGlobal = (PROC_HDR *) @@ -182,10 +182,10 @@ InitProcGlobal(int maxBackends) */ DummyProc = (PROC *) ShmemAlloc(sizeof(PROC)); DummyProc->pid = 0; /* marks DummyProc as not in use */ - i = semMapEntries-1; - ProcGlobal->procSemMap[i].freeSemMap |= 1 << (PROC_NSEMS_PER_SET-1); + i = semMapEntries - 1; + ProcGlobal->procSemMap[i].freeSemMap |= 1 << (PROC_NSEMS_PER_SET - 1); DummyProc->sem.semId = ProcGlobal->procSemMap[i].procSemId; - DummyProc->sem.semNum = PROC_NSEMS_PER_SET-1; + DummyProc->sem.semNum = PROC_NSEMS_PER_SET - 1; /* Create ProcStructLock spinlock, too */ ProcStructLock = (slock_t *) ShmemAlloc(sizeof(slock_t)); @@ -199,11 +199,11 @@ InitProcGlobal(int maxBackends) void InitProcess(void) { - SHMEM_OFFSET myOffset; + SHMEM_OFFSET myOffset; /* - * ProcGlobal should be set by a previous call to InitProcGlobal - * (if we are a backend, we inherit this by fork() from the postmaster). + * ProcGlobal should be set by a previous call to InitProcGlobal (if + * we are a backend, we inherit this by fork() from the postmaster). */ if (ProcGlobal == NULL) elog(STOP, "InitProcess: Proc Header uninitialized"); @@ -260,8 +260,8 @@ InitProcess(void) on_shmem_exit(ProcKill, 0); /* - * Set up a wait-semaphore for the proc. (We rely on ProcKill to clean - * up MyProc if this fails.) + * Set up a wait-semaphore for the proc. (We rely on ProcKill to + * clean up MyProc if this fails.) */ if (IsUnderPostmaster) ProcGetNewSemIdAndNum(&MyProc->sem.semId, &MyProc->sem.semNum); @@ -291,8 +291,8 @@ void InitDummyProcess(void) { /* - * ProcGlobal should be set by a previous call to InitProcGlobal - * (we inherit this by fork() from the postmaster). + * ProcGlobal should be set by a previous call to InitProcGlobal (we + * inherit this by fork() from the postmaster). */ if (ProcGlobal == NULL || DummyProc == NULL) elog(STOP, "InitDummyProcess: Proc Header uninitialized"); @@ -309,8 +309,8 @@ InitDummyProcess(void) MyProc = DummyProc; /* - * Initialize all fields of MyProc, except MyProc->sem which was - * set up by InitProcGlobal. + * Initialize all fields of MyProc, except MyProc->sem which was set + * up by InitProcGlobal. */ MyProc->pid = MyProcPid; /* marks DummyProc as in use by me */ SHMQueueElemInit(&(MyProc->links)); @@ -471,7 +471,7 @@ ProcKill(void) /* * DummyProcKill() -- Cut-down version of ProcKill for dummy (checkpoint) - * processes. The PROC and sema are not released, only marked + * processes. The PROC and sema are not released, only marked * as not-in-use. */ static void @@ -520,7 +520,6 @@ ProcQueueAlloc(char *name) ProcQueueInit(queue); return queue; } - #endif /* @@ -599,10 +598,11 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable, if (lockctl->conflictTab[lockmode] & proc->heldLocks) { /* - * Yes, so we have a deadlock. Easiest way to clean up - * correctly is to call RemoveFromWaitQueue(), but we - * can't do that until we are *on* the wait queue. - * So, set a flag to check below, and break out of loop. + * Yes, so we have a deadlock. Easiest way to clean + * up correctly is to call RemoveFromWaitQueue(), but + * we can't do that until we are *on* the wait queue. + * So, set a flag to check below, and break out of + * loop. */ early_deadlock = true; break; @@ -653,12 +653,12 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable, MyProc->waitHolder = holder; MyProc->waitLockMode = lockmode; - MyProc->errType = STATUS_OK; /* initialize result for success */ + MyProc->errType = STATUS_OK; /* initialize result for success */ /* * If we detected deadlock, give up without waiting. This must agree - * with HandleDeadLock's recovery code, except that we shouldn't release - * the semaphore since we haven't tried to lock it yet. + * with HandleDeadLock's recovery code, except that we shouldn't + * release the semaphore since we haven't tried to lock it yet. */ if (early_deadlock) { @@ -689,7 +689,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable, * By delaying the check until we've waited for a bit, we can avoid * running the rather expensive deadlock-check code in most cases. */ - if (! enable_sigalrm_interrupt(DeadlockTimeout)) + if (!enable_sigalrm_interrupt(DeadlockTimeout)) elog(FATAL, "ProcSleep: Unable to set timer for process wakeup"); /* @@ -711,7 +711,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable, /* * Disable the timer, if it's still running */ - if (! disable_sigalrm_interrupt()) + if (!disable_sigalrm_interrupt()) elog(FATAL, "ProcSleep: Unable to disable timer for process wakeup"); /* @@ -821,7 +821,6 @@ ProcLockWakeup(LOCKMETHODTABLE *lockMethodTable, LOCK *lock) } else { - /* * Cannot wake this guy. Remember his request for later * checks. @@ -851,8 +850,8 @@ HandleDeadLock(SIGNAL_ARGS) * Acquire locktable lock. Note that the SIGALRM interrupt had better * not be enabled anywhere that this process itself holds the * locktable lock, else this will wait forever. Also note that - * LWLockAcquire creates a critical section, so that this - * routine cannot be interrupted by cancel/die interrupts. + * LWLockAcquire creates a critical section, so that this routine + * cannot be interrupted by cancel/die interrupts. */ LWLockAcquire(LockMgrLock, LW_EXCLUSIVE); @@ -960,7 +959,7 @@ ProcCancelWaitForSignal(void) void ProcSendSignal(BackendId procId) { - PROC *proc = BackendIdGetProc(procId); + PROC *proc = BackendIdGetProc(procId); if (proc != NULL) IpcSemaphoreUnlock(proc->sem.semId, proc->sem.semNum); @@ -976,7 +975,7 @@ ProcSendSignal(BackendId procId) /* * Enable the SIGALRM interrupt to fire after the specified delay * - * Delay is given in milliseconds. Caller should be sure a SIGALRM + * Delay is given in milliseconds. Caller should be sure a SIGALRM * signal handler is installed before this is called. * * Returns TRUE if okay, FALSE on failure. @@ -997,7 +996,7 @@ enable_sigalrm_interrupt(int delayms) /* BeOS doesn't have setitimer, but has set_alarm */ bigtime_t time_interval; - time_interval = delayms * 1000; /* usecs */ + time_interval = delayms * 1000; /* usecs */ if (set_alarm(time_interval, B_ONE_SHOT_RELATIVE_ALARM) < 0) return false; #endif @@ -1044,7 +1043,7 @@ ProcGetNewSemIdAndNum(IpcSemaphoreId *semId, int *semNum) { int i; int semMapEntries = ProcGlobal->semMapEntries; - SEM_MAP_ENTRY *procSemMap = ProcGlobal->procSemMap; + SEM_MAP_ENTRY *procSemMap = ProcGlobal->procSemMap; int32 fullmask = (1 << PROC_NSEMS_PER_SET) - 1; SpinLockAcquire(ProcStructLock); @@ -1080,10 +1079,11 @@ ProcGetNewSemIdAndNum(IpcSemaphoreId *semId, int *semNum) SpinLockRelease(ProcStructLock); /* - * If we reach here, all the semaphores are in use. This is one of the - * possible places to detect "too many backends", so give the standard - * error message. (Whether we detect it here or in sinval.c depends on - * whether MaxBackends is a multiple of PROC_NSEMS_PER_SET.) + * If we reach here, all the semaphores are in use. This is one of + * the possible places to detect "too many backends", so give the + * standard error message. (Whether we detect it here or in sinval.c + * depends on whether MaxBackends is a multiple of + * PROC_NSEMS_PER_SET.) */ elog(FATAL, "Sorry, too many clients already"); } diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index 055c809cf8..84934b3b02 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.2 2001/09/29 04:02:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.3 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,13 +48,14 @@ s_lock(volatile slock_t *lock, const char *file, int line) struct timeval delay; /* - * We loop tightly for awhile, then delay using select() and try again. - * Preferably, "awhile" should be a small multiple of the maximum time - * we expect a spinlock to be held. 100 iterations seems about right. + * We loop tightly for awhile, then delay using select() and try + * again. Preferably, "awhile" should be a small multiple of the + * maximum time we expect a spinlock to be held. 100 iterations seems + * about right. * * We use a 10 millisec select delay because that is the lower limit on - * many platforms. The timeout is figured on this delay only, and so the - * nominal 1 minute is a lower bound. + * many platforms. The timeout is figured on this delay only, and so + * the nominal 1 minute is a lower bound. */ #define SPINS_PER_DELAY 100 #define DELAY_MSEC 10 @@ -108,7 +109,6 @@ _success: \n\ rts \n\ "); } - #endif /* __m68k__ */ #if defined(__APPLE__) && defined(__ppc__) @@ -138,7 +138,6 @@ success: \n\ blr \n\ "); } - #endif /* __APPLE__ && __ppc__ */ #if defined(__powerpc__) @@ -163,7 +162,6 @@ success: \n\ blr \n\ "); } - #endif /* __powerpc__ */ #if defined(__mips__) && !defined(__sgi) @@ -171,7 +169,7 @@ static void tas_dummy() { __asm__ __volatile__( - "\ + "\ .global tas \n\ tas: \n\ .frame $sp, 0, $31 \n\ @@ -188,10 +186,9 @@ fail: \n\ j $31 \n\ "); } - #endif /* __mips__ && !__sgi */ -#else /* not __GNUC__ */ +#else /* not __GNUC__ */ /*************************************************************************** * All non gcc */ @@ -220,7 +217,6 @@ tas_dummy() /* really means: extern int tas(slock_t asm(" rts"); asm(" .data"); } - #endif /* sun3 */ @@ -244,7 +240,6 @@ tas_dummy() /* really means: extern int tas(slock_t asm("retl"); asm("nop"); } - #endif /* NEED_SPARC_TAS_ASM */ @@ -255,7 +250,6 @@ tas_dummy() /* really means: extern int tas(slock_t #endif /* NEED_I386_TAS_ASM */ - #endif /* not __GNUC__ */ @@ -298,5 +292,4 @@ main() exit(3); } - #endif /* S_LOCK_TEST */ diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c index 6ace9cc11a..59a7b4414c 100644 --- a/src/backend/storage/lmgr/spin.c +++ b/src/backend/storage/lmgr/spin.c @@ -5,8 +5,8 @@ * * * For machines that have test-and-set (TAS) instructions, s_lock.h/.c - * define the spinlock implementation. This file contains only a stub - * implementation for spinlocks using SysV semaphores. The semaphore method + * define the spinlock implementation. This file contains only a stub + * implementation for spinlocks using SysV semaphores. The semaphore method * is too slow to be very useful :-( * * @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.4 2001/10/01 18:16:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.5 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,8 +92,8 @@ CreateSpinlocks(void) { /* * Compute number of spinlocks needed. It would be cleaner to - * distribute this logic into the affected modules, - * similar to the way shmem space estimation is handled. + * 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. @@ -186,5 +186,4 @@ tas_sema(volatile slock_t *lock) /* Note that TAS macros return 0 if *success* */ return !IpcSemaphoreTryLock(lock->semId, lock->sem); } - #endif /* !HAS_TEST_AND_SET */ diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 038ec65ac7..3fc1958b53 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.38 2001/10/23 02:20:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.39 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,7 +125,6 @@ PageAddItem(Page page, } else { - /* * Don't actually do the shuffle till we've checked free * space! @@ -264,7 +263,7 @@ itemoffcompare(const void *itemidp1, const void *itemidp2) * It doesn't remove unused line pointers! Please don't change this. * This routine is usable for heap pages only. * - * Returns number of unused line pointers on page. If "unused" is not NULL + * Returns number of unused line pointers on page. If "unused" is not NULL * then the unused[] array is filled with indexes of unused line pointers. */ int @@ -283,11 +282,11 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) Offset upper; /* - * It's worth the trouble to be more paranoid here than in most places, - * because we are about to reshuffle data in (what is usually) a shared - * disk buffer. If we aren't careful then corrupted pointers, lengths, - * etc could cause us to clobber adjacent disk buffers, spreading the - * data loss further. So, check everything. + * It's worth the trouble to be more paranoid here than in most + * places, because we are about to reshuffle data in (what is usually) + * a shared disk buffer. If we aren't careful then corrupted + * pointers, lengths, etc could cause us to clobber adjacent disk + * buffers, spreading the data loss further. So, check everything. */ if (pd_lower < (sizeof(PageHeaderData) - sizeof(ItemIdData)) || pd_lower > pd_upper || @@ -344,7 +343,7 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) } else { - (*lp).lp_len = 0; /* indicate unused & deallocated */ + (*lp).lp_len = 0; /* indicate unused & deallocated */ } } @@ -390,7 +389,7 @@ PageGetFreeSpace(Page page) if (space < sizeof(ItemIdData)) return 0; - space -= sizeof(ItemIdData); /* XXX not always appropriate */ + space -= sizeof(ItemIdData); /* XXX not always appropriate */ return space; } diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 424b667c63..c8fd782988 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.87 2001/08/24 14:07:49 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.88 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,7 +58,7 @@ typedef struct _MdfdVec int mdfd_nextFree; /* link to next freelist member, if free */ #ifndef LET_OS_MANAGE_FILESIZE - struct _MdfdVec *mdfd_chain;/* for large relations */ + struct _MdfdVec *mdfd_chain; /* for large relations */ #endif } MdfdVec; @@ -194,7 +194,7 @@ mdunlink(RelFileNode rnode) if (status == SM_SUCCESS) { char *segpath = (char *) palloc(strlen(path) + 12); - BlockNumber segno; + BlockNumber segno; for (segno = 1;; segno++) { @@ -258,11 +258,11 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer) /* * Note: because caller obtained blocknum by calling mdnblocks, which * did a seek(SEEK_END), this seek is often redundant and will be - * optimized away by fd.c. It's not redundant, however, if there is a - * partial page at the end of the file. In that case we want to try to - * overwrite the partial page with a full page. It's also not redundant - * if bufmgr.c had to dump another buffer of the same file to make room - * for the new page's buffer. + * optimized away by fd.c. It's not redundant, however, if there is a + * partial page at the end of the file. In that case we want to try + * to overwrite the partial page with a full page. It's also not + * redundant if bufmgr.c had to dump another buffer of the same file + * to make room for the new page's buffer. */ if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos) return SM_FAIL; @@ -271,7 +271,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer) { if (nbytes > 0) { - int save_errno = errno; + int save_errno = errno; /* Remove the partially-written page */ FileTruncate(v->mdfd_vfd, seekpos); @@ -309,7 +309,6 @@ mdopen(Relation reln) if (fd < 0) { - /* * During bootstrap, there are cases where a system relation will * be accessed (by internal backend processes) before the @@ -383,7 +382,6 @@ mdclose_fd(int fd) /* if not closed already */ if (v->mdfd_vfd >= 0) { - /* * We sync the file descriptor so that we don't need to reopen * it at transaction commit to force changes to disk. (This @@ -406,7 +404,6 @@ mdclose_fd(int fd) { if (v->mdfd_vfd >= 0) { - /* * We sync the file descriptor so that we don't need to reopen * it at transaction commit to force changes to disk. (This @@ -455,8 +452,8 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer) if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ) { /* - * If we are at EOF, return zeroes without complaining. - * (XXX Is this still necessary/a good idea??) + * If we are at EOF, return zeroes without complaining. (XXX Is + * this still necessary/a good idea??) */ if (nbytes == 0 || (nbytes > 0 && mdnblocks(reln) == blocknum)) @@ -664,9 +661,10 @@ mdnblocks(Relation reln) { int fd; MdfdVec *v; + #ifndef LET_OS_MANAGE_FILESIZE - BlockNumber nblocks; - BlockNumber segno; + BlockNumber nblocks; + BlockNumber segno; #endif fd = _mdfd_getrelnfd(reln); @@ -681,6 +679,7 @@ mdnblocks(Relation reln) elog(FATAL, "segment too big in mdnblocks!"); if (nblocks < ((BlockNumber) RELSEG_SIZE)) return (segno * ((BlockNumber) RELSEG_SIZE)) + nblocks; + /* * If segment is exactly RELSEG_SIZE, advance to next one. */ @@ -689,11 +688,11 @@ mdnblocks(Relation reln) if (v->mdfd_chain == (MdfdVec *) NULL) { /* - * Because we pass O_CREAT, we will create the next - * segment (with zero length) immediately, if the last - * segment is of length REL_SEGSIZE. This is unnecessary - * but harmless, and testing for the case would take more - * cycles than it seems worth. + * Because we pass O_CREAT, we will create the next segment + * (with zero length) immediately, if the last segment is of + * length REL_SEGSIZE. This is unnecessary but harmless, and + * testing for the case would take more cycles than it seems + * worth. */ v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT); if (v->mdfd_chain == (MdfdVec *) NULL) @@ -718,9 +717,10 @@ mdtruncate(Relation reln, BlockNumber nblocks) { int fd; MdfdVec *v; - BlockNumber curnblk; + BlockNumber curnblk; + #ifndef LET_OS_MANAGE_FILESIZE - BlockNumber priorblocks; + BlockNumber priorblocks; #endif /* @@ -729,7 +729,7 @@ mdtruncate(Relation reln, BlockNumber nblocks) */ curnblk = mdnblocks(reln); if (nblocks > curnblk) - return InvalidBlockNumber; /* bogus request */ + return InvalidBlockNumber; /* bogus request */ if (nblocks == curnblk) return nblocks; /* no work */ @@ -768,7 +768,7 @@ mdtruncate(Relation reln, BlockNumber nblocks) * truncate the K+1st segment to 0 length but keep it. This is * mainly so that the right thing happens if nblocks==0. */ - BlockNumber lastsegblocks = nblocks - priorblocks; + BlockNumber lastsegblocks = nblocks - priorblocks; if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0) return InvalidBlockNumber; @@ -838,7 +838,6 @@ mdcommit() int mdabort() { - /* * We don't actually have to do anything here. fd.c will discard * fsync-needed bits in its AtEOXact_Files() routine. @@ -1004,9 +1003,10 @@ _mdfd_getseg(Relation reln, BlockNumber blkno) { MdfdVec *v; int fd; + #ifndef LET_OS_MANAGE_FILESIZE - BlockNumber segno; - BlockNumber i; + BlockNumber segno; + BlockNumber i; #endif fd = _mdfd_getrelnfd(reln); @@ -1019,7 +1019,6 @@ _mdfd_getseg(Relation reln, BlockNumber blkno) if (v->mdfd_chain == (MdfdVec *) NULL) { - /* * We will create the next segment only if the target block is * within it. This prevents Sorcerer's Apprentice syndrome if @@ -1063,8 +1062,9 @@ _mdfd_blind_getseg(RelFileNode rnode, BlockNumber blkno) { char *path; int fd; + #ifndef LET_OS_MANAGE_FILESIZE - BlockNumber segno; + BlockNumber segno; #endif path = relpath(rnode); diff --git a/src/backend/storage/smgr/mm.c b/src/backend/storage/smgr/mm.c index fcb282f916..789083fba2 100644 --- a/src/backend/storage/smgr/mm.c +++ b/src/backend/storage/smgr/mm.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.27 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.28 2001/10/25 05:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -481,7 +481,7 @@ mmnblocks(Relation reln) { MMRelTag rtag; MMRelHashEntry *rentry; - BlockNumber nblocks; + BlockNumber nblocks; if (reln->rd_rel->relisshared) rtag.mmrt_dbid = (Oid) 0; @@ -561,5 +561,4 @@ MMShmemSize() return size; } - #endif /* STABLE_MEMORY_STORAGE */ diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 555b666faa..f4df40bf40 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.53 2001/09/29 04:02:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.54 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,21 +33,21 @@ typedef struct f_smgr int (*smgr_create) (Relation reln); int (*smgr_unlink) (RelFileNode rnode); int (*smgr_extend) (Relation reln, BlockNumber blocknum, - char *buffer); + char *buffer); int (*smgr_open) (Relation reln); int (*smgr_close) (Relation reln); int (*smgr_read) (Relation reln, BlockNumber blocknum, - char *buffer); + char *buffer); int (*smgr_write) (Relation reln, BlockNumber blocknum, - char *buffer); + char *buffer); int (*smgr_flush) (Relation reln, BlockNumber blocknum, - char *buffer); + char *buffer); int (*smgr_blindwrt) (RelFileNode rnode, BlockNumber blkno, - char *buffer, bool dofsync); + char *buffer, bool dofsync); int (*smgr_markdirty) (Relation reln, BlockNumber blkno); int (*smgr_blindmarkdirty) (RelFileNode, BlockNumber blkno); - BlockNumber (*smgr_nblocks) (Relation reln); - BlockNumber (*smgr_truncate) (Relation reln, BlockNumber nblocks); + BlockNumber (*smgr_nblocks) (Relation reln); + BlockNumber (*smgr_truncate) (Relation reln, BlockNumber nblocks); int (*smgr_commit) (void); /* may be NULL */ int (*smgr_abort) (void); /* may be NULL */ int (*smgr_sync) (void); @@ -71,7 +71,6 @@ static f_smgr smgrsw[] = { {mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose, mmread, mmwrite, mmflush, mmblindwrt, mmmarkdirty, mmblindmarkdirty, mmnblocks, NULL, mmcommit, mmabort}, - #endif }; @@ -89,7 +88,6 @@ static bool smgrwo[] = { false, /* main memory */ #endif }; - #endif static int NSmgr = lengthof(smgrsw); @@ -438,9 +436,10 @@ smgrblindmarkdirty(int16 which, BlockNumber smgrnblocks(int16 which, Relation reln) { - BlockNumber nblocks; + BlockNumber nblocks; nblocks = (*(smgrsw[which].smgr_nblocks)) (reln); + /* * NOTE: if a relation ever did grow to 2^32-1 blocks, this code would * fail --- but that's a good thing, because it would stop us from @@ -464,15 +463,15 @@ smgrnblocks(int16 which, Relation reln) BlockNumber smgrtruncate(int16 which, Relation reln, BlockNumber nblocks) { - BlockNumber newblks; + BlockNumber newblks; newblks = nblocks; if (smgrsw[which].smgr_truncate) { /* * Tell the free space map to forget anything it may have stored - * for the about-to-be-deleted blocks. We want to be sure it won't - * return bogus block numbers later on. + * for the about-to-be-deleted blocks. We want to be sure it + * won't return bogus block numbers later on. */ MultiRecordFreeSpace(&reln->rd_node, nblocks, MaxBlockNumber, @@ -601,7 +600,6 @@ smgriswo(int16 smgrno) return smgrwo[smgrno]; } - #endif void diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index 0e9cdd2213..61b1b55821 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.44 2001/03/22 06:16:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.45 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -173,7 +173,7 @@ DestToFunction(CommandDest dest) { switch (dest) { - case Remote: + case Remote: return printtup_create_DR(false); case RemoteInternal: @@ -272,13 +272,13 @@ NullCommand(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: + case RemoteInternal: + case Remote: /* * tell the fe that we saw an empty query string */ - pq_putbytes("I", 2);/* note we send I and \0 */ + pq_putbytes("I", 2); /* note we send I and \0 */ break; case Debug: @@ -303,8 +303,8 @@ ReadyForQuery(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: + case RemoteInternal: + case Remote: if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) pq_putbytes("Z", 1); /* Flush output at end of cycle in any case. */ @@ -323,7 +323,7 @@ UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples) { switch (operation) { - case CMD_INSERT: + case CMD_INSERT: if (tuples > 1) lastoid = InvalidOid; sprintf(CommandInfo, " %u %u", lastoid, tuples); diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index ccb36b20c1..c710d2c3d4 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.49 2001/06/01 15:45:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.50 2001/10/25 05:49:43 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -120,8 +120,8 @@ SendFunctionResult(Datum retval,/* actual return value */ * each fastpath call as a separate transaction command, and so the * cached data could never actually have been reused. If it had worked * as intended, it would have had problems anyway with dangling references - * in the FmgrInfo struct. So, forget about caching and just repeat the - * syscache fetches on each usage. They're not *that* expensive. + * in the FmgrInfo struct. So, forget about caching and just repeat the + * syscache fetches on each usage. They're not *that* expensive. */ struct fp_info { @@ -157,7 +157,8 @@ fetch_fp_info(Oid func_id, struct fp_info * fip) * correct value until we are about to return with a good struct * fp_info, since we can be interrupted (i.e., with an elog(ERROR, * ...)) at any time. [No longer really an issue since we don't save - * the struct fp_info across transactions anymore, but keep it anyway.] + * the struct fp_info across transactions anymore, but keep it + * anyway.] */ MemSet((char *) fip, 0, sizeof(struct fp_info)); fip->funcid = InvalidOid; @@ -260,8 +261,8 @@ HandleFunctionRequest(void) return EOF; /* - * There used to be a lame attempt at caching lookup info here. - * Now we just do the lookups on every call. + * There used to be a lame attempt at caching lookup info here. Now we + * just do the lookups on every call. */ fip = &my_fp; fetch_fp_info(fid, fip); diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index ce7ccb2af5..e839e47f1c 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.238 2001/10/21 03:25:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.239 2001/10/25 05:49:43 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -72,7 +72,7 @@ extern int optind; extern char *optarg; -char *debug_query_string; /* used by pgmonitor */ +char *debug_query_string; /* used by pgmonitor */ /* Note: whereToSendOutput is initialized for the bootstrap/standalone case */ CommandDest whereToSendOutput = Debug; @@ -99,7 +99,6 @@ int UseNewLine = 1; /* Use newlines query delimiters (the #else int UseNewLine = 0; /* Use EOF as query delimiters */ - #endif /* TCOP_DONTUSENEWLINE */ /* @@ -163,7 +162,6 @@ InteractiveBackend(StringInfo inBuf) { if (UseNewLine) { - /* * if we are using \n as a delimiter, then read characters * until the \n. @@ -199,7 +197,6 @@ InteractiveBackend(StringInfo inBuf) } else { - /* * otherwise read characters until EOF. */ @@ -258,7 +255,6 @@ SocketBackend(StringInfo inBuf) switch (qtype) { - /* * 'Q': user entered a query */ @@ -686,7 +682,6 @@ pg_exec_query_string(char *query_string, /* string to execute */ if (!allowit) { - /* * the EndCommand() stuff is to tell the frontend that the * command ended. -cim 6/1/90 @@ -755,7 +750,6 @@ pg_exec_query_string(char *query_string, /* string to execute */ if (querytree->commandType == CMD_UTILITY) { - /* * process utility functions (create, destroy, etc..) */ @@ -768,7 +762,6 @@ pg_exec_query_string(char *query_string, /* string to execute */ } else { - /* * process a plannable query. */ @@ -848,7 +841,7 @@ pg_exec_query_string(char *query_string, /* string to execute */ if (xact_started) finish_xact_command(); - debug_query_string = NULL; /* used by pgmonitor */ + debug_query_string = NULL; /* used by pgmonitor */ } /* @@ -901,7 +894,7 @@ quickdie(SIGNAL_ARGS) "\n\tThe Postmaster has informed me that some other backend" "\n\tdied abnormally and possibly corrupted shared memory." "\n\tI have rolled back the current transaction and am" - "\n\tgoing to terminate your database system connection and exit." + "\n\tgoing to terminate your database system connection and exit." "\n\tPlease reconnect to the database system and repeat your query."); /* @@ -1111,7 +1104,7 @@ PostgresMain(int argc, char *argv[], const char *username) bool secure; int errs = 0; GucContext ctx; - char *tmp; + char *tmp; int firstchar; StringInfo parser_input; @@ -1482,9 +1475,9 @@ PostgresMain(int argc, char *argv[], const char *username) if (!potential_DataDir) { fprintf(stderr, "%s does not know where to find the database system " - "data. You must specify the directory that contains the " - "database system either by specifying the -D invocation " - "option or by setting the PGDATA environment variable.\n\n", + "data. You must specify the directory that contains the " + "database system either by specifying the -D invocation " + "option or by setting the PGDATA environment variable.\n\n", argv[0]); proc_exit(1); } @@ -1509,7 +1502,7 @@ PostgresMain(int argc, char *argv[], const char *username) pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */ pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */ pqsignal(SIGTERM, die); /* cancel current query and exit */ - pqsignal(SIGQUIT, quickdie);/* hard crash time */ + pqsignal(SIGQUIT, quickdie); /* hard crash time */ pqsignal(SIGALRM, HandleDeadLock); /* check for deadlock after * timeout */ @@ -1529,7 +1522,8 @@ PostgresMain(int argc, char *argv[], const char *username) * Reset some signals that are accepted by postmaster but not by * backend */ - pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some platforms */ + pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some + * platforms */ pqsignal(SIGTTIN, SIG_DFL); pqsignal(SIGTTOU, SIG_DFL); pqsignal(SIGCONT, SIG_DFL); @@ -1586,8 +1580,8 @@ PostgresMain(int argc, char *argv[], const char *username) argv[0]); /* - * Validate we have been given a reasonable-looking DataDir - * (if under postmaster, assume postmaster did this already). + * Validate we have been given a reasonable-looking DataDir (if + * under postmaster, assume postmaster did this already). */ ValidatePgVersion(DataDir); @@ -1648,7 +1642,7 @@ PostgresMain(int argc, char *argv[], const char *username) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.238 $ $Date: 2001/10/21 03:25:35 $\n"); + puts("$Revision: 1.239 $ $Date: 2001/10/25 05:49:43 $\n"); } /* @@ -1740,7 +1734,6 @@ PostgresMain(int argc, char *argv[], const char *username) for (;;) { - /* * Release storage left over from prior query cycle, and create a * new query input buffer in the cleared QueryContext. @@ -1819,7 +1812,6 @@ PostgresMain(int argc, char *argv[], const char *username) */ switch (firstchar) { - /* * 'F' indicates a fastpath call. */ @@ -1849,7 +1841,6 @@ PostgresMain(int argc, char *argv[], const char *username) case 'Q': if (strspn(parser_input->data, " \t\r\n") == parser_input->len) { - /* * if there is nothing in the input buffer, don't * bother trying to parse and execute anything; just @@ -1860,7 +1851,6 @@ PostgresMain(int argc, char *argv[], const char *username) } else { - /* * otherwise, process the input string. * @@ -2058,6 +2048,5 @@ assertTest(int val) return val; } - #endif #endif diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index c7a33a3bc2..91d98a2d50 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.45 2001/10/05 17:28:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.46 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ static char *CreateOperationTag(int operationType); * CreateQueryDesc * ---------------------------------------------------------------- */ -QueryDesc * +QueryDesc * CreateQueryDesc(Query *parsetree, Plan *plantree, CommandDest dest) @@ -140,7 +140,6 @@ PreparePortal(char *portalName) portal = GetPortalByName(portalName); if (PortalIsValid(portal)) { - /* * XXX Should we raise an error rather than closing the old * portal? @@ -197,7 +196,6 @@ ProcessQuery(Query *parsetree, intoName = parsetree->into; if (parsetree->isBinary) { - /* * For internal format portals, we change Remote * (externalized form) to RemoteInternal (internalized diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 66ccb65278..7142f0e60f 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.121 2001/10/18 17:30:15 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.122 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -144,7 +144,6 @@ ProcessUtility(Node *parsetree, switch (nodeTag(parsetree)) { - /* * ******************************** transactions ******************************** * @@ -386,7 +385,6 @@ ProcessUtility(Node *parsetree, */ if (stmt->column == NULL) { - /* * rename relation * @@ -398,7 +396,6 @@ ProcessUtility(Node *parsetree, } else { - /* * rename attribute */ @@ -476,7 +473,8 @@ ProcessUtility(Node *parsetree, case T_GrantStmt: { - GrantStmt *stmt = (GrantStmt *) parsetree; + GrantStmt *stmt = (GrantStmt *) parsetree; + commandTag = stmt->is_grant ? "GRANT" : "REVOKE"; set_ps_display(commandTag); diff --git a/src/backend/tioga/Arr_TgRecipe.h b/src/backend/tioga/Arr_TgRecipe.h index a382411455..346f74c293 100644 --- a/src/backend/tioga/Arr_TgRecipe.h +++ b/src/backend/tioga/Arr_TgRecipe.h @@ -52,7 +52,6 @@ typedef struct Arr_TgString AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgString) #define deleteArr_TgString(A) FreeVarray(A) - #endif /* _ARR_TgString_ */ /* -- Defining types and function for Arr_TgElementPtr type -- */ @@ -90,7 +89,6 @@ typedef struct Arr_TgElementPtr AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgElementPtr) #define deleteArr_TgElementPtr(A) FreeVarray(A) - #endif /* _ARR_TgElementPtr_ */ /* -- Defining types and function for Arr_TgNodePtr type -- */ @@ -128,5 +126,4 @@ typedef struct Arr_TgNodePtr AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgNodePtr) #define deleteArr_TgNodePtr(A) FreeVarray(A) - #endif /* _ARR_TgNodePtr_ */ diff --git a/src/backend/tioga/Varray.h b/src/backend/tioga/Varray.h index aed53855a4..c81a7f28ef 100644 --- a/src/backend/tioga/Varray.h +++ b/src/backend/tioga/Varray.h @@ -44,5 +44,4 @@ typedef void (*CopyingFunct) (void *from, void *to); extern Varray *NewVarray(size_t nobj, size_t size); extern int AppendVarray(Varray * array, void *value, CopyingFunct copy); - #endif /* _VARRAY_H_ */ diff --git a/src/backend/tioga/tgRecipe.c b/src/backend/tioga/tgRecipe.c index 0a2dca7dd8..b9304c5bf7 100644 --- a/src/backend/tioga/tgRecipe.c +++ b/src/backend/tioga/tgRecipe.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.19 2001/03/22 03:59:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.20 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,7 @@ findElemInRecipe() XXX Currently, this is done by linear search. Change to using a hash table. -------------------------------------- */ -TgElement * +TgElement * findElemInRecipe(TgRecipe * r, char *elemName) { int i; @@ -188,7 +188,6 @@ fillTgNode(TgRecipe * r, TgNode * node, PortalBuffer * pbuf, int tupno) if (!attnums_initialized) { - /* * the first time fillTgNode is called, we find out all the * relevant attribute numbers in a TgNode so subsequent calls are @@ -278,7 +277,6 @@ fillTgElement(TgElement * elem, PortalBuffer * pbuf, int tupno) if (!attnums_initialized) { - /* * the first time fillTgElement is called, we find out all the * relevant attribute numbers in a TgElement so subsequent calls @@ -617,7 +615,7 @@ fillTgRecipe takes a query result in the PortalBuffer containing a Recipe and converts it to a C TgRecipe strcture ------------------------------------ */ -TgRecipe * +TgRecipe * fillTgRecipe(PortalBuffer * pbuf, int tupno) { TgRecipe *r; @@ -690,7 +688,7 @@ fillTgRecipe(PortalBuffer * pbuf, int tupno) retrieveRecipe find the recipe with the given name ------------------------------------ */ -TgRecipe * +TgRecipe * retrieveRecipe(char *name) { char qbuf[MAX_QBUF_LENGTH]; diff --git a/src/backend/tioga/tgRecipe.h b/src/backend/tioga/tgRecipe.h index 52868554a1..f22e4bc8b5 100644 --- a/src/backend/tioga/tgRecipe.h +++ b/src/backend/tioga/tgRecipe.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tgRecipe.h,v 1.17 2001/03/22 06:16:17 momjian Exp $ + * $Id: tgRecipe.h,v 1.18 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,31 +42,31 @@ typedef struct * * * + * * geo-decls.h */ - #endif /* TIOGA_FRONTEND */ typedef enum { - TG_INGRED, - TG_EYE, - TG_RECIPE + TG_INGRED, + TG_EYE, + TG_RECIPE } TgElemType; typedef enum { - TG_SQL, - TG_C, - TG_RECIPE_GRAPH, - TG_COMPILED + TG_SQL, + TG_C, + TG_RECIPE_GRAPH, + TG_COMPILED } TgSrcLangType; typedef enum { - TG_INGRED_NODE, - TG_EYE_NODE, - TG_RECIPE_NODE, - TG_TEE_NODE /* tee nodes are not stored in the db we + TG_INGRED_NODE, + TG_EYE_NODE, + TG_RECIPE_NODE, + TG_TEE_NODE /* tee nodes are not stored in the db we * create them when we read the recipe * back */ } TgNodeType; diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 4a21630b06..11f4dc52bf 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.64 2001/06/14 01:09:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.65 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,11 +38,11 @@ static bool aclitemgt(const AclItem *a1, const AclItem *a2); static AclMode convert_priv_string(text *priv_type_text); static bool has_table_privilege_cname_cname(char *username, char *relname, - text *priv_type_text); + text *priv_type_text); static bool has_table_privilege_cname_id(char *username, Oid reloid, - text *priv_type_text); + text *priv_type_text); static bool has_table_privilege_id_cname(int32 usesysid, char *relname, - text *priv_type_text); + text *priv_type_text); /* @@ -394,7 +394,7 @@ acldefault(const char *relname, AclId ownerid) /* - * Add or replace an item in an ACL array. The result is a modified copy; + * Add or replace an item in an ACL array. The result is a modified copy; * the input object is not changed. * * NB: caller is responsible for having detoasted the input ACL, if needed. @@ -622,7 +622,7 @@ aclmakepriv(const char *old_privlist, char new_priv) int l; Assert(strlen(old_privlist) <= strlen(ACL_MODE_STR)); - priv = palloc(strlen(ACL_MODE_STR)+1); + priv = palloc(strlen(ACL_MODE_STR) + 1); if (old_privlist == NULL || old_privlist[0] == '\0') { @@ -687,7 +687,7 @@ char * makeAclString(const char *privileges, const char *grantee, char grant_or_revoke) { StringInfoData str; - char *ret; + char *ret; initStringInfo(&str); @@ -731,7 +731,7 @@ has_table_privilege_name_name(PG_FUNCTION_ARGS) { Name username = PG_GETARG_NAME(0); Name relname = PG_GETARG_NAME(1); - text *priv_type_text = PG_GETARG_TEXT_P(2); + text *priv_type_text = PG_GETARG_TEXT_P(2); bool result; result = has_table_privilege_cname_cname(NameStr(*username), @@ -757,7 +757,7 @@ Datum has_table_privilege_name(PG_FUNCTION_ARGS) { Name relname = PG_GETARG_NAME(0); - text *priv_type_text = PG_GETARG_TEXT_P(1); + text *priv_type_text = PG_GETARG_TEXT_P(1); int32 usesysid; bool result; @@ -786,7 +786,7 @@ has_table_privilege_name_id(PG_FUNCTION_ARGS) { Name username = PG_GETARG_NAME(0); Oid reloid = PG_GETARG_OID(1); - text *priv_type_text = PG_GETARG_TEXT_P(2); + text *priv_type_text = PG_GETARG_TEXT_P(2); bool result; result = has_table_privilege_cname_id(NameStr(*username), @@ -812,7 +812,7 @@ Datum has_table_privilege_id(PG_FUNCTION_ARGS) { Oid reloid = PG_GETARG_OID(0); - text *priv_type_text = PG_GETARG_TEXT_P(1); + text *priv_type_text = PG_GETARG_TEXT_P(1); char *relname; int32 usesysid; AclMode mode; @@ -828,12 +828,12 @@ has_table_privilege_id(PG_FUNCTION_ARGS) elog(ERROR, "has_table_privilege: invalid relation oid %u", reloid); - /* + /* * Convert priv_type_text to an AclMode */ mode = convert_priv_string(priv_type_text); - /* + /* * Finally, check for the privilege */ result = pg_aclcheck(relname, usesysid, mode); @@ -860,7 +860,7 @@ has_table_privilege_id_name(PG_FUNCTION_ARGS) { int32 usesysid = PG_GETARG_INT32(0); Name relname = PG_GETARG_NAME(1); - text *priv_type_text = PG_GETARG_TEXT_P(2); + text *priv_type_text = PG_GETARG_TEXT_P(2); bool result; result = has_table_privilege_id_cname(usesysid, @@ -886,8 +886,8 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS) { int32 usesysid = PG_GETARG_INT32(0); Oid reloid = PG_GETARG_OID(1); - text *priv_type_text = PG_GETARG_TEXT_P(2); - char *relname; + text *priv_type_text = PG_GETARG_TEXT_P(2); + char *relname; AclMode mode; int32 result; @@ -899,12 +899,12 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS) elog(ERROR, "has_table_privilege: invalid relation oid %u", reloid); - /* + /* * Convert priv_type_text to an AclMode */ mode = convert_priv_string(priv_type_text); - /* + /* * Finally, check for the privilege */ result = pg_aclcheck(relname, usesysid, mode); @@ -931,7 +931,7 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS) static AclMode convert_priv_string(text *priv_type_text) { - char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text))); + char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -958,6 +958,7 @@ convert_priv_string(text *priv_type_text) return ACL_TRIGGER; elog(ERROR, "has_table_privilege: invalid privilege type %s", priv_type); + /* * We should never get here, but stop the compiler from complaining */ @@ -986,8 +987,8 @@ has_table_privilege_cname_cname(char *username, char *relname, usesysid = get_usesysid(username); /* - * Make use of has_table_privilege_id_cname. - * It accepts the arguments we now have. + * Make use of has_table_privilege_id_cname. It accepts the arguments + * we now have. */ return has_table_privilege_id_cname(usesysid, relname, priv_type_text); } @@ -1008,7 +1009,7 @@ has_table_privilege_cname_id(char *username, Oid reloid, text *priv_type_text) { int32 usesysid; - char *relname; + char *relname; /* * Lookup userid based on username @@ -1024,8 +1025,8 @@ has_table_privilege_cname_id(char *username, Oid reloid, reloid); /* - * Make use of has_table_privilege_id_cname. - * It accepts the arguments we now have. + * Make use of has_table_privilege_id_cname. It accepts the arguments + * we now have. */ return has_table_privilege_id_cname(usesysid, relname, priv_type_text); } @@ -1050,10 +1051,9 @@ has_table_privilege_id_cname(int32 usesysid, char *relname, int32 result; /* - * Check relname is valid. - * This is needed to deal with the case when usename is a superuser - * in which case pg_aclcheck simply returns ACLCHECK_OK - * without validating relname + * Check relname is valid. This is needed to deal with the case when + * usename is a superuser in which case pg_aclcheck simply returns + * ACLCHECK_OK without validating relname */ tuple = SearchSysCache(RELNAME, PointerGetDatum(relname), @@ -1063,12 +1063,12 @@ has_table_privilege_id_cname(int32 usesysid, char *relname, relname); ReleaseSysCache(tuple); - /* + /* * Convert priv_type_text to an AclMode */ mode = convert_priv_string(priv_type_text); - /* + /* * Finally, check for the privilege */ result = pg_aclcheck(relname, usesysid, mode); diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 84c674071c..f668784714 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.70 2001/03/22 03:59:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.71 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -764,7 +764,6 @@ array_ref(ArrayType *array, if (arraylen > 0) { - /* * fixed-length arrays -- these are assumed to be 1-d, 0-based */ @@ -815,7 +814,7 @@ array_ref(ArrayType *array, * lowerIndx[] and upperIndx[]. These are generally just temporaries. *----------------------------------------------------------------------------- */ -ArrayType * +ArrayType * array_get_slice(ArrayType *array, int nSubscripts, int *upperIndx, @@ -841,7 +840,6 @@ array_get_slice(ArrayType *array, if (arraylen > 0) { - /* * fixed-length arrays -- currently, cannot slice these because * parser labels output as being of the fixed-length array type! @@ -926,7 +924,7 @@ array_get_slice(ArrayType *array, * with NULL, which will probably not make him happy. *----------------------------------------------------------------------------- */ -ArrayType * +ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, @@ -958,7 +956,6 @@ array_set(ArrayType *array, if (arraylen > 0) { - /* * fixed-length arrays -- these are assumed to be 1-d, 0-based. We * cannot extend them, either. @@ -1090,7 +1087,7 @@ array_set(ArrayType *array, * with NULL, which will probably not make him happy. *---------------------------------------------------------------------------- */ -ArrayType * +ArrayType * array_set_slice(ArrayType *array, int nSubscripts, int *upperIndx, @@ -1123,7 +1120,6 @@ array_set_slice(ArrayType *array, if (arraylen > 0) { - /* * fixed-length arrays -- not got round to doing this... */ @@ -1192,7 +1188,6 @@ array_set_slice(ArrayType *array, olddatasize = ARR_SIZE(array) - overheadlen; if (ndim > 1) { - /* * here we do not need to cope with extension of the array; it * would be a lot more complicated if we had to do so... @@ -1203,7 +1198,6 @@ array_set_slice(ArrayType *array, } else { - /* * here we must allow for possibility of slice larger than orig * array @@ -1237,7 +1231,6 @@ array_set_slice(ArrayType *array, if (ndim > 1) { - /* * here we do not need to cope with extension of the array; it * would be a lot more complicated if we had to do so... @@ -1401,7 +1394,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType) * NULL element values are not supported. *---------- */ -ArrayType * +ArrayType * construct_array(Datum *elems, int nelems, bool elmbyval, int elmlen, char elmalign) { diff --git a/src/backend/utils/adt/ascii.c b/src/backend/utils/adt/ascii.c index 99bafca1ba..c08960ca20 100644 --- a/src/backend/utils/adt/ascii.c +++ b/src/backend/utils/adt/ascii.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * ascii.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.9 2001/09/06 04:57:29 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.10 2001/10/25 05:49:43 momjian Exp $ * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group * @@ -80,7 +80,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int if (enc == PG_LATIN1) { - /* * ISO-8859-1 <range: 160 -- 255> */ @@ -89,7 +88,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int } else if (enc == PG_LATIN2) { - /* * ISO-8859-2 <range: 160 -- 255> */ @@ -98,7 +96,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int } else if (enc == PG_WIN1250) { - /* * Window CP1250 <range: 128 -- 255> */ @@ -151,13 +148,13 @@ Datum to_ascii_encname(PG_FUNCTION_ARGS) { PG_RETURN_TEXT_P - ( - encode_to_ascii - ( - PG_GETARG_TEXT_P_COPY(0), - pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1))) - ) - ); + ( + encode_to_ascii + ( + PG_GETARG_TEXT_P_COPY(0), + pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1))) + ) + ); } /* ---------- @@ -168,13 +165,13 @@ Datum to_ascii_enc(PG_FUNCTION_ARGS) { PG_RETURN_TEXT_P - ( - encode_to_ascii - ( - PG_GETARG_TEXT_P_COPY(0), - PG_GETARG_INT32(1) - ) - ); + ( + encode_to_ascii + ( + PG_GETARG_TEXT_P_COPY(0), + PG_GETARG_INT32(1) + ) + ); } /* ---------- @@ -185,13 +182,12 @@ Datum to_ascii_default(PG_FUNCTION_ARGS) { PG_RETURN_TEXT_P - ( - encode_to_ascii - ( - PG_GETARG_TEXT_P_COPY(0), - GetDatabaseEncoding() - ) - ); + ( + encode_to_ascii + ( + PG_GETARG_TEXT_P_COPY(0), + GetDatabaseEncoding() + ) + ); } - #endif /* MULTIBYTE */ diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index dbcf881bf6..7ffa8a82c3 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.50 2001/03/22 03:59:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.51 2001/10/25 05:49:43 momjian Exp $ */ #include "postgres.h" @@ -85,7 +85,6 @@ cash_in(PG_FUNCTION_ARGS) #ifdef USE_LOCALE struct lconv *lconvert = PGLC_localeconv(); - #endif #ifdef USE_LOCALE @@ -244,7 +243,6 @@ cash_out(PG_FUNCTION_ARGS) #ifdef USE_LOCALE struct lconv *lconvert = PGLC_localeconv(); - #endif #ifdef USE_LOCALE diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index dc6bd5e976..fa2cc09321 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.31 2001/05/28 21:58:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.32 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -161,9 +161,9 @@ text_char(PG_FUNCTION_ARGS) char result; /* - * An empty input string is converted to \0 (for consistency with charin). - * If the input is longer than one character, the excess data is silently - * discarded. + * An empty input string is converted to \0 (for consistency with + * charin). If the input is longer than one character, the excess data + * is silently discarded. */ if (VARSIZE(arg1) > VARHDRSZ) result = *(VARDATA(arg1)); @@ -189,9 +189,7 @@ char_text(PG_FUNCTION_ARGS) *(VARDATA(result)) = arg1; } else - { VARATT_SIZEP(result) = VARHDRSZ; - } PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index d59d9f9e11..8fb2bbad29 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.62 2001/10/18 17:30:15 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.63 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -268,7 +268,7 @@ Datum date_timestamptz(PG_FUNCTION_ARGS) { DateADT dateVal = PG_GETARG_DATEADT(0); - TimestampTz result; + TimestampTz result; struct tm tt, *tm = &tt; time_t utime; @@ -310,7 +310,7 @@ date_timestamptz(PG_FUNCTION_ARGS) Datum timestamptz_date(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); DateADT result; struct tm tt, *tm = &tt; @@ -427,6 +427,7 @@ Datum time_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -506,7 +507,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) TimeTypmod = typmod; } - *time = (rint(((double) *time)*TimeScale)/TimeScale); + *time = (rint(((double) *time) * TimeScale) / TimeScale); if (*time >= 86400) *time -= 86400; @@ -610,7 +611,6 @@ time_smaller(PG_FUNCTION_ARGS) Datum overlaps_time(PG_FUNCTION_ARGS) { - /* * The arguments are TimeADT, but we leave them as generic Datums to * avoid dereferencing nulls (TimeADT is pass-by-reference!) @@ -679,7 +679,6 @@ overlaps_time(PG_FUNCTION_ARGS) */ if (TIMEADT_GT(ts1, ts2)) { - /* * This case is ts1 < te2 OR te1 < te2, which may look redundant * but in the presence of nulls it's not quite completely so. @@ -715,7 +714,6 @@ overlaps_time(PG_FUNCTION_ARGS) } else { - /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a * rather silly way of saying "true if both are nonnull, else @@ -937,6 +935,7 @@ Datum timetz_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -1199,7 +1198,6 @@ timetz_mi_interval(PG_FUNCTION_ARGS) Datum overlaps_timetz(PG_FUNCTION_ARGS) { - /* * The arguments are TimeTzADT *, but we leave them as generic Datums * for convenience of notation --- and to avoid dereferencing nulls. @@ -1268,7 +1266,6 @@ overlaps_timetz(PG_FUNCTION_ARGS) */ if (TIMETZ_GT(ts1, ts2)) { - /* * This case is ts1 < te2 OR te1 < te2, which may look redundant * but in the presence of nulls it's not quite completely so. @@ -1304,7 +1301,6 @@ overlaps_timetz(PG_FUNCTION_ARGS) } else { - /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a * rather silly way of saying "true if both are nonnull, else @@ -1360,7 +1356,7 @@ time_timetz(PG_FUNCTION_ARGS) Datum timestamptz_timetz(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); TimeTzADT *result; struct tm tt, *tm = &tt; @@ -1394,7 +1390,7 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS) { DateADT date = PG_GETARG_DATEADT(0); TimeTzADT *time = PG_GETARG_TIMETZADT_P(1); - TimestampTz result; + TimestampTz result; result = date * 86400.0 + time->time + time->zone; @@ -1477,7 +1473,7 @@ timetz_part(PG_FUNCTION_ARGS) if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) elog(ERROR, "TIMETZ units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); up = VARDATA(units); lp = lowunits; for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++) @@ -1550,19 +1546,17 @@ timetz_part(PG_FUNCTION_ARGS) default: elog(ERROR, "TIMETZ units '%s' not supported", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); result = 0; } } else if ((type == RESERV) && (val == DTK_EPOCH)) - { result = time->time - time->zone; - } else { elog(ERROR, "TIMETZ units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); result = 0; } diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 6d6fbd6b45..06b249a8e1 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.74 2001/10/20 01:02:18 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.75 2001/10/25 05:49:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,29 +27,29 @@ static int DecodeNumber(int flen, char *field, - int fmask, int *tmask, - struct tm * tm, double *fsec, int *is2digits); + int fmask, int *tmask, + struct tm * tm, double *fsec, int *is2digits); static int DecodeNumberField(int len, char *str, - int fmask, int *tmask, - struct tm * tm, double *fsec, int *is2digits); + int fmask, int *tmask, + struct tm * tm, double *fsec, int *is2digits); static int DecodeTime(char *str, int fmask, int *tmask, - struct tm * tm, double *fsec); + struct tm * tm, double *fsec); static int DecodeTimezone(char *str, int *tzp); static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel); static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); static int DecodePosixTimezone(char *str, int *val); -void TrimTrailingZeros(char *str); +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}; /***************************************************************************** @@ -237,7 +237,7 @@ static datetkn australian_datetktbl[] = { }; static unsigned int australian_szdatetktbl = sizeof australian_datetktbl / - sizeof australian_datetktbl[0]; +sizeof australian_datetktbl[0]; static datetkn deltatktbl[] = { /* text, token, lexval */ @@ -247,41 +247,41 @@ static datetkn deltatktbl[] = { {"cent", UNITS, DTK_CENTURY}, /* "century" relative */ {"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative */ {DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative */ - {"d", UNITS, DTK_DAY}, /* "day" relative */ - {DDAY, UNITS, DTK_DAY}, /* "day" relative */ - {"days", UNITS, DTK_DAY}, /* "days" relative */ - {"dec", UNITS, DTK_DECADE}, /* "decade" relative */ - {"decs", UNITS, DTK_DECADE}, /* "decades" relative */ + {"d", UNITS, DTK_DAY}, /* "day" relative */ + {DDAY, UNITS, DTK_DAY}, /* "day" relative */ + {"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 */ - {"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 */ + {"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 */ - {"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 */ + {"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 */ - {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */ - {"mins", UNITS, DTK_MINUTE}, /* "minutes" 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 */ {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative */ - {"mon", UNITS, DTK_MONTH}, /* "months" relative */ - {"mons", UNITS, DTK_MONTH}, /* "months" relative */ - {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */ + {"mon", UNITS, DTK_MONTH}, /* "months" relative */ + {"mons", UNITS, DTK_MONTH}, /* "months" relative */ + {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */ {"months", UNITS, DTK_MONTH}, {"ms", UNITS, DTK_MILLISEC}, {"msec", UNITS, DTK_MILLISEC}, {DMILLISEC, UNITS, DTK_MILLISEC}, {"mseconds", UNITS, DTK_MILLISEC}, {"msecs", UNITS, DTK_MILLISEC}, - {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */ + {"qtr", UNITS, DTK_QUARTER},/* "quarter" relative */ {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */ {"reltime", IGNORE, 0}, /* pre-v6.1 "Undefined Reltime" */ {"s", UNITS, DTK_SECOND}, @@ -289,12 +289,12 @@ static datetkn deltatktbl[] = { {DSECOND, UNITS, DTK_SECOND}, {"seconds", UNITS, DTK_SECOND}, {"secs", UNITS, DTK_SECOND}, - {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 */ + {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 */ {"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 */ @@ -391,7 +391,7 @@ j2day(int date) void TrimTrailingZeros(char *str) { - int len = strlen(str); + int len = strlen(str); #if 0 /* chop off trailing one to cope with interval rounding */ @@ -585,7 +585,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 flen, val; @@ -594,16 +595,17 @@ DecodeDateTime(char **field, int *ftype, int nf, int is2digits = FALSE; int bc = FALSE; - /* We'll insist on at least all of the date fields, - * but initialize the remaining fields in case they are not - * set later... + /* + * We'll insist on at least all of the date fields, but initialize the + * remaining fields in case they are not set later... */ *dtype = DTK_DATE; tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; *fsec = 0; - tm->tm_isdst = -1; /* don't know daylight savings time status apriori */ + tm->tm_isdst = -1; /* don't know daylight savings time status + * apriori */ if (tzp != NULL) *tzp = 0; @@ -612,13 +614,17 @@ DecodeDateTime(char **field, int *ftype, int nf, switch (ftype[i]) { case DTK_DATE: - /* Previous field was a label for "julian date"? - * then this should be a julian date with fractional day... + + /* + * Previous field was a label for "julian date"? then this + * should be a julian date with fractional day... */ if (ptype == JULIAN) { - char *cp; - double dt, date, time; + char *cp; + double dt, + date, + time; dt = strtod(field[i], &cp); if (*cp != '\0') @@ -633,9 +639,10 @@ DecodeDateTime(char **field, int *ftype, int nf, *dtype = DTK_DATE; } - /* Already have a date? Then this might be a POSIX time - * zone with an embedded dash (e.g. "PST-3" == "EST") - * - thomas 2000-03-15 + /* + * Already have a date? Then this might be a POSIX time + * zone with an embedded dash (e.g. "PST-3" == "EST") - + * thomas 2000-03-15 */ else if ((fmask & DTK_DATE_M) == DTK_DATE_M) { @@ -647,16 +654,15 @@ DecodeDateTime(char **field, int *ftype, int nf, tmask = DTK_M(TZ); } else if (DecodeDate(field[i], fmask, &tmask, tm) != 0) - { return -1; - } break; case DTK_TIME: if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) return -1; - /* Check upper limit on hours; other limits checked in + /* + * Check upper limit on hours; other limits checked in * DecodeTime() */ if (tm->tm_hour > 23) @@ -696,19 +702,21 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_NUMBER: flen = strlen(field[i]); - /* Was this an "ISO date" with embedded field labels? - * An example is "y2001m02d04" - thomas 2001-02-04 + /* + * Was this an "ISO date" with embedded field labels? An + * example is "y2001m02d04" - thomas 2001-02-04 */ if (ptype != 0) { - char *cp; - int val; + char *cp; + int val; val = strtol(field[i], &cp, 10); if (*cp != '\0') return -1; - switch (ptype) { + switch (ptype) + { case YEAR: tm->tm_year = val; tmask = DTK_M(ptype); @@ -740,9 +748,12 @@ DecodeDateTime(char **field, int *ftype, int nf, break; case JULIAN: - /* previous field was a label for "julian date"? - * then this is a julian day with no fractional part - * (see DTK_DATE for cases involving fractional parts) + + /* + * previous field was a label for "julian + * date"? then this is a julian day with no + * fractional part (see DTK_DATE for cases + * involving fractional parts) */ j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday); @@ -757,6 +768,7 @@ DecodeDateTime(char **field, int *ftype, int nf, ptype = 0; *dtype = DTK_DATE; } + /* * long numeric string and either no date or no time read * yet? then interpret as a concatenated date or time... @@ -769,9 +781,7 @@ DecodeDateTime(char **field, int *ftype, int nf, } /* otherwise it is a single date/time field... */ else if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0) - { return -1; - } break; case DTK_STRING: @@ -916,9 +926,9 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_ISO_TIME: tmask = 0; - if ((i < 1) || (i >= (nf-1)) - || (ftype[i-1] != DTK_DATE) - || (ftype[i+1] != DTK_TIME)) + if ((i < 1) || (i >= (nf - 1)) + || (ftype[i - 1] != DTK_DATE) + || (ftype[i + 1] != DTK_TIME)) return -1; break; @@ -977,7 +987,6 @@ DecodeDateTime(char **field, int *ftype, int nf, if (((fmask & DTK_DATE_M) == DTK_DATE_M) && (tzp != NULL) && (!(fmask & DTK_M(TZ)))) { - /* * daylight savings time modifier but no standard timezone? * then error @@ -1008,16 +1017,16 @@ DetermineLocalTimeZone(struct tm * tm) int tz; if (HasCTZSet) - { tz = CTimeZone; - } else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday)) { #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) + /* - * Some buggy mktime() implementations may change the year/month/day - * when given a time right at a DST boundary. To prevent corruption - * of the caller's data, give mktime() a copy... + * Some buggy mktime() implementations may change the + * year/month/day when given a time right at a DST boundary. To + * prevent corruption of the caller's data, give mktime() a + * copy... */ struct tm tt, *tmp = &tt; @@ -1500,9 +1509,8 @@ DecodeNumber(int flen, char *str, int fmask, /* * Enough digits to be unequivocal year? Used to test for 4 digits or * more, but we now test first for a three-digit doy so anything - * bigger than two digits had better be an explicit year. - * - thomas 1999-01-09 - * Back to requiring a 4 digit year. We accept a two digit + * bigger than two digits had better be an explicit year. - thomas + * 1999-01-09 Back to requiring a 4 digit year. We accept a two digit * year farther down. - thomas 2000-03-28 */ else if (flen >= 4) @@ -1745,7 +1753,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) tp = NULL; if (Australian_timezones) tp = datebsearch(lowtoken, australian_datetktbl, - australian_szdatetktbl); + australian_szdatetktbl); if (!tp) tp = datebsearch(lowtoken, datetktbl, szdatetktbl); } @@ -1863,7 +1871,6 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do { if (*cp == '.') { - /* * Got a decimal point? Then assume some sort of * seconds specification @@ -1872,7 +1879,6 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do } else if (*cp == '\0') { - /* * Only a signed integer? Then must assume a * timezone-like usage @@ -2062,9 +2068,7 @@ DecodeUnits(int field, char *lowtoken, int *val) && (strncmp(lowtoken, deltacache[field]->token, TOKMAXLEN) == 0)) tp = deltacache[field]; else - { tp = datebsearch(lowtoken, deltatktbl, szdeltatktbl); - } deltacache[field] = tp; if (tp == NULL) { @@ -2189,25 +2193,23 @@ EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str) sprintf(str, "%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 */ - if (fsec != 0) { + if (fsec != 0) + { sprintf((str + strlen(str)), ":%013.10f", sec); /* chop off trailing pairs of zeros... */ while ((strcmp((str + strlen(str) - 2), "00") == 0) && (*(str + strlen(str) - 3) != '.')) - { *(str + strlen(str) - 2) = '\0'; - } } else - { sprintf((str + strlen(str)), ":%02.0f", sec); - } if (tzp != NULL) { @@ -2257,24 +2259,28 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha sprintf(str, "%04d-%02d-%02d %02d:%02d", tm->tm_year, 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 */ - if (fsec != 0) { + if (fsec != 0) + { sprintf((str + strlen(str)), ":%013.10f", sec); TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02.0f", sec); - } - /* 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)) { @@ -2306,27 +2312,26 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha sprintf((str + 5), "/%04d %02d:%02d", tm->tm_year, 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 */ - if (fsec != 0) { + if (fsec != 0) + { sprintf((str + strlen(str)), ":%013.10f", sec); TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02.0f", sec); - } if ((tzp != NULL) && (tm->tm_isdst >= 0)) { if (*tzn != NULL) - { sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn); - } else { hour = -(*tzp / 3600); @@ -2348,27 +2353,26 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha sprintf((str + 5), ".%04d %02d:%02d", tm->tm_year, 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 */ - if (fsec != 0) { + if (fsec != 0) + { sprintf((str + strlen(str)), ":%013.10f", sec); TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02.0f", sec); - } if ((tzp != NULL) && (tm->tm_isdst >= 0)) { if (*tzn != NULL) - { sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn); - } else { hour = -(*tzp / 3600); @@ -2400,35 +2404,36 @@ EncodeDateTime(struct tm * tm, double 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 */ - if (fsec != 0) { + if (fsec != 0) + { sprintf((str + strlen(str)), ":%013.10f", sec); TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02.0f", sec); - } sprintf((str + strlen(str)), " %04d", tm->tm_year); if ((tzp != NULL) && (tm->tm_isdst >= 0)) { if (*tzn != NULL) - { sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn); - } 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); @@ -2663,10 +2668,11 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str) } /* EncodeTimeSpan() */ -void ClearDateCache(bool dummy) +void +ClearDateCache(bool dummy) { - int i; + int i; - for (i=0; i < MAXDATEFIELDS; i++) + for (i = 0; i < MAXDATEFIELDS; i++) datecache[i] = NULL; } diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index 4e278c0489..bb3fafdafb 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.21 2001/07/15 22:48:18 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.22 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,7 +133,6 @@ datumFree(Datum value, bool typByVal, int typLen) pfree(s); } } - #endif /*------------------------------------------------------------------------- @@ -157,7 +156,6 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen) if (typByVal) { - /* * just compare the two datums. NOTE: just comparing "len" bytes * will not do the work, because we do not know how these bytes diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index ce197bd19f..e5308aca27 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.3 2001/09/30 22:03:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.4 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,13 +20,13 @@ struct pg_encoding { - unsigned (*encode_len) (const uint8 *data, unsigned dlen); - unsigned (*decode_len) (const uint8 *data, unsigned dlen); - unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res); - unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res); + unsigned (*encode_len) (const uint8 *data, unsigned dlen); + unsigned (*decode_len) (const uint8 *data, unsigned dlen); + unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res); + unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res); }; -static struct pg_encoding * pg_find_encoding(const char *name); +static struct pg_encoding *pg_find_encoding(const char *name); /* * SQL functions. @@ -39,7 +39,9 @@ binary_encode(PG_FUNCTION_ARGS) Datum name = PG_GETARG_DATUM(1); text *result; char *namebuf; - int datalen, resultlen, res; + int datalen, + resultlen, + res; struct pg_encoding *enc; datalen = VARSIZE(data) - VARHDRSZ; @@ -70,8 +72,10 @@ binary_decode(PG_FUNCTION_ARGS) text *data = PG_GETARG_TEXT_P(0); Datum name = PG_GETARG_DATUM(1); bytea *result; - char *namebuf; - int datalen, resultlen, res; + char *namebuf; + int datalen, + resultlen, + res; struct pg_encoding *enc; datalen = VARSIZE(data) - VARHDRSZ; @@ -115,9 +119,9 @@ static const int8 hexlookup[128] = { }; static unsigned -hex_encode(const uint8 * src, unsigned len, uint8 * dst) +hex_encode(const uint8 *src, unsigned len, uint8 *dst) { - const uint8 *end = src + len; + const uint8 *end = src + len; while (src < end) { @@ -131,7 +135,7 @@ hex_encode(const uint8 * src, unsigned len, uint8 * dst) static uint8 get_hex(unsigned c) { - int res = -1; + int res = -1; if (c > 0 && c < 127) res = hexlookup[c]; @@ -139,11 +143,11 @@ get_hex(unsigned c) if (res < 0) elog(ERROR, "Bad hex code: '%c'", c); - return (uint8)res; + return (uint8) res; } static unsigned -hex_decode(const uint8 * src, unsigned len, uint8 * dst) +hex_decode(const uint8 *src, unsigned len, uint8 *dst) { const uint8 *s, *srcend; @@ -172,13 +176,13 @@ hex_decode(const uint8 * src, unsigned len, uint8 * dst) } static unsigned -hex_enc_len(const uint8 * src, unsigned srclen) +hex_enc_len(const uint8 *src, unsigned srclen) { return srclen << 1; } static unsigned -hex_dec_len(const uint8 * src, unsigned srclen) +hex_dec_len(const uint8 *src, unsigned srclen) { return srclen >> 1; } @@ -202,7 +206,7 @@ static const int8 b64lookup[128] = { }; static unsigned -b64_encode(const uint8 * src, unsigned len, uint8 * dst) +b64_encode(const uint8 *src, unsigned len, uint8 *dst) { uint8 *p, *lend = dst + 76; @@ -249,9 +253,9 @@ b64_encode(const uint8 * src, unsigned len, uint8 * dst) } static unsigned -b64_decode(const uint8 * src, unsigned len, uint8 * dst) +b64_decode(const uint8 *src, unsigned len, uint8 *dst) { - const char *srcend = src + len, + const char *srcend = src + len, *s = src; uint8 *p = dst; unsigned c; @@ -281,7 +285,8 @@ b64_decode(const uint8 * src, unsigned len, uint8 * dst) } b = 0; } - else { + else + { b = -1; if (c > 0 && c < 127) b = b64lookup[c]; @@ -311,14 +316,14 @@ b64_decode(const uint8 * src, unsigned len, uint8 * dst) static unsigned -b64_enc_len(const uint8 * src, unsigned srclen) +b64_enc_len(const uint8 *src, unsigned srclen) { /* 3 bytes will be converted to 4, linefeed after 76 chars */ return (srclen + 2) * 4 / 3 + srclen / (76 * 3 / 4); } static unsigned -b64_dec_len(const uint8 * src, unsigned srclen) +b64_dec_len(const uint8 *src, unsigned srclen) { return (srclen * 3) >> 2; } @@ -327,10 +332,10 @@ b64_dec_len(const uint8 * src, unsigned srclen) * Escape * Minimally escape bytea to text. * De-escape text to bytea. - * + * * Only two characters are escaped: * \0 (null) and \\ (backslash) - * + * * De-escapes \\ and any \### octal */ @@ -340,9 +345,9 @@ b64_dec_len(const uint8 * src, unsigned srclen) static unsigned esc_encode(const uint8 *src, unsigned srclen, uint8 *dst) { - const uint8 *end = src + srclen; - uint8 *rp = dst; - int len = 0; + const uint8 *end = src + srclen; + uint8 *rp = dst; + int len = 0; while (src < end) { @@ -377,22 +382,20 @@ esc_encode(const uint8 *src, unsigned srclen, uint8 *dst) static unsigned esc_decode(const uint8 *src, unsigned srclen, uint8 *dst) { - const uint8 *end = src + srclen; - uint8 *rp = dst; - int len = 0; + const uint8 *end = src + srclen; + uint8 *rp = dst; + int len = 0; while (src < end) { if (src[0] != '\\') - { *rp++ = *src++; - } - else if ( src+3 < end && - (src[1] >= '0' && src[1] <= '3') && - (src[2] >= '0' && src[2] <= '7') && - (src[3] >= '0' && src[3] <= '7') ) + else if (src + 3 < end && + (src[1] >= '0' && src[1] <= '3') && + (src[2] >= '0' && src[2] <= '7') && + (src[3] >= '0' && src[3] <= '7')) { - int val; + int val; val = VAL(src[1]); val <<= 3; @@ -401,8 +404,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst) *rp++ = val + VAL(src[3]); src += 4; } - else if ( src+1 < end && - (src[1] == '\\') ) + else if (src + 1 < end && + (src[1] == '\\')) { *rp++ = '\\'; src += 2; @@ -410,8 +413,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst) else { /* - * One backslash, not followed by ### valid octal. - * Should never get here, since esc_dec_len does same check. + * One backslash, not followed by ### valid octal. Should + * never get here, since esc_dec_len does same check. */ elog(ERROR, "decode: Bad input string for type bytea"); } @@ -425,8 +428,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst) static unsigned esc_enc_len(const uint8 *src, unsigned srclen) { - const uint8 *end = src + srclen; - int len = 0; + const uint8 *end = src + srclen; + int len = 0; while (src < end) { @@ -446,27 +449,25 @@ esc_enc_len(const uint8 *src, unsigned srclen) static unsigned esc_dec_len(const uint8 *src, unsigned srclen) { - const uint8 *end = src + srclen; - int len = 0; + const uint8 *end = src + srclen; + int len = 0; while (src < end) { if (src[0] != '\\') - { src++; - } - else if ( src+3 < end && - (src[1] >= '0' && src[1] <= '3') && - (src[2] >= '0' && src[2] <= '7') && - (src[3] >= '0' && src[3] <= '7') ) + else if (src + 3 < end && + (src[1] >= '0' && src[1] <= '3') && + (src[2] >= '0' && src[2] <= '7') && + (src[3] >= '0' && src[3] <= '7')) { /* * backslash + valid octal */ src += 4; } - else if ( src+1 < end && - (src[1] == '\\') ) + else if (src + 1 < end && + (src[1] == '\\')) { /* * two backslashes = backslash @@ -490,20 +491,43 @@ esc_dec_len(const uint8 *src, unsigned srclen) * Common */ -static struct { +static struct +{ const char *name; struct pg_encoding enc; -} enclist[] = { - {"hex", { hex_enc_len, hex_dec_len, hex_encode, hex_decode }}, - {"base64", { b64_enc_len, b64_dec_len, b64_encode, b64_decode }}, - {"escape", { esc_enc_len, esc_dec_len, esc_encode, esc_decode }}, - {NULL, { NULL, NULL, NULL, NULL } } +} enclist[] = + +{ + { + "hex", + { + hex_enc_len, hex_dec_len, hex_encode, hex_decode + } + }, + { + "base64", + { + b64_enc_len, b64_dec_len, b64_encode, b64_decode + } + }, + { + "escape", + { + esc_enc_len, esc_dec_len, esc_encode, esc_decode + } + }, + { + NULL, + { + NULL, NULL, NULL, NULL + } + } }; static struct pg_encoding * pg_find_encoding(const char *name) { - int i; + int i; for (i = 0; enclist[i].name; i++) if (strcasecmp(enclist[i].name, name) == 0) diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 8e5408af31..c7dc220d07 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.74 2001/06/07 00:09:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.75 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,7 +71,6 @@ #ifndef atof extern double atof(const char *p); - #endif #ifndef HAVE_CBRT @@ -81,7 +80,6 @@ static double cbrt(double x); #else #if !defined(nextstep) extern double cbrt(double x); - #endif #endif /* HAVE_CBRT */ @@ -91,9 +89,7 @@ static double rint(double x); #else extern double rint(double x); - #endif /* HAVE_RINT */ - #endif /* NeXT check */ @@ -140,7 +136,6 @@ static void CheckFloat8Val(double val); static void CheckFloat4Val(double val) { - /* * defining unsafe floats's will make float4 and float8 ops faster at * the cost of safety, of course! @@ -165,7 +160,6 @@ CheckFloat4Val(double val) static void CheckFloat8Val(double val) { - /* * defining unsafe floats's will make float4 and float8 ops faster at * the cost of safety, of course! @@ -344,6 +338,7 @@ Datum float4up(PG_FUNCTION_ARGS) { float4 arg = PG_GETARG_FLOAT4(0); + PG_RETURN_FLOAT4(arg); } @@ -410,6 +405,7 @@ Datum float8up(PG_FUNCTION_ARGS) { float8 arg = PG_GETARG_FLOAT8(0); + PG_RETURN_FLOAT8(arg); } @@ -578,9 +574,9 @@ static int float4_cmp_internal(float4 a, float4 b) { /* - * We consider all NANs to be equal and larger than any non-NAN. - * This is somewhat arbitrary; the important thing is to have a - * consistent sort order. + * We consider all NANs to be equal and larger than any non-NAN. This + * is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ if (isnan(a)) { @@ -674,9 +670,9 @@ static int float8_cmp_internal(float8 a, float8 b) { /* - * We consider all NANs to be equal and larger than any non-NAN. - * This is somewhat arbitrary; the important thing is to have a - * consistent sort order. + * We consider all NANs to be equal and larger than any non-NAN. This + * is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ if (isnan(a)) { @@ -1479,7 +1475,6 @@ setseed(PG_FUNCTION_ARGS) static float8 * check_float8_array(ArrayType *transarray, const char *caller) { - /* * We expect the input to be a 3-element float array; verify that. We * don't need to use deconstruct_array() since the array data is just @@ -1974,7 +1969,6 @@ rint(double x) w = TWO52[sx] + x; return w - TWO52[sx]; } - #endif /* !HAVE_RINT */ #ifndef HAVE_CBRT @@ -1987,5 +1981,4 @@ cbrt(double x) return isneg ? -tmpres : tmpres; } - #endif /* !HAVE_CBRT */ diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index f2cf46200d..af928933dd 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.20 2001/10/23 20:12:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.21 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -216,8 +216,8 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid) case INTERVALOID: if (with_typemod) { - int fields = typemod >> 16; - int precision = typemod & 0xFFFF; + int fields = typemod >> 16; + int precision = typemod & 0xFFFF; const char *fieldstr; switch (fields) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index d517eb6818..0957783a4a 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.41 2001/09/28 08:09:11 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.42 2001/10/25 05:49:44 momjian Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group @@ -44,9 +44,9 @@ * * Karel Zak * - * TODO - * - better number building (formatting) / parsing, now it isn't - * ideal code + * TODO + * - better number building (formatting) / parsing, now it isn't + * ideal code * - use Assert() * - add support for abstime * - add support for roman number to standard number conversion @@ -374,11 +374,11 @@ typedef struct yyyy, yyy, yy, - y, + y, bc, iw, ww, - w, + w, cc, q, j, @@ -414,13 +414,13 @@ typedef struct */ typedef struct TmToChar { - struct tm tm; /* classic 'tm' struct */ - double fsec; /* milliseconds */ - char *tzn; /* timezone */ + struct tm tm; /* classic 'tm' struct */ + double fsec; /* milliseconds */ + char *tzn; /* timezone */ } TmToChar; #define tmtcTm(_X) (&(_X)->tm) -#define tmtcTzn(_X) ((_X)->tzn) +#define tmtcTzn(_X) ((_X)->tzn) #define tmtcFsec(_X) ((_X)->fsec) #define ZERO_tm( _X ) \ @@ -521,132 +521,132 @@ static KeySuffix DCH_suff[] = { typedef enum { - DCH_A_D, - DCH_A_M, - DCH_AD, - DCH_AM, - DCH_B_C, - DCH_BC, - DCH_CC, - DCH_DAY, - DCH_DDD, - DCH_DD, - DCH_DY, - DCH_Day, - DCH_Dy, - DCH_D, - DCH_FX, /* global suffix */ - DCH_HH24, - DCH_HH12, - DCH_HH, - DCH_IW, - DCH_J, - DCH_MI, - DCH_MM, - DCH_MONTH, - DCH_MON, - DCH_MS, - DCH_Month, - DCH_Mon, - DCH_P_M, - DCH_PM, - DCH_Q, - DCH_RM, - DCH_SSSS, - DCH_SS, - DCH_TZ, - DCH_US, - DCH_WW, - DCH_W, - DCH_Y_YYY, - DCH_YYYY, - DCH_YYY, - DCH_YY, - DCH_Y, - DCH_a_d, - DCH_a_m, - DCH_ad, - DCH_am, - DCH_b_c, - DCH_bc, - DCH_cc, - DCH_day, - DCH_ddd, - DCH_dd, - DCH_dy, - DCH_d, - DCH_fx, - DCH_hh24, - DCH_hh12, - DCH_hh, - DCH_iw, - DCH_j, - DCH_mi, - DCH_mm, - DCH_month, - DCH_mon, - DCH_ms, - DCH_p_m, - DCH_pm, - DCH_q, - DCH_rm, - DCH_ssss, - DCH_ss, - DCH_tz, - DCH_us, - DCH_ww, - DCH_w, - DCH_y_yyy, - DCH_yyyy, - DCH_yyy, - DCH_yy, - DCH_y, + DCH_A_D, + DCH_A_M, + DCH_AD, + DCH_AM, + DCH_B_C, + DCH_BC, + DCH_CC, + DCH_DAY, + DCH_DDD, + DCH_DD, + DCH_DY, + DCH_Day, + DCH_Dy, + DCH_D, + DCH_FX, /* global suffix */ + DCH_HH24, + DCH_HH12, + DCH_HH, + DCH_IW, + DCH_J, + DCH_MI, + DCH_MM, + DCH_MONTH, + DCH_MON, + DCH_MS, + DCH_Month, + DCH_Mon, + DCH_P_M, + DCH_PM, + DCH_Q, + DCH_RM, + DCH_SSSS, + DCH_SS, + DCH_TZ, + DCH_US, + DCH_WW, + DCH_W, + DCH_Y_YYY, + DCH_YYYY, + DCH_YYY, + DCH_YY, + DCH_Y, + DCH_a_d, + DCH_a_m, + DCH_ad, + DCH_am, + DCH_b_c, + DCH_bc, + DCH_cc, + DCH_day, + DCH_ddd, + DCH_dd, + DCH_dy, + DCH_d, + DCH_fx, + DCH_hh24, + DCH_hh12, + DCH_hh, + DCH_iw, + DCH_j, + DCH_mi, + DCH_mm, + DCH_month, + DCH_mon, + DCH_ms, + DCH_p_m, + DCH_pm, + DCH_q, + DCH_rm, + DCH_ssss, + DCH_ss, + DCH_tz, + DCH_us, + DCH_ww, + DCH_w, + DCH_y_yyy, + DCH_yyyy, + DCH_yyy, + DCH_yy, + DCH_y, /* last */ - _DCH_last_ + _DCH_last_ } DCH_poz; typedef enum { - NUM_COMMA, - NUM_DEC, - NUM_0, - NUM_9, - NUM_B, - NUM_C, - NUM_D, - NUM_E, - NUM_FM, - NUM_G, - NUM_L, - NUM_MI, - NUM_PL, - NUM_PR, - NUM_RN, - NUM_SG, - NUM_SP, - NUM_S, - NUM_TH, - NUM_V, - NUM_b, - NUM_c, - NUM_d, - NUM_e, - NUM_fm, - NUM_g, - NUM_l, - NUM_mi, - NUM_pl, - NUM_pr, - NUM_rn, - NUM_sg, - NUM_sp, - NUM_s, - NUM_th, - NUM_v, + NUM_COMMA, + NUM_DEC, + NUM_0, + NUM_9, + NUM_B, + NUM_C, + NUM_D, + NUM_E, + NUM_FM, + NUM_G, + NUM_L, + NUM_MI, + NUM_PL, + NUM_PR, + NUM_RN, + NUM_SG, + NUM_SP, + NUM_S, + NUM_TH, + NUM_V, + NUM_b, + NUM_c, + NUM_d, + NUM_e, + NUM_fm, + NUM_g, + NUM_l, + NUM_mi, + NUM_pl, + NUM_pr, + NUM_rn, + NUM_sg, + NUM_sp, + NUM_s, + NUM_th, + NUM_v, /* last */ - _NUM_last_ + _NUM_last_ } NUM_poz; /* ---------- @@ -689,7 +689,7 @@ static KeyWord DCH_keywords[] = { {"SSSS", 4, dch_time, DCH_SSSS, TRUE}, /* S */ {"SS", 2, dch_time, DCH_SS, TRUE}, {"TZ", 2, dch_time, DCH_TZ, FALSE}, /* T */ - {"US", 2, dch_time, DCH_US, TRUE}, /* U */ + {"US", 2, dch_time, DCH_US, TRUE}, /* U */ {"WW", 2, dch_date, DCH_WW, TRUE}, /* W */ {"W", 1, dch_date, DCH_W, TRUE}, {"Y,YYY", 5, dch_date, DCH_Y_YYY, TRUE}, /* Y */ @@ -883,12 +883,11 @@ static char *DCH_processor(FormatNode *node, char *inout, int flag, void *data); #ifdef DEBUG_TO_FROM_CHAR static void dump_index(KeyWord *k, int *index); static void dump_node(FormatNode *node, int max); - #endif static char *get_th(char *num, int type); static char *str_numth(char *dest, char *num, int type); -static int strdigits_len(char *str); +static int strdigits_len(char *str); static char *str_toupper(char *buff); static char *str_tolower(char *buff); @@ -1196,7 +1195,6 @@ parse_format(FormatNode *node, char *str, KeyWord *kw, } else if (*str) { - /* * Special characters '\' and '"' */ @@ -1299,7 +1297,6 @@ DCH_processor(FormatNode *node, char *inout, int flag, void *data) } else { - /* * Remove to output char from input in TO_CHAR */ @@ -1308,7 +1305,6 @@ DCH_processor(FormatNode *node, char *inout, int flag, void *data) else { - /* * Skip blank space in FROM_CHAR's input */ @@ -1364,8 +1360,7 @@ dump_node(FormatNode *node, int max) } } - -#endif /* DEBUG */ +#endif /* DEBUG */ /***************************************************************************** * Private utils @@ -1571,8 +1566,7 @@ dump_index(KeyWord *k, int *index) elog(DEBUG_elog_output, "\n\t\tUsed positions: %d,\n\t\tFree positions: %d", count, free_i); } - -#endif /* DEBUG */ +#endif /* DEBUG */ /* ---------- * Skip TM / th in FROM_CHAR @@ -1630,10 +1624,10 @@ is_next_separator(FormatNode *n) static int strdigits_len(char *str) { - char *p = str; - int len = 0; - - while (*p && isdigit((unsigned char ) *p) && len <= DCH_MAX_ITEM_SIZ) + char *p = str; + int len = 0; + + while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ) { len++; p++; @@ -1652,12 +1646,12 @@ strdigits_len(char *str) static int dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) { - char *p_inout = inout; - struct tm *tm = NULL; - TmFromChar *tmfc = NULL; - TmToChar *tmtc = NULL; + char *p_inout = inout; + struct tm *tm = NULL; + TmFromChar *tmfc = NULL; + TmToChar *tmtc = NULL; - if (flag==TO_CHAR) + if (flag == TO_CHAR) { tmtc = (TmToChar *) data; tm = tmtcTm(tmtc); @@ -1850,7 +1844,7 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) } } break; - case DCH_MS: /* millisecond */ + case DCH_MS: /* millisecond */ if (flag == TO_CHAR) { sprintf(inout, "%03d", (int) rint(tmtc->fsec * 1000)); @@ -1864,34 +1858,39 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) } else if (flag == FROM_CHAR) { - int len, x; - + int len, + x; + if (is_next_separator(node)) { sscanf(inout, "%d", &tmfc->ms); len = x = strdigits_len(inout); } - else + else { sscanf(inout, "%03d", &tmfc->ms); x = strdigits_len(inout); - len = x = x > 3 ? 3 : x; - } - - /* 25 is 0.25 and 250 is 0.25 too; - * 025 is 0.025 and not 0.25 + len = x = x > 3 ? 3 : x; + } + + /* + * 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not + * 0.25 + */ + tmfc->ms *= x == 1 ? 100 : + x == 2 ? 10 : 1; + + /* + * elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, + * len); */ - tmfc->ms *= x==1 ? 100 : - x==2 ? 10 : 1; - - /* elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, len); */ return len - 1 + SKIP_THth(suf); } break; - case DCH_US: /* microsecond */ + case DCH_US: /* microsecond */ if (flag == TO_CHAR) { - sprintf(inout, "%06d", (int)rint(tmtc->fsec * 1000000)); + sprintf(inout, "%06d", (int) rint(tmtc->fsec * 1000000)); if (S_THth(suf)) str_numth(p_inout, inout, S_TH_TYPE(suf)); if (S_THth(suf)) @@ -1901,27 +1900,31 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) } else if (flag == FROM_CHAR) { - int len, x; - + int len, + x; + if (is_next_separator(node)) { sscanf(inout, "%d", &tmfc->us); len = x = strdigits_len(inout); } - else + else { sscanf(inout, "%06d", &tmfc->us); x = strdigits_len(inout); - len = x = x > 6 ? 6 : x; - } - - tmfc->us *= x==1 ? 100000 : - x==2 ? 10000 : - x==3 ? 1000 : - x==4 ? 100 : - x==5 ? 10 : 1; - - /* elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us, len); */ + len = x = x > 6 ? 6 : x; + } + + tmfc->us *= x == 1 ? 100000 : + x == 2 ? 10000 : + x == 3 ? 1000 : + x == 4 ? 100 : + x == 5 ? 10 : 1; + + /* + * elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us, + * len); + */ return len - 1 + SKIP_THth(suf); } break; @@ -1953,7 +1956,7 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) case DCH_TZ: if (flag == TO_CHAR && tmtcTzn(tmtc)) { - int siz = strlen(tmtcTzn(tmtc)); + int siz = strlen(tmtcTzn(tmtc)); if (arg == DCH_TZ) strcpy(inout, tmtcTzn(tmtc)); @@ -1990,13 +1993,15 @@ do { \ static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) { - char buff[DCH_CACHE_SIZE], *p_inout; - int i, len; - struct tm *tm = NULL; - TmFromChar *tmfc = NULL; - TmToChar *tmtc = NULL; + char buff[DCH_CACHE_SIZE], + *p_inout; + int i, + len; + struct tm *tm = NULL; + TmFromChar *tmfc = NULL; + TmToChar *tmtc = NULL; - if (flag==TO_CHAR) + if (flag == TO_CHAR) { tmtc = (TmToChar *) data; tm = tmtcTm(tmtc); @@ -2394,7 +2399,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) sscanf(inout, "%d,%03d", &cc, &tmfc->yyyy); tmfc->yyyy += (cc * 1000); - return strdigits_len(inout) + 3 + SKIP_THth(suf); + return strdigits_len(inout) + 3 + SKIP_THth(suf); } break; case DCH_YYYY: @@ -2648,10 +2653,11 @@ static text * datetime_to_char_body(TmToChar *tmtc, text *fmt) { FormatNode *format; - struct tm *tm = NULL; - char *str_fmt, *result; - bool incache; - int len = VARSIZE(fmt) - VARHDRSZ; + struct tm *tm = NULL; + char *str_fmt, + *result; + bool incache; + int len = VARSIZE(fmt) - VARHDRSZ; tm = tmtcTm(tmtc); tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7; @@ -2671,7 +2677,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt) /* * Allocate new memory if format picture is bigger than static cache - * and not use cache (call parser always) - incache=FALSE show this variant + * and not use cache (call parser always) - incache=FALSE show this + * variant */ if (len > DCH_CACHE_SIZE) { @@ -2686,11 +2693,11 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt) } else { - /* * Use cache buffers */ DCHCacheEntry *ent; + incache = TRUE; if ((ent = DCH_cache_search(str_fmt)) == NULL) @@ -2730,7 +2737,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt) pfree(result); else { - text *res = (text *) palloc(len + 1 + VARHDRSZ); + text *res = (text *) palloc(len + 1 + VARHDRSZ); memcpy(VARDATA(res), result, len); VARATT_SIZEP(res) = len + VARHDRSZ; @@ -2750,12 +2757,13 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt) Datum timestamp_to_char(PG_FUNCTION_ARGS) { - Timestamp dt = PG_GETARG_TIMESTAMP(0); - text *fmt = PG_GETARG_TEXT_P(1), *res; - TmToChar tmtc; - int r = 0; + Timestamp dt = PG_GETARG_TIMESTAMP(0); + text *fmt = PG_GETARG_TEXT_P(1), + *res; + TmToChar tmtc; + int r = 0; - if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt)) + if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt)) PG_RETURN_NULL(); ZERO_tmtc(&tmtc); @@ -2765,7 +2773,7 @@ timestamp_to_char(PG_FUNCTION_ARGS) if (r != 0) elog(ERROR, "to_char(): Unable to convert timestamp to tm"); - if (!(res=datetime_to_char_body(&tmtc, fmt))) + if (!(res = datetime_to_char_body(&tmtc, fmt))) PG_RETURN_NULL(); PG_RETURN_TEXT_P(res); @@ -2775,11 +2783,13 @@ Datum timestamptz_to_char(PG_FUNCTION_ARGS) { TimestampTz dt = PG_GETARG_TIMESTAMP(0); - text *fmt = PG_GETARG_TEXT_P(1), *res; - TmToChar tmtc; - int tz, r = 0; + text *fmt = PG_GETARG_TEXT_P(1), + *res; + TmToChar tmtc; + int tz, + r = 0; - if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt)) + if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt)) PG_RETURN_NULL(); ZERO_tmtc(&tmtc); @@ -2789,7 +2799,7 @@ timestamptz_to_char(PG_FUNCTION_ARGS) if (r != 0) elog(ERROR, "to_char(): Unable to convert timestamp to tm"); - if (!(res=datetime_to_char_body(&tmtc, fmt))) + if (!(res = datetime_to_char_body(&tmtc, fmt))) PG_RETURN_NULL(); PG_RETURN_TEXT_P(res); @@ -2803,9 +2813,10 @@ timestamptz_to_char(PG_FUNCTION_ARGS) Datum interval_to_char(PG_FUNCTION_ARGS) { - Interval *it = PG_GETARG_INTERVAL_P(0); - text *fmt = PG_GETARG_TEXT_P(1), *res; - TmToChar tmtc; + Interval *it = PG_GETARG_INTERVAL_P(0); + text *fmt = PG_GETARG_TEXT_P(1), + *res; + TmToChar tmtc; if ((VARSIZE(fmt) - VARHDRSZ) <= 0) PG_RETURN_NULL(); @@ -2815,7 +2826,7 @@ interval_to_char(PG_FUNCTION_ARGS) if (interval2tm(*it, tmtcTm(&tmtc), &tmtcFsec(&tmtc)) != 0) PG_RETURN_NULL(); - if (!(res=datetime_to_char_body(&tmtc, fmt))) + if (!(res = datetime_to_char_body(&tmtc, fmt))) PG_RETURN_NULL(); PG_RETURN_TEXT_P(res); @@ -2831,19 +2842,21 @@ interval_to_char(PG_FUNCTION_ARGS) Datum to_timestamp(PG_FUNCTION_ARGS) { - text *date_txt = PG_GETARG_TEXT_P(0); - text *fmt = PG_GETARG_TEXT_P(1); - - Timestamp result; + text *date_txt = PG_GETARG_TEXT_P(0); + text *fmt = PG_GETARG_TEXT_P(1); + + Timestamp result; FormatNode *format; - TmFromChar tmfc; - - bool incache; - char *str; - char *date_str; - int len, date_len, tz = 0; - struct tm tm; - double fsec = 0; + TmFromChar tmfc; + + bool incache; + char *str; + char *date_str; + int len, + date_len, + tz = 0; + struct tm tm; + double fsec = 0; ZERO_tm(&tm); ZERO_tmfc(&tmfc); @@ -2858,7 +2871,7 @@ to_timestamp(PG_FUNCTION_ARGS) /* * Allocate new memory if format picture is bigger than static - * cache and not use cache (call parser always) - incache=FALSE + * cache and not use cache (call parser always) - incache=FALSE * show this variant */ if (len > DCH_CACHE_SIZE) @@ -2873,11 +2886,11 @@ to_timestamp(PG_FUNCTION_ARGS) } else { - /* * Use cache buffers */ DCHCacheEntry *ent; + incache = 0; if ((ent = DCH_cache_search(str)) == NULL) @@ -2924,7 +2937,7 @@ to_timestamp(PG_FUNCTION_ARGS) pfree(format); } - DEBUG_TMFC(&tmfc); + DEBUG_TMFC(&tmfc); /* * Convert values that user define for FROM_CHAR @@ -2932,7 +2945,7 @@ to_timestamp(PG_FUNCTION_ARGS) */ if (tmfc.ssss) { - int x = tmfc.ssss; + int x = tmfc.ssss; tm.tm_hour = x / 3600; x %= 3600; @@ -2994,7 +3007,6 @@ to_timestamp(PG_FUNCTION_ARGS) else if (tmfc.y) { - /* * 1-digit year: always +2000 */ @@ -3096,7 +3108,7 @@ to_timestamp(PG_FUNCTION_ARGS) DEBUG_TM(&tm); tz = DetermineLocalTimeZone(&tm); - + if (tm2timestamp(&tm, fsec, &tz, &result) != 0) elog(ERROR, "to_timestamp(): can't convert 'tm' to timestamp."); @@ -3111,7 +3123,6 @@ to_timestamp(PG_FUNCTION_ARGS) Datum to_date(PG_FUNCTION_ARGS) { - /* * Quick hack: since our inputs are just like to_timestamp, hand over * the whole input info struct... @@ -3173,7 +3184,6 @@ NUM_cache_getnew(char *str) for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++) { - /* * entry removed via NUM_cache_remove() can be used here */ @@ -3291,7 +3301,6 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag) } else { - /* * Use cache buffers */ @@ -3453,7 +3462,6 @@ NUM_prepare_locale(NUMProc *Np) } else { - #endif /* @@ -3678,7 +3686,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) #endif if (IS_LSIGN(Np->Num)) { - /* * Write locale SIGN */ @@ -3713,7 +3720,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) (Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0) + (IS_DECIMAL(Np->Num) ? 1 : 0))) { - /* * Write close BRACKET */ @@ -3734,7 +3740,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) if (Np->num_curr < Np->num_pre && (Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num))) { - /* * Write blank space */ @@ -3752,7 +3757,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) Np->num_curr < Np->num_pre && Np->Num->zero_start <= Np->num_curr) { - /* * Write ZERO */ @@ -3766,7 +3770,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) } else { - /* * Write Decinal point */ @@ -3796,7 +3799,6 @@ NUM_numpart_to_char(NUMProc *Np, int id) } else { - /* * Write Digits */ @@ -3946,7 +3948,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, if (!Np->sign_wrote) { - /* * Set SING position */ @@ -4029,7 +4030,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, if (Np->type == FROM_CHAR) { - /* * Check non-string inout end */ @@ -4042,7 +4042,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, */ if (n->type == NODE_TYPE_ACTION) { - /* * Create/reading digit/zero/blank/sing */ @@ -4143,7 +4142,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, else Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) - 1; break; - + case NUM_rn: if (IS_FILLMODE(Np->Num)) { @@ -4228,7 +4227,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, } else { - /* * Remove to output char from input in TO_CHAR */ diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 4590500eca..28a04d0725 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.59 2001/10/13 17:40:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.60 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -484,11 +484,11 @@ box_ov(BOX *box1, BOX *box2) FPle(box1->low.x, box2->high.x)) || (FPge(box2->high.x, box1->high.x) && FPle(box2->low.x, box1->high.x))) - && - ((FPge(box1->high.y, box2->high.y) && - FPle(box1->low.y, box2->high.y)) || - (FPge(box2->high.y, box1->high.y) && - FPle(box2->low.y, box1->high.y))); + && + ((FPge(box1->high.y, box2->high.y) && + FPle(box1->low.y, box2->high.y)) || + (FPge(box2->high.y, box1->high.y) && + FPle(box2->low.y, box1->high.y))); } /* box_overleft - is the right edge of box1 to the left of @@ -811,7 +811,6 @@ line_in(PG_FUNCTION_ARGS) { #ifdef ENABLE_LINE_TYPE char *str = PG_GETARG_CSTRING(0); - #endif LINE *line; @@ -840,7 +839,6 @@ line_out(PG_FUNCTION_ARGS) { #ifdef ENABLE_LINE_TYPE LINE *line = PG_GETARG_LINE_P(0); - #endif char *result; @@ -1403,28 +1401,28 @@ path_inter(PG_FUNCTION_ARGS) /* pairwise check lseg intersections */ for (i = 0; i < p1->npts; i++) { - int iprev; + int iprev; if (i > 0) - iprev = i-1; + iprev = i - 1; else { if (!p1->closed) continue; - iprev = p1->npts-1; /* include the closure segment */ + iprev = p1->npts - 1; /* include the closure segment */ } for (j = 0; j < p2->npts; j++) { - int jprev; + int jprev; if (j > 0) - jprev = j-1; + jprev = j - 1; else { if (!p2->closed) continue; - jprev = p2->npts-1; /* include the closure segment */ + jprev = p2->npts - 1; /* include the closure segment */ } statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]); @@ -1457,28 +1455,28 @@ path_distance(PG_FUNCTION_ARGS) for (i = 0; i < p1->npts; i++) { - int iprev; + int iprev; if (i > 0) - iprev = i-1; + iprev = i - 1; else { if (!p1->closed) continue; - iprev = p1->npts-1; /* include the closure segment */ + iprev = p1->npts - 1; /* include the closure segment */ } for (j = 0; j < p2->npts; j++) { - int jprev; + int jprev; if (j > 0) - jprev = j-1; + jprev = j - 1; else { if (!p2->closed) continue; - jprev = p2->npts-1; /* include the closure segment */ + jprev = p2->npts - 1; /* include the closure segment */ } statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]); @@ -1515,15 +1513,15 @@ path_length(PG_FUNCTION_ARGS) for (i = 0; i < path->npts; i++) { - int iprev; + int iprev; if (i > 0) - iprev = i-1; + iprev = i - 1; else { if (!path->closed) continue; - iprev = path->npts-1; /* include the closure segment */ + iprev = path->npts - 1; /* include the closure segment */ } result += point_dt(&path->p[iprev], &path->p[i]); @@ -2114,7 +2112,7 @@ static double dist_pl_internal(Point *pt, LINE *line) { return (line->A * pt->x + line->B * pt->y + line->C) / - HYPOT(line->A, line->B); + HYPOT(line->A, line->B); } Datum @@ -2216,15 +2214,16 @@ dist_ppath(PG_FUNCTION_ARGS) */ for (i = 0; i < path->npts; i++) { - int iprev; + int iprev; if (i > 0) - iprev = i-1; + iprev = i - 1; else { if (!path->closed) continue; - iprev = path->npts-1; /* include the closure segment */ + iprev = path->npts - 1; /* include the closure + * segment */ } statlseg_construct(&lseg, &path->p[iprev], &path->p[i]); @@ -2307,7 +2306,6 @@ dist_lb(PG_FUNCTION_ARGS) #ifdef NOT_USED LINE *line = PG_GETARG_LINE_P(0); BOX *box = PG_GETARG_BOX_P(1); - #endif /* think about this one for a while */ @@ -2830,7 +2828,6 @@ close_lb(PG_FUNCTION_ARGS) #ifdef NOT_USED LINE *line = PG_GETARG_LINE_P(0); BOX *box = PG_GETARG_BOX_P(1); - #endif /* think about this one for a while */ @@ -3430,7 +3427,6 @@ poly_distance(PG_FUNCTION_ARGS) #ifdef NOT_USED POLYGON *polya = PG_GETARG_POLYGON_P(0); POLYGON *polyb = PG_GETARG_POLYGON_P(1); - #endif elog(ERROR, "poly_distance not implemented"); @@ -3737,7 +3733,6 @@ path_center(PG_FUNCTION_ARGS) { #ifdef NOT_USED PATH *path = PG_GETARG_PATH_P(0); - #endif elog(ERROR, "path_center not implemented"); diff --git a/src/backend/utils/adt/inet_net_ntop.c b/src/backend/utils/adt/inet_net_ntop.c index 7332930095..c0d782ec08 100644 --- a/src/backend/utils/adt/inet_net_ntop.c +++ b/src/backend/utils/adt/inet_net_ntop.c @@ -16,8 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.10 2001/03/22 03:59:51 momjian Exp $"; - +static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.11 2001/10/25 05:49:44 momjian Exp $"; #endif #include <sys/types.h> @@ -56,7 +55,7 @@ inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return (inet_cidr_ntop_ipv4(src, bits, dst, size)); default: errno = EAFNOSUPPORT; @@ -157,7 +156,7 @@ inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return (inet_net_ntop_ipv4(src, bits, dst, size)); default: errno = EAFNOSUPPORT; diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c index 3784bf04be..785d333f9d 100644 --- a/src/backend/utils/adt/inet_net_pton.c +++ b/src/backend/utils/adt/inet_net_pton.c @@ -16,8 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_pton.c,v 1.12 2000/12/03 20:45:36 tgl Exp $"; - +static const char rcsid[] = "$Id: inet_net_pton.c,v 1.13 2001/10/25 05:49:44 momjian Exp $"; #endif #include <sys/types.h> @@ -64,10 +63,10 @@ inet_net_pton(int af, const char *src, void *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return size == -1 ? - inet_net_pton_ipv4(src, dst) : - inet_cidr_pton_ipv4(src, dst, size); + inet_net_pton_ipv4(src, dst) : + inet_cidr_pton_ipv4(src, dst, size); default: errno = EAFNOSUPPORT; return (-1); diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 8d8f9ed642..41a6061588 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.33 2001/09/07 01:33:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.34 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ int8in(PG_FUNCTION_ARGS) * Do our own scan, rather than relying on sscanf which might be * broken for long long. */ - while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */ + while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */ ptr++; if (*ptr == '-') /* handle sign */ sign = -1, ptr++; diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index f3f8b9854e..2969f15891 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.47 2001/10/04 02:15:47 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.48 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,14 +35,14 @@ static int MatchText(unsigned char *t, int tlen, static int MatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen); static int MatchBytea(unsigned char *t, int tlen, - unsigned char *p, int plen); + unsigned char *p, int plen); static text *do_like_escape(text *, text *); #ifdef MULTIBYTE static int MBMatchText(unsigned char *t, int tlen, - unsigned char *p, int plen); -static int MBMatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen); +static int MBMatchTextIC(unsigned char *t, int tlen, + unsigned char *p, int plen); static text *MB_do_like_escape(text *, text *); /*-------------------- @@ -107,7 +107,6 @@ iwchareq(unsigned char *p1, unsigned char *p2) c2[0] = tolower(c2[0]); return (c1[0] == c2[0]); } - #endif #ifdef MULTIBYTE @@ -123,7 +122,7 @@ iwchareq(unsigned char *p1, unsigned char *p2) } while (0) #define MatchText MBMatchText -#define MatchTextIC MBMatchTextIC +#define MatchTextIC MBMatchTextIC #define do_like_escape MB_do_like_escape #include "like_match.c" #undef CHAREQ @@ -167,11 +166,11 @@ namelike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MatchText(s, slen, p, plen) == LIKE_TRUE); else - result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE); #else - result = (MatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MatchText(s, slen, p, plen) == LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -195,11 +194,11 @@ namenlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MatchText(s, slen, p, plen) != LIKE_TRUE); else - result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE); #else - result = (MatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MatchText(s, slen, p, plen) != LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -215,6 +214,7 @@ textlike(PG_FUNCTION_ARGS) *p; int slen, plen; + s = VARDATA(str); slen = (VARSIZE(str) - VARHDRSZ); p = VARDATA(pat); @@ -222,11 +222,11 @@ textlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MatchText(s, slen, p, plen) == LIKE_TRUE); else - result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE); #else - result = (MatchText(s, slen, p, plen) == LIKE_TRUE); + result = (MatchText(s, slen, p, plen) == LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -250,11 +250,11 @@ textnlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MatchText(s, slen, p, plen) != LIKE_TRUE); else - result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE); #else - result = (MatchText(s, slen, p, plen) != LIKE_TRUE); + result = (MatchText(s, slen, p, plen) != LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -324,11 +324,11 @@ nameiclike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); else - result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE); #else - result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -352,11 +352,11 @@ nameicnlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); else - result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE); #else - result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -380,11 +380,11 @@ texticlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); else - result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE); #else - result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -408,11 +408,11 @@ texticnlike(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); else - result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE); #else - result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); + result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE); #endif PG_RETURN_BOOL(result); @@ -431,9 +431,9 @@ like_escape(PG_FUNCTION_ARGS) #ifdef MULTIBYTE if (pg_database_encoding_max_length() == 1) - result = do_like_escape(pat, esc); + result = do_like_escape(pat, esc); else - result = MB_do_like_escape(pat, esc); + result = MB_do_like_escape(pat, esc); #else result = do_like_escape(pat, esc); #endif @@ -472,7 +472,6 @@ like_escape_bytea(PG_FUNCTION_ARGS) if (elen == 0) { - /* * No escape character is wanted. Double any backslashes in the * pattern to make them act like ordinary characters. @@ -486,7 +485,6 @@ like_escape_bytea(PG_FUNCTION_ARGS) } else { - /* * The specified escape must be only a single character. */ @@ -574,7 +572,6 @@ MatchBytea(unsigned char *t, int tlen, unsigned char *p, int plen) */ while (tlen > 0) { - /* * Optimization to prevent most recursion: don't recurse * unless first pattern char might match this text char. @@ -598,7 +595,6 @@ MatchBytea(unsigned char *t, int tlen, unsigned char *p, int plen) } else if ((*p != '_') && !BYTEA_CHAREQ(t, p)) { - /* * Not the single-character wildcard and no explicit match? * Then time to quit... diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index f13b8fea05..f92d424d3e 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -18,7 +18,7 @@ * Copyright (c) 1996-2001, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.1 2001/10/04 02:15:47 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.2 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -101,7 +101,6 @@ MatchText(unsigned char *t, int tlen, unsigned char *p, int plen) */ while (tlen > 0) { - /* * Optimization to prevent most recursion: don't recurse * unless first pattern char might match this text char. @@ -125,7 +124,6 @@ MatchText(unsigned char *t, int tlen, unsigned char *p, int plen) } else if ((*p != '_') && !CHAREQ(t, p)) { - /* * Not the single-character wildcard and no explicit match? * Then time to quit... @@ -189,7 +187,6 @@ MatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen) */ while (tlen > 0) { - /* * Optimization to prevent most recursion: don't recurse * unless first pattern char might match this text char. @@ -213,7 +210,6 @@ MatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen) } else if ((*p != '_') && !ICHAREQ(t, p)) { - /* * Not the single-character wildcard and no explicit match? * Then time to quit... @@ -271,7 +267,6 @@ do_like_escape(text *pat, text *esc) if (elen == 0) { - /* * No escape character is wanted. Double any backslashes in the * pattern to make them act like ordinary characters. @@ -285,7 +280,6 @@ do_like_escape(text *pat, text *esc) } else { - /* * The specified escape must be only a single character. */ diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index af08bda878..5bdd5475c3 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.22 2001/03/22 03:59:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.23 2001/10/25 05:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,6 @@ oidrand(PG_FUNCTION_ARGS) { #ifdef NOT_USED Oid o = PG_GETARG_OID(0); - #endif int32 X = PG_GETARG_INT32(1); bool result; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 29608aa78d..3bbf5ec7c8 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.90 2001/10/20 01:02:18 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.91 2001/10/25 05:49:44 momjian Exp $ * * NOTES * @@ -90,7 +90,6 @@ static int sec_tab[] = { 1, 1, 60, 60, 3600, 3600, 86400, 86400, 604800, 604800, 2592000, 2592000, 31536000, 31536000}; - #endif /* @@ -103,7 +102,6 @@ static void reltime2tm(RelativeTime time, struct tm * tm); #ifdef NOT_USED static int correct_unit(char *unit, int *unptr); static int correct_dir(char *direction, int *signptr); - #endif static int istinterval(char *i_string, @@ -188,13 +186,15 @@ GetCurrentAbsoluteTime(void) AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec) { - time_t now; + time_t now; struct timeval tp; + #ifdef NOT_USED struct timezone tpz; #endif #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) struct tm *tm; + #else struct timeb tb; /* the old V7-ism */ #endif @@ -271,7 +271,7 @@ GetCurrentTime(struct tm * tm) void -GetCurrentTimeUsec(struct tm *tm, double *fsec) +GetCurrentTimeUsec(struct tm * tm, double *fsec) { int tz; int usec; @@ -297,15 +297,16 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) ftime(&tb); #endif - /* If HasCTZSet is true then we have a brute force time zone specified. - * Go ahead and rotate to the local time zone since we will later bypass - * any calls which adjust the tm fields. + /* + * If HasCTZSet is true then we have a brute force time zone + * specified. Go ahead and rotate to the local time zone since we will + * later bypass any calls which adjust the tm fields. */ if (HasCTZSet && (tzp != NULL)) time -= CTimeZone; #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) - if ((! HasCTZSet) && (tzp != NULL)) + if ((!HasCTZSet) && (tzp != NULL)) { tx = localtime((time_t *) &time); #ifdef NO_MKTIME_BEFORE_1970 @@ -336,9 +337,9 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) if (tzp != NULL) { - /* We have a brute force time zone per SQL99? - * Then use it without change - * since we have already rotated to the time zone. + /* + * We have a brute force time zone per SQL99? Then use it without + * change since we have already rotated to the time zone. */ if (HasCTZSet) { @@ -351,14 +352,18 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) } else { - *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ + *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ - /* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */ + /* + * XXX FreeBSD man pages indicate that this should work - tgl + * 97/04/23 + */ if (tzn != NULL) { /* - * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it - * contains an error message, which doesn't fit in the buffer + * Copy no more than MAXTZLEN bytes of timezone to tzn, in + * case it contains an error message, which doesn't fit in + * the buffer */ StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1); if (strlen(tm->tm_zone) > MAXTZLEN) @@ -367,15 +372,13 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) } } else - { tm->tm_isdst = -1; - } #elif defined(HAVE_INT_TIMEZONE) if (tzp != NULL) { - /* We have a brute force time zone per SQL99? - * Then use it without change - * since we have already rotated to the time zone. + /* + * We have a brute force time zone per SQL99? Then use it without + * change since we have already rotated to the time zone. */ if (HasCTZSet) { @@ -390,10 +393,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) if (tzn != NULL) { - /* - * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it - * contains an error message, which doesn't fit in the buffer + * Copy no more than MAXTZLEN bytes of timezone to tzn, in + * case it contains an error message, which doesn't fit in + * the buffer */ StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1); if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN) @@ -402,16 +405,14 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) } } else - { tm->tm_isdst = -1; - } #endif #else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */ if (tzp != NULL) { - /* We have a brute force time zone per SQL99? - * Then use it without change - * since we have already rotated to the time zone. + /* + * We have a brute force time zone per SQL99? Then use it without + * change since we have already rotated to the time zone. */ if (HasCTZSet) { @@ -424,20 +425,19 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) *tzp = tb.timezone * 60; /* - * XXX does this work to get the local timezone string in V7? - tgl - * 97/03/18 + * XXX does this work to get the local timezone string in V7? + * - tgl 97/03/18 */ if (tzn != NULL) { strftime(*tzn, MAXTZLEN, "%Z", localtime(&now)); - tzn[MAXTZLEN] = '\0'; /* let's just be sure it's null-terminated */ + tzn[MAXTZLEN] = '\0'; /* let's just be sure it's + * null-terminated */ } } } else - { tm->tm_isdst = -1; - } #endif return; @@ -517,8 +517,11 @@ nabstimein(PG_FUNCTION_ARGS) break; case DTK_EPOCH: - /* Don't bother retaining this as a reserved value, - * but instead just set to the actual epoch time (1970-01-01) */ + + /* + * Don't bother retaining this as a reserved value, but + * instead just set to the actual epoch time (1970-01-01) + */ result = 0; break; @@ -562,9 +565,10 @@ nabstimeout(PG_FUNCTION_ARGS) switch (time) { - /* Note that timestamp no longer supports 'invalid'. - * Retain 'invalid' for abstime for now, but dump it someday. - */ + /* + * Note that timestamp no longer supports 'invalid'. Retain + * 'invalid' for abstime for now, but dump it someday. + */ case INVALID_ABSTIME: strcpy(buf, INVALID); break; @@ -611,14 +615,14 @@ abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b) */ if (a == INVALID_ABSTIME) { - if (b == INVALID_ABSTIME) - return 0; /* INVALID = INVALID */ - else - return 1; /* INVALID > non-INVALID */ + if (b == INVALID_ABSTIME) + return 0; /* INVALID = INVALID */ + else + return 1; /* INVALID > non-INVALID */ } if (b == INVALID_ABSTIME) - return -1; /* non-INVALID < INVALID */ + return -1; /* non-INVALID < INVALID */ #if 0 /* CURRENT is no longer stored internally... */ @@ -777,7 +781,7 @@ abstime_timestamp(PG_FUNCTION_ARGS) Datum timestamptz_abstime(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); AbsoluteTime result; double fsec; struct tm tt, @@ -805,7 +809,7 @@ Datum abstime_timestamptz(PG_FUNCTION_ARGS) { AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0); - TimestampTz result; + TimestampTz result; switch (abstime) { @@ -928,7 +932,7 @@ tintervalin(PG_FUNCTION_ARGS) elog(ERROR, "Unable to decode tinterval '%s'", intervalstr); if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME) - interval->status = T_INTERVAL_INVAL; /* undefined */ + interval->status = T_INTERVAL_INVAL; /* undefined */ else interval->status = T_INTERVAL_VALID; @@ -1273,11 +1277,11 @@ tintervalsame(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); if (DatumGetBool(DirectFunctionCall2(abstimeeq, - AbsoluteTimeGetDatum(i1->data[0]), - AbsoluteTimeGetDatum(i2->data[0]))) && + AbsoluteTimeGetDatum(i1->data[0]), + AbsoluteTimeGetDatum(i2->data[0]))) && DatumGetBool(DirectFunctionCall2(abstimeeq, - AbsoluteTimeGetDatum(i1->data[1]), - AbsoluteTimeGetDatum(i2->data[1])))) + AbsoluteTimeGetDatum(i1->data[1]), + AbsoluteTimeGetDatum(i2->data[1])))) PG_RETURN_BOOL(true); PG_RETURN_BOOL(false); } @@ -1293,9 +1297,9 @@ tintervaleq(PG_FUNCTION_ARGS) TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0); TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1); AbsoluteTime t10, - t11, - t20, - t21; + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); @@ -1318,9 +1322,9 @@ tintervalne(PG_FUNCTION_ARGS) TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0); TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1); AbsoluteTime t10, - t11, - t20, - t21; + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); @@ -1343,9 +1347,9 @@ tintervallt(PG_FUNCTION_ARGS) TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0); TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1); AbsoluteTime t10, - t11, - t20, - t21; + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); @@ -1368,9 +1372,9 @@ tintervalle(PG_FUNCTION_ARGS) TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0); TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1); AbsoluteTime t10, - t11, - t20, - t21; + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); @@ -1462,7 +1466,7 @@ tintervalleneq(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL((rt != INVALID_RELTIME) && (rt == t)); } @@ -1569,11 +1573,11 @@ tintervalov(PG_FUNCTION_ARGS) if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); if (DatumGetBool(DirectFunctionCall2(abstimelt, - AbsoluteTimeGetDatum(i1->data[1]), - AbsoluteTimeGetDatum(i2->data[0]))) || + AbsoluteTimeGetDatum(i1->data[1]), + AbsoluteTimeGetDatum(i2->data[0]))) || DatumGetBool(DirectFunctionCall2(abstimegt, - AbsoluteTimeGetDatum(i1->data[0]), - AbsoluteTimeGetDatum(i2->data[1])))) + AbsoluteTimeGetDatum(i1->data[0]), + AbsoluteTimeGetDatum(i2->data[1])))) PG_RETURN_BOOL(false); PG_RETURN_BOOL(true); } diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index 532a9d863a..cc3c8a791f 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.31 2001/01/24 19:43:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.32 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -155,7 +155,6 @@ namecat(Name n1, Name n2) return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer * than n1 */ } - #endif #ifdef NOT_USED @@ -164,7 +163,6 @@ namecmp(Name n1, Name n2) { return strncmp(NameStr(*n1), NameStr(*n2), NAMEDATALEN); } - #endif int @@ -196,7 +194,6 @@ namestrcat(Name name, const char *str) } return 0; } - #endif int @@ -243,5 +240,4 @@ NameComputeLength(Name name) ; return (uint32) length; } - #endif diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 674ed49630..4004492174 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.33 2001/08/27 20:03:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.34 2001/10/25 05:49:45 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -153,44 +153,43 @@ cidr_out(PG_FUNCTION_ARGS) static Datum text_network(text *src, int type) { - int len = VARSIZE(src) - VARHDRSZ; + int len = VARSIZE(src) - VARHDRSZ; - char *str = palloc(len + 1); - memcpy(str, VARDATA(src), len); - *(str + len) = '\0'; + char *str = palloc(len + 1); - PG_RETURN_INET_P(network_in( str, type)); + memcpy(str, VARDATA(src), len); + *(str + len) = '\0'; + + PG_RETURN_INET_P(network_in(str, type)); } Datum text_cidr(PG_FUNCTION_ARGS) { - return text_network( PG_GETARG_TEXT_P(0), 1); + return text_network(PG_GETARG_TEXT_P(0), 1); } Datum text_inet(PG_FUNCTION_ARGS) { - return text_network( PG_GETARG_TEXT_P(0), 0); + return text_network(PG_GETARG_TEXT_P(0), 0); } Datum inet_set_masklen(PG_FUNCTION_ARGS) { - inet *src = PG_GETARG_INET_P(0); - int bits = PG_GETARG_INT32(1); - inet *dst; + inet *src = PG_GETARG_INET_P(0); + int bits = PG_GETARG_INT32(1); + inet *dst; - if ((bits < 0) || (bits > 32)) /* no support for v6 yet */ - { - elog(ERROR, "set_masklen - invalid value '%d'", bits); - } + if ((bits < 0) || (bits > 32)) /* no support for v6 yet */ + elog(ERROR, "set_masklen - invalid value '%d'", bits); /* clone the original data */ - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); memcpy(dst, src, VARHDRSZ + sizeof(inet_struct)); - ip_bits(dst) = bits; + ip_bits(dst) = bits; PG_RETURN_INET_P(dst); } @@ -618,7 +617,7 @@ network_netmask(PG_FUNCTION_ARGS) * involving network types. * * Currently, inet/cidr values are simply converted to the IPv4 address; - * this will need more thought when IPv6 is supported too. MAC addresses + * this will need more thought when IPv6 is supported too. MAC addresses * are converted to their numeric equivalent as well (OK since we have a * double to play in). */ @@ -629,26 +628,26 @@ convert_network_to_scalar(Datum value, Oid typid) { case INETOID: case CIDROID: - { - inet *ip = DatumGetInetP(value); - - if (ip_family(ip) == AF_INET) - return (double) ip_v4addr(ip); - else - /* Go for an IPV6 address here, before faulting out: */ - elog(ERROR, "unknown address family (%d)", ip_family(ip)); - break; - } + { + inet *ip = DatumGetInetP(value); + + if (ip_family(ip) == AF_INET) + return (double) ip_v4addr(ip); + else + /* Go for an IPV6 address here, before faulting out: */ + elog(ERROR, "unknown address family (%d)", ip_family(ip)); + break; + } case MACADDROID: - { - macaddr *mac = DatumGetMacaddrP(value); - double res; - - res = (mac->a << 16) | (mac->b << 8) | (mac->c); - res *= 256*256*256; - res += (mac->d << 16) | (mac->e << 8) | (mac->f); - return res; - } + { + macaddr *mac = DatumGetMacaddrP(value); + double res; + + res = (mac->a << 16) | (mac->b << 8) | (mac->c); + res *= 256 * 256 * 256; + res += (mac->d << 16) | (mac->e << 8) | (mac->f); + return res; + } } /* @@ -722,7 +721,7 @@ network_scan_first(Datum in) } /* - * return "last" IP on a given network. It's the broadcast address, + * return "last" IP on a given network. It's the broadcast address, * however, masklen has to be set to 32, since * 192.168.0.255/24 is considered less than 192.168.0.255/32 * diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c index ac596b1f12..8c3ca1b73b 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.26 2001/03/22 03:59:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.27 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -113,7 +113,6 @@ oidnotin(PG_FUNCTION_ARGS) #ifdef NOT_USED text *relation_and_attr = PG_GETARG_TEXT_P(1); - #endif if (the_oid == InvalidOid) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 5160f690c1..4e7398448b 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.45 2001/10/13 23:32:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.46 2001/10/25 05:49:45 momjian Exp $ * * ---------- */ @@ -193,6 +193,7 @@ Datum numeric_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -440,7 +441,6 @@ numeric_sign(PG_FUNCTION_ARGS) set_var_from_var(&const_zero, &result); else { - /* * And if there are some, we return a copy of ONE with the sign of * our argument @@ -496,7 +496,6 @@ numeric_round(PG_FUNCTION_ARGS) if (i < arg.ndigits) { - /* * If i = 0, the value loses all digits, but could round up if its * first digit is more than 4. If i < 0 the result must be 0. @@ -518,7 +517,7 @@ numeric_round(PG_FUNCTION_ARGS) if (i < 0) { - Assert(i == -1);/* better not have added more than 1 digit */ + Assert(i == -1); /* better not have added more than 1 digit */ Assert(arg.digits > arg.buf); arg.digits--; arg.ndigits++; @@ -781,9 +780,9 @@ cmp_numerics(Numeric num1, Numeric num2) int result; /* - * We consider all NANs to be equal and larger than any non-NAN. - * This is somewhat arbitrary; the important thing is to have a - * consistent sort order. + * We consider all NANs to be equal and larger than any non-NAN. This + * is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ if (NUMERIC_IS_NAN(num1)) { @@ -1799,9 +1798,9 @@ numeric_accum(PG_FUNCTION_ARGS) /* * Integer data types all use Numeric accumulators to share code and - * avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation + * avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation * is overkill for the N and sum(X) values, but definitely not overkill - * for the sum(X*X) value. Hence, we use int2_accum and int4_accum only + * for the sum(X*X) value. Hence, we use int2_accum and int4_accum only * for stddev/variance --- there are faster special-purpose accumulator * routines for SUM and AVG of these datatypes. */ @@ -2020,7 +2019,7 @@ numeric_stddev(PG_FUNCTION_ARGS) * the initial condition of the transition data value needs to be NULL. This * means we can't rely on ExecAgg to automatically insert the first non-null * data value into the transition data: it doesn't know how to do the type - * conversion. The upshot is that these routines have to be marked non-strict + * conversion. The upshot is that these routines have to be marked non-strict * and handle substitution of the first non-null input themselves. */ @@ -2269,7 +2268,6 @@ dump_var(char *str, NumericVar *var) printf("\n"); } - #endif /* NUMERIC_DEBUG */ @@ -2795,7 +2793,6 @@ cmp_var(NumericVar *var1, NumericVar *var2) static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) { - /* * Decide on the signs of the two variables what to do */ @@ -2803,7 +2800,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) { if (var2->sign == NUMERIC_POS) { - /* * Both are positive result = +(ABS(var1) + ABS(var2)) */ @@ -2812,7 +2808,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) } else { - /* * var1 is positive, var2 is negative Must compare absolute * values @@ -2919,7 +2914,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result) { - /* * Decide on the signs of the two variables what to do */ diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 92af2ab56c..bb7f894441 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.45 2001/03/22 03:59:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.46 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -345,7 +345,6 @@ frac_out: return avail; #endif } - #endif /* @@ -476,5 +475,4 @@ atof1(char *str, double *val) *val = v; return 0; } - #endif diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 698c309f9d..46a029caae 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.35 2001/09/23 11:02:01 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.36 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -171,8 +171,9 @@ lpad(PG_FUNCTION_ARGS) int m, s1len, s2len; + #ifdef MULTIBYTE - int bytelen; + int bytelen; #endif /* Negative len is silently taken as zero */ @@ -188,7 +189,7 @@ lpad(PG_FUNCTION_ARGS) s2len = 0; /* shouldn't happen */ #ifdef MULTIBYTE - s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len); + s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len); #endif if (s1len > len) s1len = len; /* truncate string1 to len chars */ @@ -213,12 +214,13 @@ lpad(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (m--) { - int mlen = pg_mblen(ptr2); - memcpy(ptr_ret, ptr2, mlen); - ptr_ret += mlen; - ptr2 += mlen; - if (ptr2 == ptr2end) /* wrap around at end of s2 */ - ptr2 = VARDATA(string2); + int mlen = pg_mblen(ptr2); + + memcpy(ptr_ret, ptr2, mlen); + ptr_ret += mlen; + ptr2 += mlen; + if (ptr2 == ptr2end) /* wrap around at end of s2 */ + ptr2 = VARDATA(string2); } #else while (m--) @@ -234,10 +236,11 @@ lpad(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (s1len--) { - int mlen = pg_mblen(ptr1); - memcpy(ptr_ret, ptr1, mlen); - ptr_ret += mlen; - ptr1 += mlen; + int mlen = pg_mblen(ptr1); + + memcpy(ptr_ret, ptr1, mlen); + ptr_ret += mlen; + ptr1 += mlen; } #else while (s1len--) @@ -278,8 +281,9 @@ rpad(PG_FUNCTION_ARGS) int m, s1len, s2len; + #ifdef MULTIBYTE - int bytelen; + int bytelen; #endif /* Negative len is silently taken as zero */ @@ -295,7 +299,7 @@ rpad(PG_FUNCTION_ARGS) s2len = 0; /* shouldn't happen */ #ifdef MULTIBYTE - s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len); + s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len); #endif if (s1len > len) @@ -320,10 +324,11 @@ rpad(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (s1len--) { - int mlen = pg_mblen(ptr1); - memcpy(ptr_ret, ptr1, mlen); - ptr_ret += mlen; - ptr1 += mlen; + int mlen = pg_mblen(ptr1); + + memcpy(ptr_ret, ptr1, mlen); + ptr_ret += mlen; + ptr1 += mlen; } #else while (s1len--) @@ -336,12 +341,13 @@ rpad(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (m--) { - int mlen = pg_mblen(ptr2); - memcpy(ptr_ret, ptr2, mlen); - ptr_ret += mlen; - ptr2 += mlen; - if (ptr2 == ptr2end) /* wrap around at end of s2 */ - ptr2 = VARDATA(string2); + int mlen = pg_mblen(ptr2); + + memcpy(ptr_ret, ptr2, mlen); + ptr_ret += mlen; + ptr2 += mlen; + if (ptr2 == ptr2end) /* wrap around at end of s2 */ + ptr2 = VARDATA(string2); } #else while (m--) @@ -384,11 +390,11 @@ btrim(PG_FUNCTION_ARGS) int m; #ifdef MULTIBYTE - char **mp; - int mplen; - char *p; - int mblen; - int len; + char **mp; + int mplen; + char *p; + int mblen; + int len; #endif if ((m = VARSIZE(string) - VARHDRSZ) <= 0 || @@ -398,18 +404,18 @@ btrim(PG_FUNCTION_ARGS) ptr = VARDATA(string); #ifdef MULTIBYTE - len = m; - mp = (char **)palloc(len*sizeof(char *)); + len = m; + mp = (char **) palloc(len * sizeof(char *)); p = ptr; mplen = 0; /* build the mb pointer array */ while (len > 0) { - mp[mplen++] = p; - mblen = pg_mblen(p); - p += mblen; - len -= mblen; + mp[mplen++] = p; + mblen = pg_mblen(p); + p += mblen; + len -= mblen; } mplen--; #else @@ -420,16 +426,17 @@ btrim(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (m > 0) { - int str_len = pg_mblen(ptr); + int str_len = pg_mblen(ptr); + ptr2 = VARDATA(set); while (ptr2 <= end2) { - int set_len = pg_mblen(ptr2); + int set_len = pg_mblen(ptr2); - if (str_len == set_len && - memcmp(ptr,ptr2,str_len) == 0) + if (str_len == set_len && + memcmp(ptr, ptr2, str_len) == 0) break; - ptr2 += set_len; + ptr2 += set_len; } if (ptr2 > end2) break; @@ -439,18 +446,19 @@ btrim(PG_FUNCTION_ARGS) while (m > 0) { - int str_len; + int str_len; + end = mp[mplen--]; str_len = pg_mblen(end); ptr2 = VARDATA(set); while (ptr2 <= end2) { - int set_len = pg_mblen(ptr2); + int set_len = pg_mblen(ptr2); - if (str_len == set_len && - memcmp(end,ptr2,str_len) == 0) + if (str_len == set_len && + memcmp(end, ptr2, str_len) == 0) break; - ptr2 += set_len; + ptr2 += set_len; } if (ptr2 > end2) break; @@ -604,16 +612,17 @@ ltrim(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (m > 0) { - int str_len = pg_mblen(ptr); + int str_len = pg_mblen(ptr); + ptr2 = VARDATA(set); while (ptr2 <= end2) { - int set_len = pg_mblen(ptr2); + int set_len = pg_mblen(ptr2); - if (str_len == set_len && - memcmp(ptr,ptr2,str_len) == 0) + if (str_len == set_len && + memcmp(ptr, ptr2, str_len) == 0) break; - ptr2 += set_len; + ptr2 += set_len; } if (ptr2 > end2) break; @@ -673,11 +682,11 @@ rtrim(PG_FUNCTION_ARGS) int m; #ifdef MULTIBYTE - char **mp; - int mplen; - char *p; - int mblen; - int len; + char **mp; + int mplen; + char *p; + int mblen; + int len; #endif if ((m = VARSIZE(string) - VARHDRSZ) <= 0 || @@ -687,18 +696,18 @@ rtrim(PG_FUNCTION_ARGS) ptr = VARDATA(string); #ifdef MULTIBYTE - len = m; - mp = (char **)palloc(len*sizeof(char *)); + len = m; + mp = (char **) palloc(len * sizeof(char *)); p = ptr; mplen = 0; /* build the mb pointer array */ while (len > 0) { - mp[mplen++] = p; - mblen = pg_mblen(p); - p += mblen; - len -= mblen; + mp[mplen++] = p; + mblen = pg_mblen(p); + p += mblen; + len -= mblen; } mplen--; #else @@ -709,18 +718,19 @@ rtrim(PG_FUNCTION_ARGS) #ifdef MULTIBYTE while (m > 0) { - int str_len; + int str_len; + end = mp[mplen--]; str_len = pg_mblen(end); ptr2 = VARDATA(set); while (ptr2 <= end2) { - int set_len = pg_mblen(ptr2); + int set_len = pg_mblen(ptr2); - if (str_len == set_len && - memcmp(end,ptr2,str_len) == 0) + if (str_len == set_len && + memcmp(end, ptr2, str_len) == 0) break; - ptr2 += set_len; + ptr2 += set_len; } if (ptr2 > end2) break; @@ -784,12 +794,13 @@ translate(PG_FUNCTION_ARGS) tolen, retlen, i; + #ifdef MULTIBYTE - int str_len; - int estimate_len; - int len; - int source_len; - int from_index; + int str_len; + int estimate_len; + int len; + int source_len; + int from_index; #endif if ((m = VARSIZE(string) - VARHDRSZ) <= 0) @@ -802,8 +813,8 @@ translate(PG_FUNCTION_ARGS) #ifdef MULTIBYTE str_len = VARSIZE(string); - estimate_len = (tolen*1.0/fromlen + 0.5)*str_len; - estimate_len = estimate_len>str_len?estimate_len:str_len; + estimate_len = (tolen * 1.0 / fromlen + 0.5) * str_len; + estimate_len = estimate_len > str_len ? estimate_len : str_len; result = (text *) palloc(estimate_len); #else result = (text *) palloc(VARSIZE(string)); @@ -821,38 +832,39 @@ translate(PG_FUNCTION_ARGS) for (i = 0; i < fromlen; i += len) { - len = pg_mblen(&from_ptr[i]); - if (len == source_len && - memcmp(source, &from_ptr[i], len) == 0) - break; + len = pg_mblen(&from_ptr[i]); + if (len == source_len && + memcmp(source, &from_ptr[i], len) == 0) + break; - from_index++; + from_index++; } if (i < fromlen) { - /* substitute */ - char *p = to_ptr; - for (i=0;i<from_index;i++) - { - p += pg_mblen(p); - if (p >= (to_ptr + tolen)) - break; - } - if (p < (to_ptr + tolen)) - { - len = pg_mblen(p); - memcpy(target, p, len); - target += len; - retlen += len; - } + /* substitute */ + char *p = to_ptr; + + for (i = 0; i < from_index; i++) + { + p += pg_mblen(p); + if (p >= (to_ptr + tolen)) + break; + } + if (p < (to_ptr + tolen)) + { + len = pg_mblen(p); + memcpy(target, p, len); + target += len; + retlen += len; + } } else { /* no match, so copy */ - memcpy(target, source, source_len); - target += source_len; - retlen += source_len; + memcpy(target, source, source_len); + target += source_len; + retlen += source_len; } source += source_len; diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 513328d35c..17abbbd5a3 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -4,7 +4,7 @@ * The PostgreSQL locale utils. * * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.10 2001/09/29 21:16:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.11 2001/10/25 05:49:45 momjian Exp $ * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group * @@ -28,15 +28,15 @@ static bool CurrentLocaleConvValid = false; static struct lconv CurrentLocaleConv; -static void PGLC_setlocale(PG_LocaleCategories * lc); +static void PGLC_setlocale(PG_LocaleCategories *lc); /*------ - * Frees memory used in PG_LocaleCategories -- this memory is + * Frees memory used in PG_LocaleCategories -- this memory is * allocated in PGLC_current(). *------ */ void -PGLC_free_categories(PG_LocaleCategories * lc) +PGLC_free_categories(PG_LocaleCategories *lc) { if (lc->lc_ctype) pfree(lc->lc_ctype); @@ -47,7 +47,7 @@ PGLC_free_categories(PG_LocaleCategories * lc) if (lc->lc_collate) pfree(lc->lc_collate); if (lc->lc_monetary); - pfree(lc->lc_monetary); + pfree(lc->lc_monetary); #ifdef LC_MESSAGES if (lc->lc_messages) pfree(lc->lc_messages); @@ -61,17 +61,17 @@ PGLC_free_categories(PG_LocaleCategories * lc) *------ */ void -PGLC_current(PG_LocaleCategories * lc) +PGLC_current(PG_LocaleCategories *lc) { lc->lang = getenv("LANG"); - lc->lc_ctype = pstrdup( setlocale(LC_CTYPE, NULL) ); - lc->lc_numeric = pstrdup( setlocale(LC_NUMERIC, NULL) ); - lc->lc_time = pstrdup( setlocale(LC_TIME, NULL) ); - lc->lc_collate = pstrdup( setlocale(LC_COLLATE, NULL) ); - lc->lc_monetary = pstrdup( setlocale(LC_MONETARY, NULL) ); + lc->lc_ctype = pstrdup(setlocale(LC_CTYPE, NULL)); + lc->lc_numeric = pstrdup(setlocale(LC_NUMERIC, NULL)); + lc->lc_time = pstrdup(setlocale(LC_TIME, NULL)); + lc->lc_collate = pstrdup(setlocale(LC_COLLATE, NULL)); + lc->lc_monetary = pstrdup(setlocale(LC_MONETARY, NULL)); #ifdef LC_MESSAGES - lc->lc_messages = pstrdup( setlocale(LC_MESSAGES, NULL) ); + lc->lc_messages = pstrdup(setlocale(LC_MESSAGES, NULL)); #endif } @@ -83,7 +83,7 @@ PGLC_current(PG_LocaleCategories * lc) *------ */ static void -PGLC_debug_lc(PG_LocaleCategories * lc) +PGLC_debug_lc(PG_LocaleCategories *lc) { #ifdef LC_MESSAGES elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n", @@ -104,7 +104,6 @@ PGLC_debug_lc(PG_LocaleCategories * lc) lc->lc_monetary); #endif } - #endif /*------ @@ -117,7 +116,7 @@ PGLC_debug_lc(PG_LocaleCategories * lc) *------ */ static void -PGLC_setlocale(PG_LocaleCategories * lc) +PGLC_setlocale(PG_LocaleCategories *lc) { if (!setlocale(LC_COLLATE, lc->lc_collate)) elog(NOTICE, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.", @@ -172,7 +171,10 @@ PGLC_localeconv(void) /* Get formatting information for the external environment */ extlconv = localeconv(); - /* Must copy all values since restoring internal settings may overwrite */ + /* + * Must copy all values since restoring internal settings may + * overwrite + */ CurrentLocaleConv = *extlconv; CurrentLocaleConv.currency_symbol = strdup(extlconv->currency_symbol); CurrentLocaleConv.decimal_point = strdup(extlconv->decimal_point); @@ -194,5 +196,4 @@ PGLC_localeconv(void) CurrentLocaleConvValid = true; return &CurrentLocaleConv; } - #endif /* USE_LOCALE */ diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c index 5c6cc6e1e4..056ad98844 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.12 2001/10/25 01:29:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.13 2001/10/25 05:49:45 momjian Exp $ * * This is an implementation of LZ compression for PostgreSQL. * It uses a simple history table and generates 2-3 byte tags @@ -394,7 +394,6 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end, hent = hstart[pglz_hist_idx(input, end)]; while (hent && len < good_match) { - /* * Be happy with lesser good matches the more entries we visited. */ @@ -566,7 +565,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate */ while (dp < dend) { - /* * If we already exceeded the maximum result size, set no * compression flag and stop this. But don't check too often. @@ -583,7 +581,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate if (pglz_find_match(hist_start, dp, dend, &match_len, &match_off, good_match, good_drop)) { - /* * Create the tag and add history entries for all matched * characters. @@ -598,7 +595,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate } else { - /* * No match found. Copy one literal byte. */ @@ -671,7 +667,6 @@ pglz_decompress(PGLZ_Header *source, char *dest) while (dp < dend) { - /* * Read one control byte and process the next 8 items. */ @@ -680,7 +675,6 @@ pglz_decompress(PGLZ_Header *source, char *dest) { if (ctrl & 1) { - /* * Otherwise it contains the match length minus 3 and the * upper 4 bits of the offset. The next following byte @@ -708,7 +702,6 @@ pglz_decompress(PGLZ_Header *source, char *dest) } else { - /* * An unset control bit means LITERAL BYTE. So we just * copy one from INPUT to OUTPUT. @@ -744,7 +737,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) if (dstate->tocopy > 0) { - /* * Copy one byte from output to output until we did it for the * length specified by the last tag. Return that byte. @@ -755,7 +747,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) if (dstate->ctrl_count == 0) { - /* * Get the next control byte if we need to, but check for EOF * before. @@ -838,7 +829,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) dstate->ctrl_count--; if (dstate->ctrl & 0x01) { - /* * Bit is set, so tag is following. Setup copy information and do * the copy for the first byte as above. @@ -857,7 +847,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) } else { - /* * Bit is unset, so literal byte follows. */ diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 01cc5e45b3..b5f3744d51 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -9,41 +9,41 @@ #include "pgstat.h" -extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS); - -extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS); - -extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS); -extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS); + +extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS); + +extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS); Datum pg_stat_get_numscans(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->numscans); + result = (int64) (tabentry->numscans); PG_RETURN_INT64(result); } @@ -52,16 +52,16 @@ pg_stat_get_numscans(PG_FUNCTION_ARGS) Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->tuples_returned); + result = (int64) (tabentry->tuples_returned); PG_RETURN_INT64(result); } @@ -70,16 +70,16 @@ pg_stat_get_tuples_returned(PG_FUNCTION_ARGS) Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->tuples_fetched); + result = (int64) (tabentry->tuples_fetched); PG_RETURN_INT64(result); } @@ -88,16 +88,16 @@ pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS) Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->tuples_inserted); + result = (int64) (tabentry->tuples_inserted); PG_RETURN_INT64(result); } @@ -106,16 +106,16 @@ pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS) Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->tuples_updated); + result = (int64) (tabentry->tuples_updated); PG_RETURN_INT64(result); } @@ -124,16 +124,16 @@ pg_stat_get_tuples_updated(PG_FUNCTION_ARGS) Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->tuples_deleted); + result = (int64) (tabentry->tuples_deleted); PG_RETURN_INT64(result); } @@ -142,16 +142,16 @@ pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS) Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->blocks_fetched); + result = (int64) (tabentry->blocks_fetched); PG_RETURN_INT64(result); } @@ -160,16 +160,16 @@ pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS) Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS) { - PgStat_StatTabEntry *tabentry; - Oid relid; - int64 result; + PgStat_StatTabEntry *tabentry; + Oid relid; + int64 result; - relid = PG_GETARG_OID(0); + relid = PG_GETARG_OID(0); if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) result = 0; else - result = (int64)(tabentry->blocks_hit); + result = (int64) (tabentry->blocks_hit); PG_RETURN_INT64(result); } @@ -178,8 +178,8 @@ pg_stat_get_blocks_hit(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS) { - FmgrInfo *fmgr_info = fcinfo->flinfo; - int32 result; + FmgrInfo *fmgr_info = fcinfo->flinfo; + int32 result; if (fcinfo->resultinfo == NULL || !IsA(fcinfo->resultinfo, ReturnSetInfo)) @@ -191,22 +191,22 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS) elog(ERROR, "No function memory context in set-function"); fmgr_info->fn_extra = MemoryContextAlloc(fmgr_info->fn_mcxt, 2 * sizeof(int)); - ((int *)(fmgr_info->fn_extra))[0] = 0; - ((int *)(fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends(); + ((int *) (fmgr_info->fn_extra))[0] = 0; + ((int *) (fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends(); } - ((int *)(fmgr_info->fn_extra))[0] += 1; - result = ((int *)(fmgr_info->fn_extra))[0]; + ((int *) (fmgr_info->fn_extra))[0] += 1; + result = ((int *) (fmgr_info->fn_extra))[0]; - if (result > ((int *)(fmgr_info->fn_extra))[1]) + if (result > ((int *) (fmgr_info->fn_extra))[1]) { pfree(fmgr_info->fn_extra); fmgr_info->fn_extra = NULL; - ((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprEndResult; + ((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprEndResult; PG_RETURN_NULL(); } - ((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprMultipleResult; + ((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprMultipleResult; PG_RETURN_INT32(result); } @@ -214,10 +214,10 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS) { - PgStat_StatBeEntry *beentry; - int32 beid; + PgStat_StatBeEntry *beentry; + int32 beid; - beid = PG_GETARG_INT32(0); + beid = PG_GETARG_INT32(0); if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -229,10 +229,10 @@ pg_stat_get_backend_pid(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS) { - PgStat_StatBeEntry *beentry; - int32 beid; + PgStat_StatBeEntry *beentry; + int32 beid; - beid = PG_GETARG_INT32(0); + beid = PG_GETARG_INT32(0); if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -244,10 +244,10 @@ pg_stat_get_backend_dbid(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS) { - PgStat_StatBeEntry *beentry; - int32 beid; + PgStat_StatBeEntry *beentry; + int32 beid; - beid = PG_GETARG_INT32(0); + beid = PG_GETARG_INT32(0); if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -259,15 +259,15 @@ pg_stat_get_backend_userid(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS) { - PgStat_StatBeEntry *beentry; - int32 beid; - int len; - text *result; + PgStat_StatBeEntry *beentry; + int32 beid; + int len; + text *result; if (!superuser()) PG_RETURN_NULL(); - beid = PG_GETARG_INT32(0); + beid = PG_GETARG_INT32(0); if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) PG_RETURN_NULL(); @@ -284,16 +284,16 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS) Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS) { - PgStat_StatDBEntry *dbentry; - Oid dbid; - int32 result; + PgStat_StatDBEntry *dbentry; + Oid dbid; + int32 result; - dbid = PG_GETARG_OID(0); + dbid = PG_GETARG_OID(0); if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) result = 0; else - result = (int32)(dbentry->n_backends); + result = (int32) (dbentry->n_backends); PG_RETURN_INT32(result); } @@ -302,16 +302,16 @@ pg_stat_get_db_numbackends(PG_FUNCTION_ARGS) Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS) { - PgStat_StatDBEntry *dbentry; - Oid dbid; - int64 result; + PgStat_StatDBEntry *dbentry; + Oid dbid; + int64 result; - dbid = PG_GETARG_OID(0); + dbid = PG_GETARG_OID(0); if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) result = 0; else - result = (int64)(dbentry->n_xact_commit); + result = (int64) (dbentry->n_xact_commit); PG_RETURN_INT64(result); } @@ -320,16 +320,16 @@ pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS) Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS) { - PgStat_StatDBEntry *dbentry; - Oid dbid; - int64 result; + PgStat_StatDBEntry *dbentry; + Oid dbid; + int64 result; - dbid = PG_GETARG_OID(0); + dbid = PG_GETARG_OID(0); if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) result = 0; else - result = (int64)(dbentry->n_xact_rollback); + result = (int64) (dbentry->n_xact_rollback); PG_RETURN_INT64(result); } @@ -338,16 +338,16 @@ pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS) Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS) { - PgStat_StatDBEntry *dbentry; - Oid dbid; - int64 result; + PgStat_StatDBEntry *dbentry; + Oid dbid; + int64 result; - dbid = PG_GETARG_OID(0); + dbid = PG_GETARG_OID(0); if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) result = 0; else - result = (int64)(dbentry->n_blocks_fetched); + result = (int64) (dbentry->n_blocks_fetched); PG_RETURN_INT64(result); } @@ -356,18 +356,16 @@ pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS) Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS) { - PgStat_StatDBEntry *dbentry; - Oid dbid; - int64 result; + PgStat_StatDBEntry *dbentry; + Oid dbid; + int64 result; - dbid = PG_GETARG_OID(0); + dbid = PG_GETARG_OID(0); if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) result = 0; else - result = (int64)(dbentry->n_blocks_hit); + result = (int64) (dbentry->n_blocks_hit); PG_RETURN_INT64(result); } - - diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index 10999150a2..45e4c1133d 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.4 2001/03/22 03:59:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.5 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -289,5 +289,4 @@ do_quote_literal(text *lptr) return result; } - #endif diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 146ae74263..926d7875ba 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.36 2001/03/22 03:59:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.37 2001/10/25 05:49:45 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -121,7 +121,6 @@ RE_compile_and_execute(text *text_re, char *text, int cflags) regcomp_result = pg95_regcomp(&rev[oldest].cre_re, re, cflags); if (regcomp_result == 0) { - /* * use malloc/free for the cre_s field because the storage has to * persist across transactions diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 3ae65c6c8e..b06001af3d 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.63 2001/08/21 16:36:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.64 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,9 +53,9 @@ regprocin(PG_FUNCTION_ARGS) Oid searchOid; searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(pro_name_or_oid))); + CStringGetDatum(pro_name_or_oid))); result = (RegProcedure) GetSysCacheOid(PROCOID, - ObjectIdGetDatum(searchOid), + ObjectIdGetDatum(searchOid), 0, 0, 0); if (!RegProcedureIsValid(result)) elog(ERROR, "No procedure with oid %s", pro_name_or_oid); diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index a03ca77440..b71732a194 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -18,7 +18,7 @@ * Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group * Copyright 1999 Jan Wieck * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.28 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.29 2001/10/25 05:49:45 momjian Exp $ * * ---------- */ @@ -423,7 +423,6 @@ RI_FKey_check(PG_FUNCTION_ARGS) */ for (i = 0; i < qkey.nkeypairs; i++) { - /* * We can implement MATCH PARTIAL by excluding this column from * the query if it is null. Simple! Unfortunately, the @@ -2140,7 +2139,6 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) qualsep = "WHERE"; for (i = 0; i < qkey.nkeypairs; i++) { - /* * MATCH <unspecified> - only change columns * corresponding to changed columns in pk_rel's key @@ -2402,7 +2400,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) defval = NULL; for (i = 0; i < qkey.nkeypairs && defval != NULL; i++) { - /* * For each key attribute lookup the tuple constructor * for a corresponding default value @@ -2412,7 +2409,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) if (defval[j].adnum == qkey.keypair[i][RI_KEYPAIR_FK_IDX]) { - /* * That's the one - push the expression from * defval.adbin into the plan's targetlist @@ -2629,7 +2625,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) qualsep = "WHERE"; for (i = 0; i < qkey.nkeypairs; i++) { - /* * MATCH <unspecified> - only change columns * corresponding to changed columns in pk_rel's key @@ -2669,7 +2664,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) defval = NULL; for (i = 0; i < qkey.nkeypairs && defval != NULL; i++) { - /* * MATCH <unspecified> - only change columns * corresponding to changed columns in pk_rel's key. @@ -2680,7 +2674,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) !ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey, RI_KEYPAIR_PK_IDX)) { - /* * For each key attribute lookup the tuple * constructor for a corresponding default value @@ -2690,7 +2683,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) if (defval[j].adnum == qkey.keypair[i][RI_KEYPAIR_FK_IDX]) { - /* * That's the one - push the expression * from defval.adbin into the plan's @@ -2807,7 +2799,6 @@ RI_FKey_keyequal_upd(TriggerData *trigdata) switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { - /* * MATCH <UNSPECIFIED> */ @@ -3079,7 +3070,6 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup, for (i = 0; i < key->nkeypairs; i++) { - /* * Get one attributes oldvalue. If it is NULL - they're not equal. */ @@ -3129,7 +3119,6 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, keys_unequal = true; for (i = 0; keys_unequal && i < key->nkeypairs; i++) { - /* * Get one attributes oldvalue. If it is NULL - they're not equal. */ @@ -3252,17 +3241,17 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) CharGetDatum('b')); if (!HeapTupleIsValid(opr_tup)) elog(ERROR, - "ri_AttributesEqual(): cannot find '=' operator for type %u", + "ri_AttributesEqual(): cannot find '=' operator for type %u", typeid); opr_proc = ((Form_pg_operator) GETSTRUCT(opr_tup))->oprcode; ReleaseSysCache(opr_tup); /* * Since fmgr_info could fail, call it *before* creating the - * hashtable entry --- otherwise we could elog leaving an incomplete - * entry in the hashtable. Also, because this will be a permanent - * table entry, we must make sure any subsidiary structures of the - * fmgr record are kept in TopMemoryContext. + * hashtable entry --- otherwise we could elog leaving an + * incomplete entry in the hashtable. Also, because this will be + * a permanent table entry, we must make sure any subsidiary + * structures of the fmgr record are kept in TopMemoryContext. */ fmgr_info_cxt(opr_proc, &finfo, TopMemoryContext); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 1d1969e68d..3ed36783f5 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.85 2001/10/08 19:55:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.86 2001/10/25 05:49:45 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -84,7 +84,7 @@ typedef struct List *rtable; /* List of RangeTblEntry nodes */ List *namespace; /* List of joinlist items (RangeTblRef and * JoinExpr nodes) */ -} deparse_namespace; +} deparse_namespace; /* ---------- @@ -118,8 +118,8 @@ static void get_basic_select_query(Query *query, deparse_context *context); static void get_setop_query(Node *setOp, Query *query, deparse_context *context, bool toplevel); static void get_rule_sortgroupclause(SortClause *srt, List *tlist, - bool force_colno, - deparse_context *context); + bool force_colno, + deparse_context *context); static void get_names_for_var(Var *var, deparse_context *context, char **refname, char **attname); static bool get_alias_for_case(CaseExpr *caseexpr, deparse_context *context, @@ -138,7 +138,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_opclass_name(Oid opclass, Oid actual_datatype, - StringInfo buf); + StringInfo buf); static bool tleIsArrayAssign(TargetEntry *tle); static char *quote_identifier(char *ident); static char *get_relation_name(Oid relid); @@ -302,7 +302,6 @@ pg_get_viewdef(PG_FUNCTION_ARGS) appendStringInfo(&buf, "Not a view"); else { - /* * Get the rules definition and put it into executors memory */ @@ -409,7 +408,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS) sep = ""; for (keyno = 0; keyno < INDEX_MAX_KEYS; keyno++) { - AttrNumber attnum = idxrec->indkey[keyno]; + AttrNumber attnum = idxrec->indkey[keyno]; if (attnum == InvalidAttrNumber) break; @@ -470,16 +469,17 @@ pg_get_indexdef(PG_FUNCTION_ARGS) */ if (VARSIZE(&idxrec->indpred) > VARHDRSZ) { - Node *node; - List *context; - char *exprstr; - char *str; + Node *node; + List *context; + char *exprstr; + char *str; /* Convert TEXT object to C string */ exprstr = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&idxrec->indpred))); + PointerGetDatum(&idxrec->indpred))); /* Convert expression to node tree */ node = (Node *) stringToNode(exprstr); + /* * If top level is a List, assume it is an implicit-AND structure, * and convert to explicit AND. This is needed for partial index @@ -528,14 +528,14 @@ pg_get_indexdef(PG_FUNCTION_ARGS) Datum pg_get_expr(PG_FUNCTION_ARGS) { - text *expr = PG_GETARG_TEXT_P(0); - Oid relid = PG_GETARG_OID(1); - text *result; - Node *node; - List *context; - char *exprstr; - char *relname; - char *str; + text *expr = PG_GETARG_TEXT_P(0); + Oid relid = PG_GETARG_OID(1); + text *result; + Node *node; + List *context; + char *exprstr; + char *relname; + char *str; /* Get the name for the relation */ relname = get_rel_name(relid); @@ -550,19 +550,17 @@ pg_get_expr(PG_FUNCTION_ARGS) node = (Node *) stringToNode(exprstr); /* - * If top level is a List, assume it is an implicit-AND structure, - * and convert to explicit AND. This is needed for partial index + * If top level is a List, assume it is an implicit-AND structure, and + * convert to explicit AND. This is needed for partial index * predicates. */ if (node && IsA(node, List)) - { node = (Node *) make_ands_explicit((List *) node); - } /* Deparse */ context = deparse_context_for(relname, relid); str = deparse_expression(node, context, false); - + /* Pass the result back as TEXT */ result = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str))); @@ -1178,10 +1176,11 @@ get_rule_sortgroupclause(SortClause *srt, List *tlist, bool force_colno, tle = get_sortgroupclause_tle(srt, tlist); expr = tle->expr; + /* * Use column-number form if requested by caller or if expression is a - * constant --- a constant is ambiguous (and will be misinterpreted - * by findTargetlistEntry()) if we dump it explicitly. + * constant --- a constant is ambiguous (and will be misinterpreted by + * findTargetlistEntry()) if we dump it explicitly. */ if (force_colno || (expr && IsA(expr, Const))) { @@ -1938,54 +1937,54 @@ get_rule_expr(Node *node, deparse_context *context) case T_NullTest: { - NullTest *ntest = (NullTest *) node; + NullTest *ntest = (NullTest *) node; appendStringInfo(buf, "("); get_rule_expr(ntest->arg, context); - switch (ntest->nulltesttype) - { - case IS_NULL: + switch (ntest->nulltesttype) + { + case IS_NULL: appendStringInfo(buf, " IS NULL)"); break; - case IS_NOT_NULL: + case IS_NOT_NULL: appendStringInfo(buf, " IS NOT NULL)"); break; - default: - elog(ERROR, "get_rule_expr: unexpected nulltesttype %d", - (int) ntest->nulltesttype); + default: + elog(ERROR, "get_rule_expr: unexpected nulltesttype %d", + (int) ntest->nulltesttype); } } break; case T_BooleanTest: { - BooleanTest *btest = (BooleanTest *) node; + BooleanTest *btest = (BooleanTest *) node; appendStringInfo(buf, "("); get_rule_expr(btest->arg, context); - switch (btest->booltesttype) - { - case IS_TRUE: + switch (btest->booltesttype) + { + case IS_TRUE: appendStringInfo(buf, " IS TRUE)"); break; - case IS_NOT_TRUE: + case IS_NOT_TRUE: appendStringInfo(buf, " IS NOT TRUE)"); break; - case IS_FALSE: + case IS_FALSE: appendStringInfo(buf, " IS FALSE)"); break; - case IS_NOT_FALSE: + case IS_NOT_FALSE: appendStringInfo(buf, " IS NOT FALSE)"); break; - case IS_UNKNOWN: + case IS_UNKNOWN: appendStringInfo(buf, " IS UNKNOWN)"); break; - case IS_NOT_UNKNOWN: + case IS_NOT_UNKNOWN: appendStringInfo(buf, " IS NOT UNKNOWN)"); break; - default: - elog(ERROR, "get_rule_expr: unexpected booltesttype %d", - (int) btest->booltesttype); + default: + elog(ERROR, "get_rule_expr: unexpected booltesttype %d", + (int) btest->booltesttype); } } break; @@ -2051,14 +2050,15 @@ get_func_expr(Expr *expr, deparse_context *context) appendStringInfoChar(buf, '('); get_rule_expr(arg, context); + /* * Show typename with appropriate length decoration. Note that * since exprIsLengthCoercion succeeded, the function's output * type is the right thing to use. * * XXX In general it is incorrect to quote the result of - * format_type_with_typemod, but are there any special cases - * where we should do so? + * format_type_with_typemod, but are there any special cases where + * we should do so? */ typdesc = format_type_with_typemod(procStruct->prorettype, coercedTypmod); @@ -2107,7 +2107,7 @@ strip_type_coercion(Node *expr, Oid resultType) if (IsA(expr, RelabelType)) return strip_type_coercion(((RelabelType *) expr)->arg, resultType); - if (IsA(expr, Expr) && ((Expr *) expr)->opType == FUNC_EXPR) + if (IsA(expr, Expr) &&((Expr *) expr)->opType == FUNC_EXPR) { Func *func; HeapTuple procTuple; @@ -2135,7 +2135,7 @@ strip_type_coercion(Node *expr, Oid resultType) } /* See if function has same name as its result type */ typeTuple = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup for type %u failed", @@ -2221,7 +2221,6 @@ get_const_expr(Const *constval, deparse_context *context) if (constval->constisnull) { - /* * Always label the type of a NULL constant. This not only * prevents misdecisions about the type, but it ensures that our @@ -2625,7 +2624,6 @@ tleIsArrayAssign(TargetEntry *tle) static char * quote_identifier(char *ident) { - /* * Can avoid quoting if ident starts with a lowercase letter and * contains only lowercase letters, digits, and underscores, *and* is @@ -2657,7 +2655,6 @@ quote_identifier(char *ident) if (safe) { - /* * Check for keyword. This test is overly strong, since many of * the "keywords" known to the parser are usable as column names, diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 306758ff77..e7d319e9b6 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.99 2001/10/13 23:32:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.100 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ /* * Note: the default selectivity estimates are not chosen entirely at random. * We want them to be small enough to ensure that indexscans will be used if - * available, for typical table densities of ~100 tuples/page. Thus, for + * available, for typical table densities of ~100 tuples/page. Thus, for * example, 0.01 is not quite small enough, since that makes it appear that * nearly all pages will be hit anyway. Also, since we sometimes estimate * eqsel as 1/num_distinct, we probably want DEFAULT_NUM_DISTINCT to equal @@ -135,22 +135,22 @@ static void convert_string_to_scalar(unsigned char *value, unsigned char *hibound, double *scaledhibound); static void convert_bytea_to_scalar(Datum value, - double *scaledvalue, - Datum lobound, - double *scaledlobound, - Datum hibound, - double *scaledhibound); + double *scaledvalue, + Datum lobound, + double *scaledlobound, + Datum hibound, + double *scaledhibound); static double convert_one_string_to_scalar(unsigned char *value, int rangelo, int rangehi); static double convert_one_bytea_to_scalar(unsigned char *value, int valuelen, - int rangelo, int rangehi); + int rangelo, int rangehi); static unsigned char *convert_string_datum(Datum value, Oid typid); static double convert_timevalue_to_scalar(Datum value, Oid typid); static double get_att_numdistinct(Query *root, Var *var, - Form_pg_statistic stats); + Form_pg_statistic stats); static bool get_restriction_var(List *args, int varRelid, - Var **var, Node **other, - bool *varonleft); + Var **var, Node **other, + bool *varonleft); static void get_join_vars(List *args, Var **var1, Var **var2); static Selectivity prefix_selectivity(Query *root, Var *var, char *prefix); static Selectivity pattern_selectivity(char *patt, Pattern_Type ptype); @@ -188,9 +188,9 @@ eqsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not var = something or something = var for - * a simple var of a real relation (no subqueries, for now), - * then punt and return a default estimate. + * If expression is not var = something or something = var for a + * simple var of a real relation (no subqueries, for now), then punt + * and return a default estimate. */ if (!get_restriction_var(args, varRelid, &var, &other, &varonleft)) @@ -200,10 +200,10 @@ eqsel(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(DEFAULT_EQ_SEL); /* - * If the something is a NULL constant, assume operator is strict - * and return zero, ie, operator will never return TRUE. + * If the something is a NULL constant, assume operator is strict and + * return zero, ie, operator will never return TRUE. */ - if (IsA(other, Const) && ((Const *) other)->constisnull) + if (IsA(other, Const) &&((Const *) other)->constisnull) PG_RETURN_FLOAT8(0.0); /* get stats for the attribute, if available */ @@ -220,15 +220,15 @@ eqsel(PG_FUNCTION_ARGS) if (IsA(other, Const)) { /* Var is being compared to a known non-null constant */ - Datum constval = ((Const *) other)->constvalue; - bool match = false; - int i; + Datum constval = ((Const *) other)->constvalue; + bool match = false; + int i; /* * Is the constant "=" to any of the column's most common - * values? (Although the given operator may not really be - * "=", we will assume that seeing whether it returns TRUE - * is an appropriate test. If you don't like this, maybe you + * values? (Although the given operator may not really be + * "=", we will assume that seeing whether it returns TRUE is + * an appropriate test. If you don't like this, maybe you * shouldn't be using eqsel for your operator...) */ if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod, @@ -267,41 +267,42 @@ eqsel(PG_FUNCTION_ARGS) { /* * Constant is "=" to this common value. We know - * selectivity exactly (or as exactly as VACUUM - * could calculate it, anyway). + * selectivity exactly (or as exactly as VACUUM could + * calculate it, anyway). */ selec = numbers[i]; } else { /* - * Comparison is against a constant that is neither - * NULL nor any of the common values. Its selectivity - * cannot be more than this: + * Comparison is against a constant that is neither NULL + * nor any of the common values. Its selectivity cannot + * be more than this: */ - double sumcommon = 0.0; - double otherdistinct; + double sumcommon = 0.0; + double otherdistinct; for (i = 0; i < nnumbers; i++) sumcommon += numbers[i]; selec = 1.0 - sumcommon - stats->stanullfrac; + /* - * and in fact it's probably a good deal less. - * We approximate that all the not-common values - * share this remaining fraction equally, so we - * divide by the number of other distinct values. + * and in fact it's probably a good deal less. We + * approximate that all the not-common values share this + * remaining fraction equally, so we divide by the number + * of other distinct values. */ otherdistinct = get_att_numdistinct(root, var, stats) - nnumbers; if (otherdistinct > 1) selec /= otherdistinct; + /* - * Another cross-check: selectivity shouldn't be - * estimated as more than the least common - * "most common value". + * Another cross-check: selectivity shouldn't be estimated + * as more than the least common "most common value". */ - if (nnumbers > 0 && selec > numbers[nnumbers-1]) - selec = numbers[nnumbers-1]; + if (nnumbers > 0 && selec > numbers[nnumbers - 1]) + selec = numbers[nnumbers - 1]; } free_attstatsslot(var->vartype, values, nvalues, @@ -312,22 +313,23 @@ eqsel(PG_FUNCTION_ARGS) double ndistinct; /* - * Search is for a value that we do not know a priori, but - * we will assume it is not NULL. Estimate the selectivity - * as non-null fraction divided by number of distinct values, - * so that we get a result averaged over all possible values - * whether common or uncommon. (Essentially, we are assuming + * Search is for a value that we do not know a priori, but we + * will assume it is not NULL. Estimate the selectivity as + * non-null fraction divided by number of distinct values, so + * that we get a result averaged over all possible values + * whether common or uncommon. (Essentially, we are assuming * that the not-yet-known comparison value is equally likely * to be any of the possible values, regardless of their - * frequency in the table. Is that a good idea?) + * frequency in the table. Is that a good idea?) */ selec = 1.0 - stats->stanullfrac; ndistinct = get_att_numdistinct(root, var, stats); if (ndistinct > 1) selec /= ndistinct; + /* - * Cross-check: selectivity should never be - * estimated as more than the most common value's. + * Cross-check: selectivity should never be estimated as more + * than the most common value's. */ if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod, STATISTIC_KIND_MCV, InvalidOid, @@ -347,8 +349,8 @@ eqsel(PG_FUNCTION_ARGS) /* * No VACUUM ANALYZE stats available, so make a guess using * estimated number of distinct values and assuming they are - * equally common. (The guess is unlikely to be very good, - * but we do know a few special cases.) + * equally common. (The guess is unlikely to be very good, but we + * do know a few special cases.) */ selec = 1.0 / get_att_numdistinct(root, var, NULL); } @@ -387,10 +389,10 @@ neqsel(PG_FUNCTION_ARGS) if (eqop) { result = DatumGetFloat8(DirectFunctionCall4(eqsel, - PointerGetDatum(root), - ObjectIdGetDatum(eqop), - PointerGetDatum(args), - Int32GetDatum(varRelid))); + PointerGetDatum(root), + ObjectIdGetDatum(eqop), + PointerGetDatum(args), + Int32GetDatum(varRelid))); } else { @@ -433,23 +435,24 @@ scalarineqsel(Query *root, Oid operator, bool isgt, int i; /* - * If expression is not var op something or something op var for - * a simple var of a real relation (no subqueries, for now), - * then punt and return a default estimate. + * If expression is not var op something or something op var for a + * simple var of a real relation (no subqueries, for now), then punt + * and return a default estimate. */ relid = getrelid(var->varno, root->rtable); if (relid == InvalidOid) return DEFAULT_INEQ_SEL; /* - * Can't do anything useful if the something is not a constant, either. + * Can't do anything useful if the something is not a constant, + * either. */ - if (! IsA(other, Const)) + if (!IsA(other, Const)) return DEFAULT_INEQ_SEL; /* - * If the constant is NULL, assume operator is strict - * and return zero, ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, + * ie, operator will never return TRUE. */ if (((Const *) other)->constisnull) return 0.0; @@ -471,9 +474,9 @@ scalarineqsel(Query *root, Oid operator, bool isgt, fmgr_info(get_opcode(operator), &opproc); /* - * If we have most-common-values info, add up the fractions of the - * MCV entries that satisfy MCV OP CONST. These fractions contribute - * directly to the result selectivity. Also add up the total fraction + * If we have most-common-values info, add up the fractions of the MCV + * entries that satisfy MCV OP CONST. These fractions contribute + * directly to the result selectivity. Also add up the total fraction * represented by MCV entries. */ mcv_selec = 0.0; @@ -517,8 +520,8 @@ scalarineqsel(Query *root, Oid operator, bool isgt, { if (nvalues > 1) { - double histfrac; - bool ltcmp; + double histfrac; + bool ltcmp; ltcmp = DatumGetBool(FunctionCall2(&opproc, values[0], @@ -533,9 +536,10 @@ scalarineqsel(Query *root, Oid operator, bool isgt, else { /* - * Scan to find proper location. This could be made faster - * by using a binary-search method, but it's probably not - * worth the trouble for typical histogram sizes. + * Scan to find proper location. This could be made + * faster by using a binary-search method, but it's + * probably not worth the trouble for typical histogram + * sizes. */ for (i = 1; i < nvalues; i++) { @@ -563,11 +567,11 @@ scalarineqsel(Query *root, Oid operator, bool isgt, * We have values[i-1] < constant < values[i]. * * Convert the constant and the two nearest bin boundary - * values to a uniform comparison scale, and do a linear - * interpolation within this bin. + * values to a uniform comparison scale, and do a + * linear interpolation within this bin. */ if (convert_to_scalar(constval, consttype, &val, - values[i-1], values[i], + values[i - 1], values[i], var->vartype, &low, &high)) { @@ -583,11 +587,12 @@ scalarineqsel(Query *root, Oid operator, bool isgt, else { binfrac = (val - low) / (high - low); + /* - * Watch out for the possibility that we got a NaN - * or Infinity from the division. This can happen - * despite the previous checks, if for example - * "low" is -Infinity. + * Watch out for the possibility that we got a + * NaN or Infinity from the division. This + * can happen despite the previous checks, if + * for example "low" is -Infinity. */ if (isnan(binfrac) || binfrac < 0.0 || binfrac > 1.0) @@ -597,35 +602,40 @@ scalarineqsel(Query *root, Oid operator, bool isgt, else { /* - * Ideally we'd produce an error here, on the grounds - * that the given operator shouldn't have scalarXXsel - * registered as its selectivity func unless we can - * deal with its operand types. But currently, all - * manner of stuff is invoking scalarXXsel, so give a - * default estimate until that can be fixed. + * Ideally we'd produce an error here, on the + * grounds that the given operator shouldn't have + * scalarXXsel registered as its selectivity func + * unless we can deal with its operand types. But + * currently, all manner of stuff is invoking + * scalarXXsel, so give a default estimate until + * that can be fixed. */ binfrac = 0.5; } + /* - * Now, compute the overall selectivity across the values - * represented by the histogram. We have i-1 full bins - * and binfrac partial bin below the constant. + * Now, compute the overall selectivity across the + * values represented by the histogram. We have i-1 + * full bins and binfrac partial bin below the + * constant. */ - histfrac = (double) (i-1) + binfrac; + histfrac = (double) (i - 1) + binfrac; histfrac /= (double) (nvalues - 1); } } + /* - * Now histfrac = fraction of histogram entries below the constant. + * Now histfrac = fraction of histogram entries below the + * constant. * * Account for "<" vs ">" */ hist_selec = isgt ? (1.0 - histfrac) : histfrac; + /* * The histogram boundaries are only approximate to begin - * with, and may well be out of date anyway. Therefore, - * don't believe extremely small or large selectivity - * estimates. + * with, and may well be out of date anyway. Therefore, don't + * believe extremely small or large selectivity estimates. */ if (hist_selec < 0.0001) hist_selec = 0.0001; @@ -684,9 +694,9 @@ scalarltsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not var op something or something op var for - * a simple var of a real relation (no subqueries, for now), - * then punt and return a default estimate. + * If expression is not var op something or something op var for a + * simple var of a real relation (no subqueries, for now), then punt + * and return a default estimate. */ if (!get_restriction_var(args, varRelid, &var, &other, &varonleft)) @@ -734,9 +744,9 @@ scalargtsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not var op something or something op var for - * a simple var of a real relation (no subqueries, for now), - * then punt and return a default estimate. + * If expression is not var op something or something op var for a + * simple var of a real relation (no subqueries, for now), then punt + * and return a default estimate. */ if (!get_restriction_var(args, varRelid, &var, &other, &varonleft)) @@ -774,6 +784,7 @@ static double patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) { Query *root = (Query *) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid operator = PG_GETARG_OID(1); #endif @@ -791,9 +802,9 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) double result; /* - * If expression is not var op constant for - * a simple var of a real relation (no subqueries, for now), - * then punt and return a default estimate. + * If expression is not var op constant for a simple var of a real + * relation (no subqueries, for now), then punt and return a default + * estimate. */ if (!get_restriction_var(args, varRelid, &var, &other, &varonleft)) @@ -805,8 +816,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) return DEFAULT_MATCH_SEL; /* - * If the constant is NULL, assume operator is strict - * and return zero, ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, + * ie, operator will never return TRUE. */ if (((Const *) other)->constisnull) return 0.0; @@ -834,16 +845,16 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) eqargs = makeList2(var, eqcon); result = DatumGetFloat8(DirectFunctionCall4(eqsel, PointerGetDatum(root), - ObjectIdGetDatum(eqopr), - PointerGetDatum(eqargs), - Int32GetDatum(varRelid))); + ObjectIdGetDatum(eqopr), + PointerGetDatum(eqargs), + Int32GetDatum(varRelid))); } else { /* - * Not exact-match pattern. We estimate selectivity of the - * fixed prefix and remainder of pattern separately, then - * combine the two. + * Not exact-match pattern. We estimate selectivity of the fixed + * prefix and remainder of pattern separately, then combine the + * two. */ Selectivity prefixsel; Selectivity restsel; @@ -964,28 +975,28 @@ icnlikesel(PG_FUNCTION_ARGS) Selectivity booltestsel(Query *root, BooleanTest *clause, int varRelid) { - Var *var; - Node *arg; - Oid relid; - HeapTuple statsTuple; - Datum *values; - int nvalues; - float4 *numbers; - int nnumbers; - double selec; + Var *var; + Node *arg; + Oid relid; + HeapTuple statsTuple; + Datum *values; + int nvalues; + float4 *numbers; + int nnumbers; + double selec; Assert(clause && IsA(clause, BooleanTest)); arg = (Node *) clause->arg; /* - * Ignore any binary-compatible relabeling (probably unnecessary, - * but can't hurt) + * Ignore any binary-compatible relabeling (probably unnecessary, but + * can't hurt) */ if (IsA(arg, RelabelType)) arg = ((RelabelType *) arg)->arg; - if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno)) + if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno)) var = (Var *) arg; else { @@ -996,24 +1007,24 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) * and just assume the value is either TRUE or FALSE. */ switch (clause->booltesttype) - { + { case IS_UNKNOWN: selec = DEFAULT_UNK_SEL; break; case IS_NOT_UNKNOWN: selec = DEFAULT_NOT_UNK_SEL; break; - case IS_TRUE: - case IS_NOT_FALSE: + case IS_TRUE: + case IS_NOT_FALSE: selec = (double) clause_selectivity(root, arg, varRelid); break; - case IS_FALSE: - case IS_NOT_TRUE: + case IS_FALSE: + case IS_NOT_TRUE: selec = 1.0 - (double) clause_selectivity(root, arg, varRelid); break; - default: - elog(ERROR, "booltestsel: unexpected booltesttype %d", - (int) clause->booltesttype); + default: + elog(ERROR, "booltestsel: unexpected booltesttype %d", + (int) clause->booltesttype); selec = 0.0; /* Keep compiler quiet */ break; } @@ -1033,7 +1044,7 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) if (HeapTupleIsValid(statsTuple)) { Form_pg_statistic stats; - double freq_null; + double freq_null; stats = (Form_pg_statistic) GETSTRUCT(statsTuple); @@ -1045,8 +1056,8 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) &numbers, &nnumbers) && nnumbers > 0) { - double freq_true; - double freq_false; + double freq_true; + double freq_false; /* * Get first MCV frequency and derive frequency for true. @@ -1057,41 +1068,41 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) freq_true = 1.0 - numbers[0] - freq_null; /* - * Next derive freqency for false. - * Then use these as appropriate to derive frequency for each case. + * Next derive freqency for false. Then use these as + * appropriate to derive frequency for each case. */ freq_false = 1.0 - freq_true - freq_null; switch (clause->booltesttype) - { - case IS_UNKNOWN: + { + case IS_UNKNOWN: /* select only NULL values */ selec = freq_null; break; - case IS_NOT_UNKNOWN: + case IS_NOT_UNKNOWN: /* select non-NULL values */ selec = 1.0 - freq_null; break; - case IS_TRUE: + case IS_TRUE: /* select only TRUE values */ selec = freq_true; break; - case IS_NOT_TRUE: + case IS_NOT_TRUE: /* select non-TRUE values */ selec = 1.0 - freq_true; break; - case IS_FALSE: + case IS_FALSE: /* select only FALSE values */ selec = freq_false; break; - case IS_NOT_FALSE: + case IS_NOT_FALSE: /* select non-FALSE values */ selec = 1.0 - freq_false; break; - default: - elog(ERROR, "booltestsel: unexpected booltesttype %d", - (int) clause->booltesttype); - selec = 0.0; /* Keep compiler quiet */ + default: + elog(ERROR, "booltestsel: unexpected booltesttype %d", + (int) clause->booltesttype); + selec = 0.0; /* Keep compiler quiet */ break; } @@ -1101,37 +1112,38 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) else { /* - * No most-common-value info available. - * Still have null fraction information, - * so use it for IS [NOT] UNKNOWN. - * Otherwise adjust for null fraction and - * assume an even split for boolean tests. + * No most-common-value info available. Still have null + * fraction information, so use it for IS [NOT] UNKNOWN. + * Otherwise adjust for null fraction and assume an even split + * for boolean tests. */ switch (clause->booltesttype) - { - case IS_UNKNOWN: + { + case IS_UNKNOWN: + /* * Use freq_null directly. */ selec = freq_null; break; - case IS_NOT_UNKNOWN: + case IS_NOT_UNKNOWN: + /* - * Select not unknown (not null) values. - * Calculate from freq_null. + * Select not unknown (not null) values. Calculate + * from freq_null. */ selec = 1.0 - freq_null; break; - case IS_TRUE: - case IS_NOT_TRUE: - case IS_FALSE: - case IS_NOT_FALSE: + case IS_TRUE: + case IS_NOT_TRUE: + case IS_FALSE: + case IS_NOT_FALSE: selec = (1.0 - freq_null) / 2.0; break; - default: - elog(ERROR, "booltestsel: unexpected booltesttype %d", - (int) clause->booltesttype); - selec = 0.0; /* Keep compiler quiet */ + default: + elog(ERROR, "booltestsel: unexpected booltesttype %d", + (int) clause->booltesttype); + selec = 0.0; /* Keep compiler quiet */ break; } } @@ -1161,7 +1173,7 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) default: elog(ERROR, "booltestsel: unexpected booltesttype %d", (int) clause->booltesttype); - selec = 0.0; /* Keep compiler quiet */ + selec = 0.0; /* Keep compiler quiet */ break; } } @@ -1181,28 +1193,28 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid) Selectivity nulltestsel(Query *root, NullTest *clause, int varRelid) { - Var *var; - Node *arg; - Oid relid; - HeapTuple statsTuple; - double selec; - double defselec; - double freq_null; + Var *var; + Node *arg; + Oid relid; + HeapTuple statsTuple; + double selec; + double defselec; + double freq_null; Assert(clause && IsA(clause, NullTest)); switch (clause->nulltesttype) - { - case IS_NULL: + { + case IS_NULL: defselec = DEFAULT_UNK_SEL; break; - case IS_NOT_NULL: + case IS_NOT_NULL: defselec = DEFAULT_NOT_UNK_SEL; break; - default: - elog(ERROR, "nulltestsel: unexpected nulltesttype %d", - (int) clause->nulltesttype); - return (Selectivity) 0; /* keep compiler quiet */ + default: + elog(ERROR, "nulltestsel: unexpected nulltesttype %d", + (int) clause->nulltesttype); + return (Selectivity) 0; /* keep compiler quiet */ } arg = (Node *) clause->arg; @@ -1213,7 +1225,7 @@ nulltestsel(Query *root, NullTest *clause, int varRelid) if (IsA(arg, RelabelType)) arg = ((RelabelType *) arg)->arg; - if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno)) + if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno)) var = (Var *) arg; else { @@ -1225,7 +1237,7 @@ nulltestsel(Query *root, NullTest *clause, int varRelid) relid = getrelid(var->varno, root->rtable); if (relid == InvalidOid) - return (Selectivity) defselec; + return (Selectivity) defselec; /* get stats for the attribute, if available */ statsTuple = SearchSysCache(STATRELATT, @@ -1240,24 +1252,26 @@ nulltestsel(Query *root, NullTest *clause, int varRelid) freq_null = stats->stanullfrac; switch (clause->nulltesttype) - { - case IS_NULL: + { + case IS_NULL: + /* * Use freq_null directly. */ selec = freq_null; break; - case IS_NOT_NULL: + case IS_NOT_NULL: + /* - * Select not unknown (not null) values. - * Calculate from freq_null. + * Select not unknown (not null) values. Calculate from + * freq_null. */ selec = 1.0 - freq_null; break; - default: - elog(ERROR, "nulltestsel: unexpected nulltesttype %d", - (int) clause->nulltesttype); - return (Selectivity) 0; /* keep compiler quiet */ + default: + elog(ERROR, "nulltestsel: unexpected nulltesttype %d", + (int) clause->nulltesttype); + return (Selectivity) 0; /* keep compiler quiet */ } ReleaseSysCache(statsTuple); @@ -1318,13 +1332,13 @@ eqjoinsel(PG_FUNCTION_ARGS) if (var1 != NULL) { /* get stats for the attribute, if available */ - Oid relid1 = getrelid(var1->varno, root->rtable); + Oid relid1 = getrelid(var1->varno, root->rtable); if (relid1 != InvalidOid) { statsTuple1 = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid1), - Int16GetDatum(var1->varattno), + Int16GetDatum(var1->varattno), 0, 0); if (HeapTupleIsValid(statsTuple1)) { @@ -1345,13 +1359,13 @@ eqjoinsel(PG_FUNCTION_ARGS) if (var2 != NULL) { /* get stats for the attribute, if available */ - Oid relid2 = getrelid(var2->varno, root->rtable); + Oid relid2 = getrelid(var2->varno, root->rtable); if (relid2 != InvalidOid) { statsTuple2 = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid2), - Int16GetDatum(var2->varattno), + Int16GetDatum(var2->varattno), 0, 0); if (HeapTupleIsValid(statsTuple2)) { @@ -1372,17 +1386,18 @@ eqjoinsel(PG_FUNCTION_ARGS) if (have_mcvs1 && have_mcvs2) { /* - * We have most-common-value lists for both relations. Run + * We have most-common-value lists for both relations. Run * through the lists to see which MCVs actually join to each * other with the given operator. This allows us to determine * the exact join selectivity for the portion of the relations - * represented by the MCV lists. We still have to estimate for - * the remaining population, but in a skewed distribution this - * gives us a big leg up in accuracy. For motivation see the - * analysis in Y. Ioannidis and S. Christodoulakis, "On the - * propagation of errors in the size of join results", Technical - * Report 1018, Computer Science Dept., University of Wisconsin, - * Madison, March 1991 (available from ftp.cs.wisc.edu). + * represented by the MCV lists. We still have to estimate + * for the remaining population, but in a skewed distribution + * this gives us a big leg up in accuracy. For motivation see + * the analysis in Y. Ioannidis and S. Christodoulakis, "On + * the propagation of errors in the size of join results", + * Technical Report 1018, Computer Science Dept., University + * of Wisconsin, Madison, March 1991 (available from + * ftp.cs.wisc.edu). */ FmgrInfo eqproc; bool *hasmatch1; @@ -1404,17 +1419,19 @@ eqjoinsel(PG_FUNCTION_ARGS) memset(hasmatch1, 0, nvalues1 * sizeof(bool)); hasmatch2 = (bool *) palloc(nvalues2 * sizeof(bool)); memset(hasmatch2, 0, nvalues2 * sizeof(bool)); + /* - * Note we assume that each MCV will match at most one member of - * the other MCV list. If the operator isn't really equality, - * there could be multiple matches --- but we don't look for them, - * both for speed and because the math wouldn't add up... + * Note we assume that each MCV will match at most one member + * of the other MCV list. If the operator isn't really + * equality, there could be multiple matches --- but we don't + * look for them, both for speed and because the math wouldn't + * add up... */ matchprodfreq = 0.0; nmatches = 0; for (i = 0; i < nvalues1; i++) { - int j; + int j; for (j = 0; j < nvalues2; j++) { @@ -1450,19 +1467,21 @@ eqjoinsel(PG_FUNCTION_ARGS) } pfree(hasmatch1); pfree(hasmatch2); + /* * Compute total frequency of non-null values that are not in * the MCV lists. */ otherfreq1 = 1.0 - stats1->stanullfrac - matchfreq1 - unmatchfreq1; otherfreq2 = 1.0 - stats2->stanullfrac - matchfreq2 - unmatchfreq2; + /* - * We can estimate the total selectivity from the point of view - * of relation 1 as: the known selectivity for matched MCVs, plus - * unmatched MCVs that are assumed to match against random members - * of relation 2's non-MCV population, plus non-MCV values that - * are assumed to match against random members of relation 2's - * unmatched MCVs plus non-MCV values. + * We can estimate the total selectivity from the point of + * view of relation 1 as: the known selectivity for matched + * MCVs, plus unmatched MCVs that are assumed to match against + * random members of relation 2's non-MCV population, plus + * non-MCV values that are assumed to match against random + * members of relation 2's unmatched MCVs plus non-MCV values. */ totalsel1 = matchprodfreq; if (nd2 > nvalues2) @@ -1477,33 +1496,36 @@ eqjoinsel(PG_FUNCTION_ARGS) if (nd1 > nmatches) totalsel2 += otherfreq2 * (otherfreq1 + unmatchfreq1) / (nd1 - nmatches); + /* - * Use the smaller of the two estimates. This can be justified - * in essentially the same terms as given below for the no-stats - * case: to a first approximation, we are estimating from the - * point of view of the relation with smaller nd. + * Use the smaller of the two estimates. This can be + * justified in essentially the same terms as given below for + * the no-stats case: to a first approximation, we are + * estimating from the point of view of the relation with + * smaller nd. */ selec = (totalsel1 < totalsel2) ? totalsel1 : totalsel2; } else { /* - * We do not have MCV lists for both sides. Estimate the - * join selectivity as MIN(1/nd1, 1/nd2). This is plausible - * if we assume that the values are about equally distributed: - * a given tuple of rel1 will join to either 0 or N2/nd2 rows - * of rel2, so total join rows are at most N1*N2/nd2 giving - * a join selectivity of not more than 1/nd2. By the same logic + * We do not have MCV lists for both sides. Estimate the join + * selectivity as MIN(1/nd1, 1/nd2). This is plausible if we + * assume that the values are about equally distributed: a + * given tuple of rel1 will join to either 0 or N2/nd2 rows of + * rel2, so total join rows are at most N1*N2/nd2 giving a + * join selectivity of not more than 1/nd2. By the same logic * it is not more than 1/nd1, so MIN(1/nd1, 1/nd2) is an upper * bound. Using the MIN() means we estimate from the point of - * view of the relation with smaller nd (since the larger nd is - * determining the MIN). It is reasonable to assume that most - * tuples in this rel will have join partners, so the bound is - * probably reasonably tight and should be taken as-is. + * view of the relation with smaller nd (since the larger nd + * is determining the MIN). It is reasonable to assume that + * most tuples in this rel will have join partners, so the + * bound is probably reasonably tight and should be taken + * as-is. * - * XXX Can we be smarter if we have an MCV list for just one side? - * It seems that if we assume equal distribution for the other - * side, we end up with the same answer anyway. + * XXX Can we be smarter if we have an MCV list for just one + * side? It seems that if we assume equal distribution for the + * other side, we end up with the same answer anyway. */ if (nd1 > nd2) selec = 1.0 / nd1; @@ -1545,9 +1567,9 @@ neqjoinsel(PG_FUNCTION_ARGS) if (eqop) { result = DatumGetFloat8(DirectFunctionCall3(eqjoinsel, - PointerGetDatum(root), - ObjectIdGetDatum(eqop), - PointerGetDatum(args))); + PointerGetDatum(root), + ObjectIdGetDatum(eqop), + PointerGetDatum(args))); } else @@ -1702,9 +1724,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, { switch (valuetypid) { - /* - * Built-in numeric types - */ + /* + * Built-in numeric types + */ case BOOLOID: case INT2OID: case INT4OID: @@ -1719,9 +1741,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, *scaledhibound = convert_numeric_to_scalar(hibound, boundstypid); return true; - /* - * Built-in string types - */ + /* + * Built-in string types + */ case CHAROID: case BPCHAROID: case VARCHAROID: @@ -1741,9 +1763,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, return true; } - /* - * Built-in bytea type - */ + /* + * Built-in bytea type + */ case BYTEAOID: { convert_bytea_to_scalar(value, scaledvalue, @@ -1752,9 +1774,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, return true; } - /* - * Built-in time types - */ + /* + * Built-in time types + */ case TIMESTAMPOID: case TIMESTAMPTZOID: case ABSTIMEOID: @@ -1769,9 +1791,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, *scaledhibound = convert_timevalue_to_scalar(hibound, boundstypid); return true; - /* - * Built-in network types - */ + /* + * Built-in network types + */ case INETOID: case CIDROID: case MACADDROID: @@ -1975,7 +1997,6 @@ convert_string_datum(Datum value, Oid typid) char *xfrmstr; size_t xfrmsize; size_t xfrmlen; - #endif switch (typid) @@ -2016,7 +2037,7 @@ convert_string_datum(Datum value, Oid typid) #ifdef USE_LOCALE /* Guess that transformed string is not much bigger than original */ - xfrmsize = strlen(val) + 32;/* arbitrary pad value here... */ + xfrmsize = strlen(val) + 32; /* arbitrary pad value here... */ xfrmstr = (char *) palloc(xfrmsize); xfrmlen = strxfrm(xfrmstr, val, xfrmsize); if (xfrmlen >= xfrmsize) @@ -2060,8 +2081,8 @@ convert_bytea_to_scalar(Datum value, i, minlen; unsigned char *valstr = (unsigned char *) VARDATA(DatumGetPointer(value)), - *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)), - *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound)); + *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)), + *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound)); /* * Assume bytea data is uniformly distributed across all byte values. @@ -2101,8 +2122,8 @@ convert_one_bytea_to_scalar(unsigned char *value, int valuelen, return 0.0; /* empty string has scalar value 0 */ /* - * Since base is 256, need not consider more than about 10 - * chars (even this many seems like overkill) + * Since base is 256, need not consider more than about 10 chars (even + * this many seems like overkill) */ if (valuelen > 10) valuelen = 10; @@ -2214,12 +2235,13 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats) ntuples = rel->tuples; if (ntuples <= 0.0) - return DEFAULT_NUM_DISTINCT; /* no data available; return a default */ + return DEFAULT_NUM_DISTINCT; /* no data available; return a + * default */ /* - * Look to see if there is a unique index on the attribute. - * If so, we assume it's distinct, ignoring pg_statistic info - * which could be out of date. + * Look to see if there is a unique index on the attribute. If so, we + * assume it's distinct, ignoring pg_statistic info which could be out + * of date. */ if (has_unique_index(rel, var->varattno)) return ntuples; @@ -2232,12 +2254,12 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats) if (stats->stadistinct > 0.0) return stats->stadistinct; if (stats->stadistinct < 0.0) - return - stats->stadistinct * ntuples; + return -stats->stadistinct * ntuples; } /* - * ANALYZE does not compute stats for system attributes, - * but some of them can reasonably be assumed unique anyway. + * ANALYZE does not compute stats for system attributes, but some of + * them can reasonably be assumed unique anyway. */ switch (var->varattno) { @@ -2249,7 +2271,8 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats) } /* - * Estimate ndistinct = ntuples if the table is small, else use default. + * Estimate ndistinct = ntuples if the table is small, else use + * default. */ if (ntuples < DEFAULT_NUM_DISTINCT) return ntuples; @@ -2260,7 +2283,7 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats) /* * get_restriction_var * Examine the args of a restriction clause to see if it's of the - * form (var op something) or (something op var). If so, extract + * form (var op something) or (something op var). If so, extract * and return the var and the other argument. * * Inputs: @@ -2492,7 +2515,6 @@ regex_fixed_prefix(char *patt, bool case_insensitive, /* note start at pos 1 to skip leading ^ */ for (pos = 1; patt[pos]; pos++) { - /* * Check for characters that indicate multiple possible matches * here. XXX I suspect isalpha() is not an adequately @@ -2609,8 +2631,8 @@ prefix_selectivity(Query *root, Var *var, char *prefix) /* Assume scalargtsel is appropriate for all supported types */ prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel, PointerGetDatum(root), - ObjectIdGetDatum(cmpopr), - PointerGetDatum(cmpargs), + ObjectIdGetDatum(cmpopr), + PointerGetDatum(cmpargs), Int32GetDatum(0))); /*------- @@ -2632,8 +2654,8 @@ prefix_selectivity(Query *root, Var *var, char *prefix) /* Assume scalarltsel is appropriate for all supported types */ topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel, PointerGetDatum(root), - ObjectIdGetDatum(cmpopr), - PointerGetDatum(cmpargs), + ObjectIdGetDatum(cmpopr), + PointerGetDatum(cmpargs), Int32GetDatum(0))); /* @@ -2655,7 +2677,6 @@ prefix_selectivity(Query *root, Var *var, char *prefix) { if (prefixsel < -0.01) { - /* * No data available --- use a default estimate that is * small, but not real small. @@ -2664,7 +2685,6 @@ prefix_selectivity(Query *root, Var *var, char *prefix) } else { - /* * It's just roundoff error; use a small positive value */ @@ -2738,7 +2758,7 @@ regex_selectivity_sub(char *patt, int pattlen, bool case_insensitive) if (patt[pos] == '(') { if (paren_depth == 0) - paren_pos = pos;/* remember start of parenthesized item */ + paren_pos = pos; /* remember start of parenthesized item */ paren_depth++; } else if (patt[pos] == ')' && paren_depth > 0) @@ -2751,7 +2771,6 @@ regex_selectivity_sub(char *patt, int pattlen, bool case_insensitive) } else if (patt[pos] == '|' && paren_depth == 0) { - /* * If unquoted | is present at paren level 0 in pattern, we * have multiple alternatives; sum their probabilities. @@ -3091,30 +3110,31 @@ genericcostestimate(Query *root, RelOptInfo *rel, List *selectivityQuals = indexQuals; /* - * If the index is partial, AND the index predicate with the explicitly - * given indexquals to produce a more accurate idea of the index - * restriction. This may produce redundant clauses, which we hope that - * cnfify and clauselist_selectivity will deal with intelligently. + * If the index is partial, AND the index predicate with the + * explicitly given indexquals to produce a more accurate idea of the + * index restriction. This may produce redundant clauses, which we + * hope that cnfify and clauselist_selectivity will deal with + * intelligently. * - * Note that index->indpred and indexQuals are both in implicit-AND - * form to start with, which we have to make explicit to hand to + * Note that index->indpred and indexQuals are both in implicit-AND form + * to start with, which we have to make explicit to hand to * canonicalize_qual, and then we get back implicit-AND form again. */ if (index->indpred != NIL) { - Expr *andedQuals; + Expr *andedQuals; andedQuals = make_ands_explicit(nconc(listCopy(index->indpred), indexQuals)); selectivityQuals = canonicalize_qual(andedQuals, true); } - /* Estimate the fraction of main-table tuples that will be visited */ - *indexSelectivity = clauselist_selectivity(root, selectivityQuals, - lfirsti(rel->relids)); + /* Estimate the fraction of main-table tuples that will be visited */ + *indexSelectivity = clauselist_selectivity(root, selectivityQuals, + lfirsti(rel->relids)); /* - * Estimate the number of tuples that will be visited. We do it in + * Estimate the number of tuples that will be visited. We do it in * this rather peculiar-looking way in order to get the right answer * for partial indexes. We can bound the number of tuples by the * index size, in any case. @@ -3124,14 +3144,14 @@ genericcostestimate(Query *root, RelOptInfo *rel, if (numIndexTuples > index->tuples) numIndexTuples = index->tuples; - /* + /* * Always estimate at least one tuple is touched, even when * indexSelectivity estimate is tiny. */ if (numIndexTuples < 1.0) numIndexTuples = 1.0; - /* + /* * Estimate the number of index pages that will be retrieved. * * For all currently-supported index types, the first page of the index @@ -3185,11 +3205,11 @@ btcostestimate(PG_FUNCTION_ARGS) /* * If it's a functional index, leave the default zero-correlation - * estimate in place. If not, and if we can get an estimate for - * the first variable's ordering correlation C from pg_statistic, - * estimate the index correlation as C / number-of-columns. - * (The idea here is that multiple columns dilute the importance - * of the first column's ordering, but don't negate it entirely.) + * estimate in place. If not, and if we can get an estimate for the + * first variable's ordering correlation C from pg_statistic, estimate + * the index correlation as C / number-of-columns. (The idea here is + * that multiple columns dilute the importance of the first column's + * ordering, but don't negate it entirely.) */ if (index->indproc == InvalidOid) { @@ -3204,10 +3224,10 @@ btcostestimate(PG_FUNCTION_ARGS) 0, 0); if (HeapTupleIsValid(tuple)) { - Oid typid; - int32 typmod; - float4 *numbers; - int nnumbers; + Oid typid; + int32 typmod; + float4 *numbers; + int nnumbers; get_atttypetypmod(relid, index->indexkeys[0], &typid, &typmod); @@ -3216,13 +3236,13 @@ btcostestimate(PG_FUNCTION_ARGS) index->ordering[0], NULL, NULL, &numbers, &nnumbers)) { - double varCorrelation; - int nKeys; + double varCorrelation; + int nKeys; Assert(nnumbers == 1); varCorrelation = numbers[0]; for (nKeys = 1; index->indexkeys[nKeys] != 0; nKeys++) - /*skip*/; + /* skip */ ; *indexCorrelation = varCorrelation / nKeys; diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 4385b003de..623d3178e0 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.27 2001/09/17 00:29:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.28 2001/10/25 05:49:45 momjian Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -116,7 +116,6 @@ tidne(PG_FUNCTION_ARGS) BlockIdGetBlockNumber(&(arg2->ip_blkid)) || arg1->ip_posid != arg2->ip_posid); } - #endif /* @@ -125,7 +124,7 @@ tidne(PG_FUNCTION_ARGS) * Maybe these implementations should be moved to another place */ -static ItemPointerData Current_last_tid = { {0, 0}, 0}; +static ItemPointerData Current_last_tid = {{0, 0}, 0}; void setLastTid(const ItemPointer tid) @@ -142,11 +141,11 @@ currtid_byreloid(PG_FUNCTION_ARGS) Relation rel; result = (ItemPointer) palloc(sizeof(ItemPointerData)); - if (!reloid) - { - *result = Current_last_tid; - PG_RETURN_ITEMPOINTER(result); - } + if (!reloid) + { + *result = Current_last_tid; + PG_RETURN_ITEMPOINTER(result); + } ItemPointerCopy(tid, result); if ((rel = heap_open(reloid, AccessShareLock)) != NULL) { diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index f39e85b235..7bb5bcab88 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.58 2001/10/20 01:02:18 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.59 2001/10/25 05:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,6 +47,7 @@ Datum timestamp_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -146,7 +147,7 @@ timestamp_scale(PG_FUNCTION_ARGS) static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod) { - if (! TIMESTAMP_NOT_FINITE(*time) && + if (!TIMESTAMP_NOT_FINITE(*time) && (typmod >= 0) && (typmod <= 13)) { static double TimestampScale = 1; @@ -158,7 +159,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) TimestampTypmod = typmod; } - *time = (rint(((double) *time) * TimestampScale)/TimestampScale); + *time = (rint(((double) *time) * TimestampScale) / TimestampScale); } } @@ -170,11 +171,12 @@ Datum timestamptz_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif int32 typmod = PG_GETARG_INT32(2); - TimestampTz result; + TimestampTz result; double fsec; struct tm tt, *tm = &tt; @@ -229,7 +231,7 @@ timestamptz_in(PG_FUNCTION_ARGS) Datum timestamptz_out(PG_FUNCTION_ARGS) { - TimestampTz dt = PG_GETARG_TIMESTAMP(0); + TimestampTz dt = PG_GETARG_TIMESTAMP(0); char *result; int tz; struct tm tt, @@ -256,9 +258,9 @@ timestamptz_out(PG_FUNCTION_ARGS) Datum timestamptz_scale(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); int32 typmod = PG_GETARG_INT32(1); - TimestampTz result; + TimestampTz result; result = timestamp; @@ -278,6 +280,7 @@ Datum interval_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -374,8 +377,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { if (typmod != -1) { - int range = ((typmod >> 16) & 0x7FFF); - int precision = (typmod & 0xFFFF); + int range = ((typmod >> 16) & 0x7FFF); + int precision = (typmod & 0xFFFF); if (range == 0x7FFF) { @@ -392,69 +395,65 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) interval->time = 0; } /* YEAR TO MONTH */ - else if (range == (MASK(YEAR) | MASK(MONTH))) - { + else if (range == (MASK(YEAR) | MASK(MONTH))) interval->time = 0; - } else if (range == MASK(DAY)) { interval->month = 0; - interval->time = (((int)(interval->time / 86400)) * 86400); + interval->time = (((int) (interval->time / 86400)) * 86400); } else if (range == MASK(HOUR)) { - double day; + double day; interval->month = 0; TMODULO(interval->time, day, 86400.0); - interval->time = (((int)(interval->time / 3600)) * 3600.0); + interval->time = (((int) (interval->time / 3600)) * 3600.0); } else if (range == MASK(MINUTE)) { - double hour; + double hour; interval->month = 0; TMODULO(interval->time, hour, 3600.0); - interval->time = (((int)(interval->time / 60)) * 60); + interval->time = (((int) (interval->time / 60)) * 60); } else if (range == MASK(SECOND)) { - double hour; + double hour; interval->month = 0; TMODULO(interval->time, hour, 60.0); -// interval->time = (int)(interval->time); +/* interval->time = (int)(interval->time); */ } /* DAY TO HOUR */ else if (range == (MASK(DAY) | MASK(HOUR))) { interval->month = 0; - interval->time = (((int)(interval->time / 3600)) * 3600); + interval->time = (((int) (interval->time / 3600)) * 3600); } /* DAY TO MINUTE */ else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE))) { interval->month = 0; - interval->time = (((int)(interval->time / 60)) * 60); + interval->time = (((int) (interval->time / 60)) * 60); } /* DAY TO SECOND */ else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE) | MASK(SECOND))) - { interval->month = 0; - } /* HOUR TO MINUTE */ else if (range == (MASK(HOUR) | MASK(MINUTE))) { - double day; + double day; interval->month = 0; TMODULO(interval->time, day, 86400.0); - interval->time = (((int)(interval->time / 60)) * 60); + interval->time = (((int) (interval->time / 60)) * 60); } /* HOUR TO SECOND */ else if (range == (MASK(HOUR) | MASK(MINUTE) | MASK(SECOND))) { - double day; + double day; interval->month = 0; TMODULO(interval->time, day, 86400.0); @@ -462,20 +461,18 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) /* MINUTE TO SECOND */ else if (range == (MASK(MINUTE) | MASK(SECOND))) { - double hour; + double hour; interval->month = 0; TMODULO(interval->time, hour, 3600.0); } else - { elog(ERROR, "AdjustIntervalForTypmod(): internal coding error"); - } if (precision != 0xFFFF) { static double IntervalScale = 1; - static int IntervalTypmod = 0; + static int IntervalTypmod = 0; if (precision != IntervalTypmod) { @@ -483,15 +480,15 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) IntervalScale = pow(10.0, IntervalTypmod); } - /* Hmm. For the time field, we can get to a large value - * since we store everything related to an absolute interval - * (e.g. years worth of days) in this one field. So we have + /* + * Hmm. For the time field, we can get to a large value since + * we store everything related to an absolute interval (e.g. + * years worth of days) in this one field. So we have * precision problems doing rint() on this field if the field - * is too large. This resulted in an annoying "...0001" appended - * to the printed result on my Linux box. - * I hate doing an expensive math operation like log10() - * to avoid this, but what else can we do?? - * - thomas 2001-10-19 + * is too large. This resulted in an annoying "...0001" + * appended to the printed result on my Linux box. I hate + * doing an expensive math operation like log10() to avoid + * this, but what else can we do?? - thomas 2001-10-19 */ if ((log10(interval->time) + IntervalTypmod) <= 13) interval->time = (rint(interval->time * IntervalScale) / IntervalScale); @@ -521,7 +518,7 @@ EncodeSpecialTimestamp(Timestamp dt, char *str) Datum now(PG_FUNCTION_ARGS) { - TimestampTz result; + TimestampTz result; AbsoluteTime sec; int usec; @@ -571,14 +568,14 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn) #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) struct tm *tx; - #endif date0 = date2j(2000, 1, 1); - /* If HasCTZSet is true then we have a brute force time zone specified. - * Go ahead and rotate to the local time zone since we will later bypass - * any calls which adjust the tm fields. + /* + * If HasCTZSet is true then we have a brute force time zone + * specified. Go ahead and rotate to the local time zone since we will + * later bypass any calls which adjust the tm fields. */ if (HasCTZSet && (tzp != NULL)) dt -= CTimeZone; @@ -607,9 +604,9 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn) if (tzp != NULL) { - /* We have a brute force time zone per SQL99? - * Then use it without change - * since we have already rotated to the time zone. + /* + * We have a brute force time zone per SQL99? Then use it without + * change since we have already rotated to the time zone. */ if (HasCTZSet) { @@ -623,8 +620,9 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn) *tzn = NULL; } - /* Does this fall within the capabilities of the localtime() interface? - * Then use this to rotate to the local time zone. + /* + * Does this fall within the capabilities of the localtime() + * interface? Then use this to rotate to the local time zone. */ else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday)) { @@ -1031,7 +1029,6 @@ interval_hash(PG_FUNCTION_ARGS) Datum overlaps_timestamp(PG_FUNCTION_ARGS) { - /* * The arguments are Timestamps, but we leave them as generic Datums * to avoid unnecessary conversions between value and reference forms @@ -1101,7 +1098,6 @@ overlaps_timestamp(PG_FUNCTION_ARGS) */ if (TIMESTAMP_GT(ts1, ts2)) { - /* * This case is ts1 < te2 OR te1 < te2, which may look redundant * but in the presence of nulls it's not quite completely so. @@ -1137,7 +1133,6 @@ overlaps_timestamp(PG_FUNCTION_ARGS) } else { - /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a * rather silly way of saying "true if both are nonnull, else @@ -1225,9 +1220,7 @@ timestamp_pl_span(PG_FUNCTION_ARGS) Timestamp result; if (TIMESTAMP_NOT_FINITE(timestamp)) - { result = timestamp; - } else { if (span->month != 0) @@ -1309,16 +1302,14 @@ timestamp_mi_span(PG_FUNCTION_ARGS) Datum timestamptz_pl_span(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); Interval *span = PG_GETARG_INTERVAL_P(1); - TimestampTz result; + TimestampTz result; int tz; char *tzn; if (TIMESTAMP_NOT_FINITE(timestamp)) - { result = timestamp; - } else { if (span->month != 0) @@ -1349,7 +1340,7 @@ timestamptz_pl_span(PG_FUNCTION_ARGS) if (tm2timestamp(tm, fsec, &tz, ×tamp) != 0) elog(ERROR, "Unable to add TIMESTAMP and INTERVAL" - "\n\ttimestamptz_pl_span() internal error encoding timestamp"); + "\n\ttimestamptz_pl_span() internal error encoding timestamp"); } else { @@ -1373,7 +1364,7 @@ timestamptz_pl_span(PG_FUNCTION_ARGS) Datum timestamptz_mi_span(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); Interval *span = PG_GETARG_INTERVAL_P(1); Interval tspan; @@ -1584,8 +1575,8 @@ interval_accum(PG_FUNCTION_ARGS) memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval)); newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl, - IntervalPGetDatum(&sumX), - IntervalPGetDatum(newval))); + IntervalPGetDatum(&sumX), + IntervalPGetDatum(newval))); N.time += 1; transdatums[0] = IntervalPGetDatum(newsum); @@ -1750,8 +1741,8 @@ timestamp_age(PG_FUNCTION_ARGS) Datum timestamptz_age(PG_FUNCTION_ARGS) { - TimestampTz dt1 = PG_GETARG_TIMESTAMP(0); - TimestampTz dt2 = PG_GETARG_TIMESTAMP(1); + TimestampTz dt1 = PG_GETARG_TIMESTAMP(0); + TimestampTz dt2 = PG_GETARG_TIMESTAMP(1); Interval *result; double fsec, fsec1, @@ -1978,7 +1969,7 @@ interval_text(PG_FUNCTION_ARGS) int len; str = DatumGetCString(DirectFunctionCall1(interval_out, - IntervalPGetDatum(interval))); + IntervalPGetDatum(interval))); len = (strlen(str) + VARHDRSZ); @@ -2043,7 +2034,7 @@ timestamp_trunc(PG_FUNCTION_ARGS) if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) elog(ERROR, "TIMESTAMP units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); up = VARDATA(units); lp = lowunits; for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++) @@ -2113,8 +2104,8 @@ Datum timestamptz_trunc(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_P(0); - TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); - TimestampTz result; + TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); + TimestampTz result; int tz; int type, val; @@ -2130,7 +2121,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS) if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) elog(ERROR, "TIMESTAMP WITH TIME ZONE units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); up = VARDATA(units); lp = lowunits; for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++) @@ -2218,7 +2209,7 @@ interval_trunc(PG_FUNCTION_ARGS) if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) elog(ERROR, "INTERVAL units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); up = VARDATA(units); lp = lowunits; for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++) @@ -2281,7 +2272,7 @@ interval_trunc(PG_FUNCTION_ARGS) { elog(ERROR, "INTERVAL units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); *result = *interval; } @@ -2390,7 +2381,7 @@ timestamp_part(PG_FUNCTION_ARGS) if (VARSIZE(units) - VARHDRSZ > MAXDATELEN) elog(ERROR, "TIMESTAMP units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); up = VARDATA(units); lp = lowunits; for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++) @@ -2517,7 +2508,7 @@ Datum timestamptz_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_P(0); - TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); float8 result; int tz; int type, @@ -2756,7 +2747,7 @@ interval_part(PG_FUNCTION_ARGS) default: elog(ERROR, "INTERVAL units '%s' not supported", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); result = 0; } @@ -2781,7 +2772,7 @@ interval_part(PG_FUNCTION_ARGS) { elog(ERROR, "INTERVAL units '%s' not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))); + PointerGetDatum(units)))); result = 0; } @@ -2797,7 +2788,7 @@ timestamp_zone(PG_FUNCTION_ARGS) { text *zone = PG_GETARG_TEXT_P(0); Timestamp timestamp = PG_GETARG_TIMESTAMP(1); - TimestampTz result; + TimestampTz result; int tz; int type, val; @@ -2845,7 +2836,7 @@ timestamp_izone(PG_FUNCTION_ARGS) { Interval *zone = PG_GETARG_INTERVAL_P(0); Timestamp timestamp = PG_GETARG_TIMESTAMP(1); - TimestampTz result; + TimestampTz result; int tz; if (TIMESTAMP_NOT_FINITE(timestamp)) @@ -2869,16 +2860,14 @@ Datum timestamp_timestamptz(PG_FUNCTION_ARGS) { Timestamp timestamp = PG_GETARG_TIMESTAMP(0); - TimestampTz result; + TimestampTz result; struct tm tt, *tm = &tt; double fsec; int tz; if (TIMESTAMP_NOT_FINITE(timestamp)) - { result = timestamp; - } else { if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0) @@ -2899,7 +2888,7 @@ timestamp_timestamptz(PG_FUNCTION_ARGS) Datum timestamptz_timestamp(PG_FUNCTION_ARGS) { - TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(0); Timestamp result; struct tm tt, *tm = &tt; @@ -2908,9 +2897,7 @@ timestamptz_timestamp(PG_FUNCTION_ARGS) int tz; if (TIMESTAMP_NOT_FINITE(timestamp)) - { result = timestamp; - } else { if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0) @@ -2930,9 +2917,9 @@ Datum timestamptz_zone(PG_FUNCTION_ARGS) { text *zone = PG_GETARG_TEXT_P(0); - TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); text *result; - TimestampTz dt; + TimestampTz dt; int tz; int type, val; @@ -3007,9 +2994,9 @@ Datum timestamptz_izone(PG_FUNCTION_ARGS) { Interval *zone = PG_GETARG_INTERVAL_P(0); - TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); + TimestampTz timestamp = PG_GETARG_TIMESTAMP(1); text *result; - TimestampTz dt; + TimestampTz dt; int tz; char *tzn = ""; double fsec; @@ -3033,7 +3020,7 @@ timestamptz_izone(PG_FUNCTION_ARGS) if (timestamp2tm(dt, NULL, tm, &fsec, NULL) != 0) elog(ERROR, "Unable to decode TIMESTAMP WITH TIME ZONE" - "\n\ttimestamptz_izone() internal coding error"); + "\n\ttimestamptz_izone() internal coding error"); EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf); len = (strlen(buf) + VARHDRSZ); diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index a294bfc9ff..b1304fbae7 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.19 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.20 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,6 @@ bit_in(PG_FUNCTION_ARGS) #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); - #endif int32 atttypmod = PG_GETARG_INT32(2); VarBit *result; /* The resulting bit string */ @@ -77,7 +76,6 @@ bit_in(PG_FUNCTION_ARGS) } else { - /* * Otherwise it's binary. This allows things like cast('1001' as * bit) to work transparently. @@ -233,8 +231,8 @@ _bit(PG_FUNCTION_ARGS) FunctionCallInfoData locfcinfo; /* - * Since bit() is a built-in function, we should only need to look - * it up once per run. + * Since bit() is a built-in function, we should only need to look it + * up once per run. */ static FmgrInfo bit_finfo; @@ -264,7 +262,6 @@ varbit_in(PG_FUNCTION_ARGS) #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); - #endif int32 atttypmod = PG_GETARG_INT32(2); VarBit *result; /* The resulting bit string */ @@ -733,7 +730,6 @@ bitsubstr(PG_FUNCTION_ARGS) } else { - /* * OK, we've got a true substring starting at position s1-1 and * ending at position e1-1 diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index c963709ac8..a09bed915f 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.84 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.85 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,23 +65,26 @@ Datum bpcharin(PG_FUNCTION_ARGS) { char *s = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif int32 atttypmod = PG_GETARG_INT32(2); BpChar *result; char *r; - size_t len, maxlen; + size_t len, + maxlen; int i; + #ifdef MULTIBYTE - int charlen; /* number of charcters in the input string */ - char *ermsg; + int charlen; /* number of charcters in the input string */ + char *ermsg; #endif len = strlen(s); #ifdef MULTIBYTE if ((ermsg = pg_verifymbstr(s, len))) - elog(ERROR,"%s",ermsg); + elog(ERROR, "%s", ermsg); charlen = pg_mbstrlen(s); #endif @@ -104,19 +107,21 @@ bpcharin(PG_FUNCTION_ARGS) { /* Verify that extra characters are spaces, and clip them off */ #ifdef MULTIBYTE - size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen); + size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen); + /* - * at this point, len is the actual BYTE length of the - * input string, maxlen is the max number of - * CHARACTERS allowed for this bpchar type. + * at this point, len is the actual BYTE length of the input + * string, maxlen is the max number of CHARACTERS allowed for this + * bpchar type. */ if (strspn(s + mbmaxlen, " ") == len - mbmaxlen) len = mbmaxlen; else elog(ERROR, "value too long for type character(%d)", maxlen); + /* - * XXX: at this point, maxlen is the necessary byte - * length, not the number of CHARACTERS! + * XXX: at this point, maxlen is the necessary byte length, not + * the number of CHARACTERS! */ maxlen = len; #else @@ -130,8 +135,8 @@ bpcharin(PG_FUNCTION_ARGS) else { /* - * XXX: at this point, maxlen is the necessary byte - * length, not the number of CHARACTERS! + * XXX: at this point, maxlen is the necessary byte length, not + * the number of CHARACTERS! */ maxlen = len + (maxlen - charlen); } @@ -194,9 +199,10 @@ bpchar(PG_FUNCTION_ARGS) char *r; char *s; int i; + #ifdef MULTIBYTE - int charlen; /* number of charcters in the input string - + VARHDRSZ*/ + int charlen; /* number of charcters in the input string + * + VARHDRSZ */ #endif len = VARSIZE(source); @@ -217,7 +223,7 @@ bpchar(PG_FUNCTION_ARGS) size_t maxmblen; maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ, - maxlen - VARHDRSZ) + VARHDRSZ; + maxlen - VARHDRSZ) + VARHDRSZ; for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++) if (*(VARDATA(source) + i) != ' ') @@ -225,6 +231,7 @@ bpchar(PG_FUNCTION_ARGS) maxlen - VARHDRSZ); len = maxmblen; + /* * XXX: at this point, maxlen is the necessary byte * length+VARHDRSZ, not the number of CHARACTERS! @@ -403,20 +410,23 @@ Datum varcharin(PG_FUNCTION_ARGS) { char *s = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif int32 atttypmod = PG_GETARG_INT32(2); VarChar *result; - size_t len, maxlen; + size_t len, + maxlen; + #ifdef MULTIBYTE - char *ermsg; + char *ermsg; #endif len = strlen(s); #ifdef MULTIBYTE if ((ermsg = pg_verifymbstr(s, len))) - elog(ERROR,"%s",ermsg); + elog(ERROR, "%s", ermsg); #endif maxlen = atttypmod - VARHDRSZ; @@ -424,7 +434,7 @@ varcharin(PG_FUNCTION_ARGS) { /* Verify that extra characters are spaces, and clip them off */ #ifdef MULTIBYTE - size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen); + size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen); if (strspn(s + mbmaxlen, " ") == len - mbmaxlen) len = mbmaxlen; @@ -499,7 +509,7 @@ varchar(PG_FUNCTION_ARGS) /* truncate multi-byte string preserving multi-byte boundary */ maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ, - maxlen - VARHDRSZ) + VARHDRSZ; + maxlen - VARHDRSZ) + VARHDRSZ; for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++) if (*(VARDATA(source) + i) != ' ') @@ -586,8 +596,8 @@ bpcharlen(PG_FUNCTION_ARGS) #ifdef MULTIBYTE PG_RETURN_INT32( - pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ) - ); + pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ) + ); #else PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ); #endif @@ -794,8 +804,8 @@ varcharlen(PG_FUNCTION_ARGS) #ifdef MULTIBYTE PG_RETURN_INT32( - pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ) - ); + pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ) + ); #else PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ); #endif diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 1c6de93f01..7b15cfa690 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.73 2001/09/14 17:46:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.74 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,21 +54,15 @@ byteain(PG_FUNCTION_ARGS) for (byte = 0, tp = inputText; *tp != '\0'; byte++) { if (tp[0] != '\\') - { tp++; - } - else if ( (tp[0] == '\\') && - (tp[1] >= '0' && tp[1] <= '3') && - (tp[2] >= '0' && tp[2] <= '7') && - (tp[3] >= '0' && tp[3] <= '7') ) - { + else if ((tp[0] == '\\') && + (tp[1] >= '0' && tp[1] <= '3') && + (tp[2] >= '0' && tp[2] <= '7') && + (tp[3] >= '0' && tp[3] <= '7')) tp += 4; - } - else if ( (tp[0] == '\\') && - (tp[1] == '\\') ) - { + else if ((tp[0] == '\\') && + (tp[1] == '\\')) tp += 2; - } else { /* @@ -87,13 +81,11 @@ byteain(PG_FUNCTION_ARGS) while (*tp != '\0') { if (tp[0] != '\\') - { *rp++ = *tp++; - } - else if ( (tp[0] == '\\') && - (tp[1] >= '0' && tp[1] <= '3') && - (tp[2] >= '0' && tp[2] <= '7') && - (tp[3] >= '0' && tp[3] <= '7') ) + else if ((tp[0] == '\\') && + (tp[1] >= '0' && tp[1] <= '3') && + (tp[2] >= '0' && tp[2] <= '7') && + (tp[3] >= '0' && tp[3] <= '7')) { byte = VAL(tp[1]); byte <<= 3; @@ -102,8 +94,8 @@ byteain(PG_FUNCTION_ARGS) *rp++ = byte + VAL(tp[3]); tp += 4; } - else if ( (tp[0] == '\\') && - (tp[1] == '\\') ) + else if ((tp[0] == '\\') && + (tp[1] == '\\')) { *rp++ = '\\'; tp += 2; @@ -111,8 +103,8 @@ byteain(PG_FUNCTION_ARGS) else { /* - * We should never get here. The first pass should - * not allow it. + * We should never get here. The first pass should not allow + * it. */ elog(ERROR, "Bad input string for type bytea"); } @@ -188,15 +180,16 @@ textin(PG_FUNCTION_ARGS) char *inputText = PG_GETARG_CSTRING(0); text *result; int len; + #ifdef MULTIBYTE - char *ermsg; + char *ermsg; #endif len = strlen(inputText) + VARHDRSZ; #ifdef MULTIBYTE if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ))) - elog(ERROR,"%s",ermsg); + elog(ERROR, "%s", ermsg); #endif result = (text *) palloc(len); @@ -368,7 +361,6 @@ text_substr(PG_FUNCTION_ARGS) #ifdef MULTIBYTE int i; char *p; - #endif len = VARSIZE(string) - VARHDRSZ; @@ -442,7 +434,6 @@ textpos(PG_FUNCTION_ARGS) #ifdef MULTIBYTE pg_wchar *ps1, *ps2; - #endif if (VARSIZE(t2) <= VARHDRSZ) @@ -819,8 +810,8 @@ byteapos(PG_FUNCTION_ARGS) p; int len1, len2; - char *p1, - *p2; + char *p1, + *p2; if (VARSIZE(t2) <= VARHDRSZ) PG_RETURN_INT32(1); /* result for empty pattern */ @@ -1072,8 +1063,8 @@ name_text(PG_FUNCTION_ARGS) Datum byteaeq(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; bool result; @@ -1096,8 +1087,8 @@ byteaeq(PG_FUNCTION_ARGS) Datum byteane(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; bool result; @@ -1120,8 +1111,8 @@ byteane(PG_FUNCTION_ARGS) Datum bytealt(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; int cmp; @@ -1140,8 +1131,8 @@ bytealt(PG_FUNCTION_ARGS) Datum byteale(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; int cmp; @@ -1160,8 +1151,8 @@ byteale(PG_FUNCTION_ARGS) Datum byteagt(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; int cmp; @@ -1180,8 +1171,8 @@ byteagt(PG_FUNCTION_ARGS) Datum byteage(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; int cmp; @@ -1200,8 +1191,8 @@ byteage(PG_FUNCTION_ARGS) Datum byteacmp(PG_FUNCTION_ARGS) { - bytea *arg1 = PG_GETARG_BYTEA_P(0); - bytea *arg2 = PG_GETARG_BYTEA_P(1); + bytea *arg1 = PG_GETARG_BYTEA_P(0); + bytea *arg2 = PG_GETARG_BYTEA_P(1); int len1, len2; int cmp; diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 77112a694e..fe347fe5fb 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.83 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.84 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,13 +30,13 @@ #include "utils/syscache.h" -/* #define CACHEDEBUG */ /* turns DEBUG elogs on */ + /* #define CACHEDEBUG *//* turns DEBUG elogs on */ /* * Constants related to size of the catcache. * * NCCBUCKETS should be prime and must be less than 64K (because - * SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In + * SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In * practice it should be a lot less, anyway, to avoid chewing up too much * space on hash bucket headers. * @@ -642,13 +642,13 @@ CatalogCacheFlushRelation(Oid relId) tupRelid = ct->tuple.t_data->t_oid; else { - bool isNull; + bool isNull; tupRelid = DatumGetObjectId( - fastgetattr(&ct->tuple, - cache->cc_reloidattr, - cache->cc_tupdesc, - &isNull)); + fastgetattr(&ct->tuple, + cache->cc_reloidattr, + cache->cc_tupdesc, + &isNull)); Assert(!isNull); } @@ -707,8 +707,8 @@ InitCatCache(int id, oldcxt = MemoryContextSwitchTo(CacheMemoryContext); /* - * if first time through, initialize the cache group header, - * including global LRU list header + * if first time through, initialize the cache group header, including + * global LRU list header */ if (CacheHdr == NULL) { @@ -740,7 +740,7 @@ InitCatCache(int id, cp->cc_relname = relname; cp->cc_indname = indname; cp->cc_reloidattr = reloidattr; - cp->cc_relisshared = false; /* temporary */ + cp->cc_relisshared = false; /* temporary */ cp->cc_tupdesc = (TupleDesc) NULL; cp->cc_ntup = 0; cp->cc_size = NCCBUCKETS; @@ -749,8 +749,8 @@ InitCatCache(int id, cp->cc_key[i] = key[i]; /* - * new cache is initialized as far as we can go for now. - * print some debugging information, if appropriate. + * new cache is initialized as far as we can go for now. print some + * debugging information, if appropriate. */ InitCatCache_DEBUG1; @@ -1105,9 +1105,7 @@ ReleaseCatCache(HeapTuple tuple) && ct->dead #endif ) - { CatCacheRemoveCTup(ct->my_cache, ct); - } } /* @@ -1141,7 +1139,7 @@ ReleaseCatCache(HeapTuple tuple) void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, - void (*function) (int, Index, ItemPointer, Oid)) + void (*function) (int, Index, ItemPointer, Oid)) { CatCache *ccp; diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index cd01bc9adc..9ebf5f3bf2 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -22,14 +22,14 @@ * second lives till end of transaction. Finally, we need a third list of * all tuples outdated in the current transaction; if we commit, we send * those invalidation events to all other backends (via the SI message queue) - * so that they can flush obsolete entries from their caches. This list + * so that they can flush obsolete entries from their caches. This list * definitely can't be processed until after we commit, otherwise the other * backends won't see our updated tuples as good. * * We do not need to register EVERY tuple operation in this way, just those - * on tuples in relations that have associated catcaches. We do, however, + * on tuples in relations that have associated catcaches. We do, however, * have to register every operation on every tuple that *could* be in a - * catcache, whether or not it currently is in our cache. Also, if the + * catcache, whether or not it currently is in our cache. Also, if the * tuple is in a relation that has multiple catcaches, we need to register * an invalidation message for each such catcache. catcache.c's * PrepareToInvalidateCacheTuple() routine provides the knowledge of which @@ -56,7 +56,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.45 2001/06/19 19:42:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.46 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,15 +74,15 @@ /* * To minimize palloc traffic, we keep pending requests in successively- * larger chunks (a slightly more sophisticated version of an expansible - * array). All request types can be stored as SharedInvalidationMessage + * array). All request types can be stored as SharedInvalidationMessage * records. */ typedef struct InvalidationChunk { - struct InvalidationChunk *next; /* list link */ + struct InvalidationChunk *next; /* list link */ int nitems; /* # items currently stored in chunk */ int maxitems; /* size of allocated array in this chunk */ - SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */ + SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */ } InvalidationChunk; /* VARIABLE LENGTH STRUCTURE */ typedef struct InvalidationListHeader @@ -148,7 +148,7 @@ AddInvalidationMessage(InvalidationChunk **listHdr, chunk = (InvalidationChunk *) MemoryContextAlloc(TopTransactionContext, sizeof(InvalidationChunk) + - (FIRSTCHUNKSIZE-1) * sizeof(SharedInvalidationMessage)); + (FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage)); chunk->nitems = 0; chunk->maxitems = FIRSTCHUNKSIZE; chunk->next = *listHdr; @@ -157,12 +157,12 @@ AddInvalidationMessage(InvalidationChunk **listHdr, else if (chunk->nitems >= chunk->maxitems) { /* Need another chunk; double size of last chunk */ - int chunksize = 2 * chunk->maxitems; + int chunksize = 2 * chunk->maxitems; chunk = (InvalidationChunk *) MemoryContextAlloc(TopTransactionContext, sizeof(InvalidationChunk) + - (chunksize-1) * sizeof(SharedInvalidationMessage)); + (chunksize - 1) *sizeof(SharedInvalidationMessage)); chunk->nitems = 0; chunk->maxitems = chunksize; chunk->next = *listHdr; @@ -279,7 +279,10 @@ DiscardInvalidationMessages(InvalidationListHeader *hdr, bool physicalFree) } else { - /* Assume the storage will go away at xact end, just reset pointers */ + /* + * Assume the storage will go away at xact end, just reset + * pointers + */ hdr->cclist = NULL; hdr->rclist = NULL; } @@ -421,7 +424,7 @@ InvalidateSystemCaches(void) static void PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, void (*CacheIdRegisterFunc) (int, Index, - ItemPointer, Oid), + ItemPointer, Oid), void (*RelationIdRegisterFunc) (Oid, Oid)) { Oid tupleRelId; @@ -460,12 +463,12 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, * Yes. We need to register a relcache invalidation event for the * relation identified by relationId. * - * KLUGE ALERT: we always send the relcache event with MyDatabaseId, - * even if the rel in question is shared. This essentially means that - * only backends in this same database will react to the relcache flush - * request. This is in fact appropriate, since only those backends could - * see our pg_class or pg_attribute change anyway. It looks a bit ugly - * though. + * KLUGE ALERT: we always send the relcache event with MyDatabaseId, even + * if the rel in question is shared. This essentially means that only + * backends in this same database will react to the relcache flush + * request. This is in fact appropriate, since only those backends + * could see our pg_class or pg_attribute change anyway. It looks a + * bit ugly though. */ (*RelationIdRegisterFunc) (MyDatabaseId, relationId); } @@ -498,7 +501,7 @@ AcceptInvalidationMessages(void) * If isCommit, we must send out the messages in our GlobalInvalidMsgs 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). Therefore, it's okay + * transaction start (via AcceptInvalidationMessages). Therefore, it's okay * to discard any pending LocalInvalidMsgs, since these will be redundant * with the global list. * @@ -538,7 +541,7 @@ AtEOXactInvalidationMessages(bool isCommit) * in a transaction. * * Here, we send no messages to the shared queue, since we don't know yet if - * we will commit. But we do need to locally process the LocalInvalidMsgs + * we will commit. But we do need to locally process the LocalInvalidMsgs * list, so as to flush our caches of any tuples we have outdated in the * current command. * @@ -563,9 +566,10 @@ CommandEndInvalidationMessages(bool isCommit) ProcessInvalidationMessages(&RollbackMsgs, LocalExecuteInvalidationMessage); } + /* - * LocalInvalidMsgs list is not interesting anymore, so flush it - * (for real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs. + * LocalInvalidMsgs list is not interesting anymore, so flush it (for + * real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs. */ DiscardInvalidationMessages(&LocalInvalidMsgs, true); } diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index b788383ba5..b359651b9b 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.58 2001/09/06 02:07:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.59 2001/10/25 05:49:46 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -589,7 +589,6 @@ get_relnatts(Oid relid) else return InvalidAttrNumber; } - #endif /* @@ -723,7 +722,6 @@ get_typalign(Oid typid) else return 'i'; } - #endif char @@ -778,8 +776,8 @@ get_typdefault(Oid typid, Datum *defaultValue) typelem = type->typelem; /* - * typdefault is potentially null, so don't try to access it as a struct - * field. Must do it the hard way with SysCacheGetAttr. + * typdefault is potentially null, so don't try to access it as a + * struct field. Must do it the hard way with SysCacheGetAttr. */ textDefaultVal = SysCacheGetAttr(TYPEOID, typeTuple, @@ -828,6 +826,7 @@ get_typavgwidth(Oid typid, int32 typmod) */ if (typlen > 0) return typlen; + /* * type_maximum_size knows the encoding of typmod for some datatypes; * don't duplicate that knowledge here. @@ -836,16 +835,17 @@ get_typavgwidth(Oid typid, int32 typmod) if (maxwidth > 0) { /* - * For BPCHAR, the max width is also the only width. Otherwise - * we need to guess about the typical data width given the max. - * A sliding scale for percentage of max width seems reasonable. + * For BPCHAR, the max width is also the only width. Otherwise we + * need to guess about the typical data width given the max. A + * sliding scale for percentage of max width seems reasonable. */ if (typid == BPCHAROID) return maxwidth; if (maxwidth <= 32) return maxwidth; /* assume full width */ if (maxwidth < 1000) - return 32 + (maxwidth - 32) / 2; /* assume 50% */ + return 32 + (maxwidth - 32) / 2; /* assume 50% */ + /* * Beyond 1000, assume we're looking at something like * "varchar(10000)" where the limit isn't actually reached often, @@ -853,6 +853,7 @@ get_typavgwidth(Oid typid, int32 typmod) */ return 32 + (1000 - 32) / 2; } + /* * Ooops, we have no idea ... wild guess time. */ @@ -887,7 +888,6 @@ get_typtype(Oid typid) else return '\0'; } - #endif /* ---------- STATISTICS CACHE ---------- */ @@ -909,7 +909,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum) 0, 0); if (HeapTupleIsValid(tp)) { - int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth; + int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth; ReleaseSysCache(tp); if (stawidth > 0) @@ -977,14 +977,17 @@ get_attstatsslot(HeapTuple statstuple, if (isnull) elog(ERROR, "get_attstatsslot: stavalues is null"); statarray = DatumGetArrayTypeP(val); + /* - * Do initial examination of the array. This produces a list - * of text Datums --- ie, pointers into the text array value. + * Do initial examination of the array. This produces a list of + * text Datums --- ie, pointers into the text array value. */ deconstruct_array(statarray, false, -1, 'i', values, nvalues); narrayelem = *nvalues; + /* - * We now need to replace each text Datum by its internal equivalent. + * We now need to replace each text Datum by its internal + * equivalent. * * Get the type input proc and typelem for the column datatype. */ @@ -997,9 +1000,10 @@ get_attstatsslot(HeapTuple statstuple, fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc); typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem; ReleaseSysCache(typeTuple); + /* - * Do the conversions. The palloc'd array of Datums is reused - * in place. + * Do the conversions. The palloc'd array of Datums is reused in + * place. */ for (j = 0; j < narrayelem; j++) { @@ -1013,6 +1017,7 @@ get_attstatsslot(HeapTuple statstuple, Int32GetDatum(atttypmod)); pfree(strval); } + /* * Free statarray if it's a detoasted copy. */ @@ -1028,10 +1033,11 @@ get_attstatsslot(HeapTuple statstuple, if (isnull) elog(ERROR, "get_attstatsslot: stanumbers is null"); statarray = DatumGetArrayTypeP(val); + /* - * We expect the array to be a 1-D float4 array; verify that. - * We don't need to use deconstruct_array() since the array - * data is just going to look like a C array of float4 values. + * We expect the array to be a 1-D float4 array; verify that. We + * don't need to use deconstruct_array() since the array data is + * just going to look like a C array of float4 values. */ narrayelem = ARR_DIMS(statarray)[0]; if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 || @@ -1040,6 +1046,7 @@ get_attstatsslot(HeapTuple statstuple, *numbers = (float4 *) palloc(narrayelem * sizeof(float4)); memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4)); *nnumbers = narrayelem; + /* * Free statarray if it's a detoasted copy. */ @@ -1057,9 +1064,9 @@ free_attstatsslot(Oid atttype, { if (values) { - if (! get_typbyval(atttype)) + if (!get_typbyval(atttype)) { - int i; + int i; for (i = 0; i < nvalues; i++) pfree(DatumGetPointer(values[i])); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index c56d606076..1073841f9d 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.146 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.147 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -226,7 +226,6 @@ static void RelationClearRelation(Relation relation, bool rebuildIt); #ifdef ENABLE_REINDEX_NAILED_RELATIONS static void RelationReloadClassinfo(Relation relation); - #endif /* ENABLE_REINDEX_NAILED_RELATIONS */ static void RelationFlushRelation(Relation relation); static Relation RelationNameCacheGetRelation(const char *relationName); @@ -273,7 +272,6 @@ static List *insert_ordered_oid(List *list, Oid datum); static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo) { - /* * If this is bootstrap time (initdb), then we can't use the system * catalog indices, because they may not exist yet. Otherwise, we @@ -333,7 +331,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo) return_tuple = pg_class_tuple; else { - /* * a satanic bug used to live here: pg_class_tuple used to be * returned here without having the corresponding buffer pinned. @@ -382,7 +379,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) default: elog(ERROR, "ScanPgRelation: bad buildinfo"); - return_tuple = NULL;/* keep compiler quiet */ + return_tuple = NULL; /* keep compiler quiet */ } heap_close(pg_class_desc, AccessShareLock); @@ -461,7 +458,6 @@ static void RelationBuildTupleDesc(RelationBuildDescInfo buildinfo, Relation relation) { - /* * If this is bootstrap time (initdb), then we can't use the system * catalog indices, because they may not exist yet. Otherwise, we @@ -649,7 +645,6 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo, { #ifdef _DROP_COLUMN_HACK__ bool columnDropped = false; - #endif /* _DROP_COLUMN_HACK__ */ atttup = AttributeRelidNumIndexScan(attrel, @@ -767,7 +762,7 @@ RelationBuildRuleLock(Relation relation) */ rulescxt = AllocSetContextCreate(CacheMemoryContext, RelationGetRelationName(relation), - 0, /* minsize */ + 0, /* minsize */ 1024, /* initsize */ 1024); /* maxsize */ relation->rd_rulescxt = rulescxt; @@ -1106,16 +1101,16 @@ RelationInitIndexAccessInfo(Relation relation) amsupport = relation->rd_am->amsupport; /* - * Make the private context to hold index access info. The reason - * we need a context, and not just a couple of pallocs, is so that - * we won't leak any subsidiary info attached to fmgr lookup records. + * Make the private context to hold index access info. The reason we + * need a context, and not just a couple of pallocs, is so that we + * won't leak any subsidiary info attached to fmgr lookup records. * * Context parameters are set on the assumption that it'll probably not * contain much data. */ indexcxt = AllocSetContextCreate(CacheMemoryContext, RelationGetRelationName(relation), - 0, /* minsize */ + 0, /* minsize */ 512, /* initsize */ 1024); /* maxsize */ relation->rd_indexcxt = indexcxt; @@ -1128,7 +1123,7 @@ RelationInitIndexAccessInfo(Relation relation) if (amsupport > 0) { - int nsupport = natts * amsupport; + int nsupport = natts * amsupport; support = (RegProcedure *) MemoryContextAlloc(indexcxt, nsupport * sizeof(RegProcedure)); @@ -1214,8 +1209,9 @@ formrdesc(char *relationName, strcpy(RelationGetPhysicalRelationName(relation), 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. + * It's important to distinguish between shared and non-shared + * relations, even at bootstrap time, to make sure we know where they + * are stored. */ relation->rd_rel->relisshared = IsSharedSystemRelationName(relationName); @@ -1267,8 +1263,8 @@ formrdesc(char *relationName, if (!IsBootstrapProcessingMode()) { /* - * This list is incomplete, but it only has to work for the - * set of rels that formrdesc is used for ... + * This list is incomplete, but it only has to work for the set of + * rels that formrdesc is used for ... */ if (strcmp(relationName, RelationRelationName) == 0 || strcmp(relationName, AttributeRelationName) == 0 || @@ -1560,7 +1556,6 @@ RelationReloadClassinfo(Relation relation) return; } - #endif /* ENABLE_REINDEX_NAILED_RELATIONS */ /* @@ -1649,7 +1644,6 @@ RelationClearRelation(Relation relation, bool rebuildIt) } else { - /* * When rebuilding an open relcache entry, must preserve ref count * and myxactonly flag. Also attempt to preserve the tupledesc, @@ -1663,7 +1657,7 @@ RelationClearRelation(Relation relation, bool rebuildIt) RuleLock *old_rules = relation->rd_rules; MemoryContext old_rulescxt = relation->rd_rulescxt; TriggerDesc *old_trigdesc = relation->trigdesc; - BlockNumber old_nblocks = relation->rd_nblocks; + BlockNumber old_nblocks = relation->rd_nblocks; RelationBuildDescInfo buildinfo; buildinfo.infotype = INFO_RELID; @@ -1730,7 +1724,6 @@ RelationFlushRelation(Relation relation) if (relation->rd_myxactonly) { - /* * Local rels should always be rebuilt, not flushed; the relcache * entry must live until RelationPurgeLocalRelation(). @@ -1739,7 +1732,6 @@ RelationFlushRelation(Relation relation) } else { - /* * Nonlocal rels can be dropped from the relcache if not open. */ @@ -1837,7 +1829,6 @@ RelationFlushIndexes(Relation *r, relation->rd_rel->relam == accessMethodId)) RelationFlushRelation(relation); } - #endif @@ -1982,8 +1973,8 @@ RelationBuildLocalRelation(const char *relname, rel->rd_isnailed = true; /* - * create a new tuple descriptor from the one passed in - * (we do this to copy it into the cache context) + * create a new tuple descriptor from the one passed in (we do this to + * copy it into the cache context) */ rel->rd_att = CreateTupleDescCopyConstr(tupDesc); @@ -2003,9 +1994,10 @@ RelationBuildLocalRelation(const char *relname, rel->rd_rel->relchecks = tupDesc->constr->num_check; /* - * Insert relation OID and database/tablespace ID into the right places. - * XXX currently we assume physical tblspace/relnode are same as logical - * dbid/reloid. Probably should pass an extra pair of parameters. + * Insert relation OID and database/tablespace ID into the right + * places. XXX currently we assume physical tblspace/relnode are same + * as logical dbid/reloid. Probably should pass an extra pair of + * parameters. */ rel->rd_rel->relisshared = (dbid == InvalidOid); @@ -2149,7 +2141,6 @@ RelationCacheInitialize(void) void RelationCacheInitializePhase2(void) { - /* * Get the real pg_class tuple for each nailed-in-cache relcache entry * that was made by RelationCacheInitialize(), and replace the phony @@ -2159,7 +2150,6 @@ RelationCacheInitializePhase2(void) */ if (!IsBootstrapProcessingMode()) { - /* * Initialize critical system index relation descriptors, first. * They are to make building relation descriptors fast. @@ -2764,9 +2754,9 @@ init_irels(void) */ indexcxt = AllocSetContextCreate(CacheMemoryContext, RelationGetRelationName(ird), - 0, /* minsize */ - 512, /* initsize */ - 1024); /* maxsize */ + 0, /* minsize */ + 512, /* initsize */ + 1024); /* maxsize */ ird->rd_indexcxt = indexcxt; /* next, read the index strategy map */ @@ -2848,7 +2838,6 @@ write_irels(void) fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY, 0600); if (fd < 0) { - /* * We used to consider this a fatal error, but we might as well * continue with backend startup ... diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 6020597f2a..e629bf48e4 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.65 2001/08/21 16:36:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.66 2001/10/25 05:49:46 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -133,7 +133,7 @@ static struct cachedesc cacheinfo[] = { 0, 0 }}, - {AccessMethodProcedureRelationName, /* AMPROCNUM */ + {AccessMethodProcedureRelationName, /* AMPROCNUM */ AccessMethodProcedureIndex, 0, 2, @@ -365,7 +365,8 @@ static struct cachedesc cacheinfo[] = { }} }; -static CatCache *SysCache[lengthof(cacheinfo)]; +static CatCache *SysCache[ + lengthof(cacheinfo)]; static int SysCacheSize = lengthof(cacheinfo); static bool CacheInitialized = false; @@ -564,7 +565,6 @@ SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull) { - /* * We just need to get the TupleDesc out of the cache entry, and then * we can apply heap_getattr(). We expect that the cache control data diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 4e1ab2684c..d9554b9575 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.89 2001/10/18 23:07:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.90 2001/10/25 05:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,16 +135,15 @@ elog(int lev, const char *fmt,...) errorstr = useful_strerror(errno); /* - * Convert initialization errors into fatal errors. This is - * probably redundant, because Warn_restart_ready won't be set - * anyway. + * Convert initialization errors into fatal errors. This is probably + * redundant, because Warn_restart_ready won't be set anyway. */ if (lev == ERROR && IsInitProcessingMode()) lev = FATAL; /* - * If we are inside a critical section, all errors become - * REALLYFATAL errors. See miscadmin.h. + * If we are inside a critical section, all errors become REALLYFATAL + * errors. See miscadmin.h. */ if (lev == ERROR || lev == FATAL) { @@ -161,6 +160,7 @@ elog(int lev, const char *fmt,...) timestamp_size += PID_SIZE; fmt = gettext(fmt); + /* * Set up the expanded format, consisting of the prefix string plus * input format, with any %m replaced by strerror() string (since @@ -189,11 +189,11 @@ elog(int lev, const char *fmt,...) lev = ERROR; prefix = elog_message_prefix(lev); } + /* - * gettext doesn't allocate memory, except in the very - * first call (which this isn't), so it's safe to - * translate here. Worst case we get the untranslated - * string back. + * gettext doesn't allocate memory, except in the very first + * call (which this isn't), so it's safe to translate here. + * Worst case we get the untranslated string back. */ /* translator: This must fit in fmt_fixedbuf. */ fmt = gettext("elog: out of memory"); @@ -329,7 +329,7 @@ elog(int lev, const char *fmt,...) write_syslog(syslog_level, msg_buf + timestamp_size); } -#endif /* ENABLE_SYSLOG */ +#endif /* ENABLE_SYSLOG */ /* syslog doesn't want a trailing newline, but other destinations do */ strcat(msg_buf, "\n"); @@ -665,8 +665,7 @@ write_syslog(int level, const char *line) syslog(level, "[%lu] %s", seq, line); } } - -#endif /* ENABLE_SYSLOG */ +#endif /* ENABLE_SYSLOG */ static void @@ -682,22 +681,22 @@ send_message_to_frontend(int type, const char *msg) pq_endmessage(&buf); /* - * This flush is normally not necessary, since postgres.c will - * flush out waiting data when control returns to the main loop. - * But it seems best to leave it here, so that the client has some - * clue what happened if the backend dies before getting back to - * the main loop ... error/notice messages should not be a - * performance-critical path anyway, so an extra flush won't hurt - * much ... + * This flush is normally not necessary, since postgres.c will flush + * out waiting data when control returns to the main loop. But it + * seems best to leave it here, so that the client has some clue what + * happened if the backend dies before getting back to the main loop + * ... error/notice messages should not be a performance-critical path + * anyway, so an extra flush won't hurt much ... */ pq_flush(); } -static const char *useful_strerror(int errnum) +static const char * +useful_strerror(int errnum) { /* this buffer is only used if errno has a bogus value */ - static char errorstr_buf[48]; + static char errorstr_buf[48]; char *str; if (errnum == ERANGE) @@ -712,7 +711,10 @@ static const char *useful_strerror(int errnum) */ if (str == NULL || *str == '\0') { - /* translator: This string will be truncated at 47 characters expanded. */ + /* + * translator: This string will be truncated at 47 characters + * expanded. + */ snprintf(errorstr_buf, 48, gettext("operating system error %d"), errnum); str = errorstr_buf; } @@ -725,7 +727,7 @@ static const char *useful_strerror(int errnum) static const char * elog_message_prefix(int lev) { - const char * prefix = NULL; + const char *prefix = NULL; switch (lev) { diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c index ee64ecb5f0..d5400e72a0 100644 --- a/src/backend/utils/error/exc.c +++ b/src/backend/utils/error/exc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.37 2001/03/22 03:59:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.38 2001/10/25 05:49:46 momjian Exp $ * * NOTE * XXX this code needs improvement--check for state violations and @@ -138,16 +138,15 @@ ExcPrint(Exception *excP, } #ifdef NOT_USED -ExcProc * +ExcProc * ExcGetUnCaught(void) { return ExcUnCaughtP; } - #endif #ifdef NOT_USED -ExcProc * +ExcProc * ExcSetUnCaught(ExcProc *newP) { ExcProc *oldP = ExcUnCaughtP; @@ -156,7 +155,6 @@ ExcSetUnCaught(ExcProc *newP) return oldP; } - #endif static void diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 3085187d8a..1a1633cc57 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.53 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.54 2001/10/25 05:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,12 +46,12 @@ static DynamicFileList *file_tail = (DynamicFileList *) NULL; #define SAME_INODE(A,B) ((A).st_ino == (B).inode && (A).st_dev == (B).device) -char * Dynamic_library_path; +char *Dynamic_library_path; static bool file_exists(const char *name); -static char * find_in_dynamic_libpath(const char * basename); -static char * expand_dynamic_library_name(const char *name); -static char * substitute_libpath_macro(const char * name); +static char *find_in_dynamic_libpath(const char *basename); +static char *expand_dynamic_library_name(const char *name); +static char *substitute_libpath_macro(const char *name); /* * Load the specified dynamic-link library file, and look for a function @@ -237,7 +237,7 @@ file_exists(const char *name) if (stat(name, &st) == 0) return S_ISDIR(st.st_mode) ? false : true; else if (!(errno == ENOENT || errno == ENOTDIR || errno == EACCES)) - elog(ERROR, "stat failed on %s: %s", name, strerror(errno)); + elog(ERROR, "stat failed on %s: %s", name, strerror(errno)); return false; } @@ -258,7 +258,7 @@ file_exists(const char *name) * If name contains a slash, check if the file exists, if so return * the name. Else (no slash) try to expand using search path (see * find_in_dynamic_libpath below); if that works, return the fully - * expanded file name. If the previous failed, append DLSUFFIX and + * expanded file name. If the previous failed, append DLSUFFIX and * try again. If all fails, return NULL. * * A non-NULL result will always be freshly palloc'd. @@ -266,9 +266,9 @@ file_exists(const char *name) static char * expand_dynamic_library_name(const char *name) { - bool have_slash; - char * new; - char * full; + bool have_slash; + char *new; + char *full; AssertArg(name); @@ -288,7 +288,7 @@ expand_dynamic_library_name(const char *name) pfree(full); } - new = palloc(strlen(name)+ strlen(DLSUFFIX) + 1); + new = palloc(strlen(name) + strlen(DLSUFFIX) + 1); strcpy(new, name); strcat(new, DLSUFFIX); @@ -307,7 +307,7 @@ expand_dynamic_library_name(const char *name) return full; pfree(full); } - + return NULL; } @@ -317,10 +317,10 @@ expand_dynamic_library_name(const char *name) * Result is always freshly palloc'd. */ static char * -substitute_libpath_macro(const char * name) +substitute_libpath_macro(const char *name) { - size_t macroname_len; - char * replacement = NULL; + size_t macroname_len; + char *replacement = NULL; AssertArg(name != NULL); @@ -329,7 +329,7 @@ substitute_libpath_macro(const char * name) macroname_len = strcspn(name + 1, "/") + 1; - if (strncmp(name, "$libdir", macroname_len)==0) + if (strncmp(name, "$libdir", macroname_len) == 0) replacement = PKGLIBDIR; else elog(ERROR, "invalid macro name in dynamic library path"); @@ -338,7 +338,7 @@ substitute_libpath_macro(const char * name) return pstrdup(replacement); else { - char * new; + char *new; new = palloc(strlen(replacement) + (strlen(name) - macroname_len) + 1); @@ -357,10 +357,10 @@ substitute_libpath_macro(const char * name) * return NULL. */ static char * -find_in_dynamic_libpath(const char * basename) +find_in_dynamic_libpath(const char *basename) { const char *p; - size_t baselen; + size_t baselen; AssertArg(basename != NULL); AssertArg(strchr(basename, '/') == NULL); @@ -374,10 +374,10 @@ find_in_dynamic_libpath(const char * basename) for (;;) { - size_t len; - char * piece; - char * mangled; - char *full; + size_t len; + char *piece; + char *mangled; + char *full; len = strcspn(p, ":"); diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 5faa8a155c..18d2000d21 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.55 2001/10/06 23:21:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.56 2001/10/25 05:49:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,6 @@ typedef int32 ((*func_ptr) ()); #else typedef char *((*func_ptr) ()); - #endif /* @@ -143,9 +142,9 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt) char *prosrc; /* - * fn_oid *must* be filled in last. Some code assumes that if fn_oid is - * valid, the whole struct is valid. Some FmgrInfo struct's do survive - * elogs. + * fn_oid *must* be filled in last. Some code assumes that if fn_oid + * is valid, the whole struct is valid. Some FmgrInfo struct's do + * survive elogs. */ finfo->fn_oid = InvalidOid; finfo->fn_extra = NULL; @@ -154,7 +153,8 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt) if ((fbp = fmgr_isbuiltin(functionId)) != NULL) { /* - * Fast path for builtin functions: don't bother consulting pg_proc + * Fast path for builtin functions: don't bother consulting + * pg_proc */ finfo->fn_nargs = fbp->nargs; finfo->fn_strict = fbp->strict; @@ -189,6 +189,7 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt) switch (procedureStruct->prolang) { case INTERNALlanguageId: + /* * For an ordinary builtin function, we should never get here * because the isbuiltin() search above will have succeeded. @@ -405,7 +406,7 @@ fetch_finfo_record(void *filehandle, char *funcname) * Copy an FmgrInfo struct * * This is inherently somewhat bogus since we can't reliably duplicate - * language-dependent subsidiary info. We cheat by zeroing fn_extra, + * language-dependent subsidiary info. We cheat by zeroing fn_extra, * instead, meaning that subsidiary info will have to be recomputed. */ void @@ -624,7 +625,6 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) static Datum fmgr_untrusted(PG_FUNCTION_ARGS) { - /* * Currently these are unsupported. Someday we might do something * like forking a subprocess to execute 'em. @@ -1457,19 +1457,20 @@ Int64GetDatum(int64 X) *retval = X; return PointerGetDatum(retval); -#else /* INT64_IS_BUSTED */ +#else /* INT64_IS_BUSTED */ + /* - * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be - * 8, but we want Int64GetDatum to return an 8-byte object anyway, with - * zeroes in the unused bits. This is needed so that, for example, - * hash join of int8 will behave properly. + * On a machine with no 64-bit-int C datatype, sizeof(int64) will not + * be 8, but we want Int64GetDatum to return an 8-byte object anyway, + * with zeroes in the unused bits. This is needed so that, for + * example, hash join of int8 will behave properly. */ int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8)); MemSet(retval, 0, Max(sizeof(int64), 8)); *retval = X; return PointerGetDatum(retval); -#endif /* INT64_IS_BUSTED */ +#endif /* INT64_IS_BUSTED */ } Datum diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 2d5a79551e..d12cbcbbf1 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.38 2001/10/05 17:28:13 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.39 2001/10/25 05:49:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,11 +66,11 @@ static void *DynaHashAlloc(Size size); static uint32 call_hash(HTAB *hashp, void *k); static HASHSEGMENT seg_alloc(HTAB *hashp); -static bool element_alloc(HTAB *hashp); -static bool dir_realloc(HTAB *hashp); -static bool expand_table(HTAB *hashp); -static bool hdefault(HTAB *hashp); -static bool init_htab(HTAB *hashp, long nelem); +static bool element_alloc(HTAB *hashp); +static bool dir_realloc(HTAB *hashp); +static bool expand_table(HTAB *hashp); +static bool hdefault(HTAB *hashp); +static bool init_htab(HTAB *hashp, long nelem); static void hash_corrupted(HTAB *hashp); @@ -104,7 +104,7 @@ HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) { HTAB *hashp; - HASHHDR *hctl; + HASHHDR *hctl; /* First time through, create a memory context for hash tables */ if (!DynaHashCxt) @@ -132,7 +132,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) if (flags & HASH_FUNCTION) hashp->hash = info->hash; else - hashp->hash = string_hash; /* default hash function */ + hashp->hash = string_hash; /* default hash function */ if (flags & HASH_SHARED_MEM) { @@ -212,20 +212,20 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) { /* hash table structures live in child of given context */ CurrentDynaHashCxt = AllocSetContextCreate(info->hcxt, - "DynaHashTable", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + "DynaHashTable", + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); hashp->hcxt = CurrentDynaHashCxt; } else { /* hash table structures live in child of DynaHashCxt */ CurrentDynaHashCxt = AllocSetContextCreate(DynaHashCxt, - "DynaHashTable", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + "DynaHashTable", + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); hashp->hcxt = CurrentDynaHashCxt; } } @@ -244,7 +244,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) static bool hdefault(HTAB *hashp) { - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; MemSet(hctl, 0, sizeof(HASHHDR)); @@ -274,7 +274,7 @@ hdefault(HTAB *hashp) static bool init_htab(HTAB *hashp, long nelem) { - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; HASHSEGMENT *segp; int nbuckets; int nsegs; @@ -372,7 +372,7 @@ hash_estimate_size(long num_entries, long entrysize) nDirEntries <<= 1; /* dir_alloc doubles dsize at each call */ /* fixed control info */ - size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */ + size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */ /* directory */ size += MAXALIGN(nDirEntries * sizeof(HASHSEGMENT)); /* segments */ @@ -429,15 +429,15 @@ hash_destroy(HTAB *hashp) hash_stats("destroy", hashp); /* - * Free buckets, dir etc. by destroying the hash table's - * memory context. + * Free buckets, dir etc. by destroying the hash table's memory + * context. */ MemoryContextDelete(hashp->hcxt); /* - * Free the HTAB and control structure, which are allocated - * in the parent context (DynaHashCxt or the context given - * by the caller of hash_create()). + * Free the HTAB and control structure, which are allocated in the + * parent context (DynaHashCxt or the context given by the caller + * of hash_create()). */ MEM_FREE(hashp->hctl); MEM_FREE(hashp->tabname); @@ -460,7 +460,6 @@ hash_stats(const char *where, HTAB *hashp) where, hash_accesses, hash_collisions); fprintf(stderr, "hash_stats: total expansions %ld\n", hash_expansions); - #endif } @@ -470,7 +469,7 @@ hash_stats(const char *where, HTAB *hashp) static uint32 call_hash(HTAB *hashp, void *k) { - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; long hash_val, bucket; @@ -503,7 +502,7 @@ call_hash(HTAB *hashp, void *k) * HASH_ENTER case, but is redundant with the return value otherwise. * * The HASH_FIND_SAVE/HASH_REMOVE_SAVED interface is a hack to save one - * table lookup in a find/process/remove scenario. Note that no other + * table lookup in a find/process/remove scenario. Note that no other * addition or removal in the table can safely happen in between. *---------- */ @@ -513,17 +512,17 @@ hash_search(HTAB *hashp, HASHACTION action, bool *foundPtr) { - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; uint32 bucket; long segment_num; long segment_ndx; - HASHSEGMENT segp; - HASHBUCKET currBucket; + HASHSEGMENT segp; + HASHBUCKET currBucket; HASHBUCKET *prevBucketPtr; static struct State { - HASHBUCKET currBucket; + HASHBUCKET currBucket; HASHBUCKET *prevBucketPtr; } saveState; @@ -631,7 +630,7 @@ hash_search(HTAB *hashp, { /* no free elements. allocate another chunk of buckets */ if (!element_alloc(hashp)) - return NULL; /* out of memory */ + return NULL; /* out of memory */ currBucket = hctl->freeList; Assert(currBucket != NULL); } @@ -651,8 +650,9 @@ hash_search(HTAB *hashp, if (++hctl->nentries / (hctl->max_bucket + 1) > hctl->ffactor) { /* - * NOTE: failure to expand table is not a fatal error, it just - * means we have to run at higher fill factor than we wanted. + * NOTE: failure to expand table is not a fatal error, it + * just means we have to run at higher fill factor than we + * wanted. */ expand_table(hashp); } @@ -688,13 +688,13 @@ void * hash_seq_search(HASH_SEQ_STATUS *status) { HTAB *hashp = status->hashp; - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; while (status->curBucket <= hctl->max_bucket) { long segment_num; long segment_ndx; - HASHSEGMENT segp; + HASHSEGMENT segp; if (status->curEntry != NULL) { @@ -703,7 +703,7 @@ hash_seq_search(HASH_SEQ_STATUS *status) curElem = status->curEntry; status->curEntry = curElem->link; - if (status->curEntry == NULL) /* end of this bucket */ + if (status->curEntry == NULL) /* end of this bucket */ ++status->curBucket; return (void *) ELEMENTKEY(curElem); } @@ -731,7 +731,7 @@ hash_seq_search(HASH_SEQ_STATUS *status) */ status->curEntry = segp[segment_ndx]; - if (status->curEntry == NULL) /* empty bucket */ + if (status->curEntry == NULL) /* empty bucket */ ++status->curBucket; } @@ -747,8 +747,8 @@ hash_seq_search(HASH_SEQ_STATUS *status) static bool expand_table(HTAB *hashp) { - HASHHDR *hctl = hashp->hctl; - HASHSEGMENT old_seg, + HASHHDR *hctl = hashp->hctl; + HASHSEGMENT old_seg, new_seg; long old_bucket, new_bucket; @@ -758,7 +758,7 @@ expand_table(HTAB *hashp) old_segndx; HASHBUCKET *oldlink, *newlink; - HASHBUCKET currElement, + HASHBUCKET currElement, nextElement; #ifdef HASH_STATISTICS @@ -879,7 +879,7 @@ dir_realloc(HTAB *hashp) static HASHSEGMENT seg_alloc(HTAB *hashp) { - HASHSEGMENT segp; + HASHSEGMENT segp; CurrentDynaHashCxt = hashp->hcxt; segp = (HASHSEGMENT) hashp->alloc(sizeof(HASHBUCKET) * hashp->hctl->ssize); @@ -898,7 +898,7 @@ seg_alloc(HTAB *hashp) static bool element_alloc(HTAB *hashp) { - HASHHDR *hctl = hashp->hctl; + HASHHDR *hctl = hashp->hctl; Size elementSize; HASHELEMENT *tmpElement; int i; @@ -930,7 +930,7 @@ hash_corrupted(HTAB *hashp) { /* * If the corruption is in a shared hashtable, we'd better force a - * systemwide restart. Otherwise, just shut down this one backend. + * systemwide restart. Otherwise, just shut down this one backend. */ if (hashp->isshared) elog(STOP, "Hash table '%s' corrupted", hashp->tabname); diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c index 958deee804..4c7dd4cbb4 100644 --- a/src/backend/utils/hash/hashfn.c +++ b/src/backend/utils/hash/hashfn.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.14 2001/10/01 05:36:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.15 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,41 +57,41 @@ tag_hash(void *key, int keysize) * Use four byte chunks in a "jump table" to go a little faster. * * Currently the maximum keysize is 16 (mar 17 1992). I have put in - * cases for up to 32. Bigger than this will resort to a for loop + * cases for up to 32. Bigger than this will resort to a for loop * (see the default case). */ switch (keysize) { case 8 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 7 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 6 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 5 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 4 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 3 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case 2 * sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); /* fall through */ case sizeof(int): - h = (h * PRIME1) ^ (*k++); + h = (h * PRIME1) ^(*k++); break; default: @@ -102,7 +102,7 @@ tag_hash(void *key, int keysize) /* Cope with any partial-int leftover bytes */ if (keysize > 0) { - unsigned char *keybyte = (unsigned char *) k; + unsigned char *keybyte = (unsigned char *) k; do h = (h * PRIME1) ^ (*keybyte++); diff --git a/src/backend/utils/hash/pg_crc.c b/src/backend/utils/hash/pg_crc.c index 9ad712c066..86a714aa40 100644 --- a/src/backend/utils/hash/pg_crc.c +++ b/src/backend/utils/hash/pg_crc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.3 2001/03/23 18:42:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.4 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -413,5 +413,4 @@ const uint64 crc_table[256] = { INT64CONST(0x5DEDC41A34BBEEB2), INT64CONST(0x1F1D25F19D51D821), INT64CONST(0xD80C07CD676F8394), INT64CONST(0x9AFCE626CE85B507) }; - #endif /* INT64_IS_BUSTED */ diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index c6dafb9e2f..ec6235aba4 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.61 2001/10/21 03:25:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.62 2001/10/25 05:49:51 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -57,7 +57,8 @@ Relation reldesc; /* current relation descriptor */ char OutputFileName[MAXPGPATH]; -char pg_pathname[MAXPGPATH]; /* full path to postgres executable */ +char pg_pathname[MAXPGPATH]; /* full path to postgres + * executable */ BackendId MyBackendId; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index fc8b6b3ed7..2043fd6a4a 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.80 2001/10/19 18:19:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.81 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -256,7 +256,6 @@ next_token(FILE *fp, char *buf, const int bufsz) if (c != '\n') { - /* * build a token in buf of next characters up to EOF, eol, or * blank. @@ -317,8 +316,8 @@ SetCharSet() if (p && *p != '\0') { - map_file = malloc(strlen(DataDir) + strlen(p) + 2); - if (! map_file) + map_file = malloc(strlen(DataDir) + strlen(p) + 2); + if (!map_file) elog(FATAL, "out of memory"); sprintf(map_file, "%s/%s", DataDir, p); file = AllocateFile(map_file, PG_BINARY_R); @@ -381,7 +380,6 @@ convertstr(unsigned char *buff, int len, int dest) } return ch; } - #endif @@ -487,7 +485,8 @@ InitializeSessionUserIdStandalone(void) /* * Change session auth ID while running */ -void SetSessionAuthorization(const char * username) +void +SetSessionAuthorization(const char *username) { int32 userid; @@ -579,13 +578,12 @@ CreateLockFile(const char *filename, bool amPostmaster, pid_t my_pid = getpid(); /* - * We need a loop here because of race conditions. But don't loop + * We need a loop here because of race conditions. But don't loop * forever (for example, a non-writable $PGDATA directory might cause * a failure that won't go away). 100 tries seems like plenty. */ - for (ntries = 0; ; ntries++) + for (ntries = 0;; ntries++) { - /* * Try to create the lock file --- O_EXCL makes this atomic. */ diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index f653f55640..edec4a8329 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.94 2001/10/19 17:03:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.95 2001/10/25 05:49:51 momjian Exp $ * * *------------------------------------------------------------------------- @@ -221,7 +221,10 @@ InitPostgres(const char *dbname, const char *username) char *fullpath, datpath[MAXPGPATH]; - /* Formerly we validated DataDir here, but now that's done earlier. */ + /* + * Formerly we validated DataDir here, but now that's done + * earlier. + */ /* * Find oid and path of the database we're about to open. Since @@ -257,7 +260,7 @@ InitPostgres(const char *dbname, const char *username) */ /* - * Set up my per-backend PROC struct in shared memory. (We need to + * Set up my per-backend PROC struct in shared memory. (We need to * know MyDatabaseId before we can do this, since it's entered into * the PROC struct.) */ @@ -284,8 +287,8 @@ InitPostgres(const char *dbname, const char *username) AmiTransactionOverride(bootstrap); /* - * Initialize the relation descriptor cache. - * The pre-allocated reldescs are created here. + * Initialize the relation descriptor cache. The pre-allocated + * reldescs are created here. */ RelationCacheInitialize(); @@ -320,9 +323,8 @@ InitPostgres(const char *dbname, const char *username) RelationCacheInitializePhase2(); /* - * Figure out our postgres user id. In standalone mode we use a - * fixed id, otherwise we figure it out from the authenticated - * user name. + * Figure out our postgres user id. In standalone mode we use a fixed + * id, otherwise we figure it out from the authenticated user name. */ if (bootstrap) InitializeSessionUserIdStandalone(); @@ -388,7 +390,6 @@ InitPostgres(const char *dbname, const char *username) static void ShutdownPostgres(void) { - /* * These operations are really just a minimal subset of * AbortTransaction(). We don't want to do any inessential cleanup, @@ -408,7 +409,7 @@ ShutdownPostgres(void) * has to happen before bufmgr shutdown, so having smgr register a * callback for it wouldn't work. */ - smgrDoPendingDeletes(false);/* delete as though aborting xact */ + smgrDoPendingDeletes(false); /* delete as though aborting xact */ } diff --git a/src/backend/utils/mb/big5.c b/src/backend/utils/mb/big5.c index 2546ee4079..7ebaafb079 100644 --- a/src/backend/utils/mb/big5.c +++ b/src/backend/utils/mb/big5.c @@ -7,7 +7,7 @@ * * 1999/1/15 Tatsuo Ishii * - * $Id: big5.c,v 1.7 2001/02/10 02:31:27 tgl Exp $ + * $Id: big5.c,v 1.8 2001/10/25 05:49:51 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/conv.c b/src/backend/utils/mb/conv.c index 68fec7e090..a3ff9aaf8f 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -6,7 +6,7 @@ * WIN1250 client encoding support contributed by Pavel Behal * SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya * - * $Id: conv.c,v 1.32 2001/10/16 10:09:17 ishii Exp $ + * $Id: conv.c,v 1.33 2001/10/25 05:49:51 momjian Exp $ * * */ @@ -64,7 +64,6 @@ #include "Unicode/utf8_to_koi8r.map" #include "Unicode/utf8_to_win1251.map" - #endif /* UNICODE_CONVERSION */ /* @@ -124,7 +123,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) } else if (c1 > 0x7f) { - /* * JIS X0208, X0212, user defined extended characters */ @@ -168,7 +166,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) } else if (k >= 0xf040 && k < 0xf540) { - /* * UDC1 mapping to X0208 85 ku - 94 ku JIS code 0x7521 - * 0x7e7e EUC 0xf5a1 - 0xfefe @@ -181,7 +178,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) } else if (k >= 0xf540 && k < 0xfa40) { - /* * UDC2 mapping to X0212 85 ku - 94 ku JIS code 0x7521 - * 0x7e7e EUC 0x8ff5a1 - 0x8ffefe @@ -194,7 +190,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) } else if (k >= 0xfa40) { - /* * mapping IBM kanji to X0208 and X0212 * @@ -624,7 +619,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len) { if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4) { - *p++ = 0x9d;/* LCPRV2 */ + *p++ = 0x9d; /* LCPRV2 */ } *p++ = lc; /* Plane No. */ *p++ = (cnsBuf >> 8) & 0x00ff; @@ -793,7 +788,6 @@ mic2latin5(unsigned char *mic, unsigned char *p, int len) { mic2latin(mic, p, len, LC_ISO8859_5); } - #endif /* @@ -1275,7 +1269,7 @@ compare2(const void *p1, const void *p2) */ static void utf_to_local(unsigned char *utf, unsigned char *iso, - pg_utf_to_local * map, int size, int len) + pg_utf_to_local *map, int size, int len) { unsigned int iutf; int l; @@ -1355,14 +1349,14 @@ utf_to_latin5(unsigned char *utf, unsigned char *iso, int len) { utf_to_local(utf, iso, ULmapISO8859_5, sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local), len); } -#endif /* NOT_USED */ +#endif /* NOT_USED */ /* * Cyrillic charsets */ /* - * UTF-8 --->KOI8-R + * UTF-8 --->KOI8-R */ static void utf_to_KOI8R(unsigned char *utf, unsigned char *iso, int len) @@ -1372,7 +1366,7 @@ utf_to_KOI8R(unsigned char *utf, unsigned char *iso, int len) } /* - * UTF-8 --->WIN1251 + * UTF-8 --->WIN1251 */ static void utf_to_WIN1251(unsigned char *utf, unsigned char *iso, int len) @@ -1382,7 +1376,7 @@ utf_to_WIN1251(unsigned char *utf, unsigned char *iso, int len) } /* - * UTF-8 --->ALT + * UTF-8 --->ALT */ static void utf_to_ALT(unsigned char *utf, unsigned char *iso, int len) @@ -1396,7 +1390,7 @@ utf_to_ALT(unsigned char *utf, unsigned char *iso, int len) */ static void local_to_utf(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; @@ -1441,7 +1435,7 @@ local_to_utf(unsigned char *iso, unsigned char *utf, if (p == NULL) { elog(NOTICE, "local_to_utf: could not convert (0x%04x) %s to UTF-8. Ignored", - iiso, (&pg_enc2name_tbl[ encoding ])->name); + iiso, (&pg_enc2name_tbl[encoding])->name); continue; } if (p->utf & 0xff000000) @@ -1492,7 +1486,7 @@ latin5_to_utf(unsigned char *iso, unsigned char *utf, int len) { local_to_utf(iso, utf, LUmapISO8859_5, sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf), PG_LATIN5, len); } -#endif /* NOT_USED */ +#endif /* NOT_USED */ #define UTF_ISO8859(_id_) \ static void \ @@ -1546,6 +1540,7 @@ ALT_to_utf(unsigned char *iso, unsigned char *utf, int len) { local_to_utf(iso, utf, LUmapALT, sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len); } + /* * UTF-8 ---> EUC_JP */ @@ -1564,7 +1559,7 @@ static void euc_jp_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, 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); } /* @@ -1585,7 +1580,7 @@ static void euc_cn_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, 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); } /* @@ -1606,7 +1601,7 @@ static void euc_kr_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, 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); } /* @@ -1627,7 +1622,7 @@ static void euc_tw_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, 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); } /* @@ -1648,7 +1643,7 @@ static void sjis_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, LUmapSJIS, - sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len); + sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len); } /* @@ -1669,7 +1664,7 @@ static void big5_to_utf(unsigned char *euc, unsigned char *utf, int len) { local_to_utf(euc, utf, LUmapBIG5, - sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len); + sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len); } /* ---------- @@ -1678,69 +1673,176 @@ big5_to_utf(unsigned char *euc, unsigned char *utf, int len) * WARINIG: must by same order as pg_enc in include/mb/pg_wchar.h! * ---------- */ -pg_enconv pg_enconv_tbl[] = -{ - { PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii}, - { PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp}, - { PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn}, - { PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr}, - { PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw}, - { PG_UTF8, 0, 0, 0, 0}, - { PG_MULE_INTERNAL, 0, 0, 0, 0}, - { PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1}, - { PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2}, - { PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3}, - { PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4}, - { PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9}, - { PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10}, - { PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13}, - { PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14}, - { PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15}, - { PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16}, - { PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R}, - { PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251}, - { PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT}, - { PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5}, - { PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6}, - { PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7}, - { PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8}, - - { PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis}, - { PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5}, - { PG_WIN1250, win12502mic, mic2win1250, 0, 0}, +pg_enconv pg_enconv_tbl[] = +{ + { + PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii + } , + { + PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp + }, + { + PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn + }, + { + PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr + }, + { + PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw + }, + { + PG_UTF8, 0, 0, 0, 0 + }, + { + PG_MULE_INTERNAL, 0, 0, 0, 0 + }, + { + PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1 + }, + { + PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2 + }, + { + PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3 + }, + { + PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4 + }, + { + PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9 + }, + { + PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10 + }, + { + PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13 + }, + { + PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14 + }, + { + PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15 + }, + { + PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16 + }, + { + PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R + }, + { + PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251 + }, + { + PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT + }, + { + PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5 + }, + { + PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6 + }, + { + PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7 + }, + { + PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8 + }, + + { + PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis + }, + { + PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5 + }, + { + PG_WIN1250, win12502mic, mic2win1250, 0, 0 + }, }; #else -pg_enconv pg_enconv_tbl[] = -{ - { PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0}, - { PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0}, - { PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0}, - { PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0}, - { PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0}, - { PG_UTF8, 0, 0, 0, 0}, - { PG_MULE_INTERNAL, 0, 0, 0, 0}, - { PG_LATIN1, latin12mic, mic2latin1, 0, 0}, - { PG_LATIN2, latin22mic, mic2latin2, 0, 0}, - { PG_LATIN3, latin32mic, mic2latin3, 0, 0}, - { PG_LATIN4, latin42mic, mic2latin4, 0, 0}, - { PG_LATIN5, iso2mic, mic2iso, 0, 0}, - { PG_LATIN6, 0, 0, 0, 0}, - { PG_LATIN7, 0, 0, 0, 0}, - { PG_LATIN8, 0, 0, 0, 0}, - { PG_LATIN9, 0, 0, 0, 0}, - { PG_LATIN10, 0, 0, 0, 0}, - { PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0}, - { PG_WIN1251, win12512mic, mic2win1251, 0, 0}, - { PG_ALT, alt2mic, mic2alt, 0, 0}, - { PG_ISO_8859_5, 0, 0, 0, 0}, - { PG_ISO_8859_6, 0, 0, 0, 0}, - { PG_ISO_8859_7, 0, 0, 0, 0}, - { PG_ISO_8859_8, 0, 0, 0, 0}, - { PG_SJIS, sjis2mic, mic2sjis, 0, 0}, - { PG_BIG5, big52mic, mic2big5, 0, 0}, - { PG_WIN1250, win12502mic, mic2win1250, 0, 0}, +pg_enconv pg_enconv_tbl[] = +{ + { + PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0 + } , + { + PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0 + }, + { + PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0 + }, + { + PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0 + }, + { + PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0 + }, + { + PG_UTF8, 0, 0, 0, 0 + }, + { + PG_MULE_INTERNAL, 0, 0, 0, 0 + }, + { + PG_LATIN1, latin12mic, mic2latin1, 0, 0 + }, + { + PG_LATIN2, latin22mic, mic2latin2, 0, 0 + }, + { + PG_LATIN3, latin32mic, mic2latin3, 0, 0 + }, + { + PG_LATIN4, latin42mic, mic2latin4, 0, 0 + }, + { + PG_LATIN5, iso2mic, mic2iso, 0, 0 + }, + { + PG_LATIN6, 0, 0, 0, 0 + }, + { + PG_LATIN7, 0, 0, 0, 0 + }, + { + PG_LATIN8, 0, 0, 0, 0 + }, + { + PG_LATIN9, 0, 0, 0, 0 + }, + { + PG_LATIN10, 0, 0, 0, 0 + }, + { + PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0 + }, + { + PG_WIN1251, win12512mic, mic2win1251, 0, 0 + }, + { + PG_ALT, alt2mic, mic2alt, 0, 0 + }, + { + PG_ISO_8859_5, 0, 0, 0, 0 + }, + { + PG_ISO_8859_6, 0, 0, 0, 0 + }, + { + PG_ISO_8859_7, 0, 0, 0, 0 + }, + { + PG_ISO_8859_8, 0, 0, 0, 0 + }, + { + PG_SJIS, sjis2mic, mic2sjis, 0, 0 + }, + { + PG_BIG5, big52mic, mic2big5, 0, 0 + }, + { + PG_WIN1250, win12502mic, mic2win1250, 0, 0 + }, }; - #endif /* UNICODE_CONVERSION */ diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index f2e16460eb..7667e478aa 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.4 2001/10/16 10:09:17 ishii Exp $ + * $Id: encnames.c,v 1.5 2001/10/25 05:49:51 momjian Exp $ */ #ifdef FRONTEND #include "postgres_fe.h" @@ -23,7 +23,7 @@ #include <ctype.h> /* ---------- - * All encoding names, sorted: *** A L P H A B E T I C *** + * All encoding names, sorted: *** A L P H A B E T I C *** * * All names must be without irrelevan chars, search routines use * isalnum() chars only. It means ISO-8859-1, iso_8859-1 and Iso8859_1 @@ -34,58 +34,153 @@ * Karel Zak, Aug 2001 * ---------- */ -pg_encname pg_encname_tbl[] = +pg_encname pg_encname_tbl[] = { - { "alt", PG_ALT }, /* IBM866 */ - { "big5", PG_BIG5 }, /* Big5; Chinese for Taiwan Multi-byte set */ - { "euccn", PG_EUC_CN }, /* EUC-CN; Extended Unix Code for simplified Chinese */ - { "eucjp", PG_EUC_JP }, /* EUC-JP; Extended UNIX Code fixed Width for Japanese, stdandard OSF */ - { "euckr", PG_EUC_KR }, /* EUC-KR; RFC1557,Choi */ - { "euctw", PG_EUC_TW }, /* EUC-TW; Extended Unix Code for traditional Chinese */ - { "iso88591", PG_LATIN1 }, /* ISO-8859-1; RFC1345,KXS2 */ - { "iso885910", PG_LATIN6 }, /* ISO-8859-10; RFC1345,KXS2 */ - { "iso885913", PG_LATIN7 }, /* ISO-8859-13; RFC1345,KXS2 */ - { "iso885914", PG_LATIN8 }, /* ISO-8859-14; RFC1345,KXS2 */ - { "iso885915", PG_LATIN9 }, /* ISO-8859-15; RFC1345,KXS2 */ - { "iso885916", PG_LATIN10 }, /* ISO-8859-16; RFC1345,KXS2 */ - { "iso88592", PG_LATIN2 }, /* ISO-8859-2; RFC1345,KXS2 */ - { "iso88593", PG_LATIN3 }, /* ISO-8859-3; RFC1345,KXS2 */ - { "iso88594", PG_LATIN4 }, /* ISO-8859-4; RFC1345,KXS2 */ - { "iso88595", PG_ISO_8859_5 }, /* ISO-8859-5; RFC1345,KXS2 */ - { "iso88596", PG_ISO_8859_6 }, /* ISO-8859-6; RFC1345,KXS2 */ - { "iso88597", PG_ISO_8859_7 }, /* ISO-8859-7; RFC1345,KXS2 */ - { "iso88598", PG_ISO_8859_8 }, /* ISO-8859-8; RFC1345,KXS2 */ - { "iso88599", PG_LATIN5 }, /* ISO-8859-9; RFC1345,KXS2 */ - { "koi8", PG_KOI8R }, /* _dirty_ alias for KOI8-R (backward compatibility) */ - { "koi8r", PG_KOI8R }, /* KOI8-R; RFC1489 */ - { "latin1", PG_LATIN1 }, /* alias for ISO-8859-1 */ - { "latin10", PG_LATIN10}, /* alias for ISO-8859-16 */ - { "latin2", PG_LATIN2 }, /* alias for ISO-8859-2 */ - { "latin3", PG_LATIN3 }, /* alias for ISO-8859-3 */ - { "latin4", PG_LATIN4 }, /* alias for ISO-8859-4 */ - { "latin5", PG_LATIN5 }, /* alias for ISO-8859-9 */ - { "latin6", PG_LATIN6}, /* alias for ISO-8859-10 */ - { "latin7", PG_LATIN7}, /* alias for ISO-8859-13 */ - { "latin8", PG_LATIN8}, /* alias for ISO-8859-14 */ - { "latin9", PG_LATIN9}, /* alias for ISO-8859-15 */ - { "mskanji", PG_SJIS }, /* alias for Shift_JIS */ - { "muleinternal",PG_MULE_INTERNAL }, - { "shiftjis", PG_SJIS }, /* Shift_JIS; JIS X 0202-1991 */ - { "sjis", PG_SJIS }, /* alias for Shift_JIS */ - { "sqlascii", PG_SQL_ASCII }, - { "unicode", PG_UTF8 }, /* alias for UTF-8 */ - { "utf8", PG_UTF8 }, /* UTF-8; RFC2279 */ - { "win", PG_WIN1251 }, /* _dirty_ alias for windows-1251 (backward compatibility) */ - { "win1250", PG_WIN1250 }, /* alias for Windows-1250 */ - { "win1251", PG_WIN1251 }, /* alias for Windows-1251 */ - { "windows1250",PG_WIN1250 }, /* Windows-1251; Microsoft */ - { "windows1251",PG_WIN1251 }, /* Windows-1251; Microsoft */ + { + "alt", PG_ALT + } , /* IBM866 */ + { + "big5", PG_BIG5 + }, /* Big5; Chinese for Taiwan Multi-byte set */ + { + "euccn", PG_EUC_CN + }, /* EUC-CN; Extended Unix Code for + * simplified Chinese */ + { + "eucjp", PG_EUC_JP + }, /* EUC-JP; Extended UNIX Code fixed Width + * for Japanese, stdandard OSF */ + { + "euckr", PG_EUC_KR + }, /* EUC-KR; RFC1557,Choi */ + { + "euctw", PG_EUC_TW + }, /* EUC-TW; Extended Unix Code for + * traditional Chinese */ + { + "iso88591", PG_LATIN1 + }, /* ISO-8859-1; RFC1345,KXS2 */ + { + "iso885910", PG_LATIN6 + }, /* ISO-8859-10; RFC1345,KXS2 */ + { + "iso885913", PG_LATIN7 + }, /* ISO-8859-13; RFC1345,KXS2 */ + { + "iso885914", PG_LATIN8 + }, /* ISO-8859-14; RFC1345,KXS2 */ + { + "iso885915", PG_LATIN9 + }, /* ISO-8859-15; RFC1345,KXS2 */ + { + "iso885916", PG_LATIN10 + }, /* ISO-8859-16; RFC1345,KXS2 */ + { + "iso88592", PG_LATIN2 + }, /* ISO-8859-2; RFC1345,KXS2 */ + { + "iso88593", PG_LATIN3 + }, /* ISO-8859-3; RFC1345,KXS2 */ + { + "iso88594", PG_LATIN4 + }, /* ISO-8859-4; RFC1345,KXS2 */ + { + "iso88595", PG_ISO_8859_5 + }, /* ISO-8859-5; RFC1345,KXS2 */ + { + "iso88596", PG_ISO_8859_6 + }, /* ISO-8859-6; RFC1345,KXS2 */ + { + "iso88597", PG_ISO_8859_7 + }, /* ISO-8859-7; RFC1345,KXS2 */ + { + "iso88598", PG_ISO_8859_8 + }, /* ISO-8859-8; RFC1345,KXS2 */ + { + "iso88599", PG_LATIN5 + }, /* ISO-8859-9; RFC1345,KXS2 */ + { + "koi8", PG_KOI8R + }, /* _dirty_ alias for KOI8-R (backward + * compatibility) */ + { + "koi8r", PG_KOI8R + }, /* KOI8-R; RFC1489 */ + { + "latin1", PG_LATIN1 + }, /* alias for ISO-8859-1 */ + { + "latin10", PG_LATIN10 + }, /* alias for ISO-8859-16 */ + { + "latin2", PG_LATIN2 + }, /* alias for ISO-8859-2 */ + { + "latin3", PG_LATIN3 + }, /* alias for ISO-8859-3 */ + { + "latin4", PG_LATIN4 + }, /* alias for ISO-8859-4 */ + { + "latin5", PG_LATIN5 + }, /* alias for ISO-8859-9 */ + { + "latin6", PG_LATIN6 + }, /* alias for ISO-8859-10 */ + { + "latin7", PG_LATIN7 + }, /* alias for ISO-8859-13 */ + { + "latin8", PG_LATIN8 + }, /* alias for ISO-8859-14 */ + { + "latin9", PG_LATIN9 + }, /* alias for ISO-8859-15 */ + { + "mskanji", PG_SJIS + }, /* alias for Shift_JIS */ + { + "muleinternal", PG_MULE_INTERNAL + }, + { + "shiftjis", PG_SJIS + }, /* Shift_JIS; JIS X 0202-1991 */ + { + "sjis", PG_SJIS + }, /* alias for Shift_JIS */ + { + "sqlascii", PG_SQL_ASCII + }, + { + "unicode", PG_UTF8 + }, /* alias for UTF-8 */ + { + "utf8", PG_UTF8 + }, /* UTF-8; RFC2279 */ + { + "win", PG_WIN1251 + }, /* _dirty_ alias for windows-1251 + * (backward compatibility) */ + { + "win1250", PG_WIN1250 + }, /* alias for Windows-1250 */ + { + "win1251", PG_WIN1251 + }, /* alias for Windows-1251 */ + { + "windows1250", PG_WIN1250 + }, /* Windows-1251; Microsoft */ + { + "windows1251", PG_WIN1251 + }, /* Windows-1251; Microsoft */ - { NULL, 0 } /* last */ + { + NULL, 0 + } /* last */ }; unsigned int pg_encname_tbl_sz = \ - sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) -1; +sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) - 1; /* ---------- * These are "official" encoding names. @@ -94,33 +189,87 @@ unsigned int pg_encname_tbl_sz = \ */ pg_enc2name pg_enc2name_tbl[] = { - { "SQL_ASCII", PG_SQL_ASCII }, - { "EUC_JP", PG_EUC_JP }, - { "EUC_CN", PG_EUC_CN }, - { "EUC_KR", PG_EUC_KR }, - { "EUC_TW", PG_EUC_TW }, - { "UNICODE", PG_UTF8 }, - { "MULE_INTERNAL",PG_MULE_INTERNAL }, - { "LATIN1", PG_LATIN1 }, - { "LATIN2", PG_LATIN2 }, - { "LATIN3", PG_LATIN3 }, - { "LATIN4", PG_LATIN4 }, - { "LATIN5", PG_LATIN5 }, - { "LATIN6", PG_LATIN6 }, - { "LATIN7", PG_LATIN7 }, - { "LATIN8", PG_LATIN8 }, - { "LATIN9", PG_LATIN9 }, - { "LATIN10", PG_LATIN10 }, - { "KOI8", PG_KOI8R }, - { "WIN", PG_WIN1251 }, - { "ALT", PG_ALT }, - { "ISO_8859_5", PG_ISO_8859_5 }, - { "ISO_8859_6", PG_ISO_8859_6 }, - { "ISO_8859_7", PG_ISO_8859_7 }, - { "ISO_8859_8", PG_ISO_8859_8 }, - { "SJIS", PG_SJIS }, - { "BIG5", PG_BIG5 }, - { "WIN1250", PG_WIN1250 } + { + "SQL_ASCII", PG_SQL_ASCII + } , + { + "EUC_JP", PG_EUC_JP + }, + { + "EUC_CN", PG_EUC_CN + }, + { + "EUC_KR", PG_EUC_KR + }, + { + "EUC_TW", PG_EUC_TW + }, + { + "UNICODE", PG_UTF8 + }, + { + "MULE_INTERNAL", PG_MULE_INTERNAL + }, + { + "LATIN1", PG_LATIN1 + }, + { + "LATIN2", PG_LATIN2 + }, + { + "LATIN3", PG_LATIN3 + }, + { + "LATIN4", PG_LATIN4 + }, + { + "LATIN5", PG_LATIN5 + }, + { + "LATIN6", PG_LATIN6 + }, + { + "LATIN7", PG_LATIN7 + }, + { + "LATIN8", PG_LATIN8 + }, + { + "LATIN9", PG_LATIN9 + }, + { + "LATIN10", PG_LATIN10 + }, + { + "KOI8", PG_KOI8R + }, + { + "WIN", PG_WIN1251 + }, + { + "ALT", PG_ALT + }, + { + "ISO_8859_5", PG_ISO_8859_5 + }, + { + "ISO_8859_6", PG_ISO_8859_6 + }, + { + "ISO_8859_7", PG_ISO_8859_7 + }, + { + "ISO_8859_8", PG_ISO_8859_8 + }, + { + "SJIS", PG_SJIS + }, + { + "BIG5", PG_BIG5 + }, + { + "WIN1250", PG_WIN1250 + } }; /* ---------- @@ -130,12 +279,12 @@ pg_enc2name pg_enc2name_tbl[] = int pg_valid_client_encoding(const char *name) { - int enc; + int enc; if ((enc = pg_char_to_encoding(name)) < 0) return -1; - if (!PG_VALID_FE_ENCODING( enc)) + if (!PG_VALID_FE_ENCODING(enc)) return -1; return enc; @@ -144,12 +293,12 @@ pg_valid_client_encoding(const char *name) int pg_valid_server_encoding(const char *name) { - int enc; + int enc; if ((enc = pg_char_to_encoding(name)) < 0) return -1; - if (!PG_VALID_BE_ENCODING( enc)) + if (!PG_VALID_BE_ENCODING(enc)) return -1; return enc; @@ -162,12 +311,13 @@ pg_valid_server_encoding(const char *name) static char * clean_encoding_name(char *key, char *newkey) { - char *p, *np; + char *p, + *np; - for(p=key, np=newkey; *p!='\0'; p++) + for (p = key, np = newkey; *p != '\0'; p++) { if (isalnum((unsigned char) *p)) - *np++=tolower((unsigned char) *p); + *np++ = tolower((unsigned char) *p); } *np = '\0'; return newkey; @@ -180,15 +330,15 @@ clean_encoding_name(char *key, char *newkey) pg_encname * pg_char_to_encname_struct(const char *name) { - unsigned int nel = pg_encname_tbl_sz; - pg_encname *base = pg_encname_tbl, - *last = base + nel - 1, - *position; - int result; + unsigned int nel = pg_encname_tbl_sz; + pg_encname *base = pg_encname_tbl, + *last = base + nel - 1, + *position; + int result; char buff[NAMEDATALEN], - *key; + *key; - if(name==NULL || *name=='\0') + if (name == NULL || *name == '\0') return NULL; if (strlen(name) > NAMEDATALEN) @@ -241,6 +391,7 @@ Datum PG_char_to_encoding(PG_FUNCTION_ARGS) { Name s = PG_GETARG_NAME(0); + PG_RETURN_INT32(pg_char_to_encoding(NameStr(*s))); } #endif @@ -250,8 +401,9 @@ pg_encoding_to_char(int encoding) { if (PG_VALID_ENCODING(encoding)) { - pg_enc2name *p = &pg_enc2name_tbl[ encoding ]; - Assert( encoding == p->encoding ); + pg_enc2name *p = &pg_enc2name_tbl[encoding]; + + Assert(encoding == p->encoding); return p->name; } return ""; @@ -262,9 +414,8 @@ Datum PG_encoding_to_char(PG_FUNCTION_ARGS) { int32 encoding = PG_GETARG_INT32(0); - const char *encoding_name = pg_encoding_to_char(encoding); + const char *encoding_name = pg_encoding_to_char(encoding); return DirectFunctionCall1(namein, CStringGetDatum(encoding_name)); } #endif - diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index c0949a6324..645b9f3260 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.24 2001/10/12 02:08:34 ishii Exp $ + * $Id: mbutils.c,v 1.25 2001/10/25 05:49:51 momjian Exp $ */ #include "postgres.h" @@ -12,7 +12,7 @@ #include "utils/builtins.h" /* - * We handle for actual FE and BE encoding setting encoding-identificator + * We handle for actual FE and BE encoding setting encoding-identificator * and encoding-name too. It prevent searching and conversion from encoding * to encoding name in getdatabaseencoding() and other routines. * @@ -21,13 +21,13 @@ * * Karel Zak (Aug 2001) */ -static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ]; -static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ]; +static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; static to_mic_converter client_to_mic; /* something to MIC */ -static from_mic_converter client_from_mic; /* MIC to something */ +static from_mic_converter client_from_mic; /* MIC to something */ static to_mic_converter server_to_mic; /* something to MIC */ -static from_mic_converter server_from_mic; /* MIC to something */ +static from_mic_converter server_from_mic; /* MIC to something */ /* * find encoding table entry by encoding @@ -37,8 +37,8 @@ pg_get_enconv_by_encoding(int encoding) { if (PG_VALID_ENCODING(encoding)) { - Assert((&pg_enconv_tbl[ encoding ])->encoding == encoding); - return &pg_enconv_tbl[ encoding ]; + Assert((&pg_enconv_tbl[encoding])->encoding == encoding); + return &pg_enconv_tbl[encoding]; } return 0; } @@ -113,7 +113,7 @@ pg_find_encoding_converters(int src, int dest, int pg_set_client_encoding(int encoding) { - int current_server_encoding = DatabaseEncoding->encoding; + int current_server_encoding = DatabaseEncoding->encoding; if (!PG_VALID_FE_ENCODING(encoding)) return (-1); @@ -121,7 +121,7 @@ pg_set_client_encoding(int encoding) if (pg_find_encoding_converters(encoding, current_server_encoding, &client_to_mic, &server_from_mic) < 0) return (-1); - ClientEncoding = &pg_enc2name_tbl[ encoding ]; + ClientEncoding = &pg_enc2name_tbl[encoding]; Assert(ClientEncoding->encoding == encoding); @@ -162,7 +162,7 @@ pg_get_client_encoding_name(void) * function). Another case is you have direct-conversion function from * src to dest. In this case either src_to_mic or dest_from_mic could * be set to 0 also. - * + * * Note that If src or dest is UNICODE, we have to do * direct-conversion, since we don't support conversion bwteen UNICODE * and MULE_INTERNAL, we cannot go through MULE_INTERNAL. @@ -175,7 +175,7 @@ pg_get_client_encoding_name(void) * to determine whether to pfree the result or not! * * Note: we assume that conversion cannot cause more than a 4-to-1 growth - * in the length of the string --- is this enough? */ + * in the length of the string --- is this enough? */ unsigned char * pg_do_encoding_conversion(unsigned char *src, int len, @@ -212,32 +212,33 @@ pg_do_encoding_conversion(unsigned char *src, int len, Datum pg_convert(PG_FUNCTION_ARGS) { - text *string = PG_GETARG_TEXT_P(0); - Name s = PG_GETARG_NAME(1); - int encoding = pg_char_to_encoding(NameStr(*s)); - int db_encoding = DatabaseEncoding->encoding; + text *string = PG_GETARG_TEXT_P(0); + Name s = PG_GETARG_NAME(1); + int encoding = pg_char_to_encoding(NameStr(*s)); + int db_encoding = DatabaseEncoding->encoding; to_mic_converter src; from_mic_converter dest; - unsigned char *result; - text *retval; + unsigned char *result; + text *retval; if (encoding < 0) - elog(ERROR, "Invalid encoding name %s", NameStr(*s)); + elog(ERROR, "Invalid encoding name %s", NameStr(*s)); if (pg_find_encoding_converters(db_encoding, encoding, &src, &dest) < 0) { - char *encoding_name = (char *)pg_encoding_to_char(db_encoding); - elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name); + char *encoding_name = (char *) pg_encoding_to_char(db_encoding); + + elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name); } - result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ, - src, dest); + result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ, + src, dest); if (result == NULL) - elog(ERROR, "Encoding conversion failed"); + elog(ERROR, "Encoding conversion failed"); retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result))); - if (result != (unsigned char *)VARDATA(string)) - pfree(result); + if (result != (unsigned char *) VARDATA(string)) + pfree(result); /* free memory if allocated by the toaster */ PG_FREE_IF_COPY(string, 0); @@ -253,35 +254,35 @@ pg_convert(PG_FUNCTION_ARGS) Datum pg_convert2(PG_FUNCTION_ARGS) { - text *string = PG_GETARG_TEXT_P(0); - char *src_encoding_name = NameStr(*PG_GETARG_NAME(1)); - int src_encoding = pg_char_to_encoding(src_encoding_name); - char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2)); - int dest_encoding = pg_char_to_encoding(dest_encoding_name); + text *string = PG_GETARG_TEXT_P(0); + char *src_encoding_name = NameStr(*PG_GETARG_NAME(1)); + int src_encoding = pg_char_to_encoding(src_encoding_name); + char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2)); + int dest_encoding = pg_char_to_encoding(dest_encoding_name); to_mic_converter src; from_mic_converter dest; - unsigned char *result; - text *retval; + unsigned char *result; + text *retval; if (src_encoding < 0) - elog(ERROR, "Invalid source encoding name %s", src_encoding_name); + elog(ERROR, "Invalid source encoding name %s", src_encoding_name); if (dest_encoding < 0) - elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name); + elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name); if (pg_find_encoding_converters(src_encoding, dest_encoding, &src, &dest) < 0) { - elog(ERROR, "Conversion from %s to %s is not possible", - src_encoding_name, dest_encoding_name); + elog(ERROR, "Conversion from %s to %s is not possible", + src_encoding_name, dest_encoding_name); } - result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ, - src, dest); + result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ, + src, dest); if (result == NULL) - elog(ERROR, "Encoding conversion failed"); + elog(ERROR, "Encoding conversion failed"); retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result))); - if (result != (unsigned char *)VARDATA(string)) - pfree(result); + if (result != (unsigned char *) VARDATA(string)) + pfree(result); /* free memory if allocated by the toaster */ PG_FREE_IF_COPY(string, 0); @@ -309,7 +310,7 @@ pg_client_to_server(unsigned char *s, int len) Assert(ClientEncoding); if (ClientEncoding->encoding == DatabaseEncoding->encoding) - return s; + return s; return pg_do_encoding_conversion(s, len, client_to_mic, server_from_mic); } @@ -341,23 +342,23 @@ pg_server_to_client(unsigned char *s, int len) /* convert a multi-byte string to a wchar */ int -pg_mb2wchar(const unsigned char *from, pg_wchar * to) +pg_mb2wchar(const unsigned char *from, pg_wchar *to) { - return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, strlen(from)); + return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, strlen(from)); } /* convert a multi-byte string to a wchar with a limited length */ int -pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len) +pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len) { - return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, len); + return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, len); } /* returns the byte length of a multi-byte word */ int pg_mblen(const unsigned char *mbstr) { - return ((*pg_wchar_table[ DatabaseEncoding->encoding ].mblen) (mbstr)); + return ((*pg_wchar_table[DatabaseEncoding->encoding].mblen) (mbstr)); } /* returns the length (counted as a wchar) of a multi-byte string */ @@ -447,7 +448,7 @@ SetDatabaseEncoding(int encoding) if (!PG_VALID_BE_ENCODING(encoding)) elog(ERROR, "SetDatabaseEncoding(): invalid database encoding"); - DatabaseEncoding = &pg_enc2name_tbl[ encoding ]; + DatabaseEncoding = &pg_enc2name_tbl[encoding]; Assert(DatabaseEncoding->encoding == encoding); } diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 0c51da5ab7..9d778d0041 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 multi-byte streams. * Tatsuo Ishii - * $Id: wchar.c,v 1.24 2001/10/15 01:19:15 ishii Exp $ + * $Id: wchar.c,v 1.25 2001/10/25 05:49:51 momjian Exp $ * * WIN1250 client encoding updated by Pavel Behal * @@ -29,7 +29,7 @@ * SQL/ASCII */ static int pg_ascii2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -54,7 +54,7 @@ pg_ascii_mblen(const unsigned char *s) */ static int pg_euc2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -111,7 +111,7 @@ pg_euc_mblen(const unsigned char *s) * EUC_JP */ static int pg_eucjp2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { return (pg_euc2wchar_with_len(from, to, len)); } @@ -126,7 +126,7 @@ pg_eucjp_mblen(const unsigned char *s) * EUC_KR */ static int pg_euckr2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { return (pg_euc2wchar_with_len(from, to, len)); } @@ -141,7 +141,7 @@ pg_euckr_mblen(const unsigned char *s) * EUC_CN */ static int pg_euccn2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -195,7 +195,7 @@ pg_euccn_mblen(const unsigned char *s) * EUC_TW */ static int pg_euctw2wchar_with_len - (const unsigned char *from, pg_wchar * to, int len) + (const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -257,7 +257,7 @@ pg_euctw_mblen(const unsigned char *s) * "from" not necessarily null terminated. */ static int -pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len) +pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len) { unsigned char c1, c2, @@ -325,7 +325,7 @@ pg_utf_mblen(const unsigned char *s) * "from" not necessarily null terminated. */ static int -pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len) +pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -395,7 +395,7 @@ pg_mule_mblen(const unsigned char *s) * ISO8859-1 */ static int -pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len) +pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len) { int cnt = 0; @@ -458,33 +458,33 @@ pg_big5_mblen(const unsigned char *s) } 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 */ - {pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */ - {pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */ - {pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */ + {pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */ + {pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */ + {pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */ + {pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */ + {pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */ {pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 5; PG_UNICODE */ - {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */ - {0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */ - {0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */ - {pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */ + {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */ + {0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */ + {0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */ + {pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */ }; /* returns the byte length of a word for mule internal code */ @@ -502,9 +502,9 @@ pg_encoding_mblen(int encoding, const unsigned char *mbstr) { Assert(PG_VALID_ENCODING(encoding)); - return( (encoding >= 0 && - encoding < sizeof(pg_wchar_table)/sizeof(pg_wchar_tbl)) ? - ((*pg_wchar_table[encoding].mblen) (mbstr)) : + return ((encoding >= 0 && + encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ? + ((*pg_wchar_table[encoding].mblen) (mbstr)) : ((*pg_wchar_table[PG_SQL_ASCII].mblen) (mbstr))); } @@ -531,59 +531,62 @@ pg_encoding_max_length(int encoding) char * pg_verifymbstr(const unsigned char *mbstr, int len) { - int l; - int i, j; - static char buf[256]; - int slen = 0; + int l; + int i, + j; + static char buf[256]; + int slen = 0; /* we do not check single byte encodings */ if (pg_database_encoding_max_length() <= 1) - return NULL; + return NULL; while (len > 0 && *mbstr) { /* special UTF-8 check */ if (GetDatabaseEncoding() == PG_UTF8 && - (*mbstr & 0xf8) == 0xf0) + (*mbstr & 0xf8) == 0xf0) { - snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted"); - return(buf); + snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted"); + return (buf); } - + l = pg_mblen(mbstr); /* multi-byte letter? */ if (l > 1) { - for (i=1;i<l;i++) - { - if (i > len || *(mbstr+i) == '\0' || - /* we assume that every muti-byte letter - * consists of bytes being the 8th bit set - */ - ((*(mbstr+i) & 0x80) == 0)) + for (i = 1; i < l; i++) { - int remains = sizeof(buf); - char *p = buf; - - slen = snprintf(p, remains, "Invalid %s character sequence found (0x", - GetDatabaseEncodingName()); - p += slen; - remains -= slen; - - i = ((*(mbstr+i) & 0x80) == 0)?l:i; - - for (j=0;j<i;j++) - { - slen = snprintf(p, remains, "%02x", - *(mbstr+j)); - p += slen; - remains -= slen; - } - snprintf(p, remains, ")"); - return(buf); + if (i > len || *(mbstr + i) == '\0' || + + /* + * we assume that every muti-byte letter consists of bytes + * being the 8th bit set + */ + ((*(mbstr + i) & 0x80) == 0)) + { + int remains = sizeof(buf); + char *p = buf; + + slen = snprintf(p, remains, "Invalid %s character sequence found (0x", + GetDatabaseEncodingName()); + p += slen; + remains -= slen; + + i = ((*(mbstr + i) & 0x80) == 0) ? l : i; + + for (j = 0; j < i; j++) + { + slen = snprintf(p, remains, "%02x", + *(mbstr + j)); + p += slen; + remains -= slen; + } + snprintf(p, remains, ")"); + return (buf); + } } - } } len -= l; mbstr += l; @@ -599,5 +602,4 @@ pg_database_encoding_max_length(void) { return pg_wchar_table[GetDatabaseEncoding()].maxmblen; } - #endif diff --git a/src/backend/utils/mb/wstrcmp.c b/src/backend/utils/mb/wstrcmp.c index 13255d7c5e..f828c31a3a 100644 --- a/src/backend/utils/mb/wstrcmp.c +++ b/src/backend/utils/mb/wstrcmp.c @@ -43,7 +43,7 @@ pg_char_and_wchar_strcmp(s1, s2) register const char *s1; register const pg_wchar *s2; { - while ((pg_wchar) * s1 == *s2++) + while ((pg_wchar) *s1 == *s2++) if (*s1++ == 0) return 0; return *(const unsigned char *) s1 - *(const pg_wchar *) (s2 - 1); diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index 218114f7cf..293d9df525 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.48 2001/08/25 18:52:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.49 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,6 @@ ExpandDatabasePath(const char *dbpath) */ for (cp = buf; *cp; cp++) { - /* * The following characters will not be allowed anywhere in the * database path. (Do not include the slash or '.' here.) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index c506e3147c..ff57dc92bb 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4,7 +4,7 @@ * Support for grand unified configuration scheme, including SET * command, configuration file, and command line options. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.55 2001/09/30 20:16:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.56 2001/10/25 05:49:51 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. @@ -95,11 +95,11 @@ bool Password_encryption = false; */ enum config_type { - PGC_NONE = 0, - PGC_BOOL, - PGC_INT, - PGC_REAL, - PGC_STRING + PGC_NONE = 0, + PGC_BOOL, + PGC_INT, + PGC_REAL, + PGC_STRING }; @@ -161,7 +161,7 @@ struct config_string const char *boot_default_val; bool (*parse_hook) (const char *proposed); void (*assign_hook) (const char *newval); - char *default_val; + char *default_val; }; @@ -192,92 +192,196 @@ struct config_string static struct config_bool ConfigureNamesBool[] = { - {"enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL}, - {"enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL}, - {"enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL}, - {"enable_sort", PGC_USERSET, &enable_sort, true, NULL}, - {"enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL}, - {"enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL}, - {"enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL}, - - {"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL}, - {"geqo", PGC_USERSET, &enable_geqo, true, NULL}, - - {"tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL}, - {"ssl", PGC_POSTMASTER, &EnableSSL, false, NULL}, - {"fsync", PGC_SIGHUP, &enableFsync, true, NULL}, - {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL}, - - {"log_connections", PGC_BACKEND, &Log_connections, false, NULL}, - {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL}, - {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL}, + { + "enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL + } , + { + "enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL + }, + { + "enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL + }, + { + "enable_sort", PGC_USERSET, &enable_sort, true, NULL + }, + { + "enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL + }, + { + "enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL + }, + { + "enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL + }, + + { + "ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL + }, + { + "geqo", PGC_USERSET, &enable_geqo, true, NULL + }, + + { + "tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL + }, + { + "ssl", PGC_POSTMASTER, &EnableSSL, false, NULL + }, + { + "fsync", PGC_SIGHUP, &enableFsync, true, NULL + }, + { + "silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL + }, + + { + "log_connections", PGC_BACKEND, &Log_connections, false, NULL + }, + { + "log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL + }, + { + "log_pid", PGC_SIGHUP, &Log_pid, false, NULL + }, #ifdef USE_ASSERT_CHECKING - {"debug_assertions", PGC_USERSET, &assert_enabled, true, NULL}, + { + "debug_assertions", PGC_USERSET, &assert_enabled, true, NULL + }, #endif - {"debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL}, - {"debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL}, - {"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL}, - {"debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL}, - {"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL}, + { + "debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL + }, + { + "debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL + }, + { + "debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL + }, + { + "debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL + }, + { + "debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL + }, - {"show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL}, - {"show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL}, - {"show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL}, - {"show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL}, + { + "show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL + }, + { + "show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL + }, + { + "show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL + }, + { + "show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL + }, #ifdef BTREE_BUILD_STATS - {"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL}, + { + "show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL + }, #endif - {"stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL}, - {"stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL}, - {"stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL}, - {"stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL}, - {"stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL}, + { + "stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL + }, + { + "stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL + }, + { + "stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL + }, + { + "stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL + }, + { + "stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL + }, - {"trace_notify", PGC_USERSET, &Trace_notify, false, NULL}, + { + "trace_notify", PGC_USERSET, &Trace_notify, false, NULL + }, #ifdef LOCK_DEBUG - {"trace_locks", PGC_SUSET, &Trace_locks, false, NULL}, - {"trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL}, - {"trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL}, - {"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL}, + { + "trace_locks", PGC_SUSET, &Trace_locks, false, NULL + }, + { + "trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL + }, + { + "trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL + }, + { + "debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL + }, #endif - {"hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL}, - {"show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL}, + { + "hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL + }, + { + "show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL + }, - {"sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL}, - {"australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache}, - {"fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL}, - {"password_encryption", PGC_USERSET, &Password_encryption, false, NULL}, - {"transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL}, + { + "sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL + }, + { + "australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache + }, + { + "fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL + }, + { + "password_encryption", PGC_USERSET, &Password_encryption, false, NULL + }, + { + "transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL + }, - {NULL, 0, NULL, false, NULL} + { + NULL, 0, NULL, false, NULL + } }; static struct config_int ConfigureNamesInt[] = { - {"geqo_threshold", PGC_USERSET, &geqo_rels, - DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL}, - {"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, - 1, 1, INT_MAX, NULL, NULL}, - {"geqo_generations", PGC_USERSET, &Geqo_generations, - 0, 0, INT_MAX, NULL, NULL}, - {"geqo_random_seed", PGC_USERSET, &Geqo_random_seed, - -1, INT_MIN, INT_MAX, NULL, NULL}, - - {"deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout, - 1000, 0, INT_MAX, NULL, NULL}, + { + "geqo_threshold", PGC_USERSET, &geqo_rels, + DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL + } , + { + "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, + 1, 1, INT_MAX, NULL, NULL + }, + { + "geqo_generations", PGC_USERSET, &Geqo_generations, + 0, 0, INT_MAX, NULL, NULL + }, + { + "geqo_random_seed", PGC_USERSET, &Geqo_random_seed, + -1, INT_MIN, INT_MAX, NULL, NULL + }, + + { + "deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout, + 1000, 0, INT_MAX, NULL, NULL + }, #ifdef ENABLE_SYSLOG - {"syslog", PGC_SIGHUP, &Use_syslog, - 0, 0, 2, NULL, NULL}, + { + "syslog", PGC_SIGHUP, &Use_syslog, + 0, 0, 2, NULL, NULL + }, #endif /* @@ -285,133 +389,215 @@ static struct config_int * sure the buffers are at least twice the number of backends, so the * constraints here are partially unused. */ - {"max_connections", PGC_POSTMASTER, &MaxBackends, - DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL}, + { + "max_connections", PGC_POSTMASTER, &MaxBackends, + DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL + }, - {"shared_buffers", PGC_POSTMASTER, &NBuffers, - DEF_NBUFFERS, 16, INT_MAX, NULL, NULL}, + { + "shared_buffers", PGC_POSTMASTER, &NBuffers, + DEF_NBUFFERS, 16, INT_MAX, NULL, NULL + }, - {"port", PGC_POSTMASTER, &PostPortNumber, - DEF_PGPORT, 1, 65535, NULL, NULL}, + { + "port", PGC_POSTMASTER, &PostPortNumber, + DEF_PGPORT, 1, 65535, NULL, NULL + }, - {"unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions, - 0777, 0000, 0777, NULL, NULL}, + { + "unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions, + 0777, 0000, 0777, NULL, NULL + }, - {"sort_mem", PGC_USERSET, &SortMem, - 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL}, + { + "sort_mem", PGC_USERSET, &SortMem, + 512, 4 * BLCKSZ / 1024, INT_MAX, NULL, NULL + }, - {"vacuum_mem", PGC_USERSET, &VacuumMem, - 8192, 1024, INT_MAX, NULL, NULL}, + { + "vacuum_mem", PGC_USERSET, &VacuumMem, + 8192, 1024, INT_MAX, NULL, NULL + }, - {"max_files_per_process", PGC_BACKEND, &max_files_per_process, - 1000, 25, INT_MAX, NULL, NULL}, + { + "max_files_per_process", PGC_BACKEND, &max_files_per_process, + 1000, 25, INT_MAX, NULL, NULL + }, - {"debug_level", PGC_USERSET, &DebugLvl, - 0, 0, 16, NULL, NULL}, + { + "debug_level", PGC_USERSET, &DebugLvl, + 0, 0, 16, NULL, NULL + }, #ifdef LOCK_DEBUG - {"trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin, - BootstrapObjectIdData, 1, INT_MAX, NULL, NULL}, - {"trace_lock_table", PGC_SUSET, &Trace_lock_table, - 0, 0, INT_MAX, NULL, NULL}, + { + "trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin, + BootstrapObjectIdData, 1, INT_MAX, NULL, NULL + }, + { + "trace_lock_table", PGC_SUSET, &Trace_lock_table, + 0, 0, INT_MAX, NULL, NULL + }, #endif - {"max_expr_depth", PGC_USERSET, &max_expr_depth, - DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL}, + { + "max_expr_depth", PGC_USERSET, &max_expr_depth, + DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL + }, - {"max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations, - 100, 10, INT_MAX, NULL, NULL}, - {"max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages, - 10000, 1000, INT_MAX, NULL, NULL}, + { + "max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations, + 100, 10, INT_MAX, NULL, NULL + }, + { + "max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages, + 10000, 1000, INT_MAX, NULL, NULL + }, - {"max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact, - 64, 10, INT_MAX, NULL, NULL}, + { + "max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact, + 64, 10, INT_MAX, NULL, NULL + }, - {"authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout, - 60, 1, 600, NULL, NULL}, + { + "authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout, + 60, 1, 600, NULL, NULL + }, - {"pre_auth_delay", PGC_SIGHUP, &PreAuthDelay, - 0, 0, 60, NULL, NULL}, + { + "pre_auth_delay", PGC_SIGHUP, &PreAuthDelay, + 0, 0, 60, NULL, NULL + }, - {"checkpoint_segments", PGC_SIGHUP, &CheckPointSegments, - 3, 1, INT_MAX, NULL, NULL}, + { + "checkpoint_segments", PGC_SIGHUP, &CheckPointSegments, + 3, 1, INT_MAX, NULL, NULL + }, - {"checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout, - 300, 30, 3600, NULL, NULL}, + { + "checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout, + 300, 30, 3600, NULL, NULL + }, - {"wal_buffers", PGC_POSTMASTER, &XLOGbuffers, - 8, 4, INT_MAX, NULL, NULL}, + { + "wal_buffers", PGC_POSTMASTER, &XLOGbuffers, + 8, 4, INT_MAX, NULL, NULL + }, - {"wal_files", PGC_SIGHUP, &XLOGfiles, - 0, 0, 64, NULL, NULL}, + { + "wal_files", PGC_SIGHUP, &XLOGfiles, + 0, 0, 64, NULL, NULL + }, - {"wal_debug", PGC_SUSET, &XLOG_DEBUG, - 0, 0, 16, NULL, NULL}, + { + "wal_debug", PGC_SUSET, &XLOG_DEBUG, + 0, 0, 16, NULL, NULL + }, - {"commit_delay", PGC_USERSET, &CommitDelay, - 0, 0, 100000, NULL, NULL}, + { + "commit_delay", PGC_USERSET, &CommitDelay, + 0, 0, 100000, NULL, NULL + }, - {"commit_siblings", PGC_USERSET, &CommitSiblings, - 5, 1, 1000, NULL, NULL}, + { + "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 + } }; static struct config_real ConfigureNamesReal[] = { - {"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, - DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL}, - {"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, - DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL}, - {"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, - DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS, - MAX_GEQO_SELECTION_BIAS, NULL, NULL}, - - {NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL} + { + "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, + DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL + }, + { + "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, + DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL + }, + { + "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, + DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS, + MAX_GEQO_SELECTION_BIAS, NULL, NULL + }, + + { + NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL + } }; static struct config_string ConfigureNamesString[] = { - {"default_transaction_isolation", PGC_USERSET, &default_iso_level_string, - "read committed", check_defaultxactisolevel, assign_defaultxactisolevel}, + { + "default_transaction_isolation", PGC_USERSET, &default_iso_level_string, + "read committed", check_defaultxactisolevel, assign_defaultxactisolevel + } , - {"dynamic_library_path", PGC_SUSET, &Dynamic_library_path, - "$libdir", NULL, NULL}, + { + "dynamic_library_path", PGC_SUSET, &Dynamic_library_path, + "$libdir", NULL, NULL + }, - {"krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile, - PG_KRB_SRVTAB, NULL, NULL}, + { + "krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile, + PG_KRB_SRVTAB, NULL, NULL + }, #ifdef ENABLE_SYSLOG - {"syslog_facility", PGC_POSTMASTER, &Syslog_facility, - "LOCAL0", check_facility, NULL}, - {"syslog_ident", PGC_POSTMASTER, &Syslog_ident, - "postgres", NULL, NULL}, + { + "syslog_facility", PGC_POSTMASTER, &Syslog_facility, + "LOCAL0", check_facility, NULL + }, + { + "syslog_ident", PGC_POSTMASTER, &Syslog_ident, + "postgres", NULL, NULL + }, #endif - {"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group, - "", NULL, NULL}, + { + "unix_socket_group", PGC_POSTMASTER, &Unix_socket_group, + "", NULL, NULL + }, - {"unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir, - "", NULL, NULL}, + { + "unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir, + "", NULL, NULL + }, - {"virtual_host", PGC_POSTMASTER, &VirtualHost, - "", NULL, NULL}, + { + "virtual_host", PGC_POSTMASTER, &VirtualHost, + "", NULL, NULL + }, - {"wal_sync_method", PGC_SIGHUP, &XLOG_sync_method, - XLOG_sync_method_default, check_xlog_sync_method, - assign_xlog_sync_method}, + { + "wal_sync_method", PGC_SIGHUP, &XLOG_sync_method, + XLOG_sync_method_default, check_xlog_sync_method, + assign_xlog_sync_method + }, - {NULL, 0, NULL, NULL, NULL, NULL} + { + NULL, 0, NULL, NULL, NULL, NULL + } }; /******** end of options list ********/ @@ -628,10 +814,10 @@ parse_int(const char *value, int *result) val = strtol(value, &endptr, 0); if (endptr == value || *endptr != '\0' || errno == ERANGE #ifdef HAVE_LONG_INT_64 - /* if long > 32 bits, check for overflow of int4 */ + /* if long > 32 bits, check for overflow of int4 */ || val != (long) ((int32) val) #endif - ) + ) return false; if (result) *result = (int) val; @@ -715,23 +901,24 @@ set_config_option(const char *name, const char *value, case PGC_SIGHUP: if (context != PGC_SIGHUP && context != PGC_POSTMASTER) elog(ERROR, "'%s' cannot be changed now", name); + /* - * Hmm, the idea of the SIGHUP context is "ought to be global, but - * can be changed after postmaster start". But there's nothing - * that prevents a crafty administrator from sending SIGHUP - * signals to individual backends only. + * Hmm, the idea of the SIGHUP context is "ought to be global, + * but can be changed after postmaster start". But there's + * nothing that prevents a crafty administrator from sending + * SIGHUP signals to individual backends only. */ break; case PGC_BACKEND: if (context == PGC_SIGHUP) { /* - * If a PGC_BACKEND parameter is changed in the config file, - * we want to accept the new value in the postmaster (whence - * it will propagate to subsequently-started backends), but - * ignore it in existing backends. This is a tad klugy, but - * necessary because we don't re-read the config file during - * backend start. + * If a PGC_BACKEND parameter is changed in the config + * file, we want to accept the new value in the postmaster + * (whence it will propagate to subsequently-started + * backends), but ignore it in existing backends. This is + * a tad klugy, but necessary because we don't re-read the + * config file during backend start. */ if (IsUnderPostmaster) return true; @@ -903,7 +1090,8 @@ set_config_option(const char *name, const char *value, if (makeDefault) { str = strdup(value); - if (str == NULL) { + if (str == NULL) + { elog(elevel, "out of memory"); return false; } @@ -1006,10 +1194,10 @@ GetConfigOption(const char *name) } static void -_ShowOption(enum config_type opttype, struct config_generic *record) +_ShowOption(enum config_type opttype, struct config_generic * record) { - char buffer[256]; - char *val; + char buffer[256]; + char *val; switch (opttype) { @@ -1046,16 +1234,16 @@ ShowAllGUCConfig(void) int i; for (i = 0; ConfigureNamesBool[i].name; i++) - _ShowOption(PGC_BOOL, (struct config_generic *)&ConfigureNamesBool[i]); + _ShowOption(PGC_BOOL, (struct config_generic *) & ConfigureNamesBool[i]); for (i = 0; ConfigureNamesInt[i].name; i++) - _ShowOption(PGC_INT, (struct config_generic *)&ConfigureNamesInt[i]); + _ShowOption(PGC_INT, (struct config_generic *) & ConfigureNamesInt[i]); for (i = 0; ConfigureNamesReal[i].name; i++) - _ShowOption(PGC_REAL, (struct config_generic *)&ConfigureNamesReal[i]); + _ShowOption(PGC_REAL, (struct config_generic *) & ConfigureNamesReal[i]); for (i = 0; ConfigureNamesString[i].name; i++) - _ShowOption(PGC_STRING, (struct config_generic *)&ConfigureNamesString[i]); + _ShowOption(PGC_STRING, (struct config_generic *) & ConfigureNamesString[i]); } @@ -1132,7 +1320,6 @@ check_facility(const char *facility) return true; return false; } - #endif diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index 9441aa0056..65d2e10cdb 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.7 2001/10/22 19:41:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.8 2001/10/25 05:49:51 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * various details abducted from various places @@ -83,7 +83,6 @@ static const size_t ps_buffer_size = PS_BUFFER_SIZE; #else /* PS_USE_CLOBBER_ARGV */ static char *ps_buffer; /* will point to argv area */ static size_t ps_buffer_size; /* space determined at run time */ - #endif /* PS_USE_CLOBBER_ARGV */ static size_t ps_buffer_fixed_size; /* size of the constant prefix */ @@ -97,7 +96,7 @@ static char **save_argv; * Call this early in startup to save the original argc/argv values. * * argv[] will not be overwritten by this routine, but may be overwritten - * during init_ps_display. Also, the physical location of the environment + * during init_ps_display. Also, the physical location of the environment * strings may be moved, so this should be called before any code that * might try to hang onto a getenv() result. */ @@ -108,6 +107,7 @@ save_ps_display_args(int argc, char *argv[]) save_argv = argv; #ifdef PS_USE_CLOBBER_ARGV + /* * If we're going to overwrite the argv area, count the available * space. Also move the environment to make additional room. @@ -126,7 +126,7 @@ save_ps_display_args(int argc, char *argv[]) end_of_area = argv[i] + strlen(argv[i]); } - if (end_of_area == NULL) /* probably can't happen? */ + if (end_of_area == NULL)/* probably can't happen? */ { ps_buffer = NULL; ps_buffer_size = 0; @@ -159,7 +159,7 @@ save_ps_display_args(int argc, char *argv[]) /* * Call this once during subprocess startup to set the identification - * values. At this point, the original argv[] array may be overwritten. + * values. At this point, the original argv[] array may be overwritten. */ void init_ps_display(const char *username, const char *dbname, @@ -201,6 +201,7 @@ init_ps_display(const char *username, const char *dbname, */ #ifdef PS_USE_SETPROCTITLE + /* * apparently setproctitle() already adds a `progname:' prefix to the * ps line @@ -273,7 +274,6 @@ set_ps_display(const char *activity) *cp = PS_PADDING; } #endif /* PS_USE_CLOBBER_ARGV */ - #endif /* not PS_USE_NONE */ } diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index f66e021ad5..24fd0d1793 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.41 2001/03/22 04:00:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.42 2001/10/25 05:49:51 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -207,7 +207,6 @@ static void AllocSetDelete(MemoryContext context); #ifdef MEMORY_CONTEXT_CHECKING static void AllocSetCheck(MemoryContext context); - #endif static void AllocSetStats(MemoryContext context); @@ -359,7 +358,6 @@ AllocSetContextCreate(MemoryContext parent, static void AllocSetInit(MemoryContext context) { - /* * Since MemoryContextCreate already zeroed the context node, we don't * have to do anything here: it's already OK. @@ -581,7 +579,6 @@ AllocSetAlloc(MemoryContext context, Size size) if (availspace < (chunk_size + ALLOC_CHUNKHDRSZ)) { - /* * The existing active (top) block does not have enough room * for the requested allocation, but it might still have a @@ -745,7 +742,6 @@ AllocSetFree(MemoryContext context, void *pointer) if (chunk->size > ALLOC_CHUNK_LIMIT) { - /* * Big chunks are certain to have been allocated as single-chunk * blocks. Find the containing block and return it to malloc(). @@ -837,7 +833,6 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) if (oldsize > ALLOC_CHUNK_LIMIT) { - /* * The chunk must been allocated as a single-chunk block. Find * the containing block and use realloc() to make it bigger with @@ -893,7 +888,6 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) } else { - /* * Small-chunk case. If the chunk is the last one in its block, * there might be enough free space after it that we can just @@ -1088,5 +1082,4 @@ AllocSetCheck(MemoryContext context) name, block); } } - #endif /* MEMORY_CONTEXT_CHECKING */ diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 402e4010f7..59ecb6f3fc 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.28 2001/03/22 04:00:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.29 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -263,7 +263,6 @@ MemoryContextCheck(MemoryContext context) for (child = context->firstchild; child != NULL; child = child->nextchild) MemoryContextCheck(child); } - #endif /* diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index bd48394b8c..25171ea7be 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.43 2001/10/05 17:28:13 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.44 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -257,7 +257,7 @@ PortalDrop(Portal portal) * * XXX This assumes that portals can be deleted in a random order, ie, * no portal has a reference to any other (at least not one that will be - * exercised during deletion). I think this is okay at the moment, but + * exercised during deletion). I think this is okay at the moment, but * we've had bugs of that ilk in the past. Keep a close eye on cursor * references... */ @@ -270,7 +270,5 @@ AtEOXact_portals(void) hash_seq_init(&status, PortalHashTable); while ((hentry = (PortalHashEnt *) hash_seq_search(&status)) != NULL) - { PortalDrop(hentry->portal); - } } diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c index 30d1f0f186..6b27e5de4d 100644 --- a/src/backend/utils/sort/logtape.c +++ b/src/backend/utils/sort/logtape.c @@ -64,7 +64,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.6 2001/01/24 19:43:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.7 2001/10/25 05:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -224,7 +224,6 @@ ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer) static long ltsGetFreeBlock(LogicalTapeSet *lts) { - /* * If there are multiple free blocks, we select the one appearing last * in freeBlocks[]. If there are none, assign the next block at the @@ -286,7 +285,6 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect, { if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK) { - /* * This indirect block is full, so dump it out and recursively * save its address in the next indirection level. Create a new @@ -365,7 +363,6 @@ static long ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts, IndirectBlock *indirect) { - /* * If block is not topmost, recurse to obtain address of first block * in this hierarchy level. Read that one in. @@ -612,7 +609,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) { if (lt->writing) { - /* * Completion of a write phase. Flush last partial data * block, flush any partial indirect blocks, rewind for normal @@ -626,7 +622,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) } else { - /* * This is only OK if tape is frozen; we rewind for (another) * read pass. @@ -649,7 +644,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) } else { - /* * Completion of a read phase. Rewind and prepare for write. * diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index f4e2faaa2b..5cf8e3ad1d 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.18 2001/08/21 16:36:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.19 2001/10/25 05:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -104,12 +104,13 @@ */ typedef enum { - TSS_INITIAL, /* Loading tuples; still within memory + TSS_INITIAL, /* Loading tuples; still within memory * limit */ - TSS_BUILDRUNS, /* Loading tuples; writing to tape */ - TSS_SORTEDINMEM, /* Sort completed entirely in memory */ - TSS_SORTEDONTAPE, /* Sort completed, final run is on tape */ - TSS_FINALMERGE /* Performing final merge on-the-fly */ + TSS_BUILDRUNS, /* Loading tuples; writing to tape */ + TSS_SORTEDINMEM,/* Sort completed entirely in memory */ + TSS_SORTEDONTAPE, /* Sort completed, final run is on + * tape */ + TSS_FINALMERGE /* Performing final merge on-the-fly */ } TupSortStatus; /* @@ -135,10 +136,9 @@ struct Tuplesortstate * kind of tuple we are sorting from the routines that don't need to * know it. They are set up by the tuplesort_begin_xxx routines. * - * Function to compare two tuples; result is per qsort() convention, - * ie: + * Function to compare two tuples; result is per qsort() convention, ie: * - * <0, 0, >0 according as a<b, a=b, a>b. + * <0, 0, >0 according as a<b, a=b, a>b. */ int (*comparetup) (Tuplesortstate *state, const void *a, const void *b); @@ -584,7 +584,10 @@ tuplesort_end(Tuplesortstate *state) if (state->memtupindex) pfree(state->memtupindex); - /* this stuff might better belong in a variant-specific shutdown routine */ + /* + * this stuff might better belong in a variant-specific shutdown + * routine + */ if (state->scanKeys) pfree(state->scanKeys); if (state->sortFnKinds) @@ -601,7 +604,6 @@ tuplesort_end(Tuplesortstate *state) void tuplesort_puttuple(Tuplesortstate *state, void *tuple) { - /* * Copy the given tuple into memory we control, and decrease availMem. * Then call the code shared with the Datum case. @@ -660,7 +662,7 @@ puttuple_common(Tuplesortstate *state, void *tuple) { switch (state->status) { - case TSS_INITIAL: + case TSS_INITIAL: /* * Save the copied tuple into the unsorted array. @@ -732,7 +734,7 @@ tuplesort_performsort(Tuplesortstate *state) { switch (state->status) { - case TSS_INITIAL: + case TSS_INITIAL: /* * We were able to accumulate all the tuples within the @@ -843,7 +845,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, */ if (state->eof_reached) { - /* * Seek position is pointing just past the zero tuplen at * the end of file; back up to fetch last tuple's ending @@ -858,7 +859,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, } else { - /* * Back up and fetch previously-returned tuple's ending * length word. If seek fails, assume we are at start of @@ -877,7 +877,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, state->result_tape, tuplen + 2 * sizeof(unsigned int))) { - /* * If that fails, presumably the prev tuple is the * first in the file. Back up so that it becomes next @@ -928,7 +927,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, tuplesort_heap_siftup(state, false); if ((tupIndex = state->mergenext[srcTape]) == 0) { - /* * out of preloaded data on this tape, try to read * more @@ -1457,7 +1455,6 @@ dumptuples(Tuplesortstate *state, bool alltuples) while (alltuples || (LACKMEM(state) && state->memtupcount > 1)) { - /* * Dump the heap's frontmost entry, and sift up to remove it from * the heap. @@ -2037,10 +2034,10 @@ tuplesize_datum(Tuplesortstate *state, void *tup) /* * This routine selects an appropriate sorting function to implement - * a sort operator as efficiently as possible. The straightforward + * a sort operator as efficiently as possible. The straightforward * method is to use the operator's implementation proc --- ie, "<" - * comparison. However, that way often requires two calls of the function - * per comparison. If we can find a btree three-way comparator function + * comparison. However, that way often requires two calls of the function + * per comparison. If we can find a btree three-way comparator function * associated with the operator, we can use it to do the comparisons * more efficiently. We also support the possibility that the operator * is ">" (descending sort), in which case we have to reverse the output @@ -2061,12 +2058,12 @@ SelectSortFunction(Oid sortOperator, Oid opclass = InvalidOid; /* - * Scan pg_amop to see if the target operator is registered as the - * "<" or ">" operator of any btree opclass. It's possible that it - * might be registered both ways (eg, if someone were to build a - * "reverse sort" opclass for some reason); prefer the "<" case if so. - * If the operator is registered the same way in multiple opclasses, - * assume we can use the associated comparator function from any one. + * Scan pg_amop to see if the target operator is registered as the "<" + * or ">" operator of any btree opclass. It's possible that it might + * be registered both ways (eg, if someone were to build a "reverse + * sort" opclass for some reason); prefer the "<" case if so. If the + * operator is registered the same way in multiple opclasses, assume + * we can use the associated comparator function from any one. */ ScanKeyEntryInitialize(&skey[0], 0x0, Anum_pg_amop_amopopr, @@ -2109,6 +2106,7 @@ SelectSortFunction(Oid sortOperator, if (HeapTupleIsValid(tuple)) { Form_pg_amproc aform = (Form_pg_amproc) GETSTRUCT(tuple); + *sortFunction = aform->amproc; ReleaseSysCache(tuple); Assert(RegProcedureIsValid(*sortFunction)); @@ -2119,7 +2117,8 @@ SelectSortFunction(Oid sortOperator, /* * Can't find a comparator, so use the operator as-is. Decide whether * it is forward or reverse sort by looking at its name (grotty, but - * this only matters for deciding which end NULLs should get sorted to). + * this only matters for deciding which end NULLs should get sorted + * to). */ tuple = SearchSysCache(OPEROID, ObjectIdGetDatum(sortOperator), @@ -2202,8 +2201,8 @@ ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, } if (isNull2) return 1; - return - DatumGetInt32(FunctionCall2(sortFunction, - datum1, datum2)); + return -DatumGetInt32(FunctionCall2(sortFunction, + datum1, datum2)); default: elog(ERROR, "Invalid SortFunctionKind %d", (int) kind); diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 7621e57297..6e241c480f 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -26,7 +26,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.3 2001/03/22 04:00:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.4 2001/10/25 05:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,11 +43,11 @@ */ typedef enum { - TSS_INITIAL, /* Loading tuples; still within memory + TSS_INITIAL, /* Loading tuples; still within memory * limit */ - TSS_WRITEFILE, /* Loading tuples; writing to temp file */ - TSS_READMEM, /* Reading tuples; entirely in memory */ - TSS_READFILE /* Reading tuples from temp file */ + TSS_WRITEFILE, /* Loading tuples; writing to temp file */ + TSS_READMEM, /* Reading tuples; entirely in memory */ + TSS_READFILE /* Reading tuples from temp file */ } TupStoreStatus; /* @@ -271,7 +271,6 @@ tuplestore_end(Tuplestorestate *state) void tuplestore_puttuple(Tuplestorestate *state, void *tuple) { - /* * Copy the tuple. (Must do this even in WRITEFILE case.) */ @@ -324,7 +323,7 @@ tuplestore_donestoring(Tuplestorestate *state) { switch (state->status) { - case TSS_INITIAL: + case TSS_INITIAL: /* * We were able to accumulate all the tuples within the @@ -432,7 +431,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, */ if (state->eof_reached) { - /* * Seek position is pointing just past the zero tuplen at * the end of file; back up to fetch last tuple's ending @@ -447,7 +445,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, } else { - /* * Back up and fetch previously-returned tuple's ending * length word. If seek fails, assume we are at start of @@ -466,7 +463,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, -(long) (tuplen + 2 * sizeof(unsigned int)), SEEK_CUR) != 0) { - /* * If that fails, presumably the prev tuple is the * first in the file. Back up so that it becomes next diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index f0536d7611..194959f6cc 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.42 2001/08/26 16:56:00 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.43 2001/10/25 05:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -324,7 +324,7 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) { if (th->t_infomask & HEAP_MARKED_FOR_UPDATE) return HeapTupleMayBeUpdated; - return HeapTupleUpdated;/* updated by other */ + return HeapTupleUpdated; /* updated by other */ } if (TransactionIdIsCurrentTransactionId(th->t_xmax)) @@ -374,7 +374,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) if (tuple->t_infomask & HEAP_MOVED_OFF) { - /* * HeapTupleSatisfiesDirty is used by unique btree-s and so * may be used while vacuuming. @@ -592,7 +591,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) * HeapTupleSatisfiesVacuum - determine tuple status for VACUUM and related * operations * - * OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples + * OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples * deleted by XIDs >= OldestXmin are deemed "recently dead"; they might * still be visible to some open transaction, so we can't remove them, * even if we see that the deleting transaction has committed. @@ -614,9 +613,9 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) * NOTE: must check TransactionIdIsInProgress (which looks in PROC array) * before TransactionIdDidCommit/TransactionIdDidAbort (which look in * pg_clog). Otherwise we have a race condition where we might decide - * that a just-committed transaction crashed, because none of the tests - * succeed. xact.c is careful to record commit/abort in pg_clog before - * it unsets MyProc->xid in PROC array. + * that a just-committed transaction crashed, because none of the + * tests succeed. xact.c is careful to record commit/abort in pg_clog + * before it unsets MyProc->xid in PROC array. */ if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { @@ -655,8 +654,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) else { /* - * Not in Progress, Not Committed, Not Aborted - - * so it's from crashed process. - vadim 11/26/96 + * Not in Progress, Not Committed, Not Aborted - so it's from + * crashed process. - vadim 11/26/96 */ tuple->t_infomask |= HEAP_XMIN_INVALID; return HEAPTUPLE_DEAD; @@ -666,7 +665,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) } /* - * Okay, the inserter committed, so it was good at some point. Now + * Okay, the inserter committed, so it was good at some point. Now * what about the deleting transaction? */ if (tuple->t_infomask & HEAP_XMAX_INVALID) @@ -686,8 +685,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) else { /* - * Not in Progress, Not Committed, Not Aborted - - * so it's from crashed process. - vadim 06/02/97 + * Not in Progress, Not Committed, Not Aborted - so it's from + * crashed process. - vadim 06/02/97 */ tuple->t_infomask |= HEAP_XMAX_INVALID; return HEAPTUPLE_LIVE; @@ -708,7 +707,10 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) if (TransactionIdEquals(tuple->t_xmin, tuple->t_xmax)) { - /* inserter also deleted it, so it was never visible to anyone else */ + /* + * inserter also deleted it, so it was never visible to anyone + * else + */ return HEAPTUPLE_DEAD; } diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b04b3d8eb7..d9d358892c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.59 2001/10/22 19:31:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.60 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -166,13 +166,13 @@ findParentsByOid(TableInfo *tblinfo, int numTables, selfInd = findTableByOid(tblinfo, numTables, oid); if (selfInd >= 0) write_msg(NULL, "failed sanity check, parent oid %s of table %s (oid %s) not found\n", - inhinfo[i].inhparent, - tblinfo[selfInd].relname, - oid); + inhinfo[i].inhparent, + tblinfo[selfInd].relname, + oid); else write_msg(NULL, "failed sanity check, parent oid %s of table (oid %s) not found\n", - inhinfo[i].inhparent, - oid); + inhinfo[i].inhparent, + oid); exit_nicely(); } @@ -267,7 +267,7 @@ strInArray(const char *pattern, char **arr, int arr_size) * */ -TableInfo * +TableInfo * dumpSchema(Archive *fout, int *numTablesPtr, const char *tablename, @@ -411,12 +411,12 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, int parentInd; int inhAttrInd; int (*parentIndexes)[]; - bool foundAttr; /* Attr was found in a parent */ + bool foundAttr; /* Attr was found in a parent */ bool foundNotNull; /* Attr was NOT NULL in a parent */ bool defaultsMatch; /* All non-empty defaults match */ bool defaultsFound; /* Found a default in a parent */ - char *attrDef; - char *inhDef; + char *attrDef; + char *inhDef; /* * we go backwards because the tables in tblinfo are in OID order, @@ -438,15 +438,13 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, &parentIndexes); /* - * For each attr, check the parent info: if no parent has - * an attr with the same name, then it's not inherited. If there - * *is* an attr with the same name, then only dump it if: + * For each attr, check the parent info: if no parent has an attr + * with the same name, then it's not inherited. If there *is* an + * attr with the same name, then only dump it if: * - * - it is NOT NULL and zero parents are NOT NULL - * OR - * - it has a default value AND the default value - * does not match all parent default values, or - * no parents specify a default. + * - it is NOT NULL and zero parents are NOT NULL OR - it has a + * default value AND the default value does not match all parent + * default values, or no parents specify a default. * * See discussion on -hackers around 2-Apr-2001. */ @@ -479,7 +477,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, { foundAttr = true; foundNotNull |= tblinfo[parentInd].notnull[inhAttrInd]; - if (attrDef != NULL) /* It we have a default, check parent */ + if (attrDef != NULL) /* It we have a default, + * check parent */ { inhDef = tblinfo[parentInd].adef_expr[inhAttrInd]; @@ -492,25 +491,31 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, }; }; - /* - * Based on the scan of the parents, decide if we - * can rely on the inherited attr + /* + * Based on the scan of the parents, decide if we can rely on + * the inherited attr */ - if (foundAttr) /* Attr was inherited */ + if (foundAttr) /* Attr was inherited */ { /* Set inherited flag by default */ tblinfo[i].inhAttrs[j] = 1; tblinfo[i].inhAttrDef[j] = 1; tblinfo[i].inhNotNull[j] = 1; - /* Clear it if attr had a default, but parents did not, or mismatch */ - if ( (attrDef != NULL) && (!defaultsFound || !defaultsMatch) ) + /* + * Clear it if attr had a default, but parents did not, or + * mismatch + */ + if ((attrDef != NULL) && (!defaultsFound || !defaultsMatch)) { tblinfo[i].inhAttrs[j] = 0; tblinfo[i].inhAttrDef[j] = 0; } - /* Clear it if NOT NULL and none of the parents were NOT NULL */ + /* + * Clear it if NOT NULL and none of the parents were NOT + * NULL + */ if (tblinfo[i].notnull[j] && !foundNotNull) { tblinfo[i].inhAttrs[j] = 0; @@ -631,7 +636,6 @@ fmtId(const char *rawid, bool force_quotes) appendPQExpBufferChar(id_return, '\"'); for (cp = rawid; *cp; cp++) { - /* * Did we find a double-quote in the string? Then make this a * double double-quote per SQL99. Before, we put in a diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index b06ff43973..3c359ff99f 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.15 2001/10/03 21:58:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.16 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -56,11 +56,11 @@ typedef enum _archiveFormat { - archUnknown = 0, - archCustom = 1, - archFiles = 2, - archTar = 3, - archNull = 4 + archUnknown = 0, + archCustom = 1, + archFiles = 2, + archTar = 3, + archNull = 4 } ArchiveFormat; /* @@ -69,10 +69,10 @@ typedef enum _archiveFormat */ typedef struct _Archive { - int verbose; - int remoteVersion; - int minRemoteVersion; - int maxRemoteVersion; + int verbose; + int remoteVersion; + int minRemoteVersion; + int maxRemoteVersion; /* The rest is private */ } Archive; @@ -85,7 +85,8 @@ typedef struct _restoreOptions * original object owner */ int noReconnect; /* Don't reconnect to database under any * cirsumstances */ - int use_setsessauth; /* use SET SESSSION AUTHORIZATION instead of \connect */ + int use_setsessauth;/* use SET SESSSION AUTHORIZATION instead + * of \connect */ char *superuser; /* Username to use as superuser */ int dataOnly; int dropSchema; @@ -123,18 +124,20 @@ typedef struct _restoreOptions int limitToList; int compression; - int suppressDumpWarnings; /* Suppress output of WARNING entries to stderr */ + int suppressDumpWarnings; /* Suppress output of WARNING + * entries to stderr */ } RestoreOptions; /* * Main archiver interface. */ -extern void exit_horribly(Archive *AH, const char *modulename, const char *fmt, ...) -__attribute__((format(printf,3,4))); +extern void +exit_horribly(Archive *AH, const char *modulename, const char *fmt,...) +__attribute__((format(printf, 3, 4))); extern char * -simple_prompt(const char *prompt, int maxlen, bool echo); + simple_prompt(const char *prompt, int maxlen, bool echo); /* Lets the archibe know we have a DB connection to shutdown if it dies */ @@ -189,8 +192,8 @@ extern void SortTocFromFile(Archive *AH, RestoreOptions *ropt); /* Convenience functions used only when writing DATA */ extern int archputs(const char *s, Archive *AH); extern int archputc(const char c, Archive *AH); -extern int archprintf(Archive *AH, const char *fmt, ...) +extern int +archprintf(Archive *AH, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); - #endif diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 55bbddec9b..75c5ef0075 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.34 2001/10/23 21:26:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.35 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -42,20 +42,20 @@ * - Only disable triggers in DataOnly (or implied data-only) restores. * * Modifications - 31-Mar-2001 - pjw@rhyme.com.au - * + * * - Rudimentary support for dependencies in archives. Current implementation * uses dependencies to modify the OID used in sorting TOC entries. * This will NOT handle multi-level dependencies, but will manage simple * relationships like UDTs & their functions. * - * - Treat OIDs with more respect (avoid using ints, use macros for + * - Treat OIDs with more respect (avoid using ints, use macros for * conversion & comparison). * * Modifications - 10-May-2001 - pjw@rhyme.com.au * - Treat SEQUENCE SET TOC entries as data entries rather than schema * entries. * - Make allowance for data entries that did not have a data dumper - * routine (eg. SEQUENCE SET) + * routine (eg. SEQUENCE SET) * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ static void _moveAfter(ArchiveHandle *AH, TocEntry *pos, TocEntry *te); static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te); static int _discoverArchiveFormat(ArchiveHandle *AH); static void _fixupOidInfo(TocEntry *te); -static Oid _findMaxOID(const char *((*deps)[])); +static Oid _findMaxOID(const char *((*deps)[])); const char *progname; static char *modulename = gettext_noop("archiver"); @@ -110,7 +110,7 @@ static int _restoringToDB(ArchiveHandle *AH); /* Create a new archive */ /* Public */ -Archive * +Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const int compression) @@ -122,7 +122,7 @@ CreateArchive(const char *FileSpec, const ArchiveFormat fmt, /* Open an existing archive */ /* Public */ -Archive * +Archive * OpenArchive(const char *FileSpec, const ArchiveFormat fmt) { ArchiveHandle *AH = _allocAH(FileSpec, fmt, 0, archModeRead); @@ -167,8 +167,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) * * NB: create+dropSchema is useless because if you're creating the DB, * there's no need to drop individual items in it. Moreover, if we - * tried to do that then we'd issue the drops in the database initially - * connected to, not the one we will create, which is very bad... + * tried to do that then we'd issue the drops in the database + * initially connected to, not the one we will create, which is very + * bad... */ if (ropt->create && ropt->noReconnect) die_horribly(AH, modulename, "-C and -R are incompatible options\n"); @@ -238,7 +239,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) write_msg(modulename, "WARNING:\n" " Data restoration may fail because existing triggers cannot be disabled\n" " (no superuser user name specified). This is only a problem when\n" - " restoring into a database with already existing triggers.\n"); + " restoring into a database with already existing triggers.\n"); /* * Setup the output file if necessary. @@ -283,11 +284,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) /* Dump any relevant dump warnings to stderr */ if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0) { - if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0) + if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0) write_msg(modulename, "warning from original dump file: %s\n", te->defn); else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0) write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt); - } + } defnDumped = false; @@ -306,18 +307,20 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ahlog(AH, 1, "connecting to new database %s as user %s\n", te->name, te->owner); _reconnectAsUser(AH, te->name, te->owner); } - } + } /* * If we have a data component, then process it */ - if ( (reqs & 2) != 0 ) + if ((reqs & 2) != 0) { - /* hadDumper will be set if there is genuine data component for this - * node. Otherwise, we need to check the defn field for statements - * that need to be executed in data-only restores. + /* + * hadDumper will be set if there is genuine data component + * for this node. Otherwise, we need to check the defn field + * for statements that need to be executed in data-only + * restores. */ - if (te->hadDumper) + if (te->hadDumper) { /* * If we can output the data, then restore it. @@ -332,16 +335,17 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) _printTocEntry(AH, te, ropt, true); /* - * Maybe we can't do BLOBS, so check if this node is for BLOBS + * Maybe we can't do BLOBS, so check if this node is + * for BLOBS */ if ((strcmp(te->desc, "BLOBS") == 0) && !_canRestoreBlobs(AH)) { ahprintf(AH, "--\n-- SKIPPED \n--\n\n"); /* - * This is a bit nasty - we assume, for the moment, that - * if a custom output is used, then we don't want - * warnings. + * This is a bit nasty - we assume, for the + * moment, that if a custom output is used, then + * we don't want warnings. */ if (!AH->CustomOutPtr) write_msg(modulename, "WARNING: skipping large object restoration\n"); @@ -353,21 +357,23 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) _disableTriggersIfNecessary(AH, te, ropt); /* - * Reconnect if necessary (_disableTriggers may have - * reconnected) + * Reconnect if necessary (_disableTriggers may + * have reconnected) */ _reconnectAsOwner(AH, NULL, te); ahlog(AH, 1, "restoring data for table %s\n", te->name); /* - * If we have a copy statement, use it. As of V1.3, these - * are separate to allow easy import from withing a - * database connection. Pre 1.3 archives can not use DB - * connections and are sent to output only. + * If we have a copy statement, use it. As of + * V1.3, these are separate to allow easy import + * from withing a database connection. Pre 1.3 + * archives can not use DB connections and are + * sent to output only. * - * For V1.3+, the table data MUST have a copy statement so - * that we can go into appropriate mode with libpq. + * For V1.3+, the table data MUST have a copy + * statement so that we can go into appropriate + * mode with libpq. */ if (te->copyStmt && strlen(te->copyStmt) > 0) ahprintf(AH, te->copyStmt); @@ -377,8 +383,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) _enableTriggersIfNecessary(AH, te, ropt); } } - } else if (!defnDumped) { - /* If we haven't already dumped the defn part, do so now */ + } + else if (!defnDumped) + { + /* If we haven't already dumped the defn part, do so now */ ahlog(AH, 1, "executing %s %s\n", te->desc, te->name); _printTocEntry(AH, te, ropt, false); } @@ -493,7 +501,6 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop { if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH)) { - /* * If we're not allowing changes for ownership, then remember * the user so we can change it back here. Otherwise, let @@ -552,7 +559,6 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt { if (!_restoringToDB(AH) || !ConnectedUserIsSuperuser(AH)) { - /* * If we're not allowing changes for ownership, then remember * the user so we can change it back here. Otherwise, let @@ -1065,7 +1071,6 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression) #ifdef HAVE_LIBZ char fmode[10]; - #endif int fn = 0; @@ -1233,7 +1238,6 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) } else { - /* * If we're doing a restore, and it's direct to DB, and we're * connected then send it to the DB. @@ -1262,7 +1266,7 @@ _write_msg(const char *modulename, const char *fmt, va_list ap) } void -write_msg(const char *modulename, const char *fmt, ...) +write_msg(const char *modulename, const char *fmt,...) { va_list ap; @@ -1469,7 +1473,7 @@ _discoverArchiveFormat(ArchiveHandle *AH) int wantClose = 0; #if 0 - write_msg(modulename, "attempting to ascertain archive format\n"); + write_msg(modulename, "attempting to ascertain archive format\n"); #endif if (AH->lookahead) @@ -1534,7 +1538,6 @@ _discoverArchiveFormat(ArchiveHandle *AH) } else { - /* * *Maybe* we have a tar archive format file... So, read first 512 * byte header... @@ -1554,7 +1557,6 @@ _discoverArchiveFormat(ArchiveHandle *AH) /* If we can't seek, then mark the header as read */ if (fseek(fh, 0, SEEK_SET) != 0) { - /* * NOTE: Formats that use the looahead buffer can unset this in * their Init routine. @@ -1588,7 +1590,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ArchiveHandle *AH; #if 0 - write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt); + write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt); #endif AH = (ArchiveHandle *) calloc(1, sizeof(ArchiveHandle)); @@ -1638,7 +1640,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, AH->OF = stdout; #if 0 - write_msg(modulename, "archive format is %d\n", fmt); + write_msg(modulename, "archive format is %d\n", fmt); #endif if (fmt == archUnknown) @@ -1747,12 +1749,10 @@ WriteToc(ArchiveHandle *AH) if (te->depOid != NULL) { i = 0; - while( (dep = (*te->depOid)[i++]) != NULL) - { + while ((dep = (*te->depOid)[i++]) != NULL) WriteStr(AH, dep); - } } - WriteStr(AH, NULL); /* Terminate List */ + WriteStr(AH, NULL); /* Terminate List */ if (AH->WriteExtraTocPtr) (*AH->WriteExtraTocPtr) (AH, te); @@ -1764,7 +1764,7 @@ void ReadToc(ArchiveHandle *AH) { int i; - char *((*deps)[]); + char *((*deps)[]); int depIdx; int depSize; @@ -1800,14 +1800,14 @@ ReadToc(ArchiveHandle *AH) if (AH->version >= K_VERS_1_5) { depSize = 100; - deps = malloc(sizeof(char*) * depSize); + deps = malloc(sizeof(char *) * depSize); depIdx = 0; do { if (depIdx > depSize) { depSize *= 2; - deps = realloc(deps, sizeof(char*) * depSize); + deps = realloc(deps, sizeof(char *) * depSize); } (*deps)[depIdx] = ReadStr(AH); #if 0 @@ -1815,12 +1815,12 @@ ReadToc(ArchiveHandle *AH) write_msg(modulename, "read dependency for %s -> %s\n", te->name, (*deps)[depIdx]); #endif - } while ( (*deps)[depIdx++] != NULL); + } while ((*deps)[depIdx++] != NULL); - if (depIdx > 1) /* We have a non-null entry */ - te->depOid = realloc(deps, sizeof(char*) * depIdx); /* trim it */ + if (depIdx > 1) /* We have a non-null entry */ + te->depOid = realloc(deps, sizeof(char *) * depIdx); /* trim it */ else - te->depOid = NULL; /* no deps */ + te->depOid = NULL; /* no deps */ } else te->depOid = NULL; @@ -1918,7 +1918,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt) * user, this won't do anything. * * If we're currently restoring right into a database, this will - * actuall establish a connection. Otherwise it puts a \connect into + * actuall establish a connection. Otherwise it puts a \connect into * the script output. */ static void @@ -1928,7 +1928,10 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user) || (strcmp(AH->currUser, user) == 0 && !dbname)) return; /* no need to do anything */ - /* Use SET SESSION AUTHORIZATION if allowed and no database change needed */ + /* + * Use SET SESSION AUTHORIZATION if allowed and no database change + * needed + */ if (!dbname && AH->ropt->use_setsessauth) { if (RestoringToDB(AH)) @@ -1961,8 +1964,10 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user) dbname ? dbname : "-", user ? user : "-"); - /* NOTE: currUser keeps track of what the imaginary session user - in our script is */ + /* + * NOTE: currUser keeps track of what the imaginary session user in + * our script is + */ if (AH->currUser) free(AH->currUser); @@ -1988,14 +1993,12 @@ _reconnectAsOwner(ArchiveHandle *AH, const char *dbname, TocEntry *te) static int _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData) { - char *pfx; + char *pfx; if (isData) - { pfx = "Data for "; - } else { + else pfx = ""; - } ahprintf(AH, "--\n-- %sTOC Entry ID %d (OID %s)\n--\n-- Name: %s Type: %s Owner: %s\n", pfx, te->id, te->oid, te->name, te->desc, te->owner); @@ -2136,7 +2139,6 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) te = AH->toc; for (i = 0; i <= AH->tocCount + 1; i++) { - /* * printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * te->oidVal); @@ -2159,7 +2161,6 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) te = AH->toc; for (i = 0; i <= AH->tocCount + 1; i++) { - /* * printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * te->oidVal); @@ -2187,39 +2188,48 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2) /* If we have a deterministic answer, return it. */ if (cmpval != 0) - return cmpval; + return cmpval; /* More comparisons required */ - if ( oideq(id1, te1->maxDepOidVal) ) /* maxOid1 came from deps */ + if (oideq(id1, te1->maxDepOidVal)) /* maxOid1 came from deps */ { - if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 also came from deps */ + if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 also came from + * deps */ { - cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base OIDs */ + cmpval = oidcmp(te1->oidVal, te2->oidVal); /* Just compare base + * OIDs */ } - else /* MaxOid2 was entry OID */ + else +/* MaxOid2 was entry OID */ { - return 1; /* entry1 > entry2 */ + return 1; /* entry1 > entry2 */ }; - } - else /* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */ + } + else +/* must have oideq(id1, te1->oidVal) => maxOid1 = Oid1 */ { - if ( oideq(id2, te2->maxDepOidVal) ) /* maxOid2 came from deps */ + if (oideq(id2, te2->maxDepOidVal)) /* maxOid2 came from deps */ { - return -1; /* entry1 < entry2 */ + return -1; /* entry1 < entry2 */ } - else /* MaxOid2 was entry OID - deps don't matter */ + else +/* MaxOid2 was entry OID - deps don't matter */ { cmpval = 0; }; }; - /* If we get here, then we've done another comparison - * Once again, a 0 result means we require even more + /* + * If we get here, then we've done another comparison Once again, a 0 + * result means we require even more */ if (cmpval != 0) return cmpval; - /* Entire OID details match, so use ID number (ie. original pg_dump order) */ + /* + * Entire OID details match, so use ID number (ie. original pg_dump + * order) + */ return _tocSortCompareByIDNum(te1, te2); } @@ -2245,35 +2255,35 @@ _tocSortCompareByIDNum(const void *p1, const void *p2) * Assuming Oid and depOid are set, work out the various * Oid values used in sorting. */ -static void +static void _fixupOidInfo(TocEntry *te) { te->oidVal = atooid(te->oid); te->maxDepOidVal = _findMaxOID(te->depOid); /* For the purpose of sorting, find the max OID. */ - if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0) + if (oidcmp(te->oidVal, te->maxDepOidVal) >= 0) te->maxOidVal = te->oidVal; else te->maxOidVal = te->maxDepOidVal; } -/* - * Find the max OID value for a given list of string Oid values +/* + * Find the max OID value for a given list of string Oid values */ static Oid _findMaxOID(const char *((*deps)[])) { const char *dep; int i; - Oid maxOid = (Oid)0; + Oid maxOid = (Oid) 0; Oid currOid; if (!deps) return maxOid; i = 0; - while( (dep = (*deps)[i++]) != NULL) + while ((dep = (*deps)[i++]) != NULL) { currOid = atooid(dep); if (oidcmp(maxOid, currOid) < 0) diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h index fee94d83b0..1d099452ee 100644 --- a/src/bin/pg_dump/pg_backup_archiver.h +++ b/src/bin/pg_dump/pg_backup_archiver.h @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.37 2001/08/22 20:23:23 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.38 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * - Initial version. @@ -61,7 +61,6 @@ typedef struct _z_stream int avail_out; } z_stream; typedef z_stream *z_streamp; - #endif #include "pg_backup.h" @@ -69,7 +68,7 @@ typedef z_stream *z_streamp; #define K_VERS_MAJOR 1 #define K_VERS_MINOR 5 -#define K_VERS_REV 6 +#define K_VERS_REV 6 /* Data block types */ #define BLK_DATA 1 @@ -119,8 +118,8 @@ typedef int (*TocSortCompareFn) (const void *te1, const void *te2); typedef enum _archiveMode { - archModeWrite, - archModeRead + archModeWrite, + archModeRead } ArchiveMode; typedef struct _outputContext @@ -131,10 +130,10 @@ typedef struct _outputContext typedef enum { - SQL_SCAN = 0, - SQL_IN_SQL_COMMENT, - SQL_IN_EXT_COMMENT, - SQL_IN_QUOTE + SQL_SCAN = 0, + SQL_IN_SQL_COMMENT, + SQL_IN_EXT_COMMENT, + SQL_IN_QUOTE } sqlparseState; typedef struct @@ -189,8 +188,8 @@ typedef struct _archiveHandle ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */ ClosePtr ClosePtr; /* Close the archive */ WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data - * associated with - * the current archive format */ + * associated with the current + * archive format */ ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with * archie format */ PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */ @@ -222,7 +221,7 @@ typedef struct _archiveHandle int loFd; /* BLOB fd */ int writingBlob; /* Flag */ - int createdBlobXref;/* Flag */ + int createdBlobXref; /* Flag */ int blobCount; /* # of blobs restored */ int lastID; /* Last internal ID for a TOC entry */ @@ -256,11 +255,11 @@ typedef struct _tocEntry char *dropStmt; char *copyStmt; char *owner; - char *oid; /* Oid of source of entry */ + char *oid; /* Oid of source of entry */ Oid oidVal; /* Value of above */ const char *((*depOid)[]); Oid maxDepOidVal; /* Value of largest OID in deps */ - Oid maxOidVal; /* Max of entry OID and max dep OID */ + Oid maxOidVal; /* Max of entry OID and max dep OID */ int printed; /* Indicates if entry defn has been dumped */ DataDumperPtr dataDumper; /* Routine to dump data for object */ @@ -273,8 +272,8 @@ typedef struct _tocEntry /* Used everywhere */ extern const char *progname; -extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, ...) __attribute__((format(printf,3,4))); -extern void write_msg(const char *modulename, const char *fmt, ...) __attribute__((format(printf,2,3))); +extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4))); +extern void write_msg(const char *modulename, const char *fmt,...) __attribute__((format(printf, 2, 3))); extern void WriteTOC(ArchiveHandle *AH); extern void ReadTOC(ArchiveHandle *AH); @@ -316,8 +315,7 @@ extern char *ConnectedUser(ArchiveHandle *AH); extern int ConnectedUserIsSuperuser(ArchiveHandle *AH); int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH); -int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf,2,3))); - -void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf,3,4))); +int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(printf, 2, 3))); +void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(printf, 3, 4))); #endif diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c index 76d4a78ff7..c6d9ff5123 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.15 2001/09/21 21:58:30 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.16 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -447,7 +447,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) if ((TocIDRequired(AH, id, ropt) & 2) != 0) die_horribly(AH, modulename, "Dumping a specific TOC data block out of order is not supported" - " without id on this input stream (fseek required)\n"); + " without id on this input stream (fseek required)\n"); switch (blkType) { @@ -533,7 +533,6 @@ _PrintData(ArchiveHandle *AH) #ifdef HAVE_LIBZ int res; char *out = ctx->zlibOut; - #endif #ifdef HAVE_LIBZ @@ -549,7 +548,6 @@ _PrintData(ArchiveHandle *AH) if (inflateInit(zp) != Z_OK) die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg); } - #endif blkLen = ReadInt(AH); @@ -910,7 +908,6 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te) #else AH->compression = 0; - #endif /* Just be paranoid - maybe End is called after Start, with no Write */ @@ -944,7 +941,6 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) || (zp->avail_in != 0) ) { - /* * Extra paranoia: avoid zero-length chunks since a zero * length chunk is the EOF marker. This should never happen @@ -952,7 +948,6 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) */ if (zp->avail_out < zlibOutSize) { - /* * printf("Wrote %d byte deflated chunk\n", zlibOutSize - * zp->avail_out); diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 0749c24bb5..aeea9d02c8 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -5,7 +5,7 @@ * Implements the basic DB functions used by the archiver. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.28 2001/10/18 21:57:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.29 2001/10/25 05:49:52 momjian Exp $ * * NOTES * @@ -64,7 +64,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo) { int length; char *destination; - FILE *termin, *termout; + FILE *termin, + *termout; + #ifdef HAVE_TERMIOS_H struct termios t_orig, t; @@ -77,8 +79,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) prompt_state = true; /* disable SIGINT */ /* - * Do not try to collapse these into one "w+" mode file. - * Doesn't work on some platforms (eg, HPUX 10.20). + * Do not try to collapse these into one "w+" mode file. Doesn't work + * on some platforms (eg, HPUX 10.20). */ termin = fopen("/dev/tty", "r"); termout = fopen("/dev/tty", "w"); @@ -101,7 +103,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) tcsetattr(fileno(termin), TCSAFLUSH, &t); } #endif - + if (prompt) { fputs(gettext(prompt), termout); @@ -152,17 +154,17 @@ simple_prompt(const char *prompt, int maxlen, bool echo) static int -_parse_version(ArchiveHandle *AH, const char* versionString) +_parse_version(ArchiveHandle *AH, const char *versionString) { int cnt; - int vmaj, vmin, vrev; + int vmaj, + vmin, + vrev; cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev); if (cnt < 2) - { die_horribly(AH, modulename, "unable to parse version string \"%s\"\n", versionString); - } if (cnt == 2) vrev = 0; @@ -195,8 +197,8 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion) AH->public.remoteVersion = remoteversion; - if (myversion != remoteversion - && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) ) + if (myversion != remoteversion + && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion)) { write_msg(NULL, "server version: %s; %s version: %s\n", remoteversion_str, progname, PG_VERSION); @@ -261,7 +263,7 @@ ConnectedUser(ArchiveHandle *AH) /* * Reconnect to the server. If dbname is not NULL, use that database, * else the one associated with the archive handle. If username is - * not NULL, use that user name, else the one from the handle. If + * not NULL, use that user name, else the one from the handle. If * both the database and the user and match the existing connection * already, nothing will be done. * @@ -348,7 +350,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser) noPwd = (strcmp(PQerrorMessage(newConn), "fe_sendauth: no password supplied\n") == 0); badPwd = (strncmp(PQerrorMessage(newConn), - "Password authentication failed for user", 39) == 0); + "Password authentication failed for user", 39) == 0); if (noPwd || badPwd) { @@ -432,8 +434,8 @@ ConnectDatabase(Archive *AHX, AH->requirePassword = false; /* - * Start the connection. Loop until we have a password if - * requested by backend. + * Start the connection. Loop until we have a password if requested + * by backend. */ do { @@ -480,7 +482,8 @@ ConnectDatabase(Archive *AHX, } -static void notice_processor(void *arg, const char *message) +static void +notice_processor(void *arg, const char *message) { write_msg(NULL, "%s", message); } @@ -635,7 +638,6 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) /* We may have finished Copy In, and have a non-empty buffer */ if (!AH->pgCopyIn) { - /* * The following is a mini state machine to assess then of of an * SQL statement. It really only needs to parse good SQL, or at @@ -754,7 +756,7 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename) appendPQExpBuffer(tblQry, "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t " " WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid " - " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename); + " AND t.typname in ('oid', 'lo') AND c.relname = '%s';", tablename); res = PQexec(AH->blobConnection, tblQry->data); if (!res) @@ -791,13 +793,13 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename) uRes = PQexec(AH->blobConnection, tblQry->data); if (!uRes) die_horribly(AH, modulename, - "could not update column \"%s\" of table \"%s\": %s", - attr, tablename, PQerrorMessage(AH->blobConnection)); + "could not update column \"%s\" of table \"%s\": %s", + attr, tablename, PQerrorMessage(AH->blobConnection)); if (PQresultStatus(uRes) != PGRES_COMMAND_OK) die_horribly(AH, modulename, - "error while updating column \"%s\" of table \"%s\": %s", - attr, tablename, PQerrorMessage(AH->blobConnection)); + "error while updating column \"%s\" of table \"%s\": %s", + attr, tablename, PQerrorMessage(AH->blobConnection)); PQclear(uRes); } diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c index db54ca0fd9..dfc1fdd2a1 100644 --- a/src/bin/pg_dump/pg_backup_files.c +++ b/src/bin/pg_dump/pg_backup_files.c @@ -20,7 +20,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.13 2001/09/21 21:58:30 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.14 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -550,4 +550,3 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te) die_horribly(AH, modulename, "could not close large object TOC file: %s\n", strerror(errno)); } - diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index 35d8e9b344..4f99c96781 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.18 2001/09/21 21:58:30 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.19 2001/10/25 05:49:52 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -66,7 +66,6 @@ typedef FILE ThingFile; #else typedef FILE ThingFile; - #endif typedef struct @@ -110,7 +109,6 @@ static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH); #ifdef __NOT_USED__ static char *tarGets(char *buf, int len, TAR_MEMBER *th); - #endif static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...); @@ -173,7 +171,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) if (ctx->tarFH == NULL) die_horribly(NULL, modulename, - "could not open TOC file for output: %s\n", strerror(errno)); + "could not open TOC file for output: %s\n", strerror(errno)); ctx->tarFHpos = 0; @@ -323,7 +321,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) #ifdef HAVE_LIBZ char fmode[10]; - #endif if (mode == 'r') @@ -350,7 +347,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) #else tm->nFH = ctx->tarFH; - #endif } @@ -379,7 +375,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) #else tm->nFH = tm->tmpFH; - #endif tm->AH = AH; @@ -396,7 +391,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) static void tarClose(ArchiveHandle *AH, TAR_MEMBER *th) { - /* * Close the GZ file since we dup'd. This will flush the buffers. */ @@ -458,7 +452,6 @@ tarGets(char *buf, int len, TAR_MEMBER *th) return s; } - #endif /* @@ -706,12 +699,12 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) StartRestoreBlobs(AH); - th = tarOpen(AH, NULL, 'r');/* Open next file */ + th = tarOpen(AH, NULL, 'r'); /* Open next file */ while (th != NULL) { ctx->FH = th; - oid = (Oid)strtoul(&th->targetFile[5], NULL, 10); + oid = (Oid) strtoul(&th->targetFile[5], NULL, 10); if (strncmp(th->targetFile, "blob_", 5) == 0 && oid != 0) { @@ -796,7 +789,6 @@ _CloseArchive(ArchiveHandle *AH) if (AH->mode == archModeWrite) { - /* * Write the Header & TOC to the archive FIRST */ @@ -854,7 +846,7 @@ _CloseArchive(ArchiveHandle *AH) { if (fputc(0, ctx->tarFH) == EOF) die_horribly(AH, modulename, - "could not write null block at end of tar archive\n"); + "could not write null block at end of tar archive\n"); } } @@ -1028,7 +1020,7 @@ static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) { lclContext *ctx = (lclContext *) AH->formatData; - FILE *tmp = th->tmpFH;/* Grab it for convenience */ + FILE *tmp = th->tmpFH; /* Grab it for convenience */ char buf[32768]; int cnt; int len = 0; @@ -1120,7 +1112,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) id = atoi(th->targetFile); if ((TocIDRequired(AH, id, AH->ropt) & 2) != 0) die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: " - "%s is required, but comes before %s in the archive file.\n", + "%s is required, but comes before %s in the archive file.\n", th->targetFile, filename); /* Header doesn't match, so read to next header */ @@ -1207,7 +1199,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) if (chk != sum) die_horribly(AH, modulename, "corrupt tar header found in %s " - "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n", + "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n", &name[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH)); th->targetFile = strdup(name); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index ce97db498f..9307a52d08 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -22,7 +22,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.234 2001/10/22 19:31:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.235 2001/10/25 05:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,8 +65,8 @@ typedef enum _formatLiteralOptions { - CONV_ALL = 0, - PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we + CONV_ALL = 0, + PASS_LFTAB = 3 /* NOTE: 1 and 2 are reserved in case we * want to make a mask. */ /* We could make this a bit mask for control chars, but I don't */ /* see any value in making it more complex...the current code */ @@ -74,8 +74,8 @@ typedef enum _formatLiteralOptions } formatLiteralOptions; static void dumpComment(Archive *fout, const char *target, const char *oid, - const char *classname, int subid, - const char *((*deps)[])); + const char *classname, int subid, + const char *((*deps)[])); static void dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool dataOnly); static void dumpACL(Archive *fout, TableInfo tbinfo); static void dumpTriggers(Archive *fout, const char *tablename, @@ -141,71 +141,71 @@ help(const char *progname) #ifdef HAVE_GETOPT_LONG puts(gettext( " -a, --data-only dump only the data, not the schema\n" - " -b, --blobs include large objects in dump\n" - " -c, --clean clean (drop) schema prior to create\n" - " -C, --create include commands to create database in dump\n" - " -d, --inserts dump data as INSERT, rather than COPY, commands\n" - " -D, --column-inserts dump data as INSERT commands with column names\n" - " -f, --file=FILENAME output file name\n" - " -F, --format {c|t|p} output file format (custom, tar, plain text)\n" - " -h, --host=HOSTNAME database server host name\n" - " -i, --ignore-version proceed even when server version mismatches\n" - " pg_dump version\n" - " -n, --no-quotes suppress most quotes around identifiers\n" - " -N, --quotes enable most quotes around identifiers\n" - " -o, --oids include oids in dump\n" - " -O, --no-owner do not output \\connect commands in plain\n" - " text format\n" - " -p, --port=PORT database server port number\n" - " -R, --no-reconnect disable ALL reconnections to the database in\n" - " plain text format\n" - " -s, --schema-only dump only the schema, no data\n" - " -S, --superuser=NAME specify the superuser user name to use in\n" - " plain text format\n" - " -t, --table=TABLE dump this table only (* for all)\n" + " -b, --blobs include large objects in dump\n" + " -c, --clean clean (drop) schema prior to create\n" + " -C, --create include commands to create database in dump\n" + " -d, --inserts dump data as INSERT, rather than COPY, commands\n" + " -D, --column-inserts dump data as INSERT commands with column names\n" + " -f, --file=FILENAME output file name\n" + " -F, --format {c|t|p} output file format (custom, tar, plain text)\n" + " -h, --host=HOSTNAME database server host name\n" + " -i, --ignore-version proceed even when server version mismatches\n" + " pg_dump version\n" + " -n, --no-quotes suppress most quotes around identifiers\n" + " -N, --quotes enable most quotes around identifiers\n" + " -o, --oids include oids in dump\n" + " -O, --no-owner do not output \\connect commands in plain\n" + " text format\n" + " -p, --port=PORT database server port number\n" + " -R, --no-reconnect disable ALL reconnections to the database in\n" + " plain text format\n" + " -s, --schema-only dump only the schema, no data\n" + " -S, --superuser=NAME specify the superuser user name to use in\n" + " plain text format\n" + " -t, --table=TABLE dump this table only (* for all)\n" " -U, --username=NAME connect as specified database user\n" - " -v, --verbose verbose mode\n" - " -W, --password force password prompt (should happen automatically)\n" - " -x, --no-privileges do not dump privileges (grant/revoke)\n" - " -X use-set-session-authorization, --use-set-session-authorization\n" - " output SET SESSION AUTHORIZATION commands rather\n" - " than \\connect commands\n" - " -Z, --compress {0-9} compression level for compressed formats\n" - )); + " -v, --verbose verbose mode\n" + " -W, --password force password prompt (should happen automatically)\n" + " -x, --no-privileges do not dump privileges (grant/revoke)\n" + " -X use-set-session-authorization, --use-set-session-authorization\n" + " output SET SESSION AUTHORIZATION commands rather\n" + " than \\connect commands\n" + " -Z, --compress {0-9} compression level for compressed formats\n" + )); #else puts(gettext( " -a dump only the data, not the schema\n" - " -b include large objects in dump\n" - " -c clean (drop) schema prior to create\n" - " -C include commands to create database in dump\n" - " -d dump data as INSERT, rather than COPY, commands\n" - " -D dump data as INSERT commands with column names\n" - " -f FILENAME output file name\n" - " -F {c|t|p} output file format (custom, tar, plain text)\n" - " -h HOSTNAME database server host name\n" - " -i proceed even when server version mismatches\n" - " pg_dump version\n" - " -n suppress most quotes around identifiers\n" - " -N enable most quotes around identifiers\n" - " -o include oids in dump\n" - " -O do not output \\connect commands in plain\n" - " text format\n" - " -p PORT database server port number\n" - " -R disable ALL reconnections to the database in\n" - " plain text format\n" - " -s dump only the schema, no data\n" - " -S NAME specify the superuser user name to use in\n" - " plain text format\n" - " -t TABLE dump this table only (* for all)\n" + " -b include large objects in dump\n" + " -c clean (drop) schema prior to create\n" + " -C include commands to create database in dump\n" + " -d dump data as INSERT, rather than COPY, commands\n" + " -D dump data as INSERT commands with column names\n" + " -f FILENAME output file name\n" + " -F {c|t|p} output file format (custom, tar, plain text)\n" + " -h HOSTNAME database server host name\n" + " -i proceed even when server version mismatches\n" + " pg_dump version\n" + " -n suppress most quotes around identifiers\n" + " -N enable most quotes around identifiers\n" + " -o include oids in dump\n" + " -O do not output \\connect commands in plain\n" + " text format\n" + " -p PORT database server port number\n" + " -R disable ALL reconnections to the database in\n" + " plain text format\n" + " -s dump only the schema, no data\n" + " -S NAME specify the superuser user name to use in\n" + " plain text format\n" + " -t TABLE dump this table only (* for all)\n" " -U NAME connect as specified database user\n" - " -v verbose mode\n" - " -W force password prompt (should happen automatically)\n" - " -x do not dump privileges (grant/revoke)\n" - " -X use-set-session-authorization\n" - " output SET SESSION AUTHORIZATION commands rather\n" - " than \\connect commands\n" - " -Z {0-9} compression level for compressed formats\n" - )); + " -v verbose mode\n" + " -W force password prompt (should happen automatically)\n" + " -x do not dump privileges (grant/revoke)\n" + " -X use-set-session-authorization\n" + " output SET SESSION AUTHORIZATION commands rather\n" + " than \\connect commands\n" + " -Z {0-9} compression level for compressed formats\n" + )); #endif puts(gettext("If no database name is not supplied, then the PGDATABASE environment\n" "variable value is used.\n\n" @@ -250,7 +250,6 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) if (oids && hasoids) { - /* * archprintf(fout, "COPY %s WITH OIDS FROM stdin;\n", * fmtId(classname, force_quotes)); @@ -264,7 +263,6 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) } else { - /* * archprintf(fout, "COPY %s FROM stdin;\n", fmtId(classname, * force_quotes)); @@ -291,7 +289,7 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) { write_msg(NULL, "SQL command to dump the contents of table \"%s\" executed abnormally.\n", classname); - write_msg(NULL, "The server returned status %d when %d was expected.\n", + write_msg(NULL, "The server returned status %d when %d was expected.\n", PQresultStatus(res), PGRES_COPY_OUT); write_msg(NULL, "The command was: %s\n", query); exit_nicely(); @@ -399,11 +397,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) int field; if (fout->remoteVersion >= 70100) - { appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM ONLY %s", fmtId(classname, force_quotes)); - } else { + else appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR SELECT * FROM %s", fmtId(classname, force_quotes)); - } res = PQexec(g_conn, q->data); if (!res || @@ -414,8 +410,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) write_msg(NULL, "The command was: %s\n", q->data); exit_nicely(); } - - do { + + do + { PQclear(res); res = PQexec(g_conn, "FETCH 100 FROM _pg_dump_cursor"); @@ -458,9 +455,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) { case INT2OID: case INT4OID: - case OIDOID: /* int types */ + case OIDOID: /* int types */ case FLOAT4OID: - case FLOAT8OID:/* float types */ + case FLOAT8OID: /* float types */ /* These types are printed without quotes */ archprintf(fout, "%s", PQgetvalue(res, tuple, field)); @@ -471,10 +468,11 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) PQgetvalue(res, tuple, field)); break; default: - + /* * All other types are printed as string literals, - * with appropriate escaping of special characters. + * with appropriate escaping of special + * characters. */ resetPQExpBuffer(q); formatStringLiteral(q, PQgetvalue(res, tuple, field), CONV_ALL); @@ -485,7 +483,7 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) archprintf(fout, ");\n"); } - } while( PQntuples(res) > 0 ); + } while (PQntuples(res) > 0); PQclear(res); res = PQexec(g_conn, "CLOSE _pg_dump_cursor"); @@ -528,7 +526,6 @@ formatStringLiteral(PQExpBuffer buf, const char *str, const formatLiteralOptions || (ch != '\n' && ch != '\t') )) { - /* * generate octal escape for control chars other than * whitespace @@ -618,10 +615,12 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout, static int -parse_version(const char* versionString) +parse_version(const char *versionString) { int cnt; - int vmaj, vmin, vrev; + int vmaj, + vmin, + vrev; cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev); @@ -698,12 +697,13 @@ main(int argc, char **argv) {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'}, - /* the following options don't have an equivalent short option - letter, but are available as '-X long-name' */ + /* + * the following options don't have an equivalent short option + * letter, but are available as '-X long-name' + */ {"use-set-session-authorization", no_argument, &use_setsessauth, 1} }; int optindex; - #endif #ifdef ENABLE_NLS @@ -891,15 +891,14 @@ main(int argc, char **argv) break; /* - * Option letters were getting scarce, so I invented - * this new scheme: '-X feature' turns on some - * feature. Compare to the -f option in GCC. You - * should also add an equivalent GNU-style option - * --feature. Features that require arguments should - * use '-X feature=foo'. + * Option letters were getting scarce, so I invented this + * new scheme: '-X feature' turns on some feature. + * Compare to the -f option in GCC. You should also add + * an equivalent GNU-style option --feature. Features + * that require arguments should use '-X feature=foo'. */ case 'X': - if (strcmp(optarg, "use-set-session-authorization")==0) + if (strcmp(optarg, "use-set-session-authorization") == 0) use_setsessauth = 1; else { @@ -918,7 +917,7 @@ main(int argc, char **argv) case '-': fprintf(stderr, gettext("%s was compiled without support for long options.\n" - "Use --help for help on invocation options.\n"), + "Use --help for help on invocation options.\n"), progname); exit(1); break; @@ -936,8 +935,8 @@ main(int argc, char **argv) if (optind < (argc - 1)) { fprintf(stderr, - gettext("%s: too many command line options (first is '%s')\n" - "Try '%s --help' for more information.\n"), + gettext("%s: too many command line options (first is '%s')\n" + "Try '%s --help' for more information.\n"), progname, argv[optind + 1], progname); exit(1); } @@ -1023,7 +1022,7 @@ main(int argc, char **argv) * Open the database using the Archiver, so it knows about it. Errors * mean death. */ - g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */ + g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */ g_fout->maxRemoteVersion = parse_version(PG_VERSION); g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, username, force_password, ignore_version); @@ -1086,6 +1085,7 @@ main(int argc, char **argv) MoveToEnd(g_fout, "TRIGGER"); MoveToEnd(g_fout, "RULE"); MoveToEnd(g_fout, "SEQUENCE SET"); + /* * Moving all comments to end is annoying, but must do it for comments * on stuff we just moved, and we don't seem to have quite enough @@ -1115,7 +1115,8 @@ main(int argc, char **argv) else ropt->compression = compressLevel; - ropt->suppressDumpWarnings = true; /* We've already shown them */ + ropt->suppressDumpWarnings = true; /* We've already shown + * them */ RestoreArchive(g_fout, ropt); } @@ -1220,11 +1221,9 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) /* Cursor to get all BLOB tables */ if (AH->remoteVersion >= 70100) - { appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT DISTINCT loid FROM pg_largeobject"); - } else { + else appendPQExpBuffer(oidQry, "Declare blobOid Cursor for SELECT oid from pg_class where relkind = 'l'"); - } res = PQexec(g_conn, oidQry->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) @@ -1300,7 +1299,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) * numTypes is set to the number of types read in * */ -TypeInfo * +TypeInfo * getTypes(int *numTypes) { PGresult *res; @@ -1341,18 +1340,20 @@ getTypes(int *numTypes) if (g_fout->remoteVersion < 70100) { appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, " - "typinput, typoutput, typreceive, typsend, typelem, typdelim, " - "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, " - "(select usename from pg_user where typowner = usesysid) as usename, " - "typname as typedefn " - "from pg_type"); - } else { + "typinput, typoutput, typreceive, typsend, typelem, typdelim, " + "typdefault, typrelid, typalign, 'p'::char as typstorage, typbyval, typisdefined, " + "(select usename from pg_user where typowner = usesysid) as usename, " + "typname as typedefn " + "from pg_type"); + } + else + { appendPQExpBuffer(query, "SELECT pg_type.oid, typowner, typname, typlen, typprtlen, " - "typinput, typoutput, typreceive, typsend, typelem, typdelim, " - "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, " - "(select usename from pg_user where typowner = usesysid) as usename, " - "format_type(pg_type.oid, NULL) as typedefn " - "from pg_type"); + "typinput, typoutput, typreceive, typsend, typelem, typdelim, " + "typdefault, typrelid, typalign, typstorage, typbyval, typisdefined, " + "(select usename from pg_user where typowner = usesysid) as usename, " + "format_type(pg_type.oid, NULL) as typedefn " + "from pg_type"); } res = PQexec(g_conn, query->data); @@ -1450,7 +1451,7 @@ getTypes(int *numTypes) * * numOprs is set to the number of operators read in */ -OprInfo * +OprInfo * getOperators(int *numOprs) { PGresult *res; @@ -1812,7 +1813,7 @@ clearAggInfo(AggInfo *agginfo, int numArgs) * * numAggs is set to the number of aggregates read in */ -AggInfo * +AggInfo * getAggregates(int *numAggs) { PGresult *res; @@ -1836,18 +1837,20 @@ getAggregates(int *numAggs) if (g_fout->remoteVersion < 70100) { appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn1 as aggtransfn, " - "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, " - "agginitval1 as agginitval, " - "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, " - "(select usename from pg_user where aggowner = usesysid) as usename " - "from pg_aggregate"); - } else { + "aggfinalfn, aggtranstype1 as aggtranstype, aggbasetype, " + "agginitval1 as agginitval, " + "(aggtransfn2 = 0 and aggtranstype2 = 0 and agginitval2 is null) as convertok, " + "(select usename from pg_user where aggowner = usesysid) as usename " + "from pg_aggregate"); + } + else + { appendPQExpBuffer(query, "SELECT pg_aggregate.oid, aggname, aggtransfn, " - "aggfinalfn, aggtranstype, aggbasetype, " - "agginitval, " - "'t'::boolean as convertok, " - "(select usename from pg_user where aggowner = usesysid) as usename " - "from pg_aggregate"); + "aggfinalfn, aggtranstype, aggbasetype, " + "agginitval, " + "'t'::boolean as convertok, " + "(select usename from pg_user where aggowner = usesysid) as usename " + "from pg_aggregate"); } res = PQexec(g_conn, query->data); @@ -1908,7 +1911,7 @@ getAggregates(int *numAggs) * * */ -FuncInfo * +FuncInfo * getFuncs(int *numFuncs) { PGresult *res; @@ -1936,21 +1939,23 @@ getFuncs(int *numFuncs) { appendPQExpBuffer(query, "SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, " - "proretset, proargtypes, prosrc, probin, " - "(select usename from pg_user where proowner = usesysid) as usename, " - "proiscachable, 'f'::boolean as proisstrict " - "from pg_proc " - "where pg_proc.oid > '%u'::oid", - g_last_builtin_oid); - } else { + "proretset, proargtypes, prosrc, probin, " + "(select usename from pg_user where proowner = usesysid) as usename, " + "proiscachable, 'f'::boolean as proisstrict " + "from pg_proc " + "where pg_proc.oid > '%u'::oid", + g_last_builtin_oid); + } + else + { appendPQExpBuffer(query, "SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, " - "proretset, proargtypes, prosrc, probin, " - "(select usename from pg_user where proowner = usesysid) as usename, " - "proiscachable, proisstrict " - "from pg_proc " - "where pg_proc.oid > '%u'::oid", - g_last_builtin_oid); + "proretset, proargtypes, prosrc, probin, " + "(select usename from pg_user where proowner = usesysid) as usename, " + "proiscachable, proisstrict " + "from pg_proc " + "where pg_proc.oid > '%u'::oid", + g_last_builtin_oid); } res = PQexec(g_conn, query->data); @@ -2029,7 +2034,7 @@ getFuncs(int *numFuncs) * * numTables is set to the number of tables read in */ -TableInfo * +TableInfo * getTables(int *numTables, FuncInfo *finfo, int numFuncs) { PGresult *res; @@ -2066,28 +2071,30 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) if (g_fout->remoteVersion >= 70200) { appendPQExpBuffer(query, - "SELECT pg_class.oid, relname, relacl, relkind, " + "SELECT pg_class.oid, relname, relacl, relkind, " "(select usename from pg_user where relowner = usesysid) as usename, " - "relchecks, reltriggers, relhasindex, relhasoids " + "relchecks, reltriggers, relhasindex, relhasoids " "from pg_class " "where relname !~ '^pg_' " "and relkind in ('%c', '%c', '%c') " "order by oid", - RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); + RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); } else if (g_fout->remoteVersion >= 70100) { /* all tables have oids in 7.1 */ appendPQExpBuffer(query, - "SELECT pg_class.oid, relname, relacl, relkind, " + "SELECT pg_class.oid, relname, relacl, relkind, " "(select usename from pg_user where relowner = usesysid) as usename, " - "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids " + "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids " "from pg_class " "where relname !~ '^pg_' " "and relkind in ('%c', '%c', '%c') " "order by oid", - RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); - } else { + RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); + } + else + { /* * Before 7.1, view relkind was not set to 'v', so we must check * if we have a view by looking for a rule in pg_rewrite. @@ -2095,18 +2102,18 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) appendPQExpBuffer(query, "SELECT c.oid, relname, relacl, " "CASE WHEN relhasrules and relkind = 'r' " - " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE " - " r.ev_class = c.oid AND r.ev_type = '1') " + " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE " + " r.ev_class = c.oid AND r.ev_type = '1') " "THEN '%c'::\"char\" " "ELSE relkind END AS relkind," "(select usename from pg_user where relowner = usesysid) as usename, " - "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids " + "relchecks, reltriggers, relhasindex, 't'::bool as relhasoids " "from pg_class c " "where relname !~ '^pg_' " "and relkind in ('%c', '%c', '%c') " "order by oid", RELKIND_VIEW, - RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); + RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW); } res = PQexec(g_conn, query->data); @@ -2155,10 +2162,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) resetPQExpBuffer(query); appendPQExpBuffer(query, "SELECT definition as viewdef, "); - /* XXX 7.2 - replace with att from pg_views or some other generic source */ + + /* + * XXX 7.2 - replace with att from pg_views or some other + * generic source + */ appendPQExpBuffer(query, "(select oid from pg_rewrite where " - " rulename=('_RET' || viewname)::name) as view_oid" - " from pg_views where viewname = "); + " rulename=('_RET' || viewname)::name) as view_oid" + " from pg_views where viewname = "); formatStringLiteral(query, tblinfo[i].relname, CONV_ALL); appendPQExpBuffer(query, ";"); @@ -2177,7 +2188,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) tblinfo[i].relname); else write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n", - tblinfo[i].relname); + tblinfo[i].relname); exit_nicely(); } @@ -2206,8 +2217,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) * * Exclude inherited CHECKs from CHECK constraints total. If a * constraint matches by name and condition with a constraint - * belonging to a parent class (OR conditions match and both - * names start with '$', we assume it was inherited. + * belonging to a parent class (OR conditions match and both names + * start with '$', we assume it was inherited. */ if (tblinfo[i].ncheck > 0) { @@ -2225,11 +2236,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) appendPQExpBuffer(query, "SELECT rcname, rcsrc from pg_relcheck " " where rcrelid = '%s'::oid " " and not exists " - " (select * from pg_relcheck as c, pg_inherits as i " - " where i.inhrelid = pg_relcheck.rcrelid " + " (select * from pg_relcheck as c, pg_inherits as i " + " where i.inhrelid = pg_relcheck.rcrelid " " and (c.rcname = pg_relcheck.rcname " " or ( c.rcname[0] = '$' " - " and pg_relcheck.rcname[0] = '$')" + " and pg_relcheck.rcname[0] = '$')" " )" " and c.rcsrc = pg_relcheck.rcsrc " " and c.rcrelid = i.inhparent) " @@ -2251,7 +2262,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) exit_nicely(); } - /* Set ncheck to the number of *non-inherited* CHECK constraints */ + /* + * Set ncheck to the number of *non-inherited* CHECK + * constraints + */ tblinfo[i].ncheck = ntups2; i_rcname = PQfnumber(res2, "rcname"); @@ -2296,7 +2310,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) if (PQntuples(res2) > 1) { write_msg(NULL, "query to obtain primary key of table \"%s\" produced more than one result\n", - tblinfo[i].relname); + tblinfo[i].relname); exit_nicely(); } @@ -2375,11 +2389,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) resetPQExpBuffer(query); appendPQExpBuffer(query, - "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, " - "tgisconstraint, tgconstrname, tgdeferrable, " - "tgconstrrelid, tginitdeferred, oid, " - "(select relname from pg_class where oid = tgconstrrelid) " - " as tgconstrrelname " + "SELECT tgname, tgfoid, tgtype, tgnargs, tgargs, " + "tgisconstraint, tgconstrname, tgdeferrable, " + "tgconstrrelid, tginitdeferred, oid, " + "(select relname from pg_class where oid = tgconstrrelid) " + " as tgconstrrelname " "from pg_trigger " "where tgrelid = '%s'::oid ", tblinfo[i].oid); @@ -2541,17 +2555,18 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) { tgconstrrelid = PQgetvalue(res2, i2, i_tgconstrrelid); - if (strcmp(tgconstrrelid, "0") != 0) { + if (strcmp(tgconstrrelid, "0") != 0) + { if (PQgetisnull(res2, i2, i_tgconstrrelname)) { write_msg(NULL, "query produced NULL referenced table name for foreign key trigger \"%s\" on table \"%s\" (oid of table: %s)\n", - tgname, tblinfo[i].relname, tgconstrrelid); + tgname, tblinfo[i].relname, tgconstrrelid); exit_nicely(); } appendPQExpBuffer(query, " FROM %s", - fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes)); + fmtId(PQgetvalue(res2, i2, i_tgconstrrelname), force_quotes)); } if (!tgdeferrable) appendPQExpBuffer(query, " NOT"); @@ -2610,7 +2625,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) resetPQExpBuffer(query); appendPQExpBuffer(query, "TRIGGER %s ", - fmtId(tgname, force_quotes)); + fmtId(tgname, force_quotes)); appendPQExpBuffer(query, "ON %s", fmtId(tblinfo[i].relname, force_quotes)); tblinfo[i].triggers[i2].tgcomment = strdup(query->data); @@ -2643,7 +2658,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) * * numInherits is set to the number of tables read in */ -InhInfo * +InhInfo * getInherits(int *numInherits) { PGresult *res; @@ -2737,28 +2752,30 @@ getTableAttrs(TableInfo *tblinfo, int numTables) { /* Fake the LOJ below */ appendPQExpBuffer(q, - " SELECT a.attnum, a.attname, t.typname, a.atttypmod, " - " a.attnotnull, a.atthasdef, NULL as atttypedefn " - " from pg_attribute a, pg_type t " - " where a.attrelid = '%s'::oid " - " and a.attnum > 0 " - " and a.atttypid = t.oid " - " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, " - " a.attnotnull, a.atthasdef, NULL as atttypedefn " - " from pg_attribute a " - " where a.attrelid = '%s'::oid " - " and a.attnum > 0 " - " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)" - " order by attnum", - tblinfo[i].oid, tblinfo[i].oid); - - } else { + " SELECT a.attnum, a.attname, t.typname, a.atttypmod, " + " a.attnotnull, a.atthasdef, NULL as atttypedefn " + " from pg_attribute a, pg_type t " + " where a.attrelid = '%s'::oid " + " and a.attnum > 0 " + " and a.atttypid = t.oid " + " UNION ALL SELECT a.attnum, a.attname, NULL as typname, a.atttypmod, " + " a.attnotnull, a.atthasdef, NULL as atttypedefn " + " from pg_attribute a " + " where a.attrelid = '%s'::oid " + " and a.attnum > 0 " + " and Not Exists(Select * From pg_type t where a.atttypid = t.oid)" + " order by attnum", + tblinfo[i].oid, tblinfo[i].oid); + + } + else + { appendPQExpBuffer(q, "SELECT a.attnum, a.attname, t.typname, a.atttypmod, " - "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn " - "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid " - "where a.attrelid = '%s'::oid " - "and a.attnum > 0 order by attnum", - tblinfo[i].oid); + "a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn " + "from pg_attribute a LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid " + "where a.attrelid = '%s'::oid " + "and a.attnum > 0 order by attnum", + tblinfo[i].oid); } res = PQexec(g_conn, q->data); @@ -2796,7 +2813,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) if (PQgetisnull(res, j, i_typname)) { write_msg(NULL, "query produced NULL name for data type of column %d of table %s\n", - j+1, tblinfo[i].relname); + j + 1, tblinfo[i].relname); exit_nicely(); } @@ -2863,7 +2880,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) * * */ -IndInfo * +IndInfo * getIndexes(int *numIndexes) { int i; @@ -2891,11 +2908,11 @@ getIndexes(int *numIndexes) appendPQExpBuffer(query, "SELECT i.indexrelid as indexreloid, " "i.indrelid as indreloid, " - "t1.relname as indexrelname, t2.relname as indrelname, " + "t1.relname as indexrelname, t2.relname as indrelname, " "pg_get_indexdef(i.indexrelid) as indexdef, " "i.indisprimary, i.indkey " "from pg_index i, pg_class t1, pg_class t2 " - "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid " + "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid " "and i.indexrelid > '%u'::oid " "and t2.relname !~ '^pg_' ", g_last_builtin_oid); @@ -2981,7 +2998,7 @@ dumpComment(Archive *fout, const char *target, const char *oid, { appendPQExpBuffer(query, "SELECT description FROM pg_description " "WHERE objoid = '%s'::oid and classoid = " - "(SELECT oid FROM pg_class where relname = '%s') " + "(SELECT oid FROM pg_class where relname = '%s') " "and objsubid = %d", oid, classname, subid); } @@ -2997,7 +3014,7 @@ dumpComment(Archive *fout, const char *target, const char *oid, if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { write_msg(NULL, "query to get comment on oid %s failed: %s", - oid, PQerrorMessage(g_conn)); + oid, PQerrorMessage(g_conn)); exit_nicely(); } @@ -3052,7 +3069,7 @@ dumpDBComment(Archive *fout) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { write_msg(NULL, "query to get database oid failed: %s", - PQerrorMessage(g_conn)); + PQerrorMessage(g_conn)); exit_nicely(); } @@ -3108,7 +3125,7 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs, (strcmp(tinfo[i].typinput, "array_in") == 0)) continue; - deps = malloc(sizeof(char*) * 10); + deps = malloc(sizeof(char *) * 10); depIdx = 0; /* @@ -3198,7 +3215,7 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs, else appendPQExpBuffer(q, ");\n"); - (*deps)[depIdx++] = NULL; /* End of List */ + (*deps)[depIdx++] = NULL; /* End of List */ ArchiveEntry(fout, tinfo[i].oid, tinfo[i].typname, "TYPE", deps, q->data, delq->data, "", tinfo[i].usename, NULL, NULL); @@ -3249,7 +3266,7 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs, PQresultStatus(res) != PGRES_TUPLES_OK) { write_msg(NULL, "query to obtain list of procedural languages failed: %s", - PQerrorMessage(g_conn)); + PQerrorMessage(g_conn)); exit_nicely(); } ntups = PQntuples(res); @@ -3277,7 +3294,7 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs, if (fidx >= numFuncs) { write_msg(NULL, "handler procedure for procedural language %s not found\n", - PQgetvalue(res, i, i_lanname)); + PQgetvalue(res, i, i_lanname)); exit_nicely(); } @@ -3422,7 +3439,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, finfo[i].proname); write_msg(NULL, "reason: data type name of argument %d (oid %s) not found\n", - j, finfo[i].argtypes[j]); + j, finfo[i].argtypes[j]); goto done; } @@ -3644,11 +3661,11 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators, resetPQExpBuffer(delq); appendPQExpBuffer(delq, "DROP OPERATOR %s (%s", oprinfo[i].oprname, - findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft, - zeroAsNone)); + findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft, + zeroAsNone)); appendPQExpBuffer(delq, ", %s);\n", - findTypeByOid(tinfo, numTypes, oprinfo[i].oprright, - zeroAsNone)); + findTypeByOid(tinfo, numTypes, oprinfo[i].oprright, + zeroAsNone)); resetPQExpBuffer(q); appendPQExpBuffer(q, @@ -3704,7 +3721,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs, resetPQExpBuffer(details); /* skip all the builtin oids */ - if ( oidle( atooid(agginfo[i].oid), g_last_builtin_oid) ) + if (oidle(atooid(agginfo[i].oid), g_last_builtin_oid)) continue; resetPQExpBuffer(aggSig); @@ -3720,9 +3737,9 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs, resetPQExpBuffer(q); appendPQExpBuffer(q, "-- WARNING: aggregate function %s could not be dumped correctly for this database version; ignored\n", - aggSig->data); + aggSig->data); ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL, - q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL); + q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL); continue; } @@ -3739,7 +3756,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs, appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid); appendPQExpBuffer(q, "-- reason: aggbasetype (oid %s) not found\n", agginfo[i].aggbasetype); ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL, - q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL); + q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL); continue; } appendPQExpBuffer(details, "BASETYPE = %s, ", name); @@ -3757,7 +3774,7 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs, appendPQExpBuffer(q, "-- WARNING: aggregate function \"%s\" (oid %s) not dumped\n", agginfo[i].aggname, agginfo[i].oid); appendPQExpBuffer(q, "-- reason: aggtranstype (oid %s) not found\n", agginfo[i].aggtranstype); ArchiveEntry(fout, agginfo[i].oid, aggSig->data, "WARNING", NULL, - q->data, "" /* Del */, "", agginfo[i].usename, NULL, NULL); + q->data, "" /* Del */ , "", agginfo[i].usename, NULL, NULL); continue; } appendPQExpBuffer(details, @@ -3914,7 +3931,6 @@ dumpACL(Archive *fout, TableInfo tbinfo) /* Scan comma-separated ACL items */ for (tok = strtok(aclbuf, ","); tok != NULL; tok = strtok(NULL, ",")) { - /* * Token may start with '{' and/or '"'. Actually only the start * of the string should have '{', but we don't verify that. @@ -3981,9 +3997,9 @@ dumpACL(Archive *fout, TableInfo tbinfo) static void _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) { - int32 tmp_typmod; - int precision; - int scale; + int32 tmp_typmod; + int precision; + int scale; /* Show lengths on bpchar and varchar */ if (!strcmp(tblinfo[i].typnames[j], "bpchar")) @@ -3993,7 +4009,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) appendPQExpBuffer(q, "character"); if (len > 1) appendPQExpBuffer(q, "(%d)", - tblinfo[i].atttypmod[j] - VARHDRSZ); + tblinfo[i].atttypmod[j] - VARHDRSZ); } else if (!strcmp(tblinfo[i].typnames[j], "varchar")) { @@ -4001,7 +4017,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) if (tblinfo[i].atttypmod[j] != -1) { appendPQExpBuffer(q, "(%d)", - tblinfo[i].atttypmod[j] - VARHDRSZ); + tblinfo[i].atttypmod[j] - VARHDRSZ); } } else if (!strcmp(tblinfo[i].typnames[j], "numeric")) @@ -4018,19 +4034,18 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) } /* - * char is an internal single-byte data type; Let's - * make sure we force it through with quotes. - thomas - * 1998-12-13 + * char is an internal single-byte data type; Let's make sure we force + * it through with quotes. - thomas 1998-12-13 */ else if (!strcmp(tblinfo[i].typnames[j], "char")) { appendPQExpBuffer(q, "%s", - fmtId(tblinfo[i].typnames[j], true)); + fmtId(tblinfo[i].typnames[j], true)); } else { appendPQExpBuffer(q, "%s", - fmtId(tblinfo[i].typnames[j], false)); + fmtId(tblinfo[i].typnames[j], false)); } } @@ -4106,9 +4121,9 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, objoid = tblinfo[i].viewoid; appendPQExpBuffer(delq, "DROP VIEW %s;\n", fmtId(tblinfo[i].relname, force_quotes)); appendPQExpBuffer(q, "CREATE VIEW %s as %s\n", fmtId(tblinfo[i].relname, force_quotes), tblinfo[i].viewdef); - commentDeps = malloc(sizeof(char*) * 2); + commentDeps = malloc(sizeof(char *) * 2); (*commentDeps)[0] = strdup(objoid); - (*commentDeps)[1] = NULL; /* end of list */ + (*commentDeps)[1] = NULL; /* end of list */ } else { @@ -4135,11 +4150,9 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, appendPQExpBuffer(q, "%s ", fmtId(tblinfo[i].attnames[j], force_quotes)); if (g_fout->remoteVersion >= 70100) - { appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]); - } else { + else _dumpTableAttr70(fout, tblinfo, i, j, q); - } /* Default value */ if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0) @@ -4182,7 +4195,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, if (k >= numIndexes) { write_msg(NULL, "dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n", - tblinfo[i].pkIndexOid); + tblinfo[i].pkIndexOid); exit_nicely(); } @@ -4238,7 +4251,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, appendPQExpBuffer(q, "."); appendPQExpBuffer(q, "%s", fmtId(tblinfo[i].attnames[j], force_quotes)); dumpComment(fout, q->data, tblinfo[i].oid, - "pg_class", j+1, commentDeps); + "pg_class", j + 1, commentDeps); } /* Dump Table Comments */ @@ -4295,7 +4308,7 @@ static const char * getAttrName(int attrnum, TableInfo *tblInfo) { if (attrnum > 0 && attrnum <= tblInfo->numatts) - return tblInfo->attnames[attrnum-1]; + return tblInfo->attnames[attrnum - 1]; switch (attrnum) { case SelfItemPointerAttributeNumber: @@ -4314,7 +4327,7 @@ getAttrName(int attrnum, TableInfo *tblInfo) return "tableoid"; } write_msg(NULL, "getAttrName(): invalid column number %d for table %s\n", - attrnum, tblInfo->relname); + attrnum, tblInfo->relname); exit_nicely(); return NULL; /* keep compiler quiet */ } @@ -4344,7 +4357,7 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes, if (tableInd < 0) { write_msg(NULL, "dumpIndexes(): failed sanity check, table %s was not found\n", - indinfo[i].indrelname); + indinfo[i].indrelname); exit_nicely(); } @@ -4352,14 +4365,18 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes, if (strcmp(indinfo[i].indisprimary, "t") == 0) { #if 0 - /* PK: Enable this code when ALTER TABLE supports PK constraints. */ + + /* + * PK: Enable this code when ALTER TABLE supports PK + * constraints. + */ PQExpBuffer consDef = getPKconstraint(&tblinfo[tableInd], &indinfo[i]); resetPQExpBuffer(q); appendPQExpBuffer(q, "Alter Table %s Add %s;", - fmtId(tblinfo[tableInd].relname, force_quotes), + fmtId(tblinfo[tableInd].relname, force_quotes), consDef->data); ArchiveEntry(fout, indinfo[i].oid, tblinfo[tableInd].primary_key_name, @@ -4386,9 +4403,9 @@ dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes, appendPQExpBuffer(delq, "DROP INDEX %s;\n", id1->data); /* - * We make the index belong to the owner of its table, which - * is not necessarily right but should answer 99% of the time. - * Would have to add owner name to IndInfo to do it right. + * We make the index belong to the owner of its table, which is + * not necessarily right but should answer 99% of the time. Would + * have to add owner name to IndInfo to do it right. */ ArchiveEntry(fout, indinfo[i].indexreloid, id1->data, "INDEX", NULL, q->data, delq->data, @@ -4433,7 +4450,6 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap) if (m > 0) { - /* * Print out the tuples but only print tuples with at least 1 * field. @@ -4468,7 +4484,6 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap) free(outVals); } } - #endif /* @@ -4635,14 +4650,14 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool if (PQntuples(res) != 1) { write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n", - tbinfo.relname, PQntuples(res)); + tbinfo.relname, PQntuples(res)); exit_nicely(); } if (strcmp(PQgetvalue(res, 0, 0), tbinfo.relname) != 0) { write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n", - tbinfo.relname, PQgetvalue(res, 0, 0)); + tbinfo.relname, PQgetvalue(res, 0, 0)); exit_nicely(); } @@ -4659,8 +4674,8 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool * basic CREATE SEQUENCE statement (use last_val for start if called * is false, else use min_val for start_val). * - * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff - * we load data + * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load + * data */ if (!dataOnly) @@ -4788,7 +4803,7 @@ dumpRules(Archive *fout, const char *tablename, PQresultStatus(res) != PGRES_TUPLES_OK) { write_msg(NULL, "query to get rules associated with table \"%s\" failed: %s", - tblinfo[t].relname, PQerrorMessage(g_conn)); + tblinfo[t].relname, PQerrorMessage(g_conn)); exit_nicely(); } diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index dbd7f598d7..a08105ca35 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_dump.h,v 1.73 2001/10/22 19:31:09 tgl Exp $ + * $Id: pg_dump.h,v 1.74 2001/10/25 05:49:53 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -92,18 +92,20 @@ typedef struct _tableInfo char *relacl; char *viewdef; char *viewoid; /* OID of view - should be >= oid of table - * important because views may be constructed - * manually from rules, and rule may ref things - * created after the base table was created. - */ + * important because views may be + * constructed manually from rules, and + * rule may ref things created after the + * base table was created. */ bool sequence; bool hasoids; /* does it have OIDs? */ int numatts; /* number of attributes */ int *inhAttrs; /* an array of flags, one for each * attribute if the value is 1, then this * attribute is an inherited attribute */ - int *inhAttrDef; /* Flags indicating if attrdef is inherited */ - int *inhNotNull; /* Flags indicating if NOT NULL in inherited */ + int *inhAttrDef; /* Flags indicating if attrdef is + * inherited */ + int *inhNotNull; /* Flags indicating if NOT NULL in + * inherited */ char **attnames; /* the attribute names */ char **atttypedefns; /* formatted column type definitions */ char **typnames; /* fill out attributes */ @@ -157,7 +159,8 @@ typedef struct _aggInfo char *aggbasetype; char *agginitval; char *usename; - int convertok; /* Flag to indicate of version convertsion is OK */ + int convertok; /* Flag to indicate of version convertsion + * is OK */ } AggInfo; typedef struct _oprInfo @@ -165,7 +168,7 @@ typedef struct _oprInfo char *oid; char *oprname; char *oprkind; /*---------- - * b = binary, + * b = binary, * l = left unary * r = right unary *---------- @@ -221,11 +224,11 @@ extern void dumpSchemaIdx(Archive *fout, typedef enum _OidOptions { - zeroAsOpaque = 1, - zeroAsAny = 2, - zeroAsStar = 4, - zeroAsNone = 8, - useBaseTypeName = 1024 + zeroAsOpaque = 1, + zeroAsAny = 2, + zeroAsStar = 4, + zeroAsNone = 8, + useBaseTypeName = 1024 } OidOptions; extern char *findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts); @@ -276,5 +279,4 @@ extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes, TableInfo *tbinfo, int numTables, const char *tablename); extern const char *fmtId(const char *identifier, bool force_quotes); extern void exit_nicely(void); - #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 94571db53b..3152126f8c 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -34,7 +34,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.26 2001/09/04 03:20:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.27 2001/10/25 05:49:53 momjian Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -123,12 +123,14 @@ main(int argc, char **argv) {"username", 1, NULL, 'U'}, {"verbose", 0, NULL, 'v'}, - /* the following options don't have an equivalent short option - letter, but are available as '-X long-name' */ + /* + * the following options don't have an equivalent short option + * letter, but are available as '-X long-name' + */ {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, {NULL, 0, NULL, 0} }; -#endif /* HAVE_GETOPT_LONG */ +#endif /* HAVE_GETOPT_LONG */ #ifdef ENABLE_NLS @@ -275,7 +277,7 @@ main(int argc, char **argv) break; case 'X': - if (strcmp(optarg, "use-set-session-authorization")==0) + if (strcmp(optarg, "use-set-session-authorization") == 0) use_setsessauth = 1; else { @@ -375,80 +377,80 @@ static void usage(const char *progname) { printf(gettext( - "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n" - "Usage:\n %s [options] [file]\n\n" - "Options:\n"), + "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n" + "Usage:\n %s [options] [file]\n\n" + "Options:\n"), progname, progname); #ifdef HAVE_GETOPT_LONG puts(gettext( - " -a, --data-only restore only the data, no schema\n" - " -c, --clean clean (drop) schema prior to create\n" - " -C, --create issue commands to create the database\n" - " -d, --dbname=NAME specify database name\n" - " -f, --file=FILENAME TOC output file name (see -l)\n" - " -F, --format={c|t} specify backup file format\n" - " -h, --host=HOSTNAME server host name\n" - " -i, --index=NAME restore named index\n" - " -l, --list dump summarized TOC for of the archive\n" - " -L, --use-list=FILENAME use specified table of contents for ordering\n" - " output from this file\n" - " -N, --orig-order restore in original dump order\n" - " -o, --oid-order restore in oid order\n" - " -O, --no-owner do not reconnect to database to match\n" - " object owner\n" - " -p, --port=PORT server port number\n" - " -P, --function=NAME restore named function\n" - " -r, --rearrange rearrange output to put indexes etc. at end\n" - " -R, --no-reconnect disallow ALL reconnections to the database\n" - " -s, --schema-only restore only the schema, no data\n" - " -S, --superuser=NAME specify the superuser user name to use for\n" - " disabling triggers\n" - " -t, --table=NAME restore named table\n" - " -T, --trigger=NAME restore named trigger\n" + " -a, --data-only restore only the data, no schema\n" + " -c, --clean clean (drop) schema prior to create\n" + " -C, --create issue commands to create the database\n" + " -d, --dbname=NAME specify database name\n" + " -f, --file=FILENAME TOC output file name (see -l)\n" + " -F, --format={c|t} specify backup file format\n" + " -h, --host=HOSTNAME server host name\n" + " -i, --index=NAME restore named index\n" + " -l, --list dump summarized TOC for of the archive\n" + " -L, --use-list=FILENAME use specified table of contents for ordering\n" + " output from this file\n" + " -N, --orig-order restore in original dump order\n" + " -o, --oid-order restore in oid order\n" + " -O, --no-owner do not reconnect to database to match\n" + " object owner\n" + " -p, --port=PORT server port number\n" + " -P, --function=NAME restore named function\n" + " -r, --rearrange rearrange output to put indexes etc. at end\n" + " -R, --no-reconnect disallow ALL reconnections to the database\n" + " -s, --schema-only restore only the schema, no data\n" + " -S, --superuser=NAME specify the superuser user name to use for\n" + " disabling triggers\n" + " -t, --table=NAME restore named table\n" + " -T, --trigger=NAME restore named trigger\n" " -U, --username=NAME connect as specified database user\n" - " -v, --verbose verbose mode\n" - " -W, --password force password prompt (should happen automatically)\n" - " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n" - " -X use-set-session-authorization, --use-set-session-authorization\n" - " use SET SESSION AUTHORIZATION commands instead\n" - " of reconnecting, if possible\n" - )); + " -v, --verbose verbose mode\n" + " -W, --password force password prompt (should happen automatically)\n" + " -x, --no-privileges skip restoration of access privileges (grant/revoke)\n" + " -X use-set-session-authorization, --use-set-session-authorization\n" + " use SET SESSION AUTHORIZATION commands instead\n" + " of reconnecting, if possible\n" + )); -#else /* not HAVE_GETOPT_LONG */ +#else /* not HAVE_GETOPT_LONG */ puts(gettext( - " -a restore only the data, no schema\n" - " -c clean (drop) schema prior to create\n" - " -C issue commands to create the database\n" - " -d NAME specify database name\n" - " -f FILENAME TOC output file name (see -l)\n" - " -F {c|t} specify backup file format\n" - " -h HOSTNAME server host name\n" - " -i NAME restore named index\n" - " -l dump summarized TOC for this file\n" - " -L FILENAME use specified table of contents for ordering\n" - " output from this file\n" - " -N restore in original dump order\n" - " -o restore in oid order\n" - " -O do not output reconnect to database to match\n" - " object owner\n" - " -p PORT server port number\n" - " -P NAME restore named function\n" - " -r rearrange output to put indexes etc. at end\n" - " -R disallow ALL reconnections to the database\n" - " -s restore only the schema, no data\n" - " -S NAME specify the superuser user name to use for\n" - " disabling triggers\n" - " -t NAME restore named table\n" - " -T NAME restore named trigger\n" + " -a restore only the data, no schema\n" + " -c clean (drop) schema prior to create\n" + " -C issue commands to create the database\n" + " -d NAME specify database name\n" + " -f FILENAME TOC output file name (see -l)\n" + " -F {c|t} specify backup file format\n" + " -h HOSTNAME server host name\n" + " -i NAME restore named index\n" + " -l dump summarized TOC for this file\n" + " -L FILENAME use specified table of contents for ordering\n" + " output from this file\n" + " -N restore in original dump order\n" + " -o restore in oid order\n" + " -O do not output reconnect to database to match\n" + " object owner\n" + " -p PORT server port number\n" + " -P NAME restore named function\n" + " -r rearrange output to put indexes etc. at end\n" + " -R disallow ALL reconnections to the database\n" + " -s restore only the schema, no data\n" + " -S NAME specify the superuser user name to use for\n" + " disabling triggers\n" + " -t NAME restore named table\n" + " -T NAME restore named trigger\n" " -U NAME connect as specified database user\n" - " -v verbose mode\n" - " -W force password prompt (should happen automatically)\n" - " -x skip restoration of access privileges (grant/revoke)\n" - " -X use-set-session-authorization\n" - " use SET SESSION AUTHORIZATION commands instead\n" - " of reconnecting, if possible\n" - )); + " -v verbose mode\n" + " -W force password prompt (should happen automatically)\n" + " -x skip restoration of access privileges (grant/revoke)\n" + " -X use-set-session-authorization\n" + " use SET SESSION AUTHORIZATION commands instead\n" + " of reconnecting, if possible\n" + )); #endif puts(gettext("If no input file name is supplied, then standard input is used.\n")); puts(gettext("Report bugs to <pgsql-bugs@postgresql.org>.")); diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c index 3e2b84e0bd..f63a01b90e 100644 --- a/src/bin/pg_encoding/pg_encoding.c +++ b/src/bin/pg_encoding/pg_encoding.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.9 2001/09/06 04:57:29 ishii Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.10 2001/10/25 05:49:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,17 +22,17 @@ static void usage(void); int main(int argc, char **argv) { - char *p; - int enc; - bool be_only = FALSE; + char *p; + int enc; + bool be_only = FALSE; if (argc < 2) { usage(); exit(1); } - - if (strcmp(argv[1], "-b")==0) + + if (strcmp(argv[1], "-b") == 0) { if (argc < 3) { @@ -44,14 +44,14 @@ main(int argc, char **argv) } else p = argv[1]; - + if (p && *p && isdigit((unsigned char) *p)) { /* * Encoding number to name */ - char *name; - + char *name; + enc = atoi(p); if ((name = (char *) pg_encoding_to_char(enc))) @@ -74,16 +74,16 @@ main(int argc, char **argv) printf("%d\n", enc); } exit(0); - } + } exit(1); } static void usage() { - fprintf(stderr, - "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n" - "options:" - " -b check if encoding is valid for backend\n\n" - ); + fprintf(stderr, + "\nUsage: pg_encoding [options] encoding_name | encoding_number\n\n" + "options:" + " -b check if encoding is valid for backend\n\n" + ); } diff --git a/src/bin/pg_passwd/pg_passwd.c b/src/bin/pg_passwd/pg_passwd.c index 4c9790b677..831c382370 100644 --- a/src/bin/pg_passwd/pg_passwd.c +++ b/src/bin/pg_passwd/pg_passwd.c @@ -16,7 +16,6 @@ #include <crypt.h> #else extern char *crypt(const char *, const char *); - #endif /* @@ -289,7 +288,6 @@ prompt_for_password(char *prompt, char *password) #ifdef HAVE_TERMIOS_H struct termios t_orig, t; - #endif #ifdef HAVE_TERMIOS_H diff --git a/src/bin/pgtclsh/pgtclAppInit.c b/src/bin/pgtclsh/pgtclAppInit.c index 487e11eaf5..cfdda03a8b 100644 --- a/src/bin/pgtclsh/pgtclAppInit.c +++ b/src/bin/pgtclsh/pgtclAppInit.c @@ -23,7 +23,6 @@ #ifdef NEED_MATHERR extern int matherr(); int *tclDummyMathPtr = (int *) matherr; - #endif diff --git a/src/bin/pgtclsh/pgtkAppInit.c b/src/bin/pgtclsh/pgtkAppInit.c index 3f3b43bf30..46b20edac7 100644 --- a/src/bin/pgtclsh/pgtkAppInit.c +++ b/src/bin/pgtclsh/pgtkAppInit.c @@ -23,7 +23,6 @@ #ifdef NEED_MATHERR extern int matherr(); int *tclDummyMathPtr = (int *) matherr; - #endif diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index b6f8be54e8..004b8bacaf 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.60 2001/10/11 16:54:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.61 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -56,7 +56,7 @@ static backslashResult exec_command(const char *cmd, enum option_type { - OT_NORMAL, OT_SQLID, OT_FILEPIPE + OT_NORMAL, OT_SQLID, OT_FILEPIPE }; static char *scan_option(char **string, enum option_type type, char *quote, bool semicolon); static char *unescape(const unsigned char *source, size_t len); @@ -130,11 +130,10 @@ HandleSlashCmds(const char *line, if (status == CMD_UNKNOWN) { - /* - * If the command was not recognized, try to parse it as a one-letter - * command with immediately following argument (a still-supported, - * but no longer encouraged, syntax). + * If the command was not recognized, try to parse it as a + * one-letter command with immediately following argument (a + * still-supported, but no longer encouraged, syntax). */ char new_cmd[2]; @@ -144,7 +143,10 @@ HandleSlashCmds(const char *line, /* use line for options, because my_line was clobbered above */ status = exec_command(new_cmd, line + 1, &continue_parse, query_buf); - /* continue_parse must be relative to my_line for calculation below */ + /* + * continue_parse must be relative to my_line for calculation + * below + */ continue_parse += my_line - line; #if 0 /* turned out to be too annoying */ @@ -262,8 +264,8 @@ exec_command(const char *cmd, /* \cd */ else if (strcmp(cmd, "cd") == 0) { - char *opt = scan_option(&string, OT_NORMAL, NULL, true); - char *dir; + char *opt = scan_option(&string, OT_NORMAL, NULL, true); + char *dir; if (opt) dir = opt; @@ -279,12 +281,14 @@ exec_command(const char *cmd, exit(EXIT_FAILURE); } dir = pw->pw_dir; -#else /* WIN32 */ - /* On Windows, 'cd' without arguments prints the current - directory, so if someone wants to code this here - instead... */ +#else /* WIN32 */ + + /* + * On Windows, 'cd' without arguments prints the current + * directory, so if someone wants to code this here instead... + */ dir = "/"; -#endif /* WIN32 */ +#endif /* WIN32 */ } if (chdir(dir) == -1) @@ -315,6 +319,7 @@ exec_command(const char *cmd, { char *name; bool show_verbose; + name = scan_option(&string, OT_SQLID, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; @@ -359,7 +364,7 @@ exec_command(const char *cmd, break; case 'u': success = describeUsers(name); - break; + break; default: status = CMD_UNKNOWN; } @@ -401,7 +406,7 @@ exec_command(const char *cmd, fout = pset.queryFout; else fout = stdout; - + while ((value = scan_option(&string, OT_NORMAL, "ed, false))) { if (!quoted && strcmp(value, "-n") == 0) @@ -649,7 +654,6 @@ exec_command(const char *cmd, } else { - /* * Set variable to the concatenation of the arguments. */ @@ -866,7 +870,6 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) switch (options_string[pos]) { - /* * Double quoted string */ @@ -937,7 +940,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) *string = options_string + jj + 1; if (quote) *quote = '"'; - + return return_val; } @@ -1119,10 +1122,13 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon) return_val[token_end] = 0; /* Strip any trailing semi-colons for some types */ - if (semicolon) { - int i; - for (i = strlen(return_val)-1; i && return_val[i]==';'; i--); - if (i<strlen(return_val)-1) return_val[i+1]='\0'; + if (semicolon) + { + int i; + + for (i = strlen(return_val) - 1; i && return_val[i] == ';'; i--); + if (i < strlen(return_val) - 1) + return_val[i + 1] = '\0'; } if (type == OT_SQLID) @@ -1331,7 +1337,6 @@ do_connect(const char *new_dbname, const char *new_user) } else { - /* * we don't want unpredictable things to happen in scripting * mode @@ -1466,7 +1471,6 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) #ifndef WIN32 struct stat before, after; - #endif if (filename_arg) @@ -1626,7 +1630,7 @@ _align2string(enum printFormat in) { switch (in) { - case PRINT_NOTHING: + case PRINT_NOTHING: return "nothing"; break; case PRINT_UNALIGNED: diff --git a/src/bin/psql/command.h b/src/bin/psql/command.h index f719d2aa20..8141201eea 100644 --- a/src/bin/psql/command.h +++ b/src/bin/psql/command.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.10 2000/04/12 17:16:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/command.h,v 1.11 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COMMAND_H #define COMMAND_H @@ -16,12 +16,12 @@ typedef enum _backslashResult { - CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */ - CMD_SEND, /* query complete; send off */ - CMD_SKIP_LINE, /* keep building query */ - CMD_TERMINATE, /* quit program */ - CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */ - CMD_ERROR /* the execution of the backslash command + CMD_UNKNOWN = 0,/* not done parsing yet (internal only) */ + CMD_SEND, /* query complete; send off */ + CMD_SKIP_LINE, /* keep building query */ + CMD_TERMINATE, /* quit program */ + CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */ + CMD_ERROR /* the execution of the backslash command * resulted in an error */ } backslashResult; @@ -40,5 +40,4 @@ bool do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet); - #endif /* COMMAND_H */ diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 336d813878..0380f1f1bc 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.36 2001/10/18 21:57:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.37 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" @@ -176,7 +176,9 @@ simple_prompt(const char *prompt, int maxlen, bool echo) { int length; char *destination; - FILE *termin, *termout; + FILE *termin, + *termout; + #ifdef HAVE_TERMIOS_H struct termios t_orig, t; @@ -189,8 +191,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) prompt_state = true; /* disable SIGINT */ /* - * Do not try to collapse these into one "w+" mode file. - * Doesn't work on some platforms (eg, HPUX 10.20). + * Do not try to collapse these into one "w+" mode file. Doesn't work + * on some platforms (eg, HPUX 10.20). */ termin = fopen("/dev/tty", "r"); termout = fopen("/dev/tty", "w"); @@ -213,7 +215,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) tcsetattr(fileno(termin), TCSAFLUSH, &t); } #endif - + if (prompt) { fputs(gettext(prompt), termout); @@ -304,7 +306,6 @@ handle_sigint(SIGNAL_ARGS) } errno = save_errno; /* just in case the write changed it */ } - #endif /* not WIN32 */ @@ -314,7 +315,7 @@ handle_sigint(SIGNAL_ARGS) * This is the way to send "backdoor" queries (those not directly entered * by the user). It is subject to -E but not -e. */ -PGresult * +PGresult * PSQLexec(const char *query) { PGresult *res; @@ -509,7 +510,7 @@ SendQuery(const char *query) case PGRES_COPY_IN: if (pset.cur_cmd_interactive && !QUIET()) puts(gettext("Enter data to be copied followed by a newline.\n" - "End with a backslash and a period on a line by itself.")); + "End with a backslash and a period on a line by itself.")); success = handleCopyIn(pset.db, pset.cur_cmd_source, pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL); diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h index f9604bf90d..617e4d5a84 100644 --- a/src/bin/psql/common.h +++ b/src/bin/psql/common.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.14 2001/10/03 21:58:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.15 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COMMON_H #define COMMON_H @@ -13,28 +13,27 @@ #include "pqsignal.h" #include "libpq-fe.h" -extern char *xstrdup(const char *string); +extern char *xstrdup(const char *string); -extern bool setQFout(const char *fname); +extern bool setQFout(const char *fname); -extern void psql_error(const char *fmt, ...) +extern void +psql_error(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); -extern void NoticeProcessor(void *arg, const char *message); +extern void NoticeProcessor(void *arg, const char *message); -extern char *simple_prompt(const char *prompt, int maxlen, bool echo); +extern char *simple_prompt(const char *prompt, int maxlen, bool echo); extern volatile bool cancel_pressed; extern PGconn *cancelConn; #ifndef WIN32 -extern void handle_sigint(SIGNAL_ARGS); - +extern void handle_sigint(SIGNAL_ARGS); #endif /* not WIN32 */ -extern PGresult *PSQLexec(const char *query); - -extern bool SendQuery(const char *query); +extern PGresult *PSQLexec(const char *query); +extern bool SendQuery(const char *query); #endif /* COMMON_H */ diff --git a/src/bin/psql/copy.h b/src/bin/psql/copy.h index 66114fdbf4..3bda9913f3 100644 --- a/src/bin/psql/copy.h +++ b/src/bin/psql/copy.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.9 2000/03/01 21:09:58 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.10 2001/10/25 05:49:53 momjian Exp $ */ #ifndef COPY_H #define COPY_H @@ -19,5 +19,4 @@ bool do_copy(const char *args); bool handleCopyOut(PGconn *conn, FILE *copystream); bool handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt); - #endif diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 62fec530e9..6fefdf49da 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.40 2001/10/06 14:41:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.41 2001/10/25 05:49:53 momjian Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -54,7 +54,7 @@ describeAggregates(const char *name) " obj_description(a.oid, 'pg_aggregate') as \"%s\"\n" "FROM pg_aggregate a\n", _("Name"), _("(all types)"), - _("Data type"), _("Description") ); + _("Data type"), _("Description")); if (name) { @@ -98,7 +98,7 @@ describeFunctions(const char *name, bool verbose) " p.proname as \"%s\",\n" " oidvectortypes(p.proargtypes) as \"%s\"", _("Result data type"), _("Name"), - _("Argument data types") ); + _("Argument data types")); if (verbose) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), @@ -107,7 +107,7 @@ describeFunctions(const char *name, bool verbose) " p.prosrc as \"%s\",\n" " obj_description(p.oid, 'pg_proc') as \"%s\"", _("Owner"), _("Language"), - _("Source code"), _("Description") ); + _("Source code"), _("Description")); if (!verbose) strcat(buf, @@ -155,7 +155,7 @@ describeTypes(const char *name, bool verbose) snprintf(buf, sizeof(buf), "SELECT format_type(t.oid, NULL) AS \"%s\",\n", - _("Name") ); + _("Name")); if (verbose) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " t.typname AS \"%s\",\n" @@ -163,10 +163,10 @@ describeTypes(const char *name, bool verbose) " THEN CAST('var' AS text)\n" " ELSE CAST(t.typlen AS text)\n" " END AS \"%s\",\n", - _("Internal name"), _("Size") ); - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + _("Internal name"), _("Size")); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " obj_description(t.oid, 'pg_type') as \"%s\"\n", - _("Description") ); + _("Description")); /* * do not include array types (start with underscore), do not include @@ -218,7 +218,7 @@ describeOperators(const char *name) "FROM pg_proc p, pg_operator o\n" "WHERE RegprocToOid(o.oprcode) = p.oid\n", _("Name"), _("Left arg type"), _("Right arg type"), - _("Result type"), _("Description") ); + _("Result type"), _("Description")); if (name) { strcat(buf, " AND o.oprname = '"); @@ -265,10 +265,10 @@ listAllDbs(bool desc) #endif if (desc) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - ",\n obj_description(d.oid, 'pg_database') as \"%s\"", + ",\n obj_description(d.oid, 'pg_database') as \"%s\"", _("Description")); strcat(buf, - "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n" + "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n" "ORDER BY 1;"); res = PSQLexec(buf); @@ -347,32 +347,32 @@ objectDescription(const char *object) "SELECT DISTINCT tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n" "FROM (\n" - /* Aggregate descriptions */ + /* Aggregate descriptions */ " SELECT a.oid as oid, a.tableoid as tableoid,\n" - " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(a.aggname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_aggregate a\n" - /* Function descriptions (except in/outs for datatypes) */ + /* Function descriptions (except in/outs for datatypes) */ "UNION ALL\n" " SELECT p.oid as oid, p.tableoid as tableoid,\n" - " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_proc p\n" - " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n" + " WHERE p.pronargs = 0 or oidvectortypes(p.proargtypes) <> ''\n" - /* Operator descriptions (must get comment via associated function) */ + /* Operator descriptions (must get comment via associated function) */ "UNION ALL\n" " SELECT RegprocToOid(o.oprcode) as oid,\n" " (SELECT oid FROM pg_class WHERE relname = 'pg_proc') as tableoid,\n" - " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_operator o\n" - /* Type description */ + /* Type description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" - " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" + " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" " FROM pg_type t\n" - /* Relation (tables, views, indexes, sequences) descriptions */ + /* Relation (tables, views, indexes, sequences) descriptions */ "UNION ALL\n" " SELECT c.oid as oid, c.tableoid as tableoid,\n" " CAST(c.relname AS text) as name,\n" @@ -381,17 +381,17 @@ objectDescription(const char *object) " AS text) as object\n" " FROM pg_class c\n" - /* Rule description (ignore rules for views) */ + /* Rule description (ignore rules for views) */ "UNION ALL\n" " SELECT r.oid as oid, r.tableoid as tableoid,\n" - " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" + " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_rewrite r\n" " WHERE r.rulename !~ '^_RET'\n" - /* Trigger description */ + /* Trigger description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" - " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" + " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" " FROM pg_trigger t\n" ") AS tt,\n" @@ -664,10 +664,10 @@ describeTableDetails(const char *name, bool desc) error = true; else { - char *indisunique = PQgetvalue(result, 0, 0); - char *indisprimary = PQgetvalue(result, 0, 1); - char *indamname = PQgetvalue(result, 0, 2); - char *indpred = PQgetvalue(result, 0, 3); + char *indisunique = PQgetvalue(result, 0, 0); + char *indisprimary = PQgetvalue(result, 0, 1); + char *indamname = PQgetvalue(result, 0, 2); + char *indpred = PQgetvalue(result, 0, 3); footers = xmalloc(3 * sizeof(*footers)); /* XXX This construction is poorly internationalized. */ @@ -704,18 +704,18 @@ describeTableDetails(const char *name, bool desc) else if (tableinfo.relkind == 'r') { /* Footer information about a table */ - PGresult *result1 = NULL, - *result2 = NULL, - *result3 = NULL, - *result4 = NULL, - *result5 = NULL, - *result6 = NULL; + PGresult *result1 = NULL, + *result2 = NULL, + *result3 = NULL, + *result4 = NULL, + *result5 = NULL, + *result6 = NULL; int index_count = 0, - primary_count = 0, - unique_count = 0, - constr_count = 0, - rule_count = 0, - trigger_count = 0; + primary_count = 0, + unique_count = 0, + constr_count = 0, + rule_count = 0, + trigger_count = 0; int count_footers = 0; /* count indexes */ @@ -724,7 +724,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND NOT i.indisunique ORDER BY c2.relname", + "AND NOT i.indisunique ORDER BY c2.relname", name); result1 = PSQLexec(buf); if (!result1) @@ -739,7 +739,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND i.indisprimary AND i.indisunique ORDER BY c2.relname", + "AND i.indisprimary AND i.indisunique ORDER BY c2.relname", name); result5 = PSQLexec(buf); if (!result5) @@ -754,7 +754,7 @@ describeTableDetails(const char *name, bool desc) sprintf(buf, "SELECT c2.relname\n" "FROM pg_class c, pg_class c2, pg_index i\n" "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname", + "AND NOT i.indisprimary AND i.indisunique ORDER BY c2.relname", name); result6 = PSQLexec(buf); if (!result6) @@ -808,18 +808,18 @@ describeTableDetails(const char *name, bool desc) } footers = xmalloc((index_count + primary_count + unique_count + - constr_count + rule_count + trigger_count + 1) - * sizeof(*footers)); + constr_count + rule_count + trigger_count + 1) + * sizeof(*footers)); /* print indexes */ for (i = 0; i < index_count; i++) { - char *s = _("Indexes"); + char *s = _("Indexes"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result1, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result1, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result1, i, 0)); if (i < index_count - 1) strcat(buf, ","); @@ -829,12 +829,12 @@ describeTableDetails(const char *name, bool desc) /* print primary keys */ for (i = 0; i < primary_count; i++) { - char *s = _("Primary key"); + char *s = _("Primary key"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result5, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result5, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result5, i, 0)); if (i < primary_count - 1) strcat(buf, ","); @@ -844,12 +844,12 @@ describeTableDetails(const char *name, bool desc) /* print unique constraints */ for (i = 0; i < unique_count; i++) { - char *s = _("Unique keys"); + char *s = _("Unique keys"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result6, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result6, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result6, i, 0)); if (i < unique_count - 1) strcat(buf, ","); @@ -859,26 +859,26 @@ describeTableDetails(const char *name, bool desc) /* print constraints */ for (i = 0; i < constr_count; i++) { - char *s = _("Check constraints"); + char *s = _("Check constraints"); if (i == 0) snprintf(buf, sizeof(buf), _("%s: \"%s\" %s"), s, - PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); + PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); else - snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int)strlen(s), "", - PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); + snprintf(buf, sizeof(buf), _("%*s \"%s\" %s"), (int) strlen(s), "", + PQgetvalue(result2, i, 1), PQgetvalue(result2, i, 0)); footers[count_footers++] = xstrdup(buf); } /* print rules */ for (i = 0; i < rule_count; i++) { - char *s = _("Rules"); + char *s = _("Rules"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result3, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result3, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result3, i, 0)); if (i < rule_count - 1) strcat(buf, ","); @@ -888,12 +888,12 @@ describeTableDetails(const char *name, bool desc) /* print triggers */ for (i = 0; i < trigger_count; i++) { - char *s = _("Triggers"); + char *s = _("Triggers"); if (i == 0) snprintf(buf, sizeof(buf), "%s: %s", s, PQgetvalue(result4, i, 0)); else - snprintf(buf, sizeof(buf), "%*s %s", (int)strlen(s), "", PQgetvalue(result4, i, 0)); + snprintf(buf, sizeof(buf), "%*s %s", (int) strlen(s), "", PQgetvalue(result4, i, 0)); if (i < trigger_count - 1) strcat(buf, ","); @@ -944,16 +944,16 @@ describeTableDetails(const char *name, bool desc) */ bool -describeUsers (const char *name) +describeUsers(const char *name) { char buf[384 + REGEXP_CUTOFF]; PGresult *res; printQueryOpt myopt = pset.popt; - + snprintf(buf, sizeof(buf), "SELECT u.usename AS \"%s\",\n" " u.usesysid AS \"%s\",\n" - " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n" + " CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS text)\n" " WHEN u.usesuper THEN CAST('%s' AS text)\n" " WHEN u.usecreatedb THEN CAST('%s' AS text)\n" " ELSE CAST('' AS text)\n" @@ -962,7 +962,7 @@ describeUsers (const char *name) _("User name"), _("User ID"), _("superuser, create database"), _("superuser"), _("create database"), - _("Attributes") ); + _("Attributes")); if (name) { strcat(buf, "WHERE u.usename ~ '^"); @@ -1033,7 +1033,7 @@ listTables(const char *infotype, const char *name, bool desc) ",\n obj_description(c.oid, 'pg_class') as \"%s\"", _("Description")); strcat(buf, - "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n" + "\nFROM pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid\n" "WHERE c.relkind IN ("); if (showTables) strcat(buf, "'r',"); @@ -1045,7 +1045,7 @@ listTables(const char *infotype, const char *name, bool desc) strcat(buf, "'S',"); if (showSystem && showTables) strcat(buf, "'s',"); - strcat(buf, "''"); /* dummy */ + strcat(buf, "''"); /* dummy */ strcat(buf, ")\n"); if (showSystem) diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 98821fbed0..2fc05f9d32 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.10 2001/05/09 17:29:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.11 2001/10/25 05:49:53 momjian Exp $ */ #ifndef DESCRIBE_H #define DESCRIBE_H @@ -23,7 +23,7 @@ bool describeTypes(const char *name, bool verbose); bool describeOperators(const char *name); /* \du */ -bool describeUsers(const char *name); +bool describeUsers(const char *name); /* \z (or \dp) */ bool permissionsList(const char *name); @@ -39,5 +39,4 @@ bool listAllDbs(bool desc); /* \dt, \di, \ds, \dS, etc. */ bool listTables(const char *infotype, const char *name, bool desc); - #endif /* DESCRIBE_H */ diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 46d5794afa..b4614627a7 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.41 2001/06/11 18:23:33 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.42 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "help.h" @@ -54,7 +54,6 @@ usage(void) #ifndef WIN32 struct passwd *pw = NULL; - #endif /* Find default user, in case we need it. */ @@ -132,10 +131,10 @@ usage(void) puts(_(" -X Do not read startup file (~/.psqlrc)")); puts(_( - "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n" - "(for SQL commands) from within psql, or consult the psql section in\n" - "the PostgreSQL documentation.\n\n" - "Report bugs to <pgsql-bugs@postgresql.org>.")); + "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n" + "(for SQL commands) from within psql, or consult the psql section in\n" + "the PostgreSQL documentation.\n\n" + "Report bugs to <pgsql-bugs@postgresql.org>.")); } @@ -152,7 +151,6 @@ struct winsize int ws_row; int ws_col; }; - #endif void @@ -193,7 +191,7 @@ slashUsage(void) /* if you add/remove a line here, change the row test above */ fprintf(fout, _(" \\a toggle between unaligned and aligned output mode\n")); fprintf(fout, _(" \\c[onnect] [DBNAME|- [USER]]\n" - " connect to new database (currently \"%s\")\n"), + " connect to new database (currently \"%s\")\n"), PQdb(pset.db)); fprintf(fout, _(" \\C TITLE set table title\n")); fprintf(fout, _(" \\cd [DIRNAME] change the current working directory\n")); @@ -334,5 +332,5 @@ print_copyright(void) "PARTICULAR PURPOSE.THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS,\n" "AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,\n" "SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - ); + ); } diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h index 47fed65b41..36cf326a01 100644 --- a/src/bin/psql/help.h +++ b/src/bin/psql/help.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.6 2000/02/16 13:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/help.h,v 1.7 2001/10/25 05:49:54 momjian Exp $ */ #ifndef HELP_H #define HELP_H @@ -15,5 +15,4 @@ void slashUsage(void); void helpSQL(const char *topic); void print_copyright(void); - #endif diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index 17cfee41ae..32872e9d71 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.17 2001/09/11 23:08:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.18 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "input.h" @@ -19,18 +19,17 @@ /* (of course there is no runtime command for doing that :) */ #ifdef USE_READLINE static bool useReadline; - #endif #ifdef USE_HISTORY static bool useHistory; - #endif #ifdef HAVE_ATEXIT -static void finishInput(void); +static void finishInput(void); + #else /* designed for use with on_exit() */ -static void finishInput(int, void*); +static void finishInput(int, void *); #endif @@ -48,7 +47,6 @@ gets_interactive(char *prompt) #ifdef USE_HISTORY const char *var; static char *prev_hist = NULL; - #endif #ifdef USE_READLINE diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h index ff9deade1d..86caad4f0e 100644 --- a/src/bin/psql/input.h +++ b/src/bin/psql/input.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.12 2001/09/11 23:08:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.13 2001/10/25 05:49:54 momjian Exp $ */ #ifndef INPUT_H #define INPUT_H @@ -39,5 +39,4 @@ char *gets_fromFile(FILE *source); void initializeInput(int flags); bool saveHistory(char *fname); - #endif /* INPUT_H */ diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index 5fe95a4343..9aba63767e 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.17 2001/10/04 22:39:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.18 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "large_obj.h" @@ -194,9 +194,9 @@ do_lo_import(const char *filename_arg, const char *comment_arg) /* XXX ought to replace this with some kind of COMMENT command */ if (comment_arg && pset.issuper) { - char *cmdbuf; - char *bufptr; - int slen = strlen(comment_arg); + char *cmdbuf; + char *bufptr; + int slen = strlen(comment_arg); cmdbuf = malloc(slen * 2 + 256); if (!cmdbuf) @@ -210,7 +210,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg) } sprintf(cmdbuf, "INSERT INTO pg_description VALUES ('%u', " - "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')," + "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')," " 0, '", loid); bufptr = cmdbuf + strlen(cmdbuf); for (i = 0; i < slen; i++) diff --git a/src/bin/psql/large_obj.h b/src/bin/psql/large_obj.h index b8fcfde04d..85e708b1a4 100644 --- a/src/bin/psql/large_obj.h +++ b/src/bin/psql/large_obj.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.8 2000/02/16 13:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ #ifndef LARGE_OBJ_H #define LARGE_OBJ_H @@ -12,5 +12,4 @@ bool do_lo_export(const char *loid_arg, const char *filename_arg); bool do_lo_import(const char *filename_arg, const char *comment_arg); bool do_lo_unlink(const char *loid_arg); bool do_lo_list(void); - #endif /* LARGE_OBJ_H */ diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 3c8e8ec268..f728e4df1f 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.40 2001/06/02 18:25:18 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.41 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "mainloop.h" @@ -101,7 +101,6 @@ MainLoop(FILE *source) { if (!pset.cur_cmd_interactive) { - /* * You get here if you stopped a script with Ctrl-C and a * query cancel was issued. In that case we don't do the @@ -137,14 +136,15 @@ MainLoop(FILE *source) } } - /* establish the control-C handler only after main_loop_jmp is ready */ - pqsignal(SIGINT, handle_sigint); /* control-C => cancel */ - + /* + * establish the control-C handler only after main_loop_jmp is + * ready + */ + pqsignal(SIGINT, handle_sigint); /* control-C => cancel */ #endif /* not WIN32 */ if (slashCmdStatus == CMD_NEWEDIT) { - /* * just returned from editing the line? then just copy to the * input buffer @@ -393,7 +393,7 @@ MainLoop(FILE *source) line = new; len = strlen(new); - goto rescan;/* reparse the just substituted */ + goto rescan; /* reparse the just substituted */ } else { @@ -410,7 +410,6 @@ MainLoop(FILE *source) /* is there anything else on the line? */ if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0') { - /* * insert a cosmetic newline, if this is not the first * line in the buffer @@ -454,7 +453,6 @@ MainLoop(FILE *source) /* is there anything else on the line for the command? */ if (line[query_start + strspn(line + query_start, " \t\n\r")] != '\0') { - /* * insert a cosmetic newline, if this is not the first * line in the buffer @@ -563,8 +561,8 @@ MainLoop(FILE *source) /* * Reset SIGINT handler because main_loop_jmp will be invalid as soon * as we exit this routine. If there is an outer MainLoop instance, - * it will re-enable ^C catching as soon as it gets back to the top - * of its loop and resets main_loop_jmp to point to itself. + * it will re-enable ^C catching as soon as it gets back to the top of + * its loop and resets main_loop_jmp to point to itself. */ #ifndef WIN32 pqsignal(SIGINT, SIG_DFL); diff --git a/src/bin/psql/mainloop.h b/src/bin/psql/mainloop.h index cc832f194b..55e0a65fb1 100644 --- a/src/bin/psql/mainloop.h +++ b/src/bin/psql/mainloop.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.10 2001/02/10 02:31:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.h,v 1.11 2001/10/25 05:49:54 momjian Exp $ */ #ifndef MAINLOOP_H #define MAINLOOP_H @@ -14,9 +14,7 @@ #include <setjmp.h> extern sigjmp_buf main_loop_jmp; - #endif int MainLoop(FILE *source); - #endif /* MAINLOOP_H */ diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c index 986861fe4a..1ca86f0e50 100644 --- a/src/bin/psql/mbprint.c +++ b/src/bin/psql/mbprint.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.1 2001/10/15 01:25:10 ishii Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.2 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" @@ -26,21 +26,23 @@ * original available at : http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ -struct mbinterval { +struct mbinterval +{ unsigned short first; unsigned short last; }; /* auxiliary function for binary search in interval table */ static int -mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max) +mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max) { - int min = 0; - int mid; + int min = 0; + int mid; if (ucs < table[0].first || ucs > table[max].last) return 0; - while (max >= min) { + while (max >= min) + { mid = (min + max) / 2; if (ucs > table[mid].last) min = mid + 1; @@ -57,28 +59,28 @@ mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max) /* The following functions define the column width of an ISO 10646 * character as follows: * - * - The null character (U+0000) has a column width of 0. + * - The null character (U+0000) has a column width of 0. * - * - Other C0/C1 control characters and DEL will lead to a return - * value of -1. + * - Other C0/C1 control characters and DEL will lead to a return + * value of -1. * - * - Non-spacing and enclosing combining characters (general - * category code Mn or Me in the Unicode database) have a - * column width of 0. + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. * - * - Other format characters (general category code Cf in the Unicode - * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. * - * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) - * have a column width of 0. + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. * - * - Spacing characters in the East Asian Wide (W) or East Asian - * FullWidth (F) category as defined in Unicode Technical - * Report #11 have a column width of 2. + * - Spacing characters in the East Asian Wide (W) or East Asian + * FullWidth (F) category as defined in Unicode Technical + * Report #11 have a column width of 2. * - * - All remaining characters (including all printable - * ISO 8859-1 and WGL4 characters, Unicode control characters, - * etc.) have a column width of 1. + * - All remaining characters (including all printable + * ISO 8859-1 and WGL4 characters, Unicode control characters, + * etc.) have a column width of 1. * * This implementation assumes that wchar_t characters are encoded * in ISO 10646. @@ -89,68 +91,69 @@ ucs_wcwidth(pg_wchar ucs) { /* sorted list of non-overlapping intervals of non-spacing characters */ static const struct mbinterval combining[] = { - { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 }, - { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 }, - { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, - { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 }, - { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, - { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, - { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C }, - { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 }, - { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, - { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, - { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, - { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, - { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, - { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 }, - { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, - { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, - { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, - { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, - { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, - { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, - { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, - { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, - { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, - { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, - { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, - { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, - { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, - { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, - { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, - { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 }, - { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F }, - { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A }, - { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, - { 0xFFF9, 0xFFFB } + {0x0300, 0x034E}, {0x0360, 0x0362}, {0x0483, 0x0486}, + {0x0488, 0x0489}, {0x0591, 0x05A1}, {0x05A3, 0x05B9}, + {0x05BB, 0x05BD}, {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, + {0x05C4, 0x05C4}, {0x064B, 0x0655}, {0x0670, 0x0670}, + {0x06D6, 0x06E4}, {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, + {0x070F, 0x070F}, {0x0711, 0x0711}, {0x0730, 0x074A}, + {0x07A6, 0x07B0}, {0x0901, 0x0902}, {0x093C, 0x093C}, + {0x0941, 0x0948}, {0x094D, 0x094D}, {0x0951, 0x0954}, + {0x0962, 0x0963}, {0x0981, 0x0981}, {0x09BC, 0x09BC}, + {0x09C1, 0x09C4}, {0x09CD, 0x09CD}, {0x09E2, 0x09E3}, + {0x0A02, 0x0A02}, {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42}, + {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A70, 0x0A71}, + {0x0A81, 0x0A82}, {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5}, + {0x0AC7, 0x0AC8}, {0x0ACD, 0x0ACD}, {0x0B01, 0x0B01}, + {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43}, + {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B82, 0x0B82}, + {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD}, {0x0C3E, 0x0C40}, + {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56}, + {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD}, + {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D}, {0x0DCA, 0x0DCA}, + {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31}, + {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1}, + {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, {0x0EC8, 0x0ECD}, + {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, {0x0F37, 0x0F37}, + {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, {0x0F80, 0x0F84}, + {0x0F86, 0x0F87}, {0x0F90, 0x0F97}, {0x0F99, 0x0FBC}, + {0x0FC6, 0x0FC6}, {0x102D, 0x1030}, {0x1032, 0x1032}, + {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059}, + {0x1160, 0x11FF}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6}, + {0x17C9, 0x17D3}, {0x180B, 0x180E}, {0x18A9, 0x18A9}, + {0x200B, 0x200F}, {0x202A, 0x202E}, {0x206A, 0x206F}, + {0x20D0, 0x20E3}, {0x302A, 0x302F}, {0x3099, 0x309A}, + {0xFB1E, 0xFB1E}, {0xFE20, 0xFE23}, {0xFEFF, 0xFEFF}, + {0xFFF9, 0xFFFB} }; /* test for 8-bit control characters */ - if (ucs == 0) { + if (ucs == 0) return 0; - } - if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) { + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0) || ucs > 0x0010ffff) return -1; - } /* binary search in table of non-spacing characters */ if (mbbisearch(ucs, combining, - sizeof(combining) / sizeof(struct mbinterval) - 1)) { + sizeof(combining) / sizeof(struct mbinterval) - 1)) return 0; - } - /* if we arrive here, ucs is not a combining or C0/C1 control character */ + /* + * if we arrive here, ucs is not a combining or C0/C1 control + * character + */ - return 1 + + return 1 + (ucs >= 0x1100 && - (ucs <= 0x115f || /* Hangul Jamo init. consonants */ + (ucs <= 0x115f || /* Hangul Jamo init. consonants */ (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a && - ucs != 0x303f) || /* CJK ... Yi */ - (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ - (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ - (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ - (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ + ucs != 0x303f) || /* CJK ... Yi */ + (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ + (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility + * Ideographs */ + (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ + (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ (ucs >= 0xffe0 && ucs <= 0xffe6) || (ucs >= 0x20000 && ucs <= 0x2ffff))); } @@ -158,28 +161,32 @@ ucs_wcwidth(pg_wchar ucs) pg_wchar utf2ucs(const unsigned char *c) { - /* one char version of pg_utf2wchar_with_len. - * no control here, c must point to a large enough string + /* + * one char version of pg_utf2wchar_with_len. no control here, c must + * point to a large enough string */ - if ((*c & 0x80) == 0) { - return (pg_wchar)c[0]; - } - else if ((*c & 0xe0) == 0xc0) { - return (pg_wchar)(((c[0] & 0x1f) << 6) | - (c[1] & 0x3f)); + if ((*c & 0x80) == 0) + return (pg_wchar) c[0]; + else if ((*c & 0xe0) == 0xc0) + { + return (pg_wchar) (((c[0] & 0x1f) << 6) | + (c[1] & 0x3f)); } - else if ((*c & 0xf0) == 0xe0) { - return (pg_wchar)(((c[0] & 0x0f) << 12) | - ((c[1] & 0x3f) << 6) | - (c[2] & 0x3f)); + else if ((*c & 0xf0) == 0xe0) + { + return (pg_wchar) (((c[0] & 0x0f) << 12) | + ((c[1] & 0x3f) << 6) | + (c[2] & 0x3f)); } - else if ((*c & 0xf0) == 0xf0) { - return (pg_wchar)(((c[0] & 0x07) << 18) | - ((c[1] & 0x3f) << 12) | - ((c[2] & 0x3f) << 6) | - (c[3] & 0x3f)); + else if ((*c & 0xf0) == 0xf0) + { + return (pg_wchar) (((c[0] & 0x07) << 18) | + ((c[1] & 0x3f) << 12) | + ((c[2] & 0x3f) << 6) | + (c[3] & 0x3f)); } - else { + else + { /* that is an invalid code on purpose */ return 0xffffffff; } @@ -190,14 +197,15 @@ utf2ucs(const unsigned char *c) static int mb_utf_wcswidth(unsigned char *pwcs, int len) { - int w, l = 0; - int width = 0; + int w, + l = 0; + int width = 0; - for (;*pwcs && len > 0; pwcs+=l) { + for (; *pwcs && len > 0; pwcs += l) + { l = pg_utf_mblen(pwcs); - if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) { + if ((len < l) || ((w = ucs_wcwidth(utf2ucs(pwcs))) < 0)) return width; - } len -= l; width += w; } @@ -207,91 +215,95 @@ mb_utf_wcswidth(unsigned char *pwcs, int len) static int utf_charcheck(const unsigned char *c) { - /* Unicode 3.1 compliant validation : - * for each category, it checks the combination of each byte to make sur - * it maps to a valid range. It also returns -1 for the following UCS values: - * ucs > 0x10ffff - * ucs & 0xfffe = 0xfffe - * 0xfdd0 < ucs < 0xfdef - * ucs & 0xdb00 = 0xd800 (surrogates) + /* + * Unicode 3.1 compliant validation : for each category, it checks the + * combination of each byte to make sur it maps to a valid range. It + * also returns -1 for the following UCS values: ucs > 0x10ffff ucs & + * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 + * (surrogates) */ - if ((*c & 0x80) == 0) { + if ((*c & 0x80) == 0) return 1; - } - else if ((*c & 0xe0) == 0xc0) { + else if ((*c & 0xe0) == 0xc0) + { /* two-byte char */ - if(((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) { + if (((c[1] & 0xc0) == 0x80) && ((c[0] & 0x1f) > 0x01)) return 2; - } return -1; } - else if ((*c & 0xf0) == 0xe0) { + else if ((*c & 0xf0) == 0xe0) + { /* three-byte char */ if (((c[1] & 0xc0) == 0x80) && (((c[0] & 0x0f) != 0x00) || ((c[1] & 0x20) == 0x20)) && - ((c[2] & 0xc0) == 0x80)) { - int z = c[0] & 0x0f; - int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f); - int lx = yx & 0x7f; + ((c[2] & 0xc0) == 0x80)) + { + int z = c[0] & 0x0f; + int yx = ((c[1] & 0x3f) << 6) | (c[0] & 0x3f); + int lx = yx & 0x7f; /* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */ if (((z == 0x0f) && (((yx & 0xffe) == 0xffe) || - (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || - ((z == 0x0d) && ((yx & 0xb00) == 0x800))) { + (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || + ((z == 0x0d) && ((yx & 0xb00) == 0x800))) return -1; - } return 3; } return -1; } - else if ((*c & 0xf8) == 0xf0) { - int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4); + else if ((*c & 0xf8) == 0xf0) + { + int u = ((c[0] & 0x07) << 2) | ((c[1] & 0x30) >> 4); /* four-byte char */ if (((c[1] & 0xc0) == 0x80) && (u > 0x00) && (u <= 0x10) && - ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) { + ((c[2] & 0xc0) == 0x80) && ((c[3] & 0xc0) == 0x80)) + { /* test for 0xzzzzfffe/0xzzzzfffff */ if (((c[1] & 0x0f) == 0x0f) && ((c[2] & 0x3f) == 0x3f) && - ((c[3] & 0x3e) == 0x3e)) { + ((c[3] & 0x3e) == 0x3e)) return -1; - } return 4; } return -1; } return -1; } - + static unsigned char * mb_utf_validate(unsigned char *pwcs) { - int l = 0; + int l = 0; unsigned char *p = pwcs; unsigned char *p0 = pwcs; - while( *pwcs ) { - if ((l = utf_charcheck(pwcs)) > 0) { - if (p != pwcs) { - int i; - for( i = 0; i < l; i++) { + while (*pwcs) + { + if ((l = utf_charcheck(pwcs)) > 0) + { + if (p != pwcs) + { + int i; + + for (i = 0; i < l; i++) *p++ = *pwcs++; - } } - else { + else + { pwcs += l; p += l; } } - else { + else + { /* we skip the char */ pwcs++; } } - if (p != pwcs) { + if (p != pwcs) *p = '\0'; - } return p0; } @@ -300,35 +312,41 @@ mb_utf_validate(unsigned char *pwcs) */ int -pg_wcswidth(unsigned char *pwcs, int len) { - if (pset.encoding == PG_UTF8) { +pg_wcswidth(unsigned char *pwcs, int len) +{ + if (pset.encoding == PG_UTF8) return mb_utf_wcswidth(pwcs, len); - } - else { - /* obviously, other encodings may want to fix this, but I don't know them - * myself, unfortunately. + else + { + /* + * obviously, other encodings may want to fix this, but I don't + * know them myself, unfortunately. */ return len; } } unsigned char * -mbvalidate(unsigned char *pwcs) { - if (pset.encoding == PG_UTF8) { +mbvalidate(unsigned char *pwcs) +{ + if (pset.encoding == PG_UTF8) return mb_utf_validate(pwcs); - } - else { - /* other encodings needing validation should add their own routines here + else + { + /* + * other encodings needing validation should add their own + * routines here */ return pwcs; } } -#else /* !MULTIBYTE */ + +#else /* !MULTIBYTE */ /* in single-byte environment, all cells take 1 column */ -int pg_wcswidth(unsigned char *pwcs, int len) { +int +pg_wcswidth(unsigned char *pwcs, int len) +{ return len; } #endif - - diff --git a/src/bin/psql/mbprint.h b/src/bin/psql/mbprint.h index adf92f5305..4d0cab1b9d 100644 --- a/src/bin/psql/mbprint.h +++ b/src/bin/psql/mbprint.h @@ -1,4 +1,4 @@ -/* $Id: mbprint.h,v 1.1 2001/10/15 04:52:59 ishii Exp $ */ +/* $Id: mbprint.h,v 1.2 2001/10/25 05:49:54 momjian Exp $ */ #ifndef MBPRINT_H #define MBPRINT_H @@ -7,12 +7,10 @@ #include "mb/pg_wchar.h" -pg_wchar utf2ucs(const unsigned char *c); +pg_wchar utf2ucs(const unsigned char *c); unsigned char *mbvalidate(unsigned char *pwcs); -#endif /* MULTIBYTE */ - -int pg_wcswidth(unsigned char *pwcs, int len); - -#endif /* MBPRINT_H */ +#endif /* MULTIBYTE */ +int pg_wcswidth(unsigned char *pwcs, int len); +#endif /* MBPRINT_H */ diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index c3f71951ba..97ca96d660 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.22 2001/10/15 01:25:10 ishii Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "print.h" @@ -218,7 +218,8 @@ print_aligned_text(const char *title, const char *const * headers, #ifdef MULTIBYTE unsigned int cell_count = 0; - unsigned int *head_w, *cell_w; + unsigned int *head_w, + *cell_w; #endif unsigned int i, @@ -240,38 +241,39 @@ print_aligned_text(const char *title, const char *const * headers, #ifdef MULTIBYTE head_w = calloc(col_count, sizeof(*head_w)); - if (!head_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!head_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } /* count rows */ - for (ptr = cells; *ptr; ptr++) { - cell_count++; - } + for (ptr = cells; *ptr; ptr++) + cell_count++; cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } #endif - + /* calc column widths */ - for (i = 0; i < col_count; i++) { - if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > widths[i]) { + for (i = 0; i < col_count; i++) + { + if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > widths[i]) widths[i] = tmp; - } #ifdef MULTIBYTE head_w[i] = tmp; #endif } - for (i = 0, ptr = cells; *ptr; ptr++, i++) { - if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > widths[i % col_count]) { + for (i = 0, ptr = cells; *ptr; ptr++, i++) + { + if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > widths[i % col_count]) widths[i % col_count] = tmp; - } #ifdef MULTIBYTE cell_w[i] = tmp; #endif @@ -287,14 +289,14 @@ print_aligned_text(const char *title, const char *const * headers, total_w += widths[i]; /* print title */ - if (title && !opt_barebones) { - int tlen; - if ((tlen = pg_wcswidth((unsigned char *)title, strlen(title))) >= total_w) { + if (title && !opt_barebones) + { + int tlen; + + if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w) fprintf(fout, "%s\n", title); - } - else { + else fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title); - } } /* print headers */ @@ -310,16 +312,17 @@ print_aligned_text(const char *title, const char *const * headers, for (i = 0; i < col_count; i++) { - int nbspace; + int nbspace; + #ifdef MULTIBYTE - nbspace = widths[i] - head_w[i]; + nbspace = widths[i] - head_w[i]; #else - nbspace = widths[i] - strlen(headers[i]); + nbspace = widths[i] - strlen(headers[i]); #endif /* centered */ - fprintf(fout, "%-*s%s%-*s", - nbspace / 2, "", headers[i], (nbspace+1) / 2, ""); + fprintf(fout, "%-*s%s%-*s", + nbspace / 2, "", headers[i], (nbspace + 1) / 2, ""); if (i < col_count - 1) { @@ -352,10 +355,11 @@ print_aligned_text(const char *title, const char *const * headers, } /* content */ - if (opt_align[(i) % col_count] == 'r') { + if (opt_align[(i) % col_count] == 'r') + { #ifdef MULTIBYTE - fprintf(fout, "%*s%s", - widths[i % col_count] - cell_w[i], "", cells[i] ); + fprintf(fout, "%*s%s", + widths[i % col_count] - cell_w[i], "", cells[i]); #else fprintf(fout, "%*s", widths[i % col_count], cells[i]); #endif @@ -364,10 +368,11 @@ print_aligned_text(const char *title, const char *const * headers, { if ((i + 1) % col_count == 0 && opt_border != 2) fputs(cells[i], fout); - else { + else + { #ifdef MULTIBYTE - fprintf(fout, "%-s%*s", cells[i], - widths[i % col_count] - cell_w[i], "" ); + fprintf(fout, "%-s%*s", cells[i], + widths[i % col_count] - cell_w[i], ""); #else fprintf(fout, "%-*s", widths[i % col_count], cells[i]); #endif @@ -425,9 +430,11 @@ print_aligned_vertical(const char *title, const char *const * headers, hwidth = 0, dwidth = 0; char *divider; + #ifdef MULTIBYTE unsigned int cell_count = 0; - unsigned int *cell_w,*head_w; + unsigned int *cell_w, + *head_w; #endif if (cells[0] == NULL) @@ -438,36 +445,36 @@ print_aligned_vertical(const char *title, const char *const * headers, #ifdef MULTIBYTE /* pre-count headers */ - for (ptr = headers; *ptr; ptr++) { - col_count++; - } + for (ptr = headers; *ptr; ptr++) + col_count++; head_w = calloc(col_count, sizeof(*head_w)); - if (!head_w) { - perror("calloc"); - exit(EXIT_FAILURE); + if (!head_w) + { + perror("calloc"); + exit(EXIT_FAILURE); } for (i = 0; i < col_count; i++) { - if ((tmp = pg_wcswidth((unsigned char *)headers[i], strlen(headers[i]))) > hwidth) + if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > hwidth) hwidth = tmp; head_w[i] = tmp; } - for (ptr = cells; *ptr; ptr++) { - cell_count++; - } + for (ptr = cells; *ptr; ptr++) + cell_count++; cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) { - perror("calloc"); - exit(EXIT_FAILURE); - } + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); + } /* find longest data cell */ - for (i = 0, ptr = cells; *ptr; ptr++, i++) { - if ((tmp = pg_wcswidth((unsigned char *)*ptr, strlen(*ptr))) > dwidth) { + for (i = 0, ptr = cells; *ptr; ptr++, i++) + { + if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > dwidth) dwidth = tmp; - } - cell_w[i] = tmp; + cell_w[i] = tmp; } #else /* count columns and find longest header */ @@ -479,7 +486,8 @@ print_aligned_vertical(const char *title, const char *const * headers, } /* find longest data cell */ - for (ptr = cells; *ptr; ptr++) { + for (ptr = cells; *ptr; ptr++) + { if ((tmp = strlen(*ptr)) > dwidth) dwidth = tmp; } @@ -571,7 +579,8 @@ print_aligned_vertical(const char *title, const char *const * headers, if (opt_border < 2) fprintf(fout, "%s\n", *ptr); - else { + else + { #ifdef MULTIBYTE fprintf(fout, "%-s%*s |\n", *ptr, dwidth - cell_w[i], ""); #else @@ -1152,7 +1161,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout) exit(EXIT_FAILURE); } - for (i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) + { #ifdef MULTIBYTE headers[i] = mbvalidate(PQfname(result, i)); #else @@ -1173,7 +1183,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout) { if (PQgetisnull(result, i / nfields, i % nfields)) cells[i] = opt->nullPrint ? opt->nullPrint : ""; - else { + else + { #ifdef MULTIBYTE cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields)); #else diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h index 1cc3bcb6e2..d469149b69 100644 --- a/src/bin/psql/print.h +++ b/src/bin/psql/print.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.9 2001/05/12 19:44:46 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/print.h,v 1.10 2001/10/25 05:49:54 momjian Exp $ */ #ifndef PRINT_H #define PRINT_H @@ -12,11 +12,12 @@ enum printFormat { - PRINT_NOTHING = 0, /* to make sure someone initializes this */ - PRINT_UNALIGNED, - PRINT_ALIGNED, - PRINT_HTML, - PRINT_LATEX + PRINT_NOTHING = 0, /* to make sure someone + * initializes this */ + PRINT_UNALIGNED, + PRINT_ALIGNED, + PRINT_HTML, + PRINT_LATEX /* add your favourite output format here ... */ }; @@ -64,7 +65,7 @@ typedef struct _printQueryOpt char *title; /* override title */ char **footers; /* override footer (default is "(xx * rows)") */ - bool default_footer; /* print default footer if footers==NULL */ + bool default_footer; /* print default footer if footers==NULL */ } printQueryOpt; /* @@ -73,7 +74,6 @@ typedef struct _printQueryOpt * It calls the printTable above with all the things set straight. */ void -printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout); - + printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout); #endif /* PRINT_H */ diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 12818d8afa..f01a55b569 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.21 2001/08/24 19:59:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.22 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" #include "prompt.h" @@ -33,7 +33,7 @@ * * Defined interpolations are: * %M - database server "hostname.domainname", "[local]" for AF_UNIX - * sockets, "[local:/dir/name]" if not default + * sockets, "[local:/dir/name]" if not default * %m - like %M, but hostname only (before first dot), or always "[local]" * %> - database server port number * %n - database user name @@ -120,7 +120,7 @@ get_prompt(promptStatus_t status) case 'm': if (pset.db) { - const char * host = PQhost(pset.db); + const char *host = PQhost(pset.db); /* INET socket */ if (host && host[0] && host[0] != '/') @@ -134,7 +134,7 @@ get_prompt(promptStatus_t status) else { if (!host - || strcmp(host, DEFAULT_PGSOCKET_DIR)==0 + || strcmp(host, DEFAULT_PGSOCKET_DIR) == 0 || *p == 'm') strncpy(buf, "[local]", MAX_PROMPT_SIZE); else diff --git a/src/bin/psql/prompt.h b/src/bin/psql/prompt.h index 0c0c209ff3..4c2b0a693b 100644 --- a/src/bin/psql/prompt.h +++ b/src/bin/psql/prompt.h @@ -3,22 +3,21 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.8 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/prompt.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ #ifndef PROMPT_H #define PROMPT_H typedef enum _promptStatus { - PROMPT_READY, - PROMPT_CONTINUE, - PROMPT_COMMENT, - PROMPT_SINGLEQUOTE, - PROMPT_DOUBLEQUOTE, - PROMPT_PAREN, - PROMPT_COPY + PROMPT_READY, + PROMPT_CONTINUE, + PROMPT_COMMENT, + PROMPT_SINGLEQUOTE, + PROMPT_DOUBLEQUOTE, + PROMPT_PAREN, + PROMPT_COPY } promptStatus_t; char *get_prompt(promptStatus_t status); - #endif /* PROMPT_H */ diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index d5d306b158..1be01f445c 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.10 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.11 2001/10/25 05:49:54 momjian Exp $ */ #ifndef SETTINGS_H #define SETTINGS_H @@ -69,5 +69,4 @@ extern PsqlSettings pset; #define EXIT_BADCONN 2 #define EXIT_USER 3 - #endif diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index bd0dddcb36..75d04551c3 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.51 2001/06/30 17:26:12 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.52 2001/10/25 05:49:54 momjian Exp $ */ #include "postgres_fe.h" @@ -56,11 +56,11 @@ PsqlSettings pset; */ enum _actions { - ACT_NOTHING = 0, - ACT_SINGLE_SLASH, - ACT_LIST_DB, - ACT_SINGLE_QUERY, - ACT_FILE + ACT_NOTHING = 0, + ACT_SINGLE_SLASH, + ACT_LIST_DB, + ACT_SINGLE_QUERY, + ACT_FILE }; struct adhoc_opts @@ -87,7 +87,6 @@ static void #ifdef USE_SSL static void printSSLInfo(void); - #endif @@ -167,7 +166,6 @@ main(int argc, char *argv[]) if (options.username) { - /* * The \001 is a hack to support the deprecated -u option which * issues a username prompt. The recommended option is -U followed @@ -241,7 +239,7 @@ main(int argc, char *argv[]) /* * process file given by -f */ - if (options.action == ACT_FILE && strcmp(options.action_string, "-")!=0) + if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0) { if (!options.no_psqlrc) process_psqlrc(); @@ -286,8 +284,8 @@ main(int argc, char *argv[]) printf(gettext("Welcome to %s, the PostgreSQL interactive terminal.\n\n" "Type: \\copyright for distribution terms\n" " \\h for help with SQL commands\n" - " \\? for help on internal slash commands\n" - " \\g or terminate with semicolon to execute query\n" + " \\? for help on internal slash commands\n" + " \\g or terminate with semicolon to execute query\n" " \\q to quit\n\n"), pset.progname); #ifdef USE_SSL @@ -302,7 +300,7 @@ main(int argc, char *argv[]) process_psqlrc(); if (!pset.notty) initializeInput(options.no_readline ? 0 : 1); - if (options.action_string) /* -f - was used */ + if (options.action_string) /* -f - was used */ pset.inputfile = "<stdin>"; successResult = MainLoop(stdin); } @@ -326,7 +324,6 @@ int getopt(int, char *const[], const char *); /* And it requires progname to be set */ char *__progname = "psql"; - #endif static void @@ -367,7 +364,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) }; int optindex; - #endif /* HAVE_GETOPT_LONG */ extern char *optarg; @@ -554,7 +550,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) case '-': fprintf(stderr, gettext("%s was compiled without support for long options.\n" - "Use --help for help on invocation options.\n"), + "Use --help for help on invocation options.\n"), pset.progname); exit(EXIT_FAILURE); break; @@ -673,7 +669,7 @@ showVersion(void) puts(gettext("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n" "Portions Copyright (c) 1996, Regents of the University of California\n" - "Read the file COPYRIGHT or use the command \\copyright to see the\n" + "Read the file COPYRIGHT or use the command \\copyright to see the\n" "usage and distribution terms.")); } @@ -699,5 +695,4 @@ printSSLInfo(void) printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"), SSL_get_cipher(ssl), sslbits); } - #endif diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h index 4201fd5300..2d7bdaa86b 100644 --- a/src/bin/psql/stringutils.h +++ b/src/bin/psql/stringutils.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.14 2000/02/07 23:10:07 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.h,v 1.15 2001/10/25 05:49:54 momjian Exp $ */ #ifndef STRINGUTILS_H #define STRINGUTILS_H @@ -17,5 +17,4 @@ extern char *strtokx(const char *s, char *was_quoted, unsigned int *token_pos, int encoding); - #endif /* STRINGUTILS_H */ diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index c76d9c807a..500ded13fe 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.38 2001/09/21 03:32:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.39 2001/10/25 05:49:54 momjian Exp $ */ /*---------------------------------------------------------------------- @@ -106,7 +106,7 @@ void initialize_readline(void) { rl_readline_name = pset.progname; - rl_attempted_completion_function = (void *)psql_completion; + rl_attempted_completion_function = (void *) psql_completion; rl_basic_word_break_characters = "\t\n@$><=;|&{( "; @@ -584,7 +584,11 @@ psql_completion(char *text, int start, int end) /* Complete INSERT INTO with table names */ else if (strcasecmp(prev2_wd, "INSERT") == 0 && strcasecmp(prev_wd, "INTO") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_tables); - /* Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT VALUES" */ + + /* + * Complete INSERT INTO <table> with "VALUES" or "SELECT" or "DEFAULT + * VALUES" + */ else if (strcasecmp(prev3_wd, "INSERT") == 0 && strcasecmp(prev2_wd, "INTO") == 0) { char *list_INSERT[] = {"DEFAULT VALUES", "SELECT", "VALUES", NULL}; @@ -662,19 +666,17 @@ psql_completion(char *text, int start, int end) /* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */ else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev_wd, "SESSION") == 0) { - char *my_list[] = {"AUTHORIZATION", - "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL", - NULL}; + char *my_list[] = {"AUTHORIZATION", + "CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL", + NULL}; COMPLETE_WITH_LIST(my_list); } /* Complete SET SESSION AUTHORIZATION with username */ - else if (strcasecmp(prev3_wd, "SET") == 0 + else if (strcasecmp(prev3_wd, "SET") == 0 && strcasecmp(prev2_wd, "SESSION") == 0 && strcasecmp(prev_wd, "AUTHORIZATION") == 0) - { COMPLETE_WITH_QUERY(Query_for_list_of_users); - } /* Complete SET <var> with "TO" */ else if (strcasecmp(prev2_wd, "SET") == 0 && strcasecmp(prev4_wd, "UPDATE") != 0) @@ -755,12 +757,12 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(my_list); } else if (strcmp(prev_wd, "\\cd") == 0 || - strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || + strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || strcmp(prev_wd, "\\g") == 0 || strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 || - strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || + strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || strcmp(prev_wd, "\\s") == 0 || - strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 + strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 ) matches = completion_matches(text, filename_completion_function); @@ -1110,7 +1112,5 @@ dequote_file_name(char *text, char quote_char) return s; } - #endif /* 0 */ - #endif /* USE_READLINE */ diff --git a/src/bin/psql/tab-complete.h b/src/bin/psql/tab-complete.h index 81182eae53..7200fd6feb 100644 --- a/src/bin/psql/tab-complete.h +++ b/src/bin/psql/tab-complete.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.6 2001/02/10 02:31:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.7 2001/10/25 05:49:54 momjian Exp $ */ #ifndef TAB_COMPLETE_H #define TAB_COMPLETE_H @@ -11,5 +11,4 @@ #include "postgres_fe.h" void initialize_readline(void); - #endif diff --git a/src/bin/psql/variables.h b/src/bin/psql/variables.h index 0814d71a9a..8e96966f8e 100644 --- a/src/bin/psql/variables.h +++ b/src/bin/psql/variables.h @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.8 2000/04/12 17:16:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ */ /* @@ -36,5 +36,4 @@ bool SetVariableBool(VariableSpace space, const char *name); bool DeleteVariable(VariableSpace space, const char *name); void DestroyVariableSpace(VariableSpace space); - #endif /* VARIABLES_H */ diff --git a/src/include/access/attnum.h b/src/include/access/attnum.h index babfa0b20e..2339c29030 100644 --- a/src/include/access/attnum.h +++ b/src/include/access/attnum.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: attnum.h,v 1.12 2001/01/24 19:43:19 momjian Exp $ + * $Id: attnum.h,v 1.13 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,5 +59,4 @@ typedef int16 AttrNumber; */ #define AttrOffsetGetAttrNumber(attributeOffset) \ ((AttrNumber) (1 + attributeOffset)) - #endif /* ATTNUM_H */ diff --git a/src/include/access/clog.h b/src/include/access/clog.h index 9bcd3a4294..60589e8bfc 100644 --- a/src/include/access/clog.h +++ b/src/include/access/clog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: clog.h,v 1.2 2001/09/29 04:02:26 tgl Exp $ + * $Id: clog.h,v 1.3 2001/10/25 05:49:55 momjian Exp $ */ #ifndef CLOG_H #define CLOG_H @@ -46,5 +46,4 @@ extern void TruncateCLOG(TransactionId oldestXact); extern void clog_redo(XLogRecPtr lsn, XLogRecord *record); extern void clog_undo(XLogRecPtr lsn, XLogRecord *record); extern void clog_desc(char *buf, uint8 xl_info, char *rec); - #endif /* CLOG_H */ diff --git a/src/include/access/genam.h b/src/include/access/genam.h index 0a70691e77..633fb21dfa 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: genam.h,v 1.27 2001/10/06 23:21:44 tgl Exp $ + * $Id: genam.h,v 1.28 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,9 +22,9 @@ /* Struct for statistics returned by bulk-delete operation */ typedef struct IndexBulkDeleteResult { - BlockNumber num_pages; /* pages remaining in index */ - double tuples_removed; /* # removed by bulk-delete operation */ - double num_index_tuples; /* # remaining */ + BlockNumber num_pages; /* pages remaining in index */ + double tuples_removed; /* # removed by bulk-delete operation */ + double num_index_tuples; /* # remaining */ } IndexBulkDeleteResult; /* Typedef for callback function to determine if a tuple is bulk-deletable */ @@ -51,17 +51,16 @@ extern void index_restrpos(IndexScanDesc scan); extern RetrieveIndexResult index_getnext(IndexScanDesc scan, ScanDirection direction); extern IndexBulkDeleteResult *index_bulk_delete(Relation relation, - IndexBulkDeleteCallback callback, - void *callback_state); + IndexBulkDeleteCallback callback, + void *callback_state); extern RegProcedure index_cost_estimator(Relation relation); extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum); extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum, - uint16 procnum); + uint16 procnum); /* in genam.c */ extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd, uint16 numberOfKeys, ScanKey key); extern void IndexScanEnd(IndexScanDesc scan); - #endif /* GENAM_H */ diff --git a/src/include/access/gist.h b/src/include/access/gist.h index d6bce8d845..e7cff61ee8 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: gist.h,v 1.32 2001/08/22 18:24:26 tgl Exp $ + * $Id: gist.h,v 1.33 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -123,20 +123,22 @@ typedef struct GIST_SPLITVEC OffsetNumber *spl_left; /* array of entries that go left */ int spl_nleft; /* size of this array */ Datum spl_ldatum; /* Union of keys in spl_left */ - Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_left */ - int spl_lattrsize[INDEX_MAX_KEYS]; - bool spl_lisnull[INDEX_MAX_KEYS]; + Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in + * spl_left */ + int spl_lattrsize[INDEX_MAX_KEYS]; + bool spl_lisnull[INDEX_MAX_KEYS]; OffsetNumber *spl_right; /* array of entries that go right */ int spl_nright; /* size of the array */ Datum spl_rdatum; /* Union of keys in spl_right */ - Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_right */ - int spl_rattrsize[INDEX_MAX_KEYS]; - bool spl_risnull[INDEX_MAX_KEYS]; - - int *spl_idgrp; - int *spl_ngrp; /* number in each group */ - char *spl_grpflag; /* flags of each group */ + Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in + * spl_right */ + int spl_rattrsize[INDEX_MAX_KEYS]; + bool spl_risnull[INDEX_MAX_KEYS]; + + int *spl_idgrp; + int *spl_ngrp; /* number in each group */ + char *spl_grpflag; /* flags of each group */ } GIST_SPLITVEC; /* @@ -171,10 +173,10 @@ extern void gistfreestack(GISTSTACK *s); extern void initGISTstate(GISTSTATE *giststate, Relation index); extern void freeGISTstate(GISTSTATE *giststate); extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, - Datum k, Relation r, Page pg, OffsetNumber o, - int b, bool l, bool isNull); + Datum k, Relation r, Page pg, OffsetNumber o, + int b, bool l, bool isNull); extern StrategyNumber RelationGetGISTStrategy(Relation, AttrNumber, - RegProcedure); + RegProcedure); extern void gist_redo(XLogRecPtr lsn, XLogRecord *record); extern void gist_undo(XLogRecPtr lsn, XLogRecord *record); @@ -182,5 +184,4 @@ extern void gist_desc(char *buf, uint8 xl_info, char *rec); /* gistget.c */ extern Datum gistgettuple(PG_FUNCTION_ARGS); - #endif /* GIST_H */ diff --git a/src/include/access/gistscan.h b/src/include/access/gistscan.h index f7955bce9e..ade886b077 100644 --- a/src/include/access/gistscan.h +++ b/src/include/access/gistscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: gistscan.h,v 1.16 2001/07/15 22:48:18 tgl Exp $ + * $Id: gistscan.h,v 1.17 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern Datum gistrestrpos(PG_FUNCTION_ARGS); extern Datum gistendscan(PG_FUNCTION_ARGS); extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); extern void AtEOXact_gist(void); - #endif /* GISTSCAN_H */ diff --git a/src/include/access/hash.h b/src/include/access/hash.h index e973b81a7c..11950f5664 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hash.h,v 1.39 2001/07/15 22:48:18 tgl Exp $ + * $Id: hash.h,v 1.40 2001/10/25 05:49:55 momjian Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -81,8 +81,8 @@ typedef struct HashPageOpaqueData bits16 hasho_flag; /* is this page a bucket or ovfl */ Bucket hasho_bucket; /* bucket number this pg belongs to */ OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */ - BlockNumber hasho_nextblkno;/* next ovfl blkno */ - BlockNumber hasho_prevblkno;/* previous ovfl (or bucket) blkno */ + BlockNumber hasho_nextblkno; /* next ovfl blkno */ + BlockNumber hasho_prevblkno; /* previous ovfl (or bucket) blkno */ } HashPageOpaqueData; typedef HashPageOpaqueData *HashPageOpaque; @@ -150,12 +150,12 @@ typedef struct HashMetaPageData uint16 hashm_bshift; /* bucket shift */ uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a * power of 2 */ - uint32 hashm_maxbucket;/* ID of maximum bucket in use */ + uint32 hashm_maxbucket; /* ID of maximum bucket in use */ uint32 hashm_highmask; /* mask to modulo into entire table */ uint32 hashm_lowmask; /* mask to modulo into lower half of table */ uint32 hashm_ovflpoint;/* pageno. from which ovflpgs being * allocated */ - uint32 hashm_lastfreed;/* last ovflpage freed */ + uint32 hashm_lastfreed; /* last ovflpage freed */ uint32 hashm_nmaps; /* Initial number of bitmaps */ uint32 hashm_spares[NCACHED]; /* spare pages available at * splitpoints */ @@ -327,5 +327,4 @@ extern void _hash_checkpage(Page page, int flags); extern void hash_redo(XLogRecPtr lsn, XLogRecord *record); extern void hash_undo(XLogRecPtr lsn, XLogRecord *record); extern void hash_desc(char *buf, uint8 xl_info, char *rec); - #endif /* HASH_H */ diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 095476083b..ae51658305 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: heapam.h,v 1.68 2001/09/17 00:29:10 tgl Exp $ + * $Id: heapam.h,v 1.69 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -141,7 +141,6 @@ extern Datum nocachegetattr(HeapTuple tup, int attnum, extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull); - #endif /* defined(DISABLE_COMPLEX_MACRO) */ @@ -221,10 +220,10 @@ extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr); extern void heap_undo(XLogRecPtr lsn, XLogRecord *rptr); extern void heap_desc(char *buf, uint8 xl_info, char *rec); extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer, - char *unused, int unlen); + char *unused, int unlen); extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, - ItemPointerData from, - Buffer newbuf, HeapTuple newtup); + ItemPointerData from, + Buffer newbuf, HeapTuple newtup); /* in common/heaptuple.c */ extern Size ComputeDataSize(TupleDesc tupleDesc, Datum *value, char *nulls); @@ -246,5 +245,4 @@ extern HeapTuple heap_addheader(int natts, Size structlen, void *structure); /* in common/heap/stats.c */ extern void PrintHeapAccessStatistics(HeapAccessStatistics stats); extern void initam(void); - #endif /* HEAPAM_H */ diff --git a/src/include/access/hio.h b/src/include/access/hio.h index da4114c0d0..c6a5eac0e7 100644 --- a/src/include/access/hio.h +++ b/src/include/access/hio.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hio.h,v 1.19 2001/06/29 21:08:25 tgl Exp $ + * $Id: hio.h,v 1.20 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,6 +19,5 @@ extern void RelationPutHeapTuple(Relation relation, Buffer buffer, HeapTuple tuple); extern Buffer RelationGetBufferForTuple(Relation relation, Size len, - Buffer otherBuffer); - + Buffer otherBuffer); #endif /* HIO_H */ diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 8de6fa852f..257b9d8a4a 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: htup.h,v 1.48 2001/03/25 22:40:58 tgl Exp $ + * $Id: htup.h,v 1.49 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -275,5 +275,4 @@ typedef HeapTupleData *HeapTuple; #define HeapTupleHasExtended(tuple) \ ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0) - #endif /* HTUP_H */ diff --git a/src/include/access/ibit.h b/src/include/access/ibit.h index 15b45a8b12..b724bfaa5e 100644 --- a/src/include/access/ibit.h +++ b/src/include/access/ibit.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: ibit.h,v 1.15 2001/01/24 19:43:19 momjian Exp $ + * $Id: ibit.h,v 1.16 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,5 +28,4 @@ typedef IndexAttributeBitMapData *IndexAttributeBitMap; * True iff attribute bit map is valid. */ #define IndexAttributeBitMapIsValid(bits) PointerIsValid(bits) - #endif /* IBIT_H */ diff --git a/src/include/access/iqual.h b/src/include/access/iqual.h index 4a3768a7d3..514bec3844 100644 --- a/src/include/access/iqual.h +++ b/src/include/access/iqual.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: iqual.h,v 1.15 2001/01/24 19:43:19 momjian Exp $ + * $Id: iqual.h,v 1.16 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ extern int NIndexTupleProcessed; extern bool index_keytest(IndexTuple tuple, TupleDesc tupdesc, int scanKeySize, ScanKey key); - #endif /* IQUAL_H */ diff --git a/src/include/access/istrat.h b/src/include/access/istrat.h index bb12a5eafb..6f94b8ccc6 100644 --- a/src/include/access/istrat.h +++ b/src/include/access/istrat.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: istrat.h,v 1.20 2001/03/22 04:00:28 momjian Exp $ + * $Id: istrat.h,v 1.21 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,5 +63,4 @@ extern void IndexSupportInitialize(IndexStrategy indexStrategy, StrategyNumber maxStrategyNumber, StrategyNumber maxSupportNumber, AttrNumber maxAttributeNumber); - #endif /* ISTRAT_H */ diff --git a/src/include/access/itup.h b/src/include/access/itup.h index bf31c9e2a8..4e7835df80 100644 --- a/src/include/access/itup.h +++ b/src/include/access/itup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: itup.h,v 1.31 2001/03/22 04:00:29 momjian Exp $ + * $Id: itup.h,v 1.32 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -151,5 +151,4 @@ extern RetrieveIndexResult FormRetrieveIndexResult(ItemPointer indexItemPointer, ItemPointer heapItemPointer); extern void CopyIndexTuple(IndexTuple source, IndexTuple *target); - #endif /* ITUP_H */ diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index 789dd02742..b0e1dd305d 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nbtree.h,v 1.56 2001/07/15 22:48:18 tgl Exp $ + * $Id: nbtree.h,v 1.57 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -398,5 +398,4 @@ extern BTSpool *_bt_spoolinit(Relation index, bool isunique); extern void _bt_spooldestroy(BTSpool *btspool); extern void _bt_spool(BTItem btitem, BTSpool *btspool); extern void _bt_leafbuild(BTSpool *btspool, BTSpool *spool2); - #endif /* NBTREE_H */ diff --git a/src/include/access/printtup.h b/src/include/access/printtup.h index eab2fd3db1..0f1dbed15b 100644 --- a/src/include/access/printtup.h +++ b/src/include/access/printtup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: printtup.h,v 1.15 2001/03/22 04:00:29 momjian Exp $ + * $Id: printtup.h,v 1.16 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,5 +28,4 @@ extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc, extern bool getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, bool *typIsVarlena); - #endif /* PRINTTUP_H */ diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 907ecee230..87e1b36c3f 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: relscan.h,v 1.22 2001/06/22 19:16:23 wieck Exp $ + * $Id: relscan.h,v 1.23 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ typedef struct HeapScanDescData uint16 rs_nkeys; /* number of scan keys to select tuples */ ScanKey rs_key; /* key descriptors */ - PgStat_Info rs_pgstat_info; /* statistics collector hook */ + PgStat_Info rs_pgstat_info; /* statistics collector hook */ } HeapScanDescData; typedef HeapScanDescData *HeapScanDesc; @@ -38,14 +38,14 @@ typedef struct IndexScanDescData Relation relation; /* relation descriptor */ void *opaque; /* access-method-specific info */ ItemPointerData currentItemData; /* current index pointer */ - ItemPointerData currentMarkData; /* marked current pointer */ + ItemPointerData currentMarkData; /* marked current pointer */ uint8 flags; /* scan position flags */ bool scanFromEnd; /* restart scan at end? */ uint16 numberOfKeys; /* number of scan keys to select tuples */ ScanKey keyData; /* key descriptors */ FmgrInfo fn_getnext; /* cached lookup info for am's getnext fn */ - PgStat_Info xs_pgstat_info; /* statistics collector hook */ + PgStat_Info xs_pgstat_info; /* statistics collector hook */ } IndexScanDescData; typedef IndexScanDescData *IndexScanDesc; @@ -75,5 +75,4 @@ typedef IndexScanDesc *IndexScanDescPtr; * True iff the index scan is valid. */ #define IndexScanIsValid(scan) PointerIsValid(scan) - #endif /* RELSCAN_H */ diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h index b658422fd2..106370858d 100644 --- a/src/include/access/rmgr.h +++ b/src/include/access/rmgr.h @@ -3,7 +3,7 @@ * * Resource managers definition * - * $Id: rmgr.h,v 1.6 2001/08/25 18:52:42 tgl Exp $ + * $Id: rmgr.h,v 1.7 2001/10/25 05:49:55 momjian Exp $ */ #ifndef RMGR_H #define RMGR_H @@ -24,5 +24,4 @@ typedef uint8 RmgrId; #define RM_GIST_ID 14 #define RM_SEQ_ID 15 #define RM_MAX_ID RM_SEQ_ID - #endif /* RMGR_H */ diff --git a/src/include/access/rtree.h b/src/include/access/rtree.h index 237937fe46..b9737ceeec 100644 --- a/src/include/access/rtree.h +++ b/src/include/access/rtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rtree.h,v 1.24 2001/07/15 22:48:18 tgl Exp $ + * $Id: rtree.h,v 1.25 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -134,5 +134,4 @@ extern void AtEOXact_rtree(void); /* rtstrat.c */ extern RegProcedure RTMapOperator(Relation r, AttrNumber attnum, RegProcedure proc); - #endif /* RTREE_H */ diff --git a/src/include/access/rtscan.h b/src/include/access/rtscan.h index efdf44f072..5cfba8e08f 100644 --- a/src/include/access/rtscan.h +++ b/src/include/access/rtscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rtscan.h,v 1.10 2001/01/24 19:43:19 momjian Exp $ + * $Id: rtscan.h,v 1.11 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,5 +19,4 @@ #include "utils/rel.h" void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); - #endif /* RTSCAN_H */ diff --git a/src/include/access/sdir.h b/src/include/access/sdir.h index a9229c89c3..3caa8b3ae4 100644 --- a/src/include/access/sdir.h +++ b/src/include/access/sdir.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sdir.h,v 1.9 2001/01/24 19:43:19 momjian Exp $ + * $Id: sdir.h,v 1.10 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,9 +21,9 @@ */ typedef enum ScanDirection { - BackwardScanDirection = -1, - NoMovementScanDirection = 0, - ForwardScanDirection = 1 + BackwardScanDirection = -1, + NoMovementScanDirection = 0, + ForwardScanDirection = 1 } ScanDirection; /* @@ -54,5 +54,4 @@ typedef enum ScanDirection */ #define ScanDirectionIsForward(direction) \ ((bool) ((direction) == ForwardScanDirection)) - #endif /* SDIR_H */ diff --git a/src/include/access/skey.h b/src/include/access/skey.h index 304d5e4a46..45061e38ff 100644 --- a/src/include/access/skey.h +++ b/src/include/access/skey.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: skey.h,v 1.17 2001/10/06 23:21:44 tgl Exp $ + * $Id: skey.h,v 1.18 2001/10/25 05:49:55 momjian Exp $ * * Note: * Needs more accessor/assignment routines. @@ -45,7 +45,6 @@ extern void ScanKeyEntrySetIllegal(ScanKey entry); extern void ScanKeyEntryInitialize(ScanKey entry, bits16 flags, AttrNumber attributeNumber, RegProcedure procedure, Datum argument); extern void ScanKeyEntryInitializeWithInfo(ScanKey entry, bits16 flags, - AttrNumber attributeNumber, FmgrInfo *finfo, - MemoryContext mcxt, Datum argument); - + AttrNumber attributeNumber, FmgrInfo *finfo, + MemoryContext mcxt, Datum argument); #endif /* SKEY_H */ diff --git a/src/include/access/strat.h b/src/include/access/strat.h index ffe63926cf..7c376ac37c 100644 --- a/src/include/access/strat.h +++ b/src/include/access/strat.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: strat.h,v 1.22 2001/05/30 19:53:39 tgl Exp $ + * $Id: strat.h,v 1.23 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ typedef StrategyOperatorData *StrategyOperator; typedef struct StrategyTermData { /* conjunctive term */ uint16 degree; - StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH ARRAY */ + StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH ARRAY */ } StrategyTermData; /* VARIABLE LENGTH STRUCTURE */ typedef StrategyTermData *StrategyTerm; @@ -86,5 +86,4 @@ typedef struct IndexStrategyData } IndexStrategyData; /* VARIABLE LENGTH STRUCTURE */ typedef IndexStrategyData *IndexStrategy; - #endif /* STRAT_H */ diff --git a/src/include/access/transam.h b/src/include/access/transam.h index e6fda69691..e8fc34fd90 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: transam.h,v 1.41 2001/09/29 04:02:26 tgl Exp $ + * $Id: transam.h,v 1.42 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ #define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId) #define TransactionIdEquals(id1, id2) ((id1) == (id2)) #define TransactionIdStore(xid, dest) (*(dest) = (xid)) -#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId) +#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId) /* advance a transaction ID variable, handling wraparound correctly */ #define TransactionIdAdvance(dest) \ do { \ @@ -58,7 +58,7 @@ * OIDS 10000-16383 are reserved for assignment by genbki.sh. * * OIDs beginning at 16384 are assigned at runtime from the OID - * generator. (The first few of these will be assigned during initdb, + * generator. (The first few of these will be assigned during initdb, * to objects created after the initial BKI script processing.) * * The choices of 10000 and 16384 are completely arbitrary, and can be moved @@ -121,5 +121,4 @@ extern bool AMI_OVERRIDE; /* in varsup.c */ extern VariableCache ShmemVariableCache; - #endif /* TRAMSAM_H */ diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h index 644fe201f9..afb96c37a3 100644 --- a/src/include/access/tupdesc.h +++ b/src/include/access/tupdesc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tupdesc.h,v 1.30 2001/01/24 19:43:20 momjian Exp $ + * $Id: tupdesc.h,v 1.31 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,5 +74,4 @@ extern bool TupleDescInitEntry(TupleDesc desc, bool attisset); extern TupleDesc BuildDescForRelation(List *schema, char *relname); - #endif /* TUPDESC_H */ diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h index f1bf680f31..97fb618ce1 100644 --- a/src/include/access/tupmacs.h +++ b/src/include/access/tupmacs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tupmacs.h,v 1.17 2001/03/22 04:00:31 momjian Exp $ + * $Id: tupmacs.h,v 1.18 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,7 +90,6 @@ : \ PointerGetDatum((char *) (T)) \ ) - #endif /* SIZEOF_DATUM == 8 */ /* @@ -179,7 +178,5 @@ break; \ } \ } while (0) - #endif /* SIZEOF_DATUM == 8 */ - #endif diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h index 6e38529204..99ea8d5998 100644 --- a/src/include/access/tuptoaster.h +++ b/src/include/access/tuptoaster.h @@ -6,7 +6,7 @@ * * Copyright (c) 2000, PostgreSQL Development Team * - * $Id: tuptoaster.h,v 1.11 2001/05/07 00:43:24 tgl Exp $ + * $Id: tuptoaster.h,v 1.12 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,5 +115,4 @@ extern Datum toast_compress_datum(Datum value); */ extern Size toast_raw_datum_size(Datum value); - #endif /* TUPTOASTER_H */ diff --git a/src/include/access/valid.h b/src/include/access/valid.h index d1e7f14173..d1e32602a3 100644 --- a/src/include/access/valid.h +++ b/src/include/access/valid.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: valid.h,v 1.23 2001/01/24 19:43:20 momjian Exp $ + * $Id: valid.h,v 1.24 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -130,5 +130,4 @@ do \ (tuple)->t_data = NULL; \ } \ } while (0) - #endif /* VALID_H */ diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 557e0768c3..f85e21eee4 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xact.h,v 1.38 2001/10/18 17:30:15 thomas Exp $ + * $Id: xact.h,v 1.39 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -134,5 +134,4 @@ extern Datum xidin(PG_FUNCTION_ARGS); extern Datum xidout(PG_FUNCTION_ARGS); extern Datum xideq(PG_FUNCTION_ARGS); extern Datum xid_age(PG_FUNCTION_ARGS); - #endif /* XACT_H */ diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index dd5f0284a1..04bb18b2e5 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xlog.h,v 1.25 2001/08/25 18:52:42 tgl Exp $ + * $Id: xlog.h,v 1.26 2001/10/25 05:49:56 momjian Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -103,7 +103,7 @@ typedef struct XLogContRecord /* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */ -} XLogContRecord; +} XLogContRecord; #define SizeOfXLogContRecord MAXALIGN(sizeof(XLogContRecord)) @@ -215,5 +215,4 @@ extern XLogRecPtr GetUndoRecPtr(void); extern bool check_xlog_sync_method(const char *method); extern void assign_xlog_sync_method(const char *method); - #endif /* XLOG_H */ diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index 916474bd97..c2d1f2168e 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xlogdefs.h,v 1.4 2001/08/25 18:52:42 tgl Exp $ + * $Id: xlogdefs.h,v 1.5 2001/10/25 05:49:56 momjian Exp $ */ #ifndef XLOG_DEFS_H #define XLOG_DEFS_H @@ -55,5 +55,4 @@ typedef struct XLogRecPtr * pg_clog after shutdown, in future. */ typedef uint32 StartUpID; - #endif /* XLOG_DEFS_H */ diff --git a/src/include/access/xlogutils.h b/src/include/access/xlogutils.h index b427c83649..b49bcbe134 100644 --- a/src/include/access/xlogutils.h +++ b/src/include/access/xlogutils.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xlogutils.h,v 1.8 2001/08/25 18:52:42 tgl Exp $ + * $Id: xlogutils.h,v 1.9 2001/10/25 05:49:56 momjian Exp $ */ #ifndef XLOG_UTILS_H #define XLOG_UTILS_H @@ -25,5 +25,4 @@ extern void XLogCloseRelationCache(void); extern Relation XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode); extern Buffer XLogReadBuffer(bool extend, Relation reln, BlockNumber blkno); - #endif diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h index 25f3a23d87..0388e9ecda 100644 --- a/src/include/bootstrap/bootstrap.h +++ b/src/include/bootstrap/bootstrap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bootstrap.h,v 1.23 2001/08/10 18:57:39 tgl Exp $ + * $Id: bootstrap.h,v 1.24 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,5 +62,4 @@ extern void Int_yyerror(const char *str); #define BS_XLOG_STARTUP 2 #define BS_XLOG_CHECKPOINT 3 #define BS_XLOG_SHUTDOWN 4 - #endif /* BOOTSTRAP_H */ diff --git a/src/include/c.h b/src/include/c.h index 58b36b83ca..0d129180a5 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.105 2001/10/24 21:49:14 petere Exp $ + * $Id: c.h,v 1.106 2001/10/25 05:49:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,6 @@ */ #define _priv_CppIdentity(x)x #define CppConcat(x, y) _priv_CppIdentity(x)y - #endif /* !HAVE_STRINGIZE */ /* @@ -163,9 +162,7 @@ typedef char bool; #ifndef false #define false ((bool) 0) #endif - #endif /* not C++ */ - #endif /* __BEOS__ */ typedef bool *BoolPtr; @@ -211,7 +208,6 @@ typedef char *Pointer; typedef signed char int8; /* == 8 bits */ typedef signed short int16; /* == 16 bits */ typedef signed int int32; /* == 32 bits */ - #endif /* __BEOS__ */ /* @@ -224,7 +220,6 @@ typedef signed int int32; /* == 32 bits */ typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ - #endif /* __BEOS__ */ /* @@ -616,7 +611,7 @@ typedef NameData *Name; #else /* not BUILDING_DLL */ #define DLLIMPORT __declspec (dllimport) #endif -#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ +#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ #if defined(_DLL) #define DLLIMPORT __declspec (dllexport) #else /* not _DLL */ @@ -632,7 +627,8 @@ typedef NameData *Name; */ #ifndef HAVE_SNPRINTF_DECL -extern int snprintf(char *str, size_t count, const char *fmt, ...) +extern int +snprintf(char *str, size_t count, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 3, 4))); #endif diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h index f7c970bf37..30ae2bbd2e 100644 --- a/src/include/catalog/catalog.h +++ b/src/include/catalog/catalog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catalog.h,v 1.17 2001/05/30 20:52:34 momjian Exp $ + * $Id: catalog.h,v 1.18 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,5 +25,4 @@ extern bool IsSystemRelationName(const char *relname); extern bool IsSharedSystemRelationName(const char *relname); extern Oid newoid(void); - #endif /* CATALOG_H */ diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h index 804c672b28..a00d6fd950 100644 --- a/src/include/catalog/catname.h +++ b/src/include/catalog/catname.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catname.h,v 1.20 2001/08/25 18:52:42 tgl Exp $ + * $Id: catname.h,v 1.21 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,5 +43,4 @@ #define TriggerRelationName "pg_trigger" extern char *SharedSystemRelationNames[]; - #endif /* CATNAME_H */ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 92eb1961fd..c51934dac0 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.99 2001/10/18 17:30:15 thomas Exp $ + * $Id: catversion.h,v 1.100 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,5 +54,4 @@ /* yyyymmddN */ #define CATALOG_VERSION_NO 200110181 - #endif diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 8d7346fa05..e849ae28d6 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: heap.h,v 1.38 2001/10/22 22:47:57 tgl Exp $ + * $Id: heap.h,v 1.39 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,12 +45,11 @@ extern void AddRelationRawConstraints(Relation rel, List *rawColDefaults, List *rawConstraints); -extern int RemoveCheckConstraint(Relation rel, const char *constrName, bool inh); +extern int RemoveCheckConstraint(Relation rel, const char *constrName, bool inh); extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno, - bool relhasoids); + bool relhasoids); extern Form_pg_attribute SystemAttributeByName(const char *attname, - bool relhasoids); - + bool relhasoids); #endif /* HEAP_H */ diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 52956f807b..82f30ea4c3 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: index.h,v 1.40 2001/10/06 23:21:44 tgl Exp $ + * $Id: index.h,v 1.41 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,11 +20,11 @@ /* Typedef for callback function for IndexBuildHeapScan */ typedef void (*IndexBuildCallback) (Relation index, - HeapTuple htup, - Datum *attdata, - char *nulls, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *attdata, + char *nulls, + bool tupleIsAlive, + void *state); extern Form_pg_am AccessMethodObjectIdGetForm(Oid accessMethodObjectId, @@ -52,7 +52,7 @@ extern void FormIndexDatum(IndexInfo *indexInfo, extern void UpdateStats(Oid relid, double reltuples); extern bool IndexesAreActive(Oid relid, bool comfirmCommitted); extern void setRelhasindex(Oid relid, bool hasindex, - bool isprimary, Oid reltoastidxid); + bool isprimary, Oid reltoastidxid); extern void setNewRelfilenode(Relation relation); @@ -60,16 +60,15 @@ extern bool SetReindexProcessing(bool processing); extern bool IsReindexProcessing(void); extern void index_build(Relation heapRelation, Relation indexRelation, - IndexInfo *indexInfo); + IndexInfo *indexInfo); extern double IndexBuildHeapScan(Relation heapRelation, - Relation indexRelation, - IndexInfo *indexInfo, - IndexBuildCallback callback, - void *callback_state); + Relation indexRelation, + IndexInfo *indexInfo, + IndexBuildCallback callback, + void *callback_state); extern bool reindex_index(Oid indexId, bool force, bool inplace); extern bool activate_indexes_of_a_table(Oid relid, bool activate); extern bool reindex_relation(Oid relid, bool force); - #endif /* INDEX_H */ diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 0e14819db8..11d56f5d9f 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: indexing.h,v 1.53 2001/08/21 16:36:05 tgl Exp $ + * $Id: indexing.h,v 1.54 2001/10/25 05:49:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -196,5 +196,4 @@ DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_o /* last step of initialization script: build the indices declared above */ BUILD_INDICES - #endif /* INDEXING_H */ diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index cc0edd22fc..5aa5dc3c37 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_aggregate.h,v 1.32 2001/09/28 08:09:13 thomas Exp $ + * $Id: pg_aggregate.h,v 1.33 2001/10/25 05:49:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -90,8 +90,8 @@ DATA(insert OID = 0 ( avg PGUID float8_accum float8_avg 701 1022 701 "{0,0,0}" DATA(insert OID = 0 ( avg PGUID interval_accum interval_avg 1186 1187 1186 "{0 second,0 second}" )); DATA(insert OID = 0 ( sum PGUID int8_sum - 20 1700 1700 _null_ )); -DATA(insert OID = 0 ( sum PGUID int4_sum - 23 20 20 _null_ )); -DATA(insert OID = 0 ( sum PGUID int2_sum - 21 20 20 _null_ )); +DATA(insert OID = 0 ( sum PGUID int4_sum - 23 20 20 _null_ )); +DATA(insert OID = 0 ( sum PGUID int2_sum - 21 20 20 _null_ )); DATA(insert OID = 0 ( sum PGUID float4pl - 700 700 700 _null_ )); DATA(insert OID = 0 ( sum PGUID float8pl - 701 701 701 _null_ )); DATA(insert OID = 0 ( sum PGUID cash_pl - 790 790 790 _null_ )); @@ -164,5 +164,4 @@ extern void AggregateCreate(char *aggName, extern Datum AggNameGetInitVal(char *aggName, Oid basetype, bool *isNull); - #endif /* PG_AGGREGATE_H */ diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index 3bf79404d8..21859dda6c 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_am.h,v 1.18 2001/07/15 22:48:18 tgl Exp $ + * $Id: pg_am.h,v 1.19 2001/10/25 05:49:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -38,8 +38,8 @@ CATALOG(pg_am) { NameData amname; /* access method name */ int4 amowner; /* usesysid of creator */ - int2 amstrategies; /* total NUMBER of strategies (operators) by - * which we can traverse/search this AM */ + int2 amstrategies; /* total NUMBER of strategies (operators) + * by which we can traverse/search this AM */ int2 amsupport; /* total NUMBER of support functions that * this AM uses */ int2 amorderstrategy;/* if this AM has a sort order, the @@ -98,14 +98,13 @@ typedef FormData_pg_am *Form_pg_am; * ---------------- */ -DATA(insert OID = 402 ( rtree PGUID 8 3 0 f f f f rtgettuple rtinsert rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos rtbuild rtbulkdelete rtcostestimate )); +DATA(insert OID = 402 ( rtree PGUID 8 3 0 f f f f rtgettuple rtinsert rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos rtbuild rtbulkdelete rtcostestimate )); DESCR("r-tree index access method"); -DATA(insert OID = 403 ( btree PGUID 5 1 1 t t t t btgettuple btinsert btbeginscan btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btcostestimate )); +DATA(insert OID = 403 ( btree PGUID 5 1 1 t t t t btgettuple btinsert btbeginscan btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btcostestimate )); DESCR("b-tree index access method"); #define BTREE_AM_OID 403 -DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashcostestimate )); +DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashcostestimate )); DESCR("hash index access method"); DATA(insert OID = 783 ( gist PGUID 100 7 0 f t f f gistgettuple gistinsert gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistcostestimate )); DESCR("GiST index access method"); - #endif /* PG_AM_H */ diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index e5a6fb872c..97331dbbc2 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -16,7 +16,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amop.h,v 1.42 2001/09/28 08:09:13 thomas Exp $ + * $Id: pg_amop.h,v 1.43 2001/10/25 05:49:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -425,5 +425,4 @@ DATA(insert ( 2001 1 f 1550 )); DATA(insert ( 2004 1 f 1062 )); /* timestamp_ops */ DATA(insert ( 2040 1 f 2060 )); - #endif /* PG_AMOP_H */ diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 520bf821bb..38a98d28fd 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -14,7 +14,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amproc.h,v 1.31 2001/09/28 08:09:13 thomas Exp $ + * $Id: pg_amproc.h,v 1.32 2001/10/25 05:49:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -66,39 +66,39 @@ typedef FormData_pg_amproc *Form_pg_amproc; */ /* rtree */ -DATA(insert ( 422 1 193 )); -DATA(insert ( 422 2 194 )); -DATA(insert ( 422 3 196 )); -DATA(insert ( 425 1 193 )); -DATA(insert ( 425 2 194 )); -DATA(insert ( 425 3 195 )); -DATA(insert ( 1993 1 197 )); -DATA(insert ( 1993 2 198 )); -DATA(insert ( 1993 3 199 )); +DATA(insert ( 422 1 193 )); +DATA(insert ( 422 2 194 )); +DATA(insert ( 422 3 196 )); +DATA(insert ( 425 1 193 )); +DATA(insert ( 425 2 194 )); +DATA(insert ( 425 3 195 )); +DATA(insert ( 1993 1 197 )); +DATA(insert ( 1993 2 198 )); +DATA(insert ( 1993 3 199 )); /* btree */ -DATA(insert ( 421 1 357 )); +DATA(insert ( 421 1 357 )); DATA(insert ( 423 1 1596 )); DATA(insert ( 424 1 1693 )); DATA(insert ( 426 1 1078 )); DATA(insert ( 428 1 1954 )); -DATA(insert ( 429 1 358 )); -DATA(insert ( 432 1 926 )); +DATA(insert ( 429 1 358 )); +DATA(insert ( 432 1 926 )); DATA(insert ( 434 1 1092 )); -DATA(insert ( 1970 1 354 )); -DATA(insert ( 1972 1 355 )); -DATA(insert ( 1974 1 926 )); -DATA(insert ( 1976 1 350 )); -DATA(insert ( 1978 1 351 )); -DATA(insert ( 1980 1 842 )); +DATA(insert ( 1970 1 354 )); +DATA(insert ( 1972 1 355 )); +DATA(insert ( 1974 1 926 )); +DATA(insert ( 1976 1 350 )); +DATA(insert ( 1978 1 351 )); +DATA(insert ( 1980 1 842 )); DATA(insert ( 1982 1 1315 )); -DATA(insert ( 1984 1 836 )); -DATA(insert ( 1986 1 359 )); +DATA(insert ( 1984 1 836 )); +DATA(insert ( 1986 1 359 )); DATA(insert ( 1988 1 1769 )); -DATA(insert ( 1989 1 356 )); -DATA(insert ( 1991 1 404 )); -DATA(insert ( 1994 1 360 )); +DATA(insert ( 1989 1 356 )); +DATA(insert ( 1991 1 404 )); +DATA(insert ( 1994 1 360 )); DATA(insert ( 1996 1 1107 )); DATA(insert ( 1998 1 1314 )); DATA(insert ( 2000 1 1358 )); @@ -109,25 +109,24 @@ DATA(insert ( 2039 1 1314 )); /* hash */ DATA(insert ( 427 1 1080 )); -DATA(insert ( 431 1 454 )); -DATA(insert ( 433 1 456 )); -DATA(insert ( 435 1 450 )); -DATA(insert ( 1971 1 451 )); -DATA(insert ( 1973 1 452 )); -DATA(insert ( 1975 1 456 )); -DATA(insert ( 1977 1 449 )); -DATA(insert ( 1979 1 450 )); -DATA(insert ( 1981 1 949 )); +DATA(insert ( 431 1 454 )); +DATA(insert ( 433 1 456 )); +DATA(insert ( 435 1 450 )); +DATA(insert ( 1971 1 451 )); +DATA(insert ( 1973 1 452 )); +DATA(insert ( 1975 1 456 )); +DATA(insert ( 1977 1 449 )); +DATA(insert ( 1979 1 450 )); +DATA(insert ( 1981 1 949 )); DATA(insert ( 1983 1 1697 )); -DATA(insert ( 1985 1 399 )); -DATA(insert ( 1987 1 455 )); -DATA(insert ( 1990 1 453 )); -DATA(insert ( 1992 1 457 )); -DATA(insert ( 1995 1 456 )); -DATA(insert ( 1997 1 452 )); -DATA(insert ( 1999 1 452 )); +DATA(insert ( 1985 1 399 )); +DATA(insert ( 1987 1 455 )); +DATA(insert ( 1990 1 453 )); +DATA(insert ( 1992 1 457 )); +DATA(insert ( 1995 1 456 )); +DATA(insert ( 1997 1 452 )); +DATA(insert ( 1999 1 452 )); DATA(insert ( 2001 1 1696 )); -DATA(insert ( 2004 1 456 )); -DATA(insert ( 2040 1 452 )); - +DATA(insert ( 2004 1 456 )); +DATA(insert ( 2040 1 452 )); #endif /* PG_AMPROC_H */ diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h index 55efc26966..520833472a 100644 --- a/src/include/catalog/pg_attrdef.h +++ b/src/include/catalog/pg_attrdef.h @@ -52,5 +52,4 @@ typedef FormData_pg_attrdef *Form_pg_attrdef; #define Anum_pg_attrdef_adbin 3 #define Anum_pg_attrdef_adsrc 4 - #endif /* PG_ATTRDEF_H */ diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 826d2b8ea8..8ed26ccdfc 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,14 +8,14 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.76 2001/08/26 16:56:00 tgl Exp $ + * $Id: pg_attribute.h,v 1.77 2001/10/25 05:49:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki * information from the DATA() statements. * * utils/cache/relcache.c requires hard-coded tuple descriptors - * for some of the system catalogs. So if the schema for any of + * for some of the system catalogs. So if the schema for any of * these changes, be sure and change the appropriate Schema_xxx * macros! -cim 2/5/91 * @@ -55,9 +55,10 @@ CATALOG(pg_attribute) BOOTSTRAP BKI_WITHOUT_OIDS Oid atttypid; /* - * attstattarget is the target number of statistics datapoints to collect - * during VACUUM ANALYZE of this column. A zero here indicates that we - * do not wish to collect any stats about this column. + * attstattarget is the target number of statistics datapoints to + * collect during VACUUM ANALYZE of this column. A zero here + * indicates that we do not wish to collect any stats about this + * column. */ int4 attstattarget; @@ -239,7 +240,7 @@ typedef FormData_pg_attribute *Form_pg_attribute; { 1247, {"typsend"}, 24, 0, 4, 14, 0, -1, -1, true, 'p', false, 'i', false, false }, \ { 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false }, \ { 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, true, 'p', false, 'c', false, false }, \ -{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, false , 'x', false, 'i', false, false } +{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, false , 'x', false, 'i', false, false } DATA(insert ( 1247 typname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert ( 1247 typowner 23 0 4 2 0 -1 -1 t p f i f f)); @@ -484,5 +485,4 @@ DATA(insert ( 1259 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * ---------------- */ DATA(insert ( 376 xactlockfoo 26 0 4 1 0 -1 -1 t p f i f f)); - #endif /* PG_ATTRIBUTE_H */ diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 2d0103a87b..e6dfb30f64 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_class.h,v 1.54 2001/08/26 16:56:01 tgl Exp $ + * $Id: pg_class.h,v 1.55 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -55,6 +55,7 @@ CATALOG(pg_class) BOOTSTRAP bool relisshared; /* T if shared across databases */ char relkind; /* see RELKIND_xxx constants below */ int2 relnatts; /* number of user attributes */ + /* * Class pg_attribute must contain exactly "relnatts" user attributes * (with attnums ranging from 1 to relnatts) for this class. It may @@ -69,6 +70,7 @@ CATALOG(pg_class) BOOTSTRAP bool relhaspkey; /* has PRIMARY KEY index */ bool relhasrules; /* has associated rules */ bool relhassubclass; /* has derived classes */ + /* * relacl may or may not be present, see note above! */ @@ -165,5 +167,4 @@ DESCR(""); #define RELKIND_UNCATALOGED 'u' /* temporary heap */ #define RELKIND_TOASTVALUE 't' /* moved off huge values */ #define RELKIND_VIEW 'v' /* view */ - #endif /* PG_CLASS_H */ diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h index 76de50e68b..b701e2b511 100644 --- a/src/include/catalog/pg_control.h +++ b/src/include/catalog/pg_control.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_control.h,v 1.3 2001/03/22 04:00:38 momjian Exp $ + * $Id: pg_control.h,v 1.4 2001/10/25 05:49:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,11 +51,11 @@ typedef struct CheckPoint /* System status indicator */ typedef enum DBState { - DB_STARTUP = 0, - DB_SHUTDOWNED, - DB_SHUTDOWNING, - DB_IN_RECOVERY, - DB_IN_PRODUCTION + DB_STARTUP = 0, + DB_SHUTDOWNED, + DB_SHUTDOWNING, + DB_IN_RECOVERY, + DB_IN_PRODUCTION } DBState; #define LOCALE_NAME_BUFLEN 128 @@ -110,5 +110,4 @@ typedef struct ControlFileData char lc_collate[LOCALE_NAME_BUFLEN]; char lc_ctype[LOCALE_NAME_BUFLEN]; } ControlFileData; - #endif /* PG_CONTROL_H */ diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h index f3e0fbd99b..439e4fcc3d 100644 --- a/src/include/catalog/pg_database.h +++ b/src/include/catalog/pg_database.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_database.h,v 1.18 2001/08/26 16:56:02 tgl Exp $ + * $Id: pg_database.h,v 1.19 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -39,8 +39,8 @@ CATALOG(pg_database) BOOTSTRAP bool datistemplate; /* allowed as CREATE DATABASE template? */ bool datallowconn; /* new connections allowed? */ Oid datlastsysoid; /* highest OID to consider a system OID */ - TransactionId datvacuumxid; /* all XIDs before this are vacuumed */ - TransactionId datfrozenxid; /* all XIDs before this are frozen */ + TransactionId datvacuumxid; /* all XIDs before this are vacuumed */ + TransactionId datfrozenxid; /* all XIDs before this are frozen */ text datpath; /* VARIABLE LENGTH FIELD */ } FormData_pg_database; @@ -78,5 +78,4 @@ DATAMARKOID(= 2) #define RecoveryDb 2 #undef DATAMARKOID - #endif /* PG_DATABASE_H */ diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h index e3f21a49b6..e8b304ba3b 100644 --- a/src/include/catalog/pg_description.h +++ b/src/include/catalog/pg_description.h @@ -6,12 +6,12 @@ * NOTE: an object is identified by the OID of the row that primarily * defines the object, plus the OID of the table that that row appears in. * For example, a function is identified by the OID of its pg_proc row - * plus the pg_class OID of table pg_proc. This allows unique identification + * plus the pg_class OID of table pg_proc. This allows unique identification * of objects without assuming that OIDs are unique across tables. * * Since attributes don't have OIDs of their own, we identify an attribute * comment by the objoid+classoid of its parent table, plus an "objsubid" - * giving the attribute column number. "objsubid" must be zero in a comment + * giving the attribute column number. "objsubid" must be zero in a comment * for a table itself, so that it is distinct from any column comment. * Currently, objsubid is unused and zero for all other kinds of objects, * but perhaps it might be useful someday to associate comments with @@ -22,7 +22,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_description.h,v 1.13 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_description.h,v 1.14 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -83,5 +83,4 @@ typedef FormData_pg_description *Form_pg_description; * there is no initialization here. The initial contents are extracted * by genbki.sh and loaded during initdb. */ - #endif /* PG_DESCRIPTION_H */ diff --git a/src/include/catalog/pg_group.h b/src/include/catalog/pg_group.h index d9d3ba7068..1c4ef4e97f 100644 --- a/src/include/catalog/pg_group.h +++ b/src/include/catalog/pg_group.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_group.h,v 1.10 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_group.h,v 1.11 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -40,5 +40,4 @@ typedef FormData_pg_group *Form_pg_group; #define Anum_pg_group_groname 1 #define Anum_pg_group_grosysid 2 #define Anum_pg_group_grolist 3 - #endif /* PG_GROUP_H */ diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 6fed33c862..3a0a60ffd6 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_index.h,v 1.24 2001/08/21 16:36:05 tgl Exp $ + * $Id: pg_index.h,v 1.25 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -38,14 +38,15 @@ CATALOG(pg_index) BKI_WITHOUT_OIDS regproc indproc; /* OID of function for functional index */ int2vector indkey; /* column numbers of indexed attributes */ oidvector indclass; /* opclass identifiers */ - bool indisclustered; /* presently unused */ + bool indisclustered; /* presently unused */ bool indisunique; /* is this a unique index? */ bool indisprimary; /* is this index for primary key? */ Oid indreference; /* oid of index of referenced relation (ie * - this index for foreign key) */ + /* VARIABLE LENGTH FIELD: */ - text indpred; /* expression tree for predicate, - * if a partial index */ + text indpred; /* expression tree for predicate, if a + * partial index */ } FormData_pg_index; /* ---------------- @@ -70,5 +71,4 @@ typedef FormData_pg_index *Form_pg_index; #define Anum_pg_index_indisprimary 8 #define Anum_pg_index_indreference 9 #define Anum_pg_index_indpred 10 - #endif /* PG_INDEX_H */ diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h index 599554e538..6e6b3912ce 100644 --- a/src/include/catalog/pg_inherits.h +++ b/src/include/catalog/pg_inherits.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_inherits.h,v 1.11 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_inherits.h,v 1.12 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -54,5 +54,4 @@ typedef FormData_pg_inherits *Form_pg_inherits; #define Anum_pg_inherits_inhparent 2 #define Anum_pg_inherits_inhseqno 3 - #endif /* PG_INHERITS_H */ diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h index 0d3f14fc7a..20823c3bfb 100644 --- a/src/include/catalog/pg_language.h +++ b/src/include/catalog/pg_language.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_language.h,v 1.13 2001/01/24 19:43:21 momjian Exp $ + * $Id: pg_language.h,v 1.14 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -73,5 +73,4 @@ DATA(insert OID = 14 ( "sql" f f 0 "postgres")); DESCR("SQL-language functions"); #define SQLlanguageId 14 - #endif /* PG_LANGUAGE_H */ diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h index 030ab177a2..2369e15ff2 100644 --- a/src/include/catalog/pg_largeobject.h +++ b/src/include/catalog/pg_largeobject.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_largeobject.h,v 1.9 2001/08/10 20:52:25 tgl Exp $ + * $Id: pg_largeobject.h,v 1.10 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -58,5 +58,4 @@ typedef FormData_pg_largeobject *Form_pg_largeobject; extern void LargeObjectCreate(Oid loid); extern void LargeObjectDrop(Oid loid); extern bool LargeObjectExists(Oid loid); - #endif /* PG_LARGEOBJECT_H */ diff --git a/src/include/catalog/pg_listener.h b/src/include/catalog/pg_listener.h index b191e02059..1c8f86f0f3 100644 --- a/src/include/catalog/pg_listener.h +++ b/src/include/catalog/pg_listener.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_listener.h,v 1.10 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_listener.h,v 1.11 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -60,5 +60,4 @@ typedef FormData_pg_listener *Form_pg_listener; * ---------------- */ - #endif /* PG_LISTENER_H */ diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index 4b07349c0f..b8e4625c15 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -8,7 +8,7 @@ * <opcamid, opcname> --- that is, there is a row for each valid combination * of opclass name and index access method type. This row specifies the * expected input data type for the opclass (the type of the heap column, - * or the function output type in the case of a functional index). Note + * or the function output type in the case of a functional index). Note * that types binary-compatible with the specified type will be accepted too. * * For a given <opcamid, opcintype> pair, there can be at most one row that @@ -16,17 +16,17 @@ * such an index. * * Normally opckeytype = InvalidOid (zero), indicating that the data stored - * in the index is the same as the input data. If opckeytype is nonzero + * in the index is the same as the input data. If opckeytype is nonzero * then it indicates that a conversion step is needed to produce the stored * index data, which will be of type opckeytype (which might be the same or - * different from the input data). Performing such a conversion is the + * different from the input data). Performing such a conversion is the * responsibility of the index access method --- not all AMs support this. - * + * * * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.40 2001/09/28 08:09:13 thomas Exp $ + * $Id: pg_opclass.h,v 1.41 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -127,8 +127,8 @@ DATA(insert OID = 1994 ( 403 text_ops 25 t 0 )); DATA(insert OID = 1995 ( 405 text_ops 25 t 0 )); DATA(insert OID = 1996 ( 403 time_ops 1083 t 0 )); DATA(insert OID = 1997 ( 405 time_ops 1083 t 0 )); -DATA(insert OID = 1998 ( 403 timestamptz_ops 1184 t 0 )); -DATA(insert OID = 1999 ( 405 timestamptz_ops 1184 t 0 )); +DATA(insert OID = 1998 ( 403 timestamptz_ops 1184 t 0 )); +DATA(insert OID = 1999 ( 405 timestamptz_ops 1184 t 0 )); DATA(insert OID = 2000 ( 403 timetz_ops 1266 t 0 )); DATA(insert OID = 2001 ( 405 timetz_ops 1266 t 0 )); DATA(insert OID = 2002 ( 403 varbit_ops 1562 t 0 )); @@ -136,5 +136,4 @@ DATA(insert OID = 2003 ( 403 varchar_ops 1043 t 0 )); DATA(insert OID = 2004 ( 405 varchar_ops 1043 t 0 )); DATA(insert OID = 2039 ( 403 timestamp_ops 1114 t 0 )); DATA(insert OID = 2040 ( 405 timestamp_ops 1114 t 0 )); - #endif /* PG_OPCLASS_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index e2db538241..8966c1f320 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.96 2001/09/30 06:46:58 inoue Exp $ + * $Id: pg_operator.h,v 1.97 2001/10/25 05:49:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -666,27 +666,27 @@ DATA(insert OID = 1617 ( "#" PGUID 0 b t f 628 628 600 1617 0 0 0 line_in /* MAC type */ DATA(insert OID = 1220 ( "=" PGUID 0 b t f 829 829 16 1220 1221 1222 1222 macaddr_eq eqsel eqjoinsel )); -DATA(insert OID = 1221 ( "<>" PGUID 0 b t f 829 829 16 1221 1220 0 0 macaddr_ne neqsel neqjoinsel )); -DATA(insert OID = 1222 ( "<" PGUID 0 b t f 829 829 16 1224 1225 0 0 macaddr_lt scalarltsel scalarltjoinsel )); -DATA(insert OID = 1223 ( "<=" PGUID 0 b t f 829 829 16 1225 1224 0 0 macaddr_le scalarltsel scalarltjoinsel )); -DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr_gt scalargtsel scalargtjoinsel )); -DATA(insert OID = 1225 ( ">=" PGUID 0 b t f 829 829 16 1223 1222 0 0 macaddr_ge scalargtsel scalargtjoinsel )); +DATA(insert OID = 1221 ( "<>" PGUID 0 b t f 829 829 16 1221 1220 0 0 macaddr_ne neqsel neqjoinsel )); +DATA(insert OID = 1222 ( "<" PGUID 0 b t f 829 829 16 1224 1225 0 0 macaddr_lt scalarltsel scalarltjoinsel )); +DATA(insert OID = 1223 ( "<=" PGUID 0 b t f 829 829 16 1225 1224 0 0 macaddr_le scalarltsel scalarltjoinsel )); +DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr_gt scalargtsel scalargtjoinsel )); +DATA(insert OID = 1225 ( ">=" PGUID 0 b t f 829 829 16 1223 1222 0 0 macaddr_ge scalargtsel scalargtjoinsel )); /* INET type */ DATA(insert OID = 1201 ( "=" PGUID 0 b t f 869 869 16 1201 1202 1203 1203 network_eq eqsel eqjoinsel )); -DATA(insert OID = 1202 ( "<>" PGUID 0 b t f 869 869 16 1202 1201 0 0 network_ne neqsel neqjoinsel )); -DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 network_lt scalarltsel scalarltjoinsel )); -DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 network_le scalarltsel scalarltjoinsel )); -DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 network_gt scalargtsel scalargtjoinsel )); -DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 network_ge scalargtsel scalargtjoinsel )); -DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 0 0 0 network_sub - - )); -#define OID_INET_SUB_OP 931 -DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 0 0 0 network_subeq - - )); -#define OID_INET_SUBEQ_OP 932 -DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 0 0 0 network_sup - - )); -#define OID_INET_SUP_OP 933 -DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 0 0 0 network_supeq - - )); -#define OID_INET_SUPEQ_OP 934 +DATA(insert OID = 1202 ( "<>" PGUID 0 b t f 869 869 16 1202 1201 0 0 network_ne neqsel neqjoinsel )); +DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 network_lt scalarltsel scalarltjoinsel )); +DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 network_le scalarltsel scalarltjoinsel )); +DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 network_gt scalargtsel scalargtjoinsel )); +DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 network_ge scalargtsel scalargtjoinsel )); +DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 0 0 0 network_sub - - )); +#define OID_INET_SUB_OP 931 +DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 0 0 0 network_subeq - - )); +#define OID_INET_SUBEQ_OP 932 +DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 0 0 0 network_sup - - )); +#define OID_INET_SUP_OP 933 +DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 0 0 0 network_supeq - - )); +#define OID_INET_SUPEQ_OP 934 /* CIDR type */ DATA(insert OID = 820 ( "=" PGUID 0 b t f 650 650 16 820 821 822 822 network_eq eqsel eqjoinsel )); @@ -696,7 +696,7 @@ DATA(insert OID = 823 ( "<=" PGUID 0 b t f 650 650 16 825 824 0 0 netwo DATA(insert OID = 824 ( ">" PGUID 0 b t f 650 650 16 822 823 0 0 network_gt scalargtsel scalargtjoinsel )); DATA(insert OID = 825 ( ">=" PGUID 0 b t f 650 650 16 823 822 0 0 network_ge scalargtsel scalargtjoinsel )); DATA(insert OID = 826 ( "<<" PGUID 0 b t f 650 650 16 828 0 0 0 network_sub - - )); -#define OID_CIDR_SUB_OP 826 +#define OID_CIDR_SUB_OP 826 DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 0 0 0 network_subeq - - )); #define OID_CIDR_SUBEQ_OP 827 DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 0 0 0 network_sup - - )); @@ -808,24 +808,24 @@ DATA(insert OID = 1889 ( "~" PGUID 0 l t f 0 20 20 0 0 0 0 int8not DATA(insert OID = 1890 ( "<<" PGUID 0 b t f 20 23 20 0 0 0 0 int8shl - - )); DATA(insert OID = 1891 ( ">>" PGUID 0 b t f 20 23 20 0 0 0 0 int8shr - - )); -DATA(insert OID = 1916 ( "+" PGUID 0 l t f 0 20 20 0 0 0 0 int8up - - )); -DATA(insert OID = 1917 ( "+" PGUID 0 l t f 0 21 21 0 0 0 0 int2up - - )); -DATA(insert OID = 1918 ( "+" PGUID 0 l t f 0 23 23 0 0 0 0 int4up - - )); -DATA(insert OID = 1919 ( "+" PGUID 0 l t f 0 700 700 0 0 0 0 float4up - - )); -DATA(insert OID = 1920 ( "+" PGUID 0 l t f 0 701 701 0 0 0 0 float8up - - )); -DATA(insert OID = 1921 ( "+" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_uplus - - )); +DATA(insert OID = 1916 ( "+" PGUID 0 l t f 0 20 20 0 0 0 0 int8up - - )); +DATA(insert OID = 1917 ( "+" PGUID 0 l t f 0 21 21 0 0 0 0 int2up - - )); +DATA(insert OID = 1918 ( "+" PGUID 0 l t f 0 23 23 0 0 0 0 int4up - - )); +DATA(insert OID = 1919 ( "+" PGUID 0 l t f 0 700 700 0 0 0 0 float4up - - )); +DATA(insert OID = 1920 ( "+" PGUID 0 l t f 0 701 701 0 0 0 0 float8up - - )); +DATA(insert OID = 1921 ( "+" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_uplus - - )); /* bytea operators */ DATA(insert OID = 1955 ( "=" PGUID 0 b t t 17 17 16 1955 1956 1957 1957 byteaeq eqsel eqjoinsel )); -DATA(insert OID = 1956 ( "<>" PGUID 0 b t f 17 17 16 1956 1955 0 0 byteane neqsel neqjoinsel )); -DATA(insert OID = 1957 ( "<" PGUID 0 b t f 17 17 16 1959 1960 0 0 bytealt scalarltsel scalarltjoinsel )); -DATA(insert OID = 1958 ( "<=" PGUID 0 b t f 17 17 16 1960 1959 0 0 byteale scalarltsel scalarltjoinsel )); -DATA(insert OID = 1959 ( ">" PGUID 0 b t f 17 17 16 1957 1958 0 0 byteagt scalargtsel scalargtjoinsel )); -DATA(insert OID = 1960 ( ">=" PGUID 0 b t f 17 17 16 1958 1957 0 0 byteage scalargtsel scalargtjoinsel )); -DATA(insert OID = 2016 ( "~~" PGUID 0 b t f 17 17 16 0 2017 0 0 bytealike likesel likejoinsel )); +DATA(insert OID = 1956 ( "<>" PGUID 0 b t f 17 17 16 1956 1955 0 0 byteane neqsel neqjoinsel )); +DATA(insert OID = 1957 ( "<" PGUID 0 b t f 17 17 16 1959 1960 0 0 bytealt scalarltsel scalarltjoinsel )); +DATA(insert OID = 1958 ( "<=" PGUID 0 b t f 17 17 16 1960 1959 0 0 byteale scalarltsel scalarltjoinsel )); +DATA(insert OID = 1959 ( ">" PGUID 0 b t f 17 17 16 1957 1958 0 0 byteagt scalargtsel scalargtjoinsel )); +DATA(insert OID = 1960 ( ">=" PGUID 0 b t f 17 17 16 1958 1957 0 0 byteage scalargtsel scalargtjoinsel )); +DATA(insert OID = 2016 ( "~~" PGUID 0 b t f 17 17 16 0 2017 0 0 bytealike likesel likejoinsel )); #define OID_BYTEA_LIKE_OP 2016 -DATA(insert OID = 2017 ( "!~~" PGUID 0 b t f 17 17 16 0 2016 0 0 byteanlike nlikesel nlikejoinsel )); -DATA(insert OID = 2018 ( "||" PGUID 0 b t f 17 17 17 0 0 0 0 byteacat - - )); +DATA(insert OID = 2017 ( "!~~" PGUID 0 b t f 17 17 16 0 2016 0 0 byteanlike nlikesel nlikejoinsel )); +DATA(insert OID = 2018 ( "||" PGUID 0 b t f 17 17 17 0 0 0 0 byteacat - - )); /* timestamp operators */ /* name, owner, prec, kind, isleft, canhash, left, right, result, com, negate, lsortop, rsortop, oprcode, operrest, oprjoin */ @@ -856,5 +856,4 @@ extern void OperatorCreate(char *operatorName, bool canHash, char *leftSortName, char *rightSortName); - #endif /* PG_OPERATOR_H */ diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 5efc7bed03..ca5345771b 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.217 2001/10/18 17:30:15 thomas Exp $ + * $Id: pg_proc.h,v 1.218 2001/10/25 05:49:57 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -99,113 +99,113 @@ typedef FormData_pg_proc *Form_pg_proc; DATA(insert OID = 1242 ( boolin PGUID 12 f t t t 1 f 16 "0" 100 0 0 100 boolin - )); DESCR("(internal)"); -DATA(insert OID = 1243 ( boolout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 boolout - )); +DATA(insert OID = 1243 ( boolout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 boolout - )); DESCR("(internal)"); -DATA(insert OID = 1244 ( byteain PGUID 12 f t t t 1 f 17 "0" 100 0 0 100 byteain - )); +DATA(insert OID = 1244 ( byteain PGUID 12 f t t t 1 f 17 "0" 100 0 0 100 byteain - )); DESCR("(internal)"); -DATA(insert OID = 31 ( byteaout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 byteaout - )); +DATA(insert OID = 31 ( byteaout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 byteaout - )); DESCR("(internal)"); -DATA(insert OID = 1245 ( charin PGUID 12 f t t t 1 f 18 "0" 100 0 0 100 charin - )); +DATA(insert OID = 1245 ( charin PGUID 12 f t t t 1 f 18 "0" 100 0 0 100 charin - )); DESCR("(internal)"); -DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - )); +DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - )); DESCR("(internal)"); -DATA(insert OID = 34 ( namein PGUID 12 f t t t 1 f 19 "0" 100 0 0 100 namein - )); +DATA(insert OID = 34 ( namein PGUID 12 f t t t 1 f 19 "0" 100 0 0 100 namein - )); DESCR("(internal)"); -DATA(insert OID = 35 ( nameout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 nameout - )); +DATA(insert OID = 35 ( nameout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 nameout - )); DESCR("(internal)"); -DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - )); +DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - )); DESCR("(internal)"); -DATA(insert OID = 39 ( int2out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2out - )); +DATA(insert OID = 39 ( int2out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2out - )); DESCR("(internal)"); -DATA(insert OID = 40 ( int2vectorin PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int2vectorin - )); +DATA(insert OID = 40 ( int2vectorin PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int2vectorin - )); DESCR("(internal)"); -DATA(insert OID = 41 ( int2vectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2vectorout - )); +DATA(insert OID = 41 ( int2vectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int2vectorout - )); DESCR("(internal)"); -DATA(insert OID = 42 ( int4in PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4in - )); +DATA(insert OID = 42 ( int4in PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4in - )); DESCR("(internal)"); -DATA(insert OID = 43 ( int4out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4out - )); +DATA(insert OID = 43 ( int4out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int4out - )); DESCR("(internal)"); -DATA(insert OID = 44 ( regprocin PGUID 12 f t f t 1 f 24 "0" 100 0 0 100 regprocin - )); +DATA(insert OID = 44 ( regprocin PGUID 12 f t f t 1 f 24 "0" 100 0 0 100 regprocin - )); DESCR("(internal)"); -DATA(insert OID = 45 ( regprocout PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 regprocout - )); +DATA(insert OID = 45 ( regprocout PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 regprocout - )); DESCR("(internal)"); -DATA(insert OID = 46 ( textin PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 textin - )); +DATA(insert OID = 46 ( textin PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 textin - )); DESCR("(internal)"); -DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - )); +DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - )); DESCR("(internal)"); -DATA(insert OID = 48 ( tidin PGUID 12 f t t t 1 f 27 "0" 100 0 0 100 tidin - )); +DATA(insert OID = 48 ( tidin PGUID 12 f t t t 1 f 27 "0" 100 0 0 100 tidin - )); DESCR("(internal)"); -DATA(insert OID = 49 ( tidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 tidout - )); +DATA(insert OID = 49 ( tidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 tidout - )); DESCR("(internal)"); -DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - )); +DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - )); DESCR("(internal)"); -DATA(insert OID = 51 ( xidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 xidout - )); +DATA(insert OID = 51 ( xidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 xidout - )); DESCR("(internal)"); -DATA(insert OID = 52 ( cidin PGUID 12 f t t t 1 f 29 "0" 100 0 0 100 cidin - )); +DATA(insert OID = 52 ( cidin PGUID 12 f t t t 1 f 29 "0" 100 0 0 100 cidin - )); DESCR("(internal)"); -DATA(insert OID = 53 ( cidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 cidout - )); +DATA(insert OID = 53 ( cidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 cidout - )); DESCR("(internal)"); -DATA(insert OID = 54 ( oidvectorin PGUID 12 f t t t 1 f 30 "0" 100 0 0 100 oidvectorin - )); +DATA(insert OID = 54 ( oidvectorin PGUID 12 f t t t 1 f 30 "0" 100 0 0 100 oidvectorin - )); DESCR("(internal)"); -DATA(insert OID = 55 ( oidvectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidvectorout - )); +DATA(insert OID = 55 ( oidvectorout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidvectorout - )); DESCR("(internal)"); -DATA(insert OID = 56 ( boollt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boollt - )); +DATA(insert OID = 56 ( boollt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boollt - )); DESCR("less-than"); -DATA(insert OID = 57 ( boolgt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolgt - )); +DATA(insert OID = 57 ( boolgt PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolgt - )); DESCR("greater-than"); -DATA(insert OID = 60 ( booleq PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 booleq - )); +DATA(insert OID = 60 ( booleq PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 booleq - )); DESCR("equal"); -DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - )); +DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - )); DESCR("equal"); -DATA(insert OID = 62 ( nameeq PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - )); +DATA(insert OID = 62 ( nameeq PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - )); DESCR("equal"); -DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - )); +DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - )); DESCR("equal"); -DATA(insert OID = 64 ( int2lt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2lt - )); +DATA(insert OID = 64 ( int2lt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2lt - )); DESCR("less-than"); -DATA(insert OID = 65 ( int4eq PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4eq - )); +DATA(insert OID = 65 ( int4eq PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4eq - )); DESCR("equal"); -DATA(insert OID = 66 ( int4lt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4lt - )); +DATA(insert OID = 66 ( int4lt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4lt - )); DESCR("less-than"); -DATA(insert OID = 67 ( texteq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texteq - )); +DATA(insert OID = 67 ( texteq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texteq - )); DESCR("equal"); -DATA(insert OID = 68 ( xideq PGUID 12 f t t t 2 f 16 "28 28" 100 0 0 100 xideq - )); +DATA(insert OID = 68 ( xideq PGUID 12 f t t t 2 f 16 "28 28" 100 0 0 100 xideq - )); DESCR("equal"); -DATA(insert OID = 69 ( cideq PGUID 12 f t t t 2 f 16 "29 29" 100 0 0 100 cideq - )); +DATA(insert OID = 69 ( cideq PGUID 12 f t t t 2 f 16 "29 29" 100 0 0 100 cideq - )); DESCR("equal"); -DATA(insert OID = 70 ( charne PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charne - )); +DATA(insert OID = 70 ( charne PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charne - )); DESCR("not equal"); -DATA(insert OID = 1246 ( charlt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charlt - )); +DATA(insert OID = 1246 ( charlt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charlt - )); DESCR("less-than"); -DATA(insert OID = 72 ( charle PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charle - )); +DATA(insert OID = 72 ( charle PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charle - )); DESCR("less-than-or-equal"); -DATA(insert OID = 73 ( chargt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chargt - )); +DATA(insert OID = 73 ( chargt PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chargt - )); DESCR("greater-than"); -DATA(insert OID = 74 ( charge PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charge - )); +DATA(insert OID = 74 ( charge PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 charge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1248 ( charpl PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charpl - )); +DATA(insert OID = 1248 ( charpl PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charpl - )); DESCR("add"); -DATA(insert OID = 1250 ( charmi PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmi - )); +DATA(insert OID = 1250 ( charmi PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmi - )); DESCR("subtract"); -DATA(insert OID = 77 ( charmul PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmul - )); +DATA(insert OID = 77 ( charmul PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 charmul - )); DESCR("multiply"); -DATA(insert OID = 78 ( chardiv PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 chardiv - )); +DATA(insert OID = 78 ( chardiv PGUID 12 f t t t 2 f 18 "18 18" 100 0 0 100 chardiv - )); DESCR("divide"); -DATA(insert OID = 79 ( nameregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexeq - )); +DATA(insert OID = 79 ( nameregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexeq - )); DESCR("matches regex., case-sensitive"); -DATA(insert OID = 1252 ( nameregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexne - )); +DATA(insert OID = 1252 ( nameregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameregexne - )); DESCR("does not match regex., case-sensitive"); -DATA(insert OID = 1254 ( textregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexeq - )); +DATA(insert OID = 1254 ( textregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexeq - )); DESCR("matches regex., case-sensitive"); -DATA(insert OID = 1256 ( textregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexne - )); +DATA(insert OID = 1256 ( textregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textregexne - )); DESCR("does not match regex., case-sensitive"); DATA(insert OID = 1257 ( textlen PGUID 12 f t t t 1 f 23 "25" 100 0 0 100 textlen - )); DESCR("length"); -DATA(insert OID = 1258 ( textcat PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 textcat - )); +DATA(insert OID = 1258 ( textcat PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 textcat - )); DESCR("concatenate"); -DATA(insert OID = 84 ( boolne PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolne - )); +DATA(insert OID = 84 ( boolne PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100 boolne - )); DESCR("not equal"); DATA(insert OID = 89 ( version PGUID 12 f t f t 0 f 25 "" 100 0 0 100 pgsql_version - )); DESCR("PostgreSQL version string"); @@ -291,93 +291,93 @@ DATA(insert OID = 139 ( areasel PGUID 12 f t f t 4 f 701 "0 26 0 23" 100 0 DESCR("restriction selectivity for area-comparison operators"); DATA(insert OID = 140 ( areajoinsel PGUID 12 f t f t 3 f 701 "0 26 0" 100 0 0 100 areajoinsel - )); DESCR("join selectivity for area-comparison operators"); -DATA(insert OID = 141 ( int4mul PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mul - )); +DATA(insert OID = 141 ( int4mul PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mul - )); DESCR("multiply"); DATA(insert OID = 142 ( int4fac PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4fac - )); DESCR("factorial"); -DATA(insert OID = 144 ( int4ne PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ne - )); +DATA(insert OID = 144 ( int4ne PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ne - )); DESCR("not equal"); -DATA(insert OID = 145 ( int2ne PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ne - )); +DATA(insert OID = 145 ( int2ne PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ne - )); DESCR("not equal"); -DATA(insert OID = 146 ( int2gt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2gt - )); +DATA(insert OID = 146 ( int2gt PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2gt - )); DESCR("greater-than"); -DATA(insert OID = 147 ( int4gt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4gt - )); +DATA(insert OID = 147 ( int4gt PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4gt - )); DESCR("greater-than"); -DATA(insert OID = 148 ( int2le PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2le - )); +DATA(insert OID = 148 ( int2le PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 149 ( int4le PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4le - )); +DATA(insert OID = 149 ( int4le PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 150 ( int4ge PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ge - )); +DATA(insert OID = 150 ( int4ge PGUID 12 f t t t 2 f 16 "23 23" 100 0 0 100 int4ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 151 ( int2ge PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ge - )); +DATA(insert OID = 151 ( int2ge PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 152 ( int2mul PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mul - )); +DATA(insert OID = 152 ( int2mul PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mul - )); DESCR("multiply"); -DATA(insert OID = 153 ( int2div PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2div - )); +DATA(insert OID = 153 ( int2div PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2div - )); DESCR("divide"); -DATA(insert OID = 154 ( int4div PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4div - )); +DATA(insert OID = 154 ( int4div PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4div - )); DESCR("divide"); -DATA(insert OID = 155 ( int2mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - )); +DATA(insert OID = 155 ( int2mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - )); DESCR("modulus"); -DATA(insert OID = 156 ( int4mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - )); +DATA(insert OID = 156 ( int4mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - )); DESCR("modulus"); -DATA(insert OID = 157 ( textne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textne - )); +DATA(insert OID = 157 ( textne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textne - )); DESCR("not equal"); -DATA(insert OID = 158 ( int24eq PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24eq - )); +DATA(insert OID = 158 ( int24eq PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24eq - )); DESCR("equal"); -DATA(insert OID = 159 ( int42eq PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42eq - )); +DATA(insert OID = 159 ( int42eq PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42eq - )); DESCR("equal"); -DATA(insert OID = 160 ( int24lt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24lt - )); +DATA(insert OID = 160 ( int24lt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24lt - )); DESCR("less-than"); -DATA(insert OID = 161 ( int42lt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42lt - )); +DATA(insert OID = 161 ( int42lt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42lt - )); DESCR("less-than"); -DATA(insert OID = 162 ( int24gt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24gt - )); +DATA(insert OID = 162 ( int24gt PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24gt - )); DESCR("greater-than"); -DATA(insert OID = 163 ( int42gt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42gt - )); +DATA(insert OID = 163 ( int42gt PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42gt - )); DESCR("greater-than"); -DATA(insert OID = 164 ( int24ne PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ne - )); +DATA(insert OID = 164 ( int24ne PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ne - )); DESCR("not equal"); -DATA(insert OID = 165 ( int42ne PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ne - )); +DATA(insert OID = 165 ( int42ne PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ne - )); DESCR("not equal"); -DATA(insert OID = 166 ( int24le PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24le - )); +DATA(insert OID = 166 ( int24le PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 167 ( int42le PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42le - )); +DATA(insert OID = 167 ( int42le PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 168 ( int24ge PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ge - )); +DATA(insert OID = 168 ( int24ge PGUID 12 f t t t 2 f 16 "21 23" 100 0 0 100 int24ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 169 ( int42ge PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ge - )); +DATA(insert OID = 169 ( int42ge PGUID 12 f t t t 2 f 16 "23 21" 100 0 0 100 int42ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 170 ( int24mul PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mul - )); +DATA(insert OID = 170 ( int24mul PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mul - )); DESCR("multiply"); -DATA(insert OID = 171 ( int42mul PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mul - )); +DATA(insert OID = 171 ( int42mul PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mul - )); DESCR("multiply"); -DATA(insert OID = 172 ( int24div PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24div - )); +DATA(insert OID = 172 ( int24div PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24div - )); DESCR("divide"); -DATA(insert OID = 173 ( int42div PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42div - )); +DATA(insert OID = 173 ( int42div PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42div - )); DESCR("divide"); -DATA(insert OID = 174 ( int24mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - )); +DATA(insert OID = 174 ( int24mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - )); DESCR("modulus"); -DATA(insert OID = 175 ( int42mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - )); +DATA(insert OID = 175 ( int42mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - )); DESCR("modulus"); -DATA(insert OID = 176 ( int2pl PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2pl - )); +DATA(insert OID = 176 ( int2pl PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2pl - )); DESCR("add"); -DATA(insert OID = 177 ( int4pl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4pl - )); +DATA(insert OID = 177 ( int4pl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4pl - )); DESCR("add"); -DATA(insert OID = 178 ( int24pl PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24pl - )); +DATA(insert OID = 178 ( int24pl PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24pl - )); DESCR("add"); -DATA(insert OID = 179 ( int42pl PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42pl - )); +DATA(insert OID = 179 ( int42pl PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42pl - )); DESCR("add"); -DATA(insert OID = 180 ( int2mi PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mi - )); +DATA(insert OID = 180 ( int2mi PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mi - )); DESCR("subtract"); -DATA(insert OID = 181 ( int4mi PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mi - )); +DATA(insert OID = 181 ( int4mi PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mi - )); DESCR("subtract"); -DATA(insert OID = 182 ( int24mi PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mi - )); +DATA(insert OID = 182 ( int24mi PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mi - )); DESCR("subtract"); -DATA(insert OID = 183 ( int42mi PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mi - )); +DATA(insert OID = 183 ( int42mi PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mi - )); DESCR("subtract"); -DATA(insert OID = 184 ( oideq PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oideq - )); +DATA(insert OID = 184 ( oideq PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oideq - )); DESCR("equal"); -DATA(insert OID = 185 ( oidne PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidne - )); +DATA(insert OID = 185 ( oidne PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidne - )); DESCR("not equal"); DATA(insert OID = 186 ( box_same PGUID 12 f t t t 2 f 16 "603 603" 100 0 0 100 box_same - )); DESCR("same as"); @@ -561,7 +561,7 @@ DATA(insert OID = 272 ( tintervalstart PGUID 12 f t t t 1 f 702 "704" 100 0 DESCR("start of interval"); DATA(insert OID = 273 ( tintervalend PGUID 12 f t t t 1 f 702 "704" 100 0 0 100 tintervalend - )); DESCR(""); -DATA(insert OID = 274 ( timeofday PGUID 12 f t f t 0 f 25 "0" 100 0 0 100 timeofday - )); +DATA(insert OID = 274 ( timeofday PGUID 12 f t f t 0 f 25 "0" 100 0 0 100 timeofday - )); DESCR("Current date and time with microseconds"); DATA(insert OID = 275 ( isfinite PGUID 12 f t t t 1 f 16 "702" 100 0 0 100 abstime_finite - )); DESCR(""); @@ -664,44 +664,44 @@ DESCR("convert int4 to float4"); DATA(insert OID = 319 ( int4 PGUID 12 f t t t 1 f 23 "700" 100 0 0 100 ftoi4 - )); DESCR("convert float4 to int4"); -DATA(insert OID = 320 ( rtinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtinsert - )); +DATA(insert OID = 320 ( rtinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtinsert - )); DESCR("r-tree(internal)"); DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - )); DESCR("r-tree(internal)"); -DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbuild - )); +DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbuild - )); DESCR("r-tree(internal)"); DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - )); DESCR("r-tree(internal)"); -DATA(insert OID = 325 ( rtendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - )); +DATA(insert OID = 325 ( rtendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - )); DESCR("r-tree(internal)"); -DATA(insert OID = 326 ( rtmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - )); +DATA(insert OID = 326 ( rtmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - )); DESCR("r-tree(internal)"); -DATA(insert OID = 327 ( rtrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - )); +DATA(insert OID = 327 ( rtrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - )); DESCR("r-tree(internal)"); -DATA(insert OID = 328 ( rtrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtrescan - )); +DATA(insert OID = 328 ( rtrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtrescan - )); DESCR("r-tree(internal)"); -DATA(insert OID = 321 ( rtbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbulkdelete - )); +DATA(insert OID = 321 ( rtbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtbulkdelete - )); DESCR("r-tree(internal)"); DATA(insert OID = 1265 ( rtcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 rtcostestimate - )); DESCR("r-tree(internal)"); DATA(insert OID = 330 ( btgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 btgettuple - )); DESCR("btree(internal)"); -DATA(insert OID = 331 ( btinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btinsert - )); +DATA(insert OID = 331 ( btinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btinsert - )); DESCR("btree(internal)"); DATA(insert OID = 333 ( btbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 btbeginscan - )); DESCR("btree(internal)"); -DATA(insert OID = 334 ( btrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btrescan - )); +DATA(insert OID = 334 ( btrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btrescan - )); DESCR("btree(internal)"); -DATA(insert OID = 335 ( btendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btendscan - )); +DATA(insert OID = 335 ( btendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btendscan - )); DESCR("btree(internal)"); -DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - )); +DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - )); DESCR("btree(internal)"); -DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - )); +DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - )); DESCR("btree(internal)"); -DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbuild - )); +DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbuild - )); DESCR("btree(internal)"); -DATA(insert OID = 332 ( btbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbulkdelete - )); +DATA(insert OID = 332 ( btbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btbulkdelete - )); DESCR("btree(internal)"); DATA(insert OID = 1268 ( btcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 btcostestimate - )); DESCR("btree(internal)"); @@ -727,27 +727,27 @@ DESCR("(internal)"); DATA(insert OID = 348 ( poly_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 poly_out - )); DESCR("(internal)"); -DATA(insert OID = 350 ( btint2cmp PGUID 12 f t t t 2 f 23 "21 21" 100 0 0 100 btint2cmp - )); +DATA(insert OID = 350 ( btint2cmp PGUID 12 f t t t 2 f 23 "21 21" 100 0 0 100 btint2cmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 351 ( btint4cmp PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 btint4cmp - )); +DATA(insert OID = 351 ( btint4cmp PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 btint4cmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 842 ( btint8cmp PGUID 12 f t t t 2 f 23 "20 20" 100 0 0 100 btint8cmp - )); +DATA(insert OID = 842 ( btint8cmp PGUID 12 f t t t 2 f 23 "20 20" 100 0 0 100 btint8cmp - )); DESCR("btree less-equal-greater"); DATA(insert OID = 354 ( btfloat4cmp PGUID 12 f t t t 2 f 23 "700 700" 100 0 0 100 btfloat4cmp - )); DESCR("btree less-equal-greater"); DATA(insert OID = 355 ( btfloat8cmp PGUID 12 f t t t 2 f 23 "701 701" 100 0 0 100 btfloat8cmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 356 ( btoidcmp PGUID 12 f t t t 2 f 23 "26 26" 100 0 0 100 btoidcmp - )); +DATA(insert OID = 356 ( btoidcmp PGUID 12 f t t t 2 f 23 "26 26" 100 0 0 100 btoidcmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 404 ( btoidvectorcmp PGUID 12 f t t t 2 f 23 "30 30" 100 0 0 100 btoidvectorcmp - )); +DATA(insert OID = 404 ( btoidvectorcmp PGUID 12 f t t t 2 f 23 "30 30" 100 0 0 100 btoidvectorcmp - )); DESCR("btree less-equal-greater"); DATA(insert OID = 357 ( btabstimecmp PGUID 12 f t t t 2 f 23 "702 702" 100 0 0 100 btabstimecmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 358 ( btcharcmp PGUID 12 f t t t 2 f 23 "18 18" 100 0 0 100 btcharcmp - )); +DATA(insert OID = 358 ( btcharcmp PGUID 12 f t t t 2 f 23 "18 18" 100 0 0 100 btcharcmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 359 ( btnamecmp PGUID 12 f t t t 2 f 23 "19 19" 100 0 0 100 btnamecmp - )); +DATA(insert OID = 359 ( btnamecmp PGUID 12 f t t t 2 f 23 "19 19" 100 0 0 100 btnamecmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 360 ( bttextcmp PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 bttextcmp - )); +DATA(insert OID = 360 ( bttextcmp PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 bttextcmp - )); DESCR("btree less-equal-greater"); DATA(insert OID = 361 ( lseg_distance PGUID 12 f t t t 2 f 701 "601 601" 100 0 0 100 lseg_distance - )); @@ -790,21 +790,21 @@ DESCR("convert char() to name"); DATA(insert OID = 440 ( hashgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 hashgettuple - )); DESCR("hash(internal)"); -DATA(insert OID = 441 ( hashinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashinsert - )); +DATA(insert OID = 441 ( hashinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashinsert - )); DESCR("hash(internal)"); DATA(insert OID = 443 ( hashbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 hashbeginscan - )); DESCR("hash(internal)"); -DATA(insert OID = 444 ( hashrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashrescan - )); +DATA(insert OID = 444 ( hashrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashrescan - )); DESCR("hash(internal)"); -DATA(insert OID = 445 ( hashendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - )); +DATA(insert OID = 445 ( hashendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - )); DESCR("hash(internal)"); -DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - )); +DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - )); DESCR("hash(internal)"); -DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - )); +DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - )); DESCR("hash(internal)"); -DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbuild - )); +DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbuild - )); DESCR("hash(internal)"); -DATA(insert OID = 442 ( hashbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbulkdelete - )); +DATA(insert OID = 442 ( hashbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashbulkdelete - )); DESCR("hash(internal)"); DATA(insert OID = 438 ( hashcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 hashcostestimate - )); DESCR("hash(internal)"); @@ -825,55 +825,55 @@ DATA(insert OID = 454 ( hashchar PGUID 12 f t t t 1 f 23 "18" 100 0 0 100 DESCR("hash"); DATA(insert OID = 455 ( hashname PGUID 12 f t t t 1 f 23 "19" 100 0 0 100 hashname - )); DESCR("hash"); -DATA(insert OID = 456 ( hashvarlena PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 hashvarlena - )); +DATA(insert OID = 456 ( hashvarlena PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 hashvarlena - )); DESCR("hash any varlena type"); DATA(insert OID = 457 ( hashoidvector PGUID 12 f t t t 1 f 23 "30" 100 0 0 100 hashoidvector - )); DESCR("hash"); DATA(insert OID = 399 ( hashmacaddr PGUID 12 f t t t 1 f 23 "829" 100 0 0 100 hashmacaddr - )); DESCR("hash"); -DATA(insert OID = 458 ( text_larger PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_larger - )); +DATA(insert OID = 458 ( text_larger PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_larger - )); DESCR("larger of two"); -DATA(insert OID = 459 ( text_smaller PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - )); +DATA(insert OID = 459 ( text_smaller PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - )); DESCR("smaller of two"); -DATA(insert OID = 460 ( int8in PGUID 12 f t t t 1 f 20 "0" 100 0 0 100 int8in - )); +DATA(insert OID = 460 ( int8in PGUID 12 f t t t 1 f 20 "0" 100 0 0 100 int8in - )); DESCR("(internal)"); -DATA(insert OID = 461 ( int8out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int8out - )); +DATA(insert OID = 461 ( int8out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int8out - )); DESCR("(internal)"); DATA(insert OID = 462 ( int8um PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8um - )); DESCR("negate"); -DATA(insert OID = 463 ( int8pl PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - )); +DATA(insert OID = 463 ( int8pl PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - )); DESCR("add"); -DATA(insert OID = 464 ( int8mi PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - )); +DATA(insert OID = 464 ( int8mi PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - )); DESCR("subtract"); -DATA(insert OID = 465 ( int8mul PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - )); +DATA(insert OID = 465 ( int8mul PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - )); DESCR("multiply"); -DATA(insert OID = 466 ( int8div PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - )); +DATA(insert OID = 466 ( int8div PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - )); DESCR("divide"); -DATA(insert OID = 467 ( int8eq PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - )); +DATA(insert OID = 467 ( int8eq PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - )); DESCR("equal"); -DATA(insert OID = 468 ( int8ne PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - )); +DATA(insert OID = 468 ( int8ne PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - )); DESCR("not equal"); -DATA(insert OID = 469 ( int8lt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - )); +DATA(insert OID = 469 ( int8lt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - )); DESCR("less-than"); -DATA(insert OID = 470 ( int8gt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - )); +DATA(insert OID = 470 ( int8gt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - )); DESCR("greater-than"); -DATA(insert OID = 471 ( int8le PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - )); +DATA(insert OID = 471 ( int8le PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 472 ( int8ge PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - )); +DATA(insert OID = 472 ( int8ge PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 474 ( int84eq PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - )); +DATA(insert OID = 474 ( int84eq PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - )); DESCR("equal"); -DATA(insert OID = 475 ( int84ne PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - )); +DATA(insert OID = 475 ( int84ne PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - )); DESCR("not equal"); -DATA(insert OID = 476 ( int84lt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - )); +DATA(insert OID = 476 ( int84lt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - )); DESCR("less-than"); -DATA(insert OID = 477 ( int84gt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - )); +DATA(insert OID = 477 ( int84gt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - )); DESCR("greater-than"); -DATA(insert OID = 478 ( int84le PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - )); +DATA(insert OID = 478 ( int84le PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 479 ( int84ge PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - )); +DATA(insert OID = 479 ( int84ge PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - )); DESCR("greater-than-or-equal"); DATA(insert OID = 480 ( int4 PGUID 12 f t t t 1 f 23 "20" 100 0 0 100 int84 - )); @@ -889,66 +889,66 @@ DESCR("convert float8 to int8"); /* OIDS 600 - 699 */ -DATA(insert OID = 1285 ( int4notin PGUID 12 f t f t 2 f 16 "23 25" 100 0 0 100 int4notin - )); +DATA(insert OID = 1285 ( int4notin PGUID 12 f t f t 2 f 16 "23 25" 100 0 0 100 int4notin - )); DESCR("not in"); -DATA(insert OID = 1286 ( oidnotin PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 oidnotin - )); +DATA(insert OID = 1286 ( oidnotin PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 oidnotin - )); DESCR("not in"); -DATA(insert OID = 1287 ( int44in PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int44in - )); +DATA(insert OID = 1287 ( int44in PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 int44in - )); DESCR("(internal)"); -DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - )); +DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - )); DESCR("(internal)"); -DATA(insert OID = 655 ( namelt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - )); +DATA(insert OID = 655 ( namelt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - )); DESCR("less-than"); -DATA(insert OID = 656 ( namele PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namele - )); +DATA(insert OID = 656 ( namele PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namele - )); DESCR("less-than-or-equal"); -DATA(insert OID = 657 ( namegt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - )); +DATA(insert OID = 657 ( namegt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - )); DESCR("greater-than"); -DATA(insert OID = 658 ( namege PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namege - )); +DATA(insert OID = 658 ( namege PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namege - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 659 ( namene PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namene - )); +DATA(insert OID = 659 ( namene PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namene - )); DESCR("not equal"); -DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - )); +DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - )); DESCR("adjust char() to typmod length"); -DATA(insert OID = 669 ( varchar PGUID 12 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - )); +DATA(insert OID = 669 ( varchar PGUID 12 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - )); DESCR("adjust varchar() to typmod length"); DATA(insert OID = 676 ( mktinterval PGUID 12 f t t t 2 f 704 "702 702" 100 0 0 100 mktinterval - )); DESCR("convert to tinterval"); -DATA(insert OID = 619 ( oidvectorne PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorne - )); +DATA(insert OID = 619 ( oidvectorne PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorne - )); DESCR("not equal"); -DATA(insert OID = 677 ( oidvectorlt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorlt - )); +DATA(insert OID = 677 ( oidvectorlt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorlt - )); DESCR("less-than"); -DATA(insert OID = 678 ( oidvectorle PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorle - )); +DATA(insert OID = 678 ( oidvectorle PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorle - )); DESCR("less-than-or-equal"); -DATA(insert OID = 679 ( oidvectoreq PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectoreq - )); +DATA(insert OID = 679 ( oidvectoreq PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectoreq - )); DESCR("equal"); -DATA(insert OID = 680 ( oidvectorge PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorge - )); +DATA(insert OID = 680 ( oidvectorge PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 681 ( oidvectorgt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorgt - )); +DATA(insert OID = 681 ( oidvectorgt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0 100 oidvectorgt - )); DESCR("greater-than"); /* OIDS 700 - 799 */ -DATA(insert OID = 710 ( getpgusername PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - )); +DATA(insert OID = 710 ( getpgusername PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - )); DESCR("deprecated -- use current_user"); DATA(insert OID = 711 ( userfntest PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 userfntest - )); DESCR(""); -DATA(insert OID = 713 ( oidrand PGUID 12 f t f t 2 f 16 "26 23" 100 0 0 100 oidrand - )); +DATA(insert OID = 713 ( oidrand PGUID 12 f t f t 2 f 16 "26 23" 100 0 0 100 oidrand - )); DESCR("random"); DATA(insert OID = 715 ( oidsrand PGUID 12 f t f t 1 f 16 "23" 100 0 0 100 oidsrand - )); DESCR("seed random number generator"); -DATA(insert OID = 716 ( oidlt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidlt - )); +DATA(insert OID = 716 ( oidlt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidlt - )); DESCR("less-than"); -DATA(insert OID = 717 ( oidle PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidle - )); +DATA(insert OID = 717 ( oidle PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidle - )); DESCR("less-than-or-equal"); DATA(insert OID = 720 ( octet_length PGUID 12 f t t t 1 f 23 "17" 100 0 0 100 byteaoctetlen - )); DESCR("octet length"); -DATA(insert OID = 721 ( get_byte PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - )); +DATA(insert OID = 721 ( get_byte PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - )); DESCR(""); DATA(insert OID = 722 ( set_byte PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetByte - )); DESCR(""); -DATA(insert OID = 723 ( get_bit PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - )); +DATA(insert OID = 723 ( get_bit PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - )); DESCR(""); DATA(insert OID = 724 ( set_bit PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetBit - )); DESCR(""); @@ -964,21 +964,21 @@ DESCR("distance between"); DATA(insert OID = 729 ( poly_distance PGUID 12 f t t t 2 f 701 "604 604" 100 0 0 100 poly_distance - )); DESCR("distance between"); -DATA(insert OID = 740 ( text_lt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_lt - )); +DATA(insert OID = 740 ( text_lt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_lt - )); DESCR("less-than"); -DATA(insert OID = 741 ( text_le PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_le - )); +DATA(insert OID = 741 ( text_le PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 742 ( text_gt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_gt - )); +DATA(insert OID = 742 ( text_gt PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_gt - )); DESCR("greater-than"); -DATA(insert OID = 743 ( text_ge PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_ge - )); +DATA(insert OID = 743 ( text_ge PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 text_ge - )); DESCR("greater-than-or-equal"); DATA(insert OID = 744 ( array_eq PGUID 12 f t t t 2 f 16 "0 0" 100 0 0 100 array_eq -)); DESCR("array equal"); -DATA(insert OID = 745 ( current_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - )); +DATA(insert OID = 745 ( current_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 current_user - )); DESCR("current user name"); -DATA(insert OID = 746 ( session_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 session_user - )); +DATA(insert OID = 746 ( session_user PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 session_user - )); DESCR("session user name"); DATA(insert OID = 747 ( array_dims PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 array_dims -)); @@ -999,37 +999,37 @@ DESCR("storage manager"); DATA(insert OID = 764 ( lo_import PGUID 12 f t f t 1 f 26 "25" 100 0 0 100 lo_import - )); DESCR("large object import"); -DATA(insert OID = 765 ( lo_export PGUID 12 f t f t 2 f 23 "26 25" 100 0 0 100 lo_export - )); +DATA(insert OID = 765 ( lo_export PGUID 12 f t f t 2 f 23 "26 25" 100 0 0 100 lo_export - )); DESCR("large object export"); DATA(insert OID = 766 ( int4inc PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4inc - )); DESCR("increment"); -DATA(insert OID = 768 ( int4larger PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4larger - )); +DATA(insert OID = 768 ( int4larger PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4larger - )); DESCR("larger of two"); -DATA(insert OID = 769 ( int4smaller PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4smaller - )); +DATA(insert OID = 769 ( int4smaller PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4smaller - )); DESCR("smaller of two"); -DATA(insert OID = 770 ( int2larger PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2larger - )); +DATA(insert OID = 770 ( int2larger PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2larger - )); DESCR("larger of two"); -DATA(insert OID = 771 ( int2smaller PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2smaller - )); +DATA(insert OID = 771 ( int2smaller PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2smaller - )); DESCR("smaller of two"); DATA(insert OID = 774 ( gistgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 gistgettuple - )); DESCR("gist(internal)"); -DATA(insert OID = 775 ( gistinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistinsert - )); +DATA(insert OID = 775 ( gistinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistinsert - )); DESCR("gist(internal)"); DATA(insert OID = 777 ( gistbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 gistbeginscan - )); DESCR("gist(internal)"); -DATA(insert OID = 778 ( gistrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistrescan - )); +DATA(insert OID = 778 ( gistrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistrescan - )); DESCR("gist(internal)"); -DATA(insert OID = 779 ( gistendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - )); +DATA(insert OID = 779 ( gistendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - )); DESCR("gist(internal)"); -DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - )); +DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - )); DESCR("gist(internal)"); -DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - )); +DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - )); DESCR("gist(internal)"); -DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbuild - )); +DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbuild - )); DESCR("gist(internal)"); -DATA(insert OID = 776 ( gistbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbulkdelete - )); +DATA(insert OID = 776 ( gistbulkdelete PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistbulkdelete - )); DESCR("gist(internal)"); DATA(insert OID = 772 ( gistcostestimate PGUID 12 f t f t 8 f 0 "0 0 0 0 0 0 0 0" 100 0 0 100 gistcostestimate - )); DESCR("gist(internal)"); @@ -1079,22 +1079,22 @@ DESCR("matches LIKE expression"); DATA(insert OID = 851 ( textnlike PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 textnlike - )); DESCR("does not match LIKE expression"); -DATA(insert OID = 852 ( int48eq PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - )); +DATA(insert OID = 852 ( int48eq PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - )); DESCR("equal"); -DATA(insert OID = 853 ( int48ne PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - )); +DATA(insert OID = 853 ( int48ne PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - )); DESCR("not equal"); -DATA(insert OID = 854 ( int48lt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - )); +DATA(insert OID = 854 ( int48lt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - )); DESCR("less-than"); -DATA(insert OID = 855 ( int48gt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - )); +DATA(insert OID = 855 ( int48gt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - )); DESCR("greater-than"); -DATA(insert OID = 856 ( int48le PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - )); +DATA(insert OID = 856 ( int48le PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 857 ( int48ge PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - )); +DATA(insert OID = 857 ( int48ge PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 858 ( namelike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - )); +DATA(insert OID = 858 ( namelike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - )); DESCR("matches LIKE expression"); -DATA(insert OID = 859 ( namenlike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namenlike - )); +DATA(insert OID = 859 ( namenlike PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 namenlike - )); DESCR("does not match LIKE expression"); DATA(insert OID = 860 ( bpchar PGUID 12 f t t t 1 f 1042 "18" 100 0 0 100 char_bpchar - )); @@ -1135,9 +1135,9 @@ DATA(insert OID = 894 ( cash_pl PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 DESCR("add"); DATA(insert OID = 895 ( cash_mi PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cash_mi - )); DESCR("subtract"); -DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - )); +DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - )); DESCR("multiply"); -DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - )); +DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - )); DESCR("divide"); DATA(insert OID = 898 ( cashlarger PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cashlarger - )); DESCR("larger of two"); @@ -1150,18 +1150,18 @@ DESCR("output amount as words"); /* OIDS 900 - 999 */ -DATA(insert OID = 940 ( mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - )); +DATA(insert OID = 940 ( mod PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2mod - )); DESCR("modulus"); -DATA(insert OID = 941 ( mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - )); +DATA(insert OID = 941 ( mod PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4mod - )); DESCR("modulus"); -DATA(insert OID = 942 ( mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - )); +DATA(insert OID = 942 ( mod PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100 int24mod - )); DESCR("modulus"); -DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - )); +DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - )); DESCR("modulus"); -DATA(insert OID = 945 ( int8mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); +DATA(insert OID = 945 ( int8mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); DESCR("modulus"); -DATA(insert OID = 947 ( mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); +DATA(insert OID = 947 ( mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); DESCR("modulus"); DATA(insert OID = 944 ( char PGUID 12 f t t t 1 f 18 "25" 100 0 0 100 text_char - )); @@ -1174,13 +1174,13 @@ DESCR("bool is true (not false or unknown)"); DATA(insert OID = 951 ( isfalse PGUID 12 f t t f 1 f 16 "16" 100 0 0 100 isfalse - )); DESCR("bool is false (not true or unknown)"); -DATA(insert OID = 952 ( lo_open PGUID 12 f t f t 2 f 23 "26 23" 100 0 0 100 lo_open - )); +DATA(insert OID = 952 ( lo_open PGUID 12 f t f t 2 f 23 "26 23" 100 0 0 100 lo_open - )); DESCR("large object open"); DATA(insert OID = 953 ( lo_close PGUID 12 f t f t 1 f 23 "23" 100 0 0 100 lo_close - )); DESCR("large object close"); -DATA(insert OID = 954 ( loread PGUID 12 f t f t 2 f 17 "23 23" 100 0 0 100 loread - )); +DATA(insert OID = 954 ( loread PGUID 12 f t f t 2 f 17 "23 23" 100 0 0 100 loread - )); DESCR("large object read"); -DATA(insert OID = 955 ( lowrite PGUID 12 f t f t 2 f 23 "23 17" 100 0 0 100 lowrite - )); +DATA(insert OID = 955 ( lowrite PGUID 12 f t f t 2 f 23 "23 17" 100 0 0 100 lowrite - )); DESCR("large object write"); DATA(insert OID = 956 ( lo_lseek PGUID 12 f t f t 3 f 23 "23 23 23" 100 0 0 100 lo_lseek - )); DESCR("large object seek"); @@ -1271,12 +1271,12 @@ DESCR("convert timetz to text"); /* OIDS 1000 - 1999 */ -DATA(insert OID = 1026 ( timezone PGUID 12 f t f t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - )); +DATA(insert OID = 1026 ( timezone PGUID 12 f t f t 2 f 25 "1186 1184" 100 0 0 100 timestamptz_izone - )); DESCR("time zone"); -DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nullvalue - )); +DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nullvalue - )); DESCR("(internal)"); -DATA(insert OID = 1030 ( nonnullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nonnullvalue - )); +DATA(insert OID = 1030 ( nonnullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nonnullvalue - )); DESCR("(internal)"); DATA(insert OID = 1031 ( aclitemin PGUID 12 f t f t 1 f 1033 "0" 100 0 0 100 aclitemin - )); DESCR("(internal)"); @@ -1286,45 +1286,45 @@ DATA(insert OID = 1035 ( aclinsert PGUID 12 f t f t 2 f 1034 "1034 1033" 10 DESCR("add/update ACL item"); DATA(insert OID = 1036 ( aclremove PGUID 12 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclremove - )); DESCR("remove ACL item"); -DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - )); +DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - )); DESCR("does ACL contain item?"); DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 t 23 "26" 100 0 0 100 seteval - )); DESCR("internal function supporting PostQuel-style sets"); DATA(insert OID = 1044 ( bpcharin PGUID 12 f t t t 3 f 1042 "0 26 23" 100 0 0 100 bpcharin - )); DESCR("(internal)"); -DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - )); +DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - )); DESCR("(internal)"); DATA(insert OID = 1046 ( varcharin PGUID 12 f t t t 3 f 1043 "0 26 23" 100 0 0 100 varcharin - )); DESCR("(internal)"); -DATA(insert OID = 1047 ( varcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 varcharout - )); +DATA(insert OID = 1047 ( varcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 varcharout - )); DESCR("(internal)"); -DATA(insert OID = 1048 ( bpchareq PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - )); +DATA(insert OID = 1048 ( bpchareq PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - )); DESCR("equal"); -DATA(insert OID = 1049 ( bpcharlt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharlt - )); +DATA(insert OID = 1049 ( bpcharlt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharlt - )); DESCR("less-than"); -DATA(insert OID = 1050 ( bpcharle PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharle - )); +DATA(insert OID = 1050 ( bpcharle PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharle - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1051 ( bpchargt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchargt - )); +DATA(insert OID = 1051 ( bpchargt PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchargt - )); DESCR("greater-than"); -DATA(insert OID = 1052 ( bpcharge PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharge - )); +DATA(insert OID = 1052 ( bpcharge PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1053 ( bpcharne PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharne - )); +DATA(insert OID = 1053 ( bpcharne PGUID 12 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpcharne - )); DESCR("not equal"); -DATA(insert OID = 1070 ( varchareq PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchareq - )); +DATA(insert OID = 1070 ( varchareq PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchareq - )); DESCR("equal"); -DATA(insert OID = 1071 ( varcharlt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharlt - )); +DATA(insert OID = 1071 ( varcharlt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharlt - )); DESCR("less-than"); -DATA(insert OID = 1072 ( varcharle PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharle - )); +DATA(insert OID = 1072 ( varcharle PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharle - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1073 ( varchargt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchargt - )); +DATA(insert OID = 1073 ( varchargt PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varchargt - )); DESCR("greater-than"); -DATA(insert OID = 1074 ( varcharge PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharge - )); +DATA(insert OID = 1074 ( varcharge PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1075 ( varcharne PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharne - )); +DATA(insert OID = 1075 ( varcharne PGUID 12 f t t t 2 f 16 "1043 1043" 100 0 0 100 varcharne - )); DESCR("not equal"); -DATA(insert OID = 1078 ( bpcharcmp PGUID 12 f t t t 2 f 23 "1042 1042" 100 0 0 100 bpcharcmp - )); +DATA(insert OID = 1078 ( bpcharcmp PGUID 12 f t t t 2 f 23 "1042 1042" 100 0 0 100 bpcharcmp - )); DESCR("less-equal-greater"); -DATA(insert OID = 1079 ( varcharcmp PGUID 12 f t t t 2 f 23 "1043 1043" 100 0 0 100 varcharcmp - )); +DATA(insert OID = 1079 ( varcharcmp PGUID 12 f t t t 2 f 23 "1043 1043" 100 0 0 100 varcharcmp - )); DESCR("less-equal-greater"); DATA(insert OID = 1080 ( hashbpchar PGUID 12 f t t t 1 f 23 "1042" 100 0 0 100 hashbpchar - )); DESCR("hash"); @@ -1332,52 +1332,52 @@ DATA(insert OID = 1081 ( format_type PGUID 12 f t t f 2 f 25 "26 23" 100 0 0 DESCR("format a type oid and atttypmod to canonical SQL"); DATA(insert OID = 1084 ( date_in PGUID 12 f t f t 1 f 1082 "0" 100 0 0 100 date_in - )); DESCR("(internal)"); -DATA(insert OID = 1085 ( date_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 date_out - )); +DATA(insert OID = 1085 ( date_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 date_out - )); DESCR("(internal)"); -DATA(insert OID = 1086 ( date_eq PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_eq - )); +DATA(insert OID = 1086 ( date_eq PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_eq - )); DESCR("equal"); -DATA(insert OID = 1087 ( date_lt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_lt - )); +DATA(insert OID = 1087 ( date_lt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_lt - )); DESCR("less-than"); -DATA(insert OID = 1088 ( date_le PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_le - )); +DATA(insert OID = 1088 ( date_le PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1089 ( date_gt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_gt - )); +DATA(insert OID = 1089 ( date_gt PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_gt - )); DESCR("greater-than"); -DATA(insert OID = 1090 ( date_ge PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ge - )); +DATA(insert OID = 1090 ( date_ge PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1091 ( date_ne PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ne - )); +DATA(insert OID = 1091 ( date_ne PGUID 12 f t t t 2 f 16 "1082 1082" 100 0 0 100 date_ne - )); DESCR("not equal"); -DATA(insert OID = 1092 ( date_cmp PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_cmp - )); +DATA(insert OID = 1092 ( date_cmp PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_cmp - )); DESCR("less-equal-greater"); /* OIDS 1100 - 1199 */ -DATA(insert OID = 1102 ( time_lt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_lt - )); +DATA(insert OID = 1102 ( time_lt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_lt - )); DESCR("less-than"); -DATA(insert OID = 1103 ( time_le PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_le - )); +DATA(insert OID = 1103 ( time_le PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1104 ( time_gt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_gt - )); +DATA(insert OID = 1104 ( time_gt PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_gt - )); DESCR("greater-than"); -DATA(insert OID = 1105 ( time_ge PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ge - )); +DATA(insert OID = 1105 ( time_ge PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1106 ( time_ne PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ne - )); +DATA(insert OID = 1106 ( time_ne PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_ne - )); DESCR("not equal"); -DATA(insert OID = 1107 ( time_cmp PGUID 12 f t t t 2 f 23 "1083 1083" 100 0 0 100 time_cmp - )); +DATA(insert OID = 1107 ( time_cmp PGUID 12 f t t t 2 f 23 "1083 1083" 100 0 0 100 time_cmp - )); DESCR("less-equal-greater"); DATA(insert OID = 1138 ( date_larger PGUID 12 f t t t 2 f 1082 "1082 1082" 100 0 0 100 date_larger - )); DESCR("larger of two"); DATA(insert OID = 1139 ( date_smaller PGUID 12 f t t t 2 f 1082 "1082 1082" 100 0 0 100 date_smaller - )); DESCR("smaller of two"); -DATA(insert OID = 1140 ( date_mi PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_mi - )); +DATA(insert OID = 1140 ( date_mi PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100 date_mi - )); DESCR("subtract"); -DATA(insert OID = 1141 ( date_pli PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_pli - )); +DATA(insert OID = 1141 ( date_pli PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_pli - )); DESCR("add"); -DATA(insert OID = 1142 ( date_mii PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_mii - )); +DATA(insert OID = 1142 ( date_mii PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100 date_mii - )); DESCR("subtract"); DATA(insert OID = 1143 ( time_in PGUID 12 f t f t 1 f 1083 "0" 100 0 0 100 time_in - )); DESCR("(internal)"); -DATA(insert OID = 1144 ( time_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 time_out - )); +DATA(insert OID = 1144 ( time_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 time_out - )); DESCR("(internal)"); -DATA(insert OID = 1145 ( time_eq PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_eq - )); +DATA(insert OID = 1145 ( time_eq PGUID 12 f t t t 2 f 16 "1083 1083" 100 0 0 100 time_eq - )); DESCR("equal"); DATA(insert OID = 1146 ( circle_add_pt PGUID 12 f t t t 2 f 718 "718 600" 100 0 0 100 circle_add_pt - )); @@ -1391,38 +1391,38 @@ DESCR("divide"); DATA(insert OID = 1150 ( timestamptz_in PGUID 12 f t f t 1 f 1184 "0" 100 0 0 100 timestamptz_in - )); DESCR("(internal)"); -DATA(insert OID = 1151 ( timestamptz_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamptz_out - )); +DATA(insert OID = 1151 ( timestamptz_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamptz_out - )); DESCR("(internal)"); -DATA(insert OID = 1152 ( timestamptz_eq PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_eq - )); +DATA(insert OID = 1152 ( timestamptz_eq PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_eq - )); DESCR("equal"); -DATA(insert OID = 1153 ( timestamptz_ne PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ne - )); +DATA(insert OID = 1153 ( timestamptz_ne PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ne - )); DESCR("not equal"); -DATA(insert OID = 1154 ( timestamptz_lt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_lt - )); +DATA(insert OID = 1154 ( timestamptz_lt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_lt - )); DESCR("less-than"); -DATA(insert OID = 1155 ( timestamptz_le PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_le - )); +DATA(insert OID = 1155 ( timestamptz_le PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1156 ( timestamptz_ge PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ge - )); +DATA(insert OID = 1156 ( timestamptz_ge PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1157 ( timestamptz_gt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_gt - )); +DATA(insert OID = 1157 ( timestamptz_gt PGUID 12 f t t t 2 f 16 "1184 1184" 100 0 0 100 timestamp_gt - )); DESCR("greater-than"); DATA(insert OID = 1159 ( timezone PGUID 12 f t f t 2 f 25 "25 1184" 100 0 0 100 timestamptz_zone - )); DESCR("time zone"); DATA(insert OID = 1160 ( interval_in PGUID 12 f t f t 1 f 1186 "0" 100 0 0 100 interval_in - )); DESCR("(internal)"); -DATA(insert OID = 1161 ( interval_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 interval_out - )); +DATA(insert OID = 1161 ( interval_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 interval_out - )); DESCR("(internal)"); -DATA(insert OID = 1162 ( interval_eq PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_eq - )); +DATA(insert OID = 1162 ( interval_eq PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_eq - )); DESCR("equal"); -DATA(insert OID = 1163 ( interval_ne PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ne - )); +DATA(insert OID = 1163 ( interval_ne PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ne - )); DESCR("not equal"); -DATA(insert OID = 1164 ( interval_lt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_lt - )); +DATA(insert OID = 1164 ( interval_lt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_lt - )); DESCR("less-than"); -DATA(insert OID = 1165 ( interval_le PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_le - )); +DATA(insert OID = 1165 ( interval_le PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1166 ( interval_ge PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ge - )); +DATA(insert OID = 1166 ( interval_ge PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1167 ( interval_gt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_gt - )); +DATA(insert OID = 1167 ( interval_gt PGUID 12 f t t t 2 f 16 "1186 1186" 100 0 0 100 interval_gt - )); DESCR("greater-than"); DATA(insert OID = 1168 ( interval_um PGUID 12 f t t t 1 f 1186 "1186" 100 0 0 100 interval_um - )); DESCR("subtract"); @@ -1430,21 +1430,21 @@ DATA(insert OID = 1169 ( interval_pl PGUID 12 f t t t 2 f 1186 "1186 1186" 1 DESCR("add"); DATA(insert OID = 1170 ( interval_mi PGUID 12 f t t t 2 f 1186 "1186 1186" 100 0 0 100 interval_mi - )); DESCR("subtract"); -DATA(insert OID = 1171 ( date_part PGUID 12 f t f t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - )); +DATA(insert OID = 1171 ( date_part PGUID 12 f t f t 2 f 701 "25 1184" 100 0 0 100 timestamptz_part - )); DESCR("extract field from timestamp with time zone"); -DATA(insert OID = 1172 ( date_part PGUID 12 f t t t 2 f 701 "25 1186" 100 0 0 100 interval_part - )); +DATA(insert OID = 1172 ( date_part PGUID 12 f t t t 2 f 701 "25 1186" 100 0 0 100 interval_part - )); DESCR("extract field from interval"); -DATA(insert OID = 1173 ( timestamptz PGUID 12 f t f t 1 f 1184 "702" 100 0 0 100 abstime_timestamptz - )); +DATA(insert OID = 1173 ( timestamptz PGUID 12 f t f t 1 f 1184 "702" 100 0 0 100 abstime_timestamptz - )); DESCR("convert abstime to timestamp with time zone"); DATA(insert OID = 1174 ( timestamptz PGUID 12 f t f t 1 f 1184 "1082" 100 0 0 100 date_timestamptz - )); DESCR("convert date to timestamp with time zone"); DATA(insert OID = 1176 ( timestamptz PGUID 14 f t f t 2 f 1184 "1082 1083" 100 0 0 100 "select timestamptz($1 + $2)" - )); DESCR("convert date and time to timestamp with time zone"); -DATA(insert OID = 1177 ( interval PGUID 12 f t t t 1 f 1186 "703" 100 0 0 100 reltime_interval - )); +DATA(insert OID = 1177 ( interval PGUID 12 f t t t 1 f 1186 "703" 100 0 0 100 reltime_interval - )); DESCR("convert reltime to interval"); DATA(insert OID = 1178 ( date PGUID 12 f t f t 1 f 1082 "1184" 100 0 0 100 timestamptz_date - )); DESCR("convert timestamp with time zone to date"); -DATA(insert OID = 1179 ( date PGUID 12 f t f t 1 f 1082 "702" 100 0 0 100 abstime_date - )); +DATA(insert OID = 1179 ( date PGUID 12 f t f t 1 f 1082 "702" 100 0 0 100 abstime_date - )); DESCR("convert abstime to date"); DATA(insert OID = 1180 ( abstime PGUID 12 f t f t 1 f 702 "1184" 100 0 0 100 timestamptz_abstime - )); DESCR("convert timestamp with time zone to abstime"); @@ -1457,13 +1457,13 @@ DATA(insert OID = 1189 ( timestamptz_pl_span PGUID 12 f t t t 2 f 1184 "1184 11 DESCR("plus"); DATA(insert OID = 1190 ( timestamptz_mi_span PGUID 12 f t t t 2 f 1184 "1184 1186" 100 0 0 100 timestamp_mi_span - )); DESCR("minus"); -DATA(insert OID = 1191 ( timestamptz PGUID 12 f t f t 1 f 1184 "25" 100 0 0 100 text_timestamptz - )); +DATA(insert OID = 1191 ( timestamptz PGUID 12 f t f t 1 f 1184 "25" 100 0 0 100 text_timestamptz - )); DESCR("convert text to timestamp with time zone"); -DATA(insert OID = 1192 ( text PGUID 12 f t f t 1 f 25 "1184" 100 0 0 100 timestamptz_text - )); +DATA(insert OID = 1192 ( text PGUID 12 f t f t 1 f 25 "1184" 100 0 0 100 timestamptz_text - )); DESCR("convert timestamp to text"); -DATA(insert OID = 1193 ( text PGUID 12 f t t t 1 f 25 "1186" 100 0 0 100 interval_text - )); +DATA(insert OID = 1193 ( text PGUID 12 f t t t 1 f 25 "1186" 100 0 0 100 interval_text - )); DESCR("convert interval to text"); -DATA(insert OID = 1194 ( reltime PGUID 12 f t t t 1 f 703 "1186" 100 0 0 100 interval_reltime - )); +DATA(insert OID = 1194 ( reltime PGUID 12 f t t t 1 f 703 "1186" 100 0 0 100 interval_reltime - )); DESCR("convert interval to reltime"); DATA(insert OID = 1195 ( timestamptz_smaller PGUID 12 f t t t 2 f 1184 "1184 1184" 100 0 0 100 timestamp_smaller - )); DESCR("smaller of two"); @@ -1481,14 +1481,14 @@ DESCR("date difference preserving months and years"); DATA(insert OID = 1200 ( reltime PGUID 12 f t t t 1 f 703 "23" 100 0 0 100 int4reltime - )); DESCR("convert int4 to reltime"); -DATA(insert OID = 1215 ( obj_description PGUID 14 f t f t 2 f 25 "26 19" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = $2) and objsubid = 0" - )); +DATA(insert OID = 1215 ( obj_description PGUID 14 f t f t 2 f 25 "26 19" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = $2) and objsubid = 0" - )); DESCR("get description for object id and catalog name"); -DATA(insert OID = 1216 ( col_description PGUID 14 f t f t 2 f 25 "26 23" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = \'pg_class\') and objsubid = $2" - )); +DATA(insert OID = 1216 ( col_description PGUID 14 f t f t 2 f 25 "26 23" 100 0 0 100 "select description from pg_description where objoid = $1 and classoid = (select oid from pg_class where relname = \'pg_class\') and objsubid = $2" - )); DESCR("get description for table column"); -DATA(insert OID = 1217 ( date_trunc PGUID 12 f t t t 2 f 1184 "25 1184" 100 0 0 100 timestamptz_trunc - )); +DATA(insert OID = 1217 ( date_trunc PGUID 12 f t t t 2 f 1184 "25 1184" 100 0 0 100 timestamptz_trunc - )); DESCR("truncate timestamp with time zone to specified units"); -DATA(insert OID = 1218 ( date_trunc PGUID 12 f t t t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - )); +DATA(insert OID = 1218 ( date_trunc PGUID 12 f t t t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - )); DESCR("truncate interval to specified units"); DATA(insert OID = 1219 ( int8inc PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8inc - )); @@ -1496,18 +1496,18 @@ DESCR("increment"); DATA(insert OID = 1230 ( int8abs PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8abs - )); DESCR("absolute value"); -DATA(insert OID = 1236 ( int8larger PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - )); +DATA(insert OID = 1236 ( int8larger PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - )); DESCR("larger of two"); -DATA(insert OID = 1237 ( int8smaller PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - )); +DATA(insert OID = 1237 ( int8smaller PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - )); DESCR("smaller of two"); -DATA(insert OID = 1238 ( texticregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexeq - )); +DATA(insert OID = 1238 ( texticregexeq PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexeq - )); DESCR("matches regex., case-insensitive"); -DATA(insert OID = 1239 ( texticregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexne - )); +DATA(insert OID = 1239 ( texticregexne PGUID 12 f t t t 2 f 16 "25 25" 100 0 0 100 texticregexne - )); DESCR("does not match regex., case-insensitive"); -DATA(insert OID = 1240 ( nameicregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexeq - )); +DATA(insert OID = 1240 ( nameicregexeq PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexeq - )); DESCR("matches regex., case-insensitive"); -DATA(insert OID = 1241 ( nameicregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexne - )); +DATA(insert OID = 1241 ( nameicregexne PGUID 12 f t t t 2 f 16 "19 25" 100 0 0 100 nameicregexne - )); DESCR("does not match regex., case-insensitive"); DATA(insert OID = 1251 ( int4abs PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4abs - )); @@ -1522,23 +1522,23 @@ DATA(insert OID = 1271 ( overlaps PGUID 12 f t t f 4 f 16 "1266 1266 1266 1 DESCR("SQL92 interval comparison"); DATA(insert OID = 1272 ( datetime_pl PGUID 12 f t t t 2 f 1114 "1082 1083" 100 0 0 100 datetime_timestamp - )); DESCR("convert date and time to timestamp"); -DATA(insert OID = 1273 ( date_part PGUID 12 f t t t 2 f 701 "25 1266" 100 0 0 100 timetz_part - )); +DATA(insert OID = 1273 ( date_part PGUID 12 f t t t 2 f 701 "25 1266" 100 0 0 100 timetz_part - )); DESCR("extract field from time with time zone"); -DATA(insert OID = 1274 ( int84pl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - )); +DATA(insert OID = 1274 ( int84pl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - )); DESCR("add"); -DATA(insert OID = 1275 ( int84mi PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - )); +DATA(insert OID = 1275 ( int84mi PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - )); DESCR("subtract"); -DATA(insert OID = 1276 ( int84mul PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - )); +DATA(insert OID = 1276 ( int84mul PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - )); DESCR("multiply"); -DATA(insert OID = 1277 ( int84div PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - )); +DATA(insert OID = 1277 ( int84div PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - )); DESCR("divide"); -DATA(insert OID = 1278 ( int48pl PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - )); +DATA(insert OID = 1278 ( int48pl PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - )); DESCR("add"); -DATA(insert OID = 1279 ( int48mi PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - )); +DATA(insert OID = 1279 ( int48mi PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - )); DESCR("subtract"); -DATA(insert OID = 1280 ( int48mul PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - )); +DATA(insert OID = 1280 ( int48mul PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - )); DESCR("multiply"); -DATA(insert OID = 1281 ( int48div PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - )); +DATA(insert OID = 1281 ( int48div PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - )); DESCR("divide"); DATA(insert OID = 1288 ( text PGUID 12 f t t t 1 f 25 "20" 100 0 0 100 int8_text - )); @@ -1546,16 +1546,16 @@ DESCR("convert int8 to text"); DATA(insert OID = 1289 ( int8 PGUID 12 f t t t 1 f 20 "25" 100 0 0 100 text_int8 - )); DESCR("convert text to int8"); -DATA(insert OID = 1290 ( _bpchar PGUID 12 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - )); +DATA(insert OID = 1290 ( _bpchar PGUID 12 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - )); DESCR("adjust char()[] to typmod length"); -DATA(insert OID = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - )); +DATA(insert OID = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - )); DESCR("adjust varchar()[] to typmod length"); -DATA(insert OID = 1292 ( tideq PGUID 12 f t t t 2 f 16 "27 27" 100 0 0 100 tideq - )); +DATA(insert OID = 1292 ( tideq PGUID 12 f t t t 2 f 16 "27 27" 100 0 0 100 tideq - )); DESCR("equal"); -DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - )); +DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - )); DESCR("latest tid of a tuple"); -DATA(insert OID = 1294 ( currtid2 PGUID 12 f t f t 2 f 27 "25 27" 100 0 0 100 currtid_byrelname - )); +DATA(insert OID = 1294 ( currtid2 PGUID 12 f t f t 2 f 27 "25 27" 100 0 0 100 currtid_byrelname - )); DESCR("latest tid of a tuple"); DATA(insert OID = 1296 ( timedate_pl PGUID 14 f t t t 2 f 1114 "1083 1082" 100 0 0 100 "select ($2 + $1)" - )); @@ -1578,31 +1578,31 @@ DESCR("restriction selectivity for containment comparison operators"); DATA(insert OID = 1303 ( contjoinsel PGUID 12 f t f t 3 f 701 "0 26 0" 100 0 0 100 contjoinsel - )); DESCR("join selectivity for containment comparison operators"); -DATA(insert OID = 1304 ( overlaps PGUID 12 f t t f 4 f 16 "1184 1184 1184 1184" 100 0 0 100 overlaps_timestamp - )); +DATA(insert OID = 1304 ( overlaps PGUID 12 f t t f 4 f 16 "1184 1184 1184 1184" 100 0 0 100 overlaps_timestamp - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1305 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - )); +DATA(insert OID = 1305 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1306 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - )); +DATA(insert OID = 1306 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1184 1184 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1307 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - )); +DATA(insert OID = 1307 ( overlaps PGUID 14 f t t f 4 f 16 "1184 1186 1184 1184" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1308 ( overlaps PGUID 12 f t t f 4 f 16 "1083 1083 1083 1083" 100 0 0 100 overlaps_time - )); +DATA(insert OID = 1308 ( overlaps PGUID 12 f t t f 4 f 16 "1083 1083 1083 1083" 100 0 0 100 overlaps_time - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1309 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - )); +DATA(insert OID = 1309 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1186" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1310 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - )); +DATA(insert OID = 1310 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1083 1083 1186" 100 0 0 100 "select ($1, $2) overlaps ($3, ($3 + $4))" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1311 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - )); +DATA(insert OID = 1311 ( overlaps PGUID 14 f t t f 4 f 16 "1083 1186 1083 1083" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1312 ( timestamp_in PGUID 12 f t f t 1 f 1114 "0" 100 0 0 100 timestamp_in - )); +DATA(insert OID = 1312 ( timestamp_in PGUID 12 f t f t 1 f 1114 "0" 100 0 0 100 timestamp_in - )); DESCR("(internal)"); DATA(insert OID = 1313 ( timestamp_out PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 timestamp_out - )); DESCR("(internal)"); -DATA(insert OID = 1314 ( timestamptz_cmp PGUID 12 f t t t 2 f 23 "1184 1184" 100 0 0 100 timestamp_cmp - )); +DATA(insert OID = 1314 ( timestamptz_cmp PGUID 12 f t t t 2 f 23 "1184 1184" 100 0 0 100 timestamp_cmp - )); DESCR("less-equal-greater"); -DATA(insert OID = 1315 ( interval_cmp PGUID 12 f t t t 2 f 23 "1186 1186" 100 0 0 100 interval_cmp - )); +DATA(insert OID = 1315 ( interval_cmp PGUID 12 f t t t 2 f 23 "1186 1186" 100 0 0 100 interval_cmp - )); DESCR("less-equal-greater"); DATA(insert OID = 1316 ( time PGUID 12 f t t t 1 f 1083 "1114" 100 0 0 100 timestamp_time - )); DESCR("convert timestamp to time"); @@ -1638,7 +1638,7 @@ DESCR("exponential"); /* * This form of obj_description is now deprecated, since it will fail if - * OIDs are not unique across system catalogs. Use the other forms instead. + * OIDs are not unique across system catalogs. Use the other forms instead. */ DATA(insert OID = 1348 ( obj_description PGUID 14 f t f t 1 f 25 "26" 100 0 0 100 "select description from pg_description where objoid = $1 and objsubid = 0" - )); DESCR("get description for object id (deprecated)"); @@ -1648,21 +1648,21 @@ DESCR("print type names of oidvector field"); DATA(insert OID = 1350 ( timetz_in PGUID 12 f t f t 1 f 1266 "0" 100 0 0 100 timetz_in - )); DESCR("(internal)"); -DATA(insert OID = 1351 ( timetz_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 timetz_out - )); +DATA(insert OID = 1351 ( timetz_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 timetz_out - )); DESCR("(internal)"); -DATA(insert OID = 1352 ( timetz_eq PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_eq - )); +DATA(insert OID = 1352 ( timetz_eq PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_eq - )); DESCR("equal"); -DATA(insert OID = 1353 ( timetz_ne PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ne - )); +DATA(insert OID = 1353 ( timetz_ne PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ne - )); DESCR("not equal"); -DATA(insert OID = 1354 ( timetz_lt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_lt - )); +DATA(insert OID = 1354 ( timetz_lt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_lt - )); DESCR("less-than"); -DATA(insert OID = 1355 ( timetz_le PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_le - )); +DATA(insert OID = 1355 ( timetz_le PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1356 ( timetz_ge PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ge - )); +DATA(insert OID = 1356 ( timetz_ge PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1357 ( timetz_gt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_gt - )); +DATA(insert OID = 1357 ( timetz_gt PGUID 12 f t t t 2 f 16 "1266 1266" 100 0 0 100 timetz_gt - )); DESCR("greater-than"); -DATA(insert OID = 1358 ( timetz_cmp PGUID 12 f t t t 2 f 23 "1266 1266" 100 0 0 100 timetz_cmp - )); +DATA(insert OID = 1358 ( timetz_cmp PGUID 12 f t t t 2 f 23 "1266 1266" 100 0 0 100 timetz_cmp - )); DESCR("less-equal-greater"); DATA(insert OID = 1359 ( timestamptz PGUID 12 f t t t 2 f 1184 "1082 1266" 100 0 0 100 datetimetz_timestamptz - )); DESCR("convert date and time with time zone to timestamp with time zone"); @@ -1711,9 +1711,9 @@ DATA(insert OID = 1382 ( date_part PGUID 14 f t f t 2 f 701 "25 702" 100 0 DESCR("extract field from abstime"); DATA(insert OID = 1383 ( date_part PGUID 14 f t f t 2 f 701 "25 703" 100 0 0 100 "select date_part($1, cast($2 as interval))" - )); DESCR("extract field from reltime"); -DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, cast($2 as timestamp without time zone))" - )); +DATA(insert OID = 1384 ( date_part PGUID 14 f t t t 2 f 701 "25 1082" 100 0 0 100 "select date_part($1, cast($2 as timestamp without time zone))" - )); DESCR("extract field from date"); -DATA(insert OID = 1385 ( date_part PGUID 14 f t t t 2 f 701 "25 1083" 100 0 0 100 "select date_part($1, cast($2 as time with time zone))" - )); +DATA(insert OID = 1385 ( date_part PGUID 14 f t t t 2 f 701 "25 1083" 100 0 0 100 "select date_part($1, cast($2 as time with time zone))" - )); DESCR("extract field from time"); DATA(insert OID = 1386 ( age PGUID 14 f t f t 1 f 1186 "1184" 100 0 0 100 "select age(cast(current_date as timestamp with time zone), $1)" - )); DESCR("date difference from today preserving months and years"); @@ -1782,7 +1782,7 @@ DATA(insert OID = 1414 ( isvertical PGUID 12 f t t t 1 f 16 "628" 100 0 0 100 DESCR("lines vertical?"); DATA(insert OID = 1415 ( ishorizontal PGUID 12 f t t t 1 f 16 "628" 100 0 0 100 line_horizontal - )); DESCR("lines horizontal?"); -DATA(insert OID = 1416 ( point PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); +DATA(insert OID = 1416 ( point PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); DESCR("center of"); DATA(insert OID = 1417 ( isnottrue PGUID 12 f t t f 1 f 16 "16" 100 0 0 100 isnottrue - )); @@ -1793,15 +1793,15 @@ DESCR("bool is not false (ie, true or unknown)"); DATA(insert OID = 1419 ( time PGUID 12 f t t t 1 f 1083 "1186" 100 0 0 100 interval_time - )); DESCR("convert interval to time"); -DATA(insert OID = 1421 ( box PGUID 12 f t t t 2 f 603 "600 600" 100 0 0 100 points_box - )); +DATA(insert OID = 1421 ( box PGUID 12 f t t t 2 f 603 "600 600" 100 0 0 100 points_box - )); DESCR("convert points to box"); -DATA(insert OID = 1422 ( box_add PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_add - )); +DATA(insert OID = 1422 ( box_add PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_add - )); DESCR("add point to box (translate)"); -DATA(insert OID = 1423 ( box_sub PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_sub - )); +DATA(insert OID = 1423 ( box_sub PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_sub - )); DESCR("subtract point from box (translate)"); -DATA(insert OID = 1424 ( box_mul PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_mul - )); +DATA(insert OID = 1424 ( box_mul PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_mul - )); DESCR("multiply box by point (scale)"); -DATA(insert OID = 1425 ( box_div PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_div - )); +DATA(insert OID = 1425 ( box_div PGUID 12 f t t t 2 f 603 "603 600" 100 0 0 100 box_div - )); DESCR("divide box by point (scale)"); DATA(insert OID = 1426 ( path_contain_pt PGUID 14 f t t t 2 f 16 "602 600" 100 0 0 100 "select on_ppath($2, $1)" - )); DESCR("path contains point?"); @@ -1821,41 +1821,41 @@ DESCR("# points in path"); * - thomas 97/04/20 */ -DATA(insert OID = 1433 ( pclose PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_close - )); +DATA(insert OID = 1433 ( pclose PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_close - )); DESCR("close path"); -DATA(insert OID = 1434 ( popen PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_open - )); +DATA(insert OID = 1434 ( popen PGUID 12 f t t t 1 f 602 "602" 100 0 0 100 path_open - )); DESCR("open path"); -DATA(insert OID = 1435 ( path_add PGUID 12 f t t t 2 f 602 "602 602" 100 0 0 100 path_add - )); +DATA(insert OID = 1435 ( path_add PGUID 12 f t t t 2 f 602 "602 602" 100 0 0 100 path_add - )); DESCR("concatenate open paths"); -DATA(insert OID = 1436 ( path_add_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_add_pt - )); +DATA(insert OID = 1436 ( path_add_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_add_pt - )); DESCR("add (translate path)"); -DATA(insert OID = 1437 ( path_sub_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_sub_pt - )); +DATA(insert OID = 1437 ( path_sub_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_sub_pt - )); DESCR("subtract (translate path)"); -DATA(insert OID = 1438 ( path_mul_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_mul_pt - )); +DATA(insert OID = 1438 ( path_mul_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_mul_pt - )); DESCR("multiply (rotate/scale path)"); -DATA(insert OID = 1439 ( path_div_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_div_pt - )); +DATA(insert OID = 1439 ( path_div_pt PGUID 12 f t t t 2 f 602 "602 600" 100 0 0 100 path_div_pt - )); DESCR("divide (rotate/scale path)"); -DATA(insert OID = 1440 ( point PGUID 12 f t t t 2 f 600 "701 701" 100 0 0 100 construct_point - )); +DATA(insert OID = 1440 ( point PGUID 12 f t t t 2 f 600 "701 701" 100 0 0 100 construct_point - )); DESCR("convert x, y to point"); -DATA(insert OID = 1441 ( point_add PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_add - )); +DATA(insert OID = 1441 ( point_add PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_add - )); DESCR("add points (translate)"); -DATA(insert OID = 1442 ( point_sub PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_sub - )); +DATA(insert OID = 1442 ( point_sub PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_sub - )); DESCR("subtract points (translate)"); -DATA(insert OID = 1443 ( point_mul PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_mul - )); +DATA(insert OID = 1443 ( point_mul PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_mul - )); DESCR("multiply points (scale/rotate)"); -DATA(insert OID = 1444 ( point_div PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_div - )); +DATA(insert OID = 1444 ( point_div PGUID 12 f t t t 2 f 600 "600 600" 100 0 0 100 point_div - )); DESCR("divide points (scale/rotate)"); DATA(insert OID = 1445 ( poly_npoints PGUID 12 f t t t 1 f 23 "604" 100 0 0 100 poly_npoints - )); DESCR("number of points in polygon"); -DATA(insert OID = 1446 ( box PGUID 12 f t t t 1 f 603 "604" 100 0 0 100 poly_box - )); +DATA(insert OID = 1446 ( box PGUID 12 f t t t 1 f 603 "604" 100 0 0 100 poly_box - )); DESCR("convert polygon to bounding box"); -DATA(insert OID = 1447 ( path PGUID 12 f t t t 1 f 602 "604" 100 0 0 100 poly_path - )); +DATA(insert OID = 1447 ( path PGUID 12 f t t t 1 f 602 "604" 100 0 0 100 poly_path - )); DESCR("convert polygon to path"); -DATA(insert OID = 1448 ( polygon PGUID 12 f t t t 1 f 604 "603" 100 0 0 100 box_poly - )); +DATA(insert OID = 1448 ( polygon PGUID 12 f t t t 1 f 604 "603" 100 0 0 100 box_poly - )); DESCR("convert box to polygon"); -DATA(insert OID = 1449 ( polygon PGUID 12 f t t t 1 f 604 "602" 100 0 0 100 path_poly - )); +DATA(insert OID = 1449 ( polygon PGUID 12 f t t t 1 f 604 "602" 100 0 0 100 path_poly - )); DESCR("convert path to polygon"); DATA(insert OID = 1450 ( circle_in PGUID 12 f t t t 1 f 718 "0" 100 0 0 100 circle_in - )); @@ -1894,31 +1894,31 @@ DATA(insert OID = 1466 ( circle_le PGUID 12 f t t t 2 f 16 "718 718" 100 0 0 DESCR("less-than-or-equal by area"); DATA(insert OID = 1467 ( circle_ge PGUID 12 f t t t 2 f 16 "718 718" 100 0 0 100 circle_ge - )); DESCR("greater-than-or-equal by area"); -DATA(insert OID = 1468 ( area PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_area - )); +DATA(insert OID = 1468 ( area PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_area - )); DESCR("area of circle"); -DATA(insert OID = 1469 ( diameter PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_diameter - )); +DATA(insert OID = 1469 ( diameter PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_diameter - )); DESCR("diameter of circle"); -DATA(insert OID = 1470 ( radius PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_radius - )); +DATA(insert OID = 1470 ( radius PGUID 12 f t t t 1 f 701 "718" 100 0 0 100 circle_radius - )); DESCR("radius of circle"); -DATA(insert OID = 1471 ( circle_distance PGUID 12 f t t t 2 f 701 "718 718" 100 0 0 100 circle_distance - )); +DATA(insert OID = 1471 ( circle_distance PGUID 12 f t t t 2 f 701 "718 718" 100 0 0 100 circle_distance - )); DESCR("distance between"); -DATA(insert OID = 1472 ( circle_center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); +DATA(insert OID = 1472 ( circle_center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); DESCR("center of"); -DATA(insert OID = 1473 ( circle PGUID 12 f t t t 2 f 718 "600 701" 100 0 0 100 cr_circle - )); +DATA(insert OID = 1473 ( circle PGUID 12 f t t t 2 f 718 "600 701" 100 0 0 100 cr_circle - )); DESCR("convert point and radius to circle"); -DATA(insert OID = 1474 ( circle PGUID 12 f t t t 1 f 718 "604" 100 0 0 100 poly_circle - )); +DATA(insert OID = 1474 ( circle PGUID 12 f t t t 1 f 718 "604" 100 0 0 100 poly_circle - )); DESCR("convert polygon to circle"); DATA(insert OID = 1475 ( polygon PGUID 12 f t t t 2 f 604 "23 718" 100 0 0 100 circle_poly - )); DESCR("convert vertex count and circle to polygon"); -DATA(insert OID = 1476 ( dist_pc PGUID 12 f t t t 2 f 701 "600 718" 100 0 0 100 dist_pc - )); +DATA(insert OID = 1476 ( dist_pc PGUID 12 f t t t 2 f 701 "600 718" 100 0 0 100 dist_pc - )); DESCR("distance between point and circle"); DATA(insert OID = 1477 ( circle_contain_pt PGUID 12 f t t t 2 f 16 "718 600" 100 0 0 100 circle_contain_pt - )); DESCR("circle contains point?"); DATA(insert OID = 1478 ( pt_contained_circle PGUID 12 f t t t 2 f 16 "600 718" 100 0 0 100 pt_contained_circle - )); DESCR("point inside circle?"); -DATA(insert OID = 1479 ( circle PGUID 12 f t t t 1 f 718 "603" 100 0 0 100 box_circle - )); +DATA(insert OID = 1479 ( circle PGUID 12 f t t t 1 f 718 "603" 100 0 0 100 box_circle - )); DESCR("convert box to circle"); -DATA(insert OID = 1480 ( box PGUID 12 f t t t 1 f 603 "718" 100 0 0 100 circle_box - )); +DATA(insert OID = 1480 ( box PGUID 12 f t t t 1 f 603 "718" 100 0 0 100 circle_box - )); DESCR("convert circle to box"); DATA(insert OID = 1481 ( tinterval PGUID 12 f t t t 2 f 704 "702 702" 100 0 0 100 mktinterval - )); DESCR("convert to tinterval"); @@ -1933,22 +1933,22 @@ DATA(insert OID = 1485 ( lseg_gt PGUID 12 f t t t 2 f 16 "601 601" 100 0 0 10 DESCR("greater-than by length"); DATA(insert OID = 1486 ( lseg_ge PGUID 12 f t t t 2 f 16 "601 601" 100 0 0 100 lseg_ge - )); DESCR("greater-than-or-equal by length"); -DATA(insert OID = 1487 ( lseg_length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - )); +DATA(insert OID = 1487 ( lseg_length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - )); DESCR("distance between endpoints"); -DATA(insert OID = 1488 ( close_ls PGUID 12 f t t t 2 f 600 "628 601" 100 0 0 100 close_ls - )); +DATA(insert OID = 1488 ( close_ls PGUID 12 f t t t 2 f 600 "628 601" 100 0 0 100 close_ls - )); DESCR("closest point to line on line segment"); -DATA(insert OID = 1489 ( close_lseg PGUID 12 f t t t 2 f 600 "601 601" 100 0 0 100 close_lseg - )); +DATA(insert OID = 1489 ( close_lseg PGUID 12 f t t t 2 f 600 "601 601" 100 0 0 100 close_lseg - )); DESCR("closest point to line segment on line segment"); DATA(insert OID = 1490 ( line_in PGUID 12 f t t t 1 f 628 "0" 100 0 0 100 line_in - )); DESCR("(internal)"); -DATA(insert OID = 1491 ( line_out PGUID 12 f t t t 1 f 23 "628" 100 0 0 100 line_out - )); +DATA(insert OID = 1491 ( line_out PGUID 12 f t t t 1 f 23 "628" 100 0 0 100 line_out - )); DESCR("(internal)"); -DATA(insert OID = 1492 ( line_eq PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_eq - )); +DATA(insert OID = 1492 ( line_eq PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_eq - )); DESCR("lines equal?"); -DATA(insert OID = 1493 ( line PGUID 12 f t t t 2 f 628 "600 600" 100 0 0 100 line_construct_pp - )); +DATA(insert OID = 1493 ( line PGUID 12 f t t t 2 f 628 "600 600" 100 0 0 100 line_construct_pp - )); DESCR("line from points"); -DATA(insert OID = 1494 ( line_interpt PGUID 12 f t t t 2 f 600 "628 628" 100 0 0 100 line_interpt - )); +DATA(insert OID = 1494 ( line_interpt PGUID 12 f t t t 2 f 600 "628 628" 100 0 0 100 line_interpt - )); DESCR("intersection point"); DATA(insert OID = 1495 ( line_intersect PGUID 12 f t t t 2 f 16 "628 628" 100 0 0 100 line_intersect - )); DESCR("lines intersect?"); @@ -1963,27 +1963,27 @@ DESCR("lines horizontal?"); /* OIDS 1500 - 1599 */ -DATA(insert OID = 1530 ( length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - )); +DATA(insert OID = 1530 ( length PGUID 12 f t t t 1 f 701 "601" 100 0 0 100 lseg_length - )); DESCR("distance between endpoints"); -DATA(insert OID = 1531 ( length PGUID 12 f t t t 1 f 701 "602" 100 0 0 100 path_length - )); +DATA(insert OID = 1531 ( length PGUID 12 f t t t 1 f 701 "602" 100 0 0 100 path_length - )); DESCR("sum of path segments"); -DATA(insert OID = 1532 ( point PGUID 12 f t t t 1 f 600 "601" 100 0 0 100 lseg_center - )); +DATA(insert OID = 1532 ( point PGUID 12 f t t t 1 f 600 "601" 100 0 0 100 lseg_center - )); DESCR("center of"); -DATA(insert OID = 1533 ( point PGUID 12 f t t t 1 f 600 "602" 100 0 0 100 path_center - )); +DATA(insert OID = 1533 ( point PGUID 12 f t t t 1 f 600 "602" 100 0 0 100 path_center - )); DESCR("center of"); -DATA(insert OID = 1534 ( point PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - )); +DATA(insert OID = 1534 ( point PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - )); DESCR("center of"); -DATA(insert OID = 1540 ( point PGUID 12 f t t t 1 f 600 "604" 100 0 0 100 poly_center - )); +DATA(insert OID = 1540 ( point PGUID 12 f t t t 1 f 600 "604" 100 0 0 100 poly_center - )); DESCR("center of"); -DATA(insert OID = 1541 ( lseg PGUID 12 f t t t 1 f 601 "603" 100 0 0 100 box_diagonal - )); +DATA(insert OID = 1541 ( lseg PGUID 12 f t t t 1 f 601 "603" 100 0 0 100 box_diagonal - )); DESCR("diagonal of"); -DATA(insert OID = 1542 ( center PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - )); +DATA(insert OID = 1542 ( center PGUID 12 f t t t 1 f 600 "603" 100 0 0 100 box_center - )); DESCR("center of"); -DATA(insert OID = 1543 ( center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); +DATA(insert OID = 1543 ( center PGUID 12 f t t t 1 f 600 "718" 100 0 0 100 circle_center - )); DESCR("center of"); -DATA(insert OID = 1544 ( polygon PGUID 14 f t t t 1 f 604 "718" 100 0 0 100 "select polygon(12, $1)" - )); +DATA(insert OID = 1544 ( polygon PGUID 14 f t t t 1 f 604 "718" 100 0 0 100 "select polygon(12, $1)" - )); DESCR("convert circle to 12-vertex polygon"); DATA(insert OID = 1545 ( npoints PGUID 12 f t t t 1 f 23 "602" 100 0 0 100 path_npoints - )); DESCR("# points in path"); @@ -2014,7 +2014,7 @@ DATA(insert OID = 1575 ( currval PGUID 12 f t f t 1 f 20 "25" 100 0 0 100 cu DESCR("sequence current value"); DATA(insert OID = 1576 ( setval PGUID 12 f t f t 2 f 20 "25 20" 100 0 0 100 setval - )); DESCR("set sequence value"); -DATA(insert OID = 1765 ( setval PGUID 12 f t f t 3 f 20 "25 20 16" 100 0 0 100 setval_and_iscalled - )); +DATA(insert OID = 1765 ( setval PGUID 12 f t f t 3 f 20 "25 20 16" 100 0 0 100 setval_and_iscalled - )); DESCR("set sequence value and iscalled status"); DATA(insert OID = 1579 ( varbit_in PGUID 12 f t t t 1 f 1562 "0" 100 0 0 100 varbit_in - )); @@ -2039,37 +2039,37 @@ DESCR("compare"); DATA(insert OID = 1598 ( random PGUID 12 f t f t 0 f 701 "0" 100 0 0 100 drandom - )); DESCR("random value"); -DATA(insert OID = 1599 ( setseed PGUID 12 f t f t 1 f 23 "701" 100 0 0 100 setseed - )); +DATA(insert OID = 1599 ( setseed PGUID 12 f t f t 1 f 23 "701" 100 0 0 100 setseed - )); DESCR("set random seed"); /* OIDS 1600 - 1699 */ -DATA(insert OID = 1600 ( asin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dasin - )); +DATA(insert OID = 1600 ( asin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dasin - )); DESCR("arcsine"); -DATA(insert OID = 1601 ( acos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dacos - )); +DATA(insert OID = 1601 ( acos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dacos - )); DESCR("arccosine"); -DATA(insert OID = 1602 ( atan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 datan - )); +DATA(insert OID = 1602 ( atan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 datan - )); DESCR("arctangent"); -DATA(insert OID = 1603 ( atan2 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100 datan2 - )); +DATA(insert OID = 1603 ( atan2 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100 datan2 - )); DESCR("arctangent, two arguments"); -DATA(insert OID = 1604 ( sin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dsin - )); +DATA(insert OID = 1604 ( sin PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dsin - )); DESCR("sine"); -DATA(insert OID = 1605 ( cos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcos - )); +DATA(insert OID = 1605 ( cos PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcos - )); DESCR("cosine"); -DATA(insert OID = 1606 ( tan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dtan - )); +DATA(insert OID = 1606 ( tan PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dtan - )); DESCR("tangent"); -DATA(insert OID = 1607 ( cot PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcot - )); +DATA(insert OID = 1607 ( cot PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 dcot - )); DESCR("cotangent"); -DATA(insert OID = 1608 ( degrees PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 degrees - )); +DATA(insert OID = 1608 ( degrees PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 degrees - )); DESCR("radians to degrees"); -DATA(insert OID = 1609 ( radians PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 radians - )); +DATA(insert OID = 1609 ( radians PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 radians - )); DESCR("degrees to radians"); DATA(insert OID = 1610 ( pi PGUID 12 f t t t 0 f 701 "0" 100 0 0 100 dpi - )); DESCR("PI"); DATA(insert OID = 1618 ( interval_mul PGUID 12 f t t t 2 f 1186 "1186 701" 100 0 0 100 interval_mul - )); DESCR("multiply interval"); -DATA(insert OID = 1619 ( varchar PGUID 12 f t t t 1 f 1043 "23" 100 0 0 100 int4_text - )); +DATA(insert OID = 1619 ( varchar PGUID 12 f t t t 1 f 1043 "23" 100 0 0 100 int4_text - )); DESCR("convert int4 to varchar"); DATA(insert OID = 1620 ( ascii PGUID 12 f t t t 1 f 23 "25" 100 0 0 100 ascii - )); @@ -2079,7 +2079,7 @@ DESCR("convert int4 to char"); DATA(insert OID = 1622 ( repeat PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 repeat - )); DESCR("replicate string int4 times"); -DATA(insert OID = 1623 ( varchar PGUID 12 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - )); +DATA(insert OID = 1623 ( varchar PGUID 12 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - )); DESCR("convert int8 to varchar"); DATA(insert OID = 1624 ( mul_d_interval PGUID 12 f t t t 2 f 1186 "701 1186" 100 0 0 100 mul_d_interval - )); @@ -2098,7 +2098,7 @@ DATA(insert OID = 1689 ( update_pg_pwd PGUID 12 f t f t 0 f 0 "" 100 0 0 1 DESCR("update pg_pwd file"); /* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */ -DATA(insert OID = 868 ( strpos PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 textpos - )); +DATA(insert OID = 868 ( strpos PGUID 12 f t t t 2 f 23 "25 25" 100 0 0 100 textpos - )); DESCR("find position of substring"); DATA(insert OID = 870 ( lower PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 lower - )); DESCR("lowercase"); @@ -2110,45 +2110,45 @@ DATA(insert OID = 873 ( lpad PGUID 12 f t t t 3 f 25 "25 23 25" 100 0 0 10 DESCR("left-pad string to length"); DATA(insert OID = 874 ( rpad PGUID 12 f t t t 3 f 25 "25 23 25" 100 0 0 100 rpad - )); DESCR("right-pad string to length"); -DATA(insert OID = 875 ( ltrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - )); +DATA(insert OID = 875 ( ltrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - )); DESCR("left-pad string to length"); -DATA(insert OID = 876 ( rtrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - )); +DATA(insert OID = 876 ( rtrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - )); DESCR("right-pad string to length"); DATA(insert OID = 877 ( substr PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - )); DESCR("return portion of string"); DATA(insert OID = 878 ( translate PGUID 12 f t t t 3 f 25 "25 25 25" 100 0 0 100 translate - )); DESCR("map a set of character appearing in string"); -DATA(insert OID = 879 ( lpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select lpad($1, $2, \' \')" - )); +DATA(insert OID = 879 ( lpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select lpad($1, $2, \' \')" - )); DESCR("left-pad string to length"); -DATA(insert OID = 880 ( rpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select rpad($1, $2, \' \')" - )); +DATA(insert OID = 880 ( rpad PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select rpad($1, $2, \' \')" - )); DESCR("right-pad string to length"); DATA(insert OID = 881 ( ltrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select ltrim($1, \' \')" - )); DESCR("remove initial characters from string"); DATA(insert OID = 882 ( rtrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select rtrim($1, \' \')" - )); DESCR("remove trailing characters from string"); -DATA(insert OID = 883 ( substr PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substr($1, $2, -1)" - )); +DATA(insert OID = 883 ( substr PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substr($1, $2, -1)" - )); DESCR("return portion of string"); -DATA(insert OID = 884 ( btrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 btrim - )); +DATA(insert OID = 884 ( btrim PGUID 12 f t t t 2 f 25 "25 25" 100 0 0 100 btrim - )); DESCR("trim both ends of string"); DATA(insert OID = 885 ( btrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "select btrim($1, \' \')" - )); DESCR("trim both ends of string"); DATA(insert OID = 936 ( substring PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - )); DESCR("return portion of string"); -DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substring($1, $2, -1)" - )); +DATA(insert OID = 937 ( substring PGUID 14 f t t t 2 f 25 "25 23" 100 0 0 100 "select substring($1, $2, -1)" - )); DESCR("return portion of string"); /* for multi-byte support */ /* return database encoding name */ -DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - )); +DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - )); DESCR("encoding name of current database"); /* return client encoding name i.e. session encoding */ -DATA(insert OID = 810 ( pg_client_encoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 pg_client_encoding - )); +DATA(insert OID = 810 ( pg_client_encoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 pg_client_encoding - )); DESCR("encoding name of current database"); -DATA(insert OID = 1717 ( convert PGUID 12 f t f t 2 f 25 "25 19" 100 0 0 100 pg_convert - )); +DATA(insert OID = 1717 ( convert PGUID 12 f t f t 2 f 25 "25 19" 100 0 0 100 pg_convert - )); DESCR("convert string with specified destination encoding name"); DATA(insert OID = 1813 ( convert PGUID 12 f t f t 3 f 25 "25 19 19" 100 0 0 100 pg_convert2 - )); @@ -2160,9 +2160,9 @@ DESCR("convert encoding name to encoding id"); DATA(insert OID = 1597 ( pg_encoding_to_char PGUID 12 f t f t 1 f 19 "23" 100 0 0 100 PG_encoding_to_char - )); DESCR("convert encoding id to encoding name"); -DATA(insert OID = 1638 ( oidgt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidgt - )); +DATA(insert OID = 1638 ( oidgt PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidgt - )); DESCR("greater-than"); -DATA(insert OID = 1639 ( oidge PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidge - )); +DATA(insert OID = 1639 ( oidge PGUID 12 f t t t 2 f 16 "26 26" 100 0 0 100 oidge - )); DESCR("greater-than-or-equal"); /* System-view support functions */ @@ -2174,7 +2174,7 @@ DATA(insert OID = 1642 ( pg_get_userbyid PGUID 12 f t f t 1 f 19 "23" 100 0 DESCR("user name by UID (with fallback)"); DATA(insert OID = 1643 ( pg_get_indexdef PGUID 12 f t f t 1 f 25 "26" 100 0 0 100 pg_get_indexdef - )); DESCR("index description"); -DATA(insert OID = 1716 ( pg_get_expr PGUID 12 f t f t 2 f 25 "25 26" 100 0 0 100 pg_get_expr - )); +DATA(insert OID = 1716 ( pg_get_expr PGUID 12 f t f t 2 f 25 "25 26" 100 0 0 100 pg_get_expr - )); DESCR("deparse an encoded expression"); @@ -2195,9 +2195,9 @@ DATA(insert OID = 1650 ( RI_FKey_setnull_del PGUID 12 f t f t 0 f 0 "" 100 0 0 DESCR("referential integrity ON DELETE SET NULL"); DATA(insert OID = 1651 ( RI_FKey_setnull_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setnull_upd - )); DESCR("referential integrity ON UPDATE SET NULL"); -DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_del - )); +DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_del - )); DESCR("referential integrity ON DELETE SET DEFAULT"); -DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_upd - )); +DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_upd - )); DESCR("referential integrity ON UPDATE SET DEFAULT"); DATA(insert OID = 1654 ( RI_FKey_noaction_del PGUID 12 f t f t 0 f 0 "" 100 0 0 100 RI_FKey_noaction_del - )); DESCR("referential integrity ON DELETE NO ACTION"); @@ -2233,24 +2233,24 @@ DATA(insert OID = 1678 ( bitshiftright PGUID 12 f t t t 2 f 1560 "1560 23" 100 DESCR("bitwise right shift"); DATA(insert OID = 1679 ( bitcat PGUID 12 f t t t 2 f 1560 "1560 1560" 100 0 0 100 bitcat - )); DESCR("bitwise concatenation"); -DATA(insert OID = 1680 ( substring PGUID 12 f t t t 3 f 1560 "1560 23 23" 100 0 0 100 bitsubstr - )); +DATA(insert OID = 1680 ( substring PGUID 12 f t t t 3 f 1560 "1560 23 23" 100 0 0 100 bitsubstr - )); DESCR("return portion of bitstring"); -DATA(insert OID = 1681 ( length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitlength - )); +DATA(insert OID = 1681 ( length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitlength - )); DESCR("bitstring length"); -DATA(insert OID = 1682 ( octet_length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitoctetlength - )); +DATA(insert OID = 1682 ( octet_length PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bitoctetlength - )); DESCR("octet length"); -DATA(insert OID = 1683 ( bitfromint4 PGUID 12 f t t t 1 f 1560 "23" 100 0 0 100 bitfromint4 - )); +DATA(insert OID = 1683 ( bitfromint4 PGUID 12 f t t t 1 f 1560 "23" 100 0 0 100 bitfromint4 - )); DESCR("int4 to bitstring"); -DATA(insert OID = 1684 ( bittoint4 PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bittoint4 - )); +DATA(insert OID = 1684 ( bittoint4 PGUID 12 f t t t 1 f 23 "1560" 100 0 0 100 bittoint4 - )); DESCR("bitstring to int4"); -DATA(insert OID = 1685 ( bit PGUID 12 f t t t 2 f 1560 "1560 23" 100 0 0 100 bit - )); +DATA(insert OID = 1685 ( bit PGUID 12 f t t t 2 f 1560 "1560 23" 100 0 0 100 bit - )); DESCR("adjust bit() to typmod length"); -DATA(insert OID = 1686 ( _bit PGUID 12 f t t t 2 f 1561 "1561 23" 100 0 0 100 _bit - )); +DATA(insert OID = 1686 ( _bit PGUID 12 f t t t 2 f 1561 "1561 23" 100 0 0 100 _bit - )); DESCR("adjust bit()[] to typmod length"); -DATA(insert OID = 1687 ( varbit PGUID 12 f t t t 2 f 1562 "1562 23" 100 0 0 100 varbit - )); +DATA(insert OID = 1687 ( varbit PGUID 12 f t t t 2 f 1562 "1562 23" 100 0 0 100 varbit - )); DESCR("adjust varbit() to typmod length"); -DATA(insert OID = 1688 ( _varbit PGUID 12 f t t t 2 f 1563 "1563 23" 100 0 0 100 _varbit - )); +DATA(insert OID = 1688 ( _varbit PGUID 12 f t t t 2 f 1563 "1563 23" 100 0 0 100 _varbit - )); DESCR("adjust varbit()[] to typmod length"); DATA(insert OID = 1698 ( position PGUID 12 f t t t 2 f 23 "1560 1560" 100 0 0 100 bitposition - )); @@ -2267,7 +2267,7 @@ DESCR("(internal)"); DATA(insert OID = 752 ( text PGUID 12 f t t t 1 f 25 "829" 100 0 0 100 macaddr_text - )); DESCR("MAC address to text"); -DATA(insert OID = 753 ( trunc PGUID 12 f t t t 1 f 829 "829" 100 0 0 100 macaddr_trunc - )); +DATA(insert OID = 753 ( trunc PGUID 12 f t t t 1 f 829 "829" 100 0 0 100 macaddr_trunc - )); DESCR("MAC manufacturer fields"); DATA(insert OID = 767 ( macaddr PGUID 12 f t t t 1 f 829 "25" 100 0 0 100 text_macaddr - )); DESCR("text to MAC address"); @@ -2326,13 +2326,13 @@ DESCR("is-supernet-or-equal"); /* inet/cidr functions */ DATA(insert OID = 605 ( abbrev PGUID 12 f t t t 1 f 25 "869" 100 0 0 100 network_abbrev - )); DESCR("abbreviated display of inet/cidr value"); -DATA(insert OID = 683 ( network PGUID 12 f t t t 1 f 650 "869" 100 0 0 100 network_network - )); +DATA(insert OID = 683 ( network PGUID 12 f t t t 1 f 650 "869" 100 0 0 100 network_network - )); DESCR("network part of address"); -DATA(insert OID = 696 ( netmask PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_netmask - )); +DATA(insert OID = 696 ( netmask PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_netmask - )); DESCR("netmask of address"); DATA(insert OID = 697 ( masklen PGUID 12 f t t t 1 f 23 "869" 100 0 0 100 network_masklen - )); DESCR("netmask length"); -DATA(insert OID = 698 ( broadcast PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_broadcast - )); +DATA(insert OID = 698 ( broadcast PGUID 12 f t t t 1 f 869 "869" 100 0 0 100 network_broadcast - )); DESCR("broadcast address of network"); DATA(insert OID = 699 ( host PGUID 12 f t t t 1 f 25 "869" 100 0 0 100 network_host - )); DESCR("show address octets only"); @@ -2355,9 +2355,9 @@ DESCR("greater-than-or-equal"); DATA(insert OID = 1693 ( btboolcmp PGUID 12 f t t t 2 f 23 "16 16" 100 0 0 100 btboolcmp - )); DESCR("btree less-equal-greater"); -DATA(insert OID = 1696 ( timetz_hash PGUID 12 f t t t 1 f 23 "1266" 100 0 0 100 timetz_hash - )); +DATA(insert OID = 1696 ( timetz_hash PGUID 12 f t t t 1 f 23 "1266" 100 0 0 100 timetz_hash - )); DESCR("hash"); -DATA(insert OID = 1697 ( interval_hash PGUID 12 f t t t 1 f 23 "1186" 100 0 0 100 interval_hash - )); +DATA(insert OID = 1697 ( interval_hash PGUID 12 f t t t 1 f 23 "1186" 100 0 0 100 interval_hash - )); DESCR("hash"); @@ -2430,7 +2430,7 @@ DATA(insert OID = 1738 ( pow PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 1 DESCR("m raised to the power of n"); DATA(insert OID = 1739 ( numeric_power PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100 numeric_power - )); DESCR("m raised to the power of n"); -DATA(insert OID = 1740 ( numeric PGUID 12 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - )); +DATA(insert OID = 1740 ( numeric PGUID 12 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - )); DESCR("(internal)"); DATA(insert OID = 1741 ( log PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select log(10, $1)" - )); DESCR("logarithm base 10 of n"); @@ -2438,7 +2438,7 @@ DATA(insert OID = 1742 ( numeric PGUID 12 f t t t 1 f 1700 "700" 100 0 0 100 DESCR("(internal)"); DATA(insert OID = 1743 ( numeric PGUID 12 f t t t 1 f 1700 "701" 100 0 0 100 float8_numeric - )); DESCR("(internal)"); -DATA(insert OID = 1744 ( int4 PGUID 12 f t t t 1 f 23 "1700" 100 0 0 100 numeric_int4 - )); +DATA(insert OID = 1744 ( int4 PGUID 12 f t t t 1 f 23 "1700" 100 0 0 100 numeric_int4 - )); DESCR("(internal)"); DATA(insert OID = 1745 ( float4 PGUID 12 f t t t 1 f 700 "1700" 100 0 0 100 numeric_float4 - )); DESCR("(internal)"); @@ -2464,13 +2464,13 @@ DATA(insert OID = 1769 ( numeric_cmp PGUID 12 f t t t 2 f 23 "1700 1700" 100 0 DESCR("compare two numbers"); DATA(insert OID = 1771 ( numeric_uminus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uminus - )); DESCR("negate"); -DATA(insert OID = 1779 ( int8 PGUID 12 f t t t 1 f 20 "1700" 100 0 0 100 numeric_int8 - )); +DATA(insert OID = 1779 ( int8 PGUID 12 f t t t 1 f 20 "1700" 100 0 0 100 numeric_int8 - )); DESCR("(internal)"); -DATA(insert OID = 1781 ( numeric PGUID 12 f t t t 1 f 1700 "20" 100 0 0 100 int8_numeric - )); +DATA(insert OID = 1781 ( numeric PGUID 12 f t t t 1 f 1700 "20" 100 0 0 100 int8_numeric - )); DESCR("(internal)"); -DATA(insert OID = 1782 ( numeric PGUID 12 f t t t 1 f 1700 "21" 100 0 0 100 int2_numeric - )); +DATA(insert OID = 1782 ( numeric PGUID 12 f t t t 1 f 1700 "21" 100 0 0 100 int2_numeric - )); DESCR("(internal)"); -DATA(insert OID = 1783 ( int2 PGUID 12 f t t t 1 f 21 "1700" 100 0 0 100 numeric_int2 - )); +DATA(insert OID = 1783 ( int2 PGUID 12 f t t t 1 f 21 "1700" 100 0 0 100 numeric_int2 - )); DESCR("(internal)"); /* formatting */ @@ -2478,9 +2478,9 @@ DATA(insert OID = 1770 ( to_char PGUID 12 f t f t 2 f 25 "1184 25" 100 0 0 100 DESCR("format timestamp with time zone to text"); DATA(insert OID = 1772 ( to_char PGUID 12 f t t t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - )); DESCR("format numeric to text"); -DATA(insert OID = 1773 ( to_char PGUID 12 f t t t 2 f 25 "23 25" 100 0 0 100 int4_to_char - )); +DATA(insert OID = 1773 ( to_char PGUID 12 f t t t 2 f 25 "23 25" 100 0 0 100 int4_to_char - )); DESCR("format int4 to text"); -DATA(insert OID = 1774 ( to_char PGUID 12 f t t t 2 f 25 "20 25" 100 0 0 100 int8_to_char - )); +DATA(insert OID = 1774 ( to_char PGUID 12 f t t t 2 f 25 "20 25" 100 0 0 100 int8_to_char - )); DESCR("format int8 to text"); DATA(insert OID = 1775 ( to_char PGUID 12 f t t t 2 f 25 "700 25" 100 0 0 100 float4_to_char - )); DESCR("format float4 to text"); @@ -2500,17 +2500,17 @@ DESCR("quote an identifier for usage in a querystring"); DATA(insert OID = 1283 ( quote_literal PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 quote_literal - )); DESCR("quote a literal for usage in a querystring"); -DATA(insert OID = 1798 ( oidin PGUID 12 f t t t 1 f 26 "0" 100 0 0 100 oidin - )); +DATA(insert OID = 1798 ( oidin PGUID 12 f t t t 1 f 26 "0" 100 0 0 100 oidin - )); DESCR("(internal)"); -DATA(insert OID = 1799 ( oidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidout - )); +DATA(insert OID = 1799 ( oidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 oidout - )); DESCR("(internal)"); -DATA(insert OID = 1810 ( bit_length PGUID 14 f t t t 1 f 23 "17" 100 0 0 100 "select octet_length($1) * 8" - )); +DATA(insert OID = 1810 ( bit_length PGUID 14 f t t t 1 f 23 "17" 100 0 0 100 "select octet_length($1) * 8" - )); DESCR("length in bits"); -DATA(insert OID = 1811 ( bit_length PGUID 14 f t t t 1 f 23 "25" 100 0 0 100 "select octet_length($1) * 8" - )); +DATA(insert OID = 1811 ( bit_length PGUID 14 f t t t 1 f 23 "25" 100 0 0 100 "select octet_length($1) * 8" - )); DESCR("length in bits"); -DATA(insert OID = 1812 ( bit_length PGUID 14 f t t t 1 f 23 "1560" 100 0 0 100 "select length($1)" - )); +DATA(insert OID = 1812 ( bit_length PGUID 14 f t t t 1 f 23 "1560" 100 0 0 100 "select length($1)" - )); DESCR("length in bits"); /* Selectivity estimators for LIKE and related operators */ @@ -2548,19 +2548,19 @@ DATA(insert OID = 1829 ( icregexnejoinsel PGUID 12 f t f t 3 f 701 "0 26 0" 100 DESCR("join selectivity of case-insensitive regex non-match"); /* Aggregate-related functions */ -DATA(insert OID = 1830 ( float8_avg PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_avg - )); +DATA(insert OID = 1830 ( float8_avg PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_avg - )); DESCR("AVG aggregate final function"); -DATA(insert OID = 1831 ( float8_variance PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_variance - )); +DATA(insert OID = 1831 ( float8_variance PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_variance - )); DESCR("VARIANCE aggregate final function"); -DATA(insert OID = 1832 ( float8_stddev PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_stddev - )); +DATA(insert OID = 1832 ( float8_stddev PGUID 12 f t t t 1 f 701 "1022" 100 0 0 100 float8_stddev - )); DESCR("STDDEV aggregate final function"); DATA(insert OID = 1833 ( numeric_accum PGUID 12 f t t t 2 f 1231 "1231 1700" 100 0 0 100 numeric_accum - )); DESCR("aggregate transition function"); -DATA(insert OID = 1834 ( int2_accum PGUID 12 f t t t 2 f 1231 "1231 21" 100 0 0 100 int2_accum - )); +DATA(insert OID = 1834 ( int2_accum PGUID 12 f t t t 2 f 1231 "1231 21" 100 0 0 100 int2_accum - )); DESCR("aggregate transition function"); -DATA(insert OID = 1835 ( int4_accum PGUID 12 f t t t 2 f 1231 "1231 23" 100 0 0 100 int4_accum - )); +DATA(insert OID = 1835 ( int4_accum PGUID 12 f t t t 2 f 1231 "1231 23" 100 0 0 100 int4_accum - )); DESCR("aggregate transition function"); -DATA(insert OID = 1836 ( int8_accum PGUID 12 f t t t 2 f 1231 "1231 20" 100 0 0 100 int8_accum - )); +DATA(insert OID = 1836 ( int8_accum PGUID 12 f t t t 2 f 1231 "1231 20" 100 0 0 100 int8_accum - )); DESCR("aggregate transition function"); DATA(insert OID = 1837 ( numeric_avg PGUID 12 f t t t 1 f 1700 "1231" 100 0 0 100 numeric_avg - )); DESCR("AVG aggregate final function"); @@ -2568,19 +2568,19 @@ DATA(insert OID = 1838 ( numeric_variance PGUID 12 f t t t 1 f 1700 "1231" 100 DESCR("VARIANCE aggregate final function"); DATA(insert OID = 1839 ( numeric_stddev PGUID 12 f t t t 1 f 1700 "1231" 100 0 0 100 numeric_stddev - )); DESCR("STDDEV aggregate final function"); -DATA(insert OID = 1840 ( int2_sum PGUID 12 f t t f 2 f 20 "20 21" 100 0 0 100 int2_sum - )); +DATA(insert OID = 1840 ( int2_sum PGUID 12 f t t f 2 f 20 "20 21" 100 0 0 100 int2_sum - )); DESCR("SUM(int2) transition function"); -DATA(insert OID = 1841 ( int4_sum PGUID 12 f t t f 2 f 20 "20 23" 100 0 0 100 int4_sum - )); +DATA(insert OID = 1841 ( int4_sum PGUID 12 f t t f 2 f 20 "20 23" 100 0 0 100 int4_sum - )); DESCR("SUM(int4) transition function"); -DATA(insert OID = 1842 ( int8_sum PGUID 12 f t t f 2 f 1700 "1700 20" 100 0 0 100 int8_sum - )); +DATA(insert OID = 1842 ( int8_sum PGUID 12 f t t f 2 f 1700 "1700 20" 100 0 0 100 int8_sum - )); DESCR("SUM(int8) transition function"); DATA(insert OID = 1843 ( interval_accum PGUID 12 f t t t 2 f 1187 "1187 1186" 100 0 0 100 interval_accum - )); DESCR("aggregate transition function"); DATA(insert OID = 1844 ( interval_avg PGUID 12 f t t t 1 f 1186 "1187" 100 0 0 100 interval_avg - )); DESCR("AVG aggregate final function"); -DATA(insert OID = 1962 ( int2_avg_accum PGUID 12 f t t t 2 f 1016 "1016 21" 100 0 0 100 int2_avg_accum - )); +DATA(insert OID = 1962 ( int2_avg_accum PGUID 12 f t t t 2 f 1016 "1016 21" 100 0 0 100 int2_avg_accum - )); DESCR("AVG(int2) transition function"); -DATA(insert OID = 1963 ( int4_avg_accum PGUID 12 f t t t 2 f 1016 "1016 23" 100 0 0 100 int4_avg_accum - )); +DATA(insert OID = 1963 ( int4_avg_accum PGUID 12 f t t t 2 f 1016 "1016 23" 100 0 0 100 int4_avg_accum - )); DESCR("AVG(int4) transition function"); DATA(insert OID = 1964 ( int8_avg PGUID 12 f t t t 1 f 1700 "1016" 100 0 0 100 int8_avg - )); DESCR("AVG(int) aggregate final function"); @@ -2588,90 +2588,90 @@ DESCR("AVG(int) aggregate final function"); /* To ASCII conversion */ DATA(insert OID = 1845 ( to_ascii PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 to_ascii_default - )); DESCR("encode text from DB encoding to ASCII text"); -DATA(insert OID = 1846 ( to_ascii PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 to_ascii_enc - )); +DATA(insert OID = 1846 ( to_ascii PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 to_ascii_enc - )); DESCR("encode text from encoding to ASCII text"); -DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - )); +DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - )); DESCR("encode text from encoding to ASCII text"); DATA(insert OID = 1848 ( interval_pl_time PGUID 12 f t t t 2 f 1083 "1186 1083" 100 0 0 100 interval_pl_time - )); DESCR("plus"); -DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - )); +DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - )); DESCR("equal"); -DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - )); +DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - )); DESCR("not equal"); -DATA(insert OID = 1852 ( int28lt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28lt - )); +DATA(insert OID = 1852 ( int28lt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28lt - )); DESCR("less-than"); -DATA(insert OID = 1853 ( int28gt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28gt - )); +DATA(insert OID = 1853 ( int28gt PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28gt - )); DESCR("greater-than"); -DATA(insert OID = 1854 ( int28le PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28le - )); +DATA(insert OID = 1854 ( int28le PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1855 ( int28ge PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ge - )); +DATA(insert OID = 1855 ( int28ge PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1856 ( int82eq PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82eq - )); +DATA(insert OID = 1856 ( int82eq PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82eq - )); DESCR("equal"); -DATA(insert OID = 1857 ( int82ne PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ne - )); +DATA(insert OID = 1857 ( int82ne PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ne - )); DESCR("not equal"); -DATA(insert OID = 1858 ( int82lt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82lt - )); +DATA(insert OID = 1858 ( int82lt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82lt - )); DESCR("less-than"); -DATA(insert OID = 1859 ( int82gt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82gt - )); +DATA(insert OID = 1859 ( int82gt PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82gt - )); DESCR("greater-than"); -DATA(insert OID = 1860 ( int82le PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82le - )); +DATA(insert OID = 1860 ( int82le PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1861 ( int82ge PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ge - )); +DATA(insert OID = 1861 ( int82ge PGUID 12 f t t t 2 f 16 "20 21" 100 0 0 100 int82ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1892 ( int2and PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2and - )); +DATA(insert OID = 1892 ( int2and PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2and - )); DESCR("binary and"); -DATA(insert OID = 1893 ( int2or PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2or - )); +DATA(insert OID = 1893 ( int2or PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2or - )); DESCR("binary or"); -DATA(insert OID = 1894 ( int2xor PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2xor - )); +DATA(insert OID = 1894 ( int2xor PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100 int2xor - )); DESCR("binary xor"); DATA(insert OID = 1895 ( int2not PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2not - )); DESCR("binary not"); -DATA(insert OID = 1896 ( int2shl PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shl - )); +DATA(insert OID = 1896 ( int2shl PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shl - )); DESCR("binary shift left"); -DATA(insert OID = 1897 ( int2shr PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shr - )); +DATA(insert OID = 1897 ( int2shr PGUID 12 f t t t 2 f 21 "21 23" 100 0 0 100 int2shr - )); DESCR("binary shift right"); -DATA(insert OID = 1898 ( int4and PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4and - )); +DATA(insert OID = 1898 ( int4and PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4and - )); DESCR("binary and"); -DATA(insert OID = 1899 ( int4or PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4or - )); +DATA(insert OID = 1899 ( int4or PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4or - )); DESCR("binary or"); -DATA(insert OID = 1900 ( int4xor PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4xor - )); +DATA(insert OID = 1900 ( int4xor PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4xor - )); DESCR("binary xor"); DATA(insert OID = 1901 ( int4not PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4not - )); DESCR("binary not"); -DATA(insert OID = 1902 ( int4shl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shl - )); +DATA(insert OID = 1902 ( int4shl PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shl - )); DESCR("binary shift left"); -DATA(insert OID = 1903 ( int4shr PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shr - )); +DATA(insert OID = 1903 ( int4shr PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100 int4shr - )); DESCR("binary shift right"); -DATA(insert OID = 1904 ( int8and PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8and - )); +DATA(insert OID = 1904 ( int8and PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8and - )); DESCR("binary and"); -DATA(insert OID = 1905 ( int8or PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8or - )); +DATA(insert OID = 1905 ( int8or PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8or - )); DESCR("binary or"); -DATA(insert OID = 1906 ( int8xor PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8xor - )); +DATA(insert OID = 1906 ( int8xor PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8xor - )); DESCR("binary xor"); DATA(insert OID = 1907 ( int8not PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8not - )); DESCR("binary not"); -DATA(insert OID = 1908 ( int8shl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shl - )); +DATA(insert OID = 1908 ( int8shl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shl - )); DESCR("binary shift left"); -DATA(insert OID = 1909 ( int8shr PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shr - )); +DATA(insert OID = 1909 ( int8shr PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int8shr - )); DESCR("binary shift right"); -DATA(insert OID = 1910 ( int8up PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8up - )); +DATA(insert OID = 1910 ( int8up PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8up - )); DESCR("unary plus"); -DATA(insert OID = 1911 ( int2up PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2up - )); +DATA(insert OID = 1911 ( int2up PGUID 12 f t t t 1 f 21 "21" 100 0 0 100 int2up - )); DESCR("unary plus"); -DATA(insert OID = 1912 ( int4up PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4up - )); +DATA(insert OID = 1912 ( int4up PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4up - )); DESCR("unary plus"); -DATA(insert OID = 1913 ( float4up PGUID 12 f t t t 1 f 700 "700" 100 0 0 100 float4up - )); +DATA(insert OID = 1913 ( float4up PGUID 12 f t t t 1 f 700 "700" 100 0 0 100 float4up - )); DESCR("unary plus"); -DATA(insert OID = 1914 ( float8up PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 float8up - )); +DATA(insert OID = 1914 ( float8up PGUID 12 f t t t 1 f 701 "701" 100 0 0 100 float8up - )); DESCR("unary plus"); -DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - )); +DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - )); DESCR("unary plus"); DATA(insert OID = 1922 ( has_table_privilege PGUID 12 f t f t 3 f 16 "19 19 25" 100 0 0 100 has_table_privilege_name_name - )); @@ -2682,9 +2682,9 @@ DATA(insert OID = 1924 ( has_table_privilege PGUID 12 f t f t 3 f 16 "23 19 DESCR("user privilege on relation by usesysid, relname"); DATA(insert OID = 1925 ( has_table_privilege PGUID 12 f t f t 3 f 16 "23 26 25" 100 0 0 100 has_table_privilege_id_id - )); DESCR("user privilege on relation by usesysid, rel oid"); -DATA(insert OID = 1926 ( has_table_privilege PGUID 12 f t f t 2 f 16 "19 25" 100 0 0 100 has_table_privilege_name - )); +DATA(insert OID = 1926 ( has_table_privilege PGUID 12 f t f t 2 f 16 "19 25" 100 0 0 100 has_table_privilege_name - )); DESCR("current user privilege on relation by relname"); -DATA(insert OID = 1927 ( has_table_privilege PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 has_table_privilege_id - )); +DATA(insert OID = 1927 ( has_table_privilege PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 has_table_privilege_id - )); DESCR("current user privilege on relation by rel oid"); @@ -2704,7 +2704,7 @@ DATA(insert OID = 1934 ( pg_stat_get_blocks_fetched PGUID 12 f t f t 1 f 20 "26 DESCR("Statistics: Number of blocks fetched"); DATA(insert OID = 1935 ( pg_stat_get_blocks_hit PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_blocks_hit - )); DESCR("Statistics: Number of blocks found in cache"); -DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGUID 12 f t f t 0 t 23 "" 100 0 0 100 pg_stat_get_backend_idset - )); +DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGUID 12 f t f t 0 t 23 "" 100 0 0 100 pg_stat_get_backend_idset - )); DESCR("Statistics: Currently active backend IDs"); DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGUID 12 f t f t 1 f 23 "23" 100 0 0 100 pg_stat_get_backend_pid - )); DESCR("Statistics: PID of backend"); @@ -2720,7 +2720,7 @@ DATA(insert OID = 1942 ( pg_stat_get_db_xact_commit PGUID 12 f t f t 1 f 20 "26 DESCR("Statistics: Transactions committed"); DATA(insert OID = 1943 ( pg_stat_get_db_xact_rollback PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_xact_rollback - )); DESCR("Statistics: Transactions rolled back"); -DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_fetched - )); +DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_fetched - )); DESCR("Statistics: Blocks fetched for database"); DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGUID 12 f t f t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_hit - )); DESCR("Statistics: Block found in cache for database"); @@ -2730,43 +2730,43 @@ DESCR("Convert bytea value into some ascii-only text string"); DATA(insert OID = 1947 ( decode PGUID 12 f t t t 2 f 17 "25 25" 100 0 0 100 binary_decode - )); DESCR("Convert ascii-encoded text string into bytea value"); -DATA(insert OID = 1948 ( byteaeq PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteaeq - )); +DATA(insert OID = 1948 ( byteaeq PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteaeq - )); DESCR("equal"); -DATA(insert OID = 1949 ( bytealt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealt - )); +DATA(insert OID = 1949 ( bytealt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealt - )); DESCR("less-than"); -DATA(insert OID = 1950 ( byteale PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteale - )); +DATA(insert OID = 1950 ( byteale PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteale - )); DESCR("less-than-or-equal"); -DATA(insert OID = 1951 ( byteagt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteagt - )); +DATA(insert OID = 1951 ( byteagt PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteagt - )); DESCR("greater-than"); -DATA(insert OID = 1952 ( byteage PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteage - )); +DATA(insert OID = 1952 ( byteage PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteage - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1953 ( byteane PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteane - )); +DATA(insert OID = 1953 ( byteane PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteane - )); DESCR("not equal"); -DATA(insert OID = 1954 ( byteacmp PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 100 byteacmp - )); +DATA(insert OID = 1954 ( byteacmp PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 100 byteacmp - )); DESCR("less-equal-greater"); -DATA(insert OID = 1961 ( timestamp PGUID 12 f t t t 2 f 1114 "1114 23" 100 0 0 100 timestamp_scale - )); +DATA(insert OID = 1961 ( timestamp PGUID 12 f t t t 2 f 1114 "1114 23" 100 0 0 100 timestamp_scale - )); DESCR("adjust time precision"); -DATA(insert OID = 1965 ( oidlarger PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidlarger - )); +DATA(insert OID = 1965 ( oidlarger PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidlarger - )); DESCR("larger of two"); -DATA(insert OID = 1966 ( oidsmaller PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidsmaller - )); +DATA(insert OID = 1966 ( oidsmaller PGUID 12 f t t t 2 f 26 "26 26" 100 0 0 100 oidsmaller - )); DESCR("smaller of two"); -DATA(insert OID = 1967 ( timestamptz PGUID 12 f t t t 2 f 1184 "1184 23" 100 0 0 100 timestamptz_scale - )); +DATA(insert OID = 1967 ( timestamptz PGUID 12 f t t t 2 f 1184 "1184 23" 100 0 0 100 timestamptz_scale - )); DESCR("adjust time precision"); -DATA(insert OID = 1968 ( time PGUID 12 f t t t 2 f 1083 "1083 23" 100 0 0 100 time_scale - )); +DATA(insert OID = 1968 ( time PGUID 12 f t t t 2 f 1083 "1083 23" 100 0 0 100 time_scale - )); DESCR("adjust time precision"); -DATA(insert OID = 1969 ( timetz PGUID 12 f t t t 2 f 1266 "1266 23" 100 0 0 100 timetz_scale - )); +DATA(insert OID = 1969 ( timetz PGUID 12 f t t t 2 f 1266 "1266 23" 100 0 0 100 timetz_scale - )); DESCR("adjust time with time zone precision"); DATA(insert OID = 2005 ( bytealike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - )); DESCR("matches LIKE expression"); DATA(insert OID = 2006 ( byteanlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - )); DESCR("does not match LIKE expression"); -DATA(insert OID = 2007 ( like PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - )); +DATA(insert OID = 2007 ( like PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 bytealike - )); DESCR("matches LIKE expression"); -DATA(insert OID = 2008 ( notlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - )); +DATA(insert OID = 2008 ( notlike PGUID 12 f t t t 2 f 16 "17 17" 100 0 0 100 byteanlike - )); DESCR("does not match LIKE expression"); DATA(insert OID = 2009 ( like_escape PGUID 12 f t t t 2 f 17 "17 17" 100 0 0 100 like_escape_bytea - )); DESCR("convert match pattern to use backslash escapes"); @@ -2782,12 +2782,12 @@ DATA(insert OID = 2014 ( position PGUID 12 f t t t 2 f 23 "17 17" 100 0 0 1 DESCR("return position of substring"); DATA(insert OID = 2015 ( btrim PGUID 12 f t t t 2 f 17 "17 17" 100 0 0 100 byteatrim - )); DESCR("trim both ends of string"); - + DATA(insert OID = 2020 ( date_trunc PGUID 12 f t t t 2 f 1114 "25 1114" 100 0 0 100 timestamp_trunc - )); DESCR("truncate timestamp to specified units"); DATA(insert OID = 2021 ( date_part PGUID 12 f t t t 2 f 701 "25 1114" 100 0 0 100 timestamp_part - )); DESCR("extract field from timestamp"); -DATA(insert OID = 2022 ( timestamp PGUID 12 f t f t 1 f 1114 "25" 100 0 0 100 text_timestamp - )); +DATA(insert OID = 2022 ( timestamp PGUID 12 f t f t 1 f 1114 "25" 100 0 0 100 text_timestamp - )); DESCR("convert text to timestamp"); DATA(insert OID = 2023 ( timestamp PGUID 12 f t f t 1 f 1114 "702" 100 0 0 100 abstime_timestamp - )); DESCR("convert abstime to timestamp"); @@ -2829,7 +2829,7 @@ DATA(insert OID = 2043 ( overlaps PGUID 14 f t t f 4 f 16 "1114 1114 1114 1186 DESCR("SQL92 interval comparison"); DATA(insert OID = 2044 ( overlaps PGUID 14 f t t f 4 f 16 "1114 1186 1114 1114" 100 0 0 100 "select ($1, ($1 + $2)) overlaps ($3, $4)" - )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 2045 ( timestamp_cmp PGUID 12 f t t t 2 f 23 "1114 1114" 100 0 0 100 timestamp_cmp - )); +DATA(insert OID = 2045 ( timestamp_cmp PGUID 12 f t t t 2 f 23 "1114 1114" 100 0 0 100 timestamp_cmp - )); DESCR("less-equal-greater"); DATA(insert OID = 2046 ( time PGUID 12 f t t t 1 f 1083 "1266" 100 0 0 100 timetz_time - )); DESCR("convert time with time zone to time"); @@ -2841,7 +2841,7 @@ DATA(insert OID = 2049 ( to_char PGUID 12 f t f t 2 f 25 "1114 25" 100 0 0 100 DESCR("format timestamp to text"); DATA(insert OID = 2050 ( interval_mi_time PGUID 14 f t t t 2 f 1083 "1186 1083" 100 0 0 100 "select $2 - $1" - )); DESCR("minus"); -DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1" - )); +DATA(insert OID = 2051 ( interval_mi_timetz PGUID 14 f t t t 2 f 1266 "1186 1266" 100 0 0 100 "select $2 - $1" - )); DESCR("minus"); DATA(insert OID = 2052 ( timestamp_eq PGUID 12 f t t t 2 f 16 "1114 1114" 100 0 0 100 timestamp_eq - )); DESCR("equal"); @@ -2883,5 +2883,4 @@ extern Oid ProcedureCreate(char *procedureName, int32 percall_cpu, int32 outin_ratio, List *argList); - -#endif /* PG_PROC_H */ +#endif /* PG_PROC_H */ diff --git a/src/include/catalog/pg_relcheck.h b/src/include/catalog/pg_relcheck.h index 86268f578e..6ec5addb80 100644 --- a/src/include/catalog/pg_relcheck.h +++ b/src/include/catalog/pg_relcheck.h @@ -51,5 +51,4 @@ typedef FormData_pg_relcheck *Form_pg_relcheck; #define Anum_pg_relcheck_rcname 2 #define Anum_pg_relcheck_rcbin 3 #define Anum_pg_relcheck_rcsrc 4 - #endif /* PG_RELCHECK_H */ diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h index d9df02ec97..5870ed4e83 100644 --- a/src/include/catalog/pg_rewrite.h +++ b/src/include/catalog/pg_rewrite.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_rewrite.h,v 1.14 2001/03/22 04:00:40 momjian Exp $ + * $Id: pg_rewrite.h,v 1.15 2001/10/25 05:49:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -63,5 +63,4 @@ typedef FormData_pg_rewrite *Form_pg_rewrite; #define Anum_pg_rewrite_is_instead 5 #define Anum_pg_rewrite_ev_qual 6 #define Anum_pg_rewrite_ev_action 7 - #endif /* PG_REWRITE_H */ diff --git a/src/include/catalog/pg_shadow.h b/src/include/catalog/pg_shadow.h index 7a88e868b7..8198b2a44a 100644 --- a/src/include/catalog/pg_shadow.h +++ b/src/include/catalog/pg_shadow.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_shadow.h,v 1.14 2001/09/08 15:24:00 petere Exp $ + * $Id: pg_shadow.h,v 1.15 2001/10/25 05:49:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -72,5 +72,4 @@ typedef FormData_pg_shadow *Form_pg_shadow; DATA(insert ( "POSTGRES" PGUID t t t t _null_ _null_ )); #define BOOTSTRAP_USESYSID 1 - #endif /* PG_SHADOW_H */ diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index cead36c201..920e29c439 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_statistic.h,v 1.12 2001/08/10 18:57:41 tgl Exp $ + * $Id: pg_statistic.h,v 1.13 2001/10/25 05:49:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -41,14 +41,14 @@ CATALOG(pg_statistic) BKI_WITHOUT_OIDS float4 stanullfrac; /* - * stawidth is the average width in bytes of non-null entries. For + * stawidth is the average width in bytes of non-null entries. For * fixed-width datatypes this is of course the same as the typlen, but * for varlena types it is more useful. Note that this is the average * width of the data as actually stored, post-TOASTing (eg, for a * moved-out-of-line value, only the size of the pointer object is - * counted). This is the appropriate definition for the primary use of - * the statistic, which is to estimate sizes of in-memory hash tables of - * tuples. + * counted). This is the appropriate definition for the primary use + * of the statistic, which is to estimate sizes of in-memory hash + * tables of tuples. */ int4 stawidth; @@ -61,7 +61,7 @@ CATALOG(pg_statistic) BKI_WITHOUT_OIDS * The special negative case allows us to cope with columns that are * unique (stadistinct = -1) or nearly so (for example, a column in * which values appear about twice on the average could be represented - * by stadistinct = -0.5). Because the number-of-rows statistic in + * by stadistinct = -0.5). Because the number-of-rows statistic in * pg_class may be updated more frequently than pg_statistic is, it's * important to be able to describe such situations as a multiple of * the number of rows, rather than a fixed number of distinct values. @@ -73,8 +73,8 @@ CATALOG(pg_statistic) BKI_WITHOUT_OIDS /* ---------------- * To allow keeping statistics on different kinds of datatypes, * we do not hard-wire any particular meaning for the remaining - * statistical fields. Instead, we provide several "slots" in which - * statistical data can be placed. Each slot includes: + * statistical fields. Instead, we provide several "slots" in which + * statistical data can be placed. Each slot includes: * kind integer code identifying kind of data * op OID of associated operator, if needed * numbers float4 array (for statistical values) @@ -97,10 +97,10 @@ CATALOG(pg_statistic) BKI_WITHOUT_OIDS Oid staop4; /* - * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be absent - * (NULL). They cannot be accessed as C struct entries; you have to use - * the full field access machinery (heap_getattr) for them. We declare - * them here for the catalog machinery. + * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be + * absent (NULL). They cannot be accessed as C struct entries; you + * have to use the full field access machinery (heap_getattr) for + * them. We declare them here for the catalog machinery. */ float4 stanumbers1[1]; @@ -157,11 +157,11 @@ typedef FormData_pg_statistic *Form_pg_statistic; /* * Currently, three statistical slot "kinds" are defined: most common values, - * histogram, and correlation. Additional "kinds" will probably appear in + * histogram, and correlation. Additional "kinds" will probably appear in * future to help cope with non-scalar datatypes. * * Code reading the pg_statistic relation should not assume that a particular - * data "kind" will appear in any particular slot. Instead, search the + * data "kind" will appear in any particular slot. Instead, search the * stakind fields to see if the desired data is available. */ @@ -171,11 +171,11 @@ typedef FormData_pg_statistic *Form_pg_statistic; * the K most common non-null values appearing in the column, and stanumbers * contains their frequencies (fractions of total row count). The values * shall be ordered in decreasing frequency. Note that since the arrays are - * variable-size, K may be chosen by the statistics collector. Values should + * variable-size, K may be chosen by the statistics collector. Values should * not appear in MCV unless they have been observed to occur more than once; * a unique column will have no MCV slot. */ -#define STATISTIC_KIND_MCV 1 +#define STATISTIC_KIND_MCV 1 /* * A "histogram" slot describes the distribution of scalar data. staop is @@ -183,13 +183,13 @@ typedef FormData_pg_statistic *Form_pg_statistic; * more than one histogram could appear, if a datatype has more than one * useful sort operator.) stavalues contains M (>=2) non-null values that * divide the non-null column data values into M-1 bins of approximately equal - * population. The first stavalues item is the MIN and the last is the MAX. + * population. The first stavalues item is the MIN and the last is the MAX. * stanumbers is not used and should be NULL. IMPORTANT POINT: if an MCV * slot is also provided, then the histogram describes the data distribution * *after removing the values listed in MCV* (thus, it's a "compressed * histogram" in the technical parlance). This allows a more accurate * representation of the distribution of a column with some very-common - * values. In a column with only a few distinct values, it's possible that + * values. In a column with only a few distinct values, it's possible that * the MCV list describes the entire data population; in this case the * histogram reduces to empty and should be omitted. */ @@ -199,11 +199,10 @@ typedef FormData_pg_statistic *Form_pg_statistic; * A "correlation" slot describes the correlation between the physical order * of table tuples and the ordering of data values of this column, as seen * by the "<" operator identified by staop. (As with the histogram, more - * than one entry could theoretically appear.) stavalues is not used and - * should be NULL. stanumbers contains a single entry, the correlation + * than one entry could theoretically appear.) stavalues is not used and + * should be NULL. stanumbers contains a single entry, the correlation * coefficient between the sequence of data values and the sequence of * their actual tuple positions. The coefficient ranges from +1 to -1. */ -#define STATISTIC_KIND_CORRELATION 3 - +#define STATISTIC_KIND_CORRELATION 3 #endif /* PG_STATISTIC_H */ diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h index 220c32f119..b63fe7d269 100644 --- a/src/include/catalog/pg_trigger.h +++ b/src/include/catalog/pg_trigger.h @@ -92,5 +92,4 @@ typedef FormData_pg_trigger *Form_pg_trigger; #define TRIGGER_FOR_INSERT(type) (type & TRIGGER_TYPE_INSERT) #define TRIGGER_FOR_DELETE(type) (type & TRIGGER_TYPE_DELETE) #define TRIGGER_FOR_UPDATE(type) (type & TRIGGER_TYPE_UPDATE) - #endif /* PG_TRIGGER_H */ diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 8b653a73e4..b97eb914ee 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.112 2001/09/28 08:09:14 thomas Exp $ + * $Id: pg_type.h,v 1.113 2001/10/25 05:49:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -43,14 +43,15 @@ CATALOG(pg_type) BOOTSTRAP /* * For a fixed-size type, typlen is the number of bytes we use to - * represent a value of this type, e.g. 4 for an int4. But for a + * represent a value of this type, e.g. 4 for an int4. But for a * variable-length type, typlen is -1. */ int2 typlen; + /* * typprtlen was once intended to be the length of the external * representation of a datatype, with the same interpretation as for - * typlen. But it's currently unused. + * typlen. But it's currently unused. */ int2 typprtlen; @@ -74,7 +75,8 @@ CATALOG(pg_type) BOOTSTRAP /* * If typisdefined is false, the entry is only a placeholder (forward - * reference). We know the type name, but not yet anything else about it. + * reference). We know the type name, but not yet anything else about + * it. */ bool typisdefined; @@ -90,7 +92,7 @@ CATALOG(pg_type) BOOTSTRAP * be turned into pseudo-arrays like that. Hence, the way to determine * whether a type is a "true" array type is if: * - * typelem != 0 and typlen < 0. + * typelem != 0 and typlen < 0. */ Oid typelem; @@ -139,10 +141,10 @@ CATALOG(pg_type) BOOTSTRAP char typstorage; /* - * typdefault is NULL if the type has no associated default value. - * If it's not NULL, it contains the external representation of the - * type's default value --- this default is used whenever no per-column - * default is specified for a column of the datatype. + * typdefault is NULL if the type has no associated default value. If + * it's not NULL, it contains the external representation of the + * type's default value --- this default is used whenever no + * per-column default is specified for a column of the datatype. */ text typdefault; /* VARIABLE LENGTH FIELD */ } FormData_pg_type; @@ -404,7 +406,7 @@ DATA(insert OID = 1183 ( _time PGUID -1 -1 f b t \054 0 1083 array_in array_ou DATA(insert OID = 1184 ( timestamptz PGUID 8 47 f b t \054 0 0 timestamptz_in timestamptz_out timestamptz_in timestamptz_out d p _null_ )); DESCR("date and time with time zone"); #define TIMESTAMPTZOID 1184 -DATA(insert OID = 1185 ( _timestamptz PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ )); +DATA(insert OID = 1185 ( _timestamptz PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d x _null_ )); DATA(insert OID = 1186 ( interval PGUID 12 47 f b t \054 0 0 interval_in interval_out interval_in interval_out d p _null_ )); DESCR("@ <number> <units>, time interval"); #define INTERVALOID 1186 @@ -464,5 +466,4 @@ extern Oid TypeCreate(char *typeName, extern void TypeRename(const char *oldTypeName, const char *newTypeName); extern char *makeArrayTypeName(char *typeName); - #endif /* PG_TYPE_H */ diff --git a/src/include/catalog/pg_version.h b/src/include/catalog/pg_version.h index 3acbebbc85..7c523bfe00 100644 --- a/src/include/catalog/pg_version.h +++ b/src/include/catalog/pg_version.h @@ -15,7 +15,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_version.h,v 1.12 2001/01/24 19:43:23 momjian Exp $ + * $Id: pg_version.h,v 1.13 2001/10/25 05:49:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -61,5 +61,4 @@ typedef FormData_pg_version *Form_pg_version; #define Anum_pg_version_verbaseid 2 #define Anum_pg_version_vertime 3 - #endif /* PG_VERSION_H */ diff --git a/src/include/commands/async.h b/src/include/commands/async.h index 35dcf0bfe0..ccc6a3636b 100644 --- a/src/include/commands/async.h +++ b/src/include/commands/async.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: async.h,v 1.17 2001/01/24 19:43:23 momjian Exp $ + * $Id: async.h,v 1.18 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,5 +35,4 @@ extern void Async_NotifyHandler(SIGNAL_ARGS); */ extern void EnableNotifyInterrupt(void); extern void DisableNotifyInterrupt(void); - #endif /* ASYNC_H */ diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h index cf6ca225e1..cafb18ff54 100644 --- a/src/include/commands/cluster.h +++ b/src/include/commands/cluster.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * - * $Id: cluster.h,v 1.9 2001/01/24 19:43:23 momjian Exp $ + * $Id: cluster.h,v 1.10 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,5 +24,4 @@ * functions */ extern void cluster(char *oldrelname, char *oldindexname); - #endif /* CLUSTER_H */ diff --git a/src/include/commands/command.h b/src/include/commands/command.h index 78aa06a2df..95530fda35 100644 --- a/src/include/commands/command.h +++ b/src/include/commands/command.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: command.h,v 1.28 2001/10/12 00:07:15 tgl Exp $ + * $Id: command.h,v 1.29 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,12 +44,12 @@ extern void AlterTableAddColumn(const char *relationName, bool inh, ColumnDef *colDef); extern void AlterTableAlterColumnDefault(const char *relationName, - bool inh, const char *colName, - Node *newDefault); + bool inh, const char *colName, + Node *newDefault); extern void AlterTableAlterColumnStatistics(const char *relationName, - bool inh, const char *colName, - Node *statsTarget); + bool inh, const char *colName, + Node *statsTarget); extern void AlterTableDropColumn(const char *relationName, bool inh, const char *colName, @@ -71,5 +71,4 @@ extern void AlterTableOwner(const char *relationName, const char *newOwnerName); * LOCK */ extern void LockTableCommand(LockStmt *lockstmt); - #endif /* COMMAND_H */ diff --git a/src/include/commands/comment.h b/src/include/commands/comment.h index 371f918b6e..410c6dc7f6 100644 --- a/src/include/commands/comment.h +++ b/src/include/commands/comment.h @@ -31,5 +31,4 @@ extern void CommentObject(int objtype, char *objname, char *objproperty, extern void DeleteComments(Oid oid, Oid classoid); extern void CreateComments(Oid oid, Oid classoid, int32 subid, char *comment); - #endif /* COMMENT_H */ diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h index 9b487f2f37..04ca68668d 100644 --- a/src/include/commands/copy.h +++ b/src/include/commands/copy.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: copy.h,v 1.13 2001/06/08 21:16:48 petere Exp $ + * $Id: copy.h,v 1.14 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,5 +18,4 @@ extern int copy_lineno; void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filename, char *delim, char *null_print); - #endif /* COPY_H */ diff --git a/src/include/commands/creatinh.h b/src/include/commands/creatinh.h index 7860c102cd..fd1db12fd9 100644 --- a/src/include/commands/creatinh.h +++ b/src/include/commands/creatinh.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: creatinh.h,v 1.14 2001/01/24 19:43:23 momjian Exp $ + * $Id: creatinh.h,v 1.15 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,5 +19,4 @@ extern void DefineRelation(CreateStmt *stmt, char relkind); extern void RemoveRelation(char *name); extern void TruncateRelation(char *name); - #endif /* CREATINH_H */ diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h index 39f5b3da59..3489b9d279 100644 --- a/src/include/commands/dbcommands.h +++ b/src/include/commands/dbcommands.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dbcommands.h,v 1.16 2001/03/22 04:00:42 momjian Exp $ + * $Id: dbcommands.h,v 1.17 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ extern void createdb(const char *dbname, const char *dbpath, const char *dbtemplate, int encoding); extern void dropdb(const char *dbname); - #endif /* DBCOMMANDS_H */ diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index d2c01862d9..52b760a4bf 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: defrem.h,v 1.25 2001/09/08 01:10:21 tgl Exp $ + * $Id: defrem.h,v 1.26 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,5 +48,4 @@ extern void RemoveOperator(char *operatorName, char *typeName1, char *typeName2); extern void RemoveType(char *typeName); extern void RemoveAggregate(char *aggName, char *aggType); - #endif /* DEFREM_H */ diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h index d40bc896ac..013ae16596 100644 --- a/src/include/commands/explain.h +++ b/src/include/commands/explain.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * - * $Id: explain.h,v 1.12 2001/09/18 01:59:06 tgl Exp $ + * $Id: explain.h,v 1.13 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ #include "tcop/dest.h" extern void ExplainQuery(Query *query, bool verbose, bool analyze, CommandDest dest); - #endif /* EXPLAIN_H */ diff --git a/src/include/commands/proclang.h b/src/include/commands/proclang.h index 42276055e6..29dcb32a12 100644 --- a/src/include/commands/proclang.h +++ b/src/include/commands/proclang.h @@ -13,5 +13,4 @@ extern void CreateProceduralLanguage(CreatePLangStmt *stmt); extern void DropProceduralLanguage(DropPLangStmt *stmt); - #endif /* PROCLANG_H */ diff --git a/src/include/commands/rename.h b/src/include/commands/rename.h index 569cbb921c..18b6d1e2bb 100644 --- a/src/include/commands/rename.h +++ b/src/include/commands/rename.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rename.h,v 1.10 2001/01/24 19:43:23 momjian Exp $ + * $Id: rename.h,v 1.11 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern void renameatt(char *relname, extern void renamerel(const char *oldrelname, const char *newrelname); - #endif /* RENAME_H */ diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h index 77a5470f43..a128491212 100644 --- a/src/include/commands/sequence.h +++ b/src/include/commands/sequence.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sequence.h,v 1.16 2001/08/16 20:38:55 tgl Exp $ + * $Id: sequence.h,v 1.17 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,5 +89,4 @@ extern void CloseSequences(void); extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr); extern void seq_undo(XLogRecPtr lsn, XLogRecord *rptr); extern void seq_desc(char *buf, uint8 xl_info, char *rec); - #endif /* SEQUENCE_H */ diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index ddb9a327db..6ab5880413 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: trigger.h,v 1.27 2001/06/01 02:41:36 tgl Exp $ + * $Id: trigger.h,v 1.28 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,25 +90,25 @@ extern void FreeTriggerDesc(TriggerDesc *trigdesc); extern bool equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2); extern HeapTuple ExecBRInsertTriggers(EState *estate, - ResultRelInfo *relinfo, - HeapTuple trigtuple); + ResultRelInfo *relinfo, + HeapTuple trigtuple); extern void ExecARInsertTriggers(EState *estate, - ResultRelInfo *relinfo, - HeapTuple trigtuple); + ResultRelInfo *relinfo, + HeapTuple trigtuple); extern bool ExecBRDeleteTriggers(EState *estate, - ResultRelInfo *relinfo, - ItemPointer tupleid); + ResultRelInfo *relinfo, + ItemPointer tupleid); extern void ExecARDeleteTriggers(EState *estate, - ResultRelInfo *relinfo, - ItemPointer tupleid); + ResultRelInfo *relinfo, + ItemPointer tupleid); extern HeapTuple ExecBRUpdateTriggers(EState *estate, - ResultRelInfo *relinfo, - ItemPointer tupleid, - HeapTuple newtuple); + ResultRelInfo *relinfo, + ItemPointer tupleid, + HeapTuple newtuple); extern void ExecARUpdateTriggers(EState *estate, - ResultRelInfo *relinfo, - ItemPointer tupleid, - HeapTuple newtuple); + ResultRelInfo *relinfo, + ItemPointer tupleid, + HeapTuple newtuple); /* ---------- @@ -160,5 +160,4 @@ extern void DeferredTriggerSetState(ConstraintsSetStmt *stmt); * */ extern bool RI_FKey_keyequal_upd(TriggerData *trigdata); - #endif /* TRIGGER_H */ diff --git a/src/include/commands/user.h b/src/include/commands/user.h index 489fd98c85..080c8f0c78 100644 --- a/src/include/commands/user.h +++ b/src/include/commands/user.h @@ -3,7 +3,7 @@ * user.h * * - * $Id: user.h,v 1.13 2000/06/15 03:32:35 momjian Exp $ + * $Id: user.h,v 1.14 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern void AlterGroup(AlterGroupStmt *stmt, const char *tag); extern void DropGroup(DropGroupStmt *stmt); extern Datum update_pg_pwd(PG_FUNCTION_ARGS); - #endif /* USER_H */ diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 5d1541ef3b..ed873c8640 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: vacuum.h,v 1.40 2001/08/26 16:56:02 tgl Exp $ + * $Id: vacuum.h,v 1.41 2001/10/25 05:49:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,23 +30,23 @@ /* State structure for vac_init_rusage/vac_show_rusage */ typedef struct VacRUsage { - struct timeval tv; - struct rusage ru; + struct timeval tv; + struct rusage ru; } VacRUsage; /* in commands/vacuum.c */ extern void vacuum(VacuumStmt *vacstmt); extern void vac_open_indexes(Relation relation, int *nindexes, - Relation **Irel); + Relation **Irel); extern void vac_close_indexes(int nindexes, Relation *Irel); extern void vac_update_relstats(Oid relid, - BlockNumber num_pages, - double num_tuples, - bool hasindex); + BlockNumber num_pages, + double num_tuples, + bool hasindex); extern void vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel, - TransactionId *oldestXmin, - TransactionId *freezeLimit); + TransactionId *oldestXmin, + TransactionId *freezeLimit); extern bool vac_is_partial_index(Relation indrel); extern void vac_init_rusage(VacRUsage *ru0); extern const char *vac_show_rusage(VacRUsage *ru0); @@ -56,5 +56,4 @@ extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt); /* in commands/analyze.c */ extern void analyze_rel(Oid relid, VacuumStmt *vacstmt); - #endif /* VACUUM_H */ diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h index 75e88b806b..c1eb655d9d 100644 --- a/src/include/commands/variable.h +++ b/src/include/commands/variable.h @@ -2,7 +2,7 @@ * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * statements * - * $Id: variable.h,v 1.14 2001/10/18 17:30:16 thomas Exp $ + * $Id: variable.h,v 1.15 2001/10/25 05:49:59 momjian Exp $ * */ #ifndef VARIABLE_H @@ -14,5 +14,4 @@ extern void ResetPGVariable(const char *name); extern void set_default_datestyle(void); extern void set_default_client_encoding(void); - #endif /* VARIABLE_H */ diff --git a/src/include/commands/version.h b/src/include/commands/version.h index 0198659b49..18e9a3b2f3 100644 --- a/src/include/commands/version.h +++ b/src/include/commands/version.h @@ -7,11 +7,10 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: version.h,v 1.9 2001/01/24 19:43:23 momjian Exp $ + * $Id: version.h,v 1.10 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef VERSION_H #define VERSION_H - #endif /* VERSION_H */ diff --git a/src/include/commands/view.h b/src/include/commands/view.h index b4b3d3228f..d75464ec09 100644 --- a/src/include/commands/view.h +++ b/src/include/commands/view.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: view.h,v 1.10 2001/08/12 21:35:19 tgl Exp $ + * $Id: view.h,v 1.11 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,5 +18,4 @@ extern void DefineView(char *view_name, Query *view_parse); extern void RemoveView(char *view_name); - #endif /* VIEW_H */ diff --git a/src/include/executor/execFlatten.h b/src/include/executor/execFlatten.h index b922ab845a..0028beadb0 100644 --- a/src/include/executor/execFlatten.h +++ b/src/include/executor/execFlatten.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execFlatten.h,v 1.14 2001/03/22 04:00:44 momjian Exp $ + * $Id: execFlatten.h,v 1.15 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,5 +24,4 @@ extern Datum ExecEvalIter(Iter *iterNode, ExprContext *econtext, extern void ExecEvalFjoin(TargetEntry *tlist, ExprContext *econtext, bool *isNullVect, ExprDoneCond *fj_isDone); - #endif /* EXECFLATTEN_H */ diff --git a/src/include/executor/execdebug.h b/src/include/executor/execdebug.h index 2ce7771b61..92ca247d29 100644 --- a/src/include/executor/execdebug.h +++ b/src/include/executor/execdebug.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execdebug.h,v 1.16 2001/09/20 21:07:57 tgl Exp $ + * $Id: execdebug.h,v 1.17 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -281,7 +281,6 @@ extern int NIndexTupleInserted; #define MJ_DEBUG_QUAL(clause, res) #define MJ_DEBUG_MERGE_COMPARE(qual, res) #define MJ_DEBUG_PROC_NODE(slot) - #endif /* EXEC_MERGEJOINDEBUG */ /* ---------------------------------------------------------------- @@ -298,5 +297,4 @@ extern int NIndexTupleInserted; extern long NDirectFileRead; extern long NDirectFileWrite; - #endif /* ExecDebugIncluded */ diff --git a/src/include/executor/execdefs.h b/src/include/executor/execdefs.h index 5254102457..857e3db2c8 100644 --- a/src/include/executor/execdefs.h +++ b/src/include/executor/execdefs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execdefs.h,v 1.8 2001/01/24 19:43:23 momjian Exp $ + * $Id: execdefs.h,v 1.9 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,5 +50,4 @@ #define EXEC_MJ_SKIPINNER_ADVANCE 13 #define EXEC_MJ_ENDOUTER 14 #define EXEC_MJ_ENDINNER 15 - #endif /* EXECDEFS_H */ diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h index 4ee4299a89..4232f6d2b4 100644 --- a/src/include/executor/execdesc.h +++ b/src/include/executor/execdesc.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execdesc.h,v 1.14 2001/01/24 19:43:23 momjian Exp $ + * $Id: execdesc.h,v 1.15 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,5 +36,4 @@ typedef struct QueryDesc /* in pquery.c */ extern QueryDesc *CreateQueryDesc(Query *parsetree, Plan *plantree, CommandDest dest); - #endif /* EXECDESC_H */ diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index a72594982c..05f31e10b5 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.58 2001/05/27 20:48:51 tgl Exp $ + * $Id: executor.h,v 1.59 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,7 @@ extern void ExecRestrPos(Plan *node); * prototypes from functions in execJunk.c */ extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType, - TupleTableSlot *slot); + TupleTableSlot *slot); extern void ExecFreeJunkFilter(JunkFilter *junkfilter); extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot, char *attrName, Datum *value, bool *isNull); @@ -177,5 +177,4 @@ extern void ExecOpenIndices(ResultRelInfo *resultRelInfo); extern void ExecCloseIndices(ResultRelInfo *resultRelInfo); extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid, EState *estate, bool is_update); - #endif /* EXECUTOR_H */ diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h index 676a63e94f..dc98d50f2c 100644 --- a/src/include/executor/functions.h +++ b/src/include/executor/functions.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: functions.h,v 1.15 2001/01/24 19:43:23 momjian Exp $ + * $Id: functions.h,v 1.16 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ #include "fmgr.h" extern Datum fmgr_sql(PG_FUNCTION_ARGS); - #endif /* FUNCTIONS_H */ diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 8aaf5d16ed..9f8b741794 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hashjoin.h,v 1.22 2001/03/22 04:00:44 momjian Exp $ + * $Id: hashjoin.h,v 1.23 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,5 +92,4 @@ typedef struct HashTableData } HashTableData; typedef HashTableData *HashJoinTable; - #endif /* HASHJOIN_H */ diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h index ca6aa4208a..152d5444a7 100644 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@ -6,7 +6,7 @@ * * Copyright (c) 2001, PostgreSQL Global Development Group * - * $Id: instrument.h,v 1.1 2001/09/18 01:59:06 tgl Exp $ + * $Id: instrument.h,v 1.2 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,21 +19,20 @@ typedef struct Instrumentation { /* Info about current plan cycle: */ - bool running; /* TRUE if we've completed first tuple */ + bool running; /* TRUE if we've completed first tuple */ struct timeval starttime; /* Start time of current iteration of node */ struct timeval counter; /* Accumulates runtime for this node */ - double firsttuple; /* Time for first tuple of this cycle */ - double tuplecount; /* Tuples so far this cycle */ + double firsttuple; /* Time for first tuple of this cycle */ + double tuplecount; /* Tuples so far this cycle */ /* Accumulated statistics across all completed cycles: */ - double startup; /* Total startup time (in seconds) */ - double total; /* Total total time (in seconds) */ - double ntuples; /* Total tuples produced */ - double nloops; /* # of run cycles for this node */ + double startup; /* Total startup time (in seconds) */ + double total; /* Total total time (in seconds) */ + double ntuples; /* Total tuples produced */ + double nloops; /* # of run cycles for this node */ } Instrumentation; extern Instrumentation *InstrAlloc(void); extern void InstrStartNode(Instrumentation *instr); extern void InstrStopNode(Instrumentation *instr, bool returnedTuple); extern void InstrEndLoop(Instrumentation *instr); - -#endif /* INSTRUMENT_H */ +#endif /* INSTRUMENT_H */ diff --git a/src/include/executor/nodeAgg.h b/src/include/executor/nodeAgg.h index e676264299..90643c58cc 100644 --- a/src/include/executor/nodeAgg.h +++ b/src/include/executor/nodeAgg.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeAgg.h,v 1.12 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeAgg.h,v 1.13 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitAgg(Agg *node, EState *estate, Plan *parent); extern int ExecCountSlotsAgg(Agg *node); extern void ExecEndAgg(Agg *node); extern void ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEAGG_H */ diff --git a/src/include/executor/nodeAppend.h b/src/include/executor/nodeAppend.h index bb5fea8c1a..3cd54021a5 100644 --- a/src/include/executor/nodeAppend.h +++ b/src/include/executor/nodeAppend.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeAppend.h,v 1.13 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeAppend.h,v 1.14 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern int ExecCountSlotsAppend(Append *node); extern TupleTableSlot *ExecProcAppend(Append *node); extern void ExecEndAppend(Append *node); extern void ExecReScanAppend(Append *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEAPPEND_H */ diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h index 2fadbf6dcb..ed6fe7ab0f 100644 --- a/src/include/executor/nodeGroup.h +++ b/src/include/executor/nodeGroup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeGroup.h,v 1.18 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeGroup.h,v 1.19 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ extern bool execTuplesMatch(HeapTuple tuple1, extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc, int numCols, AttrNumber *matchColIdx); - #endif /* NODEGROUP_H */ diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h index 512edec6d1..731208905d 100644 --- a/src/include/executor/nodeHash.h +++ b/src/include/executor/nodeHash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHash.h,v 1.20 2001/06/11 00:17:07 tgl Exp $ + * $Id: nodeHash.h,v 1.21 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,8 +33,7 @@ extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, List *hjclauses, extern void ExecHashTableReset(HashJoinTable hashtable, long ntuples); extern void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent); extern void ExecChooseHashTableSize(double ntuples, int tupwidth, - int *virtualbuckets, - int *physicalbuckets, - int *numbatches); - + int *virtualbuckets, + int *physicalbuckets, + int *numbatches); #endif /* NODEHASH_H */ diff --git a/src/include/executor/nodeHashjoin.h b/src/include/executor/nodeHashjoin.h index 893e9d014e..f3e04b3df1 100644 --- a/src/include/executor/nodeHashjoin.h +++ b/src/include/executor/nodeHashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHashjoin.h,v 1.19 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeHashjoin.h,v 1.20 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,5 +22,4 @@ extern int ExecCountSlotsHashJoin(HashJoin *node); extern void ExecEndHashJoin(HashJoin *node); extern void ExecHashJoinSaveTuple(HeapTuple heapTuple, BufFile *file); extern void ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEHASHJOIN_H */ diff --git a/src/include/executor/nodeIndexscan.h b/src/include/executor/nodeIndexscan.h index 91f8abd6fc..bae08bd046 100644 --- a/src/include/executor/nodeIndexscan.h +++ b/src/include/executor/nodeIndexscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeIndexscan.h,v 1.11 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeIndexscan.h,v 1.12 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,5 +25,4 @@ extern void ExecUpdateIndexScanKeys(IndexScan *node, ExprContext *econtext); extern bool ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent); extern int ExecCountSlotsIndexScan(IndexScan *node); extern void ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEINDEXSCAN_H */ diff --git a/src/include/executor/nodeLimit.h b/src/include/executor/nodeLimit.h index 3bfcd76d77..6b0acd4baa 100644 --- a/src/include/executor/nodeLimit.h +++ b/src/include/executor/nodeLimit.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeLimit.h,v 1.2 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeLimit.h,v 1.3 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitLimit(Limit *node, EState *estate, Plan *parent); extern int ExecCountSlotsLimit(Limit *node); extern void ExecEndLimit(Limit *node); extern void ExecReScanLimit(Limit *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODELIMIT_H */ diff --git a/src/include/executor/nodeMaterial.h b/src/include/executor/nodeMaterial.h index ce5a8b172f..e8e23dfeaa 100644 --- a/src/include/executor/nodeMaterial.h +++ b/src/include/executor/nodeMaterial.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeMaterial.h,v 1.14 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeMaterial.h,v 1.15 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern void ExecEndMaterial(Material *node); extern void ExecMaterialMarkPos(Material *node); extern void ExecMaterialRestrPos(Material *node); extern void ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEMATERIAL_H */ diff --git a/src/include/executor/nodeMergejoin.h b/src/include/executor/nodeMergejoin.h index 7850bbc673..94c4ef302e 100644 --- a/src/include/executor/nodeMergejoin.h +++ b/src/include/executor/nodeMergejoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeMergejoin.h,v 1.13 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeMergejoin.h,v 1.14 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitMergeJoin(MergeJoin *node, EState *estate, Plan *parent); extern int ExecCountSlotsMergeJoin(MergeJoin *node); extern void ExecEndMergeJoin(MergeJoin *node); extern void ExecReScanMergeJoin(MergeJoin *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEMERGEJOIN_H; */ diff --git a/src/include/executor/nodeNestloop.h b/src/include/executor/nodeNestloop.h index cd27030e99..7f0ae11024 100644 --- a/src/include/executor/nodeNestloop.h +++ b/src/include/executor/nodeNestloop.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeNestloop.h,v 1.14 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeNestloop.h,v 1.15 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,5 +22,4 @@ extern int ExecCountSlotsNestLoop(NestLoop *node); extern void ExecEndNestLoop(NestLoop *node); extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODENESTLOOP_H */ diff --git a/src/include/executor/nodeResult.h b/src/include/executor/nodeResult.h index 39f15a385a..7ee4fb712b 100644 --- a/src/include/executor/nodeResult.h +++ b/src/include/executor/nodeResult.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeResult.h,v 1.11 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeResult.h,v 1.12 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitResult(Result *node, EState *estate, Plan *parent); extern int ExecCountSlotsResult(Result *node); extern void ExecEndResult(Result *node); extern void ExecReScanResult(Result *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODERESULT_H */ diff --git a/src/include/executor/nodeSeqscan.h b/src/include/executor/nodeSeqscan.h index 8f42574099..b0ebbc325b 100644 --- a/src/include/executor/nodeSeqscan.h +++ b/src/include/executor/nodeSeqscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSeqscan.h,v 1.11 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeSeqscan.h,v 1.12 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern void ExecEndSeqScan(SeqScan *node); extern void ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent); extern void ExecSeqMarkPos(SeqScan *node); extern void ExecSeqRestrPos(SeqScan *node); - #endif /* NODESEQSCAN_H */ diff --git a/src/include/executor/nodeSetOp.h b/src/include/executor/nodeSetOp.h index 81805afe13..86ac187cbf 100644 --- a/src/include/executor/nodeSetOp.h +++ b/src/include/executor/nodeSetOp.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSetOp.h,v 1.2 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeSetOp.h,v 1.3 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitSetOp(SetOp *node, EState *estate, Plan *parent); extern int ExecCountSlotsSetOp(SetOp *node); extern void ExecEndSetOp(SetOp *node); extern void ExecReScanSetOp(SetOp *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODESETOP_H */ diff --git a/src/include/executor/nodeSort.h b/src/include/executor/nodeSort.h index 2b3a26398a..a667f9bb34 100644 --- a/src/include/executor/nodeSort.h +++ b/src/include/executor/nodeSort.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSort.h,v 1.11 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeSort.h,v 1.12 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern void ExecEndSort(Sort *node); extern void ExecSortMarkPos(Sort *node); extern void ExecSortRestrPos(Sort *node); extern void ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODESORT_H */ diff --git a/src/include/executor/nodeSubplan.h b/src/include/executor/nodeSubplan.h index f7c46c3ca9..0b12f3d61d 100644 --- a/src/include/executor/nodeSubplan.h +++ b/src/include/executor/nodeSubplan.h @@ -15,5 +15,4 @@ extern bool ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent); extern void ExecReScanSetParamPlan(SubPlan *node, Plan *parent); extern void ExecSetParamPlan(SubPlan *node, ExprContext *econtext); extern void ExecEndSubPlan(SubPlan *node); - #endif /* NODESUBPLAN_H */ diff --git a/src/include/executor/nodeSubqueryscan.h b/src/include/executor/nodeSubqueryscan.h index d58e80c458..acbc98aa54 100644 --- a/src/include/executor/nodeSubqueryscan.h +++ b/src/include/executor/nodeSubqueryscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSubqueryscan.h,v 1.2 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeSubqueryscan.h,v 1.3 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern void ExecEndSubqueryScan(SubqueryScan *node); extern bool ExecInitSubqueryScan(SubqueryScan *node, EState *estate, Plan *parent); extern int ExecCountSlotsSubqueryScan(SubqueryScan *node); extern void ExecSubqueryReScan(SubqueryScan *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODESUBQUERYSCAN_H */ diff --git a/src/include/executor/nodeTidscan.h b/src/include/executor/nodeTidscan.h index f49255c7cd..c9cd06b141 100644 --- a/src/include/executor/nodeTidscan.h +++ b/src/include/executor/nodeTidscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeTidscan.h,v 1.5 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeTidscan.h,v 1.6 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern void ExecTidMarkPos(TidScan *node); extern bool ExecInitTidScan(TidScan *node, EState *estate, Plan *parent); extern int ExecCountSlotsTidScan(TidScan *node); extern void ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODETIDSCAN_H */ diff --git a/src/include/executor/nodeUnique.h b/src/include/executor/nodeUnique.h index d3fc08dcec..40fc0d2955 100644 --- a/src/include/executor/nodeUnique.h +++ b/src/include/executor/nodeUnique.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeUnique.h,v 1.11 2001/01/24 19:43:23 momjian Exp $ + * $Id: nodeUnique.h,v 1.12 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern bool ExecInitUnique(Unique *node, EState *estate, Plan *parent); extern int ExecCountSlotsUnique(Unique *node); extern void ExecEndUnique(Unique *node); extern void ExecReScanUnique(Unique *node, ExprContext *exprCtxt, Plan *parent); - #endif /* NODEUNIQUE_H */ diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index bef68bc7a6..26531a49fc 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -2,7 +2,7 @@ * * spi.h * - * $Id: spi.h,v 1.28 2001/08/02 18:08:43 tgl Exp $ + * $Id: spi.h,v 1.29 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,7 +85,7 @@ extern int SPI_exec(char *src, int tcount); extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount); extern void *SPI_prepare(char *src, int nargs, Oid *argtypes); extern void *SPI_saveplan(void *plan); -extern int SPI_freeplan(void *plan); +extern int SPI_freeplan(void *plan); extern HeapTuple SPI_copytuple(HeapTuple tuple); extern TupleDesc SPI_copytupledesc(TupleDesc tupdesc); @@ -104,13 +104,12 @@ extern void SPI_pfree(void *pointer); extern void SPI_freetuple(HeapTuple pointer); extern void SPI_freetuptable(SPITupleTable *tuptable); -extern Portal SPI_cursor_open(char *name, void *plan, +extern Portal SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls); extern Portal SPI_cursor_find(char *name); -extern void SPI_cursor_fetch(Portal portal, bool forward, int count); -extern void SPI_cursor_move(Portal portal, bool forward, int count); -extern void SPI_cursor_close(Portal portal); +extern void SPI_cursor_fetch(Portal portal, bool forward, int count); +extern void SPI_cursor_move(Portal portal, bool forward, int count); +extern void SPI_cursor_close(Portal portal); extern void AtEOXact_SPI(void); - #endif /* SPI_H */ diff --git a/src/include/executor/spi_priv.h b/src/include/executor/spi_priv.h index e562663400..d7f036506b 100644 --- a/src/include/executor/spi_priv.h +++ b/src/include/executor/spi_priv.h @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface private declarations * - * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.8 2001/05/21 14:22:18 wieck Exp $ + * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.9 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,5 +35,4 @@ typedef struct #define _SPI_CPLAN_CURCXT 0 #define _SPI_CPLAN_PROCXT 1 #define _SPI_CPLAN_TOPCXT 2 - #endif /* SPI_PRIV_H */ diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index 7def0be4b6..06f1387fe9 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tuptable.h,v 1.18 2001/01/29 00:39:20 tgl Exp $ + * $Id: tuptable.h,v 1.19 2001/10/25 05:49:59 momjian Exp $ * * NOTES * The tuple table interface is getting pretty ugly. @@ -80,5 +80,4 @@ typedef struct TupleTableData } TupleTableData; typedef TupleTableData *TupleTable; - #endif /* TUPTABLE_H */ diff --git a/src/include/fmgr.h b/src/include/fmgr.h index 0acb966f68..c50e4cdff6 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fmgr.h,v 1.15 2001/10/06 23:21:44 tgl Exp $ + * $Id: fmgr.h,v 1.16 2001/10/25 05:49:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,13 +78,13 @@ extern void fmgr_info(Oid functionId, FmgrInfo *finfo); * and used to hold all subsidiary data of finfo. */ extern void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, - MemoryContext mcxt); + MemoryContext mcxt); /* * Copy an FmgrInfo struct */ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, - MemoryContext destcxt); + MemoryContext destcxt); /* * This macro invokes a function given a filled-in FunctionCallInfoData @@ -361,7 +361,7 @@ extern Oid fmgr_internal_function(const char *proname); /* * Routines in dfmgr.c */ -extern char * Dynamic_library_path; +extern char *Dynamic_library_path; extern PGFunction load_external_function(char *filename, char *funcname, bool signalNotFound, void **filehandle); @@ -383,5 +383,4 @@ extern void load_file(char *filename); * DEPRECATED, DO NOT USE IN NEW CODE */ extern char *fmgr(Oid procedureId,...); - #endif /* FMGR_H */ diff --git a/src/include/lib/dllist.h b/src/include/lib/dllist.h index 42e500fa05..6133592079 100644 --- a/src/include/lib/dllist.h +++ b/src/include/lib/dllist.h @@ -34,7 +34,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dllist.h,v 1.16 2001/03/22 04:00:46 momjian Exp $ + * $Id: dllist.h,v 1.17 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ extern void DLFreeList(Dllist *list); /* free up a list and all the extern Dlelem *DLNewElem(void *val); extern void DLInitElem(Dlelem *e, void *val); extern void DLFreeElem(Dlelem *e); -extern void DLRemove(Dlelem *e);/* removes node from list */ +extern void DLRemove(Dlelem *e); /* removes node from list */ extern void DLAddHead(Dllist *list, Dlelem *node); extern void DLAddTail(Dllist *list, Dlelem *node); extern Dlelem *DLRemHead(Dllist *list); /* remove and return the head */ @@ -81,5 +81,4 @@ extern void DLMoveToFront(Dlelem *e); /* move node to front of its list */ #define DLGetListHdr(elem) ((elem)->dle_list) #define DLE_VAL(elem) ((elem)->dle_val) - #endif /* DLLIST_H */ diff --git a/src/include/lib/lispsort.h b/src/include/lib/lispsort.h index 9d72131314..13228cfd2a 100644 --- a/src/include/lib/lispsort.h +++ b/src/include/lib/lispsort.h @@ -7,11 +7,10 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lispsort.h,v 1.7 2001/01/24 19:43:24 momjian Exp $ + * $Id: lispsort.h,v 1.8 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef LISPSORT_H #define LISPSORT_H - #endif /* LISPSORT_H */ diff --git a/src/include/lib/stringinfo.h b/src/include/lib/stringinfo.h index 6f1406ff16..fc6e2031a9 100644 --- a/src/include/lib/stringinfo.h +++ b/src/include/lib/stringinfo.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.h,v 1.20 2001/10/03 21:58:28 tgl Exp $ + * $Id: stringinfo.h,v 1.21 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,8 @@ extern void initStringInfo(StringInfo str); * to str if necessary. This is sort of like a combination of sprintf and * strcat. */ -extern void appendStringInfo(StringInfo str, const char *fmt, ...) +extern void +appendStringInfo(StringInfo str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -109,5 +110,4 @@ extern void appendStringInfoChar(StringInfo str, char ch); */ extern void appendBinaryStringInfo(StringInfo str, const char *data, int datalen); - #endif /* STRINGINFO_H */ diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h index df973df555..0ef455a882 100644 --- a/src/include/libpq/auth.h +++ b/src/include/libpq/auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: auth.h,v 1.17 2001/06/20 18:07:56 petere Exp $ + * $Id: auth.h,v 1.18 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ void ClientAuthentication(Port *port); #define PG_KRB5_VERSION "PGVER5.1" extern char *pg_krb_server_keyfile; - #endif /* AUTH_H */ diff --git a/src/include/libpq/be-fsstubs.h b/src/include/libpq/be-fsstubs.h index 9ba694fbb2..e53b60a3d8 100644 --- a/src/include/libpq/be-fsstubs.h +++ b/src/include/libpq/be-fsstubs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: be-fsstubs.h,v 1.12 2001/01/24 19:43:24 momjian Exp $ + * $Id: be-fsstubs.h,v 1.13 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,5 +46,4 @@ extern int lo_write(int fd, char *buf, int len); * Cleanup LOs at xact commit/abort [ Pascal André <andre@via.ecp.fr> ] */ extern void lo_commit(bool isCommit); - #endif /* BE_FSSTUBS_H */ diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h index bec71ca168..4f91e207fd 100644 --- a/src/include/libpq/crypt.h +++ b/src/include/libpq/crypt.h @@ -22,16 +22,15 @@ extern int pwd_cache_count; extern char *crypt_getpwdfilename(void); extern char *crypt_getpwdreloadfilename(void); -extern int md5_crypt_verify(const Port *port, const char *user, const char *pgpass); +extern int md5_crypt_verify(const Port *port, const char *user, const char *pgpass); extern bool md5_hash(const void *buff, size_t len, char *hexsum); extern bool CheckMD5Pwd(char *passwd, char *storedpwd, char *seed); -extern bool EncryptMD5(const char *passwd, const char *salt, - size_t salt_len, char *buf); +extern bool EncryptMD5(const char *passwd, const char *salt, + size_t salt_len, char *buf); #define MD5_PASSWD_LEN 35 #define isMD5(passwd) (strncmp((passwd),"md5",3) == 0 && \ strlen(passwd) == MD5_PASSWD_LEN) - #endif diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h index aea1b215fe..f29e2a7254 100644 --- a/src/include/libpq/hba.h +++ b/src/include/libpq/hba.h @@ -4,7 +4,7 @@ * Interface to hba.c * * - * $Id: hba.h,v 1.28 2001/10/01 02:26:36 ishii Exp $ + * $Id: hba.h,v 1.29 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,23 +31,22 @@ typedef enum UserAuth { - uaReject, - uaKrb4, - uaKrb5, - uaTrust, - uaIdent, - uaPassword, - uaCrypt, - uaMD5 + uaReject, + uaKrb4, + uaKrb5, + uaTrust, + uaIdent, + uaPassword, + uaCrypt, + uaMD5 #ifdef USE_PAM - ,uaPAM -#endif /* USE_PAM */ + ,uaPAM +#endif /* USE_PAM */ } UserAuth; typedef struct Port hbaPort; -extern int hba_getauthmethod(hbaPort *port); -extern int authident(hbaPort *port); +extern int hba_getauthmethod(hbaPort *port); +extern int authident(hbaPort *port); extern void load_hba_and_ident(void); - #endif diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index 56e6443cb7..729c1c3636 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-be.h,v 1.22 2001/08/17 02:59:19 momjian Exp $ + * $Id: libpq-be.h,v 1.23 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,10 +67,10 @@ typedef struct AuthRequestPacket typedef enum { - Idle, - ReadingPacketLength, - ReadingPacket, - WritingPacket + Idle, + ReadingPacketLength, + ReadingPacket, + WritingPacket } PacketState; typedef int (*PacketDoneProc) (void *arg, PacketLen pktlen, void *pktdata); @@ -120,7 +120,7 @@ typedef struct Port SockAddr laddr; /* local addr (us) */ SockAddr raddr; /* remote addr (them) */ char md5Salt[4]; /* Password salt */ - char cryptSalt[2]; /* Password salt */ + char cryptSalt[2]; /* Password salt */ /* * Information that needs to be held during the fe/be authentication @@ -155,5 +155,4 @@ int PacketReceiveFragment(Port *port); void PacketSendSetup(Packet *pkt, int nbytes, PacketDoneProc iodone, void *arg); int PacketSendFragment(Port *port); void PacketSendError(Packet *pkt, char *errormsg); - #endif /* LIBPQ_BE_H */ diff --git a/src/include/libpq/libpq-fs.h b/src/include/libpq/libpq-fs.h index 64ded84dbc..39b0291981 100644 --- a/src/include/libpq/libpq-fs.h +++ b/src/include/libpq/libpq-fs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fs.h,v 1.12 2001/02/10 02:31:28 tgl Exp $ + * $Id: libpq-fs.h,v 1.13 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ #define INV_WRITE 0x00020000 #define INV_READ 0x00040000 - #endif /* LIBPQ_FS_H */ diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h index 9390219838..685eb4a7c0 100644 --- a/src/include/libpq/libpq.h +++ b/src/include/libpq/libpq.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq.h,v 1.45 2001/08/07 10:44:16 petere Exp $ + * $Id: libpq.h,v 1.46 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,5 +76,4 @@ extern void pq_endcopyout(bool errorAbort); extern void pqdebug(char *fmt, char *msg); extern void PQtrace(void); extern void PQuntrace(void); - #endif /* LIBPQ_H */ diff --git a/src/include/libpq/password.h b/src/include/libpq/password.h index c704edeb34..8eaf643eb1 100644 --- a/src/include/libpq/password.h +++ b/src/include/libpq/password.h @@ -2,5 +2,4 @@ #define PASSWORD_H int verify_password(const Port *port, const char *user, const char *password); - #endif diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index c7afe170e0..64883424ed 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.h,v 1.59 2001/09/06 03:18:12 momjian Exp $ + * $Id: pqcomm.h,v 1.60 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,6 @@ struct sockaddr_un short int sun_family; /* AF_UNIX */ char sun_path[108]; /* path name (gag) */ }; - #endif /* Define a generic socket address type. */ @@ -179,5 +178,4 @@ typedef struct CancelRequestPacket */ #define NEGOTIATE_SSL_CODE PG_PROTOCOL(1234,5679) - #endif /* PQCOMM_H */ diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h index 6d4ca50332..61e88c881c 100644 --- a/src/include/libpq/pqformat.h +++ b/src/include/libpq/pqformat.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.h,v 1.8 2001/01/24 19:43:25 momjian Exp $ + * $Id: pqformat.h,v 1.9 2001/10/25 05:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,5 +28,4 @@ extern int pq_puttextmessage(char msgtype, const char *str); extern int pq_getint(int *result, int b); extern int pq_getstr(StringInfo s); - #endif /* PQFORMAT_H */ diff --git a/src/include/libpq/pqsignal.h b/src/include/libpq/pqsignal.h index 812377186f..efecb9cc4c 100644 --- a/src/include/libpq/pqsignal.h +++ b/src/include/libpq/pqsignal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.16 2001/09/07 16:12:49 wieck Exp $ + * $Id: pqsignal.h,v 1.17 2001/10/25 05:49:59 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -38,5 +38,4 @@ typedef void (*pqsigfunc) (int); extern void pqinitmask(void); extern pqsigfunc pqsignal(int signo, pqsigfunc func); - #endif /* PQSIGNAL_H */ diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index c1e60312ab..d6d8af82cd 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -1,4 +1,4 @@ -/* $Id: pg_wchar.h,v 1.34 2001/10/16 10:09:17 ishii Exp $ */ +/* $Id: pg_wchar.h,v 1.35 2001/10/25 05:49:59 momjian Exp $ */ #ifndef PG_WCHAR_H #define PG_WCHAR_H @@ -13,10 +13,11 @@ #endif /* - * The pg_wchar + * The pg_wchar */ #ifdef MULTIBYTE typedef unsigned int pg_wchar; + #else #define pg_wchar char #endif @@ -29,7 +30,7 @@ typedef unsigned int pg_wchar; /* * Leading byte types or leading prefix byte for MULE internal code. - * See http://www.xemacs.org for more details. (there is a doc titled + * See http://www.xemacs.org for more details. (there is a doc titled * "XEmacs Internals Manual", "MULE Character Sets and Encodings" * section. */ @@ -62,18 +63,18 @@ typedef unsigned int pg_wchar; #define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */ #define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */ #define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */ -#define LC_TIS620 0x85 /* Thai (not supported yet) */ -#define LC_ISO8859_7 0x86 /* Greek (not supported yet) */ -#define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */ -#define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */ +#define LC_TIS620 0x85 /* Thai (not supported yet) */ +#define LC_ISO8859_7 0x86 /* Greek (not supported yet) */ +#define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */ +#define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */ #define LC_JISX0201K 0x89 /* Japanese 1 byte kana */ #define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */ /* Note that 0x8b seems to be unused in as of Emacs 20.7. * However, there might be a chance that 0x8b could be used * in later version of Emacs. */ -#define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */ -#define LC_KOI8_U 0x8b /* Cyrillic KOI8-U */ +#define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */ +#define LC_KOI8_U 0x8b /* Cyrillic KOI8-U */ #define LC_ISO8859_5 0x8c /* ISO8859 Cyrillic */ #define LC_ISO8859_9 0x8d /* ISO8859 Latin 5 (not supported yet) */ /* #define FREE 0x8e free (unused) */ @@ -81,58 +82,61 @@ typedef unsigned int pg_wchar; /* * Unused */ -#define CONTROL_1 0x8f /* control characters (unused) */ +#define CONTROL_1 0x8f /* control characters (unused) */ /* * Official multibyte byte encodings (0x90-0x99) * 0x9a-0x9d are free. 0x9e and 0x9f are reserved. */ -#define LC_JISX0208_1978 0x90 /* Japanese Kanji, old JIS (not supported) */ +#define LC_JISX0208_1978 0x90/* Japanese Kanji, old JIS (not supported) */ /* #define FREE 0x90 free (unused) */ #define LC_GB2312_80 0x91 /* Chinese */ -#define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */ -#define LC_KS5601 0x93 /* Korean */ -#define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */ +#define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */ +#define LC_KS5601 0x93 /* Korean */ +#define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */ #define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */ #define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */ /* #define FREE 0x97 free (unused) */ -#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not supported) */ -#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not supported) */ +#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not + * supported) */ +#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not + * supported) */ /* * Private single byte encodings (0xa0-0xef) */ -#define LC_SISHENG 0xa0 /* Chinese SiSheng characters for PinYin/ZhuYin - (not supported) */ -#define LC_IPA 0xa1 /* IPA (International Phonetic Association) - (not supported) */ -#define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not supported) */ -#define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not supported) */ -#define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */ -#define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */ -#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) - with right-to-left direction - (not supported) */ -#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF) - (not supported) */ -#define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */ +#define LC_SISHENG 0xa0 /* Chinese SiSheng characters for + * PinYin/ZhuYin (not supported) */ +#define LC_IPA 0xa1 /* IPA (International Phonetic + * Association) (not supported) */ +#define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not + * supported) */ +#define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not + * supported) */ +#define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */ +#define LC_ARABIC_1_COLUMN 0xa5/* Arabic 1-column (not supported) */ +#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) + * with right-to-left direction + * (not supported) */ +#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF) + * (not supported) */ +#define LC_ARABIC_2_COLUMN 0xa8/* Arabic 1-column (not supported) */ /* * Private multi byte encodings (0xf0-0xff) */ -#define LC_INDIAN_1_COLUMN 0xf0 /* Indian charset for 1-column - width glypps (not supported) */ -#define LC_TIBETAN_1_COLUMN 0xf1 /* Tibetan 1 column glyph - (not supported) */ -#define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */ +#define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width + * glypps (not supported) */ +#define LC_TIBETAN_1_COLUMN 0xf1/* Tibetan 1 column glyph (not supported) */ +#define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */ #define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */ #define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */ #define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */ #define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */ #define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */ -#define LC_INDIAN_2_COLUMN 0xfb /* Indian charset for 2-column - width glypps (not supported) */ -#define LC_TIBETAN 0xfc /* Tibetan (not supported) */ +#define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width + * glypps (not supported) */ +#define LC_TIBETAN 0xfc /* Tibetan (not supported) */ /* #define FREE 0xfd free (unused) */ /* #define FREE 0xfe free (unused) */ /* #define FREE 0xff free (unused) */ @@ -140,84 +144,84 @@ typedef unsigned int pg_wchar; /* * Encoding numeral identificators * - * WARNING: the order of this table must be same as order - * in the pg_enconv[] (mb/conv.c) and pg_enc2name[] (mb/encnames.c) array! + * WARNING: the order of this table must be same as order + * in the pg_enconv[] (mb/conv.c) and pg_enc2name[] (mb/encnames.c) array! * - * If you add some encoding don'y forget check - * PG_ENCODING_[BE|FE]_LAST macros. + * If you add some encoding don'y forget check + * PG_ENCODING_[BE|FE]_LAST macros. * - * The PG_SQL_ASCII is default encoding and must be = 0. + * The PG_SQL_ASCII is default encoding and must be = 0. */ typedef enum pg_enc { - PG_SQL_ASCII = 0, /* 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_UTF8, /* Unicode UTF-8 */ - PG_MULE_INTERNAL, /* Mule internal code */ - PG_LATIN1, /* ISO-8859-1 Latin 1 */ - PG_LATIN2, /* ISO-8859-2 Latin 2 */ - PG_LATIN3, /* ISO-8859-3 Latin 3 */ - PG_LATIN4, /* ISO-8859-4 Latin 4 */ - PG_LATIN5, /* ISO-8859-9 Latin 5 */ - PG_LATIN6, /* ISO-8859-10 Latin6 */ - PG_LATIN7, /* ISO-8859-13 Latin7 */ - PG_LATIN8, /* ISO-8859-14 Latin8 */ - PG_LATIN9, /* ISO-8859-15 Latin9 */ - PG_LATIN10, /* ISO-8859-16 Latin10 */ - PG_KOI8R, /* KOI8-R */ - PG_WIN1251, /* windows-1251 (was: WIN) */ - PG_ALT, /* (MS-DOS CP866) */ - PG_ISO_8859_5, /* ISO-8859-5 */ - PG_ISO_8859_6, /* ISO-8859-6 */ - PG_ISO_8859_7, /* ISO-8859-7 */ - PG_ISO_8859_8, /* ISO-8859-8 */ + PG_SQL_ASCII = 0, /* 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_UTF8, /* Unicode UTF-8 */ + PG_MULE_INTERNAL, /* Mule internal code */ + PG_LATIN1, /* ISO-8859-1 Latin 1 */ + PG_LATIN2, /* ISO-8859-2 Latin 2 */ + PG_LATIN3, /* ISO-8859-3 Latin 3 */ + PG_LATIN4, /* ISO-8859-4 Latin 4 */ + PG_LATIN5, /* ISO-8859-9 Latin 5 */ + PG_LATIN6, /* ISO-8859-10 Latin6 */ + PG_LATIN7, /* ISO-8859-13 Latin7 */ + PG_LATIN8, /* ISO-8859-14 Latin8 */ + PG_LATIN9, /* ISO-8859-15 Latin9 */ + PG_LATIN10, /* ISO-8859-16 Latin10 */ + PG_KOI8R, /* KOI8-R */ + PG_WIN1251, /* windows-1251 (was: WIN) */ + PG_ALT, /* (MS-DOS CP866) */ + PG_ISO_8859_5, /* ISO-8859-5 */ + PG_ISO_8859_6, /* ISO-8859-6 */ + PG_ISO_8859_7, /* ISO-8859-7 */ + PG_ISO_8859_8, /* ISO-8859-8 */ /* followings are for client encoding only */ - PG_SJIS, /* Shift JIS */ - PG_BIG5, /* Big5 */ - PG_WIN1250, /* windows-1250 */ + PG_SJIS, /* Shift JIS */ + PG_BIG5, /* Big5 */ + PG_WIN1250, /* windows-1250 */ - _PG_LAST_ENCODING_ /* mark only */ + _PG_LAST_ENCODING_ /* mark only */ } pg_enc; -#define PG_ENCODING_BE_LAST PG_ISO_8859_8 -#define PG_ENCODING_FE_LAST PG_WIN1250 +#define PG_ENCODING_BE_LAST PG_ISO_8859_8 +#define PG_ENCODING_FE_LAST PG_WIN1250 #ifdef MULTIBYTE /* - * Please use these tests before access to pg_encconv_tbl[] + * Please use these tests before access to pg_encconv_tbl[] * or to other places... */ #define PG_VALID_BE_ENCODING(_enc) \ - ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST) - + ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST) + #define PG_ENCODING_IS_CLIEN_ONLY(_enc) \ (((_enc) > PG_ENCODING_BE_LAST && (_enc) <= PG_ENCODING_FE_LAST) #define PG_VALID_ENCODING(_enc) \ ((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_) -/* On FE are possible all encodings +/* On FE are possible all encodings */ -#define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc) +#define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc) -/* +/* * Encoding names with all aliases */ typedef struct pg_encname { - char *name; - pg_enc encoding; + char *name; + pg_enc encoding; } pg_encname; -extern pg_encname pg_encname_tbl[]; -extern unsigned int pg_encname_tbl_sz; +extern pg_encname pg_encname_tbl[]; +extern unsigned int pg_encname_tbl_sz; /* * Careful: @@ -227,16 +231,16 @@ extern unsigned int pg_encname_tbl_sz; */ typedef struct pg_enc2name { - char *name; - pg_enc encoding; + char *name; + pg_enc encoding; } pg_enc2name; -extern pg_enc2name pg_enc2name_tbl[]; +extern pg_enc2name pg_enc2name_tbl[]; -extern pg_encname *pg_char_to_encname_struct(const char *name); +extern pg_encname *pg_char_to_encname_struct(const char *name); -extern int pg_char_to_encoding(const char *s); -extern const char *pg_encoding_to_char(int encoding); +extern int pg_char_to_encoding(const char *s); +extern const char *pg_encoding_to_char(int encoding); typedef void (*to_mic_converter) (unsigned char *l, unsigned char *p, int len); typedef void (*from_mic_converter) (unsigned char *mic, unsigned char *p, int len); @@ -251,31 +255,31 @@ typedef void (*from_mic_converter) (unsigned char *mic, unsigned char *p, int le #ifndef FRONTEND typedef struct pg_enconv { - pg_enc encoding; /* encoding identifier */ - to_mic_converter to_mic; /* client encoding to MIC */ - from_mic_converter from_mic; /* MIC to client encoding */ - to_mic_converter to_unicode; /* client encoding to UTF-8 */ - from_mic_converter from_unicode; /* UTF-8 to client encoding */ + pg_enc encoding; /* encoding identifier */ + to_mic_converter to_mic; /* client encoding to MIC */ + from_mic_converter from_mic; /* MIC to client encoding */ + to_mic_converter to_unicode; /* client encoding to UTF-8 */ + from_mic_converter from_unicode; /* UTF-8 to client encoding */ } pg_enconv; extern pg_enconv pg_enconv_tbl[]; extern pg_enconv *pg_get_enconv_by_encoding(int encoding); - -#endif /* FRONTEND */ +#endif /* FRONTEND */ /* * pg_wchar stuff */ typedef int (*mb2wchar_with_len_converter) (const unsigned char *from, - pg_wchar *to, - int len); + pg_wchar *to, + int len); typedef int (*mblen_converter) (const unsigned char *mbstr); typedef struct { - mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multi-byte string to a wchar */ + mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multi-byte + * string to a wchar */ mblen_converter mblen; /* returns the length of a multi-byte char */ - int maxmblen; /* max bytes for a char in this charset */ + int maxmblen; /* max bytes for a char in this charset */ } pg_wchar_tbl; extern pg_wchar_tbl pg_wchar_table[]; @@ -285,8 +289,8 @@ extern pg_wchar_tbl pg_wchar_table[]; */ typedef struct { - unsigned int utf; /* UTF-8 */ - unsigned int code; /* local code */ + unsigned int utf; /* UTF-8 */ + unsigned int code; /* local code */ } pg_utf_to_local; /* @@ -294,8 +298,8 @@ typedef struct */ typedef struct { - unsigned int code; /* local code */ - unsigned int utf; /* UTF-8 */ + unsigned int code; /* local code */ + unsigned int utf; /* UTF-8 */ } pg_local_to_utf; extern int pg_mb2wchar(const unsigned char *, pg_wchar *); @@ -303,7 +307,7 @@ extern int pg_mb2wchar_with_len(const unsigned char *, pg_wchar *, int); extern int pg_char_and_wchar_strcmp(const char *, const pg_wchar *); extern int pg_wchar_strncmp(const pg_wchar *, const pg_wchar *, size_t); extern int pg_char_and_wchar_strncmp(const char *, const pg_wchar *, size_t); -extern size_t pg_wchar_strlen(const pg_wchar *); +extern size_t pg_wchar_strlen(const pg_wchar *); extern int pg_mblen(const unsigned char *); extern int pg_encoding_mblen(int, const unsigned char *); extern int pg_mule_mblen(const unsigned char *); @@ -315,24 +319,24 @@ extern int pg_mbcharcliplen(const unsigned char *, int, int); extern int pg_encoding_max_length(int); extern int pg_database_encoding_max_length(void); -extern int pg_set_client_encoding(int); -extern int pg_get_client_encoding(void); -extern const char *pg_get_client_encoding_name(void); +extern int pg_set_client_encoding(int); +extern int pg_get_client_encoding(void); +extern const char *pg_get_client_encoding_name(void); -extern void SetDatabaseEncoding(int); -extern int GetDatabaseEncoding(void); -extern const char *GetDatabaseEncodingName(void); +extern void SetDatabaseEncoding(int); +extern int GetDatabaseEncoding(void); +extern const char *GetDatabaseEncodingName(void); extern int pg_valid_client_encoding(const char *name); extern int pg_valid_server_encoding(const char *name); extern int pg_utf_mblen(const unsigned char *); -extern int pg_find_encoding_converters(int src, int dest, - to_mic_converter *src_to_mic, - from_mic_converter *dest_from_mic); +extern int pg_find_encoding_converters(int src, int dest, + to_mic_converter *src_to_mic, + from_mic_converter *dest_from_mic); extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len, - to_mic_converter src_to_mic, - from_mic_converter dest_from_mic); + to_mic_converter src_to_mic, + from_mic_converter dest_from_mic); extern unsigned char *pg_client_to_server(unsigned char *, int); extern unsigned char *pg_server_to_client(unsigned char *, int); @@ -340,8 +344,6 @@ extern unsigned char *pg_server_to_client(unsigned char *, int); extern unsigned short BIG5toCNS(unsigned short, unsigned char *); extern unsigned short CNStoBIG5(unsigned short, unsigned char); -char *pg_verifymbstr(const unsigned char *, int); - +char *pg_verifymbstr(const unsigned char *, int); #endif /* MULTIBYTE */ - #endif /* PG_WCHAR_H */ diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 70d19f8192..b85784cdca 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.94 2001/10/21 03:25:35 tgl Exp $ + * $Id: miscadmin.h,v 1.95 2001/10/25 05:49:54 momjian Exp $ * * NOTES * some of the information in this file should be moved to @@ -47,7 +47,7 @@ * * Special mechanisms are used to let an interrupt be accepted when we are * waiting for a lock or when we are waiting for command input (but, of - * course, only if the interrupt holdoff counter is zero). See the + * course, only if the interrupt holdoff counter is zero). See the * related code for details. * * A related, but conceptually distinct, mechanism is the "critical section" @@ -116,7 +116,7 @@ extern void ClosePostmasterPorts(bool pgstat_too); extern bool Noversion; extern char *DataDir; -extern DLLIMPORT int MyProcPid; +extern DLLIMPORT int MyProcPid; extern struct Port *MyProcPort; extern long MyCancelKey; @@ -128,7 +128,7 @@ extern char pg_pathname[]; * * extern BackendId MyBackendId; */ -extern DLLIMPORT Oid MyDatabaseId; +extern DLLIMPORT Oid MyDatabaseId; extern bool IsUnderPostmaster; @@ -175,7 +175,7 @@ extern int VacuumMem; /* * A few postmaster startup options are exported here so the - * configuration file processor can access them. + * configuration file processor can access them. */ extern bool NetServer; @@ -230,7 +230,8 @@ extern char *convertstr(unsigned char *buff, int len, int dest); /* in utils/misc/superuser.c */ extern bool superuser(void); /* current user is superuser */ -extern bool is_dbadmin(Oid dbid); /* current user is owner of database */ +extern bool is_dbadmin(Oid dbid); /* current user is owner of + * database */ /***************************************************************************** @@ -259,9 +260,10 @@ extern bool is_dbadmin(Oid dbid); /* current user is owner of database */ typedef enum ProcessingMode { - BootstrapProcessing, /* bootstrap creation of template database */ - InitProcessing, /* initializing system */ - NormalProcessing /* normal processing */ + BootstrapProcessing, /* bootstrap creation of template + * database */ + InitProcessing, /* initializing system */ + NormalProcessing/* normal processing */ } ProcessingMode; extern ProcessingMode Mode; @@ -303,5 +305,4 @@ extern void ValidatePgVersion(const char *path); extern void IgnoreSystemIndexes(bool mode); extern bool IsIgnoringSystemIndexes(void); extern bool IsCacheInitialized(void); - #endif /* MISCADMIN_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index ef880505c1..69f0597f81 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.63 2001/09/29 07:57:04 inoue Exp $ + * $Id: execnodes.h,v 1.64 2001/10/25 05:50:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -98,9 +98,11 @@ typedef struct ExprContext */ typedef enum { - ExprSingleResult, /* expression does not return a set */ - ExprMultipleResult, /* this result is an element of a set */ - ExprEndResult /* there are no more elements in the set */ + ExprSingleResult, /* expression does not return a + * set */ + ExprMultipleResult, /* this result is an element of a + * set */ + ExprEndResult /* there are no more elements in the set */ } ExprDoneCond; /* @@ -174,7 +176,7 @@ typedef struct ProjectionInfo * resultSlot: tuple slot that can be used to hold cleaned tuple. * * NOTE: the original targetList and tupType are passed to ExecInitJunkFilter, - * as is the resultSlot. These items do not belong to the JunkFilter. All + * as is the resultSlot. These items do not belong to the JunkFilter. All * the other subsidiary structures are created during ExecInitJunkFilter, * and all of them can be freed by deleting the memory context junkContext. * This would not be needed if we had a cleaner approach to managing @@ -461,7 +463,7 @@ typedef struct TidScanState int tss_NumTids; int tss_TidPtr; int tss_MarkTidPtr; - ItemPointerData* tss_TidList; + ItemPointerData *tss_TidList; HeapTupleData tss_htup; } TidScanState; @@ -750,7 +752,5 @@ typedef struct TeeState HeapScanDesc tee_leftScanDesc, tee_rightScanDesc; } TeeState; - #endif - #endif /* EXECNODES_H */ diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h index 93f2296f98..9a4dc6e734 100644 --- a/src/include/nodes/makefuncs.h +++ b/src/include/nodes/makefuncs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: makefuncs.h,v 1.27 2001/01/24 19:43:25 momjian Exp $ + * $Id: makefuncs.h,v 1.28 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,5 +45,4 @@ extern Const *makeConst(Oid consttype, extern Const *makeNullConst(Oid consttype); extern Attr *makeAttr(char *relname, char *attname); - #endif /* MAKEFUNC_H */ diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h index 374292b9e0..7aa88f48ce 100644 --- a/src/include/nodes/memnodes.h +++ b/src/include/nodes/memnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: memnodes.h,v 1.21 2001/03/22 04:00:51 momjian Exp $ + * $Id: memnodes.h,v 1.22 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,5 +72,4 @@ typedef struct MemoryContextData ((context) != NULL && \ (IsA((context), AllocSetContext))) - #endif /* MEMNODES_H */ diff --git a/src/include/nodes/nodeFuncs.h b/src/include/nodes/nodeFuncs.h index dc396f1612..f26db84063 100644 --- a/src/include/nodes/nodeFuncs.h +++ b/src/include/nodes/nodeFuncs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeFuncs.h,v 1.13 2001/01/24 19:43:25 momjian Exp $ + * $Id: nodeFuncs.h,v 1.14 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ extern bool single_node(Node *node); extern bool var_is_outer(Var *var); extern bool var_is_rel(Var *var); extern Oper *replace_opid(Oper *oper); - #endif /* NODEFUNCS_H */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index eee8bb4f50..66ca855f9a 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.93 2001/07/16 19:12:58 momjian Exp $ + * $Id: nodes.h,v 1.94 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,211 +23,211 @@ */ typedef enum NodeTag { - T_Invalid = 0, + T_Invalid = 0, /* * TAGS FOR PLAN NODES (plannodes.h) */ - T_Plan = 10, - T_Result, - T_Append, - T_Scan, - T_SeqScan, - T_IndexScan, - T_Join, - T_NestLoop, - T_MergeJoin, - T_HashJoin, - T_Limit, - T_Material, - T_Sort, - T_Agg, - T_Unique, - T_Hash, - T_SetOp, - T_Group, - T_SubPlan, - T_TidScan, - T_SubqueryScan, + T_Plan = 10, + T_Result, + T_Append, + T_Scan, + T_SeqScan, + T_IndexScan, + T_Join, + T_NestLoop, + T_MergeJoin, + T_HashJoin, + T_Limit, + T_Material, + T_Sort, + T_Agg, + T_Unique, + T_Hash, + T_SetOp, + T_Group, + T_SubPlan, + T_TidScan, + T_SubqueryScan, /* * TAGS FOR PRIMITIVE NODES (primnodes.h) */ - T_Resdom = 100, - T_Fjoin, - T_Expr, - T_Var, - T_Oper, - T_Const, - T_Param, - T_Aggref, - T_SubLink, - T_Func, - T_FieldSelect, - T_ArrayRef, - T_Iter, - T_RelabelType, - T_RangeTblRef, - T_FromExpr, - T_JoinExpr, + T_Resdom = 100, + T_Fjoin, + T_Expr, + T_Var, + T_Oper, + T_Const, + T_Param, + T_Aggref, + T_SubLink, + T_Func, + T_FieldSelect, + T_ArrayRef, + T_Iter, + T_RelabelType, + T_RangeTblRef, + T_FromExpr, + T_JoinExpr, /* * TAGS FOR PLANNER NODES (relation.h) */ - T_RelOptInfo = 200, - T_Path, - T_IndexPath, - T_NestPath, - T_MergePath, - T_HashPath, - T_TidPath, - T_AppendPath, - T_PathKeyItem, - T_RestrictInfo, - T_JoinInfo, - T_Stream, - T_IndexOptInfo, + T_RelOptInfo = 200, + T_Path, + T_IndexPath, + T_NestPath, + T_MergePath, + T_HashPath, + T_TidPath, + T_AppendPath, + T_PathKeyItem, + T_RestrictInfo, + T_JoinInfo, + T_Stream, + T_IndexOptInfo, /* * TAGS FOR EXECUTOR NODES (execnodes.h) */ - T_IndexInfo = 300, - T_ResultRelInfo, - T_TupleCount, - T_TupleTableSlot, - T_ExprContext, - T_ProjectionInfo, - T_JunkFilter, - T_EState, - T_BaseNode, - T_CommonState, - T_ResultState, - T_AppendState, - T_CommonScanState, - T_ScanState, - T_IndexScanState, - T_JoinState, - T_NestLoopState, - T_MergeJoinState, - T_HashJoinState, - T_MaterialState, - T_AggState, - T_GroupState, - T_SortState, - T_UniqueState, - T_HashState, - T_TidScanState, - T_SubqueryScanState, - T_SetOpState, - T_LimitState, + T_IndexInfo = 300, + T_ResultRelInfo, + T_TupleCount, + T_TupleTableSlot, + T_ExprContext, + T_ProjectionInfo, + T_JunkFilter, + T_EState, + T_BaseNode, + T_CommonState, + T_ResultState, + T_AppendState, + T_CommonScanState, + T_ScanState, + T_IndexScanState, + T_JoinState, + T_NestLoopState, + T_MergeJoinState, + T_HashJoinState, + T_MaterialState, + T_AggState, + T_GroupState, + T_SortState, + T_UniqueState, + T_HashState, + T_TidScanState, + T_SubqueryScanState, + T_SetOpState, + T_LimitState, /* * TAGS FOR MEMORY NODES (memnodes.h) */ - T_MemoryContext = 400, - T_AllocSetContext, + T_MemoryContext = 400, + T_AllocSetContext, /* * TAGS FOR VALUE NODES (pg_list.h) */ - T_Value = 500, - T_List, - T_Integer, - T_Float, - T_String, - T_BitString, - T_Null, + T_Value = 500, + T_List, + T_Integer, + T_Float, + T_String, + T_BitString, + T_Null, /* * TAGS FOR PARSE TREE NODES (parsenodes.h) */ - T_Query = 600, - T_InsertStmt, - T_DeleteStmt, - T_UpdateStmt, - T_SelectStmt, - T_AlterTableStmt, - T_SetOperationStmt, - T_GrantStmt, - T_ClosePortalStmt, - T_ClusterStmt, - T_CopyStmt, - T_CreateStmt, - T_VersionStmt, - T_DefineStmt, - T_DropStmt, - T_TruncateStmt, - T_CommentStmt, - T_FetchStmt, - T_IndexStmt, - T_ProcedureStmt, - T_RemoveAggrStmt, - T_RemoveFuncStmt, - T_RemoveOperStmt, - T_RenameStmt, - T_RuleStmt, - T_NotifyStmt, - T_ListenStmt, - T_UnlistenStmt, - T_TransactionStmt, - T_ViewStmt, - T_LoadStmt, - T_CreatedbStmt, - T_DropdbStmt, - T_VacuumStmt, - T_ExplainStmt, - T_CreateSeqStmt, - T_VariableSetStmt, - T_VariableShowStmt, - T_VariableResetStmt, - T_CreateTrigStmt, - T_DropTrigStmt, - T_CreatePLangStmt, - T_DropPLangStmt, - T_CreateUserStmt, - T_AlterUserStmt, - T_DropUserStmt, - T_LockStmt, - T_ConstraintsSetStmt, - T_CreateGroupStmt, - T_AlterGroupStmt, - T_DropGroupStmt, - T_ReindexStmt, - T_CheckPointStmt, - - T_A_Expr = 700, - T_Attr, - T_A_Const, - T_ParamNo, - T_Ident, - T_FuncCall, - T_A_Indices, - T_ResTarget, - T_TypeCast, - T_RangeSubselect, - T_SortGroupBy, - T_RangeVar, - T_TypeName, - T_IndexElem, - T_ColumnDef, - T_Constraint, - T_DefElem, - T_TargetEntry, - T_RangeTblEntry, - T_SortClause, - T_GroupClause, - T_NullTest, - T_BooleanTest, - T_CaseExpr, - T_CaseWhen, - T_FkConstraint, - T_PrivGrantee, + T_Query = 600, + T_InsertStmt, + T_DeleteStmt, + T_UpdateStmt, + T_SelectStmt, + T_AlterTableStmt, + T_SetOperationStmt, + T_GrantStmt, + T_ClosePortalStmt, + T_ClusterStmt, + T_CopyStmt, + T_CreateStmt, + T_VersionStmt, + T_DefineStmt, + T_DropStmt, + T_TruncateStmt, + T_CommentStmt, + T_FetchStmt, + T_IndexStmt, + T_ProcedureStmt, + T_RemoveAggrStmt, + T_RemoveFuncStmt, + T_RemoveOperStmt, + T_RenameStmt, + T_RuleStmt, + T_NotifyStmt, + T_ListenStmt, + T_UnlistenStmt, + T_TransactionStmt, + T_ViewStmt, + T_LoadStmt, + T_CreatedbStmt, + T_DropdbStmt, + T_VacuumStmt, + T_ExplainStmt, + T_CreateSeqStmt, + T_VariableSetStmt, + T_VariableShowStmt, + T_VariableResetStmt, + T_CreateTrigStmt, + T_DropTrigStmt, + T_CreatePLangStmt, + T_DropPLangStmt, + T_CreateUserStmt, + T_AlterUserStmt, + T_DropUserStmt, + T_LockStmt, + T_ConstraintsSetStmt, + T_CreateGroupStmt, + T_AlterGroupStmt, + T_DropGroupStmt, + T_ReindexStmt, + T_CheckPointStmt, + + T_A_Expr = 700, + T_Attr, + T_A_Const, + T_ParamNo, + T_Ident, + T_FuncCall, + T_A_Indices, + T_ResTarget, + T_TypeCast, + T_RangeSubselect, + T_SortGroupBy, + T_RangeVar, + T_TypeName, + T_IndexElem, + T_ColumnDef, + T_Constraint, + T_DefElem, + T_TargetEntry, + T_RangeTblEntry, + T_SortClause, + T_GroupClause, + T_NullTest, + T_BooleanTest, + T_CaseExpr, + T_CaseWhen, + T_FkConstraint, + T_PrivGrantee, /* * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h) */ - T_TriggerData = 800, /* in commands/trigger.h */ - T_ReturnSetInfo /* in nodes/execnodes.h */ + T_TriggerData = 800, /* in commands/trigger.h */ + T_ReturnSetInfo /* in nodes/execnodes.h */ } NodeTag; @@ -313,14 +313,14 @@ typedef double Cost; /* execution cost (in page-access units) */ */ typedef enum CmdType { - CMD_UNKNOWN, - CMD_SELECT, /* select stmt (formerly retrieve) */ - CMD_UPDATE, /* update stmt (formerly replace) */ - CMD_INSERT, /* insert stmt (formerly append) */ - CMD_DELETE, - CMD_UTILITY, /* cmds like create, destroy, copy, + CMD_UNKNOWN, + CMD_SELECT, /* select stmt (formerly retrieve) */ + CMD_UPDATE, /* update stmt (formerly replace) */ + CMD_INSERT, /* insert stmt (formerly append) */ + CMD_DELETE, + CMD_UTILITY, /* cmds like create, destroy, copy, * vacuum, etc. */ - CMD_NOTHING /* dummy command for instead nothing rules + CMD_NOTHING /* dummy command for instead nothing rules * with qual */ } CmdType; @@ -337,15 +337,14 @@ typedef enum CmdType */ typedef enum JoinType { - /* * The canonical kinds of joins */ - JOIN_INNER, /* matching tuple pairs only */ - JOIN_LEFT, /* pairs + unmatched outer tuples */ - JOIN_FULL, /* pairs + unmatched outer + unmatched + JOIN_INNER, /* matching tuple pairs only */ + JOIN_LEFT, /* pairs + unmatched outer tuples */ + JOIN_FULL, /* pairs + unmatched outer + unmatched * inner */ - JOIN_RIGHT, /* pairs + unmatched inner tuples */ + JOIN_RIGHT, /* pairs + unmatched inner tuples */ /* * SQL92 considers UNION JOIN to be a kind of join, so list it here @@ -353,7 +352,7 @@ typedef enum JoinType * join in the executor. (The planner must convert it to an Append * plan.) */ - JOIN_UNION + JOIN_UNION /* * Eventually we will have some additional join types for efficient @@ -365,5 +364,4 @@ typedef enum JoinType ((jointype) == JOIN_LEFT || \ (jointype) == JOIN_FULL || \ (jointype) == JOIN_RIGHT) - #endif /* NODES_H */ diff --git a/src/include/nodes/params.h b/src/include/nodes/params.h index 6fb2a4e157..5c55d6cf35 100644 --- a/src/include/nodes/params.h +++ b/src/include/nodes/params.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: params.h,v 1.13 2001/01/24 19:43:25 momjian Exp $ + * $Id: params.h,v 1.14 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -99,5 +99,4 @@ typedef struct ParamExecData Datum value; bool isnull; } ParamExecData; - #endif /* PARAMS_H */ diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index ef6c9c63b5..2458a543fb 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.147 2001/10/18 17:30:16 thomas Exp $ + * $Id: parsenodes.h,v 1.148 2001/10/25 05:50:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,11 +79,11 @@ typedef struct Query * commit to the exact set of child tables at parse time. This field * ought to go in some sort of TopPlan plan node, not in the Query. */ - List *resultRelations;/* integer list of RT indexes, or NIL */ + List *resultRelations; /* integer list of RT indexes, or NIL */ /* internal to planner */ List *base_rel_list; /* list of base-relation RelOptInfos */ - List *other_rel_list; /* list of other 1-relation RelOptInfos */ + List *other_rel_list; /* list of other 1-relation RelOptInfos */ List *join_rel_list; /* list of join-relation RelOptInfos */ List *equi_key_list; /* list of lists of equijoined * PathKeyItems */ @@ -93,9 +93,9 @@ typedef struct Query typedef enum InhOption { - INH_NO, /* Do NOT scan child tables */ - INH_YES, /* DO scan child tables */ - INH_DEFAULT /* Use current SQL_inheritance option */ + INH_NO, /* Do NOT scan child tables */ + INH_YES, /* DO scan child tables */ + INH_DEFAULT /* Use current SQL_inheritance option */ } InhOption; /***************************************************************************** @@ -118,7 +118,7 @@ typedef struct AlterTableStmt { NodeTag type; char subtype; /*------------ - * A = add column + * A = add column * T = alter column default * S = alter column statistics * D = drop column @@ -228,17 +228,18 @@ typedef struct CreateStmt typedef enum ConstrType /* types of constraints */ { - CONSTR_NULL, /* not SQL92, but a lot of people expect + CONSTR_NULL, /* not SQL92, but a lot of people expect * it */ - CONSTR_NOTNULL, - CONSTR_DEFAULT, - CONSTR_CHECK, - CONSTR_PRIMARY, - CONSTR_UNIQUE, - CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */ - CONSTR_ATTR_NOT_DEFERRABLE, - CONSTR_ATTR_DEFERRED, - CONSTR_ATTR_IMMEDIATE + CONSTR_NOTNULL, + CONSTR_DEFAULT, + CONSTR_CHECK, + CONSTR_PRIMARY, + CONSTR_UNIQUE, + CONSTR_ATTR_DEFERRABLE, /* attributes for previous + * constraint node */ + CONSTR_ATTR_NOT_DEFERRABLE, + CONSTR_ATTR_DEFERRED, + CONSTR_ATTR_IMMEDIATE } ConstrType; typedef struct Constraint @@ -398,7 +399,7 @@ typedef struct CreateSeqStmt { NodeTag type; char *seqname; /* the relation to create */ - bool istemp; /* is this a temp sequence? */ + bool istemp; /* is this a temp sequence? */ List *options; } CreateSeqStmt; @@ -702,7 +703,8 @@ typedef struct VacuumStmt bool analyze; /* do ANALYZE step */ bool freeze; /* early-freeze option */ bool verbose; /* print progress info */ - char *vacrel; /* name of single table to process, or NULL */ + char *vacrel; /* name of single table to process, or + * NULL */ List *va_cols; /* list of column names, or NIL for all */ } VacuumStmt; @@ -862,10 +864,10 @@ typedef struct UpdateStmt */ typedef enum SetOperation { - SETOP_NONE = 0, - SETOP_UNION, - SETOP_INTERSECT, - SETOP_EXCEPT + SETOP_NONE = 0, + SETOP_UNION, + SETOP_INTERSECT, + SETOP_EXCEPT } SetOperation; typedef struct SelectStmt @@ -1052,14 +1054,14 @@ typedef struct CaseWhen typedef enum NullTestType { - IS_NULL, IS_NOT_NULL + IS_NULL, IS_NOT_NULL } NullTestType; typedef struct NullTest { - NodeTag type; - Node *arg; /* input expression */ - NullTestType nulltesttype; /* IS NULL, IS NOT NULL */ + NodeTag type; + Node *arg; /* input expression */ + NullTestType nulltesttype; /* IS NULL, IS NOT NULL */ } NullTest; /* ---------------- @@ -1074,14 +1076,14 @@ typedef struct NullTest typedef enum BoolTestType { - IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN + IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN } BoolTestType; typedef struct BooleanTest { - NodeTag type; - Node *arg; /* input expression */ - BoolTestType booltesttype; /* test type */ + NodeTag type; + Node *arg; /* input expression */ + BoolTestType booltesttype; /* test type */ } BooleanTest; /* @@ -1339,7 +1341,7 @@ typedef struct RangeTblEntry typedef struct SortClause { NodeTag type; - Index tleSortGroupRef;/* reference into targetlist */ + Index tleSortGroupRef; /* reference into targetlist */ Oid sortop; /* the sort operator to use */ } SortClause; @@ -1352,5 +1354,4 @@ typedef struct SortClause * nodetags...). We have routines that operate interchangeably on both. */ typedef SortClause GroupClause; - #endif /* PARSENODES_H */ diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 3986f23971..db303e2da8 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_list.h,v 1.23 2001/01/24 19:43:26 momjian Exp $ + * $Id: pg_list.h,v 1.24 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -147,5 +147,4 @@ extern void freeList(List *list); /* in copyfuncs.c */ extern List *listCopy(List *list); - #endif /* PG_LIST_H */ diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index eef1678432..be66b92fce 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.50 2001/09/18 01:59:07 tgl Exp $ + * $Id: plannodes.h,v 1.51 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,8 +89,8 @@ typedef struct Plan * individual nodes point to one EState * for the whole top-level plan */ - struct Instrumentation *instrument; /* Optional runtime stats for this - * plan node */ + struct Instrumentation *instrument; /* Optional runtime stats for this + * plan node */ /* * Common structural data for all Plan types. XXX chgParam is runtime @@ -373,10 +373,10 @@ typedef struct Unique */ typedef enum SetOpCmd { - SETOPCMD_INTERSECT, - SETOPCMD_INTERSECT_ALL, - SETOPCMD_EXCEPT, - SETOPCMD_EXCEPT_ALL + SETOPCMD_INTERSECT, + SETOPCMD_INTERSECT_ALL, + SETOPCMD_EXCEPT, + SETOPCMD_EXCEPT_ALL } SetOpCmd; typedef struct SetOp @@ -433,7 +433,6 @@ typedef struct Tee * Tee may be different than the parent * plans */ } Tee; - #endif /* --------------------- @@ -464,5 +463,4 @@ typedef struct SubPlan bool needShutdown; /* TRUE = need to shutdown subplan */ HeapTuple curTuple; /* copy of most recent tuple from subplan */ } SubPlan; - #endif /* PLANNODES_H */ diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 9e69ed6099..b9bada1332 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.54 2001/05/07 00:43:25 tgl Exp $ + * $Id: primnodes.h,v 1.55 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,7 +103,7 @@ typedef struct Fjoin */ typedef enum OpType { - OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR + OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR } OpType; typedef struct Expr @@ -345,7 +345,7 @@ typedef struct Aggref */ typedef enum SubLinkType { - EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK + EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK } SubLinkType; @@ -549,5 +549,4 @@ typedef struct FromExpr List *fromlist; /* List of join subtrees */ Node *quals; /* qualifiers on join, if any */ } FromExpr; - #endif /* PRIMNODES_H */ diff --git a/src/include/nodes/print.h b/src/include/nodes/print.h index 780788581a..c40daed69e 100644 --- a/src/include/nodes/print.h +++ b/src/include/nodes/print.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: print.h,v 1.13 2001/01/24 19:43:26 momjian Exp $ + * $Id: print.h,v 1.14 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ extern void print_slot(TupleTableSlot *slot); extern void print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label); extern void print_plan(Plan *p, Query *parsetree); - #endif /* PRINT_H */ diff --git a/src/include/nodes/readfuncs.h b/src/include/nodes/readfuncs.h index b73aef5379..f770e28c69 100644 --- a/src/include/nodes/readfuncs.h +++ b/src/include/nodes/readfuncs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: readfuncs.h,v 1.11 2001/01/24 19:43:26 momjian Exp $ + * $Id: readfuncs.h,v 1.12 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ extern void *nodeRead(bool read_car_only); * prototypes for functions in readfuncs.c */ extern Node *parsePlanString(void); - #endif /* READFUNCS_H */ diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 43af861df0..117b95f73e 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: relation.h,v 1.58 2001/08/21 16:36:06 tgl Exp $ + * $Id: relation.h,v 1.59 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ typedef List *Relids; */ typedef enum CostSelector { - STARTUP_COST, TOTAL_COST + STARTUP_COST, TOTAL_COST } CostSelector; /*---------- @@ -179,14 +179,14 @@ typedef struct RelOptInfo * useful. So now we have a separate IndexOptInfo struct for indexes. * * indexoid - OID of the index relation itself - * pages - number of disk pages in index - * tuples - number of index tuples in index + * pages - number of disk pages in index + * tuples - number of index tuples in index * ncolumns - number of columns in index - * nkeys - number of keys used by index (input columns) + * nkeys - number of keys used by index (input columns) * classlist - List of PG_OPCLASS OIDs for the index * indexkeys - List of base-relation attribute numbers that are index keys * ordering - List of PG_OPERATOR OIDs which order the indexscan result - * relam - the OID of the pg_am of the index + * relam - the OID of the pg_am of the index * amcostestimate - OID of the relam's cost estimator * indproc - OID of the function if a functional index, else 0 * indpred - index predicate if a partial index, else NULL @@ -197,7 +197,7 @@ typedef struct RelOptInfo * is the number of table columns passed to the function. classlist[] * and ordering[] have ncolumns entries, while indexkeys[] has nkeys * entries. - * + * * Note: for historical reasons, the arrays classlist, indexkeys and * ordering have an extra entry that is always zero. Some code scans * until it sees a zero rather than looking at ncolumns or nkeys. @@ -221,7 +221,7 @@ typedef struct IndexOptInfo Oid *ordering; /* OIDs of sort operators for each column */ Oid relam; /* OID of the access method (in pg_am) */ - RegProcedure amcostestimate;/* OID of the access method's cost fcn */ + RegProcedure amcostestimate; /* OID of the access method's cost fcn */ Oid indproc; /* if a functional index */ List *indpred; /* if a partial index */ @@ -339,7 +339,7 @@ typedef struct TidPath { Path path; List *tideval; - Relids unjoined_relids;/* some rels not yet part of my Path */ + Relids unjoined_relids; /* some rels not yet part of my Path */ } TidPath; /* @@ -510,7 +510,7 @@ typedef struct RestrictInfo /* cache space for costs (currently only used for join clauses) */ Cost eval_cost; /* eval cost of clause; -1 if not yet set */ - Selectivity this_selec; /* selectivity; -1 if not yet set */ + Selectivity this_selec; /* selectivity; -1 if not yet set */ /* valid if clause is mergejoinable, else InvalidOid: */ Oid mergejoinoperator; /* copy of clause operator */ @@ -546,7 +546,7 @@ typedef struct RestrictInfo typedef struct JoinInfo { NodeTag type; - Relids unjoined_relids; /* some rels not yet part of my RelOptInfo */ + Relids unjoined_relids; /* some rels not yet part of my RelOptInfo */ List *jinfo_restrictinfo; /* relevant RestrictInfos */ } JoinInfo; @@ -587,5 +587,4 @@ typedef struct Stream Cost groupcost; Selectivity groupsel; } Stream; - #endif /* RELATION_H */ diff --git a/src/include/optimizer/_deadcode/xfunc.h b/src/include/optimizer/_deadcode/xfunc.h index 0fcba3f60c..8d14f90288 100644 --- a/src/include/optimizer/_deadcode/xfunc.h +++ b/src/include/optimizer/_deadcode/xfunc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: xfunc.h,v 1.5 2001/01/24 19:43:26 momjian Exp $ + * $Id: xfunc.h,v 1.6 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,5 +79,4 @@ extern bool xfunc_copyrel(RelOptInfo *from, RelOptInfo **to); * function prototypes for path/predmig.c */ extern bool xfunc_do_predmig(Path root); - #endif /* XFUNC_H */ diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 1ed5c25cd7..366e382116 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: clauses.h,v 1.45 2001/07/31 17:56:31 tgl Exp $ + * $Id: clauses.h,v 1.46 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,5 +71,4 @@ extern void query_tree_mutator(Query *query, Node *(*mutator) (), #define is_subplan(clause) ((clause) != NULL && \ IsA(clause, Expr) && \ ((Expr *) (clause))->opType == SUBPLAN_EXPR) - #endif /* CLAUSES_H */ diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 83b039c99d..b163505875 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: cost.h,v 1.40 2001/06/05 05:26:05 tgl Exp $ + * $Id: cost.h,v 1.41 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,26 +53,26 @@ extern bool enable_mergejoin; extern bool enable_hashjoin; extern void cost_seqscan(Path *path, Query *root, - RelOptInfo *baserel); + RelOptInfo *baserel); extern void cost_index(Path *path, Query *root, - RelOptInfo *baserel, IndexOptInfo *index, - List *indexQuals, bool is_injoin); + RelOptInfo *baserel, IndexOptInfo *index, + List *indexQuals, bool is_injoin); extern void cost_tidscan(Path *path, Query *root, - RelOptInfo *baserel, List *tideval); + RelOptInfo *baserel, List *tideval); extern void cost_sort(Path *path, Query *root, - List *pathkeys, double tuples, int width); + List *pathkeys, double tuples, int width); extern void cost_nestloop(Path *path, Query *root, - Path *outer_path, Path *inner_path, - List *restrictlist); + Path *outer_path, Path *inner_path, + List *restrictlist); extern void cost_mergejoin(Path *path, Query *root, - Path *outer_path, Path *inner_path, - List *restrictlist, - List *mergeclauses, - List *outersortkeys, List *innersortkeys); + Path *outer_path, Path *inner_path, + List *restrictlist, + List *mergeclauses, + List *outersortkeys, List *innersortkeys); extern void cost_hashjoin(Path *path, Query *root, - Path *outer_path, Path *inner_path, - List *restrictlist, - List *hashclauses); + Path *outer_path, Path *inner_path, + List *restrictlist, + List *hashclauses); extern Cost cost_qual_eval(List *quals); extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel); extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel, @@ -92,7 +92,6 @@ extern Selectivity clauselist_selectivity(Query *root, List *clauses, int varRelid); extern Selectivity clause_selectivity(Query *root, - Node *clause, - int varRelid); - + Node *clause, + int varRelid); #endif /* COST_H */ diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h index 34b7065f76..8b8e7a5953 100644 --- a/src/include/optimizer/geqo.h +++ b/src/include/optimizer/geqo.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo.h,v 1.24 2001/03/22 04:00:53 momjian Exp $ + * $Id: geqo.h,v 1.25 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,5 +76,4 @@ extern Cost geqo_eval(Query *root, List *initial_rels, extern RelOptInfo *gimme_tree(Query *root, List *initial_rels, Gene *tour, int num_gene, int rel_count, RelOptInfo *old_rel); - #endif /* GEQO_H */ diff --git a/src/include/optimizer/geqo_copy.h b/src/include/optimizer/geqo_copy.h index 8029861878..15d7ba4c92 100644 --- a/src/include/optimizer/geqo_copy.h +++ b/src/include/optimizer/geqo_copy.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_copy.h,v 1.9 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_copy.h,v 1.10 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,5 +25,4 @@ #include "optimizer/geqo_gene.h" extern void geqo_copy(Chromosome *chromo1, Chromosome *chromo2, int string_length); - #endif /* GEQO_COPY_H */ diff --git a/src/include/optimizer/geqo_gene.h b/src/include/optimizer/geqo_gene.h index 3ade00bf4a..528ba2bce1 100644 --- a/src/include/optimizer/geqo_gene.h +++ b/src/include/optimizer/geqo_gene.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_gene.h,v 1.10 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_gene.h,v 1.11 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ typedef struct Pool int size; int string_length; } Pool; - #endif /* GEQO_GENE_H */ diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h index a1a893afd8..24c7b7a351 100644 --- a/src/include/optimizer/geqo_misc.h +++ b/src/include/optimizer/geqo_misc.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.h,v 1.15 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_misc.h,v 1.16 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ extern void print_edge_table(FILE *fp, Edge *edge_table, int num_gene); extern void geqo_print_rel(Query *root, RelOptInfo *rel); extern void geqo_print_path(Query *root, Path *path, int indent); extern void geqo_print_joinclauses(Query *root, List *clauses); - #endif /* GEQO_MISC_H */ diff --git a/src/include/optimizer/geqo_mutation.h b/src/include/optimizer/geqo_mutation.h index 63a2295979..85d2879ad6 100644 --- a/src/include/optimizer/geqo_mutation.h +++ b/src/include/optimizer/geqo_mutation.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_mutation.h,v 1.9 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_mutation.h,v 1.10 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,5 +25,4 @@ #include "optimizer/geqo_gene.h" extern void geqo_mutation(Gene *tour, int num_gene); - #endif /* GEQO_MUTATION_H */ diff --git a/src/include/optimizer/geqo_pool.h b/src/include/optimizer/geqo_pool.h index 264bacba8f..6f0db6a7e2 100644 --- a/src/include/optimizer/geqo_pool.h +++ b/src/include/optimizer/geqo_pool.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_pool.h,v 1.12 2001/03/22 04:00:54 momjian Exp $ + * $Id: geqo_pool.h,v 1.13 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,5 +37,4 @@ extern void free_chromo(Chromosome *chromo); extern void spread_chromo(Chromosome *chromo, Pool *pool); extern void sort_pool(Pool *pool); - #endif /* GEQO_POOL_H */ diff --git a/src/include/optimizer/geqo_random.h b/src/include/optimizer/geqo_random.h index df66fbf984..c9293c8f62 100644 --- a/src/include/optimizer/geqo_random.h +++ b/src/include/optimizer/geqo_random.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_random.h,v 1.8 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_random.h,v 1.9 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,5 +34,4 @@ #define geqo_randint(upper,lower) \ ( (int) floor( geqo_rand()*(((upper)-(lower))+0.999999) ) + (lower) ) - #endif /* GEQO_RANDOM_H */ diff --git a/src/include/optimizer/geqo_recombination.h b/src/include/optimizer/geqo_recombination.h index 5dd2362403..3b99c1b432 100644 --- a/src/include/optimizer/geqo_recombination.h +++ b/src/include/optimizer/geqo_recombination.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_recombination.h,v 1.9 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_recombination.h,v 1.10 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,5 +77,4 @@ extern void ox1(Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_ /* order crossover [OX2] according to Syswerda */ extern void ox2(Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table); - #endif /* GEQO_RECOMBINATION_H */ diff --git a/src/include/optimizer/geqo_selection.h b/src/include/optimizer/geqo_selection.h index 44bee7a56f..a3d94f7cdf 100644 --- a/src/include/optimizer/geqo_selection.h +++ b/src/include/optimizer/geqo_selection.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_selection.h,v 1.9 2001/01/24 19:43:26 momjian Exp $ + * $Id: geqo_selection.h,v 1.10 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,5 +26,4 @@ #include "optimizer/geqo_gene.h" extern void geqo_selection(Chromosome *momma, Chromosome *daddy, Pool *pool, double bias); - #endif /* GEQO_SELECTION_H */ diff --git a/src/include/optimizer/joininfo.h b/src/include/optimizer/joininfo.h index be55d97b03..9573a2ce51 100644 --- a/src/include/optimizer/joininfo.h +++ b/src/include/optimizer/joininfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: joininfo.h,v 1.17 2001/01/24 19:43:26 momjian Exp $ + * $Id: joininfo.h,v 1.18 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ #include "nodes/relation.h" extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids); - #endif /* JOININFO_H */ diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 8979c0d947..4de4ffa367 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pathnode.h,v 1.38 2001/06/05 05:26:05 tgl Exp $ + * $Id: pathnode.h,v 1.39 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,36 +33,36 @@ extern IndexPath *create_index_path(Query *root, RelOptInfo *rel, List *pathkeys, ScanDirection indexscandir); extern TidPath *create_tidscan_path(Query *root, RelOptInfo *rel, - List *tideval); + List *tideval); extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths); extern Path *create_subqueryscan_path(RelOptInfo *rel); extern NestPath *create_nestloop_path(Query *root, - RelOptInfo *joinrel, - JoinType jointype, - Path *outer_path, - Path *inner_path, - List *restrict_clauses, - List *pathkeys); + RelOptInfo *joinrel, + JoinType jointype, + Path *outer_path, + Path *inner_path, + List *restrict_clauses, + List *pathkeys); extern MergePath *create_mergejoin_path(Query *root, - RelOptInfo *joinrel, - JoinType jointype, - Path *outer_path, - Path *inner_path, - List *restrict_clauses, - List *pathkeys, - List *mergeclauses, - List *outersortkeys, - List *innersortkeys); + RelOptInfo *joinrel, + JoinType jointype, + Path *outer_path, + Path *inner_path, + List *restrict_clauses, + List *pathkeys, + List *mergeclauses, + List *outersortkeys, + List *innersortkeys); extern HashPath *create_hashjoin_path(Query *root, - RelOptInfo *joinrel, - JoinType jointype, - Path *outer_path, - Path *inner_path, - List *restrict_clauses, - List *hashclauses); + RelOptInfo *joinrel, + JoinType jointype, + Path *outer_path, + Path *inner_path, + List *restrict_clauses, + List *hashclauses); /* * prototypes for relnode.c @@ -71,9 +71,8 @@ extern RelOptInfo *build_base_rel(Query *root, int relid); extern RelOptInfo *build_other_rel(Query *root, int relid); extern RelOptInfo *find_base_rel(Query *root, int relid); extern RelOptInfo *build_join_rel(Query *root, - RelOptInfo *outer_rel, - RelOptInfo *inner_rel, - JoinType jointype, - List **restrictlist_ptr); - + RelOptInfo *outer_rel, + RelOptInfo *inner_rel, + JoinType jointype, + List **restrictlist_ptr); #endif /* PATHNODE_H */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 1dcb2cc273..0d57d89bbb 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: paths.h,v 1.56 2001/10/18 16:11:42 tgl Exp $ + * $Id: paths.h,v 1.57 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ extern void debug_print_rel(Query *root, RelOptInfo *rel); */ extern void create_index_paths(Query *root, RelOptInfo *rel); extern Oid indexable_operator(Expr *clause, Oid opclass, - bool indexkey_on_left); + bool indexkey_on_left); extern List *extract_or_indexqual_conditions(RelOptInfo *rel, IndexOptInfo *index, Expr *orsubclause); @@ -88,10 +88,12 @@ extern RelOptInfo *make_jointree_rel(Query *root, Node *jtnode); */ typedef enum { - PATHKEYS_EQUAL, /* pathkeys are identical */ - PATHKEYS_BETTER1, /* pathkey 1 is a superset of pathkey 2 */ - PATHKEYS_BETTER2, /* vice versa */ - PATHKEYS_DIFFERENT /* neither pathkey includes the other */ + PATHKEYS_EQUAL, /* pathkeys are identical */ + PATHKEYS_BETTER1, /* pathkey 1 is a superset of + * pathkey 2 */ + PATHKEYS_BETTER2, /* vice versa */ + PATHKEYS_DIFFERENT /* neither pathkey includes the + * other */ } PathKeysComparison; extern void add_equijoined_keys(Query *root, RestrictInfo *restrictinfo); @@ -116,7 +118,7 @@ extern List *build_join_pathkeys(Query *root, extern List *make_pathkeys_for_sortclauses(List *sortclauses, List *tlist); extern void cache_mergeclause_pathkeys(Query *root, - RestrictInfo *restrictinfo); + RestrictInfo *restrictinfo); extern List *find_mergeclauses_for_pathkeys(Query *root, List *pathkeys, List *restrictinfos); @@ -130,5 +132,4 @@ extern int pathkeys_useful_for_ordering(Query *root, List *pathkeys); extern List *truncate_useless_pathkeys(Query *root, RelOptInfo *rel, List *pathkeys); - #endif /* PATHS_H */ diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h index a103f51e3f..1f60ee18df 100644 --- a/src/include/optimizer/plancat.h +++ b/src/include/optimizer/plancat.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: plancat.h,v 1.23 2001/05/20 20:28:20 tgl Exp $ + * $Id: plancat.h,v 1.24 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ extern void get_relation_info(Oid relationObjectId, - bool *hasindex, long *pages, double *tuples); + bool *hasindex, long *pages, double *tuples); extern List *find_secondary_indexes(Oid relationObjectId); @@ -29,12 +29,11 @@ extern bool has_subclass(Oid relationId); extern bool has_unique_index(RelOptInfo *rel, AttrNumber attno); extern Selectivity restriction_selectivity(Query *root, - Oid operator, - List *args, - int varRelid); + Oid operator, + List *args, + int varRelid); extern Selectivity join_selectivity(Query *root, - Oid operator, - List *args); - + Oid operator, + List *args); #endif /* PLANCAT_H */ diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 974dd9a457..8831bb45d2 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.51 2001/06/05 05:26:05 tgl Exp $ + * $Id: planmain.h,v 1.52 2001/10/25 05:50:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,9 +30,9 @@ extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual, Index scanrelid, Plan *subplan); extern Append *make_append(List *appendplans, bool isTarget, List *tlist); extern Sort *make_sort(Query *root, List *tlist, - Plan *lefttree, int keycount); + Plan *lefttree, int keycount); extern Sort *make_sort_from_pathkeys(Query *root, List *tlist, - Plan *lefttree, List *pathkeys); + Plan *lefttree, List *pathkeys); extern Agg *make_agg(List *tlist, List *qual, Plan *lefttree); extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp, AttrNumber *grpColIdx, Plan *lefttree); @@ -67,5 +67,4 @@ extern void fix_opids(Node *node); extern bool _use_keyset_query_optimizer; extern void transformKeySetQuery(Query *origNode); - #endif /* PLANMAIN_H */ diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h index 4a11848242..acd6ff5326 100644 --- a/src/include/optimizer/planner.h +++ b/src/include/optimizer/planner.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: planner.h,v 1.20 2001/06/05 05:26:05 tgl Exp $ + * $Id: planner.h,v 1.21 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,5 @@ extern Plan *planner(Query *parse); extern Plan *subquery_planner(Query *parse, double tuple_fraction); extern Plan *make_sortplan(Query *parse, List *tlist, - Plan *plannode, List *sortcls); - + Plan *plannode, List *sortcls); #endif /* PLANNER_H */ diff --git a/src/include/optimizer/prep.h b/src/include/optimizer/prep.h index 1888248ed5..e4a55e662c 100644 --- a/src/include/optimizer/prep.h +++ b/src/include/optimizer/prep.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: prep.h,v 1.28 2001/05/20 20:28:20 tgl Exp $ + * $Id: prep.h,v 1.29 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,10 +37,9 @@ extern Plan *plan_set_operations(Query *parse); extern List *find_all_inheritors(Oid parentrel); extern List *expand_inherted_rtentry(Query *parse, Index rti, - bool dup_parent); + bool dup_parent); extern Node *adjust_inherited_attrs(Node *node, Index old_rt_index, Oid old_relid, Index new_rt_index, Oid new_relid); - #endif /* PREP_H */ diff --git a/src/include/optimizer/restrictinfo.h b/src/include/optimizer/restrictinfo.h index 084d8e6156..186cf28832 100644 --- a/src/include/optimizer/restrictinfo.h +++ b/src/include/optimizer/restrictinfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: restrictinfo.h,v 1.11 2001/03/22 04:00:56 momjian Exp $ + * $Id: restrictinfo.h,v 1.12 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ extern bool restriction_is_or_clause(RestrictInfo *restrictinfo); extern List *get_actual_clauses(List *restrictinfo_list); extern void get_actual_join_clauses(List *restrictinfo_list, List **joinquals, List **otherquals); - #endif /* RESTRICTINFO_H */ diff --git a/src/include/optimizer/subselect.h b/src/include/optimizer/subselect.h index 9c56a7592b..a56fed5914 100644 --- a/src/include/optimizer/subselect.h +++ b/src/include/optimizer/subselect.h @@ -17,5 +17,4 @@ extern int PlannerPlanId; /* to assign unique ID to subquery plans */ extern List *SS_finalize_plan(Plan *plan); extern Node *SS_replace_correlation_vars(Node *expr); extern Node *SS_process_sublinks(Node *expr); - #endif /* SUBSELECT_H */ diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index 5d4e6a02d8..796649d596 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tlist.h,v 1.28 2001/01/24 19:43:26 momjian Exp $ + * $Id: tlist.h,v 1.29 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,5 +32,4 @@ extern TargetEntry *get_sortgroupclause_tle(SortClause *sortClause, List *targetList); extern Node *get_sortgroupclause_expr(SortClause *sortClause, List *targetList); - #endif /* TLIST_H */ diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 4cad677c7c..536fc839e1 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: var.h,v 1.14 2001/05/09 23:13:36 tgl Exp $ + * $Id: var.h,v 1.15 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,9 +18,8 @@ extern List *pull_varnos(Node *node); extern bool contain_var_reference(Node *node, int varno, int varattno, - int levelsup); + int levelsup); extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup); extern bool contain_var_clause(Node *node); extern List *pull_var_clause(Node *node, bool includeUpperVars); - #endif /* VAR_H */ diff --git a/src/include/parser/analyze.h b/src/include/parser/analyze.h index 33c76ae877..b72ed67411 100644 --- a/src/include/parser/analyze.h +++ b/src/include/parser/analyze.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: analyze.h,v 1.15 2001/09/07 21:57:53 momjian Exp $ + * $Id: analyze.h,v 1.16 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern void CheckSelectForUpdate(Query *qry); /* This was exported to allow ADD CONSTRAINT to make use of it */ extern char *makeObjectName(char *name1, char *name2, char *typename); - #endif /* ANALYZE_H */ diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h index ad045dd4b6..3399b7ea35 100644 --- a/src/include/parser/gramparse.h +++ b/src/include/parser/gramparse.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: gramparse.h,v 1.16 2001/09/20 14:20:28 petere Exp $ + * $Id: gramparse.h,v 1.17 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,6 +29,5 @@ extern Oid param_type(int t); extern int yyparse(void); extern char *xlateSqlFunc(char *name); extern char *xlateSqlType(char *name); -bool exprIsNullConstant(Node *arg); - +bool exprIsNullConstant(Node *arg); #endif /* GRAMPARSE_H */ diff --git a/src/include/parser/keywords.h b/src/include/parser/keywords.h index f111f7b882..ef4b665896 100644 --- a/src/include/parser/keywords.h +++ b/src/include/parser/keywords.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: keywords.h,v 1.9 2001/01/24 19:43:27 momjian Exp $ + * $Id: keywords.h,v 1.10 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ typedef struct ScanKeyword } ScanKeyword; extern ScanKeyword *ScanKeywordLookup(char *text); - #endif /* KEYWORDS_H */ diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h index 6102cf4eae..943f4d54da 100644 --- a/src/include/parser/parse_agg.h +++ b/src/include/parser/parse_agg.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_agg.h,v 1.17 2001/01/24 19:43:27 momjian Exp $ + * $Id: parse_agg.h,v 1.18 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,5 +22,4 @@ extern Aggref *ParseAgg(ParseState *pstate, char *aggname, Oid basetype, List *args, bool agg_star, bool agg_distinct, int precedence); extern void agg_error(char *caller, char *aggname, Oid basetypeID); - #endif /* PARSE_AGG_H */ diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h index bf05dc6d7e..2e47fe8a35 100644 --- a/src/include/parser/parse_clause.h +++ b/src/include/parser/parse_clause.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_clause.h,v 1.24 2001/03/22 04:00:56 momjian Exp $ + * $Id: parse_clause.h,v 1.25 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,5 +30,4 @@ extern List *transformDistinctClause(ParseState *pstate, List *distinctlist, extern List *addAllTargetsToSortList(List *sortlist, List *targetlist); extern Index assignSortGroupRef(TargetEntry *tle, List *tlist); - #endif /* PARSE_CLAUSE_H */ diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index 69522adf75..4614492d8e 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_coerce.h,v 1.34 2001/10/03 19:18:42 tgl Exp $ + * $Id: parse_coerce.h,v 1.35 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,18 +19,18 @@ typedef enum CATEGORY { - INVALID_TYPE, - UNKNOWN_TYPE, - BOOLEAN_TYPE, - STRING_TYPE, - BITSTRING_TYPE, - NUMERIC_TYPE, - DATETIME_TYPE, - TIMESPAN_TYPE, - GEOMETRIC_TYPE, - NETWORK_TYPE, - USER_TYPE, - MIXED_TYPE + INVALID_TYPE, + UNKNOWN_TYPE, + BOOLEAN_TYPE, + STRING_TYPE, + BITSTRING_TYPE, + NUMERIC_TYPE, + DATETIME_TYPE, + TIMESPAN_TYPE, + GEOMETRIC_TYPE, + NETWORK_TYPE, + USER_TYPE, + MIXED_TYPE } CATEGORY; @@ -81,5 +81,4 @@ extern Oid select_common_type(List *typeids, const char *context); extern Node *coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context); - #endif /* PARSE_COERCE_H */ diff --git a/src/include/parser/parse_expr.h b/src/include/parser/parse_expr.h index c51bf7cc04..6cc0796ca9 100644 --- a/src/include/parser/parse_expr.h +++ b/src/include/parser/parse_expr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_expr.h,v 1.22 2001/09/20 14:20:28 petere Exp $ + * $Id: parse_expr.h,v 1.23 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,5 +28,4 @@ extern int32 exprTypmod(Node *expr); extern bool exprIsLengthCoercion(Node *expr, int32 *coercedTypmod); extern void parse_expr_init(void); extern char *TypeNameToInternalName(TypeName *typename); - #endif /* PARSE_EXPR_H */ diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h index 44c774db5e..fb63798e78 100644 --- a/src/include/parser/parse_func.h +++ b/src/include/parser/parse_func.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_func.h,v 1.32 2001/10/04 22:06:46 tgl Exp $ + * $Id: parse_func.h,v 1.33 2001/10/25 05:50:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,9 +41,9 @@ typedef struct _CandidateList /* Result codes for func_get_detail */ typedef enum { - FUNCDETAIL_NOTFOUND, /* no suitable interpretation */ - FUNCDETAIL_NORMAL, /* found a matching function */ - FUNCDETAIL_COERCION /* it's a type coercion request */ + FUNCDETAIL_NOTFOUND, /* no suitable interpretation */ + FUNCDETAIL_NORMAL, /* found a matching function */ + FUNCDETAIL_COERCION /* it's a type coercion request */ } FuncDetailCode; @@ -55,13 +55,12 @@ extern Node *ParseFuncOrColumn(ParseState *pstate, int precedence); extern FuncDetailCode func_get_detail(char *funcname, List *fargs, - int nargs, Oid *argtypes, - Oid *funcid, Oid *rettype, - bool *retset, Oid **true_typeids); + int nargs, Oid *argtypes, + Oid *funcid, Oid *rettype, + bool *retset, Oid **true_typeids); extern bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId); extern void func_error(char *caller, char *funcname, int nargs, Oid *argtypes, char *msg); - #endif /* PARSE_FUNC_H */ diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h index a7c14883ed..2efb13ac2a 100644 --- a/src/include/parser/parse_node.h +++ b/src/include/parser/parse_node.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_node.h,v 1.26 2001/03/22 04:00:57 momjian Exp $ + * $Id: parse_node.h,v 1.27 2001/10/25 05:50:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,5 +62,4 @@ extern ArrayRef *transformArraySubscripts(ParseState *pstate, bool forceSlice, Node *assignFrom); extern Const *make_const(Value *value); - #endif /* PARSE_NODE_H */ diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h index 400702fd7a..cde4a1fe54 100644 --- a/src/include/parser/parse_oper.h +++ b/src/include/parser/parse_oper.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_oper.h,v 1.15 2001/03/22 04:00:57 momjian Exp $ + * $Id: parse_oper.h,v 1.16 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ extern Oid any_ordering_op(Oid argtype); /* Extract operator OID or underlying-function OID from an Operator tuple */ extern Oid oprid(Operator op); extern Oid oprfuncid(Operator op); - #endif /* PARSE_OPER_H */ diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index 0cf4f40f19..81d3584e83 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_relation.h,v 1.25 2001/10/23 17:39:03 tgl Exp $ + * $Id: parse_relation.h,v 1.26 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,5 +47,4 @@ extern List *expandJoinAttrs(ParseState *pstate, JoinExpr *join, extern int attnameAttNum(Relation rd, char *a); extern Name attnumAttName(Relation rd, int attid); extern Oid attnumTypeId(Relation rd, int attid); - #endif /* PARSE_RELATION_H */ diff --git a/src/include/parser/parse_target.h b/src/include/parser/parse_target.h index 7e2dcecd0d..5ce539bfd6 100644 --- a/src/include/parser/parse_target.h +++ b/src/include/parser/parse_target.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_target.h,v 1.20 2001/01/24 19:43:27 momjian Exp $ + * $Id: parse_target.h,v 1.21 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,5 +27,4 @@ extern Node *CoerceTargetExpr(ParseState *pstate, Node *expr, Oid type_id, Oid attrtype, int32 attrtypmod); extern List *checkInsertTargets(ParseState *pstate, List *cols, List **attrnos); - #endif /* PARSE_TARGET_H */ diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h index baa31c972b..3b3689af5f 100644 --- a/src/include/parser/parse_type.h +++ b/src/include/parser/parse_type.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_type.h,v 1.17 2001/10/09 04:15:38 tgl Exp $ + * $Id: parse_type.h,v 1.18 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,5 +37,4 @@ extern Oid typenameTypeId(char *s); extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod); #define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid) - #endif /* PARSE_TYPE_H */ diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h index 5f25467a95..d4c8028877 100644 --- a/src/include/parser/parser.h +++ b/src/include/parser/parser.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parser.h,v 1.8 2001/01/24 19:43:27 momjian Exp $ + * $Id: parser.h,v 1.9 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ #include "parser/parse_node.h" extern List *parser(char *str, Oid *typev, int nargs); - #endif /* PARSER_H */ diff --git a/src/include/parser/parsetree.h b/src/include/parser/parsetree.h index 63ae46d674..fdf0218d8c 100644 --- a/src/include/parser/parsetree.h +++ b/src/include/parser/parsetree.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsetree.h,v 1.13 2001/01/24 19:43:27 momjian Exp $ + * $Id: parsetree.h,v 1.14 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,5 +51,4 @@ * variable name or alias for that attribute of that RTE. */ extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum); - #endif /* PARSETREE_H */ diff --git a/src/include/parser/scansup.h b/src/include/parser/scansup.h index 3574b6506e..b8cd4023e5 100644 --- a/src/include/parser/scansup.h +++ b/src/include/parser/scansup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: scansup.h,v 1.8 2001/01/24 19:43:27 momjian Exp $ + * $Id: scansup.h,v 1.9 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,5 +16,4 @@ #define SCANSUP_H extern char *scanstr(char *s); - #endif /* SCANSUP_H */ diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 5295d08ae0..318361ac3a 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -5,7 +5,7 @@ * * Copyright (c) 2001, PostgreSQL Global Development Group * - * $Id: pgstat.h,v 1.8 2001/10/21 03:25:36 tgl Exp $ + * $Id: pgstat.h,v 1.9 2001/10/25 05:49:54 momjian Exp $ * ---------- */ #ifndef PGSTAT_H @@ -16,22 +16,22 @@ * installations $PGDATA. * ---------- */ -#define PGSTAT_STAT_FILENAME "%s/global/pgstat.stat" -#define PGSTAT_STAT_TMPFILE "%s/global/pgstat.tmp.%d" +#define PGSTAT_STAT_FILENAME "%s/global/pgstat.stat" +#define PGSTAT_STAT_TMPFILE "%s/global/pgstat.tmp.%d" /* ---------- * Timer definitions. * ---------- */ #define PGSTAT_STAT_INTERVAL 500 /* How often to write the status */ - /* file, in milliseconds. */ + /* file, in milliseconds. */ #define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed */ - /* objects known to give delayed */ - /* UDP packets time to arrive, */ - /* in milliseconds. */ + /* objects known to give delayed */ + /* UDP packets time to arrive, */ + /* in milliseconds. */ -#define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY \ +#define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY \ / PGSTAT_STAT_INTERVAL) @@ -46,20 +46,20 @@ * The types of backend/postmaster -> collector messages * ---------- */ -#define PGSTAT_MTYPE_DUMMY 0 -#define PGSTAT_MTYPE_BESTART 1 -#define PGSTAT_MTYPE_BETERM 2 -#define PGSTAT_MTYPE_ACTIVITY 3 -#define PGSTAT_MTYPE_TABSTAT 4 -#define PGSTAT_MTYPE_TABPURGE 5 -#define PGSTAT_MTYPE_DROPDB 6 -#define PGSTAT_MTYPE_RESETCOUNTER 7 +#define PGSTAT_MTYPE_DUMMY 0 +#define PGSTAT_MTYPE_BESTART 1 +#define PGSTAT_MTYPE_BETERM 2 +#define PGSTAT_MTYPE_ACTIVITY 3 +#define PGSTAT_MTYPE_TABSTAT 4 +#define PGSTAT_MTYPE_TABPURGE 5 +#define PGSTAT_MTYPE_DROPDB 6 +#define PGSTAT_MTYPE_RESETCOUNTER 7 /* ---------- * Amount of space reserved in pgstat_recvbuffer(). * ---------- */ -#define PGSTAT_RECVBUFFERSZ ((int) (1024 * sizeof(PgStat_Msg))) +#define PGSTAT_RECVBUFFERSZ ((int) (1024 * sizeof(PgStat_Msg))) /* ---------- @@ -76,7 +76,7 @@ * The data type used for counters. * ---------- */ -typedef int64 PgStat_Counter; +typedef int64 PgStat_Counter; /* ------------------------------------------------------------ @@ -87,17 +87,17 @@ typedef int64 PgStat_Counter; * PgStat_StatDBEntry The collectors data per database * ---------- */ -typedef struct PgStat_StatDBEntry +typedef struct PgStat_StatDBEntry { - Oid databaseid; - HTAB *tables; - int n_backends; - PgStat_Counter n_connects; - PgStat_Counter n_xact_commit; - PgStat_Counter n_xact_rollback; - PgStat_Counter n_blocks_fetched; - PgStat_Counter n_blocks_hit; - int destroy; + Oid databaseid; + HTAB *tables; + int n_backends; + PgStat_Counter n_connects; + PgStat_Counter n_xact_commit; + PgStat_Counter n_xact_rollback; + PgStat_Counter n_blocks_fetched; + PgStat_Counter n_blocks_hit; + int destroy; } PgStat_StatDBEntry; @@ -105,12 +105,12 @@ typedef struct PgStat_StatDBEntry * PgStat_StatBeEntry The collectors data per backend * ---------- */ -typedef struct PgStat_StatBeEntry +typedef struct PgStat_StatBeEntry { - Oid databaseid; - Oid userid; - int procpid; - char activity[PGSTAT_ACTIVITY_SIZE]; + Oid databaseid; + Oid userid; + int procpid; + char activity[PGSTAT_ACTIVITY_SIZE]; } PgStat_StatBeEntry; @@ -122,11 +122,11 @@ typedef struct PgStat_StatBeEntry * in a hash table of these structs. * ---------- */ -typedef struct PgStat_StatBeDead +typedef struct PgStat_StatBeDead { - int procpid; - int backendid; - int destroy; + int procpid; + int backendid; + int destroy; } PgStat_StatBeDead; @@ -134,22 +134,22 @@ typedef struct PgStat_StatBeDead * PgStat_StatTabEntry The collectors data table data * ---------- */ -typedef struct PgStat_StatTabEntry +typedef struct PgStat_StatTabEntry { - Oid tableid; + Oid tableid; - PgStat_Counter numscans; + PgStat_Counter numscans; - PgStat_Counter tuples_returned; - PgStat_Counter tuples_fetched; - PgStat_Counter tuples_inserted; - PgStat_Counter tuples_updated; - PgStat_Counter tuples_deleted; + PgStat_Counter tuples_returned; + PgStat_Counter tuples_fetched; + PgStat_Counter tuples_inserted; + PgStat_Counter tuples_updated; + PgStat_Counter tuples_deleted; - PgStat_Counter blocks_fetched; - PgStat_Counter blocks_hit; + PgStat_Counter blocks_fetched; + PgStat_Counter blocks_hit; - int destroy; + int destroy; } PgStat_StatTabEntry; @@ -163,34 +163,34 @@ typedef struct PgStat_StatTabEntry * PgStat_MsgHdr The common message header * ---------- */ -typedef struct PgStat_MsgHdr +typedef struct PgStat_MsgHdr { - int m_type; - int m_size; - int m_backendid; - int m_procpid; - Oid m_databaseid; - Oid m_userid; + int m_type; + int m_size; + int m_backendid; + int m_procpid; + Oid m_databaseid; + Oid m_userid; } PgStat_MsgHdr; /* ---------- * PgStat_TabEntry A table slot in a MsgTabstat * ---------- */ -typedef struct PgStat_TableEntry +typedef struct PgStat_TableEntry { - Oid t_id; + Oid t_id; - PgStat_Counter t_numscans; + PgStat_Counter t_numscans; - PgStat_Counter t_tuples_returned; - PgStat_Counter t_tuples_fetched; - PgStat_Counter t_tuples_inserted; - PgStat_Counter t_tuples_updated; - PgStat_Counter t_tuples_deleted; + PgStat_Counter t_tuples_returned; + PgStat_Counter t_tuples_fetched; + PgStat_Counter t_tuples_inserted; + PgStat_Counter t_tuples_updated; + PgStat_Counter t_tuples_deleted; - PgStat_Counter t_blocks_fetched; - PgStat_Counter t_blocks_hit; + PgStat_Counter t_blocks_fetched; + PgStat_Counter t_blocks_hit; } PgStat_TableEntry; @@ -198,28 +198,28 @@ typedef struct PgStat_TableEntry * PgStat_MsgDummy A dummy message, ignored by the collector * ---------- */ -typedef struct PgStat_MsgDummy +typedef struct PgStat_MsgDummy { - PgStat_MsgHdr m_hdr; - char m_dummy[512]; + PgStat_MsgHdr m_hdr; + char m_dummy[512]; } PgStat_MsgDummy; /* ---------- * PgStat_MsgBestart Sent by the backend on startup * ---------- */ -typedef struct PgStat_MsgBestart +typedef struct PgStat_MsgBestart { - PgStat_MsgHdr m_hdr; + PgStat_MsgHdr m_hdr; } PgStat_MsgBestart; /* ---------- * PgStat_MsgBeterm Sent by the postmaster after backend exit * ---------- */ -typedef struct PgStat_MsgBeterm +typedef struct PgStat_MsgBeterm { - PgStat_MsgHdr m_hdr; + PgStat_MsgHdr m_hdr; } PgStat_MsgBeterm; /* ---------- @@ -227,10 +227,10 @@ typedef struct PgStat_MsgBeterm * to parse a query. * ---------- */ -typedef struct PgStat_MsgActivity +typedef struct PgStat_MsgActivity { - PgStat_MsgHdr m_hdr; - char m_what[PGSTAT_ACTIVITY_SIZE]; + PgStat_MsgHdr m_hdr; + char m_what[PGSTAT_ACTIVITY_SIZE]; } PgStat_MsgActivity; /* ---------- @@ -248,13 +248,13 @@ typedef struct PgStat_MsgActivity * and buffer access statistics. * ---------- */ -typedef struct PgStat_MsgTabstat +typedef struct PgStat_MsgTabstat { - PgStat_MsgHdr m_hdr; - int m_nentries; - int m_xact_commit; - int m_xact_rollback; - PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES]; + PgStat_MsgHdr m_hdr; + int m_nentries; + int m_xact_commit; + int m_xact_rollback; + PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES]; } PgStat_MsgTabstat; @@ -270,11 +270,11 @@ typedef struct PgStat_MsgTabstat * about dead tables. * ---------- */ -typedef struct PgStat_MsgTabpurge +typedef struct PgStat_MsgTabpurge { - PgStat_MsgHdr m_hdr; - int m_nentries; - Oid m_tableid[PGSTAT_NUM_TABPURGE]; + PgStat_MsgHdr m_hdr; + int m_nentries; + Oid m_tableid[PGSTAT_NUM_TABPURGE]; } PgStat_MsgTabpurge; @@ -283,10 +283,10 @@ typedef struct PgStat_MsgTabpurge * about dropped database * ---------- */ -typedef struct PgStat_MsgDropdb +typedef struct PgStat_MsgDropdb { - PgStat_MsgHdr m_hdr; - Oid m_databaseid; + PgStat_MsgHdr m_hdr; + Oid m_databaseid; } PgStat_MsgDropdb; @@ -295,9 +295,9 @@ typedef struct PgStat_MsgDropdb * to reset counters * ---------- */ -typedef struct PgStat_MsgResetcounter +typedef struct PgStat_MsgResetcounter { - PgStat_MsgHdr m_hdr; + PgStat_MsgHdr m_hdr; } PgStat_MsgResetcounter; @@ -305,16 +305,16 @@ typedef struct PgStat_MsgResetcounter * PgStat_Msg Union over all possible messages. * ---------- */ -typedef union PgStat_Msg +typedef union PgStat_Msg { - PgStat_MsgHdr msg_hdr; - PgStat_MsgDummy msg_dummy; - PgStat_MsgBestart msg_bestart; - PgStat_MsgActivity msg_activity; - PgStat_MsgTabstat msg_tabstat; - PgStat_MsgTabpurge msg_tabpurge; - PgStat_MsgDropdb msg_dropdb; - PgStat_MsgResetcounter msg_resetcounter; + PgStat_MsgHdr msg_hdr; + PgStat_MsgDummy msg_dummy; + PgStat_MsgBestart msg_bestart; + PgStat_MsgActivity msg_activity; + PgStat_MsgTabstat msg_tabstat; + PgStat_MsgTabpurge msg_tabpurge; + PgStat_MsgDropdb msg_dropdb; + PgStat_MsgResetcounter msg_resetcounter; } PgStat_Msg; @@ -322,36 +322,36 @@ typedef union PgStat_Msg * Global variables * ---------- */ -extern bool pgstat_collect_startcollector; -extern bool pgstat_collect_resetonpmstart; -extern bool pgstat_collect_querystring; -extern bool pgstat_collect_tuplelevel; -extern bool pgstat_collect_blocklevel; +extern bool pgstat_collect_startcollector; +extern bool pgstat_collect_resetonpmstart; +extern bool pgstat_collect_querystring; +extern bool pgstat_collect_tuplelevel; +extern bool pgstat_collect_blocklevel; /* ---------- * Functions called from postmaster * ---------- */ -extern int pgstat_init(void); -extern int pgstat_start(void); -extern int pgstat_ispgstat(int pid); -extern void pgstat_close_sockets(void); -extern void pgstat_beterm(int pid); +extern int pgstat_init(void); +extern int pgstat_start(void); +extern int pgstat_ispgstat(int pid); +extern void pgstat_close_sockets(void); +extern void pgstat_beterm(int pid); /* ---------- * Functions called from backends * ---------- */ -extern void pgstat_bestart(void); +extern void pgstat_bestart(void); -extern void pgstat_ping(void); -extern void pgstat_report_activity(char *what); -extern void pgstat_report_tabstat(void); -extern int pgstat_vacuum_tabstat(void); +extern void pgstat_ping(void); +extern void pgstat_report_activity(char *what); +extern void pgstat_report_tabstat(void); +extern int pgstat_vacuum_tabstat(void); -extern void pgstat_reset_counters(void); +extern void pgstat_reset_counters(void); -extern void pgstat_initstats(PgStat_Info *stats, Relation rel); +extern void pgstat_initstats(PgStat_Info *stats, Relation rel); #define pgstat_reset_heap_scan(s) \ @@ -361,7 +361,7 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); } while (0) #define pgstat_count_heap_scan(s) \ do { \ - if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \ + if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \ !(s)->heap_scan_counted) { \ ((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \ (s)->heap_scan_counted = TRUE; \ @@ -375,7 +375,7 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); #define pgstat_count_heap_fetch(s) \ do { \ if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \ - ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++; \ + ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++; \ } while (0) #define pgstat_count_heap_insert(s) \ do { \ @@ -385,12 +385,12 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); #define pgstat_count_heap_update(s) \ do { \ if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \ - ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++; \ + ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++; \ } while (0) #define pgstat_count_heap_delete(s) \ do { \ if (pgstat_collect_tuplelevel && (s)->tabentry != NULL) \ - ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++; \ + ((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++; \ } while (0) #define pgstat_reset_index_scan(s) \ do { \ @@ -399,7 +399,7 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); } while (0) #define pgstat_count_index_scan(s) \ do { \ - if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \ + if (pgstat_collect_tuplelevel && (s)->tabentry != NULL && \ !(s)->index_scan_counted) { \ ((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \ (s)->index_scan_counted = TRUE; \ @@ -413,7 +413,7 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); #define pgstat_count_buffer_read(s,r) \ do { \ if (pgstat_collect_blocklevel && (s)->tabentry != NULL) \ - ((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \ + ((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \ else { \ if (pgstat_collect_blocklevel && !(s)->no_stats) { \ pgstat_initstats((s), (r)); \ @@ -436,18 +436,17 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); } while (0) -extern void pgstat_count_xact_commit(void); -extern void pgstat_count_xact_rollback(void); +extern void pgstat_count_xact_commit(void); +extern void pgstat_count_xact_rollback(void); /* ---------- * Support functions for the SQL-callable functions to * generate the pgstat* views. * ---------- */ -extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid); +extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid); extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry(Oid relid); -extern PgStat_StatBeEntry *pgstat_fetch_stat_beentry(int beid); -extern int pgstat_fetch_stat_numbackends(void); +extern PgStat_StatBeEntry *pgstat_fetch_stat_beentry(int beid); +extern int pgstat_fetch_stat_numbackends(void); - -#endif /* PGSTAT_H */ +#endif /* PGSTAT_H */ diff --git a/src/include/port/beos.h b/src/include/port/beos.h index cedc5d6f12..1ca198a96f 100644 --- a/src/include/port/beos.h +++ b/src/include/port/beos.h @@ -71,7 +71,7 @@ void beos_startup(int argc, char **argv); image_id beos_dl_open(char *filename); /* Find symbol */ -void beos_dl_sym(image_id im,char* symname,void** fptr); +void beos_dl_sym(image_id im, char *symname, void **fptr); /* UnLoad a shared library */ status_t beos_dl_close(image_id im); diff --git a/src/include/port/darwin.h b/src/include/port/darwin.h index 0d35a8a2f4..618eded7fd 100644 --- a/src/include/port/darwin.h +++ b/src/include/port/darwin.h @@ -9,5 +9,4 @@ typedef unsigned int slock_t; #else typedef unsigned char slock_t; - #endif diff --git a/src/include/port/darwin/sem.h b/src/include/port/darwin/sem.h index 55cf85dcca..9e4b95abf6 100644 --- a/src/include/port/darwin/sem.h +++ b/src/include/port/darwin/sem.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/include/port/darwin/Attic/sem.h,v 1.2 2001/03/22 04:01:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/port/darwin/Attic/sem.h,v 1.3 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* _SYS_SEM_H */ diff --git a/src/include/port/linux.h b/src/include/port/linux.h index c5d58489ba..b46766570e 100644 --- a/src/include/port/linux.h +++ b/src/include/port/linux.h @@ -37,5 +37,4 @@ typedef unsigned int slock_t; typedef unsigned int slock_t; #define HAS_TEST_AND_SET - #endif diff --git a/src/include/port/netbsd.h b/src/include/port/netbsd.h index 8b841e1a4a..aba5c72fe6 100644 --- a/src/include/port/netbsd.h +++ b/src/include/port/netbsd.h @@ -2,40 +2,34 @@ #define NEED_I386_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__sparc__) #define NEED_SPARC_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__vax__) #define NEED_VAX_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__ns32k__) #define NEED_NS32K_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__m68k__) #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__arm__) #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__mips__) @@ -45,11 +39,9 @@ typedef unsigned char slock_t; #if defined(__alpha__) #define HAS_TEST_AND_SET typedef unsigned long slock_t; - #endif #if defined(__powerpc__) #define HAS_TEST_AND_SET typedef unsigned int slock_t; - #endif diff --git a/src/include/port/openbsd.h b/src/include/port/openbsd.h index 8b841e1a4a..aba5c72fe6 100644 --- a/src/include/port/openbsd.h +++ b/src/include/port/openbsd.h @@ -2,40 +2,34 @@ #define NEED_I386_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__sparc__) #define NEED_SPARC_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__vax__) #define NEED_VAX_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__ns32k__) #define NEED_NS32K_TAS_ASM #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__m68k__) #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__arm__) #define HAS_TEST_AND_SET typedef unsigned char slock_t; - #endif #if defined(__mips__) @@ -45,11 +39,9 @@ typedef unsigned char slock_t; #if defined(__alpha__) #define HAS_TEST_AND_SET typedef unsigned long slock_t; - #endif #if defined(__powerpc__) #define HAS_TEST_AND_SET typedef unsigned int slock_t; - #endif diff --git a/src/include/port/solaris.h b/src/include/port/solaris.h index f19a33f00f..af715f5e11 100644 --- a/src/include/port/solaris.h +++ b/src/include/port/solaris.h @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/include/port/solaris.h,v 1.4 2001/03/22 04:01:00 momjian Exp $ */ +/* $Header: /cvsroot/pgsql/src/include/port/solaris.h,v 1.5 2001/10/25 05:50:09 momjian Exp $ */ #define HAS_TEST_AND_SET typedef unsigned char slock_t; @@ -56,7 +56,5 @@ typedef unsigned char slock_t; /* not GNUC and i386 */ #define NAN (0.0/0.0) - #endif /* GCC. */ - #endif /* not NAN */ diff --git a/src/include/port/svr4.h b/src/include/port/svr4.h index 2c6e2b4e71..d5e7f90f72 100644 --- a/src/include/port/svr4.h +++ b/src/include/port/svr4.h @@ -9,5 +9,4 @@ #include "abi_mutex.h" typedef abilock_t slock_t; - #endif diff --git a/src/include/postgres.h b/src/include/postgres.h index 3ae7bc44f8..39c6fffdca 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1995, Regents of the University of California * - * $Id: postgres.h,v 1.53 2001/10/03 21:58:28 tgl Exp $ + * $Id: postgres.h,v 1.54 2001/10/25 05:49:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,7 +77,7 @@ typedef struct varattrib int32 va_extsize; /* External saved size */ Oid va_valueid; /* Unique identifier of value */ Oid va_toastrelid; /* RelID where to find chunks */ - } va_external;/* External stored attribute */ + } va_external; /* External stored attribute */ char va_data[1]; /* Plain stored attribute */ } va_content; @@ -533,7 +533,6 @@ extern DLLIMPORT bool assert_enabled; #define AssertState(condition) \ Trap(!(condition), BadState) - #endif /* USE_ASSERT_CHECKING */ /* @@ -563,7 +562,8 @@ extern int ExceptionalCondition(char *conditionName, Exception *exceptionP, char *details, char *fileName, int lineNumber); -extern char *vararg_format(const char *fmt, ...) +extern char * +vararg_format(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); @@ -587,16 +587,14 @@ __attribute__((format(printf, 1, 2))); #ifdef ASSERT_CHECKING_TEST extern int assertTest(int val); - #endif - #endif /* USE_ASSERT_CHECKING */ /* ---------------------------------------------------------------- * Section 4: genbki macros used by catalog/pg_xxx.h files * ---------------------------------------------------------------- */ -#define CATALOG(x) typedef struct CppConcat(FormData_,x) +#define CATALOG(x) typedef struct CppConcat(FormData_,x) #define BOOTSTRAP @@ -611,5 +609,4 @@ extern int assertTest(int val); typedef int4 aclitem; /* PHONY definition for catalog use only */ - #endif /* POSTGRES_H */ diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h index 7b52f9c835..dc9058360b 100644 --- a/src/include/postgres_ext.h +++ b/src/include/postgres_ext.h @@ -15,7 +15,7 @@ * use header files that are otherwise internal to Postgres to interface * with the backend. * - * $Id: postgres_ext.h,v 1.7 2001/03/22 04:00:25 momjian Exp $ + * $Id: postgres_ext.h,v 1.8 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ typedef unsigned int Oid; * NOTE that databases with different NAMEDATALEN's cannot interoperate! */ #define NAMEDATALEN 32 - #endif diff --git a/src/include/postgres_fe.h b/src/include/postgres_fe.h index 58bff59720..4aed68eb19 100644 --- a/src/include/postgres_fe.h +++ b/src/include/postgres_fe.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1995, Regents of the University of California * - * $Id: postgres_fe.h,v 1.2 2001/08/24 22:46:28 petere Exp $ + * $Id: postgres_fe.h,v 1.3 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,5 +19,4 @@ #define POSTGRES_FE_H #include "c.h" - #endif /* POSTGRES_FE_H */ diff --git a/src/include/regex/cclass.h b/src/include/regex/cclass.h index 8290810259..c0ae7da4f6 100644 --- a/src/include/regex/cclass.h +++ b/src/include/regex/cclass.h @@ -52,7 +52,7 @@ static struct cclass }, { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - "" + "" }, { "blank", " \t", "" @@ -67,31 +67,31 @@ static struct cclass { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - "" + "" }, { "lower", "abcdefghijklmnopqrstuvwxyz", - "" + "" }, { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", - "" + "" }, { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - "" + "" }, { "space", "\t\n\v\f\r ", "" }, { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - "" + "" }, { "xdigit", "0123456789ABCDEFabcdef", - "" + "" }, { NULL, NULL, "" diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h index 180bfe204f..9ef8bee95a 100644 --- a/src/include/regex/regex.h +++ b/src/include/regex/regex.h @@ -109,5 +109,4 @@ extern int pg95_regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t *pmatch, int eflags); extern void pg95_regfree(regex_t *preg); - #endif /* !_REGEX_H_ */ diff --git a/src/include/regex/utils.h b/src/include/regex/utils.h index 4a29c21726..0ef6c50a8e 100644 --- a/src/include/regex/utils.h +++ b/src/include/regex/utils.h @@ -60,5 +60,4 @@ typedef unsigned char uch; #define NDEBUG /* no assertions please */ #endif #endif - #endif /* _REGEX_UTILS_H */ diff --git a/src/include/rewrite/prs2lock.h b/src/include/rewrite/prs2lock.h index 7d642a7251..3d24d33138 100644 --- a/src/include/rewrite/prs2lock.h +++ b/src/include/rewrite/prs2lock.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: prs2lock.h,v 1.12 2001/01/24 19:43:27 momjian Exp $ + * $Id: prs2lock.h,v 1.13 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,5 +42,4 @@ typedef struct RuleLock int numLocks; RewriteRule **rules; } RuleLock; - #endif /* REWRITE_H */ diff --git a/src/include/rewrite/rewriteDefine.h b/src/include/rewrite/rewriteDefine.h index b46d57a495..91ab7272c9 100644 --- a/src/include/rewrite/rewriteDefine.h +++ b/src/include/rewrite/rewriteDefine.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteDefine.h,v 1.10 2001/08/12 21:35:19 tgl Exp $ + * $Id: rewriteDefine.h,v 1.11 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,5 +19,4 @@ extern void DefineQueryRewrite(RuleStmt *args); extern void RenameRewriteRule(char *oldname, char *newname); - #endif /* REWRITEDEFINE_H */ diff --git a/src/include/rewrite/rewriteHandler.h b/src/include/rewrite/rewriteHandler.h index 0707d9a75b..1a80dd2b3c 100644 --- a/src/include/rewrite/rewriteHandler.h +++ b/src/include/rewrite/rewriteHandler.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteHandler.h,v 1.15 2001/06/13 18:56:30 tgl Exp $ + * $Id: rewriteHandler.h,v 1.16 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,5 +18,4 @@ extern List *QueryRewrite(Query *parsetree); - #endif /* REWRITEHANDLER_H */ diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h index 05f2fe2de3..cdb28e0149 100644 --- a/src/include/rewrite/rewriteManip.h +++ b/src/include/rewrite/rewriteManip.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteManip.h,v 1.27 2001/06/13 18:56:29 tgl Exp $ + * $Id: rewriteManip.h,v 1.28 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,5 +39,4 @@ extern bool checkExprHasSubLink(Node *node); extern Node *ResolveNew(Node *node, int target_varno, int sublevels_up, List *targetlist, int event, int update_varno); - #endif /* REWRITEMANIP_H */ diff --git a/src/include/rewrite/rewriteRemove.h b/src/include/rewrite/rewriteRemove.h index 7e64aff594..a961ea5a86 100644 --- a/src/include/rewrite/rewriteRemove.h +++ b/src/include/rewrite/rewriteRemove.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteRemove.h,v 1.7 2001/01/24 19:43:27 momjian Exp $ + * $Id: rewriteRemove.h,v 1.8 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ extern char *RewriteGetRuleEventRel(char *rulename); extern void RemoveRewriteRule(char *ruleName); extern void RelationRemoveRules(Oid relid); - #endif /* REWRITEREMOVE_H */ diff --git a/src/include/rewrite/rewriteSupport.h b/src/include/rewrite/rewriteSupport.h index 81390ac209..7fa559f4c1 100644 --- a/src/include/rewrite/rewriteSupport.h +++ b/src/include/rewrite/rewriteSupport.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteSupport.h,v 1.17 2001/08/12 21:35:19 tgl Exp $ + * $Id: rewriteSupport.h,v 1.18 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ extern char *MakeRetrieveViewRuleName(const char *view_name); extern void SetRelationRuleStatus(Oid relationId, bool relHasRules, bool relIsBecomingView); - #endif /* REWRITESUPPORT_H */ diff --git a/src/include/rusagestub.h b/src/include/rusagestub.h index 83d477c720..9f3d92e4e0 100644 --- a/src/include/rusagestub.h +++ b/src/include/rusagestub.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rusagestub.h,v 1.6 2001/01/24 19:43:19 momjian Exp $ + * $Id: rusagestub.h,v 1.7 2001/10/25 05:49:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,5 +28,4 @@ struct rusage }; extern int getrusage(int who, struct rusage * rusage); - #endif /* RUSAGESTUB_H */ diff --git a/src/include/storage/backendid.h b/src/include/storage/backendid.h index 1377803f7c..1eac0172e3 100644 --- a/src/include/storage/backendid.h +++ b/src/include/storage/backendid.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: backendid.h,v 1.9 2001/01/24 19:43:27 momjian Exp $ + * $Id: backendid.h,v 1.10 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,5 +24,4 @@ typedef int BackendId; /* unique currently active backend #define InvalidBackendId (-1) extern BackendId MyBackendId; /* backend id of this backend */ - #endif /* BACKENDID_H */ diff --git a/src/include/storage/block.h b/src/include/storage/block.h index d13f3c8f06..90bcf6b2c5 100644 --- a/src/include/storage/block.h +++ b/src/include/storage/block.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: block.h,v 1.13 2001/07/02 20:50:46 tgl Exp $ + * $Id: block.h,v 1.14 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,5 +117,4 @@ typedef BlockIdData *BlockId; /* block identifier */ AssertMacro(BlockIdIsValid(blockId)), \ (BlockNumber) (((blockId)->bi_hi << 16) | ((uint16) (blockId)->bi_lo)) \ ) - #endif /* BLOCK_H */ diff --git a/src/include/storage/buf.h b/src/include/storage/buf.h index f31d5d5cc8..4d767b808f 100644 --- a/src/include/storage/buf.h +++ b/src/include/storage/buf.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: buf.h,v 1.9 2001/06/09 18:16:59 tgl Exp $ + * $Id: buf.h,v 1.10 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,5 +43,4 @@ typedef int Buffer; * - plai 9/10/90 */ #undef NO_BUFFERISVALID - #endif /* BUF_H */ diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index aa468905bf..2ba2cfb3aa 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: buf_internals.h,v 1.51 2001/10/01 05:36:17 tgl Exp $ + * $Id: buf_internals.h,v 1.52 2001/10/25 05:50:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -95,13 +95,14 @@ typedef struct sbufdesc bool cntxDirty; /* new way to mark block as dirty */ /* - * We can't physically remove items from a disk page if another backend - * has the buffer pinned. Hence, a backend may need to wait for all - * other pins to go away. This is signaled by setting its own backend ID - * into wait_backend_id and setting flag bit BM_PIN_COUNT_WAITER. - * At present, there can be only one such waiter per buffer. + * We can't physically remove items from a disk page if another + * backend has the buffer pinned. Hence, a backend may need to wait + * for all other pins to go away. This is signaled by setting its own + * backend ID into wait_backend_id and setting flag bit + * BM_PIN_COUNT_WAITER. At present, there can be only one such waiter + * per buffer. */ - BackendId wait_backend_id; /* backend ID of pin-count waiter */ + BackendId wait_backend_id; /* backend ID of pin-count waiter */ } BufferDesc; #define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1) @@ -136,7 +137,7 @@ typedef struct _bmtrace int bmt_buf; Oid bmt_dbid; Oid bmt_relid; - BlockNumber bmt_blkno; + BlockNumber bmt_blkno; int bmt_op; #define BMT_NOTUSED 0 @@ -145,7 +146,6 @@ typedef struct _bmtrace #define BMT_DEALLOC 3 } bmtrace; - #endif /* BMTRACE */ @@ -183,5 +183,4 @@ extern int WriteLocalBuffer(Buffer buffer, bool release); extern int FlushLocalBuffer(Buffer buffer, bool sync, bool release); extern void LocalBufferSync(void); extern void ResetLocalBufferPool(void); - #endif /* BUFMGR_INTERNALS_H */ diff --git a/src/include/storage/buffile.h b/src/include/storage/buffile.h index 217f1d81fe..c39463a7e0 100644 --- a/src/include/storage/buffile.h +++ b/src/include/storage/buffile.h @@ -18,7 +18,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: buffile.h,v 1.8 2001/01/24 19:43:27 momjian Exp $ + * $Id: buffile.h,v 1.9 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size); extern int BufFileSeek(BufFile *file, int fileno, long offset, int whence); extern void BufFileTell(BufFile *file, int *fileno, long *offset); extern int BufFileSeekBlock(BufFile *file, long blknum); - #endif /* BUFFILE_H */ diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 70161c9c8d..8d755db16e 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bufmgr.h,v 1.54 2001/07/06 21:04:26 tgl Exp $ + * $Id: bufmgr.h,v 1.55 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -159,7 +159,7 @@ extern int ReleaseBuffer(Buffer buffer); extern int WriteBuffer(Buffer buffer); extern int WriteNoReleaseBuffer(Buffer buffer); extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, - BlockNumber blockNum); + BlockNumber blockNum); extern int FlushBuffer(Buffer buffer, bool sync, bool release); extern void InitBufferPool(void); @@ -191,5 +191,4 @@ extern void BufmgrCommit(void); extern void BufferSync(void); extern void InitLocalBuffer(void); - #endif diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index b38b1677a0..b948fd06b8 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bufpage.h,v 1.43 2001/08/25 18:52:43 tgl Exp $ + * $Id: bufpage.h,v 1.44 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -132,8 +132,8 @@ typedef PageHeaderData *PageHeader; typedef enum { - ShufflePageManagerMode, - OverwritePageManagerMode + ShufflePageManagerMode, + OverwritePageManagerMode } PageManagerMode; /* ---------------------------------------------------------------- @@ -320,5 +320,4 @@ extern Size PageGetFreeSpace(Page page); extern void PageIndexTupleDelete(Page page, OffsetNumber offset); extern void IndexPageCleanup(Buffer buffer); - #endif /* BUFPAGE_H */ diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 3526be1a1e..31eb02c72d 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fd.h,v 1.31 2001/09/30 18:57:45 tgl Exp $ + * $Id: fd.h,v 1.32 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ typedef int File; /* GUC parameter */ -extern int max_files_per_process; +extern int max_files_per_process; /* @@ -78,5 +78,4 @@ extern void AtEOXact_Files(void); extern void RemovePgTempFiles(void); extern int pg_fsync(int fd); extern int pg_fdatasync(int fd); - #endif /* FD_H */ diff --git a/src/include/storage/freespace.h b/src/include/storage/freespace.h index affde80717..6aebd60e20 100644 --- a/src/include/storage/freespace.h +++ b/src/include/storage/freespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: freespace.h,v 1.3 2001/09/29 04:02:26 tgl Exp $ + * $Id: freespace.h,v 1.4 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,22 +30,21 @@ extern int FreeSpaceShmemSize(void); extern BlockNumber GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded); extern void RecordFreeSpace(RelFileNode *rel, BlockNumber page, - Size spaceAvail); + Size spaceAvail); extern BlockNumber RecordAndGetPageWithFreeSpace(RelFileNode *rel, - BlockNumber oldPage, - Size oldSpaceAvail, - Size spaceNeeded); + BlockNumber oldPage, + Size oldSpaceAvail, + Size spaceNeeded); extern void MultiRecordFreeSpace(RelFileNode *rel, - BlockNumber minPage, - BlockNumber maxPage, - int nPages, - BlockNumber *pages, - Size *spaceAvail); + BlockNumber minPage, + BlockNumber maxPage, + int nPages, + BlockNumber *pages, + Size *spaceAvail); extern void FreeSpaceMapForgetRel(RelFileNode *rel); extern void FreeSpaceMapForgetDatabase(Oid dbid); #ifdef FREESPACE_DEBUG extern void DumpFreeSpace(void); #endif - #endif /* FREESPACE_H */ diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h index dae16748d0..861104d6e5 100644 --- a/src/include/storage/ipc.h +++ b/src/include/storage/ipc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: ipc.h,v 1.51 2001/09/29 04:02:26 tgl Exp $ + * $Id: ipc.h,v 1.52 2001/10/25 05:50:10 momjian Exp $ * * Some files that would normally need to include only sys/ipc.h must * instead include this file because on Ultrix, sys/ipc.h is not designed @@ -89,5 +89,4 @@ extern bool SharedMemoryIsInUse(IpcMemoryKey shmKey, IpcMemoryId shmId); /* ipci.c */ extern void CreateSharedMemoryAndSemaphores(bool makePrivate, int maxBackends); - #endif /* IPC_H */ diff --git a/src/include/storage/item.h b/src/include/storage/item.h index 61e62b7c68..afb869444a 100644 --- a/src/include/storage/item.h +++ b/src/include/storage/item.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: item.h,v 1.7 2001/01/24 19:43:27 momjian Exp $ + * $Id: item.h,v 1.8 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,5 +15,4 @@ #define ITEM_H typedef Pointer Item; - #endif /* ITEM_H */ diff --git a/src/include/storage/itemid.h b/src/include/storage/itemid.h index 68ebcfee50..ab4dca9b51 100644 --- a/src/include/storage/itemid.h +++ b/src/include/storage/itemid.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: itemid.h,v 1.16 2001/03/22 04:01:06 momjian Exp $ + * $Id: itemid.h,v 1.17 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,5 +93,4 @@ typedef bits16 ItemIdFlags; AssertMacro(ItemIdIsValid(itemId)), \ (bool) (((itemId)->lp_flags & LP_USED) != 0) \ ) - #endif /* ITEMID_H */ diff --git a/src/include/storage/itempos.h b/src/include/storage/itempos.h index 70aa5579c2..453863cd40 100644 --- a/src/include/storage/itempos.h +++ b/src/include/storage/itempos.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: itempos.h,v 1.12 2001/01/24 19:43:27 momjian Exp $ + * $Id: itempos.h,v 1.13 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ typedef ItemSubpositionData *ItemSubposition; */ #define PSKIP(OBJP, LEN)\ do { (OBJP)->op_cp += (LEN); (OBJP)->op_len -= (LEN); } while (0) - #endif /* ITEMPOS_H */ diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h index b26fab11e7..30fb918477 100644 --- a/src/include/storage/itemptr.h +++ b/src/include/storage/itemptr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: itemptr.h,v 1.18 2001/03/30 05:25:51 tgl Exp $ + * $Id: itemptr.h,v 1.19 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ * tuple header on disk, it's very important not to waste space with * structure padding bytes. The struct is designed to be six bytes long * (it contains three int16 fields) but a few compilers will pad it to - * eight bytes unless coerced. We apply appropriate persuasion where + * eight bytes unless coerced. We apply appropriate persuasion where * possible, and to cope with unpersuadable compilers, we try to use * "SizeOfIptrData" rather than "sizeof(ItemPointerData)" when computing * on-disk sizes. @@ -39,10 +39,12 @@ typedef struct ItemPointerData BlockIdData ip_blkid; OffsetNumber ip_posid; } + #ifdef __arm__ -__attribute__((packed)) /* Appropriate whack upside the head for ARM */ +__attribute__((packed)) /* Appropriate whack upside the head for + * ARM */ #endif - ItemPointerData; +ItemPointerData; #define SizeOfIptrData \ (offsetof(ItemPointerData, ip_posid) + sizeof(OffsetNumber)) @@ -140,5 +142,4 @@ typedef ItemPointerData *ItemPointer; */ extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2); - #endif /* ITEMPTR_H */ diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h index 05d6233138..a87a8e301b 100644 --- a/src/include/storage/large_object.h +++ b/src/include/storage/large_object.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: large_object.h,v 1.21 2001/03/22 04:01:07 momjian Exp $ + * $Id: large_object.h,v 1.22 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,5 +75,4 @@ extern int inv_seek(LargeObjectDesc *obj_desc, int offset, int whence); extern int inv_tell(LargeObjectDesc *obj_desc); extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes); extern int inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes); - #endif /* LARGE_OBJECT_H */ diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index 1fb490e6d6..c481b884a6 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lmgr.h,v 1.32 2001/07/09 22:18:34 tgl Exp $ + * $Id: lmgr.h,v 1.33 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,8 +31,8 @@ * ROW SHARE */ #define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR * UPDATE */ -#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, - * VACUUM FULL, and unqualified LOCK +#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM + * FULL, and unqualified LOCK * TABLE */ /* @@ -61,5 +61,4 @@ extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); /* Lock an XID (used to wait for a transaction to finish) */ extern void XactLockTableInsert(TransactionId xid); extern void XactLockTableWait(TransactionId xid); - #endif /* LMGR_H */ diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 7ff9fab32e..b5f20b3cb8 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lock.h,v 1.56 2001/10/01 05:36:17 tgl Exp $ + * $Id: lock.h,v 1.57 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -251,5 +251,4 @@ extern void InitDeadLockChecking(void); extern void DumpLocks(void); extern void DumpAllLocks(void); #endif - #endif /* LOCK_H */ diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h index 02610d3541..1725fc3b73 100644 --- a/src/include/storage/lwlock.h +++ b/src/include/storage/lwlock.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lwlock.h,v 1.1 2001/09/29 04:02:26 tgl Exp $ + * $Id: lwlock.h,v 1.2 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,37 +18,38 @@ * We have a number of predefined LWLocks, plus a bunch of LWLocks that are * dynamically assigned (for shared buffers). The LWLock structures live * in shared memory (since they contain shared data) and are identified by - * values of this enumerated type. We abuse the notion of an enum somewhat + * values of this enumerated type. We abuse the notion of an enum somewhat * by allowing values not listed in the enum declaration to be assigned. * The extra value MaxDynamicLWLock is there to keep the compiler from * deciding that the enum can be represented as char or short ... */ typedef enum LWLockId { - BufMgrLock, - LockMgrLock, - OidGenLock, - XidGenLock, - ShmemIndexLock, - SInvalLock, - FreeSpaceLock, - MMCacheLock, - WALInsertLock, - WALWriteLock, - ControlFileLock, - CheckpointLock, - CLogControlLock, + BufMgrLock, + LockMgrLock, + OidGenLock, + XidGenLock, + ShmemIndexLock, + SInvalLock, + FreeSpaceLock, + MMCacheLock, + WALInsertLock, + WALWriteLock, + ControlFileLock, + CheckpointLock, + CLogControlLock, - NumFixedLWLocks, /* must be last except for MaxDynamicLWLock */ + NumFixedLWLocks,/* must be last except for + * MaxDynamicLWLock */ - MaxDynamicLWLock = 1000000000 + MaxDynamicLWLock = 1000000000 } LWLockId; typedef enum LWLockMode { - LW_EXCLUSIVE, - LW_SHARED + LW_EXCLUSIVE, + LW_SHARED } LWLockMode; @@ -65,5 +66,4 @@ extern void LWLockReleaseAll(void); extern int NumLWLocks(void); extern int LWLockShmemSize(void); extern void CreateLWLocks(void); - #endif /* LWLOCK_H */ diff --git a/src/include/storage/off.h b/src/include/storage/off.h index e1f0b7418e..a575b8d23f 100644 --- a/src/include/storage/off.h +++ b/src/include/storage/off.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: off.h,v 1.10 2001/01/24 19:43:28 momjian Exp $ + * $Id: off.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,5 +54,4 @@ typedef uint16 OffsetNumber; ((OffsetNumber) (1 + (offsetNumber))) #define OffsetNumberPrev(offsetNumber) \ ((OffsetNumber) (-1 + (offsetNumber))) - #endif /* OFF_H */ diff --git a/src/include/storage/page.h b/src/include/storage/page.h index bbde73eca3..baf7e3ed26 100644 --- a/src/include/storage/page.h +++ b/src/include/storage/page.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: page.h,v 1.8 2001/01/24 19:43:28 momjian Exp $ + * $Id: page.h,v 1.9 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ typedef Pointer Page; * True iff page is valid. */ #define PageIsValid(page) PointerIsValid(page) - #endif /* PAGE_H */ diff --git a/src/include/storage/pos.h b/src/include/storage/pos.h index 18d4a80924..7035fe74f5 100644 --- a/src/include/storage/pos.h +++ b/src/include/storage/pos.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pos.h,v 1.10 2001/01/24 19:43:28 momjian Exp $ + * $Id: pos.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,5 +61,4 @@ typedef PositionIdData *PositionId; */ #define PositionIdGetOffsetNumber(positionId) \ ((OffsetNumber) *(positionId)) - #endif /* POS_H */ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index fe5f255bad..4be08aa3d2 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.50 2001/09/30 00:45:48 momjian Exp $ + * $Id: proc.h,v 1.51 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,9 +103,10 @@ typedef struct /* info about a single set of per-process semaphores */ IpcSemaphoreId procSemId; int32 freeSemMap; + /* - * In freeSemMap, bit i is set if the i'th semaphore of this sema - * set is allocated to a process. (i counts from 0 at the LSB) + * In freeSemMap, bit i is set if the i'th semaphore of this sema set + * is allocated to a process. (i counts from 0 at the LSB) */ } SEM_MAP_ENTRY; @@ -116,11 +117,12 @@ typedef struct PROC_HDR /* Info about semaphore sets used for per-process semaphores */ int semMapEntries; + /* - * VARIABLE LENGTH ARRAY: actual length is semMapEntries. - * THIS MUST BE LAST IN THE STRUCT DECLARATION. + * VARIABLE LENGTH ARRAY: actual length is semMapEntries. THIS MUST BE + * LAST IN THE STRUCT DECLARATION. */ - SEM_MAP_ENTRY procSemMap[1]; + SEM_MAP_ENTRY procSemMap[1]; } PROC_HDR; @@ -150,5 +152,4 @@ extern void ProcSendSignal(BackendId procId); extern bool enable_sigalrm_interrupt(int delayms); extern bool disable_sigalrm_interrupt(void); - #endif /* PROC_H */ diff --git a/src/include/storage/relfilenode.h b/src/include/storage/relfilenode.h index c53dea8f39..22af8343b5 100644 --- a/src/include/storage/relfilenode.h +++ b/src/include/storage/relfilenode.h @@ -18,5 +18,4 @@ typedef struct RelFileNode #define RelFileNodeEquals(node1, node2) \ ((node1).relNode == (node2).relNode && \ (node1).tblNode == (node2).tblNode) - #endif /* RELFILENODE_H */ diff --git a/src/include/storage/shmem.h b/src/include/storage/shmem.h index b41cc2aa0d..ef529a0826 100644 --- a/src/include/storage/shmem.h +++ b/src/include/storage/shmem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: shmem.h,v 1.33 2001/10/05 17:28:13 tgl Exp $ + * $Id: shmem.h,v 1.34 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -95,5 +95,4 @@ extern void SHMQueueInsertBefore(SHM_QUEUE *queue, SHM_QUEUE *elem); extern Pointer SHMQueueNext(SHM_QUEUE *queue, SHM_QUEUE *curElem, Size linkOffset); extern bool SHMQueueEmpty(SHM_QUEUE *queue); - #endif /* SHMEM_H */ diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h index 8ecb9024d2..21586b68ba 100644 --- a/src/include/storage/sinval.h +++ b/src/include/storage/sinval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sinval.h,v 1.22 2001/09/29 04:02:27 tgl Exp $ + * $Id: sinval.h,v 1.23 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ typedef struct ItemPointerData tuplePtr; /* tuple identifier in cached relation */ } SharedInvalCatcacheMsg; -#define SHAREDINVALRELCACHE_ID (-1) +#define SHAREDINVALRELCACHE_ID (-1) typedef struct { @@ -68,14 +68,14 @@ extern void CreateSharedInvalidationState(int maxBackends); extern void InitBackendSharedInvalidationState(void); extern void SendSharedInvalidMessage(SharedInvalidationMessage *msg); extern void ReceiveSharedInvalidMessages( - void (*invalFunction) (SharedInvalidationMessage *msg), - void (*resetFunction) (void)); + void (*invalFunction) (SharedInvalidationMessage *msg), + void (*resetFunction) (void)); extern bool DatabaseHasActiveBackends(Oid databaseId, bool ignoreMyself); extern bool TransactionIdIsInProgress(TransactionId xid); extern TransactionId GetOldestXmin(bool allDbs); extern int CountActiveBackends(void); + /* Use "struct PROC", not PROC, to avoid including proc.h here */ extern struct PROC *BackendIdGetProc(BackendId procId); - #endif /* SINVAL_H */ diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h index 606304ce31..e8d2967600 100644 --- a/src/include/storage/sinvaladt.h +++ b/src/include/storage/sinvaladt.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sinvaladt.h,v 1.27 2001/06/19 19:42:16 tgl Exp $ + * $Id: sinvaladt.h,v 1.28 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -112,7 +112,6 @@ extern int SIBackendInit(SISeg *segP); extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data); extern int SIGetDataEntry(SISeg *segP, int backendId, - SharedInvalidationMessage *data); + SharedInvalidationMessage *data); extern void SIDelExpiredDataEntries(SISeg *segP); - #endif /* SINVALADT_H */ diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index d20ce73a8f..2564fd04a2 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: smgr.h,v 1.31 2001/09/29 04:02:27 tgl Exp $ + * $Id: smgr.h,v 1.32 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,8 +28,8 @@ extern int smgrinit(void); extern int smgrcreate(int16 which, Relation reln); extern int smgrunlink(int16 which, Relation reln); -extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum, - char *buffer); +extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum, + char *buffer); extern int smgropen(int16 which, Relation reln, bool failOK); extern int smgrclose(int16 which, Relation reln); extern int smgrread(int16 which, Relation reln, BlockNumber blocknum, @@ -45,7 +45,7 @@ extern int smgrblindmarkdirty(int16 which, RelFileNode rnode, extern int smgrmarkdirty(int16 which, Relation reln, BlockNumber blkno); extern BlockNumber smgrnblocks(int16 which, Relation reln); extern BlockNumber smgrtruncate(int16 which, Relation reln, - BlockNumber nblocks); + BlockNumber nblocks); extern int smgrDoPendingDeletes(bool isCommit); extern int smgrcommit(void); extern int smgrabort(void); @@ -107,5 +107,4 @@ extern Datum smgrout(PG_FUNCTION_ARGS); extern Datum smgrin(PG_FUNCTION_ARGS); extern Datum smgreq(PG_FUNCTION_ARGS); extern Datum smgrne(PG_FUNCTION_ARGS); - #endif /* SMGR_H */ diff --git a/src/include/storage/spin.h b/src/include/storage/spin.h index bc6ad3fde0..9d13097915 100644 --- a/src/include/storage/spin.h +++ b/src/include/storage/spin.h @@ -40,7 +40,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: spin.h,v 1.16 2001/09/29 04:02:27 tgl Exp $ + * $Id: spin.h,v 1.17 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ S_LOCK(lock); \ } while (0) -#define SpinLockAcquire_NoHoldoff(lock) S_LOCK(lock) +#define SpinLockAcquire_NoHoldoff(lock) S_LOCK(lock) #define SpinLockRelease(lock) \ do { \ @@ -67,11 +67,10 @@ RESUME_INTERRUPTS(); \ } while (0) -#define SpinLockRelease_NoHoldoff(lock) S_UNLOCK(lock) +#define SpinLockRelease_NoHoldoff(lock) S_UNLOCK(lock) #define SpinLockFree(lock) S_LOCK_FREE(lock) extern void CreateSpinlocks(void); - #endif /* SPIN_H */ diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index c72f256afe..6e4fff9623 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -39,7 +39,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dest.h,v 1.25 2001/01/24 19:43:28 momjian Exp $ + * $Id: dest.h,v 1.26 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,12 +55,12 @@ */ typedef enum { - None, /* results are discarded */ - Debug, /* results go to debugging output */ - Remote, /* results sent to frontend process */ - RemoteInternal, /* results sent to frontend process in + None, /* results are discarded */ + Debug, /* results go to debugging output */ + Remote, /* results sent to frontend process */ + RemoteInternal, /* results sent to frontend process in * internal (binary) form */ - SPI /* results sent to SPI manager */ + SPI /* results sent to SPI manager */ } CommandDest; /* ---------------- @@ -97,5 +97,4 @@ extern void ReceiveCopyBegin(void); extern void NullCommand(CommandDest dest); extern void ReadyForQuery(CommandDest dest); extern void UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples); - #endif /* DEST_H */ diff --git a/src/include/tcop/fastpath.h b/src/include/tcop/fastpath.h index 9c1e10e017..b46c568d7d 100644 --- a/src/include/tcop/fastpath.h +++ b/src/include/tcop/fastpath.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fastpath.h,v 1.9 2001/06/01 15:45:42 tgl Exp $ + * $Id: fastpath.h,v 1.10 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,5 +14,4 @@ #define FASTPATH_H extern int HandleFunctionRequest(void); - #endif /* FASTPATH_H */ diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index a41cb1be1c..336e0323e0 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pquery.h,v 1.16 2001/01/24 19:43:28 momjian Exp $ + * $Id: pquery.h,v 1.17 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern void ProcessQuery(Query *parsetree, Plan *plan, CommandDest dest); extern EState *CreateExecutorState(void); extern Portal PreparePortal(char *portalName); - #endif /* PQUERY_H */ diff --git a/src/include/tcop/tcopdebug.h b/src/include/tcop/tcopdebug.h index 661c839c73..94be8307b3 100644 --- a/src/include/tcop/tcopdebug.h +++ b/src/include/tcop/tcopdebug.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tcopdebug.h,v 1.6 2001/01/24 19:43:28 momjian Exp $ + * $Id: tcopdebug.h,v 1.7 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,5 +40,4 @@ * #defines controlled by above definitions * ---------------------------------------------------------------- */ - #endif /* TCOPDEBUG_H */ diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index ff1bfadf58..c170e7bb08 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tcopprot.h,v 1.43 2001/10/21 03:25:36 tgl Exp $ + * $Id: tcopprot.h,v 1.44 2001/10/25 05:50:10 momjian Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -39,15 +39,13 @@ extern Plan *pg_plan_query(Query *querytree); extern void pg_exec_query_string(char *query_string, CommandDest dest, MemoryContext parse_context); - #endif /* BOOTSTRAP_INCLUDE */ extern void die(SIGNAL_ARGS); extern void quickdie(SIGNAL_ARGS); extern void authdie(SIGNAL_ARGS); -extern int PostgresMain(int argc, char *argv[], const char *username); +extern int PostgresMain(int argc, char *argv[], const char *username); extern void ResetUsage(void); extern void ShowUsage(void); extern FILE *StatFp; - #endif /* TCOPPROT_H */ diff --git a/src/include/tcop/utility.h b/src/include/tcop/utility.h index 8cb89cbd90..302fd21baa 100644 --- a/src/include/tcop/utility.h +++ b/src/include/tcop/utility.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: utility.h,v 1.10 2001/01/24 19:43:28 momjian Exp $ + * $Id: utility.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,5 +17,4 @@ #include "executor/execdesc.h" extern void ProcessUtility(Node *parsetree, CommandDest dest); - #endif /* UTILITY_H */ diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index df58c2aac2..eb227b3ea9 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: acl.h,v 1.36 2001/06/12 16:34:27 momjian Exp $ + * $Id: acl.h,v 1.37 2001/10/25 05:50:10 momjian Exp $ * * NOTES * For backward-compatibility purposes we have to allow there @@ -149,13 +149,14 @@ typedef ArrayType IdList; #define ACL_MODECHG_ADD_CHR '+' #define ACL_MODECHG_DEL_CHR '-' #define ACL_MODECHG_EQL_CHR '=' -#define ACL_MODE_STR "arwdRxt" /* list of valid characters */ -#define ACL_MODE_INSERT_CHR 'a' /* formerly known as "append" */ -#define ACL_MODE_SELECT_CHR 'r' /* formerly known as "read" */ -#define ACL_MODE_UPDATE_CHR 'w' /* formerly known as "write" */ +#define ACL_MODE_STR "arwdRxt" /* list of valid + * characters */ +#define ACL_MODE_INSERT_CHR 'a' /* formerly known as "append" */ +#define ACL_MODE_SELECT_CHR 'r' /* formerly known as "read" */ +#define ACL_MODE_UPDATE_CHR 'w' /* formerly known as "write" */ #define ACL_MODE_DELETE_CHR 'd' #define ACL_MODE_RULE_CHR 'R' -#define ACL_MODE_REFERENCES_CHR 'x' +#define ACL_MODE_REFERENCES_CHR 'x' #define ACL_MODE_TRIGGER_CHR 't' /* result codes for pg_aclcheck */ @@ -203,8 +204,7 @@ extern int32 pg_aclcheck(char *relname, Oid userid, AclMode mode); extern bool pg_ownercheck(Oid userid, const char *name, int cacheid); extern bool pg_oper_ownercheck(Oid userid, Oid oprid); extern bool pg_func_ownercheck(Oid userid, char *funcname, - int nargs, Oid *arglist); + int nargs, Oid *arglist); extern bool pg_aggr_ownercheck(Oid userid, char *aggname, - Oid basetypeID); - + Oid basetypeID); #endif /* ACL_H */ diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 9927035374..83fe685e49 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: array.h,v 1.29 2001/03/22 04:01:10 momjian Exp $ + * $Id: array.h,v 1.30 2001/10/25 05:50:10 momjian Exp $ * * NOTES * XXX the data array should be MAXALIGN'd -- currently we only INTALIGN @@ -127,5 +127,4 @@ extern void mda_get_prod(int n, int *range, int *prod); extern void mda_get_offset_values(int n, int *dist, int *prod, int *span); extern int mda_next_tuple(int n, int *curr, int *span); - #endif /* ARRAY_H */ diff --git a/src/include/utils/ascii.h b/src/include/utils/ascii.h index 15d4a6da67..cfead8bd1a 100644 --- a/src/include/utils/ascii.h +++ b/src/include/utils/ascii.h @@ -2,7 +2,7 @@ /* ----------------------------------------------------------------------- * ascii.h * - * $Id: ascii.h,v 1.5 2001/03/22 04:01:10 momjian Exp $ + * $Id: ascii.h,v 1.6 2001/10/25 05:50:10 momjian Exp $ * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group * @@ -22,7 +22,5 @@ extern Datum to_ascii_default(PG_FUNCTION_ARGS); extern char *pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int enc); - #endif /* MULTIBYTE */ - #endif /* _ASCII_H_ */ diff --git a/src/include/utils/bit.h b/src/include/utils/bit.h index 3b58e6b2f7..82df884b69 100644 --- a/src/include/utils/bit.h +++ b/src/include/utils/bit.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bit.h,v 1.9 2001/01/24 19:43:28 momjian Exp $ + * $Id: bit.h,v 1.10 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,5 +34,4 @@ extern void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex); * True iff the bit is set (1) in a bit array. */ extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex); - #endif /* BIT_H */ diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 36d85aa042..006b1286f8 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.168 2001/10/13 23:32:34 tgl Exp $ + * $Id: builtins.h,v 1.169 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "fmgr.h" #include "nodes/primnodes.h" -#include "storage/itemptr.h" /* for setLastTid() */ +#include "storage/itemptr.h" /* for setLastTid() */ /* * Defined in adt/ @@ -345,7 +345,7 @@ extern char *deparse_expression(Node *expr, List *dpcontext, extern List *deparse_context_for(char *relname, Oid relid); /* tid.c */ -extern void setLastTid(const ItemPointer tid); +extern void setLastTid(const ItemPointer tid); extern Datum tidin(PG_FUNCTION_ARGS); extern Datum tidout(PG_FUNCTION_ARGS); extern Datum tideq(PG_FUNCTION_ARGS); @@ -599,13 +599,12 @@ extern Datum pg_convert2(PG_FUNCTION_ARGS); /* format_type.c */ extern Datum format_type(PG_FUNCTION_ARGS); -extern char * format_type_be(Oid type_oid); -extern char * format_type_with_typemod(Oid type_oid, int32 typemod); +extern char *format_type_be(Oid type_oid); +extern char *format_type_with_typemod(Oid type_oid, int32 typemod); extern Datum oidvectortypes(PG_FUNCTION_ARGS); extern int32 type_maximum_size(Oid type_oid, int32 typemod); /* quote.c */ extern Datum quote_ident(PG_FUNCTION_ARGS); extern Datum quote_literal(PG_FUNCTION_ARGS); - #endif /* BUILTINS_H */ diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h index 07897fb0a5..49a70616e7 100644 --- a/src/include/utils/cash.h +++ b/src/include/utils/cash.h @@ -45,5 +45,4 @@ extern Datum cashlarger(PG_FUNCTION_ARGS); extern Datum cashsmaller(PG_FUNCTION_ARGS); extern Datum cash_words(PG_FUNCTION_ARGS); - #endif /* CASH_H */ diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 6b7a656e01..18fd9473e4 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catcache.h,v 1.34 2001/06/19 19:42:16 tgl Exp $ + * $Id: catcache.h,v 1.35 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,7 @@ typedef struct catcache char *cc_relname; /* name of relation the tuples come from */ char *cc_indname; /* name of index matching cache keys */ int cc_reloidattr; /* AttrNumber of relation OID, or 0 */ - bool cc_relisshared; /* is relation shared? */ + bool cc_relisshared; /* is relation shared? */ TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */ int cc_ntup; /* # of tuples currently in this cache */ int cc_size; /* # of hash buckets in this cache */ @@ -53,6 +53,7 @@ typedef struct catctup int ct_magic; /* for Assert checks */ #define CT_MAGIC 0x57261502 CatCache *my_cache; /* link to owning catcache */ + /* * Each tuple in a cache is a member of two lists: one lists all the * elements in all the caches in LRU order, and the other lists just @@ -86,8 +87,8 @@ extern void CreateCacheMemoryContext(void); extern void AtEOXact_CatCache(bool isCommit); extern CatCache *InitCatCache(int id, char *relname, char *indname, - int reloidattr, - int nkeys, int *key); + int reloidattr, + int nkeys, int *key); extern HeapTuple SearchCatCache(CatCache *cache, Datum v1, Datum v2, @@ -99,7 +100,6 @@ extern void CatalogCacheFlushRelation(Oid relId); extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, ItemPointer pointer); extern void PrepareToInvalidateCacheTuple(Relation relation, - HeapTuple tuple, - void (*function) (int, Index, ItemPointer, Oid)); - + HeapTuple tuple, + void (*function) (int, Index, ItemPointer, Oid)); #endif /* CATCACHE_H */ diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 0e1aa14128..9773d40768 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: date.h,v 1.14 2001/10/18 17:30:16 thomas Exp $ + * $Id: date.h,v 1.15 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -123,5 +123,4 @@ extern Datum timetz_zone(PG_FUNCTION_ARGS); extern Datum timetz_izone(PG_FUNCTION_ARGS); extern Datum timetz_pl_interval(PG_FUNCTION_ARGS); extern Datum timetz_mi_interval(PG_FUNCTION_ARGS); - #endif /* DATE_H */ diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index dbba5e0642..57960c7699 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.23 2001/10/23 20:17:27 tgl Exp $ + * $Id: datetime.h,v 1.24 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -281,5 +281,4 @@ extern int DecodeUnits(int field, char *lowtoken, int *val); extern void ClearDateCache(bool); extern int j2day(int jd); - #endif /* DATETIME_H */ diff --git a/src/include/utils/datum.h b/src/include/utils/datum.h index b667495f18..7f6e1662e5 100644 --- a/src/include/utils/datum.h +++ b/src/include/utils/datum.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datum.h,v 1.13 2001/03/22 04:01:11 momjian Exp $ + * $Id: datum.h,v 1.14 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,5 +45,4 @@ extern void datumFree(Datum value, bool typByVal, int typLen); */ extern bool datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen); - #endif /* DATUM_H */ diff --git a/src/include/utils/dynahash.h b/src/include/utils/dynahash.h index d324722383..549fd878c4 100644 --- a/src/include/utils/dynahash.h +++ b/src/include/utils/dynahash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dynahash.h,v 1.8 2001/01/24 19:43:28 momjian Exp $ + * $Id: dynahash.h,v 1.9 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,5 +15,4 @@ #define DYNAHASH_H extern int my_log2(long num); - #endif /* DYNAHASH_H */ diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h index 569aba644f..cf685ba745 100644 --- a/src/include/utils/dynamic_loader.h +++ b/src/include/utils/dynamic_loader.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: dynamic_loader.h,v 1.17 2001/02/10 02:31:29 tgl Exp $ + * $Id: dynamic_loader.h,v 1.18 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,5 +21,4 @@ extern void *pg_dlopen(char *filename); extern PGFunction pg_dlsym(void *handle, char *funcname); extern void pg_dlclose(void *handle); extern char *pg_dlerror(void); - #endif /* DYNAMIC_LOADER_H */ diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 4c98f4119c..83309a285a 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: elog.h,v 1.27 2001/06/08 21:16:49 petere Exp $ + * $Id: elog.h,v 1.28 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,11 +33,11 @@ extern bool Log_timestamp; extern bool Log_pid; -extern void elog(int lev, const char *fmt,...) +extern void +elog(int lev, const char *fmt,...) /* This extension allows gcc to check the format string for consistency with the supplied arguments. */ __attribute__((format(printf, 2, 3))); extern int DebugFileOpen(void); - #endif /* ELOG_H */ diff --git a/src/include/utils/exc.h b/src/include/utils/exc.h index 09b4179097..e8d90c432d 100644 --- a/src/include/utils/exc.h +++ b/src/include/utils/exc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: exc.h,v 1.19 2001/02/10 02:31:29 tgl Exp $ + * $Id: exc.h,v 1.20 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,5 +84,4 @@ extern void ExcRaise(Exception *excP, */ extern void ExcAbort(const Exception *excP, ExcDetail detail, ExcData data, ExcMessage message); - #endif /* EXC_H */ diff --git a/src/include/utils/excid.h b/src/include/utils/excid.h index eebab2e4f1..db1189842e 100644 --- a/src/include/utils/excid.h +++ b/src/include/utils/excid.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: excid.h,v 1.10 2001/03/23 18:26:01 tgl Exp $ + * $Id: excid.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,9 +20,11 @@ extern DLLIMPORT Exception BadState; extern DLLIMPORT Exception BadArg; extern DLLIMPORT Exception Unimplemented; -extern DLLIMPORT Exception CatalogFailure;/* XXX inconsistent naming style */ -extern DLLIMPORT Exception InternalError; /* XXX inconsistent naming style */ -extern DLLIMPORT Exception SemanticError; /* XXX inconsistent naming style */ -extern DLLIMPORT Exception SystemError; /* XXX inconsistent naming style */ - +extern DLLIMPORT Exception CatalogFailure; /* XXX inconsistent naming + * style */ +extern DLLIMPORT Exception InternalError; /* XXX inconsistent naming + * style */ +extern DLLIMPORT Exception SemanticError; /* XXX inconsistent naming + * style */ +extern DLLIMPORT Exception SystemError; /* XXX inconsistent naming style */ #endif /* EXCID_H */ diff --git a/src/include/utils/fcache.h b/src/include/utils/fcache.h index 7d94590feb..04a7728bb5 100644 --- a/src/include/utils/fcache.h +++ b/src/include/utils/fcache.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fcache.h,v 1.17 2001/09/21 00:11:31 tgl Exp $ + * $Id: fcache.h,v 1.18 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,11 +27,11 @@ * We store the fmgr lookup info to avoid recomputing it on each call. * * We also need to store argument values across calls when evaluating a - * function-returning-set. This is pretty ugly (and not re-entrant); + * function-returning-set. This is pretty ugly (and not re-entrant); * current-evaluation info should be somewhere in the econtext, not in * the querytree. As it stands, a function-returning-set can't safely be * recursive, at least not if it's in plpgsql which will try to re-use - * the querytree at multiple execution nesting levels. FIXME someday. + * the querytree at multiple execution nesting levels. FIXME someday. */ typedef struct FunctionCache @@ -66,5 +66,4 @@ typedef struct FunctionCache extern FunctionCachePtr init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt); - #endif /* FCACHE_H */ diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h index 34411e3330..afef186e27 100644 --- a/src/include/utils/fmgrtab.h +++ b/src/include/utils/fmgrtab.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fmgrtab.h,v 1.16 2001/03/22 04:01:12 momjian Exp $ + * $Id: fmgrtab.h,v 1.17 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,5 @@ typedef struct extern const FmgrBuiltin fmgr_builtins[]; -extern const int fmgr_nbuiltins;/* number of entries in table */ - +extern const int fmgr_nbuiltins; /* number of entries in table */ #endif /* FMGRTAB_H */ diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h index 14d3f578ab..2fd297c978 100644 --- a/src/include/utils/formatting.h +++ b/src/include/utils/formatting.h @@ -2,7 +2,7 @@ /* ----------------------------------------------------------------------- * formatting.h * - * $Id: formatting.h,v 1.9 2001/09/28 08:09:14 thomas Exp $ + * $Id: formatting.h,v 1.10 2001/10/25 05:50:10 momjian Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group @@ -32,5 +32,4 @@ extern Datum int4_to_char(PG_FUNCTION_ARGS); extern Datum int8_to_char(PG_FUNCTION_ARGS); extern Datum float4_to_char(PG_FUNCTION_ARGS); extern Datum float8_to_char(PG_FUNCTION_ARGS); - #endif diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h index 99a0524acc..7518c351be 100644 --- a/src/include/utils/geo_decls.h +++ b/src/include/utils/geo_decls.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geo_decls.h,v 1.34 2001/03/22 04:01:12 momjian Exp $ + * $Id: geo_decls.h,v 1.35 2001/10/25 05:50:10 momjian Exp $ * * NOTE * These routines do *not* use the float types from adt/. @@ -397,5 +397,4 @@ extern Datum positionsel(PG_FUNCTION_ARGS); extern Datum positionjoinsel(PG_FUNCTION_ARGS); extern Datum contsel(PG_FUNCTION_ARGS); extern Datum contjoinsel(PG_FUNCTION_ARGS); - #endif /* GEO_DECLS_H */ diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 176fa7c893..ecb883d105 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -4,7 +4,7 @@ * External declarations pertaining to backend/utils/misc/guc.c and * backend/utils/misc/guc-file.l * - * $Id: guc.h,v 1.10 2001/09/30 20:16:21 tgl Exp $ + * $Id: guc.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ */ #ifndef GUC_H #define GUC_H @@ -39,22 +39,22 @@ */ typedef enum { - PGC_POSTMASTER, - PGC_SIGHUP, - PGC_BACKEND, - PGC_SUSET, - PGC_USERSET + PGC_POSTMASTER, + PGC_SIGHUP, + PGC_BACKEND, + PGC_SUSET, + PGC_USERSET } GucContext; extern void SetConfigOption(const char *name, const char *value, - GucContext context, bool makeDefault); + GucContext context, bool makeDefault); extern const char *GetConfigOption(const char *name); extern void ProcessConfigFile(GucContext context); extern void ResetAllOptions(bool isStartup); extern void ParseLongOption(const char *string, char **name, char **value); extern bool set_config_option(const char *name, const char *value, - GucContext context, bool DoIt, bool makeDefault); + GucContext context, bool DoIt, bool makeDefault); extern void ShowAllGUCConfig(void); @@ -72,5 +72,4 @@ extern bool Show_btree_build_stats; extern bool SQL_inheritance; extern bool Australian_timezones; - #endif /* GUC_H */ diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 79f3296f12..78ecc485ca 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hsearch.h,v 1.22 2001/10/05 17:28:13 tgl Exp $ + * $Id: hsearch.h,v 1.23 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,9 +31,9 @@ * tables, the initial directory size can be left at the default. */ #define DEF_SEGSIZE 256 -#define DEF_SEGSIZE_SHIFT 8 /* must be log2(DEF_SEGSIZE) */ +#define DEF_SEGSIZE_SHIFT 8/* must be log2(DEF_SEGSIZE) */ #define DEF_DIRSIZE 256 -#define DEF_FFACTOR 1 /* default fill factor */ +#define DEF_FFACTOR 1/* default fill factor */ #define PRIME1 37 /* for the hash function */ #define PRIME2 1048583 @@ -84,11 +84,12 @@ typedef struct HASHHDR */ typedef struct HTAB { - HASHHDR *hctl; /* shared control information */ + HASHHDR *hctl; /* shared control information */ HASHSEGMENT *dir; /* directory of segment starts */ - long (*hash) (void *key, int keysize); /* Hash Function */ - void *(*alloc) (Size);/* memory allocator */ - MemoryContext hcxt; /* memory context if default allocator used */ + long (*hash) (void *key, int keysize); /* Hash Function */ + void *(*alloc) (Size); /* memory allocator */ + MemoryContext hcxt; /* memory context if default allocator + * used */ char *tabname; /* table name (for error messages) */ bool isshared; /* true if table is in shared memory */ } HTAB; @@ -100,14 +101,14 @@ typedef struct HASHCTL long ssize; /* Segment Size */ long dsize; /* (initial) Directory Size */ long ffactor; /* Fill factor */ - long (*hash) (void *key, int keysize); /* Hash Function */ + long (*hash) (void *key, int keysize); /* Hash Function */ long keysize; /* hash key length in bytes */ long entrysize; /* total user element size in bytes */ long max_dsize; /* limit to dsize if directory size is * limited */ - void *(*alloc) (Size);/* memory allocation function */ + void *(*alloc) (Size); /* memory allocation function */ HASHSEGMENT *dir; /* directory of segment starts */ - HASHHDR *hctl; /* location of header in shared mem */ + HASHHDR *hctl; /* location of header in shared mem */ MemoryContext hcxt; /* memory context to use for allocations */ } HASHCTL; @@ -131,11 +132,11 @@ typedef struct HASHCTL /* hash_search operations */ typedef enum { - HASH_FIND, - HASH_ENTER, - HASH_REMOVE, - HASH_FIND_SAVE, - HASH_REMOVE_SAVED + HASH_FIND, + HASH_ENTER, + HASH_REMOVE, + HASH_FIND_SAVE, + HASH_REMOVE_SAVED } HASHACTION; /* hash_seq status (should be considered an opaque type by callers) */ @@ -150,7 +151,7 @@ typedef struct * prototypes for functions in dynahash.c */ extern HTAB *hash_create(const char *tabname, long nelem, - HASHCTL *info, int flags); + HASHCTL *info, int flags); extern void hash_destroy(HTAB *hashp); extern void hash_stats(const char *where, HTAB *hashp); extern void *hash_search(HTAB *hashp, void *keyPtr, HASHACTION action, @@ -165,5 +166,4 @@ extern long hash_select_dirsize(long num_entries); */ extern long string_hash(void *key, int keysize); extern long tag_hash(void *key, int keysize); - #endif /* HSEARCH_H */ diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h index acb71e6002..9d0b990def 100644 --- a/src/include/utils/inet.h +++ b/src/include/utils/inet.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: inet.h,v 1.10 2001/03/22 04:01:12 momjian Exp $ + * $Id: inet.h,v 1.11 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,5 +67,4 @@ typedef struct macaddr #define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n)) #define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x) - #endif /* INET_H */ diff --git a/src/include/utils/int8.h b/src/include/utils/int8.h index 849b148060..161bb83844 100644 --- a/src/include/utils/int8.h +++ b/src/include/utils/int8.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: int8.h,v 1.27 2001/08/14 22:21:59 tgl Exp $ + * $Id: int8.h,v 1.28 2001/10/25 05:50:10 momjian Exp $ * * NOTES * These data types are supported on all 64-bit architectures, and may @@ -103,5 +103,4 @@ extern Datum dtoi8(PG_FUNCTION_ARGS); extern Datum int8_text(PG_FUNCTION_ARGS); extern Datum text_int8(PG_FUNCTION_ARGS); - #endif /* INT8_H */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index d6277e27e1..bc5b8d7fbe 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: inval.h,v 1.20 2001/06/19 19:42:16 tgl Exp $ + * $Id: inval.h,v 1.21 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,5 +26,4 @@ extern void CommandEndInvalidationMessages(bool isCommit); extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple); extern void RelationMark4RollbackHeapTuple(Relation relation, HeapTuple tuple); - #endif /* INVAL_H */ diff --git a/src/include/utils/logtape.h b/src/include/utils/logtape.h index afc8dc0b6f..960a2d3abe 100644 --- a/src/include/utils/logtape.h +++ b/src/include/utils/logtape.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: logtape.h,v 1.4 2001/01/24 19:43:28 momjian Exp $ + * $Id: logtape.h,v 1.5 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,5 +38,4 @@ extern bool LogicalTapeSeek(LogicalTapeSet *lts, int tapenum, long blocknum, int offset); extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum, long *blocknum, int *offset); - #endif /* LOGTAPE_H */ diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 6b3f8a52ea..17e9c51068 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.36 2001/09/06 02:07:42 tgl Exp $ + * $Id: lsyscache.h,v 1.37 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ extern Oid get_atttype(Oid relid, AttrNumber attnum); extern bool get_attisset(Oid relid, char *attname); extern int32 get_atttypmod(Oid relid, AttrNumber attnum); extern void get_atttypetypmod(Oid relid, AttrNumber attnum, - Oid *typid, int32 *typmod); + Oid *typid, int32 *typmod); extern bool opclass_is_btree(Oid opclass); extern RegProcedure get_opcode(Oid opno); extern char *get_opname(Oid opno); @@ -46,15 +46,14 @@ extern bool get_typdefault(Oid typid, Datum *defaultValue); extern int32 get_typavgwidth(Oid typid, int32 typmod); extern int32 get_attavgwidth(Oid relid, AttrNumber attnum); extern bool get_attstatsslot(HeapTuple statstuple, - Oid atttype, int32 atttypmod, - int reqkind, Oid reqop, - Datum **values, int *nvalues, - float4 **numbers, int *nnumbers); + Oid atttype, int32 atttypmod, + int reqkind, Oid reqop, + Datum **values, int *nvalues, + float4 **numbers, int *nnumbers); extern void free_attstatsslot(Oid atttype, - Datum *values, int nvalues, - float4 *numbers, int nnumbers); + Datum *values, int nvalues, + float4 *numbers, int nnumbers); extern int32 get_usesysid(const char *username); #define TypeIsToastable(typid) (get_typstorage(typid) != 'p') - #endif /* LSYSCACHE_H */ diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index ca8d2d78d0..263a297830 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.43 2001/03/22 04:01:13 momjian Exp $ + * $Id: memutils.h,v 1.44 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -116,5 +116,4 @@ extern MemoryContext AllocSetContextCreate(MemoryContext parent, #define ALLOCSET_DEFAULT_INITSIZE (8 * 1024) #define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024) - #endif /* MEMUTILS_H */ diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index b7aaf0d0ac..03bb3b6e9f 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.h,v 1.32 2001/10/18 17:30:16 thomas Exp $ + * $Id: nabstime.h,v 1.33 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -159,5 +159,4 @@ extern Datum timeofday(PG_FUNCTION_ARGS); extern AbsoluteTime GetCurrentAbsoluteTime(void); extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec); extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char **tzn); - #endif /* NABSTIME_H */ diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h index fa251c2262..1198b838ae 100644 --- a/src/include/utils/numeric.h +++ b/src/include/utils/numeric.h @@ -5,7 +5,7 @@ * * 1998 Jan Wieck * - * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.12 2001/03/22 04:01:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.13 2001/10/25 05:50:10 momjian Exp $ * * ---------- */ @@ -81,5 +81,4 @@ typedef NumericData *Numeric; #define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n)) #define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n)) #define PG_RETURN_NUMERIC(x) return NumericGetDatum(x) - #endif /* _PG_NUMERIC_H_ */ diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index 07a7320f97..8ba9132a44 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -21,7 +21,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: palloc.h,v 1.16 2001/03/22 04:01:13 momjian Exp $ + * $Id: palloc.h,v 1.17 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,5 +63,4 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string); #define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str)) - #endif /* PALLOC_H */ diff --git a/src/include/utils/pg_crc.h b/src/include/utils/pg_crc.h index 675859beed..e6d4b223fc 100644 --- a/src/include/utils/pg_crc.h +++ b/src/include/utils/pg_crc.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_crc.h,v 1.3 2001/03/23 18:42:12 tgl Exp $ + * $Id: pg_crc.h,v 1.4 2001/10/25 05:50:10 momjian Exp $ */ #ifndef PG_CRC_H #define PG_CRC_H @@ -116,7 +116,5 @@ do { \ /* Constant table for CRC calculation */ extern const uint64 crc_table[]; - #endif /* INT64_IS_BUSTED */ - #endif /* PG_CRC_H */ diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h index d6257b7654..a2a727290a 100644 --- a/src/include/utils/pg_locale.h +++ b/src/include/utils/pg_locale.h @@ -4,7 +4,7 @@ * The PostgreSQL locale utils. * * - * $Id: pg_locale.h,v 1.8 2001/09/29 21:16:30 tgl Exp $ + * $Id: pg_locale.h,v 1.9 2001/10/25 05:50:10 momjian Exp $ * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group * @@ -31,16 +31,17 @@ typedef struct PG_LocaleCategories *lc_collate, *lc_monetary, *lc_messages; -} PG_LocaleCategories; +} PG_LocaleCategories; /* - * Save locale category settings into PG memory + * Save locale category settings into PG memory */ -extern void PGLC_current(PG_LocaleCategories * lc); +extern void PGLC_current(PG_LocaleCategories *lc); + /* * Free memory allocated in PGLC_current() */ -extern void PGLC_free_categories(PG_LocaleCategories * lc); +extern void PGLC_free_categories(PG_LocaleCategories *lc); /*------ * Return the POSIX lconv struct (contains number/money formatting information) @@ -51,7 +52,5 @@ extern void PGLC_free_categories(PG_LocaleCategories * lc); */ extern struct lconv *PGLC_localeconv(void); - #endif /* USE_LOCALE */ - #endif /* _PG_LOCALE_ */ diff --git a/src/include/utils/pg_lzcompress.h b/src/include/utils/pg_lzcompress.h index fd1e62a8be..deaa8b1fb2 100644 --- a/src/include/utils/pg_lzcompress.h +++ b/src/include/utils/pg_lzcompress.h @@ -1,7 +1,7 @@ /* ---------- * pg_lzcompress.h - * - * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.5 2000/04/12 17:16:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/utils/pg_lzcompress.h,v 1.6 2001/10/25 05:50:10 momjian Exp $ * * Definitions for the builtin LZ compressor * ---------- @@ -227,5 +227,4 @@ int pglz_decompress(PGLZ_Header *source, char *dest); */ extern int pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate); extern int pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate); - #endif /* _PG_LZCOMPRESS_H_ */ diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index df3581c653..770b27f3f3 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.29 2001/10/05 17:28:13 tgl Exp $ + * $Id: portal.h,v 1.30 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ typedef struct PortalData bool atStart; /* T => fetch backwards is not allowed */ bool atEnd; /* T => fetch forwards is not allowed */ void (*cleanup) (Portal); /* Cleanup routine (optional) */ -} PortalData; +} PortalData; /* * PortalIsValid @@ -67,5 +67,4 @@ extern void PortalSetQuery(Portal portal, QueryDesc *queryDesc, TupleDesc attinfo, EState *state, void (*cleanup) (Portal portal)); - #endif /* PORTAL_H */ diff --git a/src/include/utils/ps_status.h b/src/include/utils/ps_status.h index fb4a52dce4..94b8e0911d 100644 --- a/src/include/utils/ps_status.h +++ b/src/include/utils/ps_status.h @@ -4,7 +4,7 @@ * * Declarations for backend/utils/misc/ps_status.c * - * $Id: ps_status.h,v 1.20 2001/10/21 03:25:36 tgl Exp $ + * $Id: ps_status.h,v 1.21 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,10 +15,9 @@ extern void save_ps_display_args(int argc, char *argv[]); extern void init_ps_display(const char *username, const char *dbname, - const char *host_info); + const char *host_info); extern void set_ps_display(const char *activity); extern const char *get_ps_display(void); - #endif /* PS_STATUS_H */ diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 9cc7a2ecb4..11c06069aa 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: rel.h,v 1.52 2001/10/06 23:21:44 tgl Exp $ + * $Id: rel.h,v 1.53 2001/10/25 05:50:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,9 +64,9 @@ typedef struct Trigger typedef struct TriggerDesc { /* - * Index data to identify which triggers are which. Since each trigger - * can appear in more than one class, for each class we provide a list - * of integer indexes into the triggers array. + * Index data to identify which triggers are which. Since each + * trigger can appear in more than one class, for each class we + * provide a list of integer indexes into the triggers array. */ #define TRIGGER_NUM_EVENT_CLASSES 4 @@ -89,12 +89,12 @@ typedef struct TriggerDesc * Same for the statistics collector data in Relation and scan data. * ---------- */ -typedef struct PgStat_Info +typedef struct PgStat_Info { - void *tabentry; - bool no_stats; - bool heap_scan_counted; - bool index_scan_counted; + void *tabentry; + bool no_stats; + bool heap_scan_counted; + bool index_scan_counted; } PgStat_Info; /* @@ -105,9 +105,9 @@ typedef struct RelationData { File rd_fd; /* open file descriptor, or -1 if none */ RelFileNode rd_node; /* file node (physical identifier) */ - BlockNumber rd_nblocks; /* number of blocks in rel */ - BlockNumber rd_targblock; /* current insertion target block, - * or InvalidBlockNumber */ + BlockNumber rd_nblocks; /* number of blocks in rel */ + BlockNumber rd_targblock; /* current insertion target block, or + * InvalidBlockNumber */ int rd_refcnt; /* reference count */ bool rd_myxactonly; /* rel uses the local buffer mgr */ bool rd_isnailed; /* rel is nailed in cache */ @@ -127,11 +127,12 @@ typedef struct RelationData MemoryContext rd_indexcxt; /* private memory cxt for this stuff */ IndexStrategy rd_istrat; /* operator strategy map */ RegProcedure *rd_support; /* OIDs of support procedures */ - struct FmgrInfo *rd_supportinfo; /* lookup info for support procedures */ + struct FmgrInfo *rd_supportinfo; /* lookup info for support + * procedures */ /* "struct FmgrInfo" avoids need to include fmgr.h here */ /* statistics collection area */ - PgStat_Info pgstat_info; + PgStat_Info pgstat_info; } RelationData; typedef RelationData *Relation; @@ -278,5 +279,4 @@ typedef Relation *RelationPtr; /* added to prevent circular dependency. bjm 1999/11/15 */ extern char *get_temp_rel_by_physicalname(const char *relname); - #endif /* REL_H */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 861185cea9..d4243c7c12 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: relcache.h,v 1.26 2001/10/06 23:21:44 tgl Exp $ + * $Id: relcache.h,v 1.27 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,9 +45,9 @@ extern void RelationCacheInitializePhase2(void); * Routine to create a relcache entry for an about-to-be-created relation */ extern Relation RelationBuildLocalRelation(const char *relname, - TupleDesc tupDesc, - Oid relid, Oid dbid, - bool nailit); + TupleDesc tupDesc, + Oid relid, Oid dbid, + bool nailit); /* * Routines for flushing/rebuilding relcache entries in various scenarios @@ -72,5 +72,4 @@ extern void DestroyDummyCaches(void); */ #define RELCACHE_INIT_FILENAME "pg_internal.init" - #endif /* RELCACHE_H */ diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h index 9c0c7b3ac9..5a7c44a6c6 100644 --- a/src/include/utils/selfuncs.h +++ b/src/include/utils/selfuncs.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: selfuncs.h,v 1.1 2001/06/25 21:11:45 tgl Exp $ + * $Id: selfuncs.h,v 1.2 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,13 +21,13 @@ typedef enum { - Pattern_Type_Like, Pattern_Type_Like_IC, - Pattern_Type_Regex, Pattern_Type_Regex_IC + Pattern_Type_Like, Pattern_Type_Like_IC, + Pattern_Type_Regex, Pattern_Type_Regex_IC } Pattern_Type; typedef enum { - Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact + Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact } Pattern_Prefix_Status; @@ -73,5 +73,4 @@ extern Datum btcostestimate(PG_FUNCTION_ARGS); extern Datum rtcostestimate(PG_FUNCTION_ARGS); extern Datum hashcostestimate(PG_FUNCTION_ARGS); extern Datum gistcostestimate(PG_FUNCTION_ARGS); - #endif /* SELFUNCS_H */ diff --git a/src/include/utils/sets.h b/src/include/utils/sets.h index 8ecf2389a0..b620967b01 100644 --- a/src/include/utils/sets.h +++ b/src/include/utils/sets.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sets.h,v 1.9 2001/01/24 19:43:29 momjian Exp $ + * $Id: sets.h,v 1.10 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,5 +23,4 @@ extern Oid SetDefine(char *querystr, char *typename); extern Datum seteval(PG_FUNCTION_ARGS); - #endif /* SETS_H */ diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 6a71d77bfc..e21081cc1e 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: syscache.h,v 1.33 2001/08/21 16:36:06 tgl Exp $ + * $Id: syscache.h,v 1.34 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,11 +66,10 @@ extern void ReleaseSysCache(HeapTuple tuple); extern HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4); extern bool SearchSysCacheExists(int cacheId, - Datum key1, Datum key2, Datum key3, Datum key4); + Datum key1, Datum key2, Datum key3, Datum key4); extern Oid GetSysCacheOid(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4); extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull); - #endif /* SYSCACHE_H */ diff --git a/src/include/utils/temprel.h b/src/include/utils/temprel.h index f503850e4e..20dc75f9e9 100644 --- a/src/include/utils/temprel.h +++ b/src/include/utils/temprel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: temprel.h,v 1.17 2001/06/19 12:03:41 momjian Exp $ + * $Id: temprel.h,v 1.18 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,5 +29,4 @@ extern char *get_temp_rel_by_username(const char *user_relname); extern char *get_temp_rel_by_physicalname(const char *relname); #define is_temp_rel_name(relname) (get_temp_rel_by_username(relname) != NULL) - #endif /* TEMPREL_H */ diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index 1e193bed3b..2272c33ff2 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: timestamp.h,v 1.21 2001/10/18 17:30:16 thomas Exp $ + * $Id: timestamp.h,v 1.22 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,8 +37,10 @@ typedef double TimestampTz; typedef struct { - double time; /* all time units other than months and years */ - int32 month; /* months and years, after time for alignment */ + double time; /* all time units other than months and + * years */ + int32 month; /* months and years, after time for + * alignment */ } Interval; @@ -49,7 +51,7 @@ typedef struct * Therefore Timestamp is pass-by-reference if and only if float8 is! */ #define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X)) -#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X)) +#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X)) #define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X)) #define TimestampGetDatum(X) Float8GetDatum(X) @@ -166,9 +168,9 @@ extern Datum now(PG_FUNCTION_ARGS); /* Internal routines (not fmgr-callable) */ extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt); -extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, - double *fsec, char **tzn); -extern void dt2time(Timestamp dt, int *hour, int *min, double *sec); +extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, + double *fsec, char **tzn); +extern void dt2time(Timestamp dt, int *hour, int *min, double *sec); extern int interval2tm(Interval span, struct tm * tm, float8 *fsec); extern int tm2interval(struct tm * tm, double fsec, Interval *span); @@ -178,5 +180,4 @@ extern void GetEpochTime(struct tm * tm); extern void isoweek2date(int woy, int *year, int *mon, int *mday); extern int date2isoweek(int year, int mon, int mday); - #endif /* TIMESTAMP_H */ diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index cc238e7457..4ebcc094d7 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tqual.h,v 1.34 2001/08/26 16:56:03 tgl Exp $ + * $Id: tqual.h,v 1.35 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,11 +90,14 @@ extern bool ReferentialIntegritySnapshotOverride; /* Result codes for HeapTupleSatisfiesVacuum */ typedef enum { - HEAPTUPLE_DEAD, /* tuple is dead and deletable */ - HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */ - HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */ - HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */ - HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */ + HEAPTUPLE_DEAD, /* tuple is dead and deletable */ + HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */ + HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not + * deletable yet */ + HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still + * in progress */ + HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still + * in progress */ } HTSV_Result; extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple); @@ -104,10 +107,9 @@ extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot); extern int HeapTupleSatisfiesUpdate(HeapTuple tuple); extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, - TransactionId OldestXmin); + TransactionId OldestXmin); extern Snapshot GetSnapshotData(bool serializable); extern void SetQuerySnapshot(void); extern void FreeXactSnapshot(void); - #endif /* TQUAL_H */ diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index a2c4f87962..1113721928 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tuplesort.h,v 1.8 2001/06/02 19:01:52 tgl Exp $ + * $Id: tuplesort.h,v 1.9 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,9 +37,9 @@ typedef struct Tuplesortstate Tuplesortstate; */ extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc, - int nkeys, - Oid *sortOperators, AttrNumber *attNums, - bool randomAccess); + int nkeys, + Oid *sortOperators, AttrNumber *attNums, + bool randomAccess); extern Tuplesortstate *tuplesort_begin_index(Relation indexRel, bool enforceUnique, bool randomAccess); @@ -83,15 +83,15 @@ extern void tuplesort_restorepos(Tuplesortstate *state); */ typedef enum { - SORTFUNC_LT, /* raw "<" operator */ - SORTFUNC_REVLT, /* raw "<" operator, but reverse NULLs */ - SORTFUNC_CMP, /* -1 / 0 / 1 three-way comparator */ - SORTFUNC_REVCMP /* 1 / 0 / -1 (reversed) 3-way comparator */ + SORTFUNC_LT, /* raw "<" operator */ + SORTFUNC_REVLT, /* raw "<" operator, but reverse NULLs */ + SORTFUNC_CMP, /* -1 / 0 / 1 three-way comparator */ + SORTFUNC_REVCMP /* 1 / 0 / -1 (reversed) 3-way comparator */ } SortFunctionKind; extern void SelectSortFunction(Oid sortOperator, - RegProcedure *sortFunction, - SortFunctionKind *kind); + RegProcedure *sortFunction, + SortFunctionKind *kind); /* * Apply a sort function (by now converted to fmgr lookup form) @@ -99,7 +99,6 @@ extern void SelectSortFunction(Oid sortOperator, * NULLs and sort ordering direction properly. */ extern int32 ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, - Datum datum1, bool isNull1, - Datum datum2, bool isNull2); - + Datum datum1, bool isNull1, + Datum datum2, bool isNull2); #endif /* TUPLESORT_H */ diff --git a/src/include/utils/tuplestore.h b/src/include/utils/tuplestore.h index 3e73f8fca9..39d1746108 100644 --- a/src/include/utils/tuplestore.h +++ b/src/include/utils/tuplestore.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tuplestore.h,v 1.3 2001/03/22 04:01:15 momjian Exp $ + * $Id: tuplestore.h,v 1.4 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,5 +56,4 @@ extern void tuplestore_end(Tuplestorestate *state); extern void tuplestore_rescan(Tuplestorestate *state); extern void tuplestore_markpos(Tuplestorestate *state); extern void tuplestore_restorepos(Tuplestorestate *state); - #endif /* TUPLESTORE_H */ diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h index 35172de7be..b4fedf18a7 100644 --- a/src/include/utils/varbit.h +++ b/src/include/utils/varbit.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: varbit.h,v 1.11 2001/05/22 16:37:17 petere Exp $ + * $Id: varbit.h,v 1.12 2001/10/25 05:50:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,5 +89,4 @@ extern Datum bitoctetlength(PG_FUNCTION_ARGS); extern Datum bitfromint4(PG_FUNCTION_ARGS); extern Datum bittoint4(PG_FUNCTION_ARGS); extern Datum bitposition(PG_FUNCTION_ARGS); - #endif diff --git a/src/interfaces/cli/example1.c b/src/interfaces/cli/example1.c index 9660ce5719..75cedda3dd 100644 --- a/src/interfaces/cli/example1.c +++ b/src/interfaces/cli/example1.c @@ -40,7 +40,7 @@ int print_err(SQLSMALLINT handletype, SQLINTEGER handle); int -example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen) +example1(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen) { SQLHENV henv; SQLHDBC hdbc; @@ -135,12 +135,12 @@ example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen) /* this time, explicitly allocate an application row descriptor */ SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc); SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0, - (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) &idind); + (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) & idind); SQLSetDescRec(hdesc, 2, SQL_ CHAR, 0, (SQLINTEGER) sizeof(name), - 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) &namelen, - (SQLSMALLINT *) &nameind); + 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) & namelen, + (SQLSMALLINT *) & nameind); /* associate descriptor with statement handle */ SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0); /* execute the fetch */ diff --git a/src/interfaces/cli/example2.c b/src/interfaces/cli/example2.c index 21685ef21b..7230abc4da 100644 --- a/src/interfaces/cli/example2.c +++ b/src/interfaces/cli/example2.c @@ -39,17 +39,17 @@ #define max(a,b) (a>b?a:b) int print_err(SQLSMALLINT handletype, SQLINTEGER handle); -int build_indicator_message(SQLCHAR *errmsg, +int build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data, SQLINTEGER collen, - SQLINTEGER *outlen, + SQLINTEGER * outlen, SQLSMALLINT colnum); SQLINTEGER display_length(SQLSMALLINT coltype, SQLINTEGER collen, - SQLCHAR *colname); + SQLCHAR * colname); -example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr) +example2(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen, SQLCHAR * sqlstr) { int i; SQLHENV henv; @@ -214,13 +214,13 @@ example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr) SQLINTEGER display_length(SQLSMALLINT coltype, SQLINTEGER collen, - SQLCHAR *colname) + SQLCHAR * colname) { switch (coltype) { - case SQL_VARCHAR: - case SQL_CHAR: + case SQL_VARCHAR: + case SQL_CHAR: return (max(collen, strlen((char *) colname))); break; @@ -252,8 +252,8 @@ display_length(SQLSMALLINT coltype, SQLINTEGER collen, } int -build_indicator_message(SQLCHAR *errmsg, SQLPOINTER * data, - SQLINTEGER collen, SQLINTEGER *outlen, SQLSMALLINT colnum) +build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data, + SQLINTEGER collen, SQLINTEGER * outlen, SQLSMALLINT colnum) { if (*outlen == SQL_NULL_DATA) { diff --git a/src/interfaces/cli/sqlcli.h b/src/interfaces/cli/sqlcli.h index 2942abf12f..a9145495fc 100644 --- a/src/interfaces/cli/sqlcli.h +++ b/src/interfaces/cli/sqlcli.h @@ -473,7 +473,7 @@ SQLRETURN SQLAllocEnv(SQLHENV * EnvironmentHandle); SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, - SQLINTEGER *OutputHandle); + SQLINTEGER * OutputHandle); SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle, SQLSTMT * StatementHandle); @@ -483,7 +483,7 @@ SQLRETURN SQLBindCol(SQLHSTMT StatementHandle, SQLSMALLINT BufferType, SQLPOINTER Data, SQLINTEGER BufferLength, - SQLINTEGER *DataLength); + SQLINTEGER * DataLength); SQLRETURN SQLBindParam(SQLHSTMT StatementHandle, SQLSMALLINT ParamNumber, @@ -492,7 +492,7 @@ SQLRETURN SQLBindParam(SQLHSTMT StatementHandle, SQLINTEGER ParamLength, SQLSMALLINT Scale, SQLPOINTER Data, - SQLINTEGER *DataLength); + SQLINTEGER * DataLength); SQLRETURN SQLCancel(SQLHSTMT StatementHandle); @@ -501,17 +501,17 @@ SQLRETURN SQLCloseCursor(SQLHSTMT StatementHandle); SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, SQLSMALLINT FieldIdentifier, - SQLCHAR *CharacterAttribute, + SQLCHAR * CharacterAttribute, SQLINTEGER BufferLength, - SQLINTEGER *AttributetLength, - SQLINTEGER *NumericAttribute); + SQLINTEGER * AttributetLength, + SQLINTEGER * NumericAttribute); SQLRETURN SQLConnect(SQLHDBC ConnectionHandle, - SQLCHAR *ServerName, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, + SQLCHAR * UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, + SQLCHAR * Authentication, SQLSMALLINT NameLength3); SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle, @@ -519,22 +519,22 @@ SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle, SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle, SQLSMALLINT Direction, - SQLCHAR *ServerName, + SQLCHAR * ServerName, SQLSMALLINT BufferLength1, - SQLSMALLINT *NameLength1, - SQLCHAR *Description, + SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2); + SQLSMALLINT * NameLength2); SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, - SQLCHAR *ColumnName, + SQLCHAR * ColumnName, SQLSMALLINT BufferLength, - SQLSMALLINT *ColumnNameLength, - SQLSMALLINT *ColumnType, - SQLINTEGER *ColumnLength, - SQLSMALLINT *ColumnScale, - SQLSMALLINT *Nullable); + SQLSMALLINT * ColumnNameLength, + SQLSMALLINT * ColumnType, + SQLINTEGER * ColumnLength, + SQLSMALLINT * ColumnScale, + SQLSMALLINT * Nullable); SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle); @@ -545,14 +545,14 @@ SQLRETURN SQLEndTran(SQLSMALLINT HandleType, SQLRETURN SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, SQLSTMT StatementHandle, - SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, - SQLCHAR *MessageText, + SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLINTEGER BufferLength, - SQLINTEGER *TextLength); + SQLINTEGER * TextLength); SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle, - SQLCHAR *StatementText, + SQLCHAR * StatementText, SQLSMALLINT StringLength); SQLRETURN SQLExecute(SQLHSTMT StatementHandle); @@ -576,38 +576,38 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle, - SQLCHAR *CursorName, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength); + SQLSMALLINT * NameLength); SQLRETURN SQLGetData(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLPOINTER TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *IndicatorValue); + SQLINTEGER * IndicatorValue); SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecordNumber, SQLSMALLINT FieldIdentifier, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecordNumber, - SQLCHAR *Name, + SQLCHAR * Name, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength, - SQLSMALLINT *Type, - SQLSMALLINT *SubType, - SQLINTEGER *Length, - SQLSMALLINT *Precision, - SQLSMALLINT *Scale, - SQLSMALLINT *Nullable); + SQLSMALLINT * StringLength, + SQLSMALLINT * Type, + SQLSMALLINT * SubType, + SQLINTEGER * Length, + SQLSMALLINT * Precision, + SQLSMALLINT * Scale, + SQLSMALLINT * Nullable); SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType, SQLINTEGER Handle, @@ -615,51 +615,51 @@ SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType, SQLSMALLINT DiagIdentifier, SQLPOINTER DiagInfo, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType, SQLINTEGER Handle, SQLSMALLINT RecordNumber, - SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, - SQLCHAR *MessageText, + SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle, SQLSMALLINT FunctionId, - SQLSMALLINT *Supported); + SQLSMALLINT * Supported); SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle, SQLSMALLINT InfoType, SQLPOINTER InfoValue, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType); SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle, - SQLINTEGER *ColumnCount); + SQLINTEGER * ColumnCount); SQLRETURN SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER * Value); SQLRETURN SQLPrepare(SQLHSTMT StatementHandle, - SQLCHAR *StatementText, + SQLCHAR * StatementText, SQLSMALLINT StringLength); @@ -668,7 +668,7 @@ SQLRETURN SQLPutData(SQLHSTMT StatementHandle, SQLINTEGER StringLength); SQLRETURN SQLRowCount(SQLHSTMT StatementHandle, - SQLINTEGER *RowCount); + SQLINTEGER * RowCount); SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER AttributeCursorName, @@ -676,7 +676,7 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER StringLength); SQLRETURN SQLSetCursorName(SQLHSTMT StatementHandle, - SQLCHAR *CursorName, + SQLCHAR * CursorName, SQLSMALLINT NameLength); SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle, @@ -692,8 +692,8 @@ SQLRETURN SQLSetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT Precision, SQLSMALLINT Scale, SQLPOINTER Data, - SQLINTEGER *StringLength, - SQLSMALLINT *Indicator); + SQLINTEGER * StringLength, + SQLSMALLINT * Indicator); SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h index 49e6269d8a..81d67277fe 100644 --- a/src/interfaces/ecpg/include/ecpgerrno.h +++ b/src/interfaces/ecpg/include/ecpgerrno.h @@ -61,5 +61,4 @@ #define ECPG_NOTICE_NO_TRANSACTION -604 /* NOTICE: BlankPortalAssignName: portal * already exists */ #define ECPG_NOTICE_PORTAL_EXISTS -605 - #endif /* !_ECPG_ERROR_H */ diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index acb022aa1b..732e70f3ce 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -70,5 +70,4 @@ extern "C" #ifdef __cplusplus } - #endif diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h index 3e6875cf1d..c2e698b84f 100644 --- a/src/interfaces/ecpg/include/ecpgtype.h +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -47,7 +47,7 @@ extern "C" ECPGt_EORT, /* End of result types. */ ECPGt_NO_INDICATOR, /* no indicator */ ECPGt_long_long, ECPGt_unsigned_long_long, - ECPGt_descriptor /* sql descriptor, no C variable */ + ECPGt_descriptor /* sql descriptor, no C variable */ }; /* descriptor items */ @@ -76,5 +76,4 @@ extern "C" #ifdef __cplusplus } - #endif diff --git a/src/interfaces/ecpg/include/sql3types.h b/src/interfaces/ecpg/include/sql3types.h index 17fe493c11..02305dd54a 100644 --- a/src/interfaces/ecpg/include/sql3types.h +++ b/src/interfaces/ecpg/include/sql3types.h @@ -2,29 +2,29 @@ * * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.5 2001/09/19 14:09:32 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.6 2001/10/25 05:50:11 momjian Exp $ */ /* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */ enum { - SQL3_CHARACTER = 1, - SQL3_NUMERIC, - SQL3_DECIMAL, - SQL3_INTEGER, - SQL3_SMALLINT, - SQL3_FLOAT, - SQL3_REAL, - SQL3_DOUBLE_PRECISION, - SQL3_DATE_TIME_TIMESTAMP, - SQL3_INTERVAL, /* 10 */ - SQL3_CHARACTER_VARYING = 12, - SQL3_ENUMERATED, - SQL3_BIT, - SQL3_BIT_VARYING, - SQL3_BOOLEAN, - SQL3_abstract + SQL3_CHARACTER = 1, + SQL3_NUMERIC, + SQL3_DECIMAL, + SQL3_INTEGER, + SQL3_SMALLINT, + SQL3_FLOAT, + SQL3_REAL, + SQL3_DOUBLE_PRECISION, + SQL3_DATE_TIME_TIMESTAMP, + SQL3_INTERVAL, /* 10 */ + SQL3_CHARACTER_VARYING = 12, + SQL3_ENUMERATED, + SQL3_BIT, + SQL3_BIT_VARYING, + SQL3_BOOLEAN, + SQL3_abstract /* the rest is xLOB stuff */ }; @@ -32,12 +32,12 @@ enum enum { - SQL3_DDT_DATE = 1, - SQL3_DDT_TIME, - SQL3_DDT_TIMESTAMP, - SQL3_DDT_TIME_WITH_TIME_ZONE, - SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE, + SQL3_DDT_DATE = 1, + SQL3_DDT_TIME, + SQL3_DDT_TIMESTAMP, + SQL3_DDT_TIME_WITH_TIME_ZONE, + SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE, - SQL3_DDT_ILLEGAL /* not a datetime data type (not part of + SQL3_DDT_ILLEGAL/* not a datetime data type (not part of * standard) */ }; diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h index 3f7e307da7..28ab20533d 100644 --- a/src/interfaces/ecpg/include/sqlca.h +++ b/src/interfaces/ecpg/include/sqlca.h @@ -6,8 +6,8 @@ #define DLLIMPORT __declspec (dllimport) #else #define DLLIMPORT -#endif /* __CYGWIN__ */ -#endif /* DLLIMPORT */ +#endif /* __CYGWIN__ */ +#endif /* DLLIMPORT */ #define SQLERRMC_LEN 70 @@ -44,7 +44,7 @@ extern "C" /* * 2: if 'W' a (hopefully) non-fatal notice occured - *//* 3: empty */ +*//* 3: empty */ /* 4: empty */ /* 5: empty */ /* 6: empty */ @@ -58,7 +58,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif diff --git a/src/interfaces/ecpg/lib/connect.c b/src/interfaces/ecpg/lib/connect.c index 9da651a020..239c766d7c 100644 --- a/src/interfaces/ecpg/lib/connect.c +++ b/src/interfaces/ecpg/lib/connect.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.12 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.13 2001/10/25 05:50:11 momjian Exp $ */ #include "postgres_fe.h" @@ -313,7 +313,7 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, /*------ * new style: - * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] + * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] * [/db name][?options] *------ */ diff --git a/src/interfaces/ecpg/lib/descriptor.c b/src/interfaces/ecpg/lib/descriptor.c index ba11f5af5e..af30723266 100644 --- a/src/interfaces/ecpg/lib/descriptor.c +++ b/src/interfaces/ecpg/lib/descriptor.c @@ -1,6 +1,6 @@ /* dynamic SQL support routines * - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.16 2001/09/19 14:09:32 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.17 2001/10/25 05:50:11 momjian Exp $ */ #include "postgres_fe.h" @@ -18,8 +18,10 @@ static PGresult * ECPGresultByDescriptor(int line, const char *name) { - PGresult **resultpp = ECPGdescriptor_lvalue ( line, name ); - if (resultpp) return *resultpp; + PGresult **resultpp = ECPGdescriptor_lvalue(line, name); + + if (resultpp) + return *resultpp; return NULL; } @@ -28,7 +30,8 @@ ECPGDynamicType_DDT(Oid type) { switch (type) { - case 1082:return SQL3_DDT_DATE; /* date */ + case 1082: + return SQL3_DDT_DATE; /* date */ case 1083: return SQL3_DDT_TIME; /* time */ case 1184: @@ -103,8 +106,8 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va { switch (vartype) { - case ECPGt_char: - case ECPGt_unsigned_char: + case ECPGt_char: + case ECPGt_unsigned_char: strncpy((char *) var, value, varcharsize); break; case ECPGt_varchar: @@ -136,9 +139,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) va_list args; PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name); enum ECPGdtype type; - bool Indicator_seen = false, - Data_seen = false; - int ntuples, act_tuple; + bool Indicator_seen = false, + Data_seen = false; + int ntuples, + act_tuple; va_start(args, index); if (!ECPGresult) @@ -180,21 +184,24 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) switch (type) { case (ECPGd_indicator): - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } Indicator_seen = true; - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index))) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index))) return (false); - var = (char*)var + offset; + var = (char *) var + offset; ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index)); } break; @@ -234,20 +241,23 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) case ECPGd_ret_length: case ECPGd_ret_octet: - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index))) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index))) return (false); - var = (char*)var + offset; + var = (char *) var + offset; ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index)); } break; @@ -280,27 +290,30 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index))); break; case ECPGd_data: - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } Data_seen = true; - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (PQgetisnull(ECPGresult, act_tuple, index)) - continue; /* do not touch data on null value */ - if (!get_data(ECPGresult, act_tuple, index, lineno, - vartype, ECPGt_NO_INDICATOR, var, NULL, - varcharsize, offset, false)) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (PQgetisnull(ECPGresult, act_tuple, index)) + continue; /* do not touch data on null value */ + if (!get_data(ECPGresult, act_tuple, index, lineno, + vartype, ECPGt_NO_INDICATOR, var, NULL, + varcharsize, offset, false)) return (false); } break; - + case ECPGd_cardinality: if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult))) return (false); @@ -318,9 +331,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) } if (Data_seen && !Indicator_seen) - { - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (PQgetisnull(ECPGresult, act_tuple, index)) + { + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (PQgetisnull(ECPGresult, act_tuple, index)) { ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL); return (false); @@ -365,14 +379,14 @@ ECPGallocate_desc(int line, const char *name) return true; } -PGresult ** +PGresult ** ECPGdescriptor_lvalue(int line, const char *descriptor) { struct descriptor *i; for (i = all_descriptors; i != NULL; i = i->next) { - if (!strcmp(descriptor, i->name)) + if (!strcmp(descriptor, i->name)) return &i->result; } diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c index 099b4cff27..e9454ec215 100644 --- a/src/interfaces/ecpg/lib/execute.c +++ b/src/interfaces/ecpg/lib/execute.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.28 2001/10/05 17:37:07 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.29 2001/10/25 05:50:11 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -30,14 +30,29 @@ /* variables visible to the programs */ struct sqlca sqlca = { - {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, - sizeof(struct sqlca), - 0, - {0, {0}}, - {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, - {0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0} + { + 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' ' + } , + sizeof(struct sqlca), + 0, + { + 0, + { + 0 + } + }, + { + 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' ' + }, + { + 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + } }; struct variable @@ -288,7 +303,6 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia if ((stmt->connection->cache_head) == NULL) { - /* * Text like types are not an array for ecpg, but postgres counts * them as an array. This define reminds you to not 'correct' @@ -356,7 +370,6 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia if (ECPGDynamicType(type) == SQL3_CHARACTER || ECPGDynamicType(type) == SQL3_CHARACTER_VARYING) { - /* * arrays of character strings are not yet implemented */ @@ -371,443 +384,439 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia bool -ECPGstore_result(const PGresult *results, int act_field, - const struct statement * stmt, struct variable *var) -{ int isarray, - act_tuple, - ntuples = PQntuples(results); - bool status = true; - - isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var); - - if (!isarray) - { +ECPGstore_result(const PGresult *results, int act_field, + const struct statement * stmt, struct variable * var) +{ + int isarray, + act_tuple, + ntuples = PQntuples(results); + bool status = true; - /* - * if we don't have enough space, we cannot read - * all tuples - */ - if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize)) - { - ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n", - stmt->lineno, ntuples, var->arrsize); - ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL); - return false; - } - } - else - { + isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var); - /* - * since we read an array, the variable has to be - * an array too - */ - if (var->arrsize == 0) - { - ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL); - return false; - } - } + if (!isarray) + { + /* + * if we don't have enough space, we cannot read all tuples + */ + if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize)) + { + ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n", + stmt->lineno, ntuples, var->arrsize); + ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL); + return false; + } + } + else + { + /* + * since we read an array, the variable has to be an array too + */ + if (var->arrsize == 0) + { + ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL); + return false; + } + } - /* - * allocate memory for NULL pointers - */ - if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL) - { - int len = 0; + /* + * allocate memory for NULL pointers + */ + if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL) + { + int len = 0; - switch (var->type) - { - case ECPGt_char: - case ECPGt_unsigned_char: - var->varcharsize = 0; - /* check strlen for each tuple */ - for (act_tuple = 0; act_tuple < ntuples; act_tuple++) - { - int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; - - if (len > var->varcharsize) - var->varcharsize = len; - } - var->offset *= var->varcharsize; - len = var->offset * ntuples; - break; - case ECPGt_varchar: - len = ntuples * (var->varcharsize + sizeof(int)); - break; - default: - len = var->offset * ntuples; - break; - } - var->value = (void *) ecpg_alloc(len, stmt->lineno); - *((void **) var->pointer) = var->value; - add_mem(var->value, stmt->lineno); - } + switch (var->type) + { + case ECPGt_char: + case ECPGt_unsigned_char: + var->varcharsize = 0; + /* check strlen for each tuple */ + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; - for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++) - { - if (!get_data(results, act_tuple, act_field, stmt->lineno, - var->type, var->ind_type, var->value, - var->ind_value, var->varcharsize, var->offset, isarray)) - status = false; - } + if (len > var->varcharsize) + var->varcharsize = len; + } + var->offset *= var->varcharsize; + len = var->offset * ntuples; + break; + case ECPGt_varchar: + len = ntuples * (var->varcharsize + sizeof(int)); + break; + default: + len = var->offset * ntuples; + break; + } + var->value = (void *) ecpg_alloc(len, stmt->lineno); + *((void **) var->pointer) = var->value; + add_mem(var->value, stmt->lineno); + } + + for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++) + { + if (!get_data(results, act_tuple, act_field, stmt->lineno, + var->type, var->ind_type, var->value, + var->ind_value, var->varcharsize, var->offset, isarray)) + status = false; + } return status; } static bool -ECPGstore_input(const struct statement * stmt, const struct variable *var, - const char **tobeinserted_p, bool *malloced_p) +ECPGstore_input(const struct statement * stmt, const struct variable * var, + const char **tobeinserted_p, bool *malloced_p) { - char *mallocedval = NULL; - char *newcopy = NULL; + char *mallocedval = NULL; + char *newcopy = NULL; - /* - * Some special treatment is needed for records since we want - * their contents to arrive in a comma-separated list on insert (I - * think). - */ - - *malloced_p=false; - *tobeinserted_p=""; + /* + * Some special treatment is needed for records since we want their + * contents to arrive in a comma-separated list on insert (I think). + */ - /* check for null value and set input buffer accordingly */ - switch (var->ind_type) - { - case ECPGt_short: - case ECPGt_unsigned_short: - if (*(short *) var->ind_value < 0) - *tobeinserted_p="null"; - break; - case ECPGt_int: - case ECPGt_unsigned_int: - if (*(int *) var->ind_value < 0) - *tobeinserted_p="null"; - break; - case ECPGt_long: - case ECPGt_unsigned_long: - if (*(long *) var->ind_value < 0L) - *tobeinserted_p="null"; - break; + *malloced_p = false; + *tobeinserted_p = ""; + + /* check for null value and set input buffer accordingly */ + switch (var->ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + if (*(short *) var->ind_value < 0) + *tobeinserted_p = "null"; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + if (*(int *) var->ind_value < 0) + *tobeinserted_p = "null"; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + if (*(long *) var->ind_value < 0L) + *tobeinserted_p = "null"; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - case ECPGt_unsigned_long_long: - if (*(long long int *) var->ind_value < (long long) 0) - *tobeinserted_p="null"; - break; + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + if (*(long long int *) var->ind_value < (long long) 0) + *tobeinserted_p = "null"; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - default: - break; - } + default: + break; + } - if (**tobeinserted_p == '\0') + if (**tobeinserted_p == '\0') + { + switch (var->type) { - switch (var->type) - { - int element; + int element; - case ECPGt_short: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_short: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%hd", *((short *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%hd", *((short *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_int: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_int: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%d", *((int *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%d", *((int *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_short: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_short: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%hu", *((unsigned short *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%hu", *((unsigned short *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_int: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_int: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%u", *((unsigned int *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%u", *((unsigned int *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%ld", *((long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%ld", *((long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%lu", *((unsigned long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%lu", *((unsigned long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) - return false; + case ECPGt_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%lld", *((long long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%lld", *((long long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_long_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) - return false; + case ECPGt_unsigned_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%llu", *((unsigned long long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%llu", *((unsigned long long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - case ECPGt_float: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_float: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%.14g", *((float *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%.14g", *((float *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_double: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_double: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%.14g", *((double *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%.14g", *((double *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_bool: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_bool: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); - - if (var->offset == sizeof(char)) - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f'); - - /* - * this is necessary since sizeof(C++'s - * bool)==sizeof(int) - */ - else if (var->offset == sizeof(int)) - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f'); - else - ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); + + if (var->offset == sizeof(char)) + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f'); + + /* + * this is necessary since sizeof(C++'s + * bool)==sizeof(int) + */ + else if (var->offset == sizeof(int)) + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f'); else - { - if (var->offset == sizeof(char)) - sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f'); - else if (var->offset == sizeof(int)) - sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f'); - else - ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - } + ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + { + if (var->offset == sizeof(char)) + sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f'); + else if (var->offset == sizeof(int)) + sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f'); + else + ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); + } - case ECPGt_char: - case ECPGt_unsigned_char: - { - /* set slen to string length if type is char * */ - int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; + + case ECPGt_char: + case ECPGt_unsigned_char: + { + /* set slen to string length if type is char * */ + int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize; - if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno))) - return false; + if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno))) + return false; - strncpy(newcopy, (char *) var->value, slen); - newcopy[slen] = '\0'; + strncpy(newcopy, (char *) var->value, slen); + newcopy[slen] = '\0'; - mallocedval = quote_postgres(newcopy, stmt->lineno); - if (!mallocedval) - return false; + mallocedval = quote_postgres(newcopy, stmt->lineno); + if (!mallocedval) + return false; - free(newcopy); + free(newcopy); - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; - case ECPGt_char_variable: - { - int slen = strlen((char *) var->value); + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; + case ECPGt_char_variable: + { + int slen = strlen((char *) var->value); - if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno))) - return false; + if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno))) + return false; - strncpy(mallocedval, (char *) var->value, slen); - mallocedval[slen] = '\0'; + strncpy(mallocedval, (char *) var->value, slen); + mallocedval[slen] = '\0'; - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; - case ECPGt_varchar: - { - struct ECPGgeneric_varchar *variable = - (struct ECPGgeneric_varchar *) (var->value); + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; + case ECPGt_varchar: + { + struct ECPGgeneric_varchar *variable = + (struct ECPGgeneric_varchar *) (var->value); - if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno))) - return false; + if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno))) + return false; - strncpy(newcopy, variable->arr, variable->len); - newcopy[variable->len] = '\0'; + strncpy(newcopy, variable->arr, variable->len); + newcopy[variable->len] = '\0'; - mallocedval = quote_postgres(newcopy, stmt->lineno); - if (!mallocedval) - return false; + mallocedval = quote_postgres(newcopy, stmt->lineno); + if (!mallocedval) + return false; - free(newcopy); + free(newcopy); - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; - default: - /* Not implemented yet */ - ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type)); - return false; - break; - } + default: + /* Not implemented yet */ + ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type)); + return false; + break; } + } return true; } @@ -831,15 +840,15 @@ ECPGexecute(struct statement * stmt) var = stmt->inlist; while (var) { - char *newcopy = NULL; + char *newcopy = NULL; const char *tobeinserted = NULL; char *p; - bool malloced=FALSE; - int hostvarl = 0; + bool malloced = FALSE; + int hostvarl = 0; if (!ECPGstore_input(stmt, var, &tobeinserted, &malloced)) return false; - + /* * Now tobeinserted points to an area that is to be inserted at * the first %s @@ -850,7 +859,6 @@ ECPGexecute(struct statement * stmt) strcpy(newcopy, copiedquery); if ((p = next_insert(newcopy + hostvarl)) == NULL) { - /* * We have an argument but we dont have the matched up string * in the string @@ -880,7 +888,7 @@ ECPGexecute(struct statement * stmt) */ if (malloced) { - free((char*)tobeinserted); + free((char *) tobeinserted); tobeinserted = NULL; } @@ -921,11 +929,14 @@ ECPGexecute(struct statement * stmt) ECPGraise(stmt->lineno, ECPG_PGSQL, PQerrorMessage(stmt->connection->connection)); } else - /* note: since some of the following code is duplicated in descriptor.c - * it should go into a separate function - */ + + /* + * note: since some of the following code is duplicated in + * descriptor.c it should go into a separate function + */ { - bool clear_result = TRUE; + bool clear_result = TRUE; + var = stmt->outlist; switch (PQresultStatus(results)) { @@ -940,37 +951,43 @@ ECPGexecute(struct statement * stmt) if (ntuples < 1) { - if (ntuples) ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n", - stmt->lineno, ntuples); + if (ntuples) + ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n", + stmt->lineno, ntuples); ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL); status = false; break; } - if (var != NULL && var->type==ECPGt_descriptor) - { PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char*)var->pointer); - if (resultpp == NULL) status = false; + if (var != NULL && var->type == ECPGt_descriptor) + { + PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char *) var->pointer); + + if (resultpp == NULL) + status = false; else - { if (*resultpp) - PQclear(*resultpp); - *resultpp=results; + { + if (*resultpp) + PQclear(*resultpp); + *resultpp = results; clear_result = FALSE; - ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char*)var->pointer); + ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char *) var->pointer); } var = var->next; } - else for (act_field = 0; act_field < nfields && status; act_field++) - { - if (var == NULL) + else + for (act_field = 0; act_field < nfields && status; act_field++) { - ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL); - return (false); - } - - status = ECPGstore_result(results, act_field, stmt, var); + if (var == NULL) + { + ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL); + return (false); + } - var = var->next; - } + status = ECPGstore_result(results, act_field, stmt, var); + + var = var->next; + } if (status && var != NULL) { @@ -1016,7 +1033,8 @@ ECPGexecute(struct statement * stmt) status = false; break; } - if (clear_result) PQclear(results); + if (clear_result) + PQclear(results); } /* check for asynchronous returns */ @@ -1038,7 +1056,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) struct statement *stmt; struct connection *con = get_connection(connection_name); bool status; - char *oldlocale; + char *oldlocale; /* Make sure we do NOT honor the locale for numeric input/output */ /* since the database wants the standard decimal point */ @@ -1081,12 +1099,12 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) return (status); } -/* old descriptor interface */ +/* old descriptor interface */ bool ECPGdo_descriptor(int line, const char *connection, const char *descriptor, const char *query) { - return ECPGdo(line, connection, (char *)query, ECPGt_EOIT, - ECPGt_descriptor, descriptor, 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + return ECPGdo(line, connection, (char *) query, ECPGt_EOIT, + ECPGt_descriptor, descriptor, 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); } diff --git a/src/interfaces/ecpg/lib/extern.h b/src/interfaces/ecpg/lib/extern.h index 971924e708..8e7ba566a3 100644 --- a/src/interfaces/ecpg/lib/extern.h +++ b/src/interfaces/ecpg/lib/extern.h @@ -62,9 +62,8 @@ struct descriptor struct descriptor *next; }; -PGresult ** -ECPGdescriptor_lvalue(int line, const char *descriptor); +PGresult ** + ECPGdescriptor_lvalue(int line, const char *descriptor); -bool -ECPGstore_result(const PGresult *results, int act_field, - const struct statement * stmt, struct variable *var); +bool ECPGstore_result(const PGresult *results, int act_field, + const struct statement * stmt, struct variable * var); diff --git a/src/interfaces/ecpg/lib/misc.c b/src/interfaces/ecpg/lib/misc.c index b5dd56e3cf..a37cd7ceb6 100644 --- a/src/interfaces/ecpg/lib/misc.c +++ b/src/interfaces/ecpg/lib/misc.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.7 2001/10/25 05:50:12 momjian Exp $ */ #include "postgres_fe.h" @@ -11,14 +11,29 @@ static struct sqlca sqlca_init = { - {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, - sizeof(struct sqlca), - 0, - {0, {0}}, - {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, - {0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0} + { + 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' ' + } , + sizeof(struct sqlca), + 0, + { + 0, + { + 0 + } + }, + { + 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' ' + }, + { + 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + } }; static int simple_debug = 0; diff --git a/src/interfaces/ecpg/lib/pg_type.h b/src/interfaces/ecpg/lib/pg_type.h index a9ffbfb627..5961dc23c6 100644 --- a/src/interfaces/ecpg/lib/pg_type.h +++ b/src/interfaces/ecpg/lib/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.2 2001/01/24 19:43:29 momjian Exp $ + * $Id: pg_type.h,v 1.3 2001/10/25 05:50:12 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -68,5 +68,4 @@ #define ZPBITOID 1560 #define VARBITOID 1562 #define NUMERICOID 1700 - #endif /* PG_TYPE_H */ diff --git a/src/interfaces/ecpg/lib/typename.c b/src/interfaces/ecpg/lib/typename.c index 345a5f36f1..48747e2c71 100644 --- a/src/interfaces/ecpg/lib/typename.c +++ b/src/interfaces/ecpg/lib/typename.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.19 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.20 2001/10/25 05:50:12 momjian Exp $ */ #include "postgres_fe.h" @@ -17,7 +17,7 @@ ECPGtype_name(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return "char"; case ECPGt_unsigned_char: return "unsigned char"; @@ -58,11 +58,12 @@ ECPGDynamicType(Oid type) { switch (type) { - case BOOLOID:return SQL3_BOOLEAN; /* bool */ + case BOOLOID: + return SQL3_BOOLEAN; /* bool */ case INT2OID: return SQL3_SMALLINT; /* int2 */ case INT4OID: - return SQL3_INTEGER;/* int4 */ + return SQL3_INTEGER; /* int4 */ case TEXTOID: return SQL3_CHARACTER; /* text */ case FLOAT4OID: @@ -80,7 +81,7 @@ ECPGDynamicType(Oid type) case TIMESTAMPOID: return SQL3_DATE_TIME_TIMESTAMP; /* datetime */ case NUMERICOID: - return SQL3_NUMERIC;/* numeric */ + return SQL3_NUMERIC; /* numeric */ default: return -type; } diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c index 6542888dd7..372a0c362d 100644 --- a/src/interfaces/ecpg/preproc/descriptor.c +++ b/src/interfaces/ecpg/preproc/descriptor.c @@ -75,9 +75,10 @@ void add_descriptor(char *name, char *connection) { struct descriptor *new; - - if (name[0]!='"') return; - + + if (name[0] != '"') + return; + new = (struct descriptor *) mm_alloc(sizeof(struct descriptor)); new->next = descriptors; @@ -99,7 +100,8 @@ drop_descriptor(char *name, char *connection) struct descriptor *i; struct descriptor **lastptr = &descriptors; - if (name[0]!='"') return; + if (name[0] != '"') + return; for (i = descriptors; i; lastptr = &i->next, i = i->next) { @@ -128,7 +130,8 @@ lookup_descriptor(char *name, char *connection) { struct descriptor *i; - if (name[0]!='"') return NULL; + if (name[0] != '"') + return NULL; for (i = descriptors; i; i = i->next) { @@ -199,21 +202,23 @@ output_get_descr(char *desc_name, char *index) /* I consider dynamic allocation overkill since at most two descriptor variables are possible per statement. (input and output descriptor) - And descriptors are no normal variables, so they don't belong into + And descriptors are no normal variables, so they don't belong into the variable list. */ - + #define MAX_DESCRIPTOR_NAMELEN 128 -struct variable *descriptor_variable(const char *name,int input) -{ static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN]; +struct variable * +descriptor_variable(const char *name, int input) +{ + static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN]; static const struct ECPGtype descriptor_type = - { ECPGt_descriptor, 0 }; + {ECPGt_descriptor, 0}; static const struct variable varspace[2] = - {{ descriptor_names[0], (struct ECPGtype*)&descriptor_type, 0, NULL }, - { descriptor_names[1], (struct ECPGtype*)&descriptor_type, 0, NULL } + {{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL}, + {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL} }; - - strncpy(descriptor_names[input],name,MAX_DESCRIPTOR_NAMELEN); - descriptor_names[input][MAX_DESCRIPTOR_NAMELEN-1]=0; - return (struct variable*)&varspace[input]; + + strncpy(descriptor_names[input], name, MAX_DESCRIPTOR_NAMELEN); + descriptor_names[input][MAX_DESCRIPTOR_NAMELEN - 1] = 0; + return (struct variable *) & varspace[input]; } diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 4897f77393..7b6f33e794 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.49 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.50 2001/10/25 05:50:12 momjian Exp $ */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ @@ -32,7 +32,7 @@ help(const char *progname) /* printf is a macro some places; don't #ifdef inside its arguments */ #ifdef YYDEBUG printf("Usage:\n" - " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", + " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", progname); #else printf("Usage:\n" @@ -47,7 +47,7 @@ help(const char *progname) printf(" -o OUTFILE write result to OUTFILE\n"); printf(" -t turn on autocommit of transactions\n"); printf("\nIf no output file is specified, the name is formed by adding .c\n" - "to the input file name, after stripping off .pgc if present.\n"); + "to the input file name, after stripping off .pgc if present.\n"); printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"); } @@ -90,12 +90,12 @@ main(int argc, char *const argv[]) if (argc > 1) { - if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0) + if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { help(progname); exit(0); } - else if (strcmp(argv[1], "--version")==0) + else if (strcmp(argv[1], "--version") == 0) { printf("ecpg (PostgreSQL %s) %d.%d.%d\n", PG_VERSION, MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h index b393fd3ad7..43f99c9cc7 100644 --- a/src/interfaces/ecpg/preproc/extern.h +++ b/src/interfaces/ecpg/preproc/extern.h @@ -22,7 +22,6 @@ extern char *yytext, #ifdef YYDEBUG extern int yydebug; - #endif extern int yylineno, yyleng; @@ -67,7 +66,7 @@ extern void whenever_action(int); extern void add_descriptor(char *, char *); extern void drop_descriptor(char *, char *); extern struct descriptor *lookup_descriptor(char *, char *); -extern struct variable *descriptor_variable(const char *name,int input); +extern struct variable *descriptor_variable(const char *name, int input); extern void add_variable(struct arguments **, struct variable *, struct variable *); extern void append_variable(struct arguments **, struct variable *, struct variable *); extern void dump_variables(struct arguments *, int); diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c index 690ed861a3..7e626b1971 100644 --- a/src/interfaces/ecpg/preproc/output.c +++ b/src/interfaces/ecpg/preproc/output.c @@ -39,7 +39,8 @@ print_action(struct when * w) { switch (w->code) { - case W_SQLPRINT:fprintf(yyout, "sqlprint();"); + case W_SQLPRINT: + fprintf(yyout, "sqlprint();"); break; case W_GOTO: fprintf(yyout, "goto %s;", w->command); diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index be688ab63e..7efca2c376 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -121,7 +121,7 @@ get_type(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return ("ECPGt_char"); break; case ECPGt_unsigned_char: @@ -212,10 +212,10 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in switch (typ->typ) { - case ECPGt_array: + case ECPGt_array: switch (typ->u.element->typ) { - case ECPGt_array: + case ECPGt_array: yyerror("No nested arrays allowed (except strings)"); /* array of array */ break; case ECPGt_struct: @@ -351,7 +351,6 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ, static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, struct ECPGtype * typ, struct ECPGtype * ind_typ, const char *offsetarg, const char *prefix, const char *ind_prefix) { - /* * If offset is NULL, then this is the first recursive level. If not * then we are in a struct in a struct and the offset is used as @@ -409,10 +408,10 @@ ECPGfree_type(struct ECPGtype * typ) { switch (typ->typ) { - case ECPGt_array: + case ECPGt_array: switch (typ->u.element->typ) { - case ECPGt_array: + case ECPGt_array: yyerror("internal error, found multi-dimensional array\n"); break; case ECPGt_struct: @@ -446,7 +445,7 @@ get_dtype(enum ECPGdtype typ) { switch (typ) { - case ECPGd_count: + case ECPGd_count: return ("ECPGd_countr"); break; case ECPGd_data: diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h index 12e45ab43a..a44cbec1ca 100644 --- a/src/interfaces/ecpg/preproc/type.h +++ b/src/interfaces/ecpg/preproc/type.h @@ -60,13 +60,13 @@ extern const char *ECPGtype_name(enum ECPGttype typ); /* some stuff for whenever statements */ enum WHEN_TYPE { - W_NOTHING, - W_CONTINUE, - W_BREAK, - W_SQLPRINT, - W_GOTO, - W_DO, - W_STOP + W_NOTHING, + W_CONTINUE, + W_BREAK, + W_SQLPRINT, + W_GOTO, + W_DO, + W_STOP }; struct when @@ -155,7 +155,7 @@ struct assignment enum errortype { - ET_NOTICE, ET_ERROR, ET_FATAL + ET_NOTICE, ET_ERROR, ET_FATAL }; struct fetch_desc diff --git a/src/interfaces/libpgeasy/libpgeasy.c b/src/interfaces/libpgeasy/libpgeasy.c index f8682c2761..0f049d6262 100644 --- a/src/interfaces/libpgeasy/libpgeasy.c +++ b/src/interfaces/libpgeasy/libpgeasy.c @@ -70,7 +70,7 @@ disconnectdb() ** doquery - returns PGresult structure ** */ -PGresult * +PGresult * doquery(char *query) { if (res != NULL && @@ -206,7 +206,7 @@ on_error_continue() ** get_result ** */ -PGresult * +PGresult * get_result() { char *cmdstatus = PQcmdStatus(res); diff --git a/src/interfaces/libpgtcl/libpgtcl.h b/src/interfaces/libpgtcl/libpgtcl.h index 2f9b49086f..7d225d03e8 100644 --- a/src/interfaces/libpgtcl/libpgtcl.h +++ b/src/interfaces/libpgtcl/libpgtcl.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpgtcl.h,v 1.11 2001/01/24 19:43:29 momjian Exp $ + * $Id: libpgtcl.h,v 1.12 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ extern int Pgtcl_Init(Tcl_Interp *interp); extern int Pgtcl_SafeInit(Tcl_Interp *interp); - #endif /* LIBPGTCL_H */ diff --git a/src/interfaces/libpgtcl/pgtcl.c b/src/interfaces/libpgtcl/pgtcl.c index 10f2ab0396..32e775f5d9 100644 --- a/src/interfaces/libpgtcl/pgtcl.c +++ b/src/interfaces/libpgtcl/pgtcl.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.23 2001/09/17 00:42:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.24 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ int Pgtcl_Init(Tcl_Interp *interp) { - double tclversion; + double tclversion; /* * finish off the ChannelType struct. Much easier to do it here then @@ -41,8 +41,9 @@ Pgtcl_Init(Tcl_Interp *interp) #endif /* - * Tcl versions >= 8.1 use UTF-8 for their internal string representation. - * Therefore PGCLIENTENCODING must be set to UNICODE for these versions. + * Tcl versions >= 8.1 use UTF-8 for their internal string + * representation. Therefore PGCLIENTENCODING must be set to UNICODE + * for these versions. */ Tcl_GetDouble(interp, Tcl_GetVar(interp, "tcl_version", TCL_GLOBAL_ONLY), &tclversion); if (tclversion >= 8.1) diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c index 8fef8732fd..f3b4cf95f5 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.c +++ b/src/interfaces/libpgtcl/pgtclCmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.57 2001/09/06 02:54:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.58 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -209,7 +209,6 @@ tcl_value(char *value) { if (*p == '\\') { - /* * escape sequence, translate it */ @@ -224,7 +223,6 @@ tcl_value(char *value) #endif return value; } - #endif /* TCL_ARRAYS */ @@ -310,7 +308,6 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (!strcmp("-conninfo", argv[1])) { - /* * Establish a connection using the new PQconnectdb() interface */ @@ -324,7 +321,6 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) } else { - /* * Establish a connection using the old PQsetdb() interface */ @@ -661,7 +657,6 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) #else PQgetvalue(result, tupno, 0); - #endif char *workspace = malloc(strlen(field0) + strlen(appendstr) + 210); @@ -830,7 +825,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (strcmp(argv[i], "-array") == 0) { - /* * The rows should appear in an array vs. to single variables */ @@ -846,7 +840,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (strcmp(argv[i], "-oid") == 0) { - /* * We should place PQoidValue() somewhere */ @@ -955,7 +948,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) */ if (i == argc) { - /* * We don't have a loop body. If we have at least one result row, * we set all the variables to the first one and return. @@ -1272,7 +1264,6 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) return TCL_OK; } - #endif /*********************************** @@ -1365,7 +1356,6 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) sprintf(interp->result, "%d", nbytes); return TCL_OK; } - #endif /*********************************** @@ -1893,7 +1883,6 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (callback) { - /* * Create or update a callback for a relation */ @@ -1937,7 +1926,6 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) } else { - /* * Remove a callback for a relation */ diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h index 6b40ea63c6..8f90af5aa9 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.h +++ b/src/interfaces/libpgtcl/pgtclCmds.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclCmds.h,v 1.22 2001/09/06 02:54:56 momjian Exp $ + * $Id: pgtclCmds.h,v 1.23 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,12 +62,13 @@ typedef struct Pg_ConnectionId_s int res_copyStatus; /* Copying status */ PGresult **results; /* The results */ - Pg_TclNotifies *notify_list;/* head of list of notify info */ + Pg_TclNotifies *notify_list; /* head of list of notify info */ int notifier_running; /* notify event source is live */ #if TCL_MAJOR_VERSION >= 8 - Tcl_Channel notifier_channel;/* Tcl_Channel on which notifier is listening */ + Tcl_Channel notifier_channel; /* Tcl_Channel on which notifier + * is listening */ #else - int notifier_socket;/* PQsocket on which notifier is listening */ + int notifier_socket; /* PQsocket on which notifier is listening */ #endif } Pg_ConnectionId; @@ -112,7 +113,6 @@ extern int Pg_lo_read( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); extern int Pg_lo_write( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); - #endif extern int Pg_lo_lseek( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); @@ -128,5 +128,4 @@ extern int Pg_lo_export( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); extern int Pg_listen( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); - #endif /* PGTCLCMDS_H */ diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c index ef34c595a4..06c3f3e18e 100644 --- a/src/interfaces/libpgtcl/pgtclId.c +++ b/src/interfaces/libpgtcl/pgtclId.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.27 2001/09/07 21:55:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.28 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,7 +135,6 @@ PgGetFileProc(ClientData cData, int direction) { return (Tcl_File) NULL; } - #endif /* @@ -147,7 +146,7 @@ PgWatchProc(ClientData instanceData, int mask) } static int PgGetHandleProc(ClientData instanceData, int direction, - ClientData *handlePtr) + ClientData *handlePtr) { return TCL_ERROR; } @@ -163,7 +162,7 @@ Tcl_ChannelType Pg_ConnType = { NULL, /* GetOptionProc, Not used */ PgWatchProc, /* WatchProc, must be defined */ PgGetHandleProc, /* GetHandleProc, must be defined */ - NULL /* Close2Proc, Not used */ + NULL /* Close2Proc, Not used */ }; /* @@ -395,7 +394,7 @@ getresid(Tcl_Interp *interp, char *id, Pg_ConnectionId ** connid_p) /* * Get back the result pointer from the Id */ -PGresult * +PGresult * PgGetResultId(Tcl_Interp *interp, char *id) { Pg_ConnectionId *connid; @@ -710,7 +709,7 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid) { #if TCL_MAJOR_VERSION >= 8 Tcl_CreateChannelHandler(connid->notifier_channel, TCL_READABLE, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD); @@ -732,7 +731,7 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid) { #if TCL_MAJOR_VERSION >= 8 Tcl_DeleteChannelHandler(connid->notifier_channel, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket, diff --git a/src/interfaces/libpgtcl/pgtclId.h b/src/interfaces/libpgtcl/pgtclId.h index fd12ee4a48..4f37378f34 100644 --- a/src/interfaces/libpgtcl/pgtclId.h +++ b/src/interfaces/libpgtcl/pgtclId.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclId.h,v 1.16 2001/01/24 19:43:29 momjian Exp $ + * $Id: pgtclId.h,v 1.17 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,6 @@ extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp); #if HAVE_TCL_GETFILEPROC extern Tcl_File PgGetFileProc(ClientData cData, int direction); - #endif extern Tcl_ChannelType Pg_ConnType; diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 4b4b039910..8cfc1d940f 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.61 2001/09/26 19:54:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.62 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,6 @@ pg_krb4_sendauth(char *PQerrormsg, int sock, } return STATUS_OK; } - #endif /* KRB4 */ #ifdef KRB5 @@ -405,7 +404,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, if (retval == KRB5_SENDAUTH_REJECTED && err_ret) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), + libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), err_ret->text.length, err_ret->text.data); } else @@ -432,33 +431,34 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, return ret; } - #endif /* KRB5 */ static int pg_local_sendauth(char *PQerrormsg, PGconn *conn) { #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) - char buf; + char buf; struct iovec iov; struct msghdr msg; + #ifdef HAVE_STRUCT_CMSGCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif #ifdef HAVE_STRUCT_SOCKCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif /* - * The backend doesn't care what we send here, but it wants - * exactly one character to force recvmsg() to block and wait - * for us. + * The backend doesn't care what we send here, but it wants exactly + * one character to force recvmsg() to block and wait for us. */ buf = '\0'; iov.iov_base = &buf; @@ -481,13 +481,13 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) if (sendmsg(conn->sock, &msg, 0) == -1) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); + "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); return STATUS_ERROR; } return STATUS_OK; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("SCM_CRED authentication method not supported\n")); + libpq_gettext("SCM_CRED authentication method not supported\n")); return STATUS_ERROR; #endif } @@ -495,51 +495,51 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) static int pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) { - int ret; - char *crypt_pwd; + int ret; + char *crypt_pwd; /* Encrypt the password if needed. */ switch (areq) { case AUTH_REQ_MD5: - { - char *crypt_pwd2; - - if (!(crypt_pwd = malloc(MD5_PASSWD_LEN+1)) || - !(crypt_pwd2 = malloc(MD5_PASSWD_LEN+1))) - { - perror("malloc"); - return STATUS_ERROR; - } - if (!EncryptMD5(password, conn->pguser, - strlen(conn->pguser), crypt_pwd2)) { - free(crypt_pwd); + char *crypt_pwd2; + + if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) || + !(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1))) + { + perror("malloc"); + return STATUS_ERROR; + } + if (!EncryptMD5(password, conn->pguser, + strlen(conn->pguser), crypt_pwd2)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } + if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, + sizeof(conn->md5Salt), crypt_pwd)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } free(crypt_pwd2); - return STATUS_ERROR; + break; } - if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, - sizeof(conn->md5Salt), crypt_pwd)) - { - free(crypt_pwd); - free(crypt_pwd2); - return STATUS_ERROR; - } - free(crypt_pwd2); - break; - } case AUTH_REQ_CRYPT: - { - char salt[3]; + { + char salt[3]; - StrNCpy(salt, conn->cryptSalt,3); - crypt_pwd = crypt(password, salt); - break; - } + StrNCpy(salt, conn->cryptSalt, 3); + crypt_pwd = crypt(password, salt); + break; + } case AUTH_REQ_PASSWORD: /* discard const so we can assign it */ - crypt_pwd = (char *)password; + crypt_pwd = (char *) password; break; default: return STATUS_ERROR; @@ -573,13 +573,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication failed\n")); + libpq_gettext("Kerberos 4 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication not supported\n")); + libpq_gettext("Kerberos 4 authentication not supported\n")); return STATUS_ERROR; #endif @@ -590,13 +590,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication failed\n")); + libpq_gettext("Kerberos 5 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication not supported\n")); + libpq_gettext("Kerberos 5 authentication not supported\n")); return STATUS_ERROR; #endif diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h index ed8d5b7774..4d99399cb9 100644 --- a/src/interfaces/libpq/fe-auth.h +++ b/src/interfaces/libpq/fe-auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fe-auth.h,v 1.12 2001/01/24 19:43:30 momjian Exp $ + * $Id: fe-auth.h,v 1.13 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ extern char *fe_getauthname(char *PQerrormsg); #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB5_VERSION "PGVER5.1" - #endif /* FE_AUTH_H */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 8829c69e32..69bd5fa591 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.177 2001/09/06 04:57:30 ishii Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.178 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,13 +59,11 @@ inet_aton(const char *cp, struct in_addr * inp) inp->s_addr = a; return 1; } - #endif #ifdef USE_SSL static SSL_CTX *SSL_context = NULL; - #endif #define NOTIFYLIST_INITIAL_SIZE 10 @@ -99,7 +97,6 @@ static SSL_CTX *SSL_context = NULL; * ---------- */ static const PQconninfoOption PQconninfoOptions[] = { - /* * "authtype" is no longer used, so mark it "don't show". We keep it * in the array so as not to reject conninfo strings from old apps @@ -191,7 +188,7 @@ static int parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage); -/* +/* * Connecting to a Database * * There are now four different ways a user of this API can connect to the @@ -576,7 +573,7 @@ update_db_info(PGconn *conn) /*------- * new style: - * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] + * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] * [/db name][?options] *------- */ @@ -601,7 +598,6 @@ update_db_info(PGconn *conn) } else { - /* * Why do we default only this value from the environment * again? @@ -676,7 +672,6 @@ update_db_info(PGconn *conn) return 0; } - #endif /* NOT_USED */ @@ -696,13 +691,13 @@ connectMakeNonblocking(PGconn *conn) #if defined(WIN32) if (ioctlsocket(conn->sock, FIONBIO, &on) != 0) #elif defined(__BEOS__) - if (ioctl(conn->sock, FIONBIO, &on) != 0) + if (ioctl(conn->sock, FIONBIO, &on) != 0) #else if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0) #endif { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to non-blocking mode: %s\n"), + libpq_gettext("could not set socket to non-blocking mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -726,7 +721,7 @@ connectNoDelay(PGconn *conn) sizeof(on)) < 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to TCP no delay mode: %s\n"), + libpq_gettext("could not set socket to TCP no delay mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -746,19 +741,19 @@ connectFailureMessage(PGconn *conn, int errorno) if (conn->raddr.sa.sa_family == AF_UNIX) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running locally and accepting\n" - "\tconnections on Unix domain socket \"%s\"?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running locally and accepting\n" + "\tconnections on Unix domain socket \"%s\"?\n" + ), SOCK_STRERROR(errorno), conn->raddr.un.sun_path); else printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running on host %s and accepting\n" - "\tTCP/IP connections on port %s?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running on host %s and accepting\n" + "\tTCP/IP connections on port %s?\n" + ), SOCK_STRERROR(errorno), conn->pghost ? conn->pghost @@ -785,7 +780,6 @@ connectDBStart(PGconn *conn) #ifdef USE_SSL StartupPacket np; /* Used to negotiate SSL connection */ char SSLok; - #endif if (!conn) @@ -944,7 +938,7 @@ connectDBStart(PGconn *conn) if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send SSL negotiation packet: %s\n"), + libpq_gettext("could not send SSL negotiation packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto connect_errReturn; } @@ -966,8 +960,8 @@ connectDBStart(PGconn *conn) if (!SSL_context) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create SSL context: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not create SSL context: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } } @@ -976,8 +970,8 @@ connectDBStart(PGconn *conn) SSL_connect(conn->ssl) <= 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not establish SSL connection: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not establish SSL connection: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } /* SSL connection finished. Continue to send startup packet */ @@ -1053,7 +1047,6 @@ connectDBComplete(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQconnectStart) is to wait for the socket to select for @@ -1134,7 +1127,6 @@ PQconnectPoll(PGconn *conn) /* Get the new data */ switch (conn->status) { - /* * We really shouldn't have been polled in these two cases, * but we can handle it. @@ -1171,9 +1163,9 @@ PQconnectPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state, " - "probably indicative of memory corruption\n" - )); + "invalid connection state, " + "probably indicative of memory corruption\n" + )); goto error_return; } @@ -1261,7 +1253,7 @@ keep_going: /* We will come back to here until there sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send startup packet: %s\n"), + libpq_gettext("could not send startup packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto error_return; } @@ -1317,9 +1309,9 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "expected authentication request from " - "server, but received %c\n" - ), + "expected authentication request from " + "server, but received %c\n" + ), beresp); goto error_return; } @@ -1404,7 +1396,6 @@ keep_going: /* We will come back to here until there case CONNECTION_AUTH_OK: { - /* * Now we expect to hear from the backend. A ReadyForQuery * message indicates that startup is successful, but we @@ -1489,9 +1480,9 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state %c, " - "probably indicative of memory corruption\n" - ), + "invalid connection state %c, " + "probably indicative of memory corruption\n" + ), conn->status); goto error_return; } @@ -1549,7 +1540,6 @@ PQsetenvPoll(PGconn *conn) #ifdef MULTIBYTE static const char envname[] = "PGCLIENTENCODING"; - #endif if (conn == NULL || conn->status == CONNECTION_BAD) @@ -1589,9 +1579,9 @@ PQsetenvPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid setenv state %c, " - "probably indicative of memory corruption\n" - ), + "invalid setenv state %c, " + "probably indicative of memory corruption\n" + ), conn->setenv_state); goto error_return; } @@ -1610,7 +1600,6 @@ keep_going: /* We will come back to here until there env = getenv(envname); if (!env || *env == '\0') { - /* * query server encoding if PGCLIENTENCODING is not * specified @@ -1756,7 +1745,7 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext("invalid state %c, " - "probably indicative of memory corruption\n"), + "probably indicative of memory corruption\n"), conn->setenv_state); goto error_return; } @@ -1793,7 +1782,6 @@ PQsetenv(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQsetenvStart) is to wait for the socket to select for writing. @@ -1834,7 +1822,6 @@ PQsetenv(PGconn *conn) flag = PQsetenvPoll(conn); } } - #endif /* NOT_USED */ @@ -1955,11 +1942,12 @@ freePGconn(PGconn *conn) static void closePGconn(PGconn *conn) { - /* Note that the protocol doesn't allow us to send Terminate - messages during the startup phase. */ + /* + * Note that the protocol doesn't allow us to send Terminate messages + * during the startup phase. + */ if (conn->sock >= 0 && conn->status == CONNECTION_OK) { - /* * Try to send "close connection" message to backend. Ignore any * error. Note: this routine used to go to substantial lengths to @@ -2298,7 +2286,6 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) { if (group_found) { - /* * Finally, we are in the right group and can parse * the line @@ -2507,7 +2494,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (option->keyword == NULL) { printfPQExpBuffer(errorMessage, - libpq_gettext("invalid connection option \"%s\"\n"), + libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); free(buf); @@ -2758,14 +2745,13 @@ PQsetClientEncoding(PGconn *conn, const char *encoding) return (status); } -#else /* without multibytle support */ +#else /* without multibytle support */ int PQsetClientEncoding(PGconn *conn, const char *encoding) { return -1; } - #endif #ifdef USE_SSL @@ -2776,7 +2762,6 @@ PQgetssl(PGconn *conn) return NULL; return conn->ssl; } - #endif void diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 2741ec67aa..123d7abd12 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.112 2001/09/14 17:46:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.113 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,31 +67,33 @@ static int getNotice(PGconn *conn); */ size_t -PQescapeString (char *to, const char *from, size_t length) +PQescapeString(char *to, const char *from, size_t length) { const char *source = from; - char *target = to; + char *target = to; unsigned int remaining = length; - while (remaining > 0) { - switch (*source) { - case '\\': - *target = '\\'; - target++; - *target = '\\'; - /* target and remaining are updated below. */ - break; + while (remaining > 0) + { + switch (*source) + { + case '\\': + *target = '\\'; + target++; + *target = '\\'; + /* target and remaining are updated below. */ + break; - case '\'': - *target = '\''; - target++; - *target = '\''; - /* target and remaining are updated below. */ - break; + case '\'': + *target = '\''; + target++; + *target = '\''; + /* target and remaining are updated below. */ + break; - default: - *target = *source; - /* target and remaining are updated below. */ + default: + *target = *source; + /* target and remaining are updated below. */ } source++; target++; @@ -100,7 +102,7 @@ PQescapeString (char *to, const char *from, size_t length) /* Write the terminating NUL character. */ *target = '\0'; - + return target - to; } @@ -117,11 +119,11 @@ PQescapeString (char *to, const char *from, size_t length) unsigned char * PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) { - unsigned char *vp; - unsigned char *rp; - unsigned char *result; - size_t i; - size_t len; + unsigned char *vp; + unsigned char *rp; + unsigned char *result; + size_t i; + size_t len; /* * empty string has 1 char ('\0') @@ -253,7 +255,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) * and the Perl5 interface, so maybe it's not so unreasonable. */ -PGresult * +PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status) { PGresult *result; @@ -346,7 +348,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) } /* If there's enough space in the current block, no problem. */ - if (nBytes <= (size_t)res->spaceLeft) + if (nBytes <= (size_t) res->spaceLeft) { space = res->curBlock->space + res->curOffset; res->curOffset += nBytes; @@ -369,7 +371,6 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) space = block->space + PGRESULT_BLOCK_OVERHEAD; if (res->curBlock) { - /* * Tuck special block below the active block, so that we don't * have to waste the free space in the active block. @@ -515,7 +516,6 @@ pqClearAsyncResult(PGconn *conn) static void saveErrorResult(PGconn *conn) { - /* * If no old async result, just let PQmakeEmptyPGresult make one. * Likewise if old result is not an error message. @@ -558,7 +558,6 @@ prepareAsyncResult(PGconn *conn) res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); else { - /* * Make sure PQerrorMessage agrees with result; it could be * different if we have concatenated messages. @@ -580,7 +579,6 @@ addTuple(PGresult *res, PGresAttValue * tup) { if (res->ntups >= res->tupArrSize) { - /* * Try to grow the array. * @@ -632,7 +630,7 @@ PQsendQuery(PGconn *conn, const char *query) if (!query) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -647,7 +645,7 @@ PQsendQuery(PGconn *conn, const char *query) if (conn->asyncStatus != PGASYNC_IDLE) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("another command is already in progress\n")); + libpq_gettext("another command is already in progress\n")); return 0; } @@ -669,7 +667,6 @@ PQsendQuery(PGconn *conn, const char *query) */ if (pqIsnonblocking(conn)) { - /* * the buffer must have emptied completely before we allow a new * query to be buffered @@ -692,7 +689,6 @@ PQsendQuery(PGconn *conn, const char *query) } else { - /* * the frontend-backend protocol uses 'Q' to designate queries */ @@ -721,7 +717,6 @@ PQsendQuery(PGconn *conn, const char *query) static void handleSendFailure(PGconn *conn) { - /* * Accept any available input data, ignoring errors. Note that if * pqReadData decides the backend has closed the channel, it will @@ -757,7 +752,6 @@ PQconsumeInput(PGconn *conn) */ if (pqReadData(conn) < 0) { - /* * for non-blocking connections try to flush the send-queue * otherwise we may never get a responce for something that may @@ -789,7 +783,6 @@ parseInput(PGconn *conn) */ for (;;) { - /* * Quit if in COPY_OUT state: we expect raw data from the server * until PQendcopy is called. Don't try to parse it according to @@ -860,7 +853,6 @@ parseInput(PGconn *conn) } else { - /* * In BUSY state, we can process everything. */ @@ -929,7 +921,6 @@ parseInput(PGconn *conn) } else { - /* * A new 'T' message is treated as the start of * another PGresult. (It is not clear that this @@ -984,7 +975,7 @@ parseInput(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "unexpected response from server; first received character was \"%c\"\n"), + "unexpected response from server; first received character was \"%c\"\n"), id); /* build an error result holding the error message */ saveErrorResult(conn); @@ -1147,7 +1138,7 @@ getAnotherTuple(PGconn *conn, int binary) vlen = 0; if (tup[i].value == NULL) { - tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool)binary); + tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool) binary); if (tup[i].value == NULL) goto outOfMemory; } @@ -1228,7 +1219,7 @@ PQisBusy(PGconn *conn) * Returns NULL if and only if no query work remains. */ -PGresult * +PGresult * PQgetResult(PGconn *conn) { PGresult *res; @@ -1246,7 +1237,6 @@ PQgetResult(PGconn *conn) if (pqWait(TRUE, FALSE, conn) || pqReadData(conn) < 0) { - /* * conn->errorMessage has been set by pqWait or pqReadData. We * want to append it to any already-received error message. @@ -1278,7 +1268,7 @@ PQgetResult(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unexpected asyncStatus: %d\n"), + libpq_gettext("unexpected asyncStatus: %d\n"), (int) conn->asyncStatus); res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); break; @@ -1300,7 +1290,7 @@ PQgetResult(PGconn *conn) * when done with it. */ -PGresult * +PGresult * PQexec(PGconn *conn, const char *query) { PGresult *result; @@ -1328,7 +1318,7 @@ PQexec(PGconn *conn, const char *query) { PQclear(result); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("COPY state must be terminated first\n")); + libpq_gettext("COPY state must be terminated first\n")); /* restore blocking status */ goto errout; } @@ -1445,7 +1435,7 @@ getNotify(PGconn *conn) * the CALLER is responsible for FREE'ing the structure returned */ -PGnotify * +PGnotify * PQnotifies(PGconn *conn) { Dlelem *e; @@ -1757,7 +1747,7 @@ PQendcopy(PGconn *conn) * ---------------- */ -PGresult * +PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, @@ -1787,9 +1777,9 @@ PQfn(PGconn *conn, return NULL; } - if (pqPuts("F ", conn) != 0 || /* function */ - pqPutInt(fnid, 4, conn) != 0 || /* function id */ - pqPutInt(nargs, 4, conn) != 0) /* # of args */ + if (pqPuts("F ", conn) != 0 || /* function */ + pqPutInt(fnid, 4, conn) != 0 || /* function id */ + pqPutInt(nargs, 4, conn) != 0) /* # of args */ { handleSendFailure(conn); return NULL; @@ -1885,7 +1875,7 @@ PQfn(PGconn *conn, { /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1919,7 +1909,7 @@ PQfn(PGconn *conn, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -2007,7 +1997,7 @@ check_field_number(const PGresult *res, int field_num) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), + libpq_gettext("column number %d is out of range 0..%d\n"), field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } @@ -2029,8 +2019,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("row number %d is out of range 0..%d\n"), - tup_num, res->ntups - 1); + libpq_gettext("row number %d is out of range 0..%d\n"), + tup_num, res->ntups - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2040,8 +2030,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), - field_num, res->numAttributes - 1); + libpq_gettext("column number %d is out of range 0..%d\n"), + field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2152,7 +2142,6 @@ PQcmdStatus(PGresult *res) char * PQoidStatus(const PGresult *res) { - /* * This must be enough to hold the result. Don't laugh, this is better * than what this function used to do. @@ -2188,7 +2177,7 @@ PQoidValue(const PGresult *res) return InvalidOid; #ifdef WIN32 - SetLastError(0); + SetLastError(0); #else errno = 0; #endif @@ -2225,8 +2214,8 @@ PQcmdTuples(PGresult *res) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("could not interpret result from server: %s\n"), - res->cmdStatus); + libpq_gettext("could not interpret result from server: %s\n"), + res->cmdStatus); DONOTICE(res, noticeBuf); } return ""; diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 7be372d6a3..99a1724bc1 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.39 2001/09/17 20:05:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.40 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -397,7 +397,7 @@ lo_import(PGconn *conn, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); return InvalidOid; } @@ -409,7 +409,7 @@ lo_import(PGconn *conn, const char *filename) if (lobjOid == InvalidOid) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create large object for file \"%s\"\n"), + libpq_gettext("could not create large object for file \"%s\"\n"), filename); (void) close(fd); return InvalidOid; @@ -419,7 +419,7 @@ lo_import(PGconn *conn, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), + libpq_gettext("could not open large object %u\n"), lobjOid); (void) close(fd); return InvalidOid; @@ -434,7 +434,7 @@ lo_import(PGconn *conn, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while reading file \"%s\"\n"), + libpq_gettext("error while reading file \"%s\"\n"), filename); (void) close(fd); (void) lo_close(conn, lobj); @@ -469,7 +469,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), lobjId); + libpq_gettext("could not open large object %u\n"), lobjId); return -1; } @@ -480,7 +480,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); (void) lo_close(conn, lobj); return -1; @@ -495,7 +495,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while writing to file \"%s\"\n"), + libpq_gettext("error while writing to file \"%s\"\n"), filename); (void) lo_close(conn, lobj); (void) close(fd); @@ -599,56 +599,56 @@ lo_initialize(PGconn *conn) if (lobjfuncs->fn_lo_open == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_open\n")); + libpq_gettext("cannot determine OID of function lo_open\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_close == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_close\n")); + libpq_gettext("cannot determine OID of function lo_close\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_creat == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_creat\n")); + libpq_gettext("cannot determine OID of function lo_creat\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_unlink == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_unlink\n")); + libpq_gettext("cannot determine OID of function lo_unlink\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_lseek == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_lseek\n")); + libpq_gettext("cannot determine OID of function lo_lseek\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_tell == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_tell\n")); + libpq_gettext("cannot determine OID of function lo_tell\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_read == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function loread\n")); + libpq_gettext("cannot determine OID of function loread\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_write == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lowrite\n")); + libpq_gettext("cannot determine OID of function lowrite\n")); free(lobjfuncs); return -1; } diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index cb7684e88f..2a75ce43d7 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.57 2001/09/30 16:23:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.58 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,16 +59,16 @@ #define DONOTICE(conn,message) \ ((*(conn)->noticeHook) ((conn)->noticeArg, (message))) -static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); +static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); /* * pqGetc: - * get a character from the connection + * get a character from the connection * - * All these routines return 0 on success, EOF on error. - * Note that for the Get routines, EOF only means there is not enough - * data in the buffer, not that there is necessarily a hard error. + * All these routines return 0 on success, EOF on error. + * Note that for the Get routines, EOF only means there is not enough + * data in the buffer, not that there is necessarily a hard error. */ int pqGetc(char *result, PGconn *conn) @@ -116,7 +116,6 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) */ if (pqIsnonblocking(conn) && nbytes > avail && pqFlush(conn)) { - /* * even if the flush failed we may still have written some data, * recalculate the size of the send-queue relative to the amount @@ -129,7 +128,7 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"), - Max(conn->outBufSize - conn->outCount, 0), nbytes); + Max(conn->outBufSize - conn->outCount, 0), nbytes); return EOF; } /* fixup avail for while loop */ @@ -211,7 +210,7 @@ pqPuts(const char *s, PGconn *conn) /* * pqGetnchar: - * get a string of exactly len bytes in buffer s, no null termination + * get a string of exactly len bytes in buffer s, no null termination */ int pqGetnchar(char *s, size_t len, PGconn *conn) @@ -232,7 +231,7 @@ pqGetnchar(char *s, size_t len, PGconn *conn) /* * pqPutnchar: - * send a string of exactly len bytes, no null termination needed + * send a string of exactly len bytes, no null termination needed */ int pqPutnchar(const char *s, size_t len, PGconn *conn) @@ -248,8 +247,8 @@ pqPutnchar(const char *s, size_t len, PGconn *conn) /* * pgGetInt - * read a 2 or 4 byte integer and convert from network byte order - * to local byte order + * read a 2 or 4 byte integer and convert from network byte order + * to local byte order */ int pqGetInt(int *result, size_t bytes, PGconn *conn) @@ -484,7 +483,7 @@ tryAgain: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -570,7 +569,7 @@ tryAgain2: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -587,9 +586,9 @@ tryAgain2: definitelyFailed: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); conn->status = CONNECTION_BAD; /* No more connection to backend */ #ifdef WIN32 closesocket(conn->sock); @@ -647,7 +646,6 @@ pqFlush(PGconn *conn) if (sent < 0) { - /* * Anything except EAGAIN or EWOULDBLOCK is trouble. If it's * EPIPE or ECONNRESET, assume we've lost the backend @@ -672,9 +670,9 @@ pqFlush(PGconn *conn) #endif printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); /* * We used to close the socket here, but that's a bad @@ -688,7 +686,7 @@ pqFlush(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send data to server: %s\n"), + libpq_gettext("could not send data to server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); /* We don't assume it's a fatal error... */ return EOF; @@ -832,7 +830,6 @@ PQenv2encoding(void) { return 0; } - #endif /* MULTIBYTE */ @@ -840,7 +837,7 @@ PQenv2encoding(void) char * libpq_gettext(const char *msgid) { - static int already_bound = 0; + static int already_bound = 0; if (!already_bound) { @@ -850,7 +847,7 @@ libpq_gettext(const char *msgid) return dgettext("libpq", msgid); } -#endif /* ENABLE_NLS */ +#endif /* ENABLE_NLS */ #ifdef WIN32 /* @@ -860,41 +857,41 @@ libpq_gettext(const char *msgid) * If you can verify this working on win9x or have a solution, let us know, ok? * */ -const char* +const char * winsock_strerror(DWORD eno) { - #define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ - int length; +#define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ + int length; + + /* First try the "system table", this works on Win2k pro */ - /* First try the "system table", this works on Win2k pro */ + if (FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* That didn't work, let's try the netmsg.dll */ - /* That didn't work, let's try the netmsg.dll */ + if (netmsgModule && + FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (netmsgModule && - FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* Everything failed, just tell the user that we don't know the desc */ - /* Everything failed, just tell the user that we don't know the desc */ - - strcat(winsock_strerror_buf,"Socket error, no description available."); + strcat(winsock_strerror_buf, "Socket error, no description available."); WSSE_GOODEXIT: - length = strlen(winsock_strerror_buf); - sprintf(winsock_strerror_buf + (length<WSSE_MAXLEN?length:WSSE_MAXLEN), - "(0x%08X)",eno); + length = strlen(winsock_strerror_buf); + sprintf(winsock_strerror_buf + (length < WSSE_MAXLEN ? length : WSSE_MAXLEN), + "(0x%08X)", eno); - return winsock_strerror_buf; + return winsock_strerror_buf; } #endif diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index f581260de0..e753e5dd52 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.42 2001/03/22 04:01:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.43 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,7 +102,6 @@ PQprint(FILE *fout, int ws_row; int ws_col; } screen_size; - #endif nTups = PQntuples(res); @@ -152,7 +151,6 @@ PQprint(FILE *fout, #endif ) { - /* * If we think there'll be more than one screen of output, try * to pipe to the pager program. diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 02448ef843..de8fa5636e 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.75 2001/09/14 17:46:40 momjian Exp $ + * $Id: libpq-fe.h,v 1.76 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,11 +23,11 @@ extern "C" #include <stdio.h> #ifdef WIN32 - #define SOCK_ERRNO (WSAGetLastError ()) - #define SOCK_STRERROR winsock_strerror +#define SOCK_ERRNO (WSAGetLastError ()) +#define SOCK_STRERROR winsock_strerror #else - #define SOCK_ERRNO errno - #define SOCK_STRERROR strerror +#define SOCK_ERRNO errno +#define SOCK_STRERROR strerror #endif @@ -44,7 +44,6 @@ extern "C" typedef enum { - /* * Although you may decide to change this list in some way, values * which become unused should never be removed, nor should @@ -252,13 +251,13 @@ extern "C" /* === in fe-exec.c === */ /* Quoting strings before inclusion in queries. */ - extern size_t PQescapeString (char *to, const char *from, size_t length); + extern size_t PQescapeString(char *to, const char *from, size_t length); extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen); /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); - extern void PQfreeNotify(PGnotify *notify); + extern void PQfreeNotify(PGnotify *notify); /* Interface for multiple-result or asynchronous queries */ extern int PQsendQuery(PGconn *conn, const char *query); @@ -374,7 +373,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* LIBPQ_FE_H */ diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 6b088e94d7..26acd3ed83 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-int.h,v 1.40 2001/10/03 21:58:28 tgl Exp $ + * $Id: libpq-int.h,v 1.41 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ struct pg_result */ PQnoticeProcessor noticeHook; /* notice/error message processor */ void *noticeArg; - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ char *errMsg; /* error message, or NULL if no error */ @@ -160,22 +160,26 @@ struct pg_result /* PGAsyncStatusType defines the state of the query-execution state machine */ typedef enum { - PGASYNC_IDLE, /* nothing's happening, dude */ - PGASYNC_BUSY, /* query in progress */ - PGASYNC_READY, /* result ready for PQgetResult */ - PGASYNC_COPY_IN, /* Copy In data transfer in progress */ - PGASYNC_COPY_OUT /* Copy Out data transfer in progress */ + PGASYNC_IDLE, /* nothing's happening, dude */ + PGASYNC_BUSY, /* query in progress */ + PGASYNC_READY, /* result ready for PQgetResult */ + PGASYNC_COPY_IN,/* Copy In data transfer in progress */ + PGASYNC_COPY_OUT/* Copy Out data transfer in progress */ } PGAsyncStatusType; /* PGSetenvStatusType defines the state of the PQSetenv state machine */ typedef enum { - SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */ - SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */ + SETENV_STATE_OPTION_SEND, /* About to send an + * Environment Option */ + SETENV_STATE_OPTION_WAIT, /* Waiting for above send + * to complete */ /* these next two are only used in MULTIBYTE mode */ - SETENV_STATE_ENCODINGS_SEND,/* About to send an "encodings" query */ - SETENV_STATE_ENCODINGS_WAIT,/* Waiting for query to complete */ - SETENV_STATE_IDLE + SETENV_STATE_ENCODINGS_SEND, /* About to send an + * "encodings" query */ + SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to + * complete */ + SETENV_STATE_IDLE } PGSetenvStatusType; /* large-object-access data ... allocated only if large-object code is used. */ @@ -236,8 +240,8 @@ struct pg_conn /* Miscellaneous stuff */ int be_pid; /* PID of backend --- needed for cancels */ int be_key; /* key of backend --- needed for cancels */ - char md5Salt[4]; /* password salt received from backend */ - char cryptSalt[2]; /* password salt received from backend */ + char md5Salt[4]; /* password salt received from backend */ + char cryptSalt[2]; /* password salt received from backend */ PGlobjfuncs *lobjfuncs; /* private state for large-object access * fns */ @@ -278,7 +282,7 @@ struct pg_conn /* Buffer for receiving various parts of messages */ PQExpBufferData workBuffer; /* expansible string */ - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ }; /* String descriptions of the ExecStatusTypes. @@ -345,10 +349,11 @@ extern int pqWriteReady(PGconn *conn); #define pqIsnonblocking(conn) ((conn)->nonblocking) #ifdef ENABLE_NLS -extern char * libpq_gettext(const char *msgid) +extern char * +libpq_gettext(const char *msgid) __attribute__((format_arg(1))); + #else #define libpq_gettext(x) (x) #endif - #endif /* LIBPQ_INT_H */ diff --git a/src/interfaces/libpq/libpqdll.c b/src/interfaces/libpq/libpqdll.c index 1e7d647937..9f9c93d2f9 100644 --- a/src/interfaces/libpq/libpqdll.c +++ b/src/interfaces/libpq/libpqdll.c @@ -14,19 +14,17 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, case DLL_PROCESS_ATTACH: if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { - /* * No really good way to do error handling here, since we * don't know how we were loaded */ return FALSE; } - if (netmsgModule == NULL){ - netmsgModule=LoadLibraryEx("netmsg.dll",NULL,LOAD_LIBRARY_AS_DATAFILE); - } + if (netmsgModule == NULL) + netmsgModule = LoadLibraryEx("netmsg.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); break; case DLL_PROCESS_DETACH: - if (netmsgModule != NULL) + if (netmsgModule != NULL) FreeLibrary(netmsgModule); WSACleanup(); break; diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 06471ee939..cf565eb9a3 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.11 2001/08/17 15:11:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.12 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -174,7 +174,6 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall @@ -223,7 +222,6 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall diff --git a/src/interfaces/libpq/pqexpbuffer.h b/src/interfaces/libpq/pqexpbuffer.h index 0db0806595..9e17b314f7 100644 --- a/src/interfaces/libpq/pqexpbuffer.h +++ b/src/interfaces/libpq/pqexpbuffer.h @@ -18,7 +18,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqexpbuffer.h,v 1.7 2001/10/03 21:58:28 tgl Exp $ + * $Id: pqexpbuffer.h,v 1.8 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,8 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed); * This is a convenience routine that does the same thing as * resetPQExpBuffer() followed by appendPQExpBuffer(). */ -extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -133,7 +134,8 @@ __attribute__((format(printf, 2, 3))); * to str if necessary. This is sort of like a combination of sprintf and * strcat. */ -extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -158,5 +160,4 @@ extern void appendPQExpBufferChar(PQExpBuffer str, char ch); */ extern void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen); - #endif /* PQEXPBUFFER_H */ diff --git a/src/interfaces/libpq/pqsignal.h b/src/interfaces/libpq/pqsignal.h index 3444bfb70e..b6b167c188 100644 --- a/src/interfaces/libpq/pqsignal.h +++ b/src/interfaces/libpq/pqsignal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.10 2001/02/10 02:31:30 tgl Exp $ + * $Id: pqsignal.h,v 1.11 2001/10/25 05:50:13 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -23,5 +23,4 @@ typedef void (*pqsigfunc) (int); extern pqsigfunc pqsignal(int signo, pqsigfunc func); - #endif /* PQSIGNAL_H */ diff --git a/src/interfaces/libpq/win32.h b/src/interfaces/libpq/win32.h index 2ba2d842a6..ac6a0ea388 100644 --- a/src/interfaces/libpq/win32.h +++ b/src/interfaces/libpq/win32.h @@ -23,7 +23,7 @@ */ #define crypt(a,b) (a) -#undef EAGAIN /* doesn't apply on sockets */ +#undef EAGAIN /* doesn't apply on sockets */ #undef EINTR #define EINTR WSAEINTR #define EWOULDBLOCK WSAEWOULDBLOCK @@ -36,4 +36,4 @@ static HINSTANCE netmsgModule = NULL; static char winsock_strerror_buf[512]; -const char* winsock_strerror(DWORD eno); +const char *winsock_strerror(DWORD eno); diff --git a/src/interfaces/odbc/bind.c b/src/interfaces/odbc/bind.c index 062632df48..4bd2c0ce08 100644 --- a/src/interfaces/odbc/bind.c +++ b/src/interfaces/odbc/bind.c @@ -26,18 +26,18 @@ /* Bind parameters on a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_BindParameter( - HSTMT hstmt, - UWORD ipar, - SWORD fParamType, - SWORD fCType, - SWORD fSqlType, - UDWORD cbColDef, - SWORD ibScale, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD ipar, + SWORD fParamType, + SWORD fCType, + SWORD fSqlType, + UDWORD cbColDef, + SWORD ibScale, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_BindParameter"; @@ -152,14 +152,14 @@ PGAPI_BindParameter( /* Associate a user-supplied buffer with a database column. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_BindCol( - HSTMT hstmt, - UWORD icol, - SWORD fCType, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD icol, + SWORD fCType, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_BindCol"; @@ -167,7 +167,7 @@ PGAPI_BindCol( mylog("%s: entering...\n", func); mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n", stmt, icol); -mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue); + mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue); if (!stmt) { @@ -265,14 +265,14 @@ mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueM * it is best to say this function is not supported and let the application assume a * data type (most likely varchar). */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_DescribeParam( - HSTMT hstmt, - UWORD ipar, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable) + HSTMT hstmt, + UWORD ipar, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_DescribeParam"; @@ -318,18 +318,19 @@ PGAPI_DescribeParam( /* Sets multiple values (arrays) for the set of parameter markers. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ParamOptions( - HSTMT hstmt, - UDWORD crow, - UDWORD FAR *pirow) + HSTMT hstmt, + UDWORD crow, + UDWORD FAR * pirow) { static char *func = "PGAPI_ParamOptions"; - StatementClass *stmt = (StatementClass *) hstmt; + StatementClass *stmt = (StatementClass *) hstmt; mylog("%s: entering... %d %x\n", func, crow, pirow); - if (crow == 1) /* temporary solution and must be rewritten later */ + if (crow == 1) /* temporary solution and must be + * rewritten later */ { if (pirow) *pirow = 1; @@ -351,10 +352,10 @@ PGAPI_ParamOptions( * to call it anyway. * If the statement does not have parameters, it should just return 0. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NumParams( - HSTMT hstmt, - SWORD FAR *pcpar) + HSTMT hstmt, + SWORD FAR * pcpar) { StatementClass *stmt = (StatementClass *) hstmt; char in_quote = FALSE; @@ -430,7 +431,7 @@ create_empty_bindings(int num_columns) void -extend_bindings(StatementClass *stmt, int num_columns) +extend_bindings(StatementClass * stmt, int num_columns) { static char *func = "extend_bindings"; BindInfoClass *new_bindings; diff --git a/src/interfaces/odbc/bind.h b/src/interfaces/odbc/bind.h index 444d30f2d2..a792c38951 100644 --- a/src/interfaces/odbc/bind.h +++ b/src/interfaces/odbc/bind.h @@ -48,6 +48,5 @@ struct ParameterInfoClass_ }; BindInfoClass *create_empty_bindings(int num_columns); -void extend_bindings(StatementClass *stmt, int num_columns); - +void extend_bindings(StatementClass * stmt, int num_columns); #endif diff --git a/src/interfaces/odbc/columninfo.c b/src/interfaces/odbc/columninfo.c index d9a22a163a..d05de1ffb7 100644 --- a/src/interfaces/odbc/columninfo.c +++ b/src/interfaces/odbc/columninfo.c @@ -42,7 +42,7 @@ CI_Constructor() void -CI_Destructor(ColumnInfoClass *self) +CI_Destructor(ColumnInfoClass * self) { CI_free_memory(self); @@ -56,7 +56,7 @@ CI_Destructor(ColumnInfoClass *self) * If self is null, then just read, don't store. */ char -CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) +CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn) { Int2 lf; int new_num_fields; @@ -112,7 +112,7 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) void -CI_free_memory(ColumnInfoClass *self) +CI_free_memory(ColumnInfoClass * self) { register Int2 lf; int num_fields = self->num_fields; @@ -148,7 +148,7 @@ CI_free_memory(ColumnInfoClass *self) void -CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) +CI_set_num_fields(ColumnInfoClass * self, int new_num_fields) { CI_free_memory(self); /* always safe to call */ @@ -164,7 +164,7 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) void -CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name, +CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name, Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod) { /* check bounds */ diff --git a/src/interfaces/odbc/columninfo.h b/src/interfaces/odbc/columninfo.h index 41e9400dce..1c805cc977 100644 --- a/src/interfaces/odbc/columninfo.h +++ b/src/interfaces/odbc/columninfo.h @@ -29,14 +29,13 @@ struct ColumnInfoClass_ #define CI_get_atttypmod(self, col) (self->atttypmod[col]) ColumnInfoClass *CI_Constructor(void); -void CI_Destructor(ColumnInfoClass *self); -void CI_free_memory(ColumnInfoClass *self); -char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn); +void CI_Destructor(ColumnInfoClass * self); +void CI_free_memory(ColumnInfoClass * self); +char CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn); /* functions for setting up the fields from within the program, */ /* without reading from a socket */ -void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields); -void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name, +void CI_set_num_fields(ColumnInfoClass * self, int new_num_fields); +void CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name, Oid new_adtid, Int2 new_adtsize, Int4 atttypmod); - #endif diff --git a/src/interfaces/odbc/connection.c b/src/interfaces/odbc/connection.c index 70c7b78230..408bef8f80 100644 --- a/src/interfaces/odbc/connection.c +++ b/src/interfaces/odbc/connection.c @@ -41,10 +41,10 @@ extern GLOBAL_VALUES globals; -RETCODE SQL_API +RETCODE SQL_API PGAPI_AllocConnect( - HENV henv, - HDBC FAR *phdbc) + HENV henv, + HDBC FAR * phdbc) { EnvironmentClass *env = (EnvironmentClass *) henv; ConnectionClass *conn; @@ -80,15 +80,15 @@ PGAPI_AllocConnect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Connect( - HDBC hdbc, - UCHAR FAR *szDSN, - SWORD cbDSN, - UCHAR FAR *szUID, - SWORD cbUID, - UCHAR FAR *szAuthStr, - SWORD cbAuthStr) + HDBC hdbc, + UCHAR FAR * szDSN, + SWORD cbDSN, + UCHAR FAR * szUID, + SWORD cbUID, + UCHAR FAR * szAuthStr, + SWORD cbAuthStr) { ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci; @@ -137,14 +137,14 @@ PGAPI_Connect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_BrowseConnect( - HDBC hdbc, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut) + HDBC hdbc, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut) { static char *func = "PGAPI_BrowseConnect"; @@ -155,9 +155,9 @@ PGAPI_BrowseConnect( /* Drop any hstmts open on hdbc and disconnect from database */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Disconnect( - HDBC hdbc) + HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; static char *func = "PGAPI_Disconnect"; @@ -194,9 +194,9 @@ PGAPI_Disconnect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeConnect( - HDBC hdbc) + HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; static char *func = "PGAPI_FreeConnect"; @@ -251,7 +251,7 @@ CC_Constructor() memset(&rv->connInfo, 0, sizeof(ConnInfo)); #ifdef DRIVER_CURSOR_IMPLEMENT rv->connInfo.updatable_cursors = 1; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ memcpy(&(rv->connInfo.drivers), &globals, sizeof(globals)); rv->sock = SOCK_Constructor(rv); if (!rv->sock) @@ -282,7 +282,7 @@ CC_Constructor() #ifdef MULTIBYTE rv->client_encoding = NULL; rv->server_encoding = NULL; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Initialize statement options to defaults */ @@ -297,7 +297,7 @@ CC_Constructor() char -CC_Destructor(ConnectionClass *self) +CC_Destructor(ConnectionClass * self) { mylog("enter CC_Destructor, self=%u\n", self); @@ -313,7 +313,7 @@ CC_Destructor(ConnectionClass *self) free(self->client_encoding); if (self->server_encoding) free(self->server_encoding); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Free up statement holders */ if (self->stmts) { @@ -349,7 +349,7 @@ CC_Destructor(ConnectionClass *self) /* Return how many cursors are opened on this connection */ int -CC_cursor_count(ConnectionClass *self) +CC_cursor_count(ConnectionClass * self) { StatementClass *stmt; int i, @@ -371,7 +371,7 @@ CC_cursor_count(ConnectionClass *self) void -CC_clear_error(ConnectionClass *self) +CC_clear_error(ConnectionClass * self) { self->errornumber = 0; self->errormsg = NULL; @@ -384,7 +384,7 @@ CC_clear_error(ConnectionClass *self) * We are almost always in the middle of a transaction. */ char -CC_abort(ConnectionClass *self) +CC_abort(ConnectionClass * self) { QResultClass *res; @@ -410,7 +410,7 @@ CC_abort(ConnectionClass *self) /* This is called by SQLDisconnect also */ char -CC_cleanup(ConnectionClass *self) +CC_cleanup(ConnectionClass * self) { int i; StatementClass *stmt; @@ -466,7 +466,7 @@ CC_cleanup(ConnectionClass *self) int -CC_set_translation(ConnectionClass *self) +CC_set_translation(ConnectionClass * self) { #ifdef WIN32 @@ -510,7 +510,7 @@ CC_set_translation(ConnectionClass *self) char -CC_connect(ConnectionClass *self, char do_password) +CC_connect(ConnectionClass * self, char do_password) { StartupPacket sp; StartupPacket6_2 sp62; @@ -522,9 +522,10 @@ CC_connect(ConnectionClass *self, char do_password) char msgbuffer[ERROR_MSG_LENGTH]; char salt[5]; static char *func = "CC_connect"; + #ifdef MULTIBYTE - char *encoding; -#endif /* MULTIBYTE */ + char *encoding; +#endif /* MULTIBYTE */ mylog("%s: entering...\n", func); @@ -556,7 +557,7 @@ CC_connect(ConnectionClass *self, char do_password) if (encoding && strcmp(encoding, "OTHER")) self->client_encoding = strdup(encoding); else - { + { encoding = check_client_encoding(ci->drivers.conn_settings); if (encoding && strcmp(encoding, "OTHER")) self->client_encoding = strdup(encoding); @@ -588,6 +589,7 @@ CC_connect(ConnectionClass *self, char do_password) mylog("CC_connect(): DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password); another_version_retry: + /* * If the socket was closed for some reason (like a SQLDisconnect, * but no SQLFreeConnect then create a socket now. @@ -673,7 +675,9 @@ another_version_retry: if (!PROTOCOL_62(ci)) { - BOOL before_64 = PG_VERSION_LT(self, 6.4), ReadyForQuery = FALSE; + BOOL before_64 = PG_VERSION_LT(self, 6.4), + ReadyForQuery = FALSE; + do { if (do_password) @@ -693,7 +697,7 @@ another_version_retry: self->errormsg = msgbuffer; qlog("ERROR from backend during authentication: '%s'\n", self->errormsg); if (strncmp(msgbuffer, "Unsupported frontend protocol", 29) == 0) - { /* retry older version */ + { /* retry older version */ if (PROTOCOL_63(ci)) strcpy(ci->protocol, PG62); else @@ -703,7 +707,7 @@ another_version_retry: CC_initialize_pg_version(self); goto another_version_retry; } - + return 0; case 'R': @@ -775,12 +779,12 @@ another_version_retry: return 0; } break; - case 'K': /* Secret key (6.4 protocol) */ - (void) SOCK_get_int(sock, 4); /* pid */ - (void) SOCK_get_int(sock, 4); /* key */ + case 'K': /* Secret key (6.4 protocol) */ + (void) SOCK_get_int(sock, 4); /* pid */ + (void) SOCK_get_int(sock, 4); /* key */ break; - case 'Z': /* Backend is ready for new query (6.4) */ + case 'Z': /* Backend is ready for new query (6.4) */ ReadyForQuery = TRUE; break; default: @@ -789,9 +793,8 @@ another_version_retry: return 0; } - /* - * There were no ReadyForQuery responce - * before 6.4. + /* + * There were no ReadyForQuery responce before 6.4. */ if (before_64 && areq == AUTH_REQ_OK) ReadyForQuery = TRUE; @@ -851,7 +854,7 @@ another_version_retry: char -CC_add_statement(ConnectionClass *self, StatementClass *stmt) +CC_add_statement(ConnectionClass * self, StatementClass * stmt) { int i; @@ -884,7 +887,7 @@ CC_add_statement(ConnectionClass *self, StatementClass *stmt) char -CC_remove_statement(ConnectionClass *self, StatementClass *stmt) +CC_remove_statement(ConnectionClass * self, StatementClass * stmt) { int i; @@ -906,7 +909,7 @@ CC_remove_statement(ConnectionClass *self, StatementClass *stmt) * error message with its socket error message. */ char * -CC_create_errormsg(ConnectionClass *self) +CC_create_errormsg(ConnectionClass * self) { SocketClass *sock = self->sock; int pos; @@ -933,7 +936,7 @@ CC_create_errormsg(ConnectionClass *self) char -CC_get_error(ConnectionClass *self, int *number, char **message) +CC_get_error(ConnectionClass * self, int *number, char **message) { int rv; @@ -971,16 +974,22 @@ CC_get_error(ConnectionClass *self, int *number, char **message) * 'declare cursor C3326857 for ...' and 'fetch 100 in C3326857' statements. */ QResultClass * -CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) +CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi) { - QResultClass *result_in = NULL, *res = NULL, *retres = NULL; - char swallow, *wq; + QResultClass *result_in = NULL, + *res = NULL, + *retres = NULL; + char swallow, + *wq; int id; SocketClass *sock = self->sock; - int maxlen, empty_reqs; - BOOL msg_truncated, ReadyToReturn, - tuples_return = FALSE, query_completed = FALSE, - before_64 = PG_VERSION_LT(self, 6.4); + int maxlen, + empty_reqs; + BOOL msg_truncated, + ReadyToReturn, + tuples_return = FALSE, + query_completed = FALSE, + before_64 = PG_VERSION_LT(self, 6.4); /* ERROR_MSG_LENGTH is suffcient */ static char msgbuffer[ERROR_MSG_LENGTH + 1]; @@ -1095,6 +1104,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) mylog("send_query: returning res = %u\n", res); if (!before_64) break; + /* * (Quotation from the original comments) since * backend may produce more than one result for some @@ -1188,9 +1198,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) CC_set_no_trans(self); } else - { self->errornumber = CONNECTION_SERVER_REPORTED_WARNING; - } QR_set_status(res, PGRES_FATAL_ERROR); QR_set_aborted(res, TRUE); while (msg_truncated) @@ -1232,9 +1240,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) } else { /* next fetch, so reuse an existing result */ + /* - * called from QR_next_tuple - * and must return immediately. + * called from QR_next_tuple and must return + * immediately. */ ReadyToReturn = TRUE; if (!QR_fetch_tuples(result_in, NULL, NULL)) @@ -1275,8 +1284,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) retres = NULL; break; } + /* - * There were no ReadyForQuery response before 6.4. + * There were no ReadyForQuery response before 6.4. */ if (before_64) { @@ -1284,8 +1294,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) break; } } - /* - * Break before being ready to return. + + /* + * Break before being ready to return. */ if (!ReadyToReturn) { @@ -1296,8 +1307,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) else retres = res; } + /* - * set notice message to result_in. + * set notice message to result_in. */ if (result_in && res && retres == result_in) { @@ -1305,8 +1317,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) QR_set_status(result_in, QR_get_status(res)); QR_set_notice(result_in, QR_get_notice(res)); } + /* - * Cleanup garbage results before returning. + * Cleanup garbage results before returning. */ if (res && retres != res) QR_Destructor(res); @@ -1322,7 +1335,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) int -CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *args, int nargs) +CC_send_function(ConnectionClass * self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * args, int nargs) { char id, c, @@ -1474,7 +1487,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_ char -CC_send_settings(ConnectionClass *self) +CC_send_settings(ConnectionClass * self) { /* char ini_query[MAX_MESSAGE_LEN]; */ ConnInfo *ci = &(self->connInfo); @@ -1583,7 +1596,7 @@ CC_send_settings(ConnectionClass *self) * will go away and the define 'PG_TYPE_LO' will be updated. */ void -CC_lookup_lo(ConnectionClass *self) +CC_lookup_lo(ConnectionClass * self) { HSTMT hstmt; StatementClass *stmt; @@ -1635,7 +1648,7 @@ CC_lookup_lo(ConnectionClass *self) * h-inoue 01-2-2001 */ void -CC_initialize_pg_version(ConnectionClass *self) +CC_initialize_pg_version(ConnectionClass * self) { strcpy(self->pg_version, self->connInfo.protocol); if (PROTOCOL_62(&self->connInfo)) @@ -1665,7 +1678,7 @@ CC_initialize_pg_version(ConnectionClass *self) * DJP - 25-1-2001 */ void -CC_lookup_pg_version(ConnectionClass *self) +CC_lookup_pg_version(ConnectionClass * self) { HSTMT hstmt; StatementClass *stmt; @@ -1731,7 +1744,7 @@ CC_lookup_pg_version(ConnectionClass *self) void -CC_log_error(char *func, char *desc, ConnectionClass *self) +CC_log_error(char *func, char *desc, ConnectionClass * self) { #ifdef PRN_NULLCHECK #define nullcheck(a) (a ? a : "(NULL)") @@ -1760,17 +1773,19 @@ CC_log_error(char *func, char *desc, ConnectionClass *self) #undef PRN_NULLCHECK } -int CC_get_max_query_len(const ConnectionClass *conn) +int +CC_get_max_query_len(const ConnectionClass * conn) { - int value; - /* Long Queries in 7.0+ */ - if (PG_VERSION_GE(conn, 7.0)) - value = 0 /* MAX_STATEMENT_LEN */; - /* Prior to 7.0 we used 2*BLCKSZ */ - else if (PG_VERSION_GE(conn, 6.5)) - value = (2 * BLCKSZ); - else - /* Prior to 6.5 we used BLCKSZ */ - value = BLCKSZ; - return value; + int value; + + /* Long Queries in 7.0+ */ + if (PG_VERSION_GE(conn, 7.0)) + value = 0 /* MAX_STATEMENT_LEN */ ; + /* Prior to 7.0 we used 2*BLCKSZ */ + else if (PG_VERSION_GE(conn, 6.5)) + value = (2 * BLCKSZ); + else + /* Prior to 6.5 we used BLCKSZ */ + value = BLCKSZ; + return value; } diff --git a/src/interfaces/odbc/connection.h b/src/interfaces/odbc/connection.h index 505325ad68..782fb0e4d1 100644 --- a/src/interfaces/odbc/connection.h +++ b/src/interfaces/odbc/connection.h @@ -17,13 +17,14 @@ typedef enum { - CONN_NOT_CONNECTED, /* Connection has not been established */ - CONN_CONNECTED, /* Connection is up and has been + CONN_NOT_CONNECTED, /* Connection has not been + * established */ + CONN_CONNECTED, /* Connection is up and has been * established */ - CONN_DOWN, /* Connection is broken */ - CONN_EXECUTING /* the connection is currently executing a + CONN_DOWN, /* Connection is broken */ + CONN_EXECUTING /* the connection is currently executing a * statement */ -} CONN_Status; +} CONN_Status; /* These errors have general sql error state */ #define CONNECTION_SERVER_NOT_REACHED 101 @@ -151,8 +152,8 @@ typedef struct char focus_password; char disallow_premature; char updatable_cursors; - GLOBAL_VALUES drivers; /* moved from driver's option */ -} ConnInfo; + GLOBAL_VALUES drivers; /* moved from driver's option */ +} ConnInfo; /* Macro to determine is the connection using 6.2 protocol? */ #define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0) @@ -212,27 +213,27 @@ struct col_info #define HINSTANCE void * #endif -typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD, - SWORD, - PTR, - SDWORD, - PTR, - SDWORD, - SDWORD FAR *, - UCHAR FAR *, - SWORD, - SWORD FAR *); - -typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD, - SWORD, - PTR, - SDWORD, - PTR, - SDWORD, - SDWORD FAR *, - UCHAR FAR *, - SWORD, - SWORD FAR *); +typedef BOOL(FAR WINAPI * DataSourceToDriverProc) (UDWORD, + SWORD, + PTR, + SDWORD, + PTR, + SDWORD, + SDWORD FAR *, + UCHAR FAR *, + SWORD, + SWORD FAR *); + +typedef BOOL(FAR WINAPI * DriverToDataSourceProc) (UDWORD, + SWORD, + PTR, + SDWORD, + PTR, + SDWORD, + SDWORD FAR *, + UCHAR FAR *, + SWORD, + SWORD FAR *); /******* The Connection handle ************/ struct ConnectionClass_ @@ -267,9 +268,9 @@ struct ConnectionClass_ Int2 pg_version_minor; char ms_jet; #ifdef MULTIBYTE - char *client_encoding; - char *server_encoding; -#endif /* MULTIBYTE */ + char *client_encoding; + char *server_encoding; +#endif /* MULTIBYTE */ }; @@ -289,24 +290,23 @@ struct ConnectionClass_ /* prototypes */ ConnectionClass *CC_Constructor(void); -char CC_Destructor(ConnectionClass *self); -int CC_cursor_count(ConnectionClass *self); -char CC_cleanup(ConnectionClass *self); -char CC_abort(ConnectionClass *self); -int CC_set_translation(ConnectionClass *self); -char CC_connect(ConnectionClass *self, char do_password); -char CC_add_statement(ConnectionClass *self, StatementClass *stmt); -char CC_remove_statement(ConnectionClass *self, StatementClass *stmt); -char CC_get_error(ConnectionClass *self, int *number, char **message); -QResultClass *CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi); -void CC_clear_error(ConnectionClass *self); -char *CC_create_errormsg(ConnectionClass *self); -int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs); -char CC_send_settings(ConnectionClass *self); -void CC_lookup_lo(ConnectionClass *conn); -void CC_lookup_pg_version(ConnectionClass *conn); -void CC_initialize_pg_version(ConnectionClass *conn); -void CC_log_error(char *func, char *desc, ConnectionClass *self); -int CC_get_max_query_len(const ConnectionClass *self); - +char CC_Destructor(ConnectionClass * self); +int CC_cursor_count(ConnectionClass * self); +char CC_cleanup(ConnectionClass * self); +char CC_abort(ConnectionClass * self); +int CC_set_translation(ConnectionClass * self); +char CC_connect(ConnectionClass * self, char do_password); +char CC_add_statement(ConnectionClass * self, StatementClass * stmt); +char CC_remove_statement(ConnectionClass * self, StatementClass * stmt); +char CC_get_error(ConnectionClass * self, int *number, char **message); +QResultClass *CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi); +void CC_clear_error(ConnectionClass * self); +char *CC_create_errormsg(ConnectionClass * self); +int CC_send_function(ConnectionClass * conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * argv, int nargs); +char CC_send_settings(ConnectionClass * self); +void CC_lookup_lo(ConnectionClass * conn); +void CC_lookup_pg_version(ConnectionClass * conn); +void CC_initialize_pg_version(ConnectionClass * conn); +void CC_log_error(char *func, char *desc, ConnectionClass * self); +int CC_get_max_query_len(const ConnectionClass * self); #endif diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c index 2afc079dfd..aae290970c 100644 --- a/src/interfaces/odbc/convert.c +++ b/src/interfaces/odbc/convert.c @@ -1,5 +1,5 @@ /*------- - * Module: convert.c + * Module: convert.c * * Description: This module contains routines related to * converting parameters and columns into requested data types. @@ -111,10 +111,10 @@ char *mapFuncs[][2] = { {0, 0} }; -static char *mapFunction(const char *func); +static char *mapFunction(const char *func); static unsigned int conv_from_octal(const unsigned char *s); static unsigned int conv_from_hex(const unsigned char *s); -static char *conv_to_octal(unsigned char val); +static char *conv_to_octal(unsigned char val); /*--------- * A Guide for date/time/timestamp conversions @@ -138,7 +138,7 @@ static char *conv_to_octal(unsigned char val); /* This is called by SQLFetch() */ int -copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col) +copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col) { BindInfoClass *bic = &(stmt->bindings[col]); @@ -149,8 +149,8 @@ copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *val /* This is called by SQLGetData() */ int -copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType, - PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue) +copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType, + PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue) { Int4 len = 0, copy_len = 0; @@ -160,16 +160,16 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 int pcbValueOffset, rgbValueOffset; char *rgbValueBindRow; - const char *ptr; + const char *ptr; int bind_row = stmt->bind_row; int bind_size = stmt->options.bind_size; int result = COPY_OK; BOOL changed; - static char *tempBuf= NULL; - static unsigned int tempBuflen = 0; + static char *tempBuf = NULL; + static unsigned int tempBuflen = 0; const char *neut_str = value; - char midtemp[2][32]; - int mtemp_cnt = 0; + char midtemp[2][32]; + int mtemp_cnt = 0; if (!tempBuf) tempBuflen = 0; @@ -200,7 +200,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 if (!value) { - /* * handle a null just by returning SQL_NULL_DATA in pcbValue, and * doing nothing to the buffer. @@ -229,7 +228,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 */ switch (field_type) { - /* * $$$ need to add parsing for date/time/timestamp strings in * PG_TYPE_CHAR,VARCHAR $$$ @@ -249,7 +247,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &st.y, &st.m, &st.d, &st.hh, &st.mm, &st.ss); else { - /* * The timestamp is invalid so set something conspicuous, * like the epoch @@ -266,7 +263,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 break; case PG_TYPE_BOOL: - { /* change T/F to 1/0 */ + { /* change T/F to 1/0 */ char *s; s = midtemp[mtemp_cnt]; @@ -287,7 +284,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 { int nval, i; - const char *vp; + const char *vp; /* this is an array of eight integers */ short *short_array = (short *) ((char *) rgbValue + rgbValueOffset); @@ -425,12 +422,14 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 default: if (stmt->current_col >= 0 && stmt->bindings[stmt->current_col].data_left == -2) - stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be needed for ADO ? */ + stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be + * needed for ADO ? */ if (stmt->current_col < 0 || stmt->bindings[stmt->current_col].data_left < 0) { /* convert linefeeds to carriage-return/linefeed */ len = convert_linefeeds(neut_str, NULL, 0, &changed); - if (cbValueMax == 0) /* just returns length info */ + if (cbValueMax == 0) /* just returns length + * info */ { result = COPY_RESULT_TRUNCATED; break; @@ -519,7 +518,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 } else { - /* * for SQL_C_CHAR, it's probably ok to leave currency symbols in. * But to convert to numeric types, it is necessary to get rid of @@ -595,8 +593,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 *((UCHAR *) rgbValue + bind_row) = atoi(neut_str); /* - * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, rgb=%d\n", - * bind_row, atoi(neut_str), cbValueMax, *((UCHAR *)rgbValue)); + * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, + * rgb=%d\n", bind_row, atoi(neut_str), cbValueMax, + * *((UCHAR *)rgbValue)); */ break; @@ -751,14 +750,15 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 * Functions/Macros to get rid of query size limit. * * I always used the follwoing macros to convert from - * old_statement to new_statement. Please improve it + * old_statement to new_statement. Please improve it * if you have a better way. Hiroshi 2001/05/22 *-------------------------------------------------------------------- */ -#define INIT_MIN_ALLOC 4096 -static int enlarge_statement(StatementClass *stmt, unsigned int newsize) +#define INIT_MIN_ALLOC 4096 +static int +enlarge_statement(StatementClass * stmt, unsigned int newsize) { - unsigned int newalsize = INIT_MIN_ALLOC; + unsigned int newalsize = INIT_MIN_ALLOC; static char *func = "enlarge_statement"; if (stmt->stmt_size_limit > 0 && stmt->stmt_size_limit < (int) newsize) @@ -784,7 +784,7 @@ static int enlarge_statement(StatementClass *stmt, unsigned int newsize) * Enlarge stmt_with_params if necessary. *---------- */ -#define ENLARGE_NEWSTATEMENT(newpos) \ +#define ENLARGE_NEWSTATEMENT(newpos) \ if (newpos >= new_stsize) \ { \ if ((new_stsize = enlarge_statement(stmt, newpos)) <= 0) \ @@ -795,7 +795,7 @@ static int enlarge_statement(StatementClass *stmt, unsigned int newsize) * Initialize stmt_with_params, new_statement etc. *---------- */ -#define CVT_INIT(size) \ +#define CVT_INIT(size) \ do { \ if (stmt->stmt_with_params) \ free(stmt->stmt_with_params); \ @@ -817,7 +817,7 @@ do { \ * Terminate the stmt_with_params string with NULL. *---------- */ -#define CVT_TERMINATE \ +#define CVT_TERMINATE \ do { \ new_statement[npos] = '\0'; \ } while (0) @@ -826,7 +826,7 @@ do { \ * Append a data. *---------- */ -#define CVT_APPEND_DATA(s, len) \ +#define CVT_APPEND_DATA(s, len) \ do { \ unsigned int newpos = npos + len; \ ENLARGE_NEWSTATEMENT(newpos) \ @@ -839,17 +839,17 @@ do { \ * Append a string. *---------- */ -#define CVT_APPEND_STR(s) \ +#define CVT_APPEND_STR(s) \ do { \ unsigned int len = strlen(s); \ CVT_APPEND_DATA(s, len); \ } while (0) /*---------- - * Append a char. + * Append a char. *---------- */ -#define CVT_APPEND_CHAR(c) \ +#define CVT_APPEND_CHAR(c) \ do { \ ENLARGE_NEWSTATEMENT(npos + 1); \ new_statement[npos++] = c; \ @@ -857,10 +857,10 @@ do { \ /*---------- * Append a binary data. - * Newly reqeuired size may be overestimated currently. + * Newly reqeuired size may be overestimated currently. *---------- */ -#define CVT_APPEND_BINARY(buf, used) \ +#define CVT_APPEND_BINARY(buf, used) \ do { \ unsigned int newlimit = npos + 5 * used; \ ENLARGE_NEWSTATEMENT(newlimit); \ @@ -871,9 +871,9 @@ do { \ * *---------- */ -#define CVT_SPECIAL_CHARS(buf, used) \ +#define CVT_SPECIAL_CHARS(buf, used) \ do { \ - int cnvlen = convert_special_chars(buf, NULL, used); \ + int cnvlen = convert_special_chars(buf, NULL, used); \ unsigned int newlimit = npos + cnvlen; \ \ ENLARGE_NEWSTATEMENT(newlimit); \ @@ -882,10 +882,10 @@ do { \ } while (0) /*---------- - * Check if the statement is + * Check if the statement is * SELECT ... INTO table FROM ..... * This isn't really a strict check but ... - *---------- + *---------- */ static BOOL into_table_from(const char *stmt) @@ -902,15 +902,14 @@ into_table_from(const char *stmt) case ',': case '\'': return FALSE; - case '\"': /* double quoted table name ? */ + case '\"': /* double quoted table name ? */ do { do - { - while (*(++stmt) != '\"' && *stmt); - } + while (*(++stmt) != '\"' && *stmt); while (*stmt && *(++stmt) == '\"'); - while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"') stmt++; + while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"') + stmt++; } while (*stmt == '\"'); break; @@ -918,7 +917,7 @@ into_table_from(const char *stmt) while (!isspace((unsigned char) *(++stmt))); break; } - if (! *stmt) + if (!*stmt) return FALSE; while (isspace((unsigned char) *(++stmt))); if (strnicmp(stmt, "from", 4)) @@ -927,17 +926,18 @@ into_table_from(const char *stmt) } /*---------- - * Check if the statement is + * Check if the statement is * SELECT ... FOR UPDATE ..... * This isn't really a strict check but ... - *---------- + *---------- */ static BOOL table_for_update(const char *stmt, int *endpos) { const char *wstmt = stmt; + while (isspace((unsigned char) *(++wstmt))); - if (! *wstmt) + if (!*wstmt) return FALSE; if (strnicmp(wstmt, "update", 6)) return FALSE; @@ -952,7 +952,7 @@ table_for_update(const char *stmt, int *endpos) * This function does a dynamic memory allocation to get rid of query size limit! */ int -copy_statement_with_parameters(StatementClass *stmt) +copy_statement_with_parameters(StatementClass * stmt) { static char *func = "copy_statement_with_parameters"; unsigned int opos, @@ -960,34 +960,43 @@ copy_statement_with_parameters(StatementClass *stmt) oldstmtlen; char param_string[128], tmp[256], - cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to handle the data in this function */ + cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to + * handle the data in + * this function */ int param_number; Int2 param_ctype, param_sqltype; - char *old_statement = stmt->statement, oldchar; + char *old_statement = stmt->statement, + oldchar; char *new_statement = stmt->stmt_with_params; - unsigned int new_stsize = 0; + unsigned int new_stsize = 0; SIMPLE_TIME st; time_t t = time(NULL); struct tm *tim; SDWORD used; - char *buffer, *buf; - BOOL in_quote = FALSE, in_dquote = FALSE, in_escape = FALSE; + char *buffer, + *buf; + BOOL in_quote = FALSE, + in_dquote = FALSE, + in_escape = FALSE; Oid lobj_oid; int lobj_fd, retval; - BOOL check_cursor_ok = FALSE; /* check cursor restriction */ - BOOL proc_no_param = TRUE; - unsigned int declare_pos = 0; - ConnectionClass *conn = SC_get_conn(stmt); - ConnInfo *ci = &(conn->connInfo); - BOOL prepare_dummy_cursor = FALSE, begin_first = FALSE; - char token_save[64]; - int token_len; - BOOL prev_token_end; + BOOL check_cursor_ok = FALSE; /* check cursor + * restriction */ + BOOL proc_no_param = TRUE; + unsigned int declare_pos = 0; + ConnectionClass *conn = SC_get_conn(stmt); + ConnInfo *ci = &(conn->connInfo); + BOOL prepare_dummy_cursor = FALSE, + begin_first = FALSE; + char token_save[64]; + int token_len; + BOOL prev_token_end; + #ifdef DRIVER_CURSOR_IMPLEMENT - BOOL search_from_pos = FALSE; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + BOOL search_from_pos = FALSE; +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (ci->disallow_premature) prepare_dummy_cursor = stmt->pre_executing; @@ -1012,7 +1021,7 @@ copy_statement_with_parameters(StatementClass *stmt) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; } else if (stmt->options.cursor_type == SQL_CURSOR_FORWARD_ONLY) - stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; + stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) { if (stmt->parse_status == STMT_PARSE_NONE) @@ -1020,11 +1029,11 @@ copy_statement_with_parameters(StatementClass *stmt) if (stmt->parse_status != STMT_PARSE_COMPLETE) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (!stmt->ti || stmt->ntab != 1) - stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; + stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else search_from_pos = TRUE; } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* If the application hasn't set a cursor name, then generate one */ if (stmt->cursor_name[0] == '\0') @@ -1052,7 +1061,7 @@ copy_statement_with_parameters(StatementClass *stmt) else if (ci->drivers.use_declarefetch) SC_set_fetchcursor(stmt); sprintf(new_statement, "%sdeclare %s cursor for ", - new_statement, stmt->cursor_name); + new_statement, stmt->cursor_name); npos = strlen(new_statement); check_cursor_ok = TRUE; declare_pos = npos; @@ -1072,18 +1081,18 @@ copy_statement_with_parameters(StatementClass *stmt) CVT_APPEND_CHAR(oldchar); continue; } + /* - * From here we are guaranteed to handle a - * 1-byte character. + * From here we are guaranteed to handle a 1-byte character. */ #endif - if (in_escape) /* escape check */ + if (in_escape) /* escape check */ { in_escape = FALSE; CVT_APPEND_CHAR(oldchar); continue; - } + } else if (in_quote || in_dquote) /* quote/double quote check */ { if (oldchar == '\\') @@ -1093,16 +1102,18 @@ copy_statement_with_parameters(StatementClass *stmt) else if (oldchar == '\"' && in_dquote) in_dquote = FALSE; CVT_APPEND_CHAR(oldchar); - continue; + continue; } + /* - * From here we are guranteed to be in neither - * an escape, a quote nor a double quote. + * From here we are guranteed to be in neither an escape, a quote + * nor a double quote. */ /* Squeeze carriage-return/linefeed pairs to linefeed only */ else if (oldchar == '\r' && opos + 1 < oldstmtlen && - old_statement[opos + 1] == '\n') + old_statement[opos + 1] == '\n') continue; + /* * Handle literals (date, time, timestamp) and ODBC scalar * functions @@ -1117,7 +1128,6 @@ copy_statement_with_parameters(StatementClass *stmt) #else char *end = strchr(begin, '}'); - #endif if (!end) @@ -1125,7 +1135,8 @@ copy_statement_with_parameters(StatementClass *stmt) /* procedure calls */ if (stmt->statement_type == STMT_TYPE_PROCCALL) { - int lit_call_len = 4; + int lit_call_len = 4; + while (isspace((unsigned char) old_statement[++opos])); /* '=?' to accept return values exists ? */ if (old_statement[opos] == '?') @@ -1145,23 +1156,21 @@ copy_statement_with_parameters(StatementClass *stmt) opos--; continue; } - opos += lit_call_len; + opos += lit_call_len; CVT_APPEND_STR("SELECT "); #ifdef MULTIBYTE if (multibyte_strchr(&old_statement[opos], '(')) #else if (strchr(&old_statement[opos], '(')) -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ proc_no_param = FALSE; - continue; + continue; } *end = '\0'; esc = convert_escape(begin); if (esc) - { CVT_APPEND_STR(esc); - } else { /* it's not a valid literal so just copy */ *end = '}'; @@ -1196,7 +1205,7 @@ copy_statement_with_parameters(StatementClass *stmt) in_escape = TRUE; else if (oldchar == '\"') in_dquote = TRUE; - else + else { if (isspace(oldchar)) { @@ -1207,7 +1216,7 @@ copy_statement_with_parameters(StatementClass *stmt) if (token_len == 4) { if (check_cursor_ok && - into_table_from(&old_statement[opos - token_len])) + into_table_from(&old_statement[opos - token_len])) { stmt->statement_type = STMT_TYPE_CREATE; SC_no_pre_executable(stmt); @@ -1218,20 +1227,21 @@ copy_statement_with_parameters(StatementClass *stmt) } #ifdef DRIVER_CURSOR_IMPLEMENT else if (search_from_pos && /* where's from clause */ - strnicmp(token_save, "from", 4) == 0) + strnicmp(token_save, "from", 4) == 0) { search_from_pos = FALSE; npos -= 5; CVT_APPEND_STR(", CTID, OID from"); } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ } if (token_len == 3) { - int endpos; + int endpos; + if (check_cursor_ok && - strnicmp(token_save, "for", 3) == 0 && - table_for_update(&old_statement[opos], &endpos)) + strnicmp(token_save, "for", 3) == 0 && + table_for_update(&old_statement[opos], &endpos)) { SC_no_fetchcursor(stmt); stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1247,7 +1257,7 @@ copy_statement_with_parameters(StatementClass *stmt) } } } - } + } } else if (prev_token_end) { @@ -1257,7 +1267,7 @@ copy_statement_with_parameters(StatementClass *stmt) } else if (token_len + 1 < sizeof(token_save)) token_save[token_len++] = oldchar; - } + } CVT_APPEND_CHAR(oldchar); continue; } @@ -1290,10 +1300,10 @@ copy_statement_with_parameters(StatementClass *stmt) } else { - - + + used = stmt->parameters[param_number].used ? *stmt->parameters[param_number].used : SQL_NTS; - + buffer = stmt->parameters[param_number].buffer; } @@ -1457,15 +1467,11 @@ copy_statement_with_parameters(StatementClass *stmt) /* it was a SQL_C_CHAR */ if (buf) - { CVT_SPECIAL_CHARS(buf, used); - } /* it was a numeric type */ else if (param_string[0] != '\0') - { CVT_APPEND_STR(param_string); - } /* it was date,time,timestamp -- use m,d,y,hh,mm,ss */ else @@ -1694,19 +1700,20 @@ copy_statement_with_parameters(StatementClass *stmt) int length = strlen(new_statement); conn->DriverToDataSource(conn->translation_option, - SQL_CHAR, - new_statement, length, - new_statement, length, NULL, - NULL, 0, NULL); + SQL_CHAR, + new_statement, length, + new_statement, length, NULL, + NULL, 0, NULL); } #ifdef DRIVER_CURSOR_IMPLEMENT if (search_from_pos) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (prepare_dummy_cursor && SC_is_pre_executable(stmt)) { - char fetchstr[128]; + char fetchstr[128]; + sprintf(fetchstr, ";fetch backward in %s;close %s;", stmt->cursor_name, stmt->cursor_name); if (begin_first && CC_is_in_autocommit(conn)) @@ -1765,7 +1772,6 @@ convert_escape(char *value) } else if (strcmp(key, "fn") == 0) { - /* * Function invocation Separate off the func name, skipping * trailing whitespace. @@ -1796,8 +1802,8 @@ convert_escape(char *value) mapFunc = mapFunction(key); /* - * We could have mapFunction() return key if not in table... - * - thomas 2000-04-03 + * We could have mapFunction() return key if not in table... - + * thomas 2000-04-03 */ if (mapFunc == NULL) { @@ -1822,7 +1828,8 @@ convert_escape(char *value) BOOL convert_money(const char *s, char *sout, size_t soutmax) { - size_t i = 0, out = 0; + size_t i = 0, + out = 0; for (i = 0; s[i]; i++) { @@ -1831,7 +1838,7 @@ convert_money(const char *s, char *sout, size_t soutmax) else { if (out + 1 >= soutmax) - return FALSE; /* sout is too short */ + return FALSE; /* sout is too short */ if (s[i] == '(') sout[out++] = '-'; else @@ -1848,7 +1855,7 @@ convert_money(const char *s, char *sout, size_t soutmax) * It does not zero out SIMPLE_TIME in case it is desired to initialize it with a value */ char -parse_datetime(char *buf, SIMPLE_TIME *st) +parse_datetime(char *buf, SIMPLE_TIME * st) { int y, m, @@ -1915,7 +1922,7 @@ parse_datetime(char *buf, SIMPLE_TIME *st) /* Change linefeed to carriage-return/linefeed */ int -convert_linefeeds(const char *si, char *dst, size_t max, BOOL *changed) +convert_linefeeds(const char *si, char *dst, size_t max, BOOL * changed) { size_t i = 0, out = 0; @@ -2069,7 +2076,8 @@ conv_from_hex(const unsigned char *s) int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax) { - size_t i, ilen = strlen(value); + size_t i, + ilen = strlen(value); int o = 0; @@ -2148,7 +2156,8 @@ convert_to_pgbinary(const unsigned char *in, char *out, int len) void encode(const char *in, char *out) { - unsigned int i, ilen = strlen(in), + unsigned int i, + ilen = strlen(in), o = 0; for (i = 0; i < ilen; i++) @@ -2175,7 +2184,8 @@ encode(const char *in, char *out) void decode(const char *in, char *out) { - unsigned int i, ilen = strlen(in), + unsigned int i, + ilen = strlen(in), o = 0; for (i = 0; i < ilen; i++) @@ -2211,16 +2221,16 @@ decode(const char *in, char *out) *------- */ int -convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue, - SDWORD cbValueMax, SDWORD *pcbValue) +convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue, + SDWORD cbValueMax, SDWORD * pcbValue) { Oid oid; int retval, result, left = -1; BindInfoClass *bindInfo = NULL; - ConnectionClass *conn = SC_get_conn(stmt); - ConnInfo *ci = &(conn->connInfo); + ConnectionClass *conn = SC_get_conn(stmt); + ConnInfo *ci = &(conn->connInfo); /* If using SQLGetData, then current_col will be set */ if (stmt->current_col >= 0) diff --git a/src/interfaces/odbc/convert.h b/src/interfaces/odbc/convert.h index 33df7ddd71..9ef3dffa64 100644 --- a/src/interfaces/odbc/convert.h +++ b/src/interfaces/odbc/convert.h @@ -27,25 +27,24 @@ typedef struct int hh; int mm; int ss; -} SIMPLE_TIME; +} SIMPLE_TIME; -int copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col); -int copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType, - PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue); +int copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col); +int copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType, + PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue); -int copy_statement_with_parameters(StatementClass *stmt); +int copy_statement_with_parameters(StatementClass * stmt); char *convert_escape(char *value); -BOOL convert_money(const char *s, char *sout, size_t soutmax); -char parse_datetime(char *buf, SIMPLE_TIME *st); -int convert_linefeeds(const char *s, char *dst, size_t max, BOOL *changed); -int convert_special_chars(const char *si, char *dst, int used); +BOOL convert_money(const char *s, char *sout, size_t soutmax); +char parse_datetime(char *buf, SIMPLE_TIME * st); +int convert_linefeeds(const char *s, char *dst, size_t max, BOOL * changed); +int convert_special_chars(const char *si, char *dst, int used); int convert_pgbinary_to_char(const char *value, char *rgbValue, int cbValueMax); int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax); int convert_to_pgbinary(const unsigned char *in, char *out, int len); void encode(const char *in, char *out); void decode(const char *in, char *out); -int convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue, - SDWORD cbValueMax, SDWORD *pcbValue); - +int convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue, + SDWORD cbValueMax, SDWORD * pcbValue); #endif diff --git a/src/interfaces/odbc/dlg_specific.c b/src/interfaces/odbc/dlg_specific.c index e67a1dc020..d395e9a35e 100644 --- a/src/interfaces/odbc/dlg_specific.c +++ b/src/interfaces/odbc/dlg_specific.c @@ -37,17 +37,17 @@ #endif extern GLOBAL_VALUES globals; + #ifdef WIN32 -static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable); -static int driver_options_update(HWND hdlg, ConnInfo *ci, BOOL); -static void updateCommons(const ConnInfo *ci); +static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable); +static int driver_options_update(HWND hdlg, ConnInfo * ci, BOOL); +static void updateCommons(const ConnInfo * ci); #endif #ifdef WIN32 void -SetDlgStuff(HWND hdlg, const ConnInfo *ci) +SetDlgStuff(HWND hdlg, const ConnInfo * ci) { - /* * If driver attribute NOT present, then set the datasource name and * description @@ -67,7 +67,7 @@ SetDlgStuff(HWND hdlg, const ConnInfo *ci) void -GetDlgStuff(HWND hdlg, ConnInfo *ci) +GetDlgStuff(HWND hdlg, ConnInfo * ci) { GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc)); @@ -80,21 +80,21 @@ GetDlgStuff(HWND hdlg, ConnInfo *ci) static int -driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable) +driver_optionsDraw(HWND hdlg, const ConnInfo * ci, int src, BOOL enable) { - const GLOBAL_VALUES *comval; - static BOOL defset = FALSE; - static GLOBAL_VALUES defval; - + const GLOBAL_VALUES *comval; + static BOOL defset = FALSE; + static GLOBAL_VALUES defval; + switch (src) { - case 0: /* driver common */ + case 0: /* driver common */ comval = &globals; break; - case 1: /* dsn specific */ + case 1: /* dsn specific */ comval = &(ci->drivers); break; - case 2: /* default */ + case 2: /* default */ if (!defset) { defval.commlog = DEFAULT_COMMLOG; @@ -164,9 +164,9 @@ driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable) return 0; } static int -driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile) +driver_options_update(HWND hdlg, ConnInfo * ci, BOOL updateProfile) { - GLOBAL_VALUES *comval; + GLOBAL_VALUES *comval; if (ci) comval = &(ci->drivers); @@ -204,7 +204,7 @@ driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile) comval->fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE); comval->max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE); comval->max_longvarchar_size = GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for - * SQL_NO_TOTAL */ + * SQL_NO_TOTAL */ GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, sizeof(comval->extra_systable_prefixes)); @@ -225,17 +225,16 @@ driver_optionsProc(HWND hdlg, WPARAM wParam, LPARAM lParam) { - ConnInfo *ci; + ConnInfo *ci; + switch (wMsg) { case WM_INITDIALOG: - SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */ + SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */ ci = (ConnInfo *) lParam; CheckDlgButton(hdlg, DRV_OR_DSN, 0); if (ci && ci->dsn && ci->dsn[0]) - { SetWindowText(hdlg, "Advanced Options (per DSN)"); - } else { SetWindowText(hdlg, "Advanced Options (Connection)"); @@ -250,7 +249,7 @@ driver_optionsProc(HWND hdlg, case IDOK: ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); driver_options_update(hdlg, IsDlgButtonChecked(hdlg, DRV_OR_DSN) ? NULL : ci, - ci && ci->dsn && ci->dsn[0]); + ci && ci->dsn && ci->dsn[0]); case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); @@ -262,6 +261,7 @@ driver_optionsProc(HWND hdlg, else { ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); + driver_optionsDraw(hdlg, ci, 0, FALSE); } break; @@ -278,6 +278,7 @@ driver_optionsProc(HWND hdlg, else { ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); + SetWindowText(hdlg, "Advanced Options (per DSN)"); driver_optionsDraw(hdlg, ci, ci ? 1 : 0, ci == NULL); } @@ -390,11 +391,11 @@ ds_optionsProc(HWND hdlg, * to the ODBCINST.INI portion of the registry */ static void -updateCommons(const ConnInfo *ci) +updateCommons(const ConnInfo * ci) { - const char *sectionName; - const char *fileName; - const GLOBAL_VALUES *comval; + const char *sectionName; + const char *fileName; + const GLOBAL_VALUES *comval; char tmp[128]; if (ci) @@ -409,7 +410,7 @@ updateCommons(const ConnInfo *ci) { mylog("ci but dsn==NULL\n"); return; - } + } else { mylog("drivers updating\n"); @@ -437,14 +438,16 @@ updateCommons(const ConnInfo *ci) SQLWritePrivateProfileString(sectionName, INI_KSQO, tmp, fileName); - /* Never update the onlyread, unique_index from this module - sprintf(tmp, "%d", comval->unique_index); - SQLWritePrivateProfileString(sectionName, - INI_UNIQUEINDEX, tmp, fileName); - - sprintf(tmp, "%d", comval->onlyread); - SQLWritePrivateProfileString(sectionName, - INI_READONLY, tmp, fileName);*/ + /* + * Never update the onlyread, unique_index from this module + * sprintf(tmp, "%d", comval->unique_index); + * SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, + * fileName); + * + * sprintf(tmp, "%d", comval->onlyread); + * SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp, + * fileName); + */ sprintf(tmp, "%d", comval->use_declarefetch); SQLWritePrivateProfileString(sectionName, @@ -456,11 +459,11 @@ updateCommons(const ConnInfo *ci) sprintf(tmp, "%d", comval->text_as_longvarchar); SQLWritePrivateProfileString(sectionName, - INI_TEXTASLONGVARCHAR, tmp, fileName); + INI_TEXTASLONGVARCHAR, tmp, fileName); sprintf(tmp, "%d", comval->unknowns_as_longvarchar); SQLWritePrivateProfileString(sectionName, - INI_UNKNOWNSASLONGVARCHAR, tmp, fileName); + INI_UNKNOWNSASLONGVARCHAR, tmp, fileName); sprintf(tmp, "%d", comval->bools_as_char); SQLWritePrivateProfileString(sectionName, @@ -480,20 +483,22 @@ updateCommons(const ConnInfo *ci) sprintf(tmp, "%d", comval->max_longvarchar_size); SQLWritePrivateProfileString(sectionName, - INI_MAXLONGVARCHARSIZE, tmp, fileName); + INI_MAXLONGVARCHARSIZE, tmp, fileName); SQLWritePrivateProfileString(sectionName, - INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName); + INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName); - /* Never update the conn_setting from this module - SQLWritePrivateProfileString(sectionName, - INI_CONNSETTINGS, comval->conn_settings, fileName); */ + /* + * Never update the conn_setting from this module + * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS, + * comval->conn_settings, fileName); + */ } #endif /* WIN32 */ void -makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) +makeConnectString(char *connect_string, const ConnInfo * ci, UWORD len) { char got_dsn = (ci->dsn[0] != '\0'); char encoded_conn_settings[LARGE_REGISTRY_LEN]; @@ -516,62 +521,62 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) hlen = strlen(connect_string); if (!abbrev) sprintf(&connect_string[hlen], - ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s", - ci->onlyread, - ci->protocol, - ci->fake_oid_index, - ci->show_oid_column, - ci->row_versioning, - ci->show_system_tables, - encoded_conn_settings, - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s", + ci->onlyread, + ci->protocol, + ci->fake_oid_index, + ci->show_oid_column, + ci->row_versioning, + ci->show_system_tables, + encoded_conn_settings, + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); /* Abbrebiation is needed ? */ if (abbrev || strlen(connect_string) >= len) sprintf(&connect_string[hlen], - ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", - ci->onlyread, - ci->protocol, - ci->fake_oid_index, - ci->show_oid_column, - ci->row_versioning, - ci->show_system_tables, - encoded_conn_settings, - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", + ci->onlyread, + ci->protocol, + ci->fake_oid_index, + ci->show_oid_column, + ci->row_versioning, + ci->show_system_tables, + encoded_conn_settings, + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); } void -copyAttributes(ConnInfo *ci, const char *attribute, const char *value) +copyAttributes(ConnInfo * ci, const char *attribute, const char *value) { if (stricmp(attribute, "DSN") == 0) strcpy(ci->dsn, value); @@ -618,19 +623,15 @@ copyAttributes(ConnInfo *ci, const char *attribute, const char *value) /* strcpy(ci->conn_settings, value); */ } else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0) - { ci->disallow_premature = atoi(value); - } else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0) - { ci->updatable_cursors = atoi(value); - } mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature); } void -copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) +copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value) { if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0) ci->drivers.fetch_max = atoi(value); @@ -644,10 +645,12 @@ copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) ci->drivers.disable_optimizer = atoi(value); else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0) ci->drivers.ksqo = atoi(value); + /* - else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || stricmp(attribute, "UIX") == 0) - ci->drivers.unique_index = atoi(value); - */ + * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || + * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index = + * atoi(value); + */ else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0) ci->drivers.unknown_sizes = atoi(value); else if (stricmp(attribute, INI_LIE) == 0) @@ -671,27 +674,27 @@ copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0) strcpy(ci->drivers.extra_systable_prefixes, value); mylog("CopyCommonAttributes: A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); } void -getDSNdefaults(ConnInfo *ci) +getDSNdefaults(ConnInfo * ci) { if (ci->port[0] == '\0') strcpy(ci->port, DEFAULT_PORT); @@ -717,11 +720,11 @@ getDSNdefaults(ConnInfo *ci) void -getDSNinfo(ConnInfo *ci, char overwrite) +getDSNinfo(ConnInfo * ci, char overwrite) { char *DSN = ci->dsn; char encoded_conn_settings[LARGE_REGISTRY_LEN], - temp[SMALL_REGISTRY_LEN]; + temp[SMALL_REGISTRY_LEN]; /* * If a driver keyword was present, then dont use a DSN and return. @@ -837,11 +840,11 @@ getDSNinfo(ConnInfo *ci, char overwrite) /* This is for datasource based options only */ void -writeDSNinfo(const ConnInfo *ci) +writeDSNinfo(const ConnInfo * ci) { - const char *DSN = ci->dsn; + const char *DSN = ci->dsn; char encoded_conn_settings[LARGE_REGISTRY_LEN], - temp[SMALL_REGISTRY_LEN]; + temp[SMALL_REGISTRY_LEN]; encode(ci->conn_settings, encoded_conn_settings); @@ -910,12 +913,12 @@ writeDSNinfo(const ConnInfo *ci) encoded_conn_settings, ODBC_INI); - sprintf(temp, "%d", ci->disallow_premature); + sprintf(temp, "%d", ci->disallow_premature); SQLWritePrivateProfileString(DSN, INI_DISALLOWPREMATURE, temp, ODBC_INI); - sprintf(temp, "%d", ci->updatable_cursors); + sprintf(temp, "%d", ci->updatable_cursors); SQLWritePrivateProfileString(DSN, INI_UPDATABLECURSORS, temp, @@ -928,10 +931,10 @@ writeDSNinfo(const ConnInfo *ci) * the registry and gets any driver defaults. */ void -getCommonDefaults(const char *section, const char *filename, ConnInfo *ci) +getCommonDefaults(const char *section, const char *filename, ConnInfo * ci) { char temp[256]; - GLOBAL_VALUES *comval; + GLOBAL_VALUES *comval; if (ci) comval = &(ci->drivers); @@ -1101,13 +1104,12 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci) /* Dont allow override of an override! */ if (!ci) { - /* * ConnSettings is stored in the driver section and per datasource * for override */ SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "", - comval->conn_settings, sizeof(comval->conn_settings), filename); + comval->conn_settings, sizeof(comval->conn_settings), filename); /* Default state for future DSN's Readonly attribute */ SQLGetPrivateProfileString(section, INI_READONLY, "", diff --git a/src/interfaces/odbc/dlg_specific.h b/src/interfaces/odbc/dlg_specific.h index 4a221469b0..b1ec7090c0 100644 --- a/src/interfaces/odbc/dlg_specific.h +++ b/src/interfaces/odbc/dlg_specific.h @@ -120,11 +120,11 @@ #define DEFAULT_EXTRASYSTABLEPREFIXES "dd_;" /* prototypes */ -void getCommonDefaults(const char *section, const char *filename, ConnInfo *ci); +void getCommonDefaults(const char *section, const char *filename, ConnInfo * ci); #ifdef WIN32 -void SetDlgStuff(HWND hdlg, const ConnInfo *ci); -void GetDlgStuff(HWND hdlg, ConnInfo *ci); +void SetDlgStuff(HWND hdlg, const ConnInfo * ci); +void GetDlgStuff(HWND hdlg, ConnInfo * ci); int CALLBACK driver_optionsProc(HWND hdlg, WORD wMsg, @@ -134,16 +134,14 @@ int CALLBACK ds_optionsProc(HWND hdlg, WORD wMsg, WPARAM wParam, LPARAM lParam); - #endif /* WIN32 */ void updateGlobals(void); -void writeDSNinfo(const ConnInfo *ci); -void getDSNdefaults(ConnInfo *ci); -void getDSNinfo(ConnInfo *ci, char overwrite); -void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD); -void copyAttributes(ConnInfo *ci, const char *attribute, const char *value); -void copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value); - +void writeDSNinfo(const ConnInfo * ci); +void getDSNdefaults(ConnInfo * ci); +void getDSNinfo(ConnInfo * ci, char overwrite); +void makeConnectString(char *connect_string, const ConnInfo * ci, UWORD); +void copyAttributes(ConnInfo * ci, const char *attribute, const char *value); +void copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value); #endif diff --git a/src/interfaces/odbc/drvconn.c b/src/interfaces/odbc/drvconn.c index b2fa55345e..ce95296e54 100644 --- a/src/interfaces/odbc/drvconn.c +++ b/src/interfaces/odbc/drvconn.c @@ -45,28 +45,27 @@ #include "dlg_specific.h" /* prototypes */ -void dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci); -static void dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci); +void dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci); +static void dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci); #ifdef WIN32 BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); -RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci); - -extern HINSTANCE NEAR s_hModule;/* Saved module handle. */ +RETCODE dconn_DoDialog(HWND hwnd, ConnInfo * ci); +extern HINSTANCE NEAR s_hModule; /* Saved module handle. */ #endif -RETCODE SQL_API +RETCODE SQL_API PGAPI_DriverConnect( - HDBC hdbc, - HWND hwnd, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, - UWORD fDriverCompletion) + HDBC hdbc, + HWND hwnd, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, + UWORD fDriverCompletion) { static char *func = "PGAPI_DriverConnect"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -74,7 +73,6 @@ PGAPI_DriverConnect( #ifdef WIN32 RETCODE dialog_result; - #endif RETCODE result; char connStrIn[MAX_CONNECT_STRING]; @@ -208,13 +206,12 @@ dialog: lenStrout = cbConnStrOutMax; if (conn->ms_jet && lenStrout > 255) - lenStrout = 255; + lenStrout = 255; makeConnectString(connStrOut, ci, lenStrout); len = strlen(connStrOut); if (szConnStrOut) { - /* * Return the completed string to the caller. The correct method * is to only construct the connect string if a dialog was put up, @@ -228,7 +225,8 @@ dialog: if (len >= cbConnStrOutMax) { - int clen; + int clen; + for (clen = strlen(szConnStrOut) - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--) szConnStrOut[clen] = '\0'; result = SQL_SUCCESS_WITH_INFO; @@ -251,7 +249,7 @@ dialog: #ifdef WIN32 RETCODE -dconn_DoDialog(HWND hwnd, ConnInfo *ci) +dconn_DoDialog(HWND hwnd, ConnInfo * ci) { int dialog_result; @@ -327,7 +325,7 @@ dconn_FDriverConnectProc( case IDC_DRIVER: ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), - hdlg, driver_optionsProc, (LPARAM) ci); + hdlg, driver_optionsProc, (LPARAM) ci); break; case IDC_DATASOURCE: @@ -340,12 +338,11 @@ dconn_FDriverConnectProc( return FALSE; } - #endif /* WIN32 */ void -dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) +dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci) { char *our_connect_string; char *pair, @@ -357,7 +354,7 @@ dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) memset(ci, 0, sizeof(ConnInfo)); #ifdef DRIVER_CURSOR_IMPLEMENT ci->updatable_cursors = 1; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ our_connect_string = strdup(connect_string); strtok_arg = our_connect_string; @@ -394,7 +391,7 @@ dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) } static void -dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) +dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci) { char *our_connect_string; char *pair, diff --git a/src/interfaces/odbc/environ.c b/src/interfaces/odbc/environ.c index 072987f165..c36c300caf 100644 --- a/src/interfaces/odbc/environ.c +++ b/src/interfaces/odbc/environ.c @@ -28,8 +28,8 @@ extern GLOBAL_VALUES globals; ConnectionClass *conns[MAX_CONNECTIONS]; -RETCODE SQL_API -PGAPI_AllocEnv(HENV FAR *phenv) +RETCODE SQL_API +PGAPI_AllocEnv(HENV FAR * phenv) { static char *func = "PGAPI_AllocEnv"; @@ -58,7 +58,7 @@ PGAPI_AllocEnv(HENV FAR *phenv) } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeEnv(HENV henv) { static char *func = "PGAPI_FreeEnv"; @@ -79,21 +79,21 @@ PGAPI_FreeEnv(HENV henv) /* Returns the next SQL error information. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Error( - HENV henv, - HDBC hdbc, - HSTMT hstmt, - UCHAR FAR *szSqlState, - SDWORD FAR *pfNativeError, - UCHAR FAR *szErrorMsg, - SWORD cbErrorMsgMax, - SWORD FAR *pcbErrorMsg) + HENV henv, + HDBC hdbc, + HSTMT hstmt, + UCHAR FAR * szSqlState, + SDWORD FAR * pfNativeError, + UCHAR FAR * szErrorMsg, + SWORD cbErrorMsgMax, + SWORD FAR * pcbErrorMsg) { char *msg; int status; - BOOL once_again = FALSE; - SWORD msglen; + BOOL once_again = FALSE; + SWORD msglen; mylog("**** PGAPI_Error: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax); @@ -212,7 +212,7 @@ PGAPI_Error( strcpy(szSqlState, "07006"); break; case STMT_INVALID_CURSOR_STATE_ERROR: - strcpy(szSqlState, "24000"); + strcpy(szSqlState, "24000"); break; case STMT_OPTION_VALUE_CHANGED: strcpy(szSqlState, "01S02"); @@ -266,7 +266,8 @@ PGAPI_Error( if (once_again) { - int outlen; + int outlen; + stmt->errornumber = status; if (cbErrorMsgMax > 0) outlen = *pcbErrorMsg; @@ -493,7 +494,7 @@ EN_Constructor(void) char -EN_Destructor(EnvironmentClass *self) +EN_Destructor(EnvironmentClass * self) { int lf; char rv = 1; @@ -515,14 +516,14 @@ EN_Destructor(EnvironmentClass *self) mylog("exit EN_Destructor: rv = %d\n", rv); #ifdef _MEMORY_DEBUG_ -debug_memory_inouecheck(); -#endif /* _MEMORY_DEBUG_ */ + debug_memory_inouecheck(); +#endif /* _MEMORY_DEBUG_ */ return rv; } char -EN_get_error(EnvironmentClass *self, int *number, char **message) +EN_get_error(EnvironmentClass * self, int *number, char **message) { if (self && self->errormsg && self->errornumber) { @@ -538,7 +539,7 @@ EN_get_error(EnvironmentClass *self, int *number, char **message) char -EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) +EN_add_connection(EnvironmentClass * self, ConnectionClass * conn) { int i; @@ -562,7 +563,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) char -EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) +EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn) { int i; @@ -578,7 +579,7 @@ EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) void -EN_log_error(char *func, char *desc, EnvironmentClass *self) +EN_log_error(char *func, char *desc, EnvironmentClass * self) { if (self) qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg); diff --git a/src/interfaces/odbc/environ.h b/src/interfaces/odbc/environ.h index 7b463b3e74..a99a4e5a28 100644 --- a/src/interfaces/odbc/environ.h +++ b/src/interfaces/odbc/environ.h @@ -22,10 +22,9 @@ struct EnvironmentClass_ /* Environment prototypes */ EnvironmentClass *EN_Constructor(void); -char EN_Destructor(EnvironmentClass *self); -char EN_get_error(EnvironmentClass *self, int *number, char **message); -char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn); -char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn); -void EN_log_error(char *func, char *desc, EnvironmentClass *self); - +char EN_Destructor(EnvironmentClass * self); +char EN_get_error(EnvironmentClass * self, int *number, char **message); +char EN_add_connection(EnvironmentClass * self, ConnectionClass * conn); +char EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn); +void EN_log_error(char *func, char *desc, EnvironmentClass * self); #endif diff --git a/src/interfaces/odbc/execute.c b/src/interfaces/odbc/execute.c index 991407975e..5a693b7163 100644 --- a/src/interfaces/odbc/execute.c +++ b/src/interfaces/odbc/execute.c @@ -31,10 +31,10 @@ /* Perform a Prepare on the SQL statement */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Prepare(HSTMT hstmt, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStr) + UCHAR FAR * szSqlStr, + SDWORD cbSqlStr) { static char *func = "PGAPI_Prepare"; StatementClass *self = (StatementClass *) hstmt; @@ -121,11 +121,11 @@ PGAPI_Prepare(HSTMT hstmt, /* Performs the equivalent of SQLPrepare, followed by SQLExecute. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ExecDirect( - HSTMT hstmt, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStr) + HSTMT hstmt, + UCHAR FAR * szSqlStr, + SDWORD cbSqlStr) { StatementClass *stmt = (StatementClass *) hstmt; RETCODE result; @@ -188,9 +188,9 @@ PGAPI_ExecDirect( /* Execute a prepared SQL statement */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Execute( - HSTMT hstmt) + HSTMT hstmt) { static char *func = "PGAPI_Execute"; StatementClass *stmt = (StatementClass *) hstmt; @@ -284,7 +284,6 @@ PGAPI_Execute( */ if (!stmt->pre_executing) { - /* * The bound parameters could have possibly changed since the last * execute of this statement? Therefore check for params and @@ -333,17 +332,19 @@ PGAPI_Execute( return retval; mylog(" stmt_with_params = '%s'\n", stmt->stmt_with_params); + /* - * Get the field info for the prepared - * query using dummy backward fetch. + * Get the field info for the prepared query using dummy backward + * fetch. */ if (stmt->inaccurate_result && conn->connInfo.disallow_premature) { if (SC_is_pre_executable(stmt)) { - BOOL in_trans = CC_is_in_trans(conn); - BOOL issued_begin = FALSE, begin_included = FALSE; - QResultClass *res; + BOOL in_trans = CC_is_in_trans(conn); + BOOL issued_begin = FALSE, + begin_included = FALSE; + QResultClass *res; if (strnicmp(stmt->stmt_with_params, "BEGIN;", 6) == 0) begin_included = TRUE; @@ -384,8 +385,8 @@ PGAPI_Execute( } else if (!in_trans && begin_included) CC_set_no_trans(conn); - } - stmt->status =STMT_FINISHED; + } + stmt->status = STMT_FINISHED; return SQL_SUCCESS; } } @@ -397,11 +398,11 @@ PGAPI_Execute( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Transact( - HENV henv, - HDBC hdbc, - UWORD fType) + HENV henv, + HDBC hdbc, + UWORD fType) { static char *func = "PGAPI_Transact"; extern ConnectionClass *conns[]; @@ -478,19 +479,18 @@ PGAPI_Transact( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Cancel( - HSTMT hstmt) /* Statement to cancel. */ + HSTMT hstmt) /* Statement to cancel. */ { static char *func = "PGAPI_Cancel"; StatementClass *stmt = (StatementClass *) hstmt; RETCODE result; - ConnInfo *ci; + ConnInfo *ci; #ifdef WIN32 HMODULE hmodule; FARPROC addr; - #endif mylog("%s: entering...\n", func); @@ -509,7 +509,6 @@ PGAPI_Cancel( */ if (stmt->data_at_exec < 0) { - /* * MAJOR HACK for Windows to reset the driver manager's cursor * state: Because of what seems like a bug in the Odbc driver @@ -559,14 +558,14 @@ PGAPI_Cancel( * Currently, just copy the input string without modification * observing buffer limits and truncation. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NativeSql( - HDBC hdbc, - UCHAR FAR *szSqlStrIn, - SDWORD cbSqlStrIn, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStrMax, - SDWORD FAR *pcbSqlStr) + HDBC hdbc, + UCHAR FAR * szSqlStrIn, + SDWORD cbSqlStrIn, + UCHAR FAR * szSqlStr, + SDWORD cbSqlStrMax, + SDWORD FAR * pcbSqlStr) { static char *func = "PGAPI_NativeSql"; int len = 0; @@ -614,16 +613,16 @@ PGAPI_NativeSql( * Supplies parameter data at execution time. * Used in conjuction with SQLPutData. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ParamData( - HSTMT hstmt, - PTR FAR *prgbValue) + HSTMT hstmt, + PTR FAR * prgbValue) { static char *func = "PGAPI_ParamData"; StatementClass *stmt = (StatementClass *) hstmt; int i, retval; - ConnInfo *ci; + ConnInfo *ci; mylog("%s: entering...\n", func); @@ -724,11 +723,11 @@ PGAPI_ParamData( * Supplies parameter data at execution time. * Used in conjunction with SQLParamData. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_PutData( - HSTMT hstmt, - PTR rgbValue, - SDWORD cbValue) + HSTMT hstmt, + PTR rgbValue, + SDWORD cbValue) { static char *func = "PGAPI_PutData"; StatementClass *stmt = (StatementClass *) hstmt; diff --git a/src/interfaces/odbc/gpps.c b/src/interfaces/odbc/gpps.c index 5128966c02..658829a5fd 100644 --- a/src/interfaces/odbc/gpps.c +++ b/src/interfaces/odbc/gpps.c @@ -50,21 +50,21 @@ /* * theIniFileName is searched for in: - * $HOME/theIniFileName - * theIniFileName - * ODBCINSTDIR/ODBCINST_INI + * $HOME/theIniFileName + * theIniFileName + * ODBCINSTDIR/ODBCINST_INI */ DWORD -GetPrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* search key name */ - const char *theDefault, /* default value if not +GetPrivateProfileString(const char *theSection, /* section name */ + const char *theKey, /* search key name */ + const char *theDefault, /* default value if not * found */ char *theReturnBuffer, /* return value stored * here */ size_t theReturnBufferLength, /* byte length of return * buffer */ - const char *theIniFileName) /* pathname of ini file to - * search */ + const char *theIniFileName) /* pathname of ini file + * to search */ { char buf[MAXPGPATH]; char *ptr = 0; @@ -84,13 +84,13 @@ GetPrivateProfileString(const char *theSection, /* section name */ if (ptr == NULL || (((struct passwd *) ptr)->pw_dir) == NULL || *(((struct passwd *) ptr)->pw_dir) == '\0') ptr = "/home"; else - ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */ + ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */ /* - * If it can't be opened because the paths are too long, then - * skip it, don't just truncate the path string... The truncated path - * might accidently be an existing file. The default value will be - * returned instead. + * If it can't be opened because the paths are too long, then skip it, + * don't just truncate the path string... The truncated path might + * accidently be an existing file. The default value will be returned + * instead. */ if (MAXPGPATH - 1 >= strlen(ptr) + 1 + strlen(theIniFileName)) { @@ -278,10 +278,10 @@ GetPrivateProfileString(const char *theSection, /* section name */ DWORD WritePrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* write key name */ + const char *theKey, /* write key name */ const char *theBuffer, /* input buffer */ - const char *theIniFileName) /* pathname of ini file to - * write */ + const char *theIniFileName) /* pathname of ini file + * to write */ { return 0; } @@ -449,8 +449,6 @@ if (!keyFound) return aReturnLength > 0 ? aReturnLength - 1 : 0; } +#endif /* NOT_USED */ -#endif /* NOT_USED */ - - -#endif /* not WIN32 */ +#endif /* not WIN32 */ diff --git a/src/interfaces/odbc/gpps.h b/src/interfaces/odbc/gpps.h index 48b6722573..f44a266f39 100644 --- a/src/interfaces/odbc/gpps.h +++ b/src/interfaces/odbc/gpps.h @@ -18,28 +18,27 @@ extern "C" { #endif - DWORD - GetPrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* search key name */ - const char *theDefault, /* default value if not - * found */ + DWORD + GetPrivateProfileString(const char *theSection, /* section name */ + const char *theKey, /* search key name */ + const char *theDefault, /* default value if not + * found */ char *theReturnBuffer, /* return valuse stored * here */ size_t theBufferLength, /* byte length of return * buffer */ - const char *theIniFileName); /* pathname of ini file + const char *theIniFileName); /* pathname of ini file * to search */ - DWORD + DWORD WritePrivateProfileString(const char *theSection, /* section name */ const char *theKey, /* write key name */ - const char *theBuffer, /* input buffer */ - const char *theIniFileName); /* pathname of ini file + const char *theBuffer, /* input buffer */ + const char *theIniFileName); /* pathname of ini file * to write */ #ifdef __cplusplus } - #endif #ifndef WIN32 diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c index 5f4059bd2d..0752ab03ab 100644 --- a/src/interfaces/odbc/info.c +++ b/src/interfaces/odbc/info.c @@ -49,13 +49,13 @@ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetInfo( - HDBC hdbc, - UWORD fInfoType, - PTR rgbInfoValue, - SWORD cbInfoValueMax, - SWORD FAR *pcbInfoValue) + HDBC hdbc, + UWORD fInfoType, + PTR rgbInfoValue, + SWORD cbInfoValueMax, + SWORD FAR * pcbInfoValue) { static char *func = "PGAPI_GetInfo"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -219,16 +219,20 @@ PGAPI_GetInfo( #ifdef DRIVER_CURSOR_IMPLEMENT { static char dver[32]; + SQLGetPrivateProfileString(DBMS_NAME, - "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini"); + "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini"); if (dver[0]) { - int major, minor; + int major, + minor; + mylog("REGISTRY_ODBC_VER = %s\n", dver) -; + ; if (sscanf(dver, "%x.%x", &major, &minor) >= 2) { - Int2 drv_ver = (major << 8) + minor; + Int2 drv_ver = (major << 8) + minor; + if (drv_ver > ODBCVER) { conn->driver_version = drv_ver; @@ -237,7 +241,7 @@ PGAPI_GetInfo( } } } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ break; case SQL_DRIVER_VER: /* ODBC 1.0 */ @@ -520,8 +524,8 @@ PGAPI_GetInfo( case SQL_POSITIONED_STATEMENTS: /* ODBC 2.0 */ len = 4; value = ci->drivers.lie ? (SQL_PS_POSITIONED_DELETE | - SQL_PS_POSITIONED_UPDATE | - SQL_PS_SELECT_FOR_UPDATE) : 0; + SQL_PS_POSITIONED_UPDATE | + SQL_PS_SELECT_FOR_UPDATE) : 0; break; case SQL_PROCEDURE_TERM: /* ODBC 1.0 */ @@ -568,10 +572,10 @@ PGAPI_GetInfo( case SQL_SCROLL_CONCURRENCY: /* ODBC 1.0 */ len = 4; value = ci->drivers.lie ? (SQL_SCCO_READ_ONLY | - SQL_SCCO_LOCK | - SQL_SCCO_OPT_ROWVER | - SQL_SCCO_OPT_VALUES) : - (SQL_SCCO_READ_ONLY); + SQL_SCCO_LOCK | + SQL_SCCO_OPT_ROWVER | + SQL_SCCO_OPT_VALUES) : + (SQL_SCCO_READ_ONLY); if (ci->updatable_cursors) value |= SQL_SCCO_OPT_ROWVER; break; @@ -579,13 +583,13 @@ PGAPI_GetInfo( case SQL_SCROLL_OPTIONS: /* ODBC 1.0 */ len = 4; value = ci->drivers.lie ? (SQL_SO_FORWARD_ONLY | - SQL_SO_STATIC | - SQL_SO_KEYSET_DRIVEN | - SQL_SO_DYNAMIC | - SQL_SO_MIXED) - : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC)); + SQL_SO_STATIC | + SQL_SO_KEYSET_DRIVEN | + SQL_SO_DYNAMIC | + SQL_SO_MIXED) + : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC)); if (ci->updatable_cursors) - value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */ + value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */ break; case SQL_SEARCH_PATTERN_ESCAPE: /* ODBC 1.0 */ @@ -730,10 +734,10 @@ PGAPI_GetInfo( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetTypeInfo( - HSTMT hstmt, - SWORD fSqlType) + HSTMT hstmt, + SWORD fSqlType) { static char *func = "PGAPI_GetTypeInfo"; StatementClass *stmt = (StatementClass *) hstmt; @@ -785,7 +789,7 @@ PGAPI_GetTypeInfo( if (fSqlType == SQL_ALL_TYPES || fSqlType == sqlType) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) * sizeof(TupleField)); /* These values can't be NULL */ set_tuplefield_string(&row->tuple[0], pgtype_to_name(stmt, pgType)); @@ -824,15 +828,15 @@ PGAPI_GetTypeInfo( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetFunctions( - HDBC hdbc, - UWORD fFunction, - UWORD FAR *pfExists) + HDBC hdbc, + UWORD fFunction, + UWORD FAR * pfExists) { static char *func = "PGAPI_GetFunctions"; - ConnectionClass *conn = (ConnectionClass *)hdbc; - ConnInfo *ci = &(conn->connInfo); + ConnectionClass *conn = (ConnectionClass *) hdbc; + ConnInfo *ci = &(conn->connInfo); mylog("%s: entering...%u\n", func, fFunction); @@ -1114,17 +1118,17 @@ PGAPI_GetFunctions( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Tables( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szTableType, - SWORD cbTableType) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szTableType, + SWORD cbTableType) { static char *func = "PGAPI_Tables"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1274,7 +1278,7 @@ PGAPI_Tables( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR, - table_name, MAX_INFO_STRING, NULL); + table_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1285,7 +1289,7 @@ PGAPI_Tables( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_CHAR, - table_owner, MAX_INFO_STRING, NULL); + table_owner, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1295,7 +1299,7 @@ PGAPI_Tables( return SQL_ERROR; } result = PGAPI_BindCol(htbl_stmt, 3, SQL_C_CHAR, - relkind_or_hasrules, MAX_INFO_STRING, NULL); + relkind_or_hasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1335,7 +1339,6 @@ PGAPI_Tables( result = PGAPI_Fetch(htbl_stmt); while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { - /* * Determine if this table name is a system table. If treating * system tables as regular tables, then no need to do this test. @@ -1384,7 +1387,7 @@ PGAPI_Tables( (view && show_views) || (regular_table && show_regular_tables)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); @@ -1434,17 +1437,17 @@ PGAPI_Tables( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Columns( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_Columns"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1520,7 +1523,7 @@ PGAPI_Columns( mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, - strlen(columns_query)); + strlen(columns_query)); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = SC_create_errormsg(hcol_stmt); @@ -1531,7 +1534,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR, - table_owner, MAX_INFO_STRING, NULL); + table_owner, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1542,7 +1545,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 2, SQL_C_CHAR, - table_name, MAX_INFO_STRING, NULL); + table_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1553,7 +1556,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 3, SQL_C_CHAR, - field_name, MAX_INFO_STRING, NULL); + field_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1564,7 +1567,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_LONG, - &field_type, 4, NULL); + &field_type, 4, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1575,7 +1578,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 5, SQL_C_CHAR, - field_type_name, MAX_INFO_STRING, NULL); + field_type_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1586,7 +1589,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 6, SQL_C_SHORT, - &field_number, MAX_INFO_STRING, NULL); + &field_number, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1597,7 +1600,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 7, SQL_C_LONG, - &field_length, MAX_INFO_STRING, NULL); + &field_length, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1608,7 +1611,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 8, SQL_C_LONG, - &mod_length, MAX_INFO_STRING, NULL); + &mod_length, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1619,7 +1622,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 9, SQL_C_CHAR, - not_null, MAX_INFO_STRING, NULL); + not_null, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1630,7 +1633,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 10, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1695,7 +1698,7 @@ PGAPI_Columns( /* For OID fields */ the_type = PG_TYPE_OID; row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); /* see note in SQLTables() */ @@ -1724,7 +1727,7 @@ PGAPI_Columns( while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); @@ -1758,7 +1761,7 @@ PGAPI_Columns( if (field_type == PG_TYPE_NUMERIC) { if (mod_length >= 4) - mod_length -= 4;/* the length is in atttypmod - 4 */ + mod_length -= 4; /* the length is in atttypmod - 4 */ if (mod_length >= 0) { @@ -1782,7 +1785,7 @@ PGAPI_Columns( useStaticPrecision = FALSE; if (mod_length >= 4) - mod_length -= 4;/* the length is in atttypmod - 4 */ + mod_length -= 4; /* the length is in atttypmod - 4 */ if (mod_length > ci->drivers.max_varchar_size || mod_length <= 0) mod_length = ci->drivers.max_varchar_size; @@ -1835,7 +1838,7 @@ PGAPI_Columns( the_type = PG_TYPE_INT4; row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); set_tuplefield_string(&row->tuple[1], ""); @@ -1872,18 +1875,18 @@ PGAPI_Columns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_SpecialColumns( - HSTMT hstmt, - UWORD fColType, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UWORD fScope, - UWORD fNullable) + HSTMT hstmt, + UWORD fColType, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UWORD fScope, + UWORD fNullable) { static char *func = "PGAPI_SpecialColumns"; TupleNode *row; @@ -1930,7 +1933,7 @@ PGAPI_SpecialColumns( mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, - strlen(columns_query)); + strlen(columns_query)); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = SC_create_errormsg(hcol_stmt); @@ -1941,7 +1944,7 @@ PGAPI_SpecialColumns( } result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1972,7 +1975,7 @@ PGAPI_SpecialColumns( /* use the oid value for the rowid */ if (fColType == SQL_BEST_ROWID) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField)); set_tuplefield_int2(&row->tuple[0], SQL_SCOPE_SESSION); set_tuplefield_string(&row->tuple[1], "oid"); @@ -1992,7 +1995,7 @@ PGAPI_SpecialColumns( if (atoi(ci->row_versioning)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField)); set_tuplefield_null(&row->tuple[0]); set_tuplefield_string(&row->tuple[1], "xmin"); @@ -2018,17 +2021,17 @@ PGAPI_SpecialColumns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Statistics( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UWORD fUnique, - UWORD fAccuracy) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UWORD fUnique, + UWORD fAccuracy) { static char *func = "PGAPI_Statistics"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2136,7 +2139,7 @@ PGAPI_Statistics( */ col_stmt->internal = TRUE; result = PGAPI_Columns(hcol_stmt, "", 0, "", 0, - table_name, (SWORD) strlen(table_name), "", 0); + table_name, (SWORD) strlen(table_name), "", 0); col_stmt->internal = FALSE; if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) @@ -2148,7 +2151,7 @@ PGAPI_Statistics( goto SEEYA; } result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_CHAR, - column_name, MAX_INFO_STRING, &column_name_len); + column_name, MAX_INFO_STRING, &column_name_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -2206,7 +2209,7 @@ PGAPI_Statistics( " and d.oid = i.indrelid" " and i.indexrelid = c.oid" " and c.relam = a.oid" - , table_name); + ,table_name); if (PG_VERSION_GT(SC_get_conn(stmt), 6.4)) strcat(index_query, " order by i.indisprimary desc"); @@ -2226,7 +2229,7 @@ PGAPI_Statistics( /* bind the index name column */ result = PGAPI_BindCol(hindx_stmt, 1, SQL_C_CHAR, - index_name, MAX_INFO_STRING, &index_name_len); + index_name, MAX_INFO_STRING, &index_name_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2238,7 +2241,7 @@ PGAPI_Statistics( } /* bind the vector column */ result = PGAPI_BindCol(hindx_stmt, 2, SQL_C_DEFAULT, - fields_vector, 32, &fields_vector_len); + fields_vector, 32, &fields_vector_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2250,7 +2253,7 @@ PGAPI_Statistics( } /* bind the "is unique" column */ result = PGAPI_BindCol(hindx_stmt, 3, SQL_C_CHAR, - isunique, sizeof(isunique), NULL); + isunique, sizeof(isunique), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2262,7 +2265,7 @@ PGAPI_Statistics( /* bind the "is clustered" column */ result = PGAPI_BindCol(hindx_stmt, 4, SQL_C_CHAR, - isclustered, sizeof(isclustered), NULL); + isclustered, sizeof(isclustered), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2275,7 +2278,7 @@ PGAPI_Statistics( /* bind the "is hash" column */ result = PGAPI_BindCol(hindx_stmt, 5, SQL_C_CHAR, - ishash, sizeof(ishash), NULL); + ishash, sizeof(ishash), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2287,7 +2290,7 @@ PGAPI_Statistics( } result = PGAPI_BindCol(hindx_stmt, 6, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; @@ -2300,7 +2303,7 @@ PGAPI_Statistics( if (relhasrules[0] != '1' && atoi(ci->show_oid_column) && atoi(ci->fake_oid_index)) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (13 - 1) *sizeof(TupleField)); + (13 - 1) * sizeof(TupleField)); /* no table qualifier */ set_tuplefield_string(&row->tuple[0], ""); @@ -2344,7 +2347,7 @@ PGAPI_Statistics( while (i < 16 && fields_vector[i] != 0) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (13 - 1) *sizeof(TupleField)); + (13 - 1) * sizeof(TupleField)); /* no table qualifier */ set_tuplefield_string(&row->tuple[0], ""); @@ -2366,8 +2369,8 @@ PGAPI_Statistics( * Clustered/HASH index? */ set_tuplefield_int2(&row->tuple[6], (Int2) - (atoi(isclustered) ? SQL_INDEX_CLUSTERED : - (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); + (atoi(isclustered) ? SQL_INDEX_CLUSTERED : + (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); set_tuplefield_int2(&row->tuple[7], (Int2) (i + 1)); if (fields_vector[i] == OID_ATTNUM) @@ -2441,17 +2444,17 @@ SEEYA: } -RETCODE SQL_API +RETCODE SQL_API PGAPI_ColumnPrivileges( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_ColumnPrivileges"; @@ -2469,15 +2472,15 @@ PGAPI_ColumnPrivileges( * * Retrieve the primary key columns for the specified table. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_PrimaryKeys( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName) { static char *func = "PGAPI_PrimaryKeys"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2492,7 +2495,9 @@ PGAPI_PrimaryKeys( SDWORD attname_len; char pktab[MAX_TABLE_LEN + 1]; Int2 result_cols; - int qno, qstart, qend; + int qno, + qstart, + qend; mylog("%s: entering...stmt=%u\n", func, stmt); @@ -2554,7 +2559,7 @@ PGAPI_PrimaryKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR, - attname, MAX_INFO_STRING, &attname_len); + attname, MAX_INFO_STRING, &attname_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -2575,32 +2580,35 @@ PGAPI_PrimaryKeys( switch (qno) { case 1: + /* - * Simplified query to remove assumptions about number of possible - * index columns. Courtesy of Tom Lane - thomas 2000-03-21 - */ + * Simplified query to remove assumptions about number of + * possible index columns. Courtesy of Tom Lane - thomas + * 2000-03-21 + */ sprintf(tables_query, "select ta.attname, ia.attnum" - " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" - " where c.relname = '%s'" - " AND c.oid = i.indrelid" - " AND i.indisprimary = 't'" - " AND ia.attrelid = i.indexrelid" - " AND ta.attrelid = i.indrelid" - " AND ta.attnum = i.indkey[ia.attnum-1]" - " order by ia.attnum", pktab); + " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" + " where c.relname = '%s'" + " AND c.oid = i.indrelid" + " AND i.indisprimary = 't'" + " AND ia.attrelid = i.indexrelid" + " AND ta.attrelid = i.indrelid" + " AND ta.attnum = i.indkey[ia.attnum-1]" + " order by ia.attnum", pktab); break; case 2: + /* - * Simplified query to search old fashoned primary key - */ + * Simplified query to search old fashoned primary key + */ sprintf(tables_query, "select ta.attname, ia.attnum" - " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" - " where c.relname = '%s_pkey'" - " AND c.oid = i.indexrelid" - " AND ia.attrelid = i.indexrelid" - " AND ta.attrelid = i.indrelid" - " AND ta.attnum = i.indkey[ia.attnum-1]" - " order by ia.attnum", pktab); + " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" + " where c.relname = '%s_pkey'" + " AND c.oid = i.indexrelid" + " AND ia.attrelid = i.indexrelid" + " AND ta.attrelid = i.indrelid" + " AND ta.attnum = i.indkey[ia.attnum-1]" + " order by ia.attnum", pktab); break; } mylog("%s: tables_query='%s'\n", func, tables_query); @@ -2622,7 +2630,7 @@ PGAPI_PrimaryKeys( while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_null(&row->tuple[0]); @@ -2679,7 +2687,8 @@ PGAPI_PrimaryKeys( * There may be much more effective way in the * future version. The way is very forcive currently. */ -static BOOL isMultibyte(const unsigned char *str) +static BOOL +isMultibyte(const unsigned char *str) { for (; *str; str++) { @@ -2688,11 +2697,15 @@ static BOOL isMultibyte(const unsigned char *str) } return FALSE; } -static char *getClientTableName(ConnectionClass *conn, char *serverTableName, BOOL *nameAlloced) +static char * +getClientTableName(ConnectionClass * conn, char *serverTableName, BOOL * nameAlloced) { - char query[1024], saveoid[24], *ret = serverTableName; - BOOL continueExec = TRUE, bError = FALSE; - QResultClass *res; + char query[1024], + saveoid[24], + *ret = serverTableName; + BOOL continueExec = TRUE, + bError = FALSE; + QResultClass *res; *nameAlloced = FALSE; if (!conn->client_encoding || !isMultibyte(serverTableName)) @@ -2764,11 +2777,16 @@ static char *getClientTableName(ConnectionClass *conn, char *serverTableName, BO } return ret; } -static char *getClientColumnName(ConnectionClass *conn, const char *serverTableName, char *serverColumnName, BOOL *nameAlloced) +static char * +getClientColumnName(ConnectionClass * conn, const char *serverTableName, char *serverColumnName, BOOL * nameAlloced) { - char query[1024], saveattrelid[24], saveattnum[16], *ret = serverColumnName; - BOOL continueExec = TRUE, bError = FALSE; - QResultClass *res; + char query[1024], + saveattrelid[24], + saveattnum[16], + *ret = serverColumnName; + BOOL continueExec = TRUE, + bError = FALSE; + QResultClass *res; *nameAlloced = FALSE; if (!conn->client_encoding || !isMultibyte(serverColumnName)) @@ -2795,8 +2813,8 @@ static char *getClientColumnName(ConnectionClass *conn, const char *serverTableN if (!bError && continueExec) { sprintf(query, "select attrelid, attnum from pg_class, pg_attribute " - "where relname = '%s' and attrelid = pg_class.oid " - "and attname = '%s'", serverTableName, serverColumnName); + "where relname = '%s' and attrelid = pg_class.oid " + "and attname = '%s'", serverTableName, serverColumnName); if (res = CC_send_query(conn, query, NULL), res) { if (QR_get_num_tuples(res) > 0) @@ -2845,23 +2863,23 @@ static char *getClientColumnName(ConnectionClass *conn, const char *serverTableN } return ret; } -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ForeignKeys( - HSTMT hstmt, - UCHAR FAR *szPkTableQualifier, - SWORD cbPkTableQualifier, - UCHAR FAR *szPkTableOwner, - SWORD cbPkTableOwner, - UCHAR FAR *szPkTableName, - SWORD cbPkTableName, - UCHAR FAR *szFkTableQualifier, - SWORD cbFkTableQualifier, - UCHAR FAR *szFkTableOwner, - SWORD cbFkTableOwner, - UCHAR FAR *szFkTableName, - SWORD cbFkTableName) + HSTMT hstmt, + UCHAR FAR * szPkTableQualifier, + SWORD cbPkTableQualifier, + UCHAR FAR * szPkTableOwner, + SWORD cbPkTableOwner, + UCHAR FAR * szPkTableName, + SWORD cbPkTableName, + UCHAR FAR * szFkTableQualifier, + SWORD cbFkTableQualifier, + UCHAR FAR * szFkTableOwner, + SWORD cbFkTableOwner, + UCHAR FAR * szFkTableName, + SWORD cbFkTableName) { static char *func = "PGAPI_ForeignKeys"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2879,14 +2897,22 @@ PGAPI_ForeignKeys( del_rule[MAX_TABLE_LEN]; char pk_table_needed[MAX_TABLE_LEN + 1]; char fk_table_needed[MAX_TABLE_LEN + 1]; - char *pkey_ptr, *pkey_text, - *fkey_ptr, *fkey_text, - *pk_table, *pkt_text, - *fk_table, *fkt_text; + char *pkey_ptr, + *pkey_text, + *fkey_ptr, + *fkey_text, + *pk_table, + *pkt_text, + *fk_table, + *fkt_text; + #ifdef MULTIBYTE - BOOL pkey_alloced, fkey_alloced, pkt_alloced, fkt_alloced; - ConnectionClass *conn; -#endif /* MULTIBYTE */ + BOOL pkey_alloced, + fkey_alloced, + pkt_alloced, + fkt_alloced; + ConnectionClass *conn; +#endif /* MULTIBYTE */ int i, j, k, @@ -2897,7 +2923,6 @@ PGAPI_ForeignKeys( #if (ODBCVER >= 0x0300) SWORD defer_type; - #endif char pkey[MAX_INFO_STRING]; Int2 result_cols; @@ -2983,7 +3008,8 @@ PGAPI_ForeignKeys( #ifdef MULTIBYTE pkey_alloced = fkey_alloced = pkt_alloced = fkt_alloced = FALSE; conn = SC_get_conn(stmt); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ + /* * Case #2 -- Get the foreign keys in the specified table (fktab) that * refer to the primary keys of other table(s). @@ -3032,7 +3058,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY, - trig_args, sizeof(trig_args), NULL); + trig_args, sizeof(trig_args), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3043,7 +3069,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT, - &trig_nargs, 0, NULL); + &trig_nargs, 0, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3076,7 +3102,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR, - upd_rule, sizeof(upd_rule), NULL); + upd_rule, sizeof(upd_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3087,7 +3113,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR, - del_rule, sizeof(del_rule), NULL); + del_rule, sizeof(del_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3120,7 +3146,7 @@ PGAPI_ForeignKeys( } keyresult = PGAPI_BindCol(hpkey_stmt, 4, SQL_C_CHAR, - pkey, sizeof(pkey), NULL); + pkey, sizeof(pkey), NULL); if (keyresult != SQL_SUCCESS) { stmt->errornumber = STMT_NO_MEMORY_ERROR; @@ -3148,7 +3174,7 @@ PGAPI_ForeignKeys( pkt_text = getClientTableName(conn, pk_table, &pkt_alloced); #else pkt_text = pk_table; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* If there is a pk table specified, then check it. */ if (pk_table_needed[0] != '\0') { @@ -3189,7 +3215,7 @@ PGAPI_ForeignKeys( pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced); #else pkey_text = pkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("%s: pkey_ptr='%s', pkey='%s'\n", func, pkey_text, pkey); if (strcmp(pkey_text, pkey)) { @@ -3199,7 +3225,7 @@ PGAPI_ForeignKeys( #ifdef MULTIBYTE if (pkey_alloced) free(pkey_text); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Get to next primary key */ for (k = 0; k < 2; k++) pkey_ptr += strlen(pkey_ptr) + 1; @@ -3251,7 +3277,7 @@ PGAPI_ForeignKeys( for (k = 0; k < num_keys; k++) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); #ifdef MULTIBYTE pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced); @@ -3259,7 +3285,7 @@ PGAPI_ForeignKeys( #else pkey_text = pkey_ptr; fkey_text = fkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("%s: pk_table = '%s', pkey_ptr = '%s'\n", func, pkt_text, pkey_text); set_tuplefield_null(&row->tuple[0]); set_tuplefield_string(&row->tuple[1], ""); @@ -3291,7 +3317,7 @@ PGAPI_ForeignKeys( if (pkey_alloced) free(pkey_text); pkey_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* next primary/foreign key */ for (i = 0; i < 2; i++) { @@ -3303,7 +3329,7 @@ PGAPI_ForeignKeys( if (pkt_alloced) free(pkt_text); pkt_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ result = PGAPI_Fetch(htbl_stmt); } @@ -3358,7 +3384,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY, - trig_args, sizeof(trig_args), NULL); + trig_args, sizeof(trig_args), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3369,7 +3395,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT, - &trig_nargs, 0, NULL); + &trig_nargs, 0, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3402,7 +3428,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR, - upd_rule, sizeof(upd_rule), NULL); + upd_rule, sizeof(upd_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3413,7 +3439,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR, - del_rule, sizeof(del_rule), NULL); + del_rule, sizeof(del_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3489,7 +3515,7 @@ PGAPI_ForeignKeys( fkt_text = getClientTableName(conn, fk_table, &fkt_alloced); #else fkt_text = fk_table; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Get to first foreign key */ fkey_ptr = trig_args; @@ -3504,10 +3530,10 @@ PGAPI_ForeignKeys( #else pkey_text = pkey_ptr; fkey_text = fkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'\n", pkey_text, fkt_text, fkey_text); - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); mylog("pk_table_needed = '%s', pkey_ptr = '%s'\n", pk_table_needed, pkey_text); set_tuplefield_null(&row->tuple[0]); @@ -3545,7 +3571,7 @@ PGAPI_ForeignKeys( if (fkey_alloced) free(fkey_text); fkey_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* next primary/foreign key */ for (j = 0; j < 2; j++) @@ -3558,7 +3584,7 @@ PGAPI_ForeignKeys( if (fkt_alloced) free(fkt_text); fkt_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ result = PGAPI_Fetch(htbl_stmt); } } @@ -3579,7 +3605,7 @@ PGAPI_ForeignKeys( free(fkt_text); if (fkey_alloced) free(fkey_text); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ PGAPI_FreeStmt(htbl_stmt, SQL_DROP); @@ -3588,17 +3614,17 @@ PGAPI_ForeignKeys( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_ProcedureColumns( - HSTMT hstmt, - UCHAR FAR *szProcQualifier, - SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, - SWORD cbProcOwner, - UCHAR FAR *szProcName, - SWORD cbProcName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szProcQualifier, + SWORD cbProcQualifier, + UCHAR FAR * szProcOwner, + SWORD cbProcOwner, + UCHAR FAR * szProcName, + SWORD cbProcName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_ProcedureColumns"; @@ -3609,24 +3635,24 @@ PGAPI_ProcedureColumns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Procedures( - HSTMT hstmt, - UCHAR FAR *szProcQualifier, - SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, - SWORD cbProcOwner, - UCHAR FAR *szProcName, - SWORD cbProcName) + HSTMT hstmt, + UCHAR FAR * szProcQualifier, + SWORD cbProcQualifier, + UCHAR FAR * szProcOwner, + SWORD cbProcOwner, + UCHAR FAR * szProcName, + SWORD cbProcName) { static char *func = "PGAPI_Procedures"; - StatementClass *stmt = (StatementClass *) hstmt; - ConnectionClass *conn = SC_get_conn(stmt); + StatementClass *stmt = (StatementClass *) hstmt; + ConnectionClass *conn = SC_get_conn(stmt); char proc_query[INFO_INQUIRY_LEN]; - QResultClass *res; + QResultClass *res; mylog("%s: entering...\n", func); - + if (PG_VERSION_LT(conn, 6.5)) { stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; @@ -3636,14 +3662,15 @@ PGAPI_Procedures( } if (!SC_recycle_statement(stmt)) return SQL_ERROR; + /* - * The following seems the simplest implementation + * The following seems the simplest implementation */ - strcpy(proc_query, "select '' as ""PROCEDURE_CAT"", '' as ""PROCEDURE_SCHEM""," - " proname as ""PROCEDURE_NAME"", '' as ""NUM_INPUT_PARAMS""," - " '' as ""NUM_OUTPUT_PARAMS"", '' as ""NUM_RESULT_SETS""," - " '' as ""REMARKS""," - " case when prorettype =0 then 1::int2 else 2::int2 end as ""PROCEDURE_TYPE"" from pg_proc"); + strcpy(proc_query, "select '' as " "PROCEDURE_CAT" ", '' as " "PROCEDURE_SCHEM" "," + " proname as " "PROCEDURE_NAME" ", '' as " "NUM_INPUT_PARAMS" "," + " '' as " "NUM_OUTPUT_PARAMS" ", '' as " "NUM_RESULT_SETS" "," + " '' as " "REMARKS" "," + " case when prorettype =0 then 1::int2 else 2::int2 end as " "PROCEDURE_TYPE" " from pg_proc"); my_strcat(proc_query, " where proname like '%.*s'", szProcName, cbProcName); res = CC_send_query(conn, proc_query, NULL); @@ -3656,6 +3683,7 @@ PGAPI_Procedures( return SQL_ERROR; } stmt->result = res; + /* * also, things need to think that this statement is finished so the * results can be retrieved. @@ -3671,26 +3699,26 @@ PGAPI_Procedures( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_TablePrivileges( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName) { - StatementClass *stmt = (StatementClass *) hstmt; + StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_TablePrivileges"; Int2 result_cols; mylog("%s: entering...\n", func); /* - * a statement is actually executed, so we'll have to do this - * ourselves. - */ + * a statement is actually executed, so we'll have to do this + * ourselves. + */ result_cols = 7; extend_bindings(stmt, result_cols); @@ -3703,7 +3731,7 @@ PGAPI_TablePrivileges( QR_set_field_info(stmt->result, 4, "GRANTEE", PG_TYPE_TEXT, MAX_INFO_STRING); QR_set_field_info(stmt->result, 5, "PRIVILEGE", PG_TYPE_TEXT, MAX_INFO_STRING); QR_set_field_info(stmt->result, 6, "IS_GRANTABLE", PG_TYPE_TEXT, MAX_INFO_STRING); - + SC_log_error(func, "Function not implemented", (StatementClass *) hstmt); return SQL_ERROR; } diff --git a/src/interfaces/odbc/iodbc.h b/src/interfaces/odbc/iodbc.h index 99ed552055..ca12dd0373 100644 --- a/src/interfaces/odbc/iodbc.h +++ b/src/interfaces/odbc/iodbc.h @@ -8,7 +8,7 @@ #include <sys/types.h> #define MEM_ALLOC(size) (malloc((size_t)(size))) -#define MEM_FREE(ptr) \ +#define MEM_FREE(ptr) \ do { \ if(ptr) \ free(ptr); \ @@ -33,7 +33,6 @@ typedef WORD WPARAM; typedef DWORD LPARAM; typedef void *HWND; typedef int BOOL; - #endif /* _UNIX_ */ #if defined(WIN32) || defined(WIN32_SYSTEM) @@ -58,7 +57,6 @@ typedef int BOOL; #define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0) #define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0) #endif - #endif /* WIN32 */ #define SYSERR (-1) @@ -66,5 +64,4 @@ typedef int BOOL; #ifndef NULL #define NULL ((void FAR*)0UL) #endif - #endif diff --git a/src/interfaces/odbc/isql.h b/src/interfaces/odbc/isql.h index 5a5a8afafd..fafb01594b 100644 --- a/src/interfaces/odbc/isql.h +++ b/src/interfaces/odbc/isql.h @@ -136,16 +136,16 @@ extern "C" #endif RETCODE SQL_API SQLAllocConnect(HENV henv, - HDBC FAR *phdbc); - RETCODE SQL_API SQLAllocEnv(HENV FAR *phenv); + HDBC FAR * phdbc); + RETCODE SQL_API SQLAllocEnv(HENV FAR * phenv); RETCODE SQL_API SQLAllocStmt(HDBC hdbc, - HSTMT FAR *phstmt); + HSTMT FAR * phstmt); RETCODE SQL_API SQLBindCol(HSTMT hstmt, UWORD icol, SWORD fCType, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLCancel(HSTMT hstmt); @@ -154,40 +154,40 @@ extern "C" UWORD fDescType, PTR rgbDesc, SWORD cbDescMax, - SWORD FAR *pcbDesc, - SDWORD FAR *pfDesc); + SWORD FAR * pcbDesc, + SDWORD FAR * pfDesc); RETCODE SQL_API SQLConnect(HDBC hdbc, - UCHAR FAR *szDSN, + UCHAR FAR * szDSN, SWORD cbDSN, - UCHAR FAR *szUID, + UCHAR FAR * szUID, SWORD cbUID, - UCHAR FAR *szAuthStr, + UCHAR FAR * szAuthStr, SWORD cbAuthStr); RETCODE SQL_API SQLDescribeCol(HSTMT hstmt, UWORD icol, - UCHAR FAR *szColName, + UCHAR FAR * szColName, SWORD cbColNameMax, - SWORD FAR *pcbColName, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable); + SWORD FAR * pcbColName, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable); RETCODE SQL_API SQLDisconnect(HDBC hdbc); RETCODE SQL_API SQLError(HENV henv, HDBC hdbc, HSTMT hstmt, - UCHAR FAR *szSqlState, - SDWORD FAR *pfNativeError, - UCHAR FAR *szErrorMsg, + UCHAR FAR * szSqlState, + SDWORD FAR * pfNativeError, + UCHAR FAR * szErrorMsg, SWORD cbErrorMsgMax, - SWORD FAR *pcbErrorMsg); + SWORD FAR * pcbErrorMsg); RETCODE SQL_API SQLExecDirect(HSTMT hstmt, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStr); RETCODE SQL_API SQLExecute(HSTMT hstmt); @@ -202,22 +202,22 @@ extern "C" UWORD fOption); RETCODE SQL_API SQLGetCursorName(HSTMT hstmt, - UCHAR FAR *szCursor, + UCHAR FAR * szCursor, SWORD cbCursorMax, - SWORD FAR *pcbCursor); + SWORD FAR * pcbCursor); RETCODE SQL_API SQLNumResultCols(HSTMT hstmt, - SWORD FAR *pccol); + SWORD FAR * pccol); RETCODE SQL_API SQLPrepare(HSTMT hstmt, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStr); RETCODE SQL_API SQLRowCount(HSTMT hstmt, - SDWORD FAR *pcrow); + SDWORD FAR * pcrow); RETCODE SQL_API SQLSetCursorName(HSTMT hstmt, - UCHAR FAR *szCursor, + UCHAR FAR * szCursor, SWORD cbCursor); RETCODE SQL_API SQLTransact(HENV henv, @@ -231,10 +231,9 @@ extern "C" UDWORD cbColDef, SWORD ibScale, PTR rgbValue, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); #ifdef __cplusplus } - #endif #endif diff --git a/src/interfaces/odbc/isqlext.h b/src/interfaces/odbc/isqlext.h index 88c9e4495b..83e9c83ee2 100644 --- a/src/interfaces/odbc/isqlext.h +++ b/src/interfaces/odbc/isqlext.h @@ -371,14 +371,13 @@ typedef struct { SQLUINTEGER dwLowWord; SQLUINTEGER dwHighWord; -} SQLUBIGINT; +} SQLUBIGINT; typedef struct { SQLUINTEGER dwLowWord; SQLINTEGER dwHighWord; -} SQLBIGINT; - +} SQLBIGINT; #endif /* GCC */ typedef struct tagDATE_STRUCT @@ -386,16 +385,18 @@ typedef struct tagDATE_STRUCT SQLSMALLINT year; SQLUSMALLINT month; SQLUSMALLINT day; -} DATE_STRUCT, -SQL_DATE_STRUCT; +} DATE_STRUCT, + + SQL_DATE_STRUCT; typedef struct tagTIME_STRUCT { SQLUSMALLINT hour; SQLUSMALLINT minute; SQLUSMALLINT second; -} TIME_STRUCT, -SQL_TIME_STRUCT; +} TIME_STRUCT, + + SQL_TIME_STRUCT; typedef struct tagTIMESTAMP_STRUCT { @@ -406,8 +407,9 @@ typedef struct tagTIMESTAMP_STRUCT SQLUSMALLINT minute; SQLUSMALLINT second; SQLUINTEGER fraction; -} TIMESTAMP_STRUCT, -SQL_TIMESTAMP_STRUCT; +} TIMESTAMP_STRUCT, + + SQL_TIMESTAMP_STRUCT; /* postodbc doesn't use these but what the heck */ /* Don't know what SQL_MAX_NUMERIC_LEN should be so I can't include this. It's @@ -428,30 +430,30 @@ typedef struct tagSQLGUID WORD Data2; WORD Data3; BYTE Data4[8]; -} SQLGUID; +} SQLGUID; typedef enum { - SQL_IS_YEAR = 1, - SQL_IS_MONTH = 2, - SQL_IS_DAY = 3, - SQL_IS_HOUR = 4, - SQL_IS_MINUTE = 5, - SQL_IS_SECOND = 6, - SQL_IS_YEAR_TO_MONTH = 7, - SQL_IS_DAY_TO_HOUR = 8, - SQL_IS_DAY_TO_MINUTE = 9, - SQL_IS_DAY_TO_SECOND = 10, - SQL_IS_HOUR_TO_MINUTE = 11, - SQL_IS_HOUR_TO_SECOND = 12, - SQL_IS_MINUTE_TO_SECOND = 13 -} SQLINTERVAL; + SQL_IS_YEAR = 1, + SQL_IS_MONTH = 2, + SQL_IS_DAY = 3, + SQL_IS_HOUR = 4, + SQL_IS_MINUTE = 5, + SQL_IS_SECOND = 6, + SQL_IS_YEAR_TO_MONTH = 7, + SQL_IS_DAY_TO_HOUR = 8, + SQL_IS_DAY_TO_MINUTE = 9, + SQL_IS_DAY_TO_SECOND = 10, + SQL_IS_HOUR_TO_MINUTE = 11, + SQL_IS_HOUR_TO_SECOND = 12, + SQL_IS_MINUTE_TO_SECOND = 13 +} SQLINTERVAL; typedef struct tagSQL_YEAR_MONTH { SQLUINTEGER year; SQLUINTEGER month; -} SQL_YEAR_MONTH_STRUCT; +} SQL_YEAR_MONTH_STRUCT; typedef struct tagSQL_DAY_SECOND { @@ -460,7 +462,7 @@ typedef struct tagSQL_DAY_SECOND SQLUINTEGER minute; SQLUINTEGER second; SQLUINTEGER fraction; -} SQL_DAY_SECOND_STRUCT; +} SQL_DAY_SECOND_STRUCT; typedef struct tagSQL_INTERVAL_STRUCT { @@ -471,7 +473,7 @@ typedef struct tagSQL_INTERVAL_STRUCT SQL_YEAR_MONTH_STRUCT year_month; SQL_DAY_SECOND_STRUCT day_second; } intval; -} SQL_INTERVAL_STRUCT; +} SQL_INTERVAL_STRUCT; #define SQL_MAX_OPTION_STRING_LENGTH 256 #define SQL_NUM_EXTENSIONS (SQL_EXT_API_LAST - SQL_EXT_API_START + 1) @@ -1347,22 +1349,22 @@ extern "C" * function prototypes previously missing from isqlext.h */ RETCODE SQL_API SQLColumns(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLDriverConnect(HDBC hdbc, HWND hwnd, - UCHAR FAR *szConnStrIn, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, + SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion); RETCODE SQL_API SQLGetConnectOption(HDBC hdbc, @@ -1374,17 +1376,17 @@ extern "C" SWORD fCType, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLGetFunctions(HDBC hdbc, UWORD fFunction, - UWORD FAR *pfExists); + UWORD FAR * pfExists); RETCODE SQL_API SQLGetInfo(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, SWORD cbInfoValueMax, - SWORD FAR *pcbInfoValue); + SWORD FAR * pcbInfoValue); RETCODE SQL_API SQLGetStmtOption(HSTMT hstmt, UWORD fOption, @@ -1394,7 +1396,7 @@ extern "C" SWORD fSqlType); RETCODE SQL_API SQLParamData(HSTMT hstmt, - PTR FAR *prgbValue); + PTR FAR * prgbValue); RETCODE SQL_API SQLPutData(HSTMT hstmt, PTR rgbValue, @@ -1406,119 +1408,119 @@ extern "C" RETCODE SQL_API SQLSpecialColumns(HSTMT hstmt, UWORD fColType, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, UWORD fScope, UWORD fNullable); RETCODE SQL_API SQLStatistics(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, UWORD fUnique, UWORD fAccuracy); RETCODE SQL_API SQLTables(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szTableType, + UCHAR FAR * szTableType, SWORD cbTableType); RETCODE SQL_API SQLBrowseConnect(HDBC hdbc, - UCHAR FAR *szConnStrIn, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut); + SWORD FAR * pcbConnStrOut); RETCODE SQL_API SQLColumnPrivileges(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLDescribeParam(HSTMT hstmt, UWORD ipar, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable); + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable); RETCODE SQL_API SQLExtendedFetch(HSTMT hstmt, UWORD fFetchType, SDWORD irow, - UDWORD FAR *pcrow, - UWORD FAR *rgfRowStatus); + UDWORD FAR * pcrow, + UWORD FAR * rgfRowStatus); RETCODE SQL_API SQLForeignKeys(HSTMT hstmt, - UCHAR FAR *szPkTableQualifier, + UCHAR FAR * szPkTableQualifier, SWORD cbPkTableQualifier, - UCHAR FAR *szPkTableOwner, + UCHAR FAR * szPkTableOwner, SWORD cbPkTableOwner, - UCHAR FAR *szPkTableName, + UCHAR FAR * szPkTableName, SWORD cbPkTableName, - UCHAR FAR *szFkTableQualifier, + UCHAR FAR * szFkTableQualifier, SWORD cbFkTableQualifier, - UCHAR FAR *szFkTableOwner, + UCHAR FAR * szFkTableOwner, SWORD cbFkTableOwner, - UCHAR FAR *szFkTableName, + UCHAR FAR * szFkTableName, SWORD cbFkTableName); RETCODE SQL_API SQLMoreResults(HSTMT hstmt); RETCODE SQL_API SQLNativeSql(HDBC hdbc, - UCHAR FAR *szSqlStrIn, + UCHAR FAR * szSqlStrIn, SDWORD cbSqlStrIn, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStrMax, - SDWORD FAR *pcbSqlStr); + SDWORD FAR * pcbSqlStr); RETCODE SQL_API SQLNumParams(HSTMT hstmt, - SWORD FAR *pcpar); + SWORD FAR * pcpar); RETCODE SQL_API SQLParamOptions(HSTMT hstmt, UDWORD crow, - UDWORD FAR *pirow); + UDWORD FAR * pirow); RETCODE SQL_API SQLPrimaryKeys(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName); RETCODE SQL_API SQLProcedureColumns(HSTMT hstmt, - UCHAR FAR *szProcQualifier, + UCHAR FAR * szProcQualifier, SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, + UCHAR FAR * szProcOwner, SWORD cbProcOwner, - UCHAR FAR *szProcName, + UCHAR FAR * szProcName, SWORD cbProcName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLProcedures(HSTMT hstmt, - UCHAR FAR *szProcQualifier, + UCHAR FAR * szProcQualifier, SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, + UCHAR FAR * szProcOwner, SWORD cbProcOwner, - UCHAR FAR *szProcName, + UCHAR FAR * szProcName, SWORD cbProcName); RETCODE SQL_API SQLSetPos(HSTMT hstmt, @@ -1527,11 +1529,11 @@ extern "C" UWORD fLock); RETCODE SQL_API SQLTablePrivileges(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName); RETCODE SQL_API SQLBindParameter(HSTMT hstmt, @@ -1543,7 +1545,7 @@ extern "C" SWORD ibScale, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLSetScrollOptions(HSTMT hstmt, UWORD fConcurrency, @@ -1553,7 +1555,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif diff --git a/src/interfaces/odbc/lobj.c b/src/interfaces/odbc/lobj.c index 6b55b82d54..ab9c287e6a 100644 --- a/src/interfaces/odbc/lobj.c +++ b/src/interfaces/odbc/lobj.c @@ -18,7 +18,7 @@ Oid -lo_creat(ConnectionClass *conn, int mode) +lo_creat(ConnectionClass * conn, int mode) { LO_ARG argv[1]; int retval, @@ -36,7 +36,7 @@ lo_creat(ConnectionClass *conn, int mode) int -lo_open(ConnectionClass *conn, int lobjId, int mode) +lo_open(ConnectionClass * conn, int lobjId, int mode) { int fd; int result_len; @@ -61,7 +61,7 @@ lo_open(ConnectionClass *conn, int lobjId, int mode) int -lo_close(ConnectionClass *conn, int fd) +lo_close(ConnectionClass * conn, int fd) { LO_ARG argv[1]; int retval, @@ -79,7 +79,7 @@ lo_close(ConnectionClass *conn, int fd) int -lo_read(ConnectionClass *conn, int fd, char *buf, int len) +lo_read(ConnectionClass * conn, int fd, char *buf, int len) { LO_ARG argv[2]; int result_len; @@ -100,7 +100,7 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len) int -lo_write(ConnectionClass *conn, int fd, char *buf, int len) +lo_write(ConnectionClass * conn, int fd, char *buf, int len) { LO_ARG argv[2]; int retval, @@ -125,7 +125,7 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len) int -lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) +lo_lseek(ConnectionClass * conn, int fd, int offset, int whence) { LO_ARG argv[3]; int retval, @@ -151,7 +151,7 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) int -lo_tell(ConnectionClass *conn, int fd) +lo_tell(ConnectionClass * conn, int fd) { LO_ARG argv[1]; int retval, @@ -169,7 +169,7 @@ lo_tell(ConnectionClass *conn, int fd) int -lo_unlink(ConnectionClass *conn, Oid lobjId) +lo_unlink(ConnectionClass * conn, Oid lobjId) { LO_ARG argv[1]; int retval, diff --git a/src/interfaces/odbc/lobj.h b/src/interfaces/odbc/lobj.h index 4d720488a0..f245411c2c 100644 --- a/src/interfaces/odbc/lobj.h +++ b/src/interfaces/odbc/lobj.h @@ -35,13 +35,12 @@ struct lo_arg #define INV_WRITE 0x00020000 #define INV_READ 0x00040000 -Oid lo_creat(ConnectionClass *conn, int mode); -int lo_open(ConnectionClass *conn, int lobjId, int mode); -int lo_close(ConnectionClass *conn, int fd); -int lo_read(ConnectionClass *conn, int fd, char *buf, int len); -int lo_write(ConnectionClass *conn, int fd, char *buf, int len); -int lo_lseek(ConnectionClass *conn, int fd, int offset, int len); -int lo_tell(ConnectionClass *conn, int fd); -int lo_unlink(ConnectionClass *conn, Oid lobjId); - +Oid lo_creat(ConnectionClass * conn, int mode); +int lo_open(ConnectionClass * conn, int lobjId, int mode); +int lo_close(ConnectionClass * conn, int fd); +int lo_read(ConnectionClass * conn, int fd, char *buf, int len); +int lo_write(ConnectionClass * conn, int fd, char *buf, int len); +int lo_lseek(ConnectionClass * conn, int fd, int offset, int len); +int lo_tell(ConnectionClass * conn, int fd); +int lo_unlink(ConnectionClass * conn, Oid lobjId); #endif diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c index b17c45e311..443d1f47b3 100644 --- a/src/interfaces/odbc/misc.c +++ b/src/interfaces/odbc/misc.c @@ -30,7 +30,7 @@ #endif extern GLOBAL_VALUES globals; -void generate_filename(const char *, const char *, char *); +void generate_filename(const char *, const char *, char *); void @@ -58,15 +58,19 @@ generate_filename(const char *dirname, const char *prefix, char *filename) return; } -static int mylog_on = 0, qlog_on = 0; -void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) +static int mylog_on = 0, + qlog_on = 0; +void +logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) { - static int mylog_on_count = 0, mylog_off_count = 0, - qlog_on_count = 0, qlog_off_count = 0; + static int mylog_on_count = 0, + mylog_off_count = 0, + qlog_on_count = 0, + qlog_off_count = 0; if (mylog_onoff) mylog_on_count += cnopen; - else + else mylog_off_count += cnopen; if (mylog_on_count > 0) mylog_on = 1; @@ -76,7 +80,7 @@ void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) mylog_on = globals.debug; if (qlog_onoff) qlog_on_count += cnopen; - else + else qlog_off_count += cnopen; if (qlog_on_count > 0) qlog_on = 1; @@ -92,7 +96,7 @@ mylog(char *fmt,...) { va_list args; char filebuf[80]; - static FILE *LOGFP = NULL; + static FILE *LOGFP = NULL; if (mylog_on) { @@ -111,7 +115,6 @@ mylog(char *fmt,...) va_end(args); } } - #endif @@ -121,7 +124,7 @@ qlog(char *fmt,...) { va_list args; char filebuf[80]; - static FILE *LOGFP = NULL; + static FILE *LOGFP = NULL; if (qlog_on) { @@ -140,7 +143,6 @@ qlog(char *fmt,...) va_end(args); } } - #endif diff --git a/src/interfaces/odbc/misc.h b/src/interfaces/odbc/misc.h index 5cedd4c147..5237af6bbe 100644 --- a/src/interfaces/odbc/misc.h +++ b/src/interfaces/odbc/misc.h @@ -94,5 +94,4 @@ char *my_strcat(char *buf, const char *fmt, const char *s, int len); #define STRCPY_NULL (-2) int my_strcpy(char *dst, int dst_len, const char *src, int src_len); - #endif diff --git a/src/interfaces/odbc/multibyte.c b/src/interfaces/odbc/multibyte.c index fa81f4775f..b19af2764c 100644 --- a/src/interfaces/odbc/multibyte.c +++ b/src/interfaces/odbc/multibyte.c @@ -70,20 +70,20 @@ multibyte_init(void) unsigned char * check_client_encoding(unsigned char *str) { - if (strstr(str, "%27SJIS%27") || - strstr(str, "%27Shift_JIS%27") || - strstr(str, "'SJIS'") || - strstr(str, "'sjis'") || - strstr(str, "'Shift_JIS'")) + if (strstr(str, "%27SJIS%27") || + strstr(str, "%27Shift_JIS%27") || + strstr(str, "'SJIS'") || + strstr(str, "'sjis'") || + strstr(str, "'Shift_JIS'")) { multibyte_client_encoding = SJIS; return ("SJIS"); } - if (strstr(str, "%27BIG5%27") || - strstr(str, "%27Big5%27") || - strstr(str, "'BIG5'") || - strstr(str, "'big5'") || - strstr(str, "'Big5'")) + if (strstr(str, "%27BIG5%27") || + strstr(str, "%27Big5%27") || + strstr(str, "'BIG5'") || + strstr(str, "'big5'") || + strstr(str, "'Big5'")) { multibyte_client_encoding = BIG5; return ("BIG5"); @@ -106,7 +106,7 @@ multibyte_char_check(unsigned char s) switch (multibyte_client_encoding) { /* Japanese Shift-JIS(CP932) Support. */ - case SJIS: + case SJIS: { if (multibyte_status < 2 && s > 0x80 && !(s > 0x9f && s < 0xE0)) multibyte_status = 2; diff --git a/src/interfaces/odbc/odbcapi.c b/src/interfaces/odbc/odbcapi.c index cec41ea2e6..3b1b1a0fc3 100644 --- a/src/interfaces/odbc/odbcapi.c +++ b/src/interfaces/odbc/odbcapi.c @@ -18,16 +18,16 @@ SQLSetConnectOption, SQLSetCursorName, SQLSetParam, SQLSetStmtOption, SQLSpecialColumns, SQLStatistics, SQLTables, SQLTransact, SQLColAttributes, - SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch, - SQLForeignKeys, SQLMoreResults, SQLNativeSql, - SQLNumParams, SQLParamOptions, SQLPrimaryKeys, - SQLProcedureColumns, SQLProcedures, SQLSetPos, - SQLTablePrivileges, SQLBindParameter + SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch, + SQLForeignKeys, SQLMoreResults, SQLNativeSql, + SQLNumParams, SQLParamOptions, SQLPrimaryKeys, + SQLProcedureColumns, SQLProcedures, SQLSetPos, + SQLTablePrivileges, SQLBindParameter *------- */ #ifdef WIN32 -#define ODBCVER_REP 0x3000 +#define ODBCVER_REP 0x3000 #endif #include "psqlodbc.h" #include <stdio.h> @@ -37,214 +37,240 @@ #include "connection.h" #include "statement.h" -RETCODE SQL_API SQLAllocConnect(HENV EnvironmentHandle, - HDBC FAR *ConnectionHandle) +RETCODE SQL_API +SQLAllocConnect(HENV EnvironmentHandle, + HDBC FAR * ConnectionHandle) { mylog("[SQLAllocConnect]"); return PGAPI_AllocConnect(EnvironmentHandle, ConnectionHandle); } -RETCODE SQL_API SQLAllocEnv(HENV FAR *EnvironmentHandle) +RETCODE SQL_API +SQLAllocEnv(HENV FAR * EnvironmentHandle) { mylog("[SQLAllocEnv]"); return PGAPI_AllocEnv(EnvironmentHandle); } -RETCODE SQL_API SQLAllocStmt(HDBC ConnectionHandle, - HSTMT *StatementHandle) +RETCODE SQL_API +SQLAllocStmt(HDBC ConnectionHandle, + HSTMT * StatementHandle) { mylog("[SQLAllocStmt]"); return PGAPI_AllocStmt(ConnectionHandle, StatementHandle); } -RETCODE SQL_API SQLBindCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLBindCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLBindCol]"); return PGAPI_BindCol(StatementHandle, ColumnNumber, - TargetType, TargetValue, BufferLength, StrLen_or_Ind); + TargetType, TargetValue, BufferLength, StrLen_or_Ind); } -RETCODE SQL_API SQLCancel(HSTMT StatementHandle) +RETCODE SQL_API +SQLCancel(HSTMT StatementHandle) { mylog("[SQLCancel]"); return PGAPI_Cancel(StatementHandle); } -RETCODE SQL_API SQLColumns(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *ColumnName, SQLSMALLINT NameLength4) +RETCODE SQL_API +SQLColumns(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, SQLSMALLINT NameLength4) { mylog("[SQLColumns]"); return PGAPI_Columns(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, - ColumnName, NameLength4); + SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4); } -RETCODE SQL_API SQLConnect(HDBC ConnectionHandle, - SQLCHAR *ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, SQLSMALLINT NameLength3) +RETCODE SQL_API +SQLConnect(HDBC ConnectionHandle, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, + SQLCHAR * UserName, SQLSMALLINT NameLength2, + SQLCHAR * Authentication, SQLSMALLINT NameLength3) { mylog("[SQLConnect]"); return PGAPI_Connect(ConnectionHandle, ServerName, NameLength1, - UserName, NameLength2, Authentication, NameLength3); + UserName, NameLength2, Authentication, NameLength3); } -RETCODE SQL_API SQLDriverConnect(HDBC hdbc, - HWND hwnd, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, - UWORD fDriverCompletion) +RETCODE SQL_API +SQLDriverConnect(HDBC hdbc, + HWND hwnd, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, + UWORD fDriverCompletion) { mylog("[SQLDriverConnect]"); return PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); } -RETCODE SQL_API SQLBrowseConnect( - HDBC hdbc, - SQLCHAR *szConnStrIn, - SQLSMALLINT cbConnStrIn, - SQLCHAR *szConnStrOut, - SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT *pcbConnStrOut) +RETCODE SQL_API +SQLBrowseConnect( + HDBC hdbc, + SQLCHAR * szConnStrIn, + SQLSMALLINT cbConnStrIn, + SQLCHAR * szConnStrOut, + SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT * pcbConnStrOut) { mylog("[SQLBrowseConnect]"); return PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn, - szConnStrOut, cbConnStrOutMax, pcbConnStrOut); + szConnStrOut, cbConnStrOutMax, pcbConnStrOut); } -RETCODE SQL_API SQLDataSources(HENV EnvironmentHandle, - SQLUSMALLINT Direction, SQLCHAR *ServerName, - SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, - SQLCHAR *Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2) +RETCODE SQL_API +SQLDataSources(HENV EnvironmentHandle, + SQLUSMALLINT Direction, SQLCHAR * ServerName, + SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, + SQLSMALLINT * NameLength2) { mylog("[SQLDataSources]"); + /* - return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, - BufferLength1, NameLength1, Description, BufferLength2, - NameLength2); - */ + * return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, + * BufferLength1, NameLength1, Description, BufferLength2, + * NameLength2); + */ return SQL_ERROR; } -RETCODE SQL_API SQLDescribeCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, - SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, - SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize, - SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) +RETCODE SQL_API +SQLDescribeCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT * NameLength, + SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize, + SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable) { mylog("[SQLDescribeCol]"); return PGAPI_DescribeCol(StatementHandle, ColumnNumber, - ColumnName, BufferLength, NameLength, - DataType, ColumnSize, DecimalDigits, Nullable); + ColumnName, BufferLength, NameLength, + DataType, ColumnSize, DecimalDigits, Nullable); } -RETCODE SQL_API SQLDisconnect(HDBC ConnectionHandle) +RETCODE SQL_API +SQLDisconnect(HDBC ConnectionHandle) { mylog("[SQLDisconnect]"); return PGAPI_Disconnect(ConnectionHandle); } -RETCODE SQL_API SQLError(HENV EnvironmentHandle, - HDBC ConnectionHandle, HSTMT StatementHandle, - SQLCHAR *Sqlstate, SQLINTEGER *NativeError, - SQLCHAR *MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *TextLength) +RETCODE SQL_API +SQLError(HENV EnvironmentHandle, + HDBC ConnectionHandle, HSTMT StatementHandle, + SQLCHAR * Sqlstate, SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, + SQLSMALLINT * TextLength) { mylog("[SQLError]"); return PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle, - Sqlstate, NativeError, MessageText, BufferLength, TextLength); + Sqlstate, NativeError, MessageText, BufferLength, TextLength); } -RETCODE SQL_API SQLExecDirect(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength) +RETCODE SQL_API +SQLExecDirect(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength) { mylog("[SQLExecDirect]"); return PGAPI_ExecDirect(StatementHandle, StatementText, TextLength); } -RETCODE SQL_API SQLExecute(HSTMT StatementHandle) +RETCODE SQL_API +SQLExecute(HSTMT StatementHandle) { mylog("[SQLExecute]"); return PGAPI_Execute(StatementHandle); } -RETCODE SQL_API SQLFetch(HSTMT StatementHandle) +RETCODE SQL_API +SQLFetch(HSTMT StatementHandle) { - static char *func = "SQLFetch"; + static char *func = "SQLFetch"; + #if (ODBCVER >= 0x3000) - StatementClass *stmt = (StatementClass *) StatementHandle; + StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn = SC_get_conn(stmt); - if (conn->driver_version >= 0x0300) + + if (conn->driver_version >= 0x0300) { - SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; - SQLINTEGER *pcRow = stmt->options.rowsFetched; + SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; + SQLINTEGER *pcRow = stmt->options.rowsFetched; mylog("[[%s]]", func); - return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0, - pcRow, rowStatusArray); + return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0, + pcRow, rowStatusArray); } #endif mylog("[%s]", func); return PGAPI_Fetch(StatementHandle); } -RETCODE SQL_API SQLFreeConnect(HDBC ConnectionHandle) +RETCODE SQL_API +SQLFreeConnect(HDBC ConnectionHandle) { mylog("[SQLFreeStmt]"); return PGAPI_FreeConnect(ConnectionHandle); } -RETCODE SQL_API SQLFreeEnv(HENV EnvironmentHandle) +RETCODE SQL_API +SQLFreeEnv(HENV EnvironmentHandle) { mylog("[SQLFreeEnv]"); return PGAPI_FreeEnv(EnvironmentHandle); } -RETCODE SQL_API SQLFreeStmt(HSTMT StatementHandle, - SQLUSMALLINT Option) +RETCODE SQL_API +SQLFreeStmt(HSTMT StatementHandle, + SQLUSMALLINT Option) { mylog("[SQLFreeStmt]"); return PGAPI_FreeStmt(StatementHandle, Option); } -RETCODE SQL_API SQLGetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, PTR Value) +RETCODE SQL_API +SQLGetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, PTR Value) { mylog("[SQLGetConnectOption]"); return PGAPI_GetConnectOption(ConnectionHandle, Option, Value); -} -RETCODE SQL_API SQLGetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength) +} +RETCODE SQL_API +SQLGetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, + SQLSMALLINT * NameLength) { mylog("[SQLGetCursorName]"); return PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength, - NameLength); + NameLength); } -RETCODE SQL_API SQLGetData(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLGetData(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLGetData]"); return PGAPI_GetData(StatementHandle, ColumnNumber, TargetType, - TargetValue, BufferLength, StrLen_or_Ind); + TargetValue, BufferLength, StrLen_or_Ind); } -RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported) +RETCODE SQL_API +SQLGetFunctions(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported) { mylog("[SQLGetFunctions]"); #if (ODBCVER >= 0x3000) @@ -253,353 +279,386 @@ RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle, #endif return PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported); } -RETCODE SQL_API SQLGetInfo(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength) +RETCODE SQL_API +SQLGetInfo(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength) { #if (ODBCVER >= 0x3000) - RETCODE ret; + RETCODE ret; + mylog("[SQLGetInfo(30)]"); if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength)) == SQL_ERROR) + BufferLength, StringLength)) == SQL_ERROR) { if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x3000) return PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength); + BufferLength, StringLength); } return ret; #else mylog("[SQLGetInfo]"); return PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength); + BufferLength, StringLength); #endif } -RETCODE SQL_API SQLGetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, PTR Value) +RETCODE SQL_API +SQLGetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, PTR Value) { mylog("[SQLGetStmtOption]"); return PGAPI_GetStmtOption(StatementHandle, Option, Value); } -RETCODE SQL_API SQLGetTypeInfo(HSTMT StatementHandle, - SQLSMALLINT DataType) +RETCODE SQL_API +SQLGetTypeInfo(HSTMT StatementHandle, + SQLSMALLINT DataType) { mylog("[SQLGetTypeInfo]"); - return PGAPI_GetTypeInfo(StatementHandle,DataType); + return PGAPI_GetTypeInfo(StatementHandle, DataType); } -RETCODE SQL_API SQLNumResultCols(HSTMT StatementHandle, - SQLSMALLINT *ColumnCount) +RETCODE SQL_API +SQLNumResultCols(HSTMT StatementHandle, + SQLSMALLINT * ColumnCount) { mylog("[SQLNumResultCols]"); return PGAPI_NumResultCols(StatementHandle, ColumnCount); } -RETCODE SQL_API SQLParamData(HSTMT StatementHandle, - PTR *Value) +RETCODE SQL_API +SQLParamData(HSTMT StatementHandle, + PTR * Value) { mylog("[SQLParamData]"); return PGAPI_ParamData(StatementHandle, Value); } -RETCODE SQL_API SQLPrepare(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength) +RETCODE SQL_API +SQLPrepare(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength) { mylog("[SQLPrepare]"); return PGAPI_Prepare(StatementHandle, StatementText, TextLength); } -RETCODE SQL_API SQLPutData(HSTMT StatementHandle, - PTR Data, SQLINTEGER StrLen_or_Ind) +RETCODE SQL_API +SQLPutData(HSTMT StatementHandle, + PTR Data, SQLINTEGER StrLen_or_Ind) { mylog("[SQLPutData]"); return PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind); } -RETCODE SQL_API SQLRowCount(HSTMT StatementHandle, - SQLINTEGER *RowCount) +RETCODE SQL_API +SQLRowCount(HSTMT StatementHandle, + SQLINTEGER * RowCount) { mylog("[SQLRowCount]"); return PGAPI_RowCount(StatementHandle, RowCount); } -RETCODE SQL_API SQLSetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, SQLUINTEGER Value) +RETCODE SQL_API +SQLSetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, SQLUINTEGER Value) { mylog("[SQLSetConnectionOption]"); return PGAPI_SetConnectOption(ConnectionHandle, Option, Value); } -RETCODE SQL_API SQLSetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT NameLength) +RETCODE SQL_API +SQLSetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT NameLength) { mylog("[SQLSetCursorName]"); return PGAPI_SetCursorName(StatementHandle, CursorName, NameLength); } -RETCODE SQL_API SQLSetParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLSetParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLSetParam]"); + /* - return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType, - ParameterType, LengthPrecision, ParameterScale, ParameterValue, - StrLen_or_Ind); - */ - return SQL_ERROR; + * return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType, + * ParameterType, LengthPrecision, ParameterScale, ParameterValue, + * StrLen_or_Ind); + */ + return SQL_ERROR; } -RETCODE SQL_API SQLSetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, SQLUINTEGER Value) +RETCODE SQL_API +SQLSetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, SQLUINTEGER Value) { mylog("[SQLSetStmtOption]"); return PGAPI_SetStmtOption(StatementHandle, Option, Value); } -RETCODE SQL_API SQLSpecialColumns(HSTMT StatementHandle, - SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, - SQLSMALLINT NameLength1, SQLCHAR *SchemaName, - SQLSMALLINT NameLength2, SQLCHAR *TableName, - SQLSMALLINT NameLength3, SQLUSMALLINT Scope, - SQLUSMALLINT Nullable) +RETCODE SQL_API +SQLSpecialColumns(HSTMT StatementHandle, + SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, SQLCHAR * TableName, + SQLSMALLINT NameLength3, SQLUSMALLINT Scope, + SQLUSMALLINT Nullable) { mylog("[SQLSpecialColumns]"); return PGAPI_SpecialColumns(StatementHandle, IdentifierType, CatalogName, - NameLength1, SchemaName, NameLength2, TableName, NameLength3, - Scope, Nullable); + NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Scope, Nullable); } -RETCODE SQL_API SQLStatistics(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLUSMALLINT Unique, SQLUSMALLINT Reserved) +RETCODE SQL_API +SQLStatistics(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, SQLUSMALLINT Reserved) { mylog("[SQLStatistics]"); return PGAPI_Statistics(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, Unique, - Reserved); + SchemaName, NameLength2, TableName, NameLength3, Unique, + Reserved); } -RETCODE SQL_API SQLTables(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *TableType, SQLSMALLINT NameLength4) +RETCODE SQL_API +SQLTables(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * TableType, SQLSMALLINT NameLength4) { mylog("[SQLTables]"); return PGAPI_Tables(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, - TableType, NameLength4); + SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4); } -RETCODE SQL_API SQLTransact(HENV EnvironmentHandle, - HDBC ConnectionHandle, SQLUSMALLINT CompletionType) +RETCODE SQL_API +SQLTransact(HENV EnvironmentHandle, + HDBC ConnectionHandle, SQLUSMALLINT CompletionType) { mylog("[SQLTransact]"); return PGAPI_Transact(EnvironmentHandle, ConnectionHandle, CompletionType); } -RETCODE SQL_API SQLColAttributes( - HSTMT hstmt, - SQLUSMALLINT icol, - SQLUSMALLINT fDescType, - PTR rgbDesc, - SQLSMALLINT cbDescMax, - SQLSMALLINT *pcbDesc, - SQLINTEGER *pfDesc) +RETCODE SQL_API +SQLColAttributes( + HSTMT hstmt, + SQLUSMALLINT icol, + SQLUSMALLINT fDescType, + PTR rgbDesc, + SQLSMALLINT cbDescMax, + SQLSMALLINT * pcbDesc, + SQLINTEGER * pfDesc) { mylog("[SQLColAttributes]"); return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc, - cbDescMax, pcbDesc, pfDesc); + cbDescMax, pcbDesc, pfDesc); } -RETCODE SQL_API SQLColumnPrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName) +RETCODE SQL_API +SQLColumnPrivileges( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName) { mylog("[SQLColumnPrivileges]"); return PGAPI_ColumnPrivileges(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName, - szColumnName, cbColumnName); + szSchemaName, cbSchemaName, szTableName, cbTableName, + szColumnName, cbColumnName); } -RETCODE SQL_API SQLDescribeParam( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT *pfSqlType, - SQLUINTEGER *pcbParamDef, - SQLSMALLINT *pibScale, - SQLSMALLINT *pfNullable) +RETCODE SQL_API +SQLDescribeParam( + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT * pfSqlType, + SQLUINTEGER * pcbParamDef, + SQLSMALLINT * pibScale, + SQLSMALLINT * pfNullable) { mylog("[SQLDescribeParam]"); return PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, - pibScale, pfNullable); + pibScale, pfNullable); } -RETCODE SQL_API SQLExtendedFetch( - HSTMT hstmt, - SQLUSMALLINT fFetchType, - SQLINTEGER irow, - SQLUINTEGER *pcrow, - SQLUSMALLINT *rgfRowStatus) +RETCODE SQL_API +SQLExtendedFetch( + HSTMT hstmt, + SQLUSMALLINT fFetchType, + SQLINTEGER irow, + SQLUINTEGER * pcrow, + SQLUSMALLINT * rgfRowStatus) { mylog("[SQLExtendedFetch]"); return PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus); } -RETCODE SQL_API SQLForeignKeys( - HSTMT hstmt, - SQLCHAR *szPkCatalogName, - SQLSMALLINT cbPkCatalogName, - SQLCHAR *szPkSchemaName, - SQLSMALLINT cbPkSchemaName, - SQLCHAR *szPkTableName, - SQLSMALLINT cbPkTableName, - SQLCHAR *szFkCatalogName, - SQLSMALLINT cbFkCatalogName, - SQLCHAR *szFkSchemaName, - SQLSMALLINT cbFkSchemaName, - SQLCHAR *szFkTableName, - SQLSMALLINT cbFkTableName) +RETCODE SQL_API +SQLForeignKeys( + HSTMT hstmt, + SQLCHAR * szPkCatalogName, + SQLSMALLINT cbPkCatalogName, + SQLCHAR * szPkSchemaName, + SQLSMALLINT cbPkSchemaName, + SQLCHAR * szPkTableName, + SQLSMALLINT cbPkTableName, + SQLCHAR * szFkCatalogName, + SQLSMALLINT cbFkCatalogName, + SQLCHAR * szFkSchemaName, + SQLSMALLINT cbFkSchemaName, + SQLCHAR * szFkTableName, + SQLSMALLINT cbFkTableName) { mylog("[SQLForeignKeys]"); return PGAPI_ForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, - szPkSchemaName, cbPkSchemaName, szPkTableName, - cbPkTableName, szFkCatalogName, cbFkCatalogName, - szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); + szPkSchemaName, cbPkSchemaName, szPkTableName, + cbPkTableName, szFkCatalogName, cbFkCatalogName, + szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); } -RETCODE SQL_API SQLMoreResults(HSTMT hstmt) +RETCODE SQL_API +SQLMoreResults(HSTMT hstmt) { mylog("[SQLMoreResults]"); return PGAPI_MoreResults(hstmt); } - -RETCODE SQL_API SQLNativeSql( - HDBC hdbc, - SQLCHAR *szSqlStrIn, - SQLINTEGER cbSqlStrIn, - SQLCHAR *szSqlStr, - SQLINTEGER cbSqlStrMax, - SQLINTEGER *pcbSqlStr) + +RETCODE SQL_API +SQLNativeSql( + HDBC hdbc, + SQLCHAR * szSqlStrIn, + SQLINTEGER cbSqlStrIn, + SQLCHAR * szSqlStr, + SQLINTEGER cbSqlStrMax, + SQLINTEGER * pcbSqlStr) { mylog("[SQLNativeSql]"); return PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, - cbSqlStrMax, pcbSqlStr); + cbSqlStrMax, pcbSqlStr); } -RETCODE SQL_API SQLNumParams( - HSTMT hstmt, - SQLSMALLINT *pcpar) +RETCODE SQL_API +SQLNumParams( + HSTMT hstmt, + SQLSMALLINT * pcpar) { mylog("[SQLNumParams]"); return PGAPI_NumParams(hstmt, pcpar); } -RETCODE SQL_API SQLParamOptions( - HSTMT hstmt, - SQLUINTEGER crow, - SQLUINTEGER *pirow) +RETCODE SQL_API +SQLParamOptions( + HSTMT hstmt, + SQLUINTEGER crow, + SQLUINTEGER * pirow) { mylog("[SQLParamOptions]"); return PGAPI_ParamOptions(hstmt, crow, pirow); } -RETCODE SQL_API SQLPrimaryKeys( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName) +RETCODE SQL_API +SQLPrimaryKeys( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName) { mylog("[SQLPrimaryKeys]"); return PGAPI_PrimaryKeys(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName); + szSchemaName, cbSchemaName, szTableName, cbTableName); } -RETCODE SQL_API SQLProcedureColumns( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName) +RETCODE SQL_API +SQLProcedureColumns( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName) { mylog("[SQLProcedureColumns]"); return PGAPI_ProcedureColumns(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szProcName, cbProcName, - szColumnName, cbColumnName); + szSchemaName, cbSchemaName, szProcName, cbProcName, + szColumnName, cbColumnName); } -RETCODE SQL_API SQLProcedures( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName) +RETCODE SQL_API +SQLProcedures( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName) { mylog("[SQLProcedures]"); return PGAPI_Procedures(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szProcName, cbProcName); + szSchemaName, cbSchemaName, szProcName, cbProcName); } -RETCODE SQL_API SQLSetPos( - HSTMT hstmt, - SQLUSMALLINT irow, - SQLUSMALLINT fOption, - SQLUSMALLINT fLock) +RETCODE SQL_API +SQLSetPos( + HSTMT hstmt, + SQLUSMALLINT irow, + SQLUSMALLINT fOption, + SQLUSMALLINT fLock) { mylog("[SQLSetPos]"); return PGAPI_SetPos(hstmt, irow, fOption, fLock); } -RETCODE SQL_API SQLTablePrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName) +RETCODE SQL_API +SQLTablePrivileges( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName) { mylog("[SQLTablePrivileges]"); return PGAPI_TablePrivileges(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName); -} - -RETCODE SQL_API SQLBindParameter( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT fParamType, - SQLSMALLINT fCType, - SQLSMALLINT fSqlType, - SQLUINTEGER cbColDef, - SQLSMALLINT ibScale, - PTR rgbValue, - SQLINTEGER cbValueMax, - SQLINTEGER *pcbValue) + szSchemaName, cbSchemaName, szTableName, cbTableName); +} + +RETCODE SQL_API +SQLBindParameter( + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT fParamType, + SQLSMALLINT fCType, + SQLSMALLINT fSqlType, + SQLUINTEGER cbColDef, + SQLSMALLINT ibScale, + PTR rgbValue, + SQLINTEGER cbValueMax, + SQLINTEGER * pcbValue) { mylog("[SQLBindParameter]"); return PGAPI_BindParameter(hstmt, ipar, fParamType, fCType, - fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, - pcbValue); + fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, + pcbValue); } diff --git a/src/interfaces/odbc/odbcapi30.c b/src/interfaces/odbc/odbcapi30.c index cce9c37d42..ccd214a69d 100644 --- a/src/interfaces/odbc/odbcapi30.c +++ b/src/interfaces/odbc/odbcapi30.c @@ -29,8 +29,9 @@ #include "pgapifunc.h" /* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */ -RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, - SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) +RETCODE SQL_API +SQLAllocHandle(SQLSMALLINT HandleType, + SQLHANDLE InputHandle, SQLHANDLE * OutputHandle) { mylog("[[SQLAllocHandle]]"); switch (HandleType) @@ -41,71 +42,87 @@ RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, return PGAPI_AllocConnect(InputHandle, OutputHandle); case SQL_HANDLE_STMT: return PGAPI_AllocStmt(InputHandle, OutputHandle); - default: break; + default: + break; } return SQL_ERROR; } + /* SQLBindParameter/SQLSetParam -> SQLBindParam */ -RETCODE SQL_API SQLBindParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLBindParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind) { - int BufferLength = 512; /* Is it OK ? */ + int BufferLength = 512; /* Is it OK ? */ + mylog("[[SQLBindParam]]"); return PGAPI_BindParameter(StatementHandle, ParameterNumber, SQL_PARAM_INPUT, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, BufferLength, StrLen_or_Ind); } + /* New function */ -RETCODE SQL_API SQLCloseCursor(HSTMT StatementHandle) +RETCODE SQL_API +SQLCloseCursor(HSTMT StatementHandle) { mylog("[[SQLCloseCursor]]"); return PGAPI_FreeStmt(StatementHandle, SQL_CLOSE); } /* SQLColAttributes -> SQLColAttribute */ -RETCODE SQL_API SQLColAttribute (HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, - PTR CharacterAttribute, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength, PTR NumericAttribute) +RETCODE SQL_API +SQLColAttribute(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, + PTR CharacterAttribute, SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength, PTR NumericAttribute) { mylog("[[SQLColAttribute]]"); return PGAPI_ColAttributes(StatementHandle, ColumnNumber, - FieldIdentifier, CharacterAttribute, BufferLength, - StringLength, NumericAttribute); + FieldIdentifier, CharacterAttribute, BufferLength, + StringLength, NumericAttribute); } + /* new function */ -RETCODE SQL_API SQLCopyDesc(SQLHDESC SourceDescHandle, - SQLHDESC TargetDescHandle) +RETCODE SQL_API +SQLCopyDesc(SQLHDESC SourceDescHandle, + SQLHDESC TargetDescHandle) { mylog("[[SQLCopyDesc]]\n"); return SQL_ERROR; } -/* SQLTransact -> SQLEndTran */ -RETCODE SQL_API SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT CompletionType) + +/* SQLTransact -> SQLEndTran */ +RETCODE SQL_API +SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT CompletionType) { mylog("[[SQLEndTran]]"); switch (HandleType) { - case SQL_HANDLE_ENV: + case SQL_HANDLE_ENV: return PGAPI_Transact(Handle, SQL_NULL_HDBC, CompletionType); - case SQL_HANDLE_DBC: + case SQL_HANDLE_DBC: return PGAPI_Transact(SQL_NULL_HENV, Handle, CompletionType); - default:break; + default: + break; } - return SQL_ERROR; /* SQLSTATE HY092 ("Invalid attribute/option identifier")*/ + return SQL_ERROR; /* SQLSTATE HY092 ("Invalid + * attribute/option identifier") */ } + /* SQLExtendedFetch -> SQLFetchScroll */ -RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle, - SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset) +RETCODE SQL_API +SQLFetchScroll(HSTMT StatementHandle, + SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset) { static char *func = "SQLFetchScroll"; - StatementClass *stmt = (StatementClass *) StatementHandle; - RETCODE ret; - SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; - SQLINTEGER *pcRow = stmt->options.rowsFetched; + StatementClass *stmt = (StatementClass *) StatementHandle; + RETCODE ret; + SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; + SQLINTEGER *pcRow = stmt->options.rowsFetched; + mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset); if (FetchOrientation == SQL_FETCH_BOOKMARK) { @@ -120,13 +137,15 @@ RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle, } } ret = PGAPI_ExtendedFetch(StatementHandle, FetchOrientation, FetchOffset, - pcRow, rowStatusArray); + pcRow, rowStatusArray); if (ret != SQL_SUCCESS) mylog("%s return = %d\n", func, ret); return ret; } + /* SQLFree(Connect/Env/Stmt) -> SQLFreeHandle */ -RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) +RETCODE SQL_API +SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) { mylog("[[SQLFreeHandle]]"); switch (HandleType) @@ -137,83 +156,97 @@ RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) return PGAPI_FreeConnect(Handle); case SQL_HANDLE_STMT: return PGAPI_FreeStmt(Handle, SQL_DROP); - default: break; + default: + break; } return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDescField(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, - PTR Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, + PTR Value, SQLINTEGER BufferLength, + SQLINTEGER * StringLength) { mylog("[[SQLGetDescField]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLCHAR *Name, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, - SQLSMALLINT *Type, SQLSMALLINT *SubType, - SQLINTEGER *Length, SQLSMALLINT *Precision, - SQLSMALLINT *Scale, SQLSMALLINT *Nullable) +RETCODE SQL_API +SQLGetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLCHAR * Name, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength, + SQLSMALLINT * Type, SQLSMALLINT * SubType, + SQLINTEGER * Length, SQLSMALLINT * Precision, + SQLSMALLINT * Scale, SQLSMALLINT * Nullable) { mylog("[[SQLGetDescRec]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, - PTR DiagInfo, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength) +RETCODE SQL_API +SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, + PTR DiagInfo, SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength) { mylog("[[SQLGetDiagField]]\n"); return SQL_ERROR; } + /* SQLError -> SQLDiagRec */ -RETCODE SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, SQLCHAR *MessageText, - SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) +RETCODE SQL_API +SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, SQLCHAR * MessageText, + SQLSMALLINT BufferLength, SQLSMALLINT * TextLength) { - RETCODE ret; + RETCODE ret; + mylog("[[SQLGetDiagRec]]\n"); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_Error(Handle, NULL, NULL, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + MessageText, BufferLength, TextLength); break; case SQL_HANDLE_DBC: - ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError, + MessageText, BufferLength, TextLength); break; case SQL_HANDLE_STMT: ret = PGAPI_Error(NULL, NULL, Handle, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + MessageText, BufferLength, TextLength); break; default: ret = SQL_ERROR; } if (ret == SQL_SUCCESS_WITH_INFO && - BufferLength == 0 && - *TextLength) + BufferLength == 0 && + *TextLength) { - SQLSMALLINT BufferLength = *TextLength + 4; - SQLCHAR *MessageText = malloc(BufferLength); + SQLSMALLINT BufferLength = *TextLength + 4; + SQLCHAR *MessageText = malloc(BufferLength); + ret = SQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, - NativeError, MessageText, BufferLength, - TextLength); + NativeError, MessageText, BufferLength, + TextLength); free(MessageText); } return ret; } + /* new function */ -RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetEnvAttr(HENV EnvironmentHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; + mylog("[[SQLGetEnvAttr]] %d\n", Attribute); switch (Attribute) { @@ -235,12 +268,15 @@ RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle, } return SQL_SUCCESS; } + /* SQLGetConnectOption -> SQLGetconnectAttr */ -RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetConnectAttr(HDBC ConnectionHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { - ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + mylog("[[SQLGetConnectAttr]] %d\n", Attribute); switch (Attribute) { @@ -253,70 +289,79 @@ RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle, conn->errormsg = "Unsupported connection option (Set)"; return SQL_ERROR; } - return PGAPI_GetConnectOption (ConnectionHandle, (UWORD) Attribute, Value); + return PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value); } + /* SQLGetStmtOption -> SQLGetStmtAttr */ -RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetStmtAttr(HSTMT StatementHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { static char *func = "SQLGetStmtAttr"; - StatementClass *stmt = (StatementClass *) StatementHandle; - RETCODE ret = SQL_SUCCESS; - int len = 0; + StatementClass *stmt = (StatementClass *) StatementHandle; + RETCODE ret = SQL_SUCCESS; + int len = 0; + mylog("[[%s]] %d\n", func, Attribute); switch (Attribute) { - case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ + case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ Value = stmt->options.bookmark_ptr; + len = 4; - break; + break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ Value = stmt->options.rowStatusArray; + len = 4; break; - case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ + case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ Value = stmt->options.rowsFetched; + len = 4; break; case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ *((SQLUINTEGER *) Value) = stmt->options.rowset_size; len = 4; - break; - case SQL_ATTR_APP_ROW_DESC: /* 10010 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + break; + case SQL_ATTR_APP_ROW_DESC: /* 10010 */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; + break; case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; - case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + break; + case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; + break; case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; - case SQL_ATTR_AUTO_IPD: /* 10001 */ + break; + case SQL_ATTR_AUTO_IPD:/* 10001 */ case SQL_ATTR_ROW_BIND_TYPE: /* == SQL_BIND_TYPE */ case SQL_ATTR_PARAMSET_SIZE: /* 22 */ - case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ - case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ + case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ + case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ - case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ - case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ + case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ + case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ - case SQL_ATTR_METADATA_ID: /* 10014 */ - /* case SQL_ATTR_PREDICATE_PTR: - case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */ + case SQL_ATTR_METADATA_ID: /* 10014 */ + + /* + * case SQL_ATTR_PREDICATE_PTR: case + * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: + */ case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ - case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ - case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ - case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ - case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ + case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ + case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ + case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ + case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER; stmt->errormsg = "Unsupported statement option (Get)"; SC_log_error(func, "", stmt); @@ -331,11 +376,12 @@ RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle, } /* SQLSetConnectOption -> SQLSetConnectAttr */ -RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetConnectAttr(HDBC ConnectionHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { - ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; mylog("[[SQLSetConnectAttr]] %d\n", Attribute); switch (Attribute) @@ -351,31 +397,38 @@ RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle, } return PGAPI_SetConnectOption(ConnectionHandle, (UWORD) Attribute, (UDWORD) Value); } + /* new function */ -RETCODE SQL_API SQLSetDescField(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, - PTR Value, SQLINTEGER BufferLength) +RETCODE SQL_API +SQLSetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, + PTR Value, SQLINTEGER BufferLength) { mylog("[[SQLSetDescField]]\n"); return SQL_ERROR; } + /* new fucntion */ -RETCODE SQL_API SQLSetDescRec(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT Type, - SQLSMALLINT SubType, SQLINTEGER Length, - SQLSMALLINT Precision, SQLSMALLINT Scale, - PTR Data, SQLINTEGER *StringLength, - SQLINTEGER *Indicator) +RETCODE SQL_API +SQLSetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT Type, + SQLSMALLINT SubType, SQLINTEGER Length, + SQLSMALLINT Precision, SQLSMALLINT Scale, + PTR Data, SQLINTEGER * StringLength, + SQLINTEGER * Indicator) { mylog("[[SQLsetDescRec]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetEnvAttr(HENV EnvironmentHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; + mylog("[[SQLSetEnvAttr]] att=%d,%u\n", Attribute, Value); switch (Attribute) { @@ -402,59 +455,69 @@ RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle, env->errormsg = "SetEnv changed to "; return SQL_SUCCESS_WITH_INFO; } + /* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */ -RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetStmtAttr(HSTMT StatementHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { static char *func = "SQLSetStmtAttr"; - StatementClass *stmt = (StatementClass *) StatementHandle; - UDWORD rowcount; + StatementClass *stmt = (StatementClass *) StatementHandle; + UDWORD rowcount; + mylog("[[%s]] %d,%u\n", func, Attribute, Value); switch (Attribute) { case SQL_ATTR_PARAMSET_SIZE: /* 22 */ return PGAPI_ParamOptions(StatementHandle, (UWORD) Value, &rowcount); - case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ - case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ + case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ + case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ - case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ - case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ + case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ + case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ - case SQL_ATTR_APP_ROW_DESC: /* 10010 */ + case SQL_ATTR_APP_ROW_DESC: /* 10010 */ case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ - case SQL_ATTR_AUTO_IPD: /* 10001 */ - /*case SQL_ATTR_ROW_BIND_TYPE:*/ /* == SQL_BIND_TYPE */ - case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ + case SQL_ATTR_AUTO_IPD:/* 10001 */ + /* case SQL_ATTR_ROW_BIND_TYPE: *//* == SQL_BIND_TYPE */ + case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ - case SQL_ATTR_METADATA_ID: /* 10014 */ - /* case SQL_ATTR_PREDICATE_PTR: - case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */ + case SQL_ATTR_METADATA_ID: /* 10014 */ + + /* + * case SQL_ATTR_PREDICATE_PTR: case + * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: + */ case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ - case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ - case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ - case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ - case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ + case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ + case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ + case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ + case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER; stmt->errormsg = "Unsupported statement option (Set)"; SC_log_error(func, "", stmt); return SQL_ERROR; - - case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ + + case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ stmt->options.bookmark_ptr = Value; + break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ stmt->options.rowStatusArray = (SQLUSMALLINT *) Value; + break; - case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ + case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ stmt->options.rowsFetched = (SQLUINTEGER *) Value; + break; - case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ + case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ stmt->options.rowset_size = (SQLUINTEGER) Value; + break; - default: + default: return PGAPI_SetStmtOption(StatementHandle, (UWORD) Attribute, (UDWORD) Value); } return SQL_SUCCESS; @@ -464,8 +527,8 @@ RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle, (*(((UWORD*) (pfExists)) + ((uwAPI) >> 4)) \ |= (1 << ((uwAPI) & 0x000F)) \ ) -RETCODE SQL_API -PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR *pfExists) +RETCODE SQL_API +PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR * pfExists) { if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS) return SQL_ERROR; @@ -474,98 +537,119 @@ PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR *pfExists) /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCSTMT); 3 deprecated */ - /* for (i = SQL_API_SQLBINDCOL; i <= 23; i++) - SQL_FUNC_ESET(pfExists, i); */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */ + + /* + * for (i = SQL_API_SQLBINDCOL; i <= 23; i++) SQL_FUNC_ESET(pfExists, + * i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCANCEL); /* 5 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLERROR); 10 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREECONNECT); 14 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEENV); 15 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPARAM); 22 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLTRANSACT); 23 deprecated */ - /*for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++) - SQL_FUNC_ESET(pfExists, i);*/ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */ + + /* + * for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++) + * SQL_FUNC_ESET(pfExists, i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTOPTION); 42 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTOPTION); 46 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */ - /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 deprecated */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */ + + /* + * SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 + * deprecated + */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTOPTION); 51 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSPECIALCOLUMNS); /* 52 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLES); /* 54 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLEXTENDEDFETCH); 59 deprecated */ - /*for (++i; i < SQL_API_SQLBINDPARAMETER; i++) - SQL_FUNC_ESET(pfExists, i);*/ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */ + + /* + * for (++i; i < SQL_API_SQLBINDPARAMETER; i++) + * SQL_FUNC_ESET(pfExists, i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMOPTIONS); 64 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPOS); /* 68 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */ - /*SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS);*/ /* 71 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */ - - SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC);/* 1004 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */ + /* SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS); *//* 71 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */ + + SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC); /* 1004 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD);/* 1008 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC);/* 1009 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD);/* 1010 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS);/* 24 not implemented yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS); /* 24 not implemented + * yet */ return SQL_SUCCESS; } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, - SWORD cbInfoValueMax, SWORD FAR *pcbInfoValue) + SWORD cbInfoValueMax, SWORD FAR * pcbInfoValue) { static char *func = "PGAPI_GetInfo30"; ConnectionClass *conn = (ConnectionClass *) hdbc; - char *p = NULL; - int len = 0, value = 0; - RETCODE result; + char *p = NULL; + int len = 0, + value = 0; + RETCODE result; switch (fInfoType) { diff --git a/src/interfaces/odbc/options.c b/src/interfaces/odbc/options.c index bc221186ba..5668d8f2d1 100644 --- a/src/interfaces/odbc/options.c +++ b/src/interfaces/odbc/options.c @@ -24,21 +24,21 @@ -RETCODE set_statement_option(ConnectionClass *conn, - StatementClass *stmt, +RETCODE set_statement_option(ConnectionClass * conn, + StatementClass * stmt, UWORD fOption, UDWORD vParam); RETCODE -set_statement_option(ConnectionClass *conn, - StatementClass *stmt, +set_statement_option(ConnectionClass * conn, + StatementClass * stmt, UWORD fOption, UDWORD vParam) { static char *func = "set_statement_option"; char changed = FALSE; - ConnInfo *ci = NULL; + ConnInfo *ci = NULL; if (conn) ci = &(conn->connInfo); @@ -67,19 +67,19 @@ set_statement_option(ConnectionClass *conn, if (ci->drivers.lie || vParam == SQL_CONCUR_READ_ONLY || vParam == SQL_CONCUR_ROWVER) { if (conn) - conn->stmtOptions.scroll_concurrency = vParam; - if (stmt) - stmt->options.scroll_concurrency = vParam; + conn->stmtOptions.scroll_concurrency = vParam; + if (stmt) + stmt->options.scroll_concurrency = vParam; } - else + else { - if (conn) - conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER; - if (stmt) - stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER; - changed = TRUE; - } - break; + if (conn) + conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER; + if (stmt) + stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER; + changed = TRUE; + } + break; case SQL_CURSOR_TYPE: @@ -275,11 +275,11 @@ set_statement_option(ConnectionClass *conn, /* Implements only SQL_AUTOCOMMIT */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetConnectOption( - HDBC hdbc, - UWORD fOption, - UDWORD vParam) + HDBC hdbc, + UWORD fOption, + UDWORD vParam) { static char *func = "PGAPI_SetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -296,7 +296,6 @@ PGAPI_SetConnectOption( switch (fOption) { - /* * Statement Options (apply to all stmts on the connection and * become defaults for new stmts) @@ -428,15 +427,15 @@ PGAPI_SetConnectOption( /* This function just can tell you whether you are in Autcommit mode or not */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetConnectOption( - HDBC hdbc, - UWORD fOption, - PTR pvParam) + HDBC hdbc, + UWORD fOption, + PTR pvParam) { static char *func = "PGAPI_GetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; - ConnInfo *ci = &(conn->connInfo); + ConnInfo *ci = &(conn->connInfo); mylog("%s: entering...\n", func); @@ -505,11 +504,11 @@ PGAPI_GetConnectOption( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetStmtOption( - HSTMT hstmt, - UWORD fOption, - UDWORD vParam) + HSTMT hstmt, + UWORD fOption, + UDWORD vParam) { static char *func = "PGAPI_SetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; @@ -531,16 +530,16 @@ PGAPI_SetStmtOption( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetStmtOption( - HSTMT hstmt, - UWORD fOption, - PTR pvParam) + HSTMT hstmt, + UWORD fOption, + PTR pvParam) { static char *func = "PGAPI_GetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); mylog("%s: entering...\n", func); diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c index 4fa7fffea5..60d16d5c1c 100644 --- a/src/interfaces/odbc/parse.c +++ b/src/interfaces/odbc/parse.c @@ -43,8 +43,8 @@ #define COL_INCR 16 char *getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric); -void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k); -char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi); +void getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k); +char searchColInfo(COL_INFO * col_info, FIELD_INFO * fi); char * @@ -90,7 +90,7 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu token[out++] = s[i++]; continue; } -#endif +#endif /* Handle quoted stuff */ if (out == 0 && (s[i] == '\"' || s[i] == '\'')) { @@ -115,13 +115,11 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu token[out++] = s[i++]; continue; } -#endif +#endif if (s[i] == qc && !in_escape) break; if (s[i] == '\\' && !in_escape) - { in_escape = TRUE; - } else { in_escape = FALSE; @@ -218,9 +216,10 @@ QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4); #endif void -getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) +getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k) { - char *str; + char *str; + if (fi->name[0] == '\0') strcpy(fi->name, QR_get_value_manual(col_info->result, k, 3)); @@ -237,7 +236,7 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) char -searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) +searchColInfo(COL_INFO * col_info, FIELD_INFO * fi) { int k, cmp; @@ -266,7 +265,7 @@ searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) char -parse_statement(StatementClass *stmt) +parse_statement(StatementClass * stmt) { static char *func = "parse_statement"; char token[256]; @@ -275,7 +274,8 @@ parse_statement(StatementClass *stmt) dquote, numeric, unquoted; - char *ptr, *pptr = NULL; + char *ptr, + *pptr = NULL; char in_select = FALSE, in_distinct = FALSE, in_on = FALSE, @@ -342,7 +342,7 @@ parse_statement(StatementClass *stmt) in_select = FALSE; in_from = TRUE; if (!from_found && - (!strnicmp(pptr, "from", 4))) + (!strnicmp(pptr, "from", 4))) { mylog("First "); from_found = TRUE; @@ -355,21 +355,21 @@ parse_statement(StatementClass *stmt) if (unquoted && blevel == 0) { if ((!stricmp(token, "where") || - !stricmp(token, "union") || - !stricmp(token, "intersect") || - !stricmp(token, "except") || - !stricmp(token, "order") || - !stricmp(token, "group") || - !stricmp(token, "having"))) + !stricmp(token, "union") || + !stricmp(token, "intersect") || + !stricmp(token, "except") || + !stricmp(token, "order") || + !stricmp(token, "group") || + !stricmp(token, "having"))) { in_select = FALSE; in_from = FALSE; in_where = TRUE; if (!first_where && - (!stricmp(token, "where"))) + (!stricmp(token, "where"))) first_where = ptr - stmt->statement; - + mylog("WHERE...\n"); break; } @@ -475,7 +475,7 @@ parse_statement(StatementClass *stmt) if (quote) { fi[stmt->nfld++]->quote = TRUE; -in_expr = TRUE; + in_expr = TRUE; continue; } else if (numeric) @@ -614,8 +614,8 @@ in_expr = TRUE; if ((unsigned char) *ptr >= 0x80) ptr++; else -#endif /* MULTIBYTE */ - *ptr = tolower((unsigned char) *ptr); +#endif /* MULTIBYTE */ + *ptr = tolower((unsigned char) *ptr); } } mylog("got table = '%s'\n", ti[stmt->ntab]->name); @@ -655,10 +655,11 @@ in_expr = TRUE; else if (fi[i]->quote) { /* handle as text */ fi[i]->ti = NULL; + /* - fi[i]->type = PG_TYPE_TEXT; - fi[i]->precision = 0; - the following may be better */ + * fi[i]->type = PG_TYPE_TEXT; fi[i]->precision = 0; the + * following may be better + */ fi[i]->type = PG_TYPE_UNKNOWN; fi[i]->precision = 254; continue; diff --git a/src/interfaces/odbc/pgapifunc.h b/src/interfaces/odbc/pgapifunc.h index 72a5286e9f..465808f0ea 100644 --- a/src/interfaces/odbc/pgapifunc.h +++ b/src/interfaces/odbc/pgapifunc.h @@ -3,241 +3,241 @@ * *------- */ -#ifndef _PG_API_FUNC_H__ -#define _PG_API_FUNC_H__ +#ifndef _PG_API_FUNC_H__ +#define _PG_API_FUNC_H__ #include "psqlodbc.h" #include <stdio.h> #include <string.h> -RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, - HDBC FAR *ConnectionHandle); -RETCODE SQL_API PGAPI_AllocEnv(HENV FAR *EnvironmentHandle); -RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle, - HSTMT *StatementHandle); -RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *ColumnName, SQLSMALLINT NameLength4); -RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle, - SQLCHAR *ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, SQLSMALLINT NameLength3); -RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, - UCHAR FAR *szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, UWORD fDriverCompletion); +RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, + HDBC FAR * ConnectionHandle); +RETCODE SQL_API PGAPI_AllocEnv(HENV FAR * EnvironmentHandle); +RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle, + HSTMT * StatementHandle); +RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, SQLSMALLINT NameLength4); +RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, + SQLCHAR * UserName, SQLSMALLINT NameLength2, + SQLCHAR * Authentication, SQLSMALLINT NameLength3); +RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion); RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc, - SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT *pcbConnStrOut); -RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle, - SQLUSMALLINT Direction, SQLCHAR *ServerName, - SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, - SQLCHAR *Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2); -RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, - SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, - SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize, - SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable); -RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle); -RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle, - HDBC ConnectionHandle, HSTMT StatementHandle, - SQLCHAR *Sqlstate, SQLINTEGER *NativeError, - SQLCHAR *MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *TextLength); -RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength); -RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle); -RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle); -RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle, - SQLUSMALLINT Option); -RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, PTR Value); -RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength); -RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); -RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); -RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength); -RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength); -RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, PTR Value); -RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle, - SQLSMALLINT DataType); -RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle, - SQLSMALLINT *ColumnCount); -RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle, - PTR *Value); -RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength); -RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle, - PTR Data, SQLINTEGER StrLen_or_Ind); -RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle, - SQLINTEGER *RowCount); -RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, SQLUINTEGER Value); -RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT NameLength); -RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, SQLUINTEGER Value); -RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle, - SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, - SQLSMALLINT NameLength1, SQLCHAR *SchemaName, - SQLSMALLINT NameLength2, SQLCHAR *TableName, - SQLSMALLINT NameLength3, SQLUSMALLINT Scope, - SQLUSMALLINT Nullable); -RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLUSMALLINT Unique, SQLUSMALLINT Reserved); -RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *TableType, SQLSMALLINT NameLength4); -RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle, - HDBC ConnectionHandle, SQLUSMALLINT CompletionType); + SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, + SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT * pcbConnStrOut); +RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle, + SQLUSMALLINT Direction, SQLCHAR * ServerName, + SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, + SQLSMALLINT * NameLength2); +RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT * NameLength, + SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize, + SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable); +RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle); +RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle, + HDBC ConnectionHandle, HSTMT StatementHandle, + SQLCHAR * Sqlstate, SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, + SQLSMALLINT * TextLength); +RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength); +RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle); +RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle); +RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle, + SQLUSMALLINT Option); +RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, PTR Value); +RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, + SQLSMALLINT * NameLength); +RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported); +RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported); +RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength); +RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength); +RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, PTR Value); +RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle, + SQLSMALLINT DataType); +RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle, + SQLSMALLINT * ColumnCount); +RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle, + PTR * Value); +RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength); +RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle, + PTR Data, SQLINTEGER StrLen_or_Ind); +RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle, + SQLINTEGER * RowCount); +RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, SQLUINTEGER Value); +RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT NameLength); +RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, SQLUINTEGER Value); +RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle, + SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, SQLCHAR * TableName, + SQLSMALLINT NameLength3, SQLUSMALLINT Scope, + SQLUSMALLINT Nullable); +RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, SQLUSMALLINT Reserved); +RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * TableType, SQLSMALLINT NameLength4); +RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle, + HDBC ConnectionHandle, SQLUSMALLINT CompletionType); RETCODE SQL_API PGAPI_ColAttributes( - HSTMT hstmt, - SQLUSMALLINT icol, - SQLUSMALLINT fDescType, - PTR rgbDesc, - SQLSMALLINT cbDescMax, - SQLSMALLINT *pcbDesc, - SQLINTEGER *pfDesc); + HSTMT hstmt, + SQLUSMALLINT icol, + SQLUSMALLINT fDescType, + PTR rgbDesc, + SQLSMALLINT cbDescMax, + SQLSMALLINT * pcbDesc, + SQLINTEGER * pfDesc); RETCODE SQL_API PGAPI_ColumnPrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName); RETCODE SQL_API PGAPI_DescribeParam( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT *pfSqlType, - SQLUINTEGER *pcbParamDef, - SQLSMALLINT *pibScale, - SQLSMALLINT *pfNullable); + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT * pfSqlType, + SQLUINTEGER * pcbParamDef, + SQLSMALLINT * pibScale, + SQLSMALLINT * pfNullable); RETCODE SQL_API PGAPI_ExtendedFetch( - HSTMT hstmt, - SQLUSMALLINT fFetchType, - SQLINTEGER irow, - SQLUINTEGER *pcrow, - SQLUSMALLINT *rgfRowStatus); + HSTMT hstmt, + SQLUSMALLINT fFetchType, + SQLINTEGER irow, + SQLUINTEGER * pcrow, + SQLUSMALLINT * rgfRowStatus); RETCODE SQL_API PGAPI_ForeignKeys( - HSTMT hstmt, - SQLCHAR *szPkCatalogName, - SQLSMALLINT cbPkCatalogName, - SQLCHAR *szPkSchemaName, - SQLSMALLINT cbPkSchemaName, - SQLCHAR *szPkTableName, - SQLSMALLINT cbPkTableName, - SQLCHAR *szFkCatalogName, - SQLSMALLINT cbFkCatalogName, - SQLCHAR *szFkSchemaName, - SQLSMALLINT cbFkSchemaName, - SQLCHAR *szFkTableName, - SQLSMALLINT cbFkTableName); + HSTMT hstmt, + SQLCHAR * szPkCatalogName, + SQLSMALLINT cbPkCatalogName, + SQLCHAR * szPkSchemaName, + SQLSMALLINT cbPkSchemaName, + SQLCHAR * szPkTableName, + SQLSMALLINT cbPkTableName, + SQLCHAR * szFkCatalogName, + SQLSMALLINT cbFkCatalogName, + SQLCHAR * szFkSchemaName, + SQLSMALLINT cbFkSchemaName, + SQLCHAR * szFkTableName, + SQLSMALLINT cbFkTableName); RETCODE SQL_API PGAPI_MoreResults( - HSTMT hstmt); + HSTMT hstmt); RETCODE SQL_API PGAPI_NativeSql( - HDBC hdbc, - SQLCHAR *szSqlStrIn, - SQLINTEGER cbSqlStrIn, - SQLCHAR *szSqlStr, - SQLINTEGER cbSqlStrMax, - SQLINTEGER *pcbSqlStr); + HDBC hdbc, + SQLCHAR * szSqlStrIn, + SQLINTEGER cbSqlStrIn, + SQLCHAR * szSqlStr, + SQLINTEGER cbSqlStrMax, + SQLINTEGER * pcbSqlStr); RETCODE SQL_API PGAPI_NumParams( - HSTMT hstmt, - SQLSMALLINT *pcpar); + HSTMT hstmt, + SQLSMALLINT * pcpar); RETCODE SQL_API PGAPI_ParamOptions( - HSTMT hstmt, - SQLUINTEGER crow, - SQLUINTEGER *pirow); + HSTMT hstmt, + SQLUINTEGER crow, + SQLUINTEGER * pirow); RETCODE SQL_API PGAPI_PrimaryKeys( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName); RETCODE SQL_API PGAPI_ProcedureColumns( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName); RETCODE SQL_API PGAPI_Procedures( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName); RETCODE SQL_API PGAPI_SetPos( - HSTMT hstmt, - SQLUSMALLINT irow, - SQLUSMALLINT fOption, - SQLUSMALLINT fLock); + HSTMT hstmt, + SQLUSMALLINT irow, + SQLUSMALLINT fOption, + SQLUSMALLINT fLock); RETCODE SQL_API PGAPI_TablePrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName); RETCODE SQL_API PGAPI_BindParameter( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT fParamType, - SQLSMALLINT fCType, - SQLSMALLINT fSqlType, - SQLUINTEGER cbColDef, - SQLSMALLINT ibScale, - PTR rgbValue, - SQLINTEGER cbValueMax, - SQLINTEGER *pcbValue); + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT fParamType, + SQLSMALLINT fCType, + SQLSMALLINT fSqlType, + SQLUINTEGER cbColDef, + SQLSMALLINT ibScale, + PTR rgbValue, + SQLINTEGER cbValueMax, + SQLINTEGER * pcbValue); RETCODE SQL_API PGAPI_SetScrollOptions( - HSTMT hstmt, - UWORD fConcurrency, - SDWORD crowKeyset, - UWORD crowRowset); -#endif /* define_PG_API_FUNC_H__ */ + HSTMT hstmt, + UWORD fConcurrency, + SDWORD crowKeyset, + UWORD crowRowset); +#endif /* define_PG_API_FUNC_H__ */ diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c index d6995f8c46..6f1282a36c 100644 --- a/src/interfaces/odbc/pgtypes.c +++ b/src/interfaces/odbc/pgtypes.c @@ -25,7 +25,7 @@ -Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); /* * these are the types we support. all of the pgtype_ functions should @@ -94,10 +94,10 @@ Int2 sqlTypes[] = { Int4 -sqltype_to_pgtype(StatementClass *stmt, SWORD fSqlType) +sqltype_to_pgtype(StatementClass * stmt, SWORD fSqlType) { Int4 pgType; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); switch (fSqlType) { @@ -190,9 +190,10 @@ sqltype_to_pgtype(StatementClass *stmt, SWORD fSqlType) * types that are unknown. All other pg routines in here return a suitable default. */ Int2 -pgtype_to_sqltype(StatementClass *stmt, Int4 type) +pgtype_to_sqltype(StatementClass * stmt, Int4 type) { - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + switch (type) { case PG_TYPE_CHAR: @@ -265,9 +266,10 @@ pgtype_to_sqltype(StatementClass *stmt, Int4 type) Int2 -pgtype_to_ctype(StatementClass *stmt, Int4 type) +pgtype_to_ctype(StatementClass * stmt, Int4 type) { - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + switch (type) { case PG_TYPE_INT8: @@ -313,7 +315,7 @@ pgtype_to_ctype(StatementClass *stmt, Int4 type) char * -pgtype_to_name(StatementClass *stmt, Int4 type) +pgtype_to_name(StatementClass * stmt, Int4 type) { switch (type) { @@ -382,7 +384,7 @@ pgtype_to_name(StatementClass *stmt, Int4 type) static Int2 -getNumericScale(StatementClass *stmt, Int4 type, int col) +getNumericScale(StatementClass * stmt, Int4 type, int col) { Int4 atttypmod; QResultClass *result; @@ -419,7 +421,7 @@ getNumericScale(StatementClass *stmt, Int4 type, int col) static Int4 -getNumericPrecision(StatementClass *stmt, Int4 type, int col) +getNumericPrecision(StatementClass * stmt, Int4 type, int col) { Int4 atttypmod; QResultClass *result; @@ -456,13 +458,13 @@ getNumericPrecision(StatementClass *stmt, Int4 type, int col) Int4 -getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { int p = -1, maxsize; QResultClass *result; ColumnInfoClass *flds; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); mylog("getCharPrecision: type=%d, col=%d, unknown = %d\n", type, col, handle_unknown_size_as); @@ -497,7 +499,7 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si { if (PG_VERSION_GE(SC_get_conn(stmt), 7.1)) maxsize = 0; - else + else maxsize = TEXT_FIELD_SIZE; } if (col < 0) @@ -543,7 +545,7 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si * This is used for functions SQLDescribeCol and SQLColAttributes. */ Int4 -pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -610,7 +612,7 @@ pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si Int4 -pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -651,7 +653,7 @@ pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown * override this length with the atttypmod length from pg_attribute */ Int4 -pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -678,12 +680,12 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ case PG_TYPE_DATE: case PG_TYPE_TIME: - return 6; /* sizeof(DATE(TIME)_STRUCT) */ + return 6; /* sizeof(DATE(TIME)_STRUCT) */ case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP: - return 16; /* sizeof(TIMESTAMP_STRUCT) */ + return 16; /* sizeof(TIMESTAMP_STRUCT) */ /* Character types (and NUMERIC) use the default precision */ case PG_TYPE_VARCHAR: @@ -695,8 +697,8 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ else #else /* CR -> CR/LF */ - return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as); -#endif /* MULTIBYTE */ + return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as); +#endif /* MULTIBYTE */ default: return pgtype_precision(stmt, type, col, handle_unknown_size_as); } @@ -704,7 +706,7 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ Int2 -pgtype_scale(StatementClass *stmt, Int4 type, int col) +pgtype_scale(StatementClass * stmt, Int4 type, int col) { switch (type) { @@ -738,7 +740,7 @@ pgtype_scale(StatementClass *stmt, Int4 type, int col) Int2 -pgtype_radix(StatementClass *stmt, Int4 type) +pgtype_radix(StatementClass * stmt, Int4 type) { switch (type) { @@ -758,14 +760,14 @@ pgtype_radix(StatementClass *stmt, Int4 type) Int2 -pgtype_nullable(StatementClass *stmt, Int4 type) +pgtype_nullable(StatementClass * stmt, Int4 type) { return SQL_NULLABLE; /* everything should be nullable */ } Int2 -pgtype_auto_increment(StatementClass *stmt, Int4 type) +pgtype_auto_increment(StatementClass * stmt, Int4 type) { switch (type) { @@ -794,7 +796,7 @@ pgtype_auto_increment(StatementClass *stmt, Int4 type) Int2 -pgtype_case_sensitive(StatementClass *stmt, Int4 type) +pgtype_case_sensitive(StatementClass * stmt, Int4 type) { switch (type) { @@ -817,7 +819,7 @@ pgtype_case_sensitive(StatementClass *stmt, Int4 type) Int2 -pgtype_money(StatementClass *stmt, Int4 type) +pgtype_money(StatementClass * stmt, Int4 type) { switch (type) { @@ -830,7 +832,7 @@ pgtype_money(StatementClass *stmt, Int4 type) Int2 -pgtype_searchable(StatementClass *stmt, Int4 type) +pgtype_searchable(StatementClass * stmt, Int4 type) { switch (type) { @@ -852,7 +854,7 @@ pgtype_searchable(StatementClass *stmt, Int4 type) Int2 -pgtype_unsigned(StatementClass *stmt, Int4 type) +pgtype_unsigned(StatementClass * stmt, Int4 type) { switch (type) { @@ -876,19 +878,20 @@ pgtype_unsigned(StatementClass *stmt, Int4 type) char * -pgtype_literal_prefix(StatementClass *stmt, Int4 type) +pgtype_literal_prefix(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_INT2: - case PG_TYPE_OID: - case PG_TYPE_XID: - case PG_TYPE_INT4: - case PG_TYPE_INT8: - case PG_TYPE_NUMERIC: - case PG_TYPE_FLOAT4: - case PG_TYPE_FLOAT8: - case PG_TYPE_MONEY:return NULL; + case PG_TYPE_INT2: + case PG_TYPE_OID: + case PG_TYPE_XID: + case PG_TYPE_INT4: + case PG_TYPE_INT8: + case PG_TYPE_NUMERIC: + case PG_TYPE_FLOAT4: + case PG_TYPE_FLOAT8: + case PG_TYPE_MONEY: + return NULL; default: return "'"; @@ -897,19 +900,20 @@ pgtype_literal_prefix(StatementClass *stmt, Int4 type) char * -pgtype_literal_suffix(StatementClass *stmt, Int4 type) +pgtype_literal_suffix(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_INT2: - case PG_TYPE_OID: - case PG_TYPE_XID: - case PG_TYPE_INT4: - case PG_TYPE_INT8: - case PG_TYPE_NUMERIC: - case PG_TYPE_FLOAT4: - case PG_TYPE_FLOAT8: - case PG_TYPE_MONEY:return NULL; + case PG_TYPE_INT2: + case PG_TYPE_OID: + case PG_TYPE_XID: + case PG_TYPE_INT4: + case PG_TYPE_INT8: + case PG_TYPE_NUMERIC: + case PG_TYPE_FLOAT4: + case PG_TYPE_FLOAT8: + case PG_TYPE_MONEY: + return NULL; default: return "'"; @@ -918,12 +922,13 @@ pgtype_literal_suffix(StatementClass *stmt, Int4 type) char * -pgtype_create_params(StatementClass *stmt, Int4 type) +pgtype_create_params(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_CHAR: - case PG_TYPE_VARCHAR:return "max. length"; + case PG_TYPE_CHAR: + case PG_TYPE_VARCHAR: + return "max. length"; default: return NULL; } @@ -933,7 +938,6 @@ pgtype_create_params(StatementClass *stmt, Int4 type) Int2 sqltype_to_default_ctype(Int2 sqltype) { - /* * from the table on page 623 of ODBC 2.0 Programmer's Reference * (Appendix D) diff --git a/src/interfaces/odbc/pgtypes.h b/src/interfaces/odbc/pgtypes.h index 7bd33cf751..6761ec319e 100644 --- a/src/interfaces/odbc/pgtypes.h +++ b/src/interfaces/odbc/pgtypes.h @@ -68,30 +68,29 @@ extern Int2 sqlTypes[]; /* Defines for pgtype_precision */ #define PG_STATIC (-1) -Int4 sqltype_to_pgtype(StatementClass *stmt, Int2 fSqlType); +Int4 sqltype_to_pgtype(StatementClass * stmt, Int2 fSqlType); -Int2 pgtype_to_sqltype(StatementClass *stmt, Int4 type); -Int2 pgtype_to_ctype(StatementClass *stmt, Int4 type); -char *pgtype_to_name(StatementClass *stmt, Int4 type); +Int2 pgtype_to_sqltype(StatementClass * stmt, Int4 type); +Int2 pgtype_to_ctype(StatementClass * stmt, Int4 type); +char *pgtype_to_name(StatementClass * stmt, Int4 type); /* These functions can use static numbers or result sets(col parameter) */ -Int4 pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); -Int4 pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); -Int4 pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); -Int2 pgtype_scale(StatementClass *stmt, Int4 type, int col); -Int2 pgtype_radix(StatementClass *stmt, Int4 type); -Int2 pgtype_nullable(StatementClass *stmt, Int4 type); -Int2 pgtype_auto_increment(StatementClass *stmt, Int4 type); -Int2 pgtype_case_sensitive(StatementClass *stmt, Int4 type); -Int2 pgtype_money(StatementClass *stmt, Int4 type); -Int2 pgtype_searchable(StatementClass *stmt, Int4 type); -Int2 pgtype_unsigned(StatementClass *stmt, Int4 type); -char *pgtype_literal_prefix(StatementClass *stmt, Int4 type); -char *pgtype_literal_suffix(StatementClass *stmt, Int4 type); -char *pgtype_create_params(StatementClass *stmt, Int4 type); +Int2 pgtype_scale(StatementClass * stmt, Int4 type, int col); +Int2 pgtype_radix(StatementClass * stmt, Int4 type); +Int2 pgtype_nullable(StatementClass * stmt, Int4 type); +Int2 pgtype_auto_increment(StatementClass * stmt, Int4 type); +Int2 pgtype_case_sensitive(StatementClass * stmt, Int4 type); +Int2 pgtype_money(StatementClass * stmt, Int4 type); +Int2 pgtype_searchable(StatementClass * stmt, Int4 type); +Int2 pgtype_unsigned(StatementClass * stmt, Int4 type); +char *pgtype_literal_prefix(StatementClass * stmt, Int4 type); +char *pgtype_literal_suffix(StatementClass * stmt, Int4 type); +char *pgtype_create_params(StatementClass * stmt, Int4 type); Int2 sqltype_to_default_ctype(Int2 sqltype); Int4 ctype_length(Int2 ctype); - #endif diff --git a/src/interfaces/odbc/psqlodbc.c b/src/interfaces/odbc/psqlodbc.c index 3c8ff2a53f..841360da34 100644 --- a/src/interfaces/odbc/psqlodbc.c +++ b/src/interfaces/odbc/psqlodbc.c @@ -114,9 +114,7 @@ _fini(void) { return TRUE; } - #endif /* not __GNUC__ */ - #endif /* not WIN32 */ @@ -127,7 +125,7 @@ _fini(void) * Driver Manager do this. Also, the ordinal values of the * functions must match the value of fFunction in SQLGetFunctions() */ -RETCODE SQL_API +RETCODE SQL_API SQLDummyOrdinal(void) { return SQL_SUCCESS; diff --git a/src/interfaces/odbc/psqlodbc.h b/src/interfaces/odbc/psqlodbc.h index 796b282af8..514922036b 100644 --- a/src/interfaces/odbc/psqlodbc.h +++ b/src/interfaces/odbc/psqlodbc.h @@ -5,7 +5,7 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.51 2001/10/12 09:41:49 inoue Exp $ + * $Id: psqlodbc.h,v 1.52 2001/10/25 05:50:15 momjian Exp $ * */ @@ -25,7 +25,7 @@ #define ODBCVER ODBCVER_REP #else #define ODBCVER 0x0250 -#endif /* ODBCVER_REP */ +#endif /* ODBCVER_REP */ #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC) @@ -185,7 +185,7 @@ typedef struct GlobalValues_ char extra_systable_prefixes[MEDIUM_REGISTRY_LEN]; char conn_settings[LARGE_REGISTRY_LEN]; char protocol[SMALL_REGISTRY_LEN]; -} GLOBAL_VALUES; +} GLOBAL_VALUES; typedef struct StatementOptions_ { @@ -199,10 +199,10 @@ typedef struct StatementOptions_ int bind_size; /* size of each structure if using Row * Binding */ int use_bookmarks; - UInt4 *rowsFetched; - UInt2 *rowStatusArray; - void *bookmark_ptr; -} StatementOptions; + UInt4 *rowsFetched; + UInt2 *rowStatusArray; + void *bookmark_ptr; +} StatementOptions; /* Used to pass extra query info to send_query */ typedef struct QueryInfo_ @@ -210,9 +210,9 @@ typedef struct QueryInfo_ int row_size; QResultClass *result_in; char *cursor; -} QueryInfo; +} QueryInfo; -void logs_on_off(int cnopen, int, int); +void logs_on_off(int cnopen, int, int); #define PG_TYPE_LO (-999) /* hack until permanent * type available */ @@ -231,20 +231,22 @@ void logs_on_off(int cnopen, int, int); #define PG_NUMERIC_MAX_PRECISION 1000 #define PG_NUMERIC_MAX_SCALE 1000 -#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for -queries used in info.c inoue 2001/05/17 */ +#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for + * queries used in info.c inoue + * 2001/05/17 */ #include "misc.h" #ifdef _MEMORY_DEBUG_ -void * debug_alloc(size_t); -void * debug_realloc(void *, size_t); -char * debug_strdup(const char *); -void debug_free(void *); -void debug_memory_check(void); -#define malloc debug_alloc -#define realloc debug_realloc -#define strdup debug_strdup -#define free debug_free -#endif /* _MEMORY_DEBUG_ */ +void *debug_alloc(size_t); +void *debug_realloc(void *, size_t); +char *debug_strdup(const char *); +void debug_free(void *); +void debug_memory_check(void); + +#define malloc debug_alloc +#define realloc debug_realloc +#define strdup debug_strdup +#define free debug_free +#endif /* _MEMORY_DEBUG_ */ #endif diff --git a/src/interfaces/odbc/qresult.c b/src/interfaces/odbc/qresult.c index b3c8f6fcc0..b9f088227f 100644 --- a/src/interfaces/odbc/qresult.c +++ b/src/interfaces/odbc/qresult.c @@ -39,7 +39,7 @@ * All info functions call this function to create the manual result set. */ void -QR_set_num_fields(QResultClass *self, int new_num_fields) +QR_set_num_fields(QResultClass * self, int new_num_fields) { mylog("in QR_set_num_fields\n"); @@ -54,28 +54,28 @@ QR_set_num_fields(QResultClass *self, int new_num_fields) void -QR_set_position(QResultClass *self, int pos) +QR_set_position(QResultClass * self, int pos) { self->tupleField = self->backend_tuples + ((self->base + pos) * self->num_fields); } void -QR_set_cache_size(QResultClass *self, int cache_size) +QR_set_cache_size(QResultClass * self, int cache_size) { self->cache_size = cache_size; } void -QR_set_rowset_size(QResultClass *self, int rowset_size) +QR_set_rowset_size(QResultClass * self, int rowset_size) { self->rowset_size = rowset_size; } void -QR_inc_base(QResultClass *self, int base_inc) +QR_inc_base(QResultClass * self, int base_inc) { self->base += base_inc; } @@ -128,7 +128,7 @@ QR_Constructor() void -QR_Destructor(QResultClass *self) +QR_Destructor(QResultClass * self) { mylog("QResult: in DESTRUCTOR\n"); @@ -168,7 +168,7 @@ QR_Destructor(QResultClass *self) void -QR_set_command(QResultClass *self, char *msg) +QR_set_command(QResultClass * self, char *msg) { if (self->command) free(self->command); @@ -178,7 +178,7 @@ QR_set_command(QResultClass *self, char *msg) void -QR_set_notice(QResultClass *self, char *msg) +QR_set_notice(QResultClass * self, char *msg) { if (self->notice) free(self->notice); @@ -188,7 +188,7 @@ QR_set_notice(QResultClass *self, char *msg) void -QR_free_memory(QResultClass *self) +QR_free_memory(QResultClass * self) { register int lf, row; @@ -211,7 +211,7 @@ QR_free_memory(QResultClass *self) free(tuple[lf].value); } } - tuple += num_fields;/* next row */ + tuple += num_fields; /* next row */ } free(self->backend_tuples); @@ -226,7 +226,7 @@ QR_free_memory(QResultClass *self) /* This function is called by send_query() */ char -QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) +QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor) { int tuple_size; @@ -238,8 +238,9 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) */ if (conn != NULL) { - ConnInfo *ci = &(conn->connInfo); - BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]); + ConnInfo *ci = &(conn->connInfo); + BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]); + self->conn = conn; mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n", (cursor == NULL) ? "" : cursor, self->cursor); @@ -305,7 +306,6 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) } else { - /* * Always have to read the field attributes. But we dont have to * reallocate memory for them! @@ -327,7 +327,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) * We only close cursor/end the transaction if a cursor was used. */ int -QR_close(QResultClass *self) +QR_close(QResultClass * self) { QResultClass *res; @@ -379,7 +379,7 @@ QR_close(QResultClass *self) /* This function is called by fetch_tuples() AND SQLFetch() */ int -QR_next_tuple(QResultClass *self) +QR_next_tuple(QResultClass * self) { int id; QResultClass *res; @@ -401,7 +401,7 @@ QR_next_tuple(QResultClass *self) char cmdbuffer[ERROR_MSG_LENGTH + 1]; char fetch[128]; QueryInfo qi; - ConnInfo *ci = NULL; + ConnInfo *ci = NULL; if (fetch_count < fcount) { @@ -423,7 +423,6 @@ QR_next_tuple(QResultClass *self) } else { - /* * See if we need to fetch another group of rows. We may be being * called from send_query(), and if so, don't send another fetch, @@ -539,12 +538,12 @@ QR_next_tuple(QResultClass *self) if ((!self->cursor || !ci->drivers.use_declarefetch) && self->fcount >= self->count_allocated) { - int tuple_size = self->count_allocated; + int tuple_size = self->count_allocated; mylog("REALLOC: old_count = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size); tuple_size *= 2; self->backend_tuples = (TupleField *) realloc(self->backend_tuples, - tuple_size * self->num_fields * sizeof(TupleField)); + tuple_size * self->num_fields * sizeof(TupleField)); if (!self->backend_tuples) { self->status = PGRES_FATAL_ERROR; @@ -621,7 +620,7 @@ QR_next_tuple(QResultClass *self) char -QR_read_tuple(QResultClass *self, char binary) +QR_read_tuple(QResultClass * self, char binary) { Int2 field_lf; TupleField *this_tuplefield; @@ -664,7 +663,6 @@ QR_read_tuple(QResultClass *self, char binary) } else { - /* * NO, the field is not null. so get at first the length of * the field (four bytes) diff --git a/src/interfaces/odbc/qresult.h b/src/interfaces/odbc/qresult.h index 29e171bad8..23e125247c 100644 --- a/src/interfaces/odbc/qresult.h +++ b/src/interfaces/odbc/qresult.h @@ -19,22 +19,23 @@ enum QueryResultCode_ { - PGRES_EMPTY_QUERY = 0, - PGRES_COMMAND_OK, /* a query command that doesn't return */ + PGRES_EMPTY_QUERY = 0, + PGRES_COMMAND_OK, /* a query command that doesn't + * return */ /* anything was executed properly by the backend */ - PGRES_TUPLES_OK, /* a query command that returns tuples */ + PGRES_TUPLES_OK,/* a query command that returns tuples */ /* was executed properly by the backend, PGresult */ /* contains the resulttuples */ - PGRES_COPY_OUT, - PGRES_COPY_IN, - PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from - * the backend */ - PGRES_NONFATAL_ERROR, - PGRES_FATAL_ERROR, - PGRES_FIELDS_OK, /* field information from a query was + PGRES_COPY_OUT, + PGRES_COPY_IN, + PGRES_BAD_RESPONSE, /* an unexpected response was + * recv'd from the backend */ + PGRES_NONFATAL_ERROR, + PGRES_FATAL_ERROR, + PGRES_FIELDS_OK,/* field information from a query was * successful */ - PGRES_END_TUPLES, - PGRES_INTERNAL_ERROR + PGRES_END_TUPLES, + PGRES_INTERNAL_ERROR }; typedef enum QueryResultCode_ QueryResultCode; @@ -47,7 +48,7 @@ struct QResultClass_ * (backend) */ /* Stuff for declare/fetch tuples */ - int count_allocated; /* m(re)alloced count */ + int count_allocated; /* m(re)alloced count */ int fetch_count; /* logical rows read so far */ int fcount; /* actual rows read in the fetch */ int currTuple; @@ -112,20 +113,19 @@ struct QResultClass_ /* Core Functions */ QResultClass *QR_Constructor(void); -void QR_Destructor(QResultClass *self); -char QR_read_tuple(QResultClass *self, char binary); -int QR_next_tuple(QResultClass *self); -int QR_close(QResultClass *self); -char QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor); -void QR_free_memory(QResultClass *self); -void QR_set_command(QResultClass *self, char *msg); -void QR_set_notice(QResultClass *self, char *msg); - -void QR_set_num_fields(QResultClass *self, int new_num_fields); /* manual result only */ - -void QR_inc_base(QResultClass *self, int base_inc); -void QR_set_cache_size(QResultClass *self, int cache_size); -void QR_set_rowset_size(QResultClass *self, int rowset_size); -void QR_set_position(QResultClass *self, int pos); - +void QR_Destructor(QResultClass * self); +char QR_read_tuple(QResultClass * self, char binary); +int QR_next_tuple(QResultClass * self); +int QR_close(QResultClass * self); +char QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor); +void QR_free_memory(QResultClass * self); +void QR_set_command(QResultClass * self, char *msg); +void QR_set_notice(QResultClass * self, char *msg); + +void QR_set_num_fields(QResultClass * self, int new_num_fields); /* manual result only */ + +void QR_inc_base(QResultClass * self, int base_inc); +void QR_set_cache_size(QResultClass * self, int cache_size); +void QR_set_rowset_size(QResultClass * self, int rowset_size); +void QR_set_position(QResultClass * self, int pos); #endif diff --git a/src/interfaces/odbc/resource.h b/src/interfaces/odbc/resource.h index 452ff929fa..688ff7a6b9 100644 --- a/src/interfaces/odbc/resource.h +++ b/src/interfaces/odbc/resource.h @@ -1,65 +1,65 @@ -//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by psqlodbc.rc
-//
-#define IDS_BADDSN 1
-#define IDS_MSGTITLE 2
-#define DLG_OPTIONS_DRV 102
-#define DLG_OPTIONS_DS 103
-#define IDC_DSNAME 400
-#define IDC_DSNAMETEXT 401
-#define IDC_DESC 404
-#define IDC_SERVER 407
-#define IDC_DATABASE 408
-#define DLG_CONFIG 1001
-#define IDC_PORT 1002
-#define IDC_USER 1006
-#define IDC_PASSWORD 1009
-#define DS_READONLY 1011
-#define DS_SHOWOIDCOLUMN 1012
-#define DS_FAKEOIDINDEX 1013
-#define DRV_COMMLOG 1014
-#define DS_PG62 1016
-#define IDC_DATASOURCE 1018
-#define DRV_OPTIMIZER 1019
-#define DS_CONNSETTINGS 1020
-#define IDC_DRIVER 1021
-#define DRV_CONNSETTINGS 1031
-#define DRV_UNIQUEINDEX 1032
-#define DRV_UNKNOWN_MAX 1035
-#define DRV_UNKNOWN_DONTKNOW 1036
-#define DRV_READONLY 1037
-#define IDC_DESCTEXT 1039
-#define DRV_MSG_LABEL 1040
-#define DRV_UNKNOWN_LONGEST 1041
-#define DRV_TEXT_LONGVARCHAR 1043
-#define DRV_UNKNOWNS_LONGVARCHAR 1044
-#define DRV_CACHE_SIZE 1045
-#define DRV_VARCHAR_SIZE 1046
-#define DRV_LONGVARCHAR_SIZE 1047
-#define IDDEFAULTS 1048
-#define DRV_USEDECLAREFETCH 1049
-#define DRV_BOOLS_CHAR 1050
-#define DS_SHOWSYSTEMTABLES 1051
-#define DRV_EXTRASYSTABLEPREFIXES 1051
-#define DS_ROWVERSIONING 1052
-#define DRV_PARSE 1052
-#define DRV_CANCELASFREESTMT 1053
-#define IDC_OPTIONS 1054
-#define DRV_KSQO 1055
-#define DS_PG64 1057
-#define DS_PG63 1058
-#define DRV_OR_DSN 1059
+/* {{NO_DEPENDENCIES}}
*/ +/* Microsoft Developer Studio generated include file.
*/ +/* Used by psqlodbc.rc
*/ +/*
*/ +#define IDS_BADDSN 1
+#define IDS_MSGTITLE 2
+#define DLG_OPTIONS_DRV 102
+#define DLG_OPTIONS_DS 103
+#define IDC_DSNAME 400
+#define IDC_DSNAMETEXT 401
+#define IDC_DESC 404
+#define IDC_SERVER 407
+#define IDC_DATABASE 408
+#define DLG_CONFIG 1001
+#define IDC_PORT 1002
+#define IDC_USER 1006
+#define IDC_PASSWORD 1009
+#define DS_READONLY 1011
+#define DS_SHOWOIDCOLUMN 1012
+#define DS_FAKEOIDINDEX 1013
+#define DRV_COMMLOG 1014
+#define DS_PG62 1016
+#define IDC_DATASOURCE 1018
+#define DRV_OPTIMIZER 1019
+#define DS_CONNSETTINGS 1020
+#define IDC_DRIVER 1021
+#define DRV_CONNSETTINGS 1031
+#define DRV_UNIQUEINDEX 1032
+#define DRV_UNKNOWN_MAX 1035
+#define DRV_UNKNOWN_DONTKNOW 1036
+#define DRV_READONLY 1037
+#define IDC_DESCTEXT 1039
+#define DRV_MSG_LABEL 1040
+#define DRV_UNKNOWN_LONGEST 1041
+#define DRV_TEXT_LONGVARCHAR 1043
+#define DRV_UNKNOWNS_LONGVARCHAR 1044
+#define DRV_CACHE_SIZE 1045
+#define DRV_VARCHAR_SIZE 1046
+#define DRV_LONGVARCHAR_SIZE 1047
+#define IDDEFAULTS 1048
+#define DRV_USEDECLAREFETCH 1049
+#define DRV_BOOLS_CHAR 1050
+#define DS_SHOWSYSTEMTABLES 1051
+#define DRV_EXTRASYSTABLEPREFIXES 1051
+#define DS_ROWVERSIONING 1052
+#define DRV_PARSE 1052
+#define DRV_CANCELASFREESTMT 1053
+#define IDC_OPTIONS 1054
+#define DRV_KSQO 1055
+#define DS_PG64 1057
+#define DS_PG63 1058
+#define DRV_OR_DSN 1059
#define DRV_DEBUG 1060
#define DS_DISALLOWPREMATURE 1061
-// Next default values for new objects
-//
+/* Next default values for new objects
*/ +/*
*/ #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1062
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1062
+#define _APS_NEXT_SYMED_VALUE 101
+#endif /*
*/ +#endif /*
*/ diff --git a/src/interfaces/odbc/results.c b/src/interfaces/odbc/results.c index c5652ff984..3565e3f8d5 100644 --- a/src/interfaces/odbc/results.c +++ b/src/interfaces/odbc/results.c @@ -33,17 +33,17 @@ -RETCODE SQL_API +RETCODE SQL_API PGAPI_RowCount( - HSTMT hstmt, - SDWORD FAR *pcrow) + HSTMT hstmt, + SDWORD FAR * pcrow) { static char *func = "PGAPI_RowCount"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; char *msg, *ptr; - ConnInfo *ci; + ConnInfo *ci; if (!stmt) { @@ -104,16 +104,16 @@ PGAPI_RowCount( * This returns the number of columns associated with the database * attached to "hstmt". */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NumResultCols( - HSTMT hstmt, - SWORD FAR *pccol) + HSTMT hstmt, + SWORD FAR * pccol) { static char *func = "PGAPI_NumResultCols"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *result; char parse_ok; - ConnInfo *ci; + ConnInfo *ci; if (!stmt) { @@ -159,10 +159,8 @@ PGAPI_NumResultCols( *pccol = QR_NumResultCols(result); /* updatable cursors */ if (ci->updatable_cursors && - stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) - { + stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) *pccol -= 2; - } } return SQL_SUCCESS; @@ -173,17 +171,17 @@ PGAPI_NumResultCols( * Return information about the database column the user wants * information about. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_DescribeCol( - HSTMT hstmt, - UWORD icol, - UCHAR FAR *szColName, - SWORD cbColNameMax, - SWORD FAR *pcbColName, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable) + HSTMT hstmt, + UWORD icol, + UCHAR FAR * szColName, + SWORD cbColNameMax, + SWORD FAR * pcbColName, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable) { static char *func = "PGAPI_DescribeCol"; @@ -192,7 +190,8 @@ PGAPI_DescribeCol( QResultClass *res; char *col_name = NULL; Int4 fieldtype = 0; - int precision = 0, scale = 0; + int precision = 0, + scale = 0; ConnInfo *ci; char parse_ok; char buf[255]; @@ -365,15 +364,15 @@ PGAPI_DescribeCol( /* Returns result column descriptor information for a result set. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ColAttributes( - HSTMT hstmt, - UWORD icol, - UWORD fDescType, - PTR rgbDesc, - SWORD cbDescMax, - SWORD FAR *pcbDesc, - SDWORD FAR *pfDesc) + HSTMT hstmt, + UWORD icol, + UWORD fDescType, + PTR rgbDesc, + SWORD cbDescMax, + SWORD FAR * pcbDesc, + SDWORD FAR * pfDesc) { static char *func = "PGAPI_ColAttributes"; StatementClass *stmt = (StatementClass *) hstmt; @@ -637,14 +636,14 @@ PGAPI_ColAttributes( /* Returns result data for a single column in the current row. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetData( - HSTMT hstmt, - UWORD icol, - SWORD fCType, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD icol, + SWORD fCType, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { static char *func = "PGAPI_GetData"; QResultClass *res; @@ -655,7 +654,7 @@ PGAPI_GetData( void *value = NULL; int result; char get_bookmark = FALSE; - ConnInfo *ci; + ConnInfo *ci; mylog("PGAPI_GetData: enter, stmt=%u\n", stmt); @@ -824,9 +823,9 @@ PGAPI_GetData( * Returns data for bound columns in the current row ("hstmt->iCursor"), * advances the cursor. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Fetch( - HSTMT hstmt) + HSTMT hstmt) { static char *func = "PGAPI_Fetch"; StatementClass *stmt = (StatementClass *) hstmt; @@ -893,13 +892,13 @@ PGAPI_Fetch( /* This fetchs a block of data (rowset). */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ExtendedFetch( - HSTMT hstmt, - UWORD fFetchType, - SDWORD irow, - UDWORD FAR *pcrow, - UWORD FAR *rgfRowStatus) + HSTMT hstmt, + UWORD fFetchType, + SDWORD irow, + UDWORD FAR * pcrow, + UWORD FAR * rgfRowStatus) { static char *func = "PGAPI_ExtendedFetch"; StatementClass *stmt = (StatementClass *) hstmt; @@ -910,7 +909,7 @@ PGAPI_ExtendedFetch( RETCODE result; char truncated, error; - ConnInfo *ci; + ConnInfo *ci; mylog("PGAPI_ExtendedFetch: stmt=%u\n", stmt); @@ -1166,7 +1165,7 @@ PGAPI_ExtendedFetch( /* this should be refined */ else if (result > 10 && result < 20) *(rgfRowStatus + i) = result - 10; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ else *(rgfRowStatus + i) = SQL_ROW_SUCCESS; } @@ -1208,9 +1207,9 @@ PGAPI_ExtendedFetch( * the "hstmt". */ /* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_MoreResults( - HSTMT hstmt) + HSTMT hstmt) { return SQL_NO_DATA_FOUND; } @@ -1218,14 +1217,14 @@ PGAPI_MoreResults( #ifdef DRIVER_CURSOR_IMPLEMENT /* - * Stuff for updatable cursors. + * Stuff for updatable cursors. */ static QResultClass * -positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval) +positioned_load(StatementClass * stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval) { - int i; - QResultClass *qres; - char selstr[4096]; + int i; + QResultClass *qres; + char selstr[4096]; sprintf(selstr, "select"); for (i = 0; i < res_cols; i++) @@ -1235,12 +1234,12 @@ positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, cons { if (latest) sprintf(selstr, "%s ctid = currtid2('%s', '%s') and", - selstr, stmt->ti[0]->name, tidval); + selstr, stmt->ti[0]->name, tidval); else sprintf(selstr, "%s ctid = '%s' and", selstr, tidval); } - sprintf(selstr, "%s oid = %u", selstr, oid), - mylog("selstr=%s\n", selstr); + sprintf(selstr, "%s oid = %u", selstr, oid), + mylog("selstr=%s\n", selstr); qres = CC_send_query(SC_get_conn(stmt), selstr, NULL); if (qres && QR_aborted(qres)) { @@ -1250,15 +1249,19 @@ positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, cons return qres; } -RETCODE SQL_API -SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) +RETCODE SQL_API +SC_pos_reload(StatementClass * stmt, UWORD irow, UWORD * count) { - int i, res_cols; - UWORD rcnt, global_ridx; - UInt4 oid; - QResultClass *res, *qres; - RETCODE ret = SQL_ERROR; - char *tidval, *oidval; + int i, + res_cols; + UWORD rcnt, + global_ridx; + UInt4 oid; + QResultClass *res, + *qres; + RETCODE ret = SQL_ERROR; + char *tidval, + *oidval; mylog("positioned load fi=%x ti=%x\n", stmt->fi, stmt->ti); rcnt = 0; @@ -1267,7 +1270,7 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1276,15 +1279,14 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) global_ridx = irow + stmt->rowset_start; res_cols = QR_NumResultCols(res); if (!(oidval = QR_get_value_backend_row(res, global_ridx, res_cols - 1))) - { return SQL_SUCCESS_WITH_INFO; - } - sscanf(oidval, "%u", &oid); + sscanf(oidval, "%u", &oid); tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2); res_cols -= 2; if (qres = positioned_load(stmt, TRUE, res_cols, oid, tidval), qres) { - TupleField *tupleo, *tuplen; + TupleField *tupleo, + *tuplen; rcnt = QR_get_num_tuples(qres); tupleo = res->backend_tuples + res->num_fields * global_ridx; @@ -1325,41 +1327,45 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) return ret; } -RETCODE SQL_API -SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) +RETCODE SQL_API +SC_pos_newload(StatementClass * stmt, UInt4 oid, const char *tidval) { - int i; - QResultClass *res, *qres; - RETCODE ret = SQL_ERROR; + int i; + QResultClass *res, + *qres; + RETCODE ret = SQL_ERROR; mylog("positioned new fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; return SQL_ERROR; } if (qres = positioned_load(stmt, TRUE, QR_NumResultCols(res) - 2, oid, tidval), qres) - { - TupleField *tupleo, *tuplen; - int count = QR_get_num_tuples(qres); + { + TupleField *tupleo, + *tuplen; + int count = QR_get_num_tuples(qres); + QR_set_position(qres, 0); if (count == 1) { tuplen = qres->tupleField; if (res->fcount >= res->count_allocated) { - int tuple_size; + int tuple_size; + if (!res->count_allocated) tuple_size = TUPLE_MALLOC_INC; else tuple_size = res->count_allocated * 2; res->backend_tuples = (TupleField *) realloc( - res->backend_tuples, - res->num_fields * sizeof(TupleField) * tuple_size); + res->backend_tuples, + res->num_fields * sizeof(TupleField) * tuple_size); if (!res->backend_tuples) { stmt->errornumber = res->status = PGRES_FATAL_ERROR; @@ -1369,7 +1375,7 @@ SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) } res->count_allocated = tuple_size; } - tupleo = res->backend_tuples + res->num_fields * res->fcount; + tupleo = res->backend_tuples + res->num_fields * res->fcount; for (i = 0; i < res->num_fields; i++) { tupleo[i].len = tuplen[i].len; @@ -1387,28 +1393,32 @@ SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) ret = SQL_SUCCESS_WITH_INFO; } QR_Destructor(qres); - /*stmt->currTuple = stmt->rowset_start + irow;*/ + /* stmt->currTuple = stmt->rowset_start + irow; */ } return ret; } -RETCODE SQL_API -SC_pos_update(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_update(StatementClass * stmt, + UWORD irow) { - int i, res_cols, num_cols, upd_cols; - UWORD global_ridx; - QResultClass *res; + int i, + res_cols, + num_cols, + upd_cols; + UWORD global_ridx; + QResultClass *res; BindInfoClass *bindings = stmt->bindings; - char updstr[4096]; - RETCODE ret; - char *tidval, *oidval; + char updstr[4096]; + RETCODE ret; + char *tidval, + *oidval; mylog("POS UPDATE %d+%d fi=%x ti=%x\n", irow, stmt->result->base, stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1420,7 +1430,7 @@ SC_pos_update(StatementClass *stmt, { stmt->errormsg = "The row is already deleted"; return SQL_ERROR; - } + } tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2); sprintf(updstr, "update \"%s\" set", stmt->ti[0]->name); @@ -1444,13 +1454,13 @@ SC_pos_update(StatementClass *stmt, } if (upd_cols > 0) { - HSTMT hstmt; - int j; - int res_cols = QR_NumResultCols(res); - StatementClass *qstmt; + HSTMT hstmt; + int j; + int res_cols = QR_NumResultCols(res); + StatementClass *qstmt; sprintf(updstr, "%s where ctid = '%s' and oid = %s", updstr, - tidval, oidval); + tidval, oidval); mylog("updstr=%s\n", updstr); if (PGAPI_AllocStmt(SC_get_conn(stmt), &hstmt) != SQL_SUCCESS) return SQL_ERROR; @@ -1462,14 +1472,14 @@ SC_pos_update(StatementClass *stmt, mylog("%d used=%d\n", i, *bindings[i].used); if (*bindings[i].used != SQL_IGNORE) { - PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++j, - SQL_PARAM_INPUT, bindings[i].returntype, - pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), - QR_get_fieldsize(res, i), - (SQLSMALLINT) stmt->fi[i]->precision, - bindings[i].buffer, - bindings[i].buflen, - bindings[i].used); + PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ j, + SQL_PARAM_INPUT, bindings[i].returntype, + pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), + QR_get_fieldsize(res, i), + (SQLSMALLINT) stmt->fi[i]->precision, + bindings[i].buffer, + bindings[i].buflen, + bindings[i].used); } } } @@ -1479,7 +1489,7 @@ SC_pos_update(StatementClass *stmt, stmt->errornumber = qstmt->errornumber; stmt->errormsg = qstmt->errormsg; } - else if (ret == SQL_NEED_DATA) /* must be fixed */ + else if (ret == SQL_NEED_DATA) /* must be fixed */ { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR; @@ -1488,11 +1498,12 @@ SC_pos_update(StatementClass *stmt, } if (ret != SQL_ERROR) { - int updcnt; + int updcnt; const char *cmdstr = QR_get_command(qstmt->result); + if (cmdstr && - sscanf(cmdstr, "UPDATE %d", &updcnt) == 1) - { + sscanf(cmdstr, "UPDATE %d", &updcnt) == 1) + { if (updcnt == 1) SC_pos_reload(stmt, irow, (UWORD *) 0); else if (updcnt == 0) @@ -1506,7 +1517,7 @@ SC_pos_update(StatementClass *stmt, else ret = SQL_ERROR; stmt->currTuple = stmt->rowset_start + irow; - } + } else ret = SQL_ERROR; if (ret == SQL_ERROR && stmt->errornumber == 0) @@ -1521,23 +1532,24 @@ SC_pos_update(StatementClass *stmt, ret = SQL_SUCCESS_WITH_INFO; return ret; } -RETCODE SQL_API -SC_pos_delete(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_delete(StatementClass * stmt, + UWORD irow) { - int res_cols; - UWORD global_ridx; - QResultClass *res, *qres; + int res_cols; + UWORD global_ridx; + QResultClass *res, + *qres; BindInfoClass *bindings = stmt->bindings; - char dltstr[4096]; - RETCODE ret; - char *oidval; + char dltstr[4096]; + RETCODE ret; + char *oidval; mylog("POS DELETE fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1549,20 +1561,21 @@ SC_pos_delete(StatementClass *stmt, { stmt->errormsg = "The row is already deleted"; return SQL_ERROR; - } + } sprintf(dltstr, "delete from \"%s\" where ctid = '%s' and oid = %s", stmt->ti[0]->name, - QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2), - oidval); + QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2), + oidval); mylog("dltstr=%s\n", dltstr); qres = CC_send_query(SC_get_conn(stmt), dltstr, NULL); if (qres && QR_command_successful(qres)) { - int dltcnt; + int dltcnt; const char *cmdstr = QR_get_command(qres); + if (cmdstr && - sscanf(cmdstr, "DELETE %d", &dltcnt) == 1) + sscanf(cmdstr, "DELETE %d", &dltcnt) == 1) { if (dltcnt == 1) SC_pos_reload(stmt, irow, (UWORD *) 0); @@ -1592,22 +1605,24 @@ SC_pos_delete(StatementClass *stmt, QR_Destructor(qres); return ret; } -RETCODE SQL_API -SC_pos_add(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_add(StatementClass * stmt, + UWORD irow) { - int num_cols, add_cols, i; - HSTMT hstmt; - QResultClass *res; + int num_cols, + add_cols, + i; + HSTMT hstmt; + QResultClass *res; BindInfoClass *bindings = stmt->bindings; - char addstr[4096]; - RETCODE ret; + char addstr[4096]; + RETCODE ret; mylog("POS ADD fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1628,14 +1643,14 @@ SC_pos_add(StatementClass *stmt, sprintf(addstr, "%s, \"%s\"", addstr, stmt->fi[i]->name); else sprintf(addstr, "%s\"%s\"", addstr, stmt->fi[i]->name); - PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++add_cols, - SQL_PARAM_INPUT, bindings[i].returntype, - pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), - QR_get_fieldsize(res, i), - (SQLSMALLINT) stmt->fi[i]->precision, - bindings[i].buffer, - bindings[i].buflen, - bindings[i].used); + PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ add_cols, + SQL_PARAM_INPUT, bindings[i].returntype, + pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), + QR_get_fieldsize(res, i), + (SQLSMALLINT) stmt->fi[i]->precision, + bindings[i].buffer, + bindings[i].buflen, + bindings[i].used); } } else @@ -1643,7 +1658,7 @@ SC_pos_add(StatementClass *stmt, } if (add_cols > 0) { - StatementClass *qstmt = (StatementClass *) hstmt; + StatementClass *qstmt = (StatementClass *) hstmt; sprintf(addstr, "%s) values (", addstr); for (i = 0; i < add_cols; i++) @@ -1656,7 +1671,7 @@ SC_pos_add(StatementClass *stmt, strcat(addstr, ")"); mylog("addstr=%s\n", addstr); ret = PGAPI_ExecDirect(hstmt, addstr, strlen(addstr)); - if (ret == SQL_NEED_DATA) /* must be fixed */ + if (ret == SQL_NEED_DATA) /* must be fixed */ { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR; @@ -1665,28 +1680,29 @@ SC_pos_add(StatementClass *stmt, } if (ret == SQL_ERROR) { - stmt->errornumber = qstmt->errornumber; - stmt->errormsg = qstmt->errormsg; + stmt->errornumber = qstmt->errornumber; + stmt->errormsg = qstmt->errormsg; } else { - int addcnt; - UInt4 oid; + int addcnt; + UInt4 oid; const char *cmdstr = QR_get_command(qstmt->result); + if (cmdstr && - sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 && - addcnt == 1) + sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 && + addcnt == 1) { SC_pos_newload(stmt, oid, NULL); - if (stmt->bookmark.buffer) - { - char buf[32]; - - sprintf(buf, "%ld", res->fcount); - copy_and_convert_field(stmt, 0, buf, - SQL_C_ULONG, stmt->bookmark.buffer, - 0, stmt->bookmark.used); - } + if (stmt->bookmark.buffer) + { + char buf[32]; + + sprintf(buf, "%ld", res->fcount); + copy_and_convert_field(stmt, 0, buf, + SQL_C_ULONG, stmt->bookmark.buffer, + 0, stmt->bookmark.used); + } } else { @@ -1701,21 +1717,22 @@ SC_pos_add(StatementClass *stmt, PGAPI_FreeStmt(hstmt, SQL_DROP); return ret; } + /* - * Stuff for updatable cursors end. + * Stuff for updatable cursors end. */ -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* * This positions the cursor within a rowset, that was positioned using SQLExtendedFetch. * This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetPos( - HSTMT hstmt, - UWORD irow, - UWORD fOption, - UWORD fLock) + HSTMT hstmt, + UWORD irow, + UWORD fOption, + UWORD fLock) { static char *func = "PGAPI_SetPos"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1735,7 +1752,7 @@ PGAPI_SetPos( if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) ; else -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (fOption != SQL_POSITION && fOption != SQL_REFRESH) { stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; @@ -1781,7 +1798,7 @@ PGAPI_SetPos( case SQL_ADD: return SC_pos_add(stmt, irow); } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* Reset for SQLGetData */ for (i = 0; i < num_cols; i++) bindings[i].data_left = -1; @@ -1789,13 +1806,13 @@ PGAPI_SetPos( if (fOption == SQL_REFRESH) { /* save the last_fetch_count */ - int last_fetch = stmt->last_fetch_count; - int bind_save = stmt->bind_row; + int last_fetch = stmt->last_fetch_count; + int bind_save = stmt->bind_row; #ifdef DRIVER_CURSOR_IMPLEMENT if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) - SC_pos_reload(stmt, irow, (UWORD *) 0); -#endif /* DRIVER_CURSOR_IMPLEMENT */ + SC_pos_reload(stmt, irow, (UWORD *) 0); +#endif /* DRIVER_CURSOR_IMPLEMENT */ stmt->currTuple = stmt->rowset_start + irow - 1; stmt->bind_row = irow; SC_fetch(stmt); @@ -1812,17 +1829,18 @@ PGAPI_SetPos( /* Sets options that control the behavior of cursors. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetScrollOptions( - HSTMT hstmt, - UWORD fConcurrency, - SDWORD crowKeyset, - UWORD crowRowset) + HSTMT hstmt, + UWORD fConcurrency, + SDWORD crowKeyset, + UWORD crowRowset) { static char *func = "PGAPI_SetScrollOptions"; StatementClass *stmt = (StatementClass *) hstmt; + mylog("PGAPI_SetScrollOptions fConcurrency=%d crowKeyset=%d crowRowset=%d\n", - fConcurrency, crowKeyset, crowRowset); + fConcurrency, crowKeyset, crowRowset); stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; stmt->errormsg = "SetScroll option not implemeted"; @@ -1832,11 +1850,11 @@ PGAPI_SetScrollOptions( /* Set the cursor name on a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetCursorName( - HSTMT hstmt, - UCHAR FAR *szCursor, - SWORD cbCursor) + HSTMT hstmt, + UCHAR FAR * szCursor, + SWORD cbCursor) { static char *func = "PGAPI_SetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1866,12 +1884,12 @@ PGAPI_SetCursorName( /* Return the cursor name for a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetCursorName( - HSTMT hstmt, - UCHAR FAR *szCursor, - SWORD cbCursorMax, - SWORD FAR *pcbCursor) + HSTMT hstmt, + UCHAR FAR * szCursor, + SWORD cbCursorMax, + SWORD FAR * pcbCursor) { static char *func = "PGAPI_GetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; diff --git a/src/interfaces/odbc/setup.c b/src/interfaces/odbc/setup.c index 6b75840d98..c4562ab90d 100644 --- a/src/interfaces/odbc/setup.c +++ b/src/interfaces/odbc/setup.c @@ -25,7 +25,7 @@ #define INTFUNC __stdcall -extern HINSTANCE NEAR s_hModule;/* Saved module handle. */ +extern HINSTANCE NEAR s_hModule; /* Saved module handle. */ /* Constants */ #define MIN(x,y) ((x) < (y) ? (x) : (y)) @@ -50,7 +50,7 @@ typedef struct tagSETUPDLG BOOL fNewDSN; /* New data source flag */ BOOL fDefault; /* Default data source flag */ -} SETUPDLG, FAR *LPSETUPDLG; +} SETUPDLG, FAR * LPSETUPDLG; @@ -217,10 +217,11 @@ ConfigDlgProc(HWND hdlg, LPARAM lParam) { LPSETUPDLG lpsetupdlg; - ConnInfo *ci; + ConnInfo *ci; + switch (wMsg) { - /* Initialize the dialog */ + /* Initialize the dialog */ case WM_INITDIALOG: lpsetupdlg = (LPSETUPDLG) lParam; ci = &lpsetupdlg->ci; @@ -229,11 +230,10 @@ ConfigDlgProc(HWND hdlg, ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE); SetWindowLong(hdlg, DWL_USER, lParam); - CenterDialog(hdlg); /* Center dialog */ + CenterDialog(hdlg); /* Center dialog */ /* - * NOTE: Values supplied in the attribute string will - * always + * NOTE: Values supplied in the attribute string will always */ /* override settings in ODBC.INI */ @@ -253,17 +253,16 @@ ConfigDlgProc(HWND hdlg, } else SendDlgItemMessage(hdlg, IDC_DSNAME, - EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L); + EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L); SendDlgItemMessage(hdlg, IDC_DESC, - EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L); - return TRUE; /* Focus was not set */ + EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L); + return TRUE; /* Focus was not set */ /* Process buttons */ case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { - /* * Ensure the OK button is enabled only when a data * source name @@ -288,8 +287,8 @@ ConfigDlgProc(HWND hdlg, /* Retrieve dialog values */ if (!lpsetupdlg->fDefault) GetDlgItemText(hdlg, IDC_DSNAME, - lpsetupdlg->ci.dsn, - sizeof(lpsetupdlg->ci.dsn)); + lpsetupdlg->ci.dsn, + sizeof(lpsetupdlg->ci.dsn)); /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); @@ -304,14 +303,14 @@ ConfigDlgProc(HWND hdlg, case IDC_DRIVER: lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), - hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci); + hdlg, driver_optionsProc, (LPARAM) & lpsetupdlg->ci); return TRUE; case IDC_DATASOURCE: lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS), - hdlg, ds_optionsProc, (LPARAM) &lpsetupdlg->ci); + hdlg, ds_optionsProc, (LPARAM) & lpsetupdlg->ci); return TRUE; } @@ -344,7 +343,6 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg) for (lpsz = lpszAttributes; *lpsz; lpsz++) { - /* * Extract key name (e.g., DSN), it must be terminated by an * equals diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c index 28a7af22bb..8250fc8738 100644 --- a/src/interfaces/odbc/socket.c +++ b/src/interfaces/odbc/socket.c @@ -35,7 +35,7 @@ extern GLOBAL_VALUES globals; void -SOCK_clear_error(SocketClass *self) +SOCK_clear_error(SocketClass * self) { self->errornumber = 0; self->errormsg = NULL; @@ -43,7 +43,7 @@ SOCK_clear_error(SocketClass *self) SocketClass * -SOCK_Constructor(const ConnectionClass *conn) +SOCK_Constructor(const ConnectionClass * conn) { SocketClass *rv; @@ -83,9 +83,9 @@ SOCK_Constructor(const ConnectionClass *conn) void -SOCK_Destructor(SocketClass *self) +SOCK_Destructor(SocketClass * self) { -mylog("SOCK_Destructor\n"); + mylog("SOCK_Destructor\n"); if (self->socket != -1) { SOCK_put_char(self, 'X'); @@ -104,7 +104,7 @@ mylog("SOCK_Destructor\n"); char -SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname) +SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname) { struct hostent *host; struct sockaddr_in sadr; @@ -162,7 +162,7 @@ SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname) void -SOCK_get_n_char(SocketClass *self, char *buffer, int len) +SOCK_get_n_char(SocketClass * self, char *buffer, int len) { int lf; @@ -179,7 +179,7 @@ SOCK_get_n_char(SocketClass *self, char *buffer, int len) void -SOCK_put_n_char(SocketClass *self, char *buffer, int len) +SOCK_put_n_char(SocketClass * self, char *buffer, int len) { int lf; @@ -201,7 +201,7 @@ SOCK_put_n_char(SocketClass *self, char *buffer, int len) * returns TRUE if truncation occurs. */ BOOL -SOCK_get_string(SocketClass *self, char *buffer, int bufsize) +SOCK_get_string(SocketClass * self, char *buffer, int bufsize) { register int lf = 0; @@ -215,7 +215,7 @@ SOCK_get_string(SocketClass *self, char *buffer, int bufsize) void -SOCK_put_string(SocketClass *self, char *string) +SOCK_put_string(SocketClass * self, char *string) { register int lf; int len; @@ -228,11 +228,11 @@ SOCK_put_string(SocketClass *self, char *string) int -SOCK_get_int(SocketClass *self, short len) +SOCK_get_int(SocketClass * self, short len) { switch (len) { - case 2: + case 2: { unsigned short buf; @@ -263,7 +263,7 @@ SOCK_get_int(SocketClass *self, short len) void -SOCK_put_int(SocketClass *self, int value, short len) +SOCK_put_int(SocketClass * self, int value, short len) { unsigned int rv; @@ -288,7 +288,7 @@ SOCK_put_int(SocketClass *self, int value, short len) void -SOCK_flush_output(SocketClass *self) +SOCK_flush_output(SocketClass * self) { int written; @@ -303,11 +303,10 @@ SOCK_flush_output(SocketClass *self) unsigned char -SOCK_get_next_byte(SocketClass *self) +SOCK_get_next_byte(SocketClass * self) { if (self->buffer_read_in >= self->buffer_filled_in) { - /* * there are no more bytes left in the buffer so reload the buffer */ @@ -336,7 +335,7 @@ SOCK_get_next_byte(SocketClass *self) void -SOCK_put_next_byte(SocketClass *self, unsigned char next_byte) +SOCK_put_next_byte(SocketClass * self, unsigned char next_byte) { int bytes_sent; diff --git a/src/interfaces/odbc/socket.h b/src/interfaces/odbc/socket.h index b49bebea9b..828372d5cb 100644 --- a/src/interfaces/odbc/socket.h +++ b/src/interfaces/odbc/socket.h @@ -26,7 +26,6 @@ #ifndef _IN_ADDR_T #define _IN_ADDR_T typedef unsigned int in_addr_t; - #endif #define INADDR_NONE ((in_addr_t)-1) #endif @@ -78,18 +77,17 @@ struct SocketClass_ /* Socket prototypes */ -SocketClass *SOCK_Constructor(const ConnectionClass *conn); -void SOCK_Destructor(SocketClass *self); -char SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname); -void SOCK_get_n_char(SocketClass *self, char *buffer, int len); -void SOCK_put_n_char(SocketClass *self, char *buffer, int len); -BOOL SOCK_get_string(SocketClass *self, char *buffer, int bufsize); -void SOCK_put_string(SocketClass *self, char *string); -int SOCK_get_int(SocketClass *self, short len); -void SOCK_put_int(SocketClass *self, int value, short len); -void SOCK_flush_output(SocketClass *self); -unsigned char SOCK_get_next_byte(SocketClass *self); -void SOCK_put_next_byte(SocketClass *self, unsigned char next_byte); -void SOCK_clear_error(SocketClass *self); - +SocketClass *SOCK_Constructor(const ConnectionClass * conn); +void SOCK_Destructor(SocketClass * self); +char SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname); +void SOCK_get_n_char(SocketClass * self, char *buffer, int len); +void SOCK_put_n_char(SocketClass * self, char *buffer, int len); +BOOL SOCK_get_string(SocketClass * self, char *buffer, int bufsize); +void SOCK_put_string(SocketClass * self, char *string); +int SOCK_get_int(SocketClass * self, short len); +void SOCK_put_int(SocketClass * self, int value, short len); +void SOCK_flush_output(SocketClass * self); +unsigned char SOCK_get_next_byte(SocketClass * self); +void SOCK_put_next_byte(SocketClass * self, unsigned char next_byte); +void SOCK_clear_error(SocketClass * self); #endif diff --git a/src/interfaces/odbc/statement.c b/src/interfaces/odbc/statement.c index ca5e8b1c31..f313f926f3 100644 --- a/src/interfaces/odbc/statement.c +++ b/src/interfaces/odbc/statement.c @@ -74,9 +74,9 @@ static struct }; -RETCODE SQL_API +RETCODE SQL_API PGAPI_AllocStmt(HDBC hdbc, - HSTMT FAR *phstmt) + HSTMT FAR * phstmt) { static char *func = "PGAPI_AllocStmt"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -126,9 +126,9 @@ PGAPI_AllocStmt(HDBC hdbc, } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeStmt(HSTMT hstmt, - UWORD fOption) + UWORD fOption) { static char *func = "PGAPI_FreeStmt"; StatementClass *stmt = (StatementClass *) hstmt; @@ -173,7 +173,6 @@ PGAPI_FreeStmt(HSTMT hstmt, SC_unbind_cols(stmt); else if (fOption == SQL_CLOSE) { - /* * this should discard all the results, but leave the statement * itself in place (it can be executed again) @@ -203,7 +202,7 @@ PGAPI_FreeStmt(HSTMT hstmt, * StatementClass implementation */ void -InitializeStatementOptions(StatementOptions *opt) +InitializeStatementOptions(StatementOptions * opt) { opt->maxRows = 0; /* driver returns all rows */ opt->maxLength = 0; /* driver returns all data for char/binary */ @@ -285,7 +284,7 @@ SC_Constructor(void) char -SC_Destructor(StatementClass *self) +SC_Destructor(StatementClass * self) { mylog("SC_Destructor: self=%u, self->result=%u, self->hdbc=%u\n", self, self->result, self->hdbc); SC_clear_error(self); @@ -357,7 +356,7 @@ SC_Destructor(StatementClass *self) * data-at-execution parameters that was allocated in SQLPutData. */ void -SC_free_params(StatementClass *self, char option) +SC_free_params(StatementClass * self, char option) { int i; @@ -422,7 +421,7 @@ statement_type(char *statement) * from SQLFreeStmt(SQL_CLOSE) */ char -SC_recycle_statement(StatementClass *self) +SC_recycle_statement(StatementClass * self) { ConnectionClass *conn; @@ -456,7 +455,7 @@ SC_recycle_statement(StatementClass *self) conn = SC_get_conn(self); if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn)) { - if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature) + if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature) CC_abort(conn); } break; @@ -508,7 +507,7 @@ SC_recycle_statement(StatementClass *self) * Reset only parameters that have anything to do with results */ self->status = STMT_READY; - self->manual_result = FALSE;/* very important */ + self->manual_result = FALSE; /* very important */ self->currTuple = -1; self->rowset_start = -1; @@ -538,7 +537,7 @@ SC_recycle_statement(StatementClass *self) /* Pre-execute a statement (SQLPrepare/SQLDescribeCol) */ void -SC_pre_execute(StatementClass *self) +SC_pre_execute(StatementClass * self) { mylog("SC_pre_execute: status = %d\n", self->status); @@ -577,7 +576,7 @@ SC_pre_execute(StatementClass *self) /* This is only called from SQLFreeStmt(SQL_UNBIND) */ char -SC_unbind_cols(StatementClass *self) +SC_unbind_cols(StatementClass * self) { Int2 lf; @@ -598,7 +597,7 @@ SC_unbind_cols(StatementClass *self) void -SC_clear_error(StatementClass *self) +SC_clear_error(StatementClass * self) { if (self->errormsg_malloced && self->errormsg) free(self->errormsg); @@ -614,7 +613,7 @@ SC_clear_error(StatementClass *self) * of the result, statement, connection, and socket messages. */ char * -SC_create_errormsg(StatementClass *self) +SC_create_errormsg(StatementClass * self) { QResultClass *res = self->result; ConnectionClass *conn = self->hdbc; @@ -653,7 +652,7 @@ SC_create_errormsg(StatementClass *self) char -SC_get_error(StatementClass *self, int *number, char **message) +SC_get_error(StatementClass * self, int *number, char **message) { char rv; @@ -685,29 +684,31 @@ SC_get_error(StatementClass *self, int *number, char **message) * someday, such as mapping a key to a 32 bit value */ unsigned long -SC_get_bookmark(StatementClass *self) +SC_get_bookmark(StatementClass * self) { return (self->currTuple + 1); } RETCODE -SC_fetch(StatementClass *self) +SC_fetch(StatementClass * self) { static char *func = "SC_fetch"; QResultClass *res = self->result; int retval, result; + #ifdef DRIVER_CURSOR_IMPLEMENT - int updret; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + int updret; +#endif /* DRIVER_CURSOR_IMPLEMENT */ Int2 num_cols, lf; Oid type; char *value; ColumnInfoClass *coli; + /* TupleField *tupleField; */ - ConnInfo *ci = &(SC_get_conn(self)->connInfo); + ConnInfo *ci = &(SC_get_conn(self)->connInfo); self->last_fetch_count = 0; coli = QR_get_fields(res); /* the column info */ @@ -719,7 +720,6 @@ SC_fetch(StatementClass *self) if (self->currTuple >= QR_get_num_tuples(res) - 1 || (self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1)) { - /* * if at the end of the tuples, return "no data found" and set * the cursor past the end of the result set @@ -741,7 +741,7 @@ SC_fetch(StatementClass *self) return SQL_NO_DATA_FOUND; } else if (retval > 0) - (self->currTuple)++;/* all is well */ + (self->currTuple)++; /* all is well */ else { mylog("SC_fetch: error\n"); @@ -780,13 +780,13 @@ SC_fetch(StatementClass *self) updret = SQL_ROW_DELETED; num_cols -= 2; } -#endif /* DRIVER_CURSOR_IMPLEMENT */ - if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ + if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */ #ifdef DRIVER_CURSOR_IMPLEMENT return updret ? updret + 10 : SQL_SUCCESS; #else - return SQL_SUCCESS; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + return SQL_SUCCESS; +#endif /* DRIVER_CURSOR_IMPLEMENT */ for (lf = 0; lf < num_cols; lf++) { mylog("fetch: cols=%d, lf=%d, self = %u, self->bindings = %u, buffer[] = %u\n", num_cols, lf, self, self->bindings, self->bindings[lf].buffer); @@ -799,7 +799,7 @@ SC_fetch(StatementClass *self) /* this column has a binding */ /* type = QR_get_field_type(res, lf); */ - type = CI_get_oid(coli, lf); /* speed things up */ + type = CI_get_oid(coli, lf); /* speed things up */ mylog("type = %d\n", type); @@ -841,7 +841,7 @@ SC_fetch(StatementClass *self) case COPY_RESULT_TRUNCATED: self->errornumber = STMT_TRUNCATED; self->errormsg = "Fetched item was truncated."; - qlog("The %dth item was truncated\n", lf + 1); + qlog("The %dth item was truncated\n", lf + 1); qlog("The buffer size = %d", self->bindings[lf].buflen); qlog(" and the value is '%s'\n", value); result = SQL_SUCCESS_WITH_INFO; @@ -870,13 +870,13 @@ SC_fetch(StatementClass *self) #ifdef DRIVER_CURSOR_IMPLEMENT if (updret) result = updret + 10; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ return result; } RETCODE -SC_execute(StatementClass *self) +SC_execute(StatementClass * self) { static char *func = "SC_execute"; ConnectionClass *conn; @@ -887,7 +887,7 @@ SC_execute(StatementClass *self) Int2 oldstatus, numcols; QueryInfo qi; - ConnInfo *ci; + ConnInfo *ci; conn = SC_get_conn(self); @@ -904,8 +904,8 @@ SC_execute(StatementClass *self) * OTHER. */ if (!self->internal && !CC_is_in_trans(conn) && - (SC_is_fetchcursor(self) || - (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER))) + (SC_is_fetchcursor(self) || + (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER))) { mylog(" about to begin a transaction on statement = %u\n", self); res = CC_send_query(conn, "BEGIN", NULL); @@ -1067,19 +1067,21 @@ SC_execute(StatementClass *self) } if (self->statement_type == STMT_TYPE_PROCCALL && - (self->errornumber == STMT_OK || - self->errornumber == STMT_INFO_ONLY) && - self->parameters && - self->parameters[0].buffer && - self->parameters[0].paramType == SQL_PARAM_OUTPUT) - { /* get the return value of the procedure call */ - RETCODE ret; - HSTMT hstmt = (HSTMT) self; + (self->errornumber == STMT_OK || + self->errornumber == STMT_INFO_ONLY) && + self->parameters && + self->parameters[0].buffer && + self->parameters[0].paramType == SQL_PARAM_OUTPUT) + { /* get the return value of the procedure + * call */ + RETCODE ret; + HSTMT hstmt = (HSTMT) self; + ret = SC_fetch(hstmt); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) - { + { ret = PGAPI_GetData(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used); - if (ret != SQL_SUCCESS) + if (ret != SQL_SUCCESS) { self->errornumber = STMT_EXEC_ERROR; self->errormsg = "GetData to Procedure return failed."; @@ -1105,7 +1107,7 @@ SC_execute(StatementClass *self) void -SC_log_error(char *func, char *desc, StatementClass *self) +SC_log_error(char *func, char *desc, StatementClass * self) { #ifdef PRN_NULLCHECK #define nullcheck(a) (a ? a : "(NULL)") diff --git a/src/interfaces/odbc/statement.h b/src/interfaces/odbc/statement.h index c1a2152b0c..801c334bf3 100644 --- a/src/interfaces/odbc/statement.h +++ b/src/interfaces/odbc/statement.h @@ -23,10 +23,10 @@ typedef enum { - STMT_ALLOCATED, /* The statement handle is allocated, but + STMT_ALLOCATED, /* The statement handle is allocated, but * not used so far */ - STMT_READY, /* the statement is waiting to be executed */ - STMT_PREMATURE, /* ODBC states that it is legal to call + STMT_READY, /* the statement is waiting to be executed */ + STMT_PREMATURE, /* ODBC states that it is legal to call * e.g. SQLDescribeCol before a call to * SQLExecute, but after SQLPrepare. To * get all the necessary information in @@ -34,9 +34,9 @@ typedef enum * query _before_ the actual call to * SQLExecute, so that statement is * considered to be "premature". */ - STMT_FINISHED, /* statement execution has finished */ - STMT_EXECUTING /* statement execution is still going on */ -} STMT_Status; + STMT_FINISHED, /* statement execution has finished */ + STMT_EXECUTING /* statement execution is still going on */ +} STMT_Status; #define STMT_ROW_VERSION_CHANGED (-4) #define STMT_POS_BEFORE_RECORDSET (-3) @@ -79,18 +79,18 @@ typedef enum /* statement types */ enum { - STMT_TYPE_UNKNOWN = -2, - STMT_TYPE_OTHER = -1, - STMT_TYPE_SELECT = 0, - STMT_TYPE_INSERT, - STMT_TYPE_UPDATE, - STMT_TYPE_DELETE, - STMT_TYPE_CREATE, - STMT_TYPE_ALTER, - STMT_TYPE_DROP, - STMT_TYPE_GRANT, - STMT_TYPE_REVOKE, - STMT_TYPE_PROCCALL + STMT_TYPE_UNKNOWN = -2, + STMT_TYPE_OTHER = -1, + STMT_TYPE_SELECT = 0, + STMT_TYPE_INSERT, + STMT_TYPE_UPDATE, + STMT_TYPE_DELETE, + STMT_TYPE_CREATE, + STMT_TYPE_ALTER, + STMT_TYPE_DROP, + STMT_TYPE_GRANT, + STMT_TYPE_REVOKE, + STMT_TYPE_PROCCALL }; #define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT) @@ -99,18 +99,18 @@ enum /* Parsing status */ enum { - STMT_PARSE_NONE = 0, - STMT_PARSE_COMPLETE, - STMT_PARSE_INCOMPLETE, - STMT_PARSE_FATAL, + STMT_PARSE_NONE = 0, + STMT_PARSE_COMPLETE, + STMT_PARSE_INCOMPLETE, + STMT_PARSE_FATAL, }; /* Result style */ enum { - STMT_FETCH_NONE = 0, - STMT_FETCH_NORMAL, - STMT_FETCH_EXTENDED, + STMT_FETCH_NONE = 0, + STMT_FETCH_NORMAL, + STMT_FETCH_EXTENDED, }; typedef struct @@ -118,7 +118,7 @@ typedef struct COL_INFO *col_info; /* cached SQLColumns info for this table */ char name[MAX_TABLE_LEN + 1]; char alias[MAX_TABLE_LEN + 1]; -} TABLE_INFO; +} TABLE_INFO; typedef struct { @@ -137,7 +137,7 @@ typedef struct char dot[MAX_TABLE_LEN + 1]; char name[MAX_COLUMN_LEN + 1]; char alias[MAX_COLUMN_LEN + 1]; -} FIELD_INFO; +} FIELD_INFO; /******** Statement Handle ***********/ @@ -204,15 +204,16 @@ struct StatementClass_ char cursor_name[MAX_CURSOR_LEN + 1]; - char *stmt_with_params; /* statement after - * parameter - * substitution */ - int stmt_size_limit; + char *stmt_with_params; /* statement after parameter + * substitution */ + int stmt_size_limit; char pre_executing; /* This statement is prematurely executing */ - char inaccurate_result; /* Current status is PREMATURE but + char inaccurate_result; /* Current status is PREMATURE but * result is inaccurate */ - char errormsg_malloced; /* Current error message is malloed (not in a static variable) ? */ + char errormsg_malloced; /* Current error message is + * malloed (not in a static + * variable) ? */ char miscinfo; }; @@ -225,30 +226,29 @@ struct StatementClass_ /* misc info */ #define SC_set_pre_executable(a) (a->miscinfo |= 1L) -#define SC_no_pre_executable(a) (a->miscinfo &= ~1L) -#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0) +#define SC_no_pre_executable(a) (a->miscinfo &= ~1L) +#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0) #define SC_set_fetchcursor(a) (a->miscinfo |= 2L) #define SC_no_fetchcursor(a) (a->miscinfo &= ~2L) #define SC_is_fetchcursor(a) ((a->miscinfo & 2L) != 0) /* Statement prototypes */ StatementClass *SC_Constructor(void); -void InitializeStatementOptions(StatementOptions *opt); -char SC_Destructor(StatementClass *self); +void InitializeStatementOptions(StatementOptions * opt); +char SC_Destructor(StatementClass * self); int statement_type(char *statement); -char parse_statement(StatementClass *stmt); -void SC_pre_execute(StatementClass *self); -char SC_unbind_cols(StatementClass *self); -char SC_recycle_statement(StatementClass *self); - -void SC_clear_error(StatementClass *self); -char SC_get_error(StatementClass *self, int *number, char **message); -char *SC_create_errormsg(StatementClass *self); -RETCODE SC_execute(StatementClass *self); -RETCODE SC_fetch(StatementClass *self); -void SC_free_params(StatementClass *self, char option); -void SC_log_error(char *func, char *desc, StatementClass *self); -unsigned long SC_get_bookmark(StatementClass *self); - +char parse_statement(StatementClass * stmt); +void SC_pre_execute(StatementClass * self); +char SC_unbind_cols(StatementClass * self); +char SC_recycle_statement(StatementClass * self); + +void SC_clear_error(StatementClass * self); +char SC_get_error(StatementClass * self, int *number, char **message); +char *SC_create_errormsg(StatementClass * self); +RETCODE SC_execute(StatementClass * self); +RETCODE SC_fetch(StatementClass * self); +void SC_free_params(StatementClass * self, char option); +void SC_log_error(char *func, char *desc, StatementClass * self); +unsigned long SC_get_bookmark(StatementClass * self); #endif diff --git a/src/interfaces/odbc/tuple.c b/src/interfaces/odbc/tuple.c index 512f36d2b2..94d0bc17d3 100644 --- a/src/interfaces/odbc/tuple.c +++ b/src/interfaces/odbc/tuple.c @@ -24,7 +24,7 @@ void -set_tuplefield_null(TupleField *tuple_field) +set_tuplefield_null(TupleField * tuple_field) { tuple_field->len = 0; tuple_field->value = NULL; /* strdup(""); */ @@ -32,7 +32,7 @@ set_tuplefield_null(TupleField *tuple_field) void -set_tuplefield_string(TupleField *tuple_field, char *string) +set_tuplefield_string(TupleField * tuple_field, char *string) { tuple_field->len = strlen(string); tuple_field->value = malloc(strlen(string) + 1); @@ -41,7 +41,7 @@ set_tuplefield_string(TupleField *tuple_field, char *string) void -set_tuplefield_int2(TupleField *tuple_field, Int2 value) +set_tuplefield_int2(TupleField * tuple_field, Int2 value) { char buffer[10]; @@ -54,7 +54,7 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value) void -set_tuplefield_int4(TupleField *tuple_field, Int4 value) +set_tuplefield_int4(TupleField * tuple_field, Int4 value) { char buffer[15]; diff --git a/src/interfaces/odbc/tuple.h b/src/interfaces/odbc/tuple.h index fdc1a5f9ea..6cd87cb9db 100644 --- a/src/interfaces/odbc/tuple.h +++ b/src/interfaces/odbc/tuple.h @@ -38,9 +38,8 @@ struct TupleNode_ #define set_nullfield_int2(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int2(FLD, (VAL)) : set_tuplefield_null(FLD)) #define set_nullfield_int4(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int4(FLD, (VAL)) : set_tuplefield_null(FLD)) -void set_tuplefield_null(TupleField *tuple_field); -void set_tuplefield_string(TupleField *tuple_field, char *string); -void set_tuplefield_int2(TupleField *tuple_field, Int2 value); -void set_tuplefield_int4(TupleField *tuple_field, Int4 value); - +void set_tuplefield_null(TupleField * tuple_field); +void set_tuplefield_string(TupleField * tuple_field, char *string); +void set_tuplefield_int2(TupleField * tuple_field, Int2 value); +void set_tuplefield_int4(TupleField * tuple_field, Int4 value); #endif diff --git a/src/interfaces/odbc/tuplelist.c b/src/interfaces/odbc/tuplelist.c index 5f3871600d..e00ab43006 100644 --- a/src/interfaces/odbc/tuplelist.c +++ b/src/interfaces/odbc/tuplelist.c @@ -44,7 +44,7 @@ TL_Constructor(UInt4 fieldcnt) void -TL_Destructor(TupleListClass *self) +TL_Destructor(TupleListClass * self) { int lf; TupleNode *node, @@ -70,7 +70,7 @@ TL_Destructor(TupleListClass *self) void * -TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) +TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno) { Int4 lf; Int4 delta, @@ -138,7 +138,6 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) } else if (start_is_closer) { - /* * the shortest way is to start the search from the head of the * list @@ -182,9 +181,8 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) char -TL_add_tuple(TupleListClass *self, TupleNode *new_field) +TL_add_tuple(TupleListClass * self, TupleNode * new_field) { - /* * we append the tuple at the end of the doubly linked list of the * tuples we have already read in @@ -203,7 +201,6 @@ TL_add_tuple(TupleListClass *self, TupleNode *new_field) } else { - /* * there is already an element in the list, so add the new one at * the end of the list diff --git a/src/interfaces/odbc/tuplelist.h b/src/interfaces/odbc/tuplelist.h index 3dc98dd78f..5ce2613e86 100644 --- a/src/interfaces/odbc/tuplelist.h +++ b/src/interfaces/odbc/tuplelist.h @@ -28,8 +28,7 @@ struct TupleListClass_ /* Create a TupleList. Each tuple consits of fieldcnt columns */ TupleListClass *TL_Constructor(UInt4 fieldcnt); -void TL_Destructor(TupleListClass *self); -void *TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno); -char TL_add_tuple(TupleListClass *self, TupleNode *new_field); - +void TL_Destructor(TupleListClass * self); +void *TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno); +char TL_add_tuple(TupleListClass * self, TupleNode * new_field); #endif diff --git a/src/interfaces/perl5/ppport.h b/src/interfaces/perl5/ppport.h index be5f99087a..e39b9f52a0 100644 --- a/src/interfaces/perl5/ppport.h +++ b/src/interfaces/perl5/ppport.h @@ -237,7 +237,6 @@ newRV_noinc(SV * sv) static #else extern void newCONSTSUB _((HV * stash, char *name, SV * sv)); - #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) @@ -284,10 +283,7 @@ SV *sv; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } - #endif - #endif /* newCONSTSUB */ - #endif /* _P_P_PORTABILITY_H_ */ diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c index 4bf0fa2aa2..38fc4f2d7c 100644 --- a/src/interfaces/python/pgmodule.c +++ b/src/interfaces/python/pgmodule.c @@ -94,16 +94,15 @@ const char *__movename[5] = static PyObject *pg_default_host; /* default database host */ static PyObject *pg_default_base; /* default database name */ -static PyObject *pg_default_opt;/* default connection options */ -static PyObject *pg_default_tty;/* default debug tty */ +static PyObject *pg_default_opt; /* default connection options */ +static PyObject *pg_default_tty; /* default debug tty */ static PyObject *pg_default_port; /* default connection port */ static PyObject *pg_default_user; /* default username */ static PyObject *pg_default_passwd; /* default password */ - #endif /* DEFAULT_VARS */ DL_EXPORT(void) init_pg(void); -int *get_type_array(PGresult *result, int nfields); +int *get_type_array(PGresult *result, int nfields); /* --------------------------------------------------------------------- */ /* OBJECTS DECLARATION */ @@ -112,7 +111,7 @@ int *get_type_array(PGresult *result, int nfields); typedef struct { - PyObject_HEAD + PyObject_HEAD int valid; /* validity flag */ PGconn *cnx; /* PostGres connection handle */ PGresult *last_result; /* last result content */ @@ -140,7 +139,7 @@ pgobject_New(void) typedef struct { - PyObject_HEAD + PyObject_HEAD PGresult *last_result; /* last result content */ int result_type; /* type of previous result */ long current_pos; /* current position in last result */ @@ -155,7 +154,7 @@ staticforward PyTypeObject PgQueryType; typedef struct { - PyObject_HEAD + PyObject_HEAD int valid; /* validity flag */ pgobject *pgcnx; /* parent connection object */ PGresult *last_result; /* last result content */ @@ -176,8 +175,8 @@ staticforward PyTypeObject PgSourceType; typedef struct { - PyObject_HEAD - pgobject * pgcnx; /* parent connection object */ + PyObject_HEAD + pgobject * pgcnx; /* parent connection object */ Oid lo_oid; /* large object oid */ int lo_fd; /* large object fd */ } pglargeobject; @@ -236,7 +235,6 @@ check_lo_obj(pglargeobject * self, int level) return 1; } - #endif /* LARGE_OBJECTS */ /* checks source object validity */ @@ -1452,7 +1450,6 @@ staticforward PyTypeObject PglargeType = { 0, /* tp_as_mapping */ 0, /* tp_hash */ }; - #endif /* LARGE_OBJECTS */ @@ -1848,32 +1845,33 @@ pgquery_getresult(pgqueryobject * self, PyObject * args) break; case 3: - { - int mult = 1; - - if (*s == '$') /* there's talk of getting rid of - * it */ - s++; - - if (*s == '-' || *s == '(') { - s++; - mult = -1; + int mult = 1; + + if (*s == '$') /* there's talk of getting + * rid of it */ + s++; + + if (*s == '-' || *s == '(') + { + s++; + mult = -1; + } + + /* get rid of the '$' and commas */ + if (*s == '$') /* Just in case we exposed + * one */ + s++; + + for (k = 0; *s; s++) + if (*s != ',') + cashbuf[k++] = *s; + + cashbuf[k] = 0; + val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); + break; } - /* get rid of the '$' and commas */ - if (*s == '$') /* Just in case we exposed one */ - s++; - - for (k = 0; *s; s++) - if (*s != ',') - cashbuf[k++] = *s; - - cashbuf[k] = 0; - val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); - break; - } - default: val = PyString_FromString(s); break; @@ -1996,32 +1994,33 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args) break; case 3: - { - int mult = 1; - - if (*s == '$') /* there's talk of getting rid of - * it */ - s++; - - if (*s == '-' || *s == '(') { - s++; - mult = -1; + int mult = 1; + + if (*s == '$') /* there's talk of getting + * rid of it */ + s++; + + if (*s == '-' || *s == '(') + { + s++; + mult = -1; + } + + /* get rid of the '$' and commas */ + if (*s == '$') /* Just in case we exposed + * one */ + s++; + + for (k = 0; *s; s++) + if (*s != ',') + cashbuf[k++] = *s; + + cashbuf[k] = 0; + val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); + break; } - /* get rid of the '$' and commas */ - if (*s == '$') /* Just in case we exposed one */ - s++; - - for (k = 0; *s; s++) - if (*s != ',') - cashbuf[k++] = *s; - - cashbuf[k] = 0; - val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); - break; - } - default: val = PyString_FromString(s); break; @@ -2336,7 +2335,6 @@ pg_endcopy(pgobject * self, PyObject * args) Py_INCREF(Py_None); return Py_None; } - #endif /* DIRECT_ACCESS */ @@ -2640,7 +2638,6 @@ static struct PyMethodDef pgobj_methods[] = { static PyObject * pg_getattr(pgobject * self, char *name) { - /* * Although we could check individually, there are only a few * attributes that don't require a live connection and unless someone @@ -3122,7 +3119,6 @@ pgsetdefport(PyObject * self, PyObject * args) return old; } - #endif /* DEFAULT_VARS */ /* List of functions defined in the module */ diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index c1229a5305..a5ae6ff7fd 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.24 2001/10/19 22:43:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.25 2001/10/25 05:50:17 momjian Exp $ * **********************************************************************/ @@ -300,8 +300,8 @@ plperl_create_sub(char *s, bool trusted) PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv(s, 0))); PUTBACK; - count = perl_call_pv( (trusted?"mksafefunc":"mkunsafefunc"), - G_SCALAR | G_EVAL | G_KEEPERR); + count = perl_call_pv((trusted ? "mksafefunc" : "mkunsafefunc"), + G_SCALAR | G_EVAL | G_KEEPERR); SPAGAIN; if (SvTRUE(ERRSV)) @@ -358,7 +358,7 @@ plperl_init_shared_libs(void) { char *file = __FILE__; - newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); + newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); newXS("SPI::bootstrap", boot_SPI, file); } @@ -622,7 +622,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) if (!is_trigger) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -660,7 +660,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) for (i = 0; i < prodesc->nargs; i++) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes[i]), + ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -780,8 +780,8 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) ************************************************************/ outputstr = DatumGetCString(OidFunctionCall3(typoutput, attr, - ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->atttypmod))); + ObjectIdGetDatum(typelem), + Int32GetDatum(tupdesc->attrs[i]->atttypmod))); sv_catpvf(output, "'%s' => '%s',", attname, outputstr); pfree(outputstr); } diff --git a/src/pl/plperl/ppport.h b/src/pl/plperl/ppport.h index be5f99087a..e39b9f52a0 100644 --- a/src/pl/plperl/ppport.h +++ b/src/pl/plperl/ppport.h @@ -237,7 +237,6 @@ newRV_noinc(SV * sv) static #else extern void newCONSTSUB _((HV * stash, char *name, SV * sv)); - #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) @@ -284,10 +283,7 @@ SV *sv; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } - #endif - #endif /* newCONSTSUB */ - #endif /* _P_P_PORTABILITY_H_ */ diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 39630876ef..443a8a625d 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.36 2001/10/09 15:59:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.37 2001/10/25 05:50:20 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -252,7 +252,6 @@ plpgsql_compile(Oid fn_oid, int functype) if (typeStruct->typrelid != InvalidOid) { - /* * For tuple type parameters, we set up a record of * that type @@ -274,7 +273,6 @@ plpgsql_compile(Oid fn_oid, int functype) } else { - /* * Normal parameters get a var node */ @@ -691,7 +689,6 @@ plpgsql_parse_dblword(char *string) case PLPGSQL_NSTYPE_REC: { - /* * First word is a record name, so second word must be a * field in this record. @@ -712,7 +709,6 @@ plpgsql_parse_dblword(char *string) case PLPGSQL_NSTYPE_ROW: { - /* * First word is a row name, so second word must be a * field in this row. @@ -794,7 +790,6 @@ plpgsql_parse_tripword(char *string) { case PLPGSQL_NSTYPE_REC: { - /* * This word is a record name, so third word must be a * field in this record. @@ -815,7 +810,6 @@ plpgsql_parse_tripword(char *string) case PLPGSQL_NSTYPE_ROW: { - /* * This word is a row name, so third word must be a field * in this row. @@ -1137,7 +1131,6 @@ plpgsql_parse_wordrowtype(char *string) for (i = 0; i < row->nfields; i++) { - /* * Get the attribute and it's type */ @@ -1164,11 +1157,11 @@ plpgsql_parse_wordrowtype(char *string) * Create the internal variable * * We know if the table definitions contain a default value or if the - * field is declared in the table as NOT NULL. But it's possible to - * create a table field as NOT NULL without a default value and that - * would lead to problems later when initializing the variables due to - * entering a block at execution time. Thus we ignore this information - * for now. + * field is declared in the table as NOT NULL. But it's possible + * to create a table field as NOT NULL without a default value and + * that would lead to problems later when initializing the + * variables due to entering a block at execution time. Thus we + * ignore this information for now. */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -1223,8 +1216,8 @@ plpgsql_parse_wordrowtype(char *string) PLpgSQL_type * plpgsql_parse_datatype(char *string) { - Oid type_id; - int32 typmod; + Oid type_id; + int32 typmod; HeapTuple typeTup; Form_pg_type typeStruct; PLpgSQL_type *typ; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index f275269826..9ad6d5dece 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.47 2001/08/02 21:31:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.48 2001/10/25 05:50:20 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -96,11 +96,11 @@ static int exec_stmt_fors(PLpgSQL_execstate * estate, static int exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt); static int exec_stmt_open(PLpgSQL_execstate * estate, - PLpgSQL_stmt_open * stmt); + PLpgSQL_stmt_open * stmt); static int exec_stmt_fetch(PLpgSQL_execstate * estate, - PLpgSQL_stmt_fetch * stmt); + PLpgSQL_stmt_fetch * stmt); static int exec_stmt_close(PLpgSQL_execstate * estate, - PLpgSQL_stmt_close * stmt); + PLpgSQL_stmt_close * stmt); static int exec_stmt_exit(PLpgSQL_execstate * estate, PLpgSQL_stmt_exit * stmt); static int exec_stmt_return(PLpgSQL_execstate * estate, @@ -115,7 +115,7 @@ static int exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt); static void plpgsql_estate_setup(PLpgSQL_execstate * estate, - PLpgSQL_function * func); + PLpgSQL_function * func); static void exec_eval_cleanup(PLpgSQL_execstate * estate); static void exec_prepare_plan(PLpgSQL_execstate * estate, @@ -859,7 +859,7 @@ exec_stmt_block(PLpgSQL_execstate * estate, PLpgSQL_stmt_block * block) if (var->freeval) { - pfree((void *)(var->value)); + pfree((void *) (var->value)); var->freeval = false; } @@ -1072,16 +1072,16 @@ exec_stmt(PLpgSQL_execstate * estate, PLpgSQL_stmt * stmt) static int exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt) { - PLpgSQL_expr *expr = stmt->expr; + PLpgSQL_expr *expr = stmt->expr; if (stmt->varno >= 0) exec_assign_expr(estate, estate->datums[stmt->varno], expr); else { /* - * PERFORM: evaluate query and discard result. This cannot share - * code with the assignment case since we do not wish to constraint - * the discarded result to be only one row/column. + * PERFORM: evaluate query and discard result. This cannot share + * code with the assignment case since we do not wish to + * constraint the discarded result to be only one row/column. */ int rc; @@ -1322,7 +1322,6 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) exec_set_found(estate, false); for (;;) { - /* * Check bounds */ @@ -1418,8 +1417,8 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt) } /* - * Open the implicit cursor for the statement and fetch - * the initial 10 rows. + * Open the implicit cursor for the statement and fetch the initial 10 + * rows. */ exec_run_select(estate, stmt->query, 0, &portal); @@ -1636,6 +1635,7 @@ exec_stmt_return(PLpgSQL_execstate * estate, PLpgSQL_stmt_return * stmt) estate->rettupdesc = SPI_copytupledesc(estate->eval_tuptable->tupdesc); estate->retisnull = false; } + /* * Okay to clean up here, since we already copied result tuple * to upper executor. @@ -1678,7 +1678,6 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) for (cp = stmt->message; *cp; cp++) { - /* * Occurences of a single % are replaced by the next arguments * external representation. Double %'s are left as is so elog() @@ -1882,8 +1881,8 @@ exec_prepare_plan(PLpgSQL_execstate * estate, Oid *argtypes; /* - * We need a temporary argtypes array to load with data. - * (The finished plan structure will contain a copy of it.) + * We need a temporary argtypes array to load with data. (The finished + * plan structure will contain a copy of it.) * * +1 is just to avoid palloc(0) error. */ @@ -2047,7 +2046,10 @@ exec_stmt_execsql(PLpgSQL_execstate * estate, expr->query); } - /* Release any result tuples from SPI_execp (probably shouldn't be any) */ + /* + * Release any result tuples from SPI_execp (probably shouldn't be + * any) + */ SPI_freetuptable(SPI_tuptable); /* Save result info for GET DIAGNOSTICS */ @@ -2181,7 +2183,7 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) HeapTuple typetup; Form_pg_type typeStruct; FmgrInfo finfo_output; - void *plan; + void *plan; Portal portal; /* @@ -2238,7 +2240,7 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) portal = SPI_cursor_open(NULL, plan, NULL, NULL); if (portal == NULL) elog(ERROR, "failed to open implicit cursor for dynamic query \"%s\"", - querystr); + querystr); pfree(querystr); SPI_freeplan(plan); @@ -2344,7 +2346,7 @@ static int exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) { PLpgSQL_var *curvar = NULL; - char *curname = NULL; + char *curname = NULL; PLpgSQL_expr *query = NULL; Portal portal; @@ -2387,7 +2389,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) * done downstairs. * ---------- */ - query = stmt->query; + query = stmt->query; if (query->plan == NULL) exec_prepare_plan(estate, query); } @@ -2403,7 +2405,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) HeapTuple typetup; Form_pg_type typeStruct; FmgrInfo finfo_output; - void *curplan = NULL; + void *curplan = NULL; /* ---------- * We evaluate the string expression after the @@ -2429,7 +2431,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) fmgr_info(typeStruct->typoutput, &finfo_output); querystr = DatumGetCString(FunctionCall3(&finfo_output, queryD, - ObjectIdGetDatum(typeStruct->typelem), + ObjectIdGetDatum(typeStruct->typelem), Int32GetDatum(-1))); ReleaseSysCache(typetup); @@ -2450,7 +2452,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) * ---------- */ if (curvar->freeval) - pfree((void *)(curvar->value)); + pfree((void *) (curvar->value)); curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name)); curvar->isnull = false; @@ -2472,20 +2474,20 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) * internal row. * ---------- */ - PLpgSQL_stmt_select set_args; + PLpgSQL_stmt_select set_args; memset(&set_args, 0, sizeof(set_args)); - set_args.cmd_type = PLPGSQL_STMT_SELECT; - set_args.lineno = stmt->lineno; - set_args.row = (PLpgSQL_row *) - (estate->datums[curvar->cursor_explicit_argrow]); - set_args.query = stmt->argquery; + set_args.cmd_type = PLPGSQL_STMT_SELECT; + set_args.lineno = stmt->lineno; + set_args.row = (PLpgSQL_row *) + (estate->datums[curvar->cursor_explicit_argrow]); + set_args.query = stmt->argquery; if (exec_stmt_select(estate, &set_args) != PLPGSQL_RC_OK) elog(ERROR, "open cursor failed during argument processing"); } - query = curvar->cursor_explicit_expr; + query = curvar->cursor_explicit_expr; if (query->plan == NULL) exec_prepare_plan(estate, query); } @@ -2574,7 +2576,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) * ---------- */ if (curvar->freeval) - pfree((void *)(curvar->value)); + pfree((void *) (curvar->value)); curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name)); curvar->isnull = false; @@ -2596,7 +2598,7 @@ exec_stmt_fetch(PLpgSQL_execstate * estate, PLpgSQL_stmt_fetch * stmt) PLpgSQL_row *row = NULL; SPITupleTable *tuptab; Portal portal; - char *curname; + char *curname; int n; /* ---------- @@ -2674,7 +2676,7 @@ exec_stmt_close(PLpgSQL_execstate * estate, PLpgSQL_stmt_close * stmt) { PLpgSQL_var *curvar = NULL; Portal portal; - char *curname; + char *curname; /* ---------- * Get the portal of the cursor by name @@ -2757,7 +2759,7 @@ exec_assign_value(PLpgSQL_execstate * estate, if (var->freeval) { - pfree((void *)(var->value)); + pfree((void *) (var->value)); var->freeval = false; } @@ -2771,23 +2773,24 @@ exec_assign_value(PLpgSQL_execstate * estate, elog(ERROR, "NULL assignment to variable '%s' declared NOT NULL", var->refname); /* - * If type is by-reference, make sure we have a freshly palloc'd - * copy; the originally passed value may not live as long as the - * variable! But we don't need to re-copy if exec_cast_value - * performed a conversion; its output must already be palloc'd. + * If type is by-reference, make sure we have a freshly + * palloc'd copy; the originally passed value may not live as + * long as the variable! But we don't need to re-copy if + * exec_cast_value performed a conversion; its output must + * already be palloc'd. */ if (!var->datatype->typbyval && !*isNull) { if (newvalue == value) { - int len; + int len; if (var->datatype->typlen < 0) len = VARSIZE(newvalue); else len = var->datatype->typlen; var->value = (Datum) palloc(len); - memcpy((void *)(var->value), (void *)newvalue, len); + memcpy((void *) (var->value), (void *) newvalue, len); } else var->value = newvalue; @@ -2825,9 +2828,9 @@ exec_assign_value(PLpgSQL_execstate * estate, natts = rec->tupdesc->natts; /* - * Set up values/datums arrays for heap_formtuple. For all the - * attributes except the one we want to replace, use the value - * that's in the old tuple. + * Set up values/datums arrays for heap_formtuple. For all + * the attributes except the one we want to replace, use the + * value that's in the old tuple. */ values = palloc(sizeof(Datum) * natts); nulls = palloc(natts); @@ -2869,8 +2872,8 @@ exec_assign_value(PLpgSQL_execstate * estate, nulls[fno] = ' '; /* - * Avoid leaking the result of exec_cast_value, if it performed - * a conversion to a pass-by-ref type. + * Avoid leaking the result of exec_cast_value, if it + * performed a conversion to a pass-by-ref type. */ if (!typeStruct->typbyval && !attisnull && values[fno] != value) mustfree = DatumGetPointer(values[fno]); @@ -2953,7 +2956,7 @@ exec_eval_expr(PLpgSQL_execstate * estate, elog(ERROR, "query \"%s\" returned more than one row", expr->query); if (estate->eval_tuptable->tupdesc->natts != 1) elog(ERROR, "query \"%s\" returned %d columns", expr->query, - estate->eval_tuptable->tupdesc->natts); + estate->eval_tuptable->tupdesc->natts); /* * Return the result and its type @@ -3062,7 +3065,7 @@ exec_run_select(PLpgSQL_execstate * estate, *portalP = SPI_cursor_open(NULL, expr->plan, values, nulls); if (*portalP == NULL) elog(ERROR, "failed to open implicit cursor for \"%s\"", - expr->query); + expr->query); pfree(values); pfree(nulls); return SPI_OK_CURSOR; @@ -3118,17 +3121,17 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, * * NOTE: we pass the SPI plan's context as the query-lifetime context for * function cache nodes and suchlike allocations. This is appropriate - * because that's where the expression tree itself is, and the function - * cache nodes must live as long as it does. + * because that's where the expression tree itself is, and the + * function cache nodes must live as long as it does. */ econtext = MakeExprContext(NULL, spi_plan->plancxt); /* * Param list can live in econtext's temporary memory context. */ - paramLI = (ParamListInfo) + paramLI = (ParamListInfo) MemoryContextAlloc(econtext->ecxt_per_tuple_memory, - (expr->nparams + 1) * sizeof(ParamListInfoData)); + (expr->nparams + 1) * sizeof(ParamListInfoData)); econtext->ecxt_param_list_info = paramLI; /* @@ -3204,8 +3207,9 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, SPI_pop(); /* - * Note: if pass-by-reference, the result is in the econtext's temporary - * memory context. It will be freed when exec_eval_cleanup is done. + * Note: if pass-by-reference, the result is in the econtext's + * temporary memory context. It will be freed when exec_eval_cleanup + * is done. */ Assert(estate->eval_econtext == NULL); estate->eval_econtext = econtext; @@ -3265,11 +3269,11 @@ exec_move_row(PLpgSQL_execstate * estate, * attributes of the tuple to the variables the row points to. * * NOTE: this code used to demand row->nfields == tup->t_data->t_natts, - * but that's wrong. The tuple might have more fields than we expected - * if it's from an inheritance-child table of the current table, or it - * might have fewer if the table has had columns added by ALTER TABLE. - * Ignore extra columns and assume NULL for missing columns, the same - * as heap_getattr would do. + * but that's wrong. The tuple might have more fields than we + * expected if it's from an inheritance-child table of the current + * table, or it might have fewer if the table has had columns added by + * ALTER TABLE. Ignore extra columns and assume NULL for missing + * columns, the same as heap_getattr would do. */ if (row != NULL) { @@ -3374,7 +3378,7 @@ exec_simple_check_node(Node *node) { switch (nodeTag(node)) { - case T_Expr: + case T_Expr: { Expr *expr = (Expr *) node; List *l; diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index bacd287fdd..75ace2e885 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.9 2001/10/09 15:59:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.10 2001/10/25 05:50:20 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -58,7 +58,7 @@ static PLpgSQL_function *compiled_functions = NULL; -static bool func_up_to_date(PLpgSQL_function *func); +static bool func_up_to_date(PLpgSQL_function * func); /* ---------- @@ -93,10 +93,11 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) if (func != NULL) { Assert(func->fn_oid == funcOid); + /* * But is the function still up to date? */ - if (! func_up_to_date(func)) + if (!func_up_to_date(func)) func = NULL; } @@ -154,7 +155,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) * function's pg_proc entry without changing its OID. */ static bool -func_up_to_date(PLpgSQL_function *func) +func_up_to_date(PLpgSQL_function * func) { HeapTuple procTup; bool result; diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 147659e7cc..cc3918b3c3 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.19 2001/10/09 15:59:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.20 2001/10/25 05:50:20 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -53,11 +53,11 @@ */ enum { - PLPGSQL_NSTYPE_LABEL, - PLPGSQL_NSTYPE_VAR, - PLPGSQL_NSTYPE_ROW, - PLPGSQL_NSTYPE_REC, - PLPGSQL_NSTYPE_RECFIELD + PLPGSQL_NSTYPE_LABEL, + PLPGSQL_NSTYPE_VAR, + PLPGSQL_NSTYPE_ROW, + PLPGSQL_NSTYPE_REC, + PLPGSQL_NSTYPE_RECFIELD }; /* ---------- @@ -66,12 +66,12 @@ enum */ enum { - PLPGSQL_DTYPE_VAR, - PLPGSQL_DTYPE_ROW, - PLPGSQL_DTYPE_REC, - PLPGSQL_DTYPE_RECFIELD, - PLPGSQL_DTYPE_EXPR, - PLPGSQL_DTYPE_TRIGARG + PLPGSQL_DTYPE_VAR, + PLPGSQL_DTYPE_ROW, + PLPGSQL_DTYPE_REC, + PLPGSQL_DTYPE_RECFIELD, + PLPGSQL_DTYPE_EXPR, + PLPGSQL_DTYPE_TRIGARG }; /* ---------- @@ -80,24 +80,24 @@ enum */ enum { - PLPGSQL_STMT_BLOCK, - PLPGSQL_STMT_ASSIGN, - PLPGSQL_STMT_IF, - PLPGSQL_STMT_LOOP, - PLPGSQL_STMT_WHILE, - PLPGSQL_STMT_FORI, - PLPGSQL_STMT_FORS, - PLPGSQL_STMT_SELECT, - PLPGSQL_STMT_EXIT, - PLPGSQL_STMT_RETURN, - PLPGSQL_STMT_RAISE, - PLPGSQL_STMT_EXECSQL, - PLPGSQL_STMT_DYNEXECUTE, - PLPGSQL_STMT_DYNFORS, - PLPGSQL_STMT_GETDIAG, - PLPGSQL_STMT_OPEN, - PLPGSQL_STMT_FETCH, - PLPGSQL_STMT_CLOSE + PLPGSQL_STMT_BLOCK, + PLPGSQL_STMT_ASSIGN, + PLPGSQL_STMT_IF, + PLPGSQL_STMT_LOOP, + PLPGSQL_STMT_WHILE, + PLPGSQL_STMT_FORI, + PLPGSQL_STMT_FORS, + PLPGSQL_STMT_SELECT, + PLPGSQL_STMT_EXIT, + PLPGSQL_STMT_RETURN, + PLPGSQL_STMT_RAISE, + PLPGSQL_STMT_EXECSQL, + PLPGSQL_STMT_DYNEXECUTE, + PLPGSQL_STMT_DYNFORS, + PLPGSQL_STMT_GETDIAG, + PLPGSQL_STMT_OPEN, + PLPGSQL_STMT_FETCH, + PLPGSQL_STMT_CLOSE }; @@ -107,9 +107,9 @@ enum */ enum { - PLPGSQL_RC_OK, - PLPGSQL_RC_EXIT, - PLPGSQL_RC_RETURN + PLPGSQL_RC_OK, + PLPGSQL_RC_EXIT, + PLPGSQL_RC_RETURN }; /* ---------- @@ -118,8 +118,8 @@ enum */ enum { - PLPGSQL_GETDIAG_ROW_COUNT, - PLPGSQL_GETDIAG_RESULT_OID + PLPGSQL_GETDIAG_ROW_COUNT, + PLPGSQL_GETDIAG_RESULT_OID }; @@ -382,7 +382,7 @@ typedef struct int cmd_type; int lineno; int curvar; - PLpgSQL_row *returntype; + PLpgSQL_row *returntype; PLpgSQL_expr *argquery; PLpgSQL_expr *query; PLpgSQL_expr *dynquery; @@ -486,7 +486,7 @@ typedef struct PLpgSQL_function PLpgSQL_datum **datums; PLpgSQL_stmt_block *action; - struct PLpgSQL_function *next; /* for chaining list of functions */ + struct PLpgSQL_function *next; /* for chaining list of functions */ } PLpgSQL_function; @@ -529,8 +529,10 @@ extern char *plpgsql_error_funcname; /* linkage to the real yytext and yylineno variables */ extern char *plpgsql_base_yytext; + #define plpgsql_yytext plpgsql_base_yytext extern int plpgsql_base_yylineno; + #define plpgsql_yylineno plpgsql_base_yylineno extern PLpgSQL_function *plpgsql_curr_compile; @@ -609,5 +611,4 @@ extern int plpgsql_base_yylex(void); extern int plpgsql_yylex(void); extern void plpgsql_push_back_token(int token); extern void plpgsql_setinput(char *s, int functype); - #endif /* PLPGSQL_H */ diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index edb2d69a9f..3483d21ae3 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.9 2001/10/22 19:32:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.10 2001/10/25 05:50:20 momjian Exp $ * ********************************************************************* */ @@ -70,88 +70,100 @@ typedef PyObject *(*PLyDatumToObFunc) (const char *); -typedef struct PLyDatumToOb { - PLyDatumToObFunc func; - FmgrInfo typfunc; - Oid typelem; - bool typbyval; -} PLyDatumToOb; +typedef struct PLyDatumToOb +{ + PLyDatumToObFunc func; + FmgrInfo typfunc; + Oid typelem; + bool typbyval; +} PLyDatumToOb; -typedef struct PLyTupleToOb { - PLyDatumToOb *atts; - int natts; -} PLyTupleToOb; +typedef struct PLyTupleToOb +{ + PLyDatumToOb *atts; + int natts; +} PLyTupleToOb; -typedef union PLyTypeInput { - PLyDatumToOb d; - PLyTupleToOb r; -} PLyTypeInput; +typedef union PLyTypeInput +{ + PLyDatumToOb d; + PLyTupleToOb r; +} PLyTypeInput; /* convert PyObject to a Postgresql Datum or tuple. * output from Python */ -typedef struct PLyObToDatum { - FmgrInfo typfunc; - Oid typelem; - bool typbyval; -} PLyObToDatum; - -typedef struct PLyObToTuple { - PLyObToDatum *atts; - int natts; -} PLyObToTuple; - -typedef union PLyTypeOutput { - PLyObToDatum d; - PLyObToTuple r; -} PLyTypeOutput; +typedef struct PLyObToDatum +{ + FmgrInfo typfunc; + Oid typelem; + bool typbyval; +} PLyObToDatum; + +typedef struct PLyObToTuple +{ + PLyObToDatum *atts; + int natts; +} PLyObToTuple; + +typedef union PLyTypeOutput +{ + PLyObToDatum d; + PLyObToTuple r; +} PLyTypeOutput; /* all we need to move Postgresql data to Python objects, * and vis versa */ -typedef struct PLyTypeInfo { - PLyTypeInput in; - PLyTypeOutput out; - int is_rel; -} PLyTypeInfo; +typedef struct PLyTypeInfo +{ + PLyTypeInput in; + PLyTypeOutput out; + int is_rel; +} PLyTypeInfo; /* cached procedure data */ -typedef struct PLyProcedure { - char *proname; - TransactionId fn_xmin; - CommandId fn_cmin; - PLyTypeInfo result; /* also used to store info for trigger tuple type */ - PLyTypeInfo args[FUNC_MAX_ARGS]; - int nargs; - PyObject *interp; /* restricted interpreter instance */ - PyObject *reval; /* interpreter return */ - PyObject *code; /* compiled procedure code */ - PyObject *statics; /* data saved across calls, local scope */ - PyObject *globals; /* data saved across calls, global score */ - PyObject *me; /* PyCObject containing pointer to this PLyProcedure */ -} PLyProcedure; - - -/* Python objects. +typedef struct PLyProcedure +{ + char *proname; + TransactionId fn_xmin; + CommandId fn_cmin; + PLyTypeInfo result; /* also used to store info for trigger + * tuple type */ + PLyTypeInfo args[FUNC_MAX_ARGS]; + int nargs; + PyObject *interp; /* restricted interpreter instance */ + PyObject *reval; /* interpreter return */ + PyObject *code; /* compiled procedure code */ + PyObject *statics; /* data saved across calls, local scope */ + PyObject *globals; /* data saved across calls, global score */ + PyObject *me; /* PyCObject containing pointer to this + * PLyProcedure */ +} PLyProcedure; + + +/* Python objects. */ -typedef struct PLyPlanObject { - PyObject_HEAD; - void *plan; /* return of an SPI_saveplan */ - int nargs; - Oid *types; - Datum *values; - PLyTypeInfo *args; -} PLyPlanObject; - -typedef struct PLyResultObject { - PyObject_HEAD; - /* HeapTuple *tuples; */ - PyObject *nrows; /* number of rows returned by query */ - PyObject *rows; /* data rows, or None if no data returned */ - PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */ -} PLyResultObject; +typedef struct PLyPlanObject +{ + PyObject_HEAD; + void *plan; /* return of an SPI_saveplan */ + int nargs; + Oid *types; + Datum *values; + PLyTypeInfo *args; +} PLyPlanObject; + +typedef struct PLyResultObject +{ + PyObject_HEAD; + /* HeapTuple *tuples; */ + PyObject *nrows; /* number of rows returned by query */ + PyObject *rows; /* data rows, or None if no data returned */ + PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */ +} PLyResultObject; /* function declarations @@ -160,7 +172,8 @@ typedef struct PLyResultObject { /* the only exported function, with the magic telling Postgresql * what function call interface it implements. */ -Datum plpython_call_handler(PG_FUNCTION_ARGS); +Datum plpython_call_handler(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(plpython_call_handler); /* most of the remaining of the declarations, all static @@ -178,12 +191,13 @@ static void PLy_init_plpy(void); /* error handler. collects the current Python exception, if any, * and appends it to the error and sends it to elog */ -static void PLy_elog(int, const char *, ...); +static void PLy_elog(int, const char *,...); /* call PyErr_SetString with a vprint interface */ -static void PLy_exception_set(PyObject *, const char *, ...) - __attribute__ ((format (printf, 2, 3))); +static void +PLy_exception_set(PyObject *, const char *,...) +__attribute__((format(printf, 2, 3))); /* some utility functions */ @@ -198,9 +212,9 @@ static HeapTuple PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure *); static PyObject *PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *); static PyObject *PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *, - HeapTuple *); + HeapTuple *); static HeapTuple PLy_modify_tuple(PLyProcedure *, PyObject *, - TriggerData *, HeapTuple); + TriggerData *, HeapTuple); static PyObject *PLy_procedure_call(PLyProcedure *, char *, PyObject *); @@ -210,8 +224,8 @@ static PyObject *PLy_procedure_call(PLyProcedure *, char *, PyObject *); static PLyProcedure *PLy_procedure_get(FunctionCallInfo fcinfo, bool); static PLyProcedure *PLy_procedure_create(FunctionCallInfo fcinfo, - bool is_trigger, - HeapTuple procTup, char *key); + bool is_trigger, + HeapTuple procTup, char *key); static void PLy_procedure_compile(PLyProcedure *, const char *); static char *PLy_procedure_munge_source(const char *, const char *); @@ -238,7 +252,7 @@ static PyObject *PLyString_FromString(const char *); /* global data */ -static int PLy_first_call = 1; +static int PLy_first_call = 1; static volatile int PLy_call_level = 0; /* this gets modified in plpython_call_handler and PLy_elog. @@ -253,42 +267,42 @@ static PyObject *PLy_interp_safe_globals = NULL; static PyObject *PLy_importable_modules = NULL; static PyObject *PLy_procedure_cache = NULL; -char *PLy_importable_modules_list[] = { - "array", - "bisect", - "calendar", - "cmath", - "errno", - "marshal", - "math", - "md5", - "mpz", - "operator", - "pickle", - "random", - "re", - "sha", - "string", - "StringIO", - "time", - "whrandom", - "zlib" +char *PLy_importable_modules_list[] = { + "array", + "bisect", + "calendar", + "cmath", + "errno", + "marshal", + "math", + "md5", + "mpz", + "operator", + "pickle", + "random", + "re", + "sha", + "string", + "StringIO", + "time", + "whrandom", + "zlib" }; /* Python exceptions */ -PyObject *PLy_exc_error = NULL; -PyObject *PLy_exc_fatal = NULL; -PyObject *PLy_exc_spi_error = NULL; +PyObject *PLy_exc_error = NULL; +PyObject *PLy_exc_fatal = NULL; +PyObject *PLy_exc_spi_error = NULL; /* some globals for the python module */ static char PLy_plan_doc[] = { - "Store a PostgreSQL plan" + "Store a PostgreSQL plan" }; static char PLy_result_doc[] = { - "Results of a PostgreSQL query" + "Results of a PostgreSQL query" }; @@ -324,58 +338,62 @@ perm_fmgr_info(Oid functionId, FmgrInfo *finfo) Datum plpython_call_handler(PG_FUNCTION_ARGS) { - DECLARE_EXC(); - Datum retval; - bool is_trigger; - PLyProcedure *volatile proc = NULL; + DECLARE_EXC(); + Datum retval; + bool is_trigger; + PLyProcedure *volatile proc = NULL; - enter(); + enter(); - if (PLy_first_call) - PLy_init_all(); + if (PLy_first_call) + PLy_init_all(); - if (SPI_connect() != SPI_OK_CONNECT) - elog(ERROR, "plpython: Unable to connect to SPI manager"); + if (SPI_connect() != SPI_OK_CONNECT) + elog(ERROR, "plpython: Unable to connect to SPI manager"); - CALL_LEVEL_INC(); - is_trigger = CALLED_AS_TRIGGER(fcinfo); + CALL_LEVEL_INC(); + is_trigger = CALLED_AS_TRIGGER(fcinfo); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - CALL_LEVEL_DEC(); - if (PLy_call_level == 0) + SAVE_EXC(); + if (TRAP_EXC()) { - PLy_restart_in_progress = 0; - PyErr_Clear(); + RESTORE_EXC(); + CALL_LEVEL_DEC(); + if (PLy_call_level == 0) + { + PLy_restart_in_progress = 0; + PyErr_Clear(); + } + else + PLy_restart_in_progress += 1; + if (proc) + Py_DECREF(proc->me); + RERAISE_EXC(); } - else - PLy_restart_in_progress += 1; - if (proc) - { Py_DECREF(proc->me); } - RERAISE_EXC(); - } - /*elog(NOTICE, "PLy_restart_in_progress is %d", PLy_restart_in_progress);*/ + /* + * elog(NOTICE, "PLy_restart_in_progress is %d", + * PLy_restart_in_progress); + */ + + proc = PLy_procedure_get(fcinfo, is_trigger); - proc = PLy_procedure_get(fcinfo, is_trigger); + if (is_trigger) + { + HeapTuple trv = PLy_trigger_handler(fcinfo, proc); + + retval = PointerGetDatum(trv); + } + else + retval = PLy_function_handler(fcinfo, proc); - if (is_trigger) - { - HeapTuple trv = PLy_trigger_handler(fcinfo, proc); - retval = PointerGetDatum(trv); - } - else - retval = PLy_function_handler(fcinfo, proc); + CALL_LEVEL_DEC(); + RESTORE_EXC(); - CALL_LEVEL_DEC(); - RESTORE_EXC(); - - Py_DECREF(proc->me); - refc(proc->me); + Py_DECREF(proc->me); + refc(proc->me); - return retval; + return retval; } /* trigger and function sub handlers @@ -389,339 +407,355 @@ plpython_call_handler(PG_FUNCTION_ARGS) * to take no arguments and return an argument of type opaque. */ HeapTuple -PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure *proc) +PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) { - DECLARE_EXC(); - HeapTuple rv = NULL; - PyObject * volatile plargs = NULL; - PyObject * volatile plrv = NULL; + DECLARE_EXC(); + HeapTuple rv = NULL; + PyObject *volatile plargs = NULL; + PyObject *volatile plrv = NULL; - enter(); + enter(); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); - Py_XDECREF(plargs); - Py_XDECREF(plrv); + Py_XDECREF(plargs); + Py_XDECREF(plrv); - RERAISE_EXC(); - } + RERAISE_EXC(); + } - plargs = PLy_trigger_build_args(fcinfo, proc, &rv); - plrv = PLy_procedure_call(proc, "TD", plargs); + plargs = PLy_trigger_build_args(fcinfo, proc, &rv); + plrv = PLy_procedure_call(proc, "TD", plargs); - /* Disconnect from SPI manager - */ - if (SPI_finish() != SPI_OK_FINISH) - elog(ERROR, "plpython: SPI_finish failed"); + /* + * Disconnect from SPI manager + */ + if (SPI_finish() != SPI_OK_FINISH) + elog(ERROR, "plpython: SPI_finish failed"); - if (plrv == NULL) - elog(FATAL, "Aiieee, PLy_procedure_call returned NULL"); + if (plrv == NULL) + elog(FATAL, "Aiieee, PLy_procedure_call returned NULL"); - if (PLy_restart_in_progress) - elog(FATAL, "Aiieee, restart in progress not expected"); + if (PLy_restart_in_progress) + elog(FATAL, "Aiieee, restart in progress not expected"); - /* return of None means we're happy with the tuple - */ - if (plrv != Py_None) - { - char *srv; + /* + * return of None means we're happy with the tuple + */ + if (plrv != Py_None) + { + char *srv; - if (!PyString_Check(plrv)) - elog(ERROR, "plpython: Expected trigger to return None or a String"); + if (!PyString_Check(plrv)) + elog(ERROR, "plpython: Expected trigger to return None or a String"); - srv = PyString_AsString(plrv); - if (strcasecmp(srv, "SKIP") == 0) - rv = NULL; - else if (strcasecmp(srv, "MODIFY") == 0) - { - TriggerData *tdata = (TriggerData *) fcinfo->context; + srv = PyString_AsString(plrv); + if (strcasecmp(srv, "SKIP") == 0) + rv = NULL; + else if (strcasecmp(srv, "MODIFY") == 0) + { + TriggerData *tdata = (TriggerData *) fcinfo->context; - if ((TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) || - (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))) - { - rv = PLy_modify_tuple(proc, plargs, tdata, rv); - } - else - elog(NOTICE,"plpython: Ignoring modified tuple in DELETE trigger"); - } - else if (strcasecmp(srv, "OK")) - { - /* hmmm, perhaps they only read the pltcl page, not a surprising - * thing since i've written no documentation, so accept a - * belated OK - */ - elog(ERROR, "plpython: Expected return to be 'SKIP' or 'MODIFY'"); + if ((TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) || + (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))) + rv = PLy_modify_tuple(proc, plargs, tdata, rv); + else + elog(NOTICE, "plpython: Ignoring modified tuple in DELETE trigger"); + } + else if (strcasecmp(srv, "OK")) + { + /* + * hmmm, perhaps they only read the pltcl page, not a + * surprising thing since i've written no documentation, so + * accept a belated OK + */ + elog(ERROR, "plpython: Expected return to be 'SKIP' or 'MODIFY'"); + } } - } - Py_DECREF(plargs); - Py_DECREF(plrv); + Py_DECREF(plargs); + Py_DECREF(plrv); - RESTORE_EXC(); + RESTORE_EXC(); - return rv; + return rv; } HeapTuple -PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata, - HeapTuple otup) -{ - DECLARE_EXC(); - PyObject * volatile plntup; - PyObject * volatile plkeys; - PyObject * volatile platt; - PyObject * volatile plval; - PyObject * volatile plstr; - HeapTuple rtup; - int natts, i, j, attn, atti; - int * volatile modattrs; - Datum * volatile modvalues; - char *volatile modnulls; - TupleDesc tupdesc; - - plntup = plkeys = platt = plval = plstr = NULL; - modattrs = NULL; - modvalues = NULL; - modnulls = NULL; - - enter(); - - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - - Py_XDECREF(plntup); - Py_XDECREF(plkeys); - Py_XDECREF(platt); - Py_XDECREF(plval); - Py_XDECREF(plstr); - - if (modnulls) - pfree(modnulls); - if (modvalues) - pfree(modvalues); - if (modattrs) +PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, + HeapTuple otup) +{ + DECLARE_EXC(); + PyObject *volatile plntup; + PyObject *volatile plkeys; + PyObject *volatile platt; + PyObject *volatile plval; + PyObject *volatile plstr; + HeapTuple rtup; + int natts, + i, + j, + attn, + atti; + int *volatile modattrs; + Datum *volatile modvalues; + char *volatile modnulls; + TupleDesc tupdesc; + + plntup = plkeys = platt = plval = plstr = NULL; + modattrs = NULL; + modvalues = NULL; + modnulls = NULL; + + enter(); + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + + Py_XDECREF(plntup); + Py_XDECREF(plkeys); + Py_XDECREF(platt); + Py_XDECREF(plval); + Py_XDECREF(plstr); + + if (modnulls) + pfree(modnulls); + if (modvalues) + pfree(modvalues); + if (modattrs) + pfree(modattrs); + + RERAISE_EXC(); + } + + if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL) + elog(ERROR, "plpython: TD[\"new\"] deleted, unable to modify tuple"); + if (!PyDict_Check(plntup)) + elog(ERROR, "plpython: TD[\"new\"] is not a dictionary object"); + Py_INCREF(plntup); + + plkeys = PyDict_Keys(plntup); + natts = PyList_Size(plkeys); + + if (natts != proc->result.out.r.natts) + elog(ERROR, "plpython: TD[\"new\"] has an incorrect number of keys."); + + modattrs = palloc(natts * sizeof(int)); + modvalues = palloc(natts * sizeof(Datum)); + for (i = 0; i < natts; i++) + { + modattrs[i] = i + 1; + modvalues[i] = (Datum) NULL; + } + modnulls = palloc(natts + 1); + memset(modnulls, 'n', natts); + modnulls[natts] = '\0'; + + tupdesc = tdata->tg_relation->rd_att; + + for (j = 0; j < natts; j++) + { + char *src; + + platt = PyList_GetItem(plkeys, j); + if (!PyString_Check(platt)) + elog(ERROR, "plpython: attribute is not a string"); + attn = modattrs[j] = SPI_fnumber(tupdesc, PyString_AsString(platt)); + + if (attn == SPI_ERROR_NOATTRIBUTE) + elog(ERROR, "plpython: invalid attribute `%s' in tuple.", + PyString_AsString(platt)); + atti = attn - 1; + + plval = PyDict_GetItem(plntup, platt); + if (plval == NULL) + elog(FATAL, "plpython: interpreter is probably corrupted"); + + Py_INCREF(plval); + + if (plval != Py_None) + { + plstr = PyObject_Str(plval); + src = PyString_AsString(plstr); + + modvalues[j] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc, + CStringGetDatum(src), + ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem), + Int32GetDatum(tupdesc->attrs[j]->atttypmod)); + modnulls[j] = ' '; + + Py_DECREF(plstr); + plstr = NULL; + } + Py_DECREF(plval); + plval = NULL; + + } + rtup = SPI_modifytuple(tdata->tg_relation, otup, natts, modattrs, + modvalues, modnulls); + + /* + * FIXME -- these leak if not explicity pfree'd by other elog calls, + * no? + */ pfree(modattrs); + pfree(modvalues); + pfree(modnulls); + + if (rtup == NULL) + elog(ERROR, "plpython: SPI_modifytuple failed -- error %d", SPI_result); + + Py_DECREF(plntup); + Py_DECREF(plkeys); + + RESTORE_EXC(); - RERAISE_EXC(); - } - - if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL) - elog(ERROR, "plpython: TD[\"new\"] deleted, unable to modify tuple"); - if (!PyDict_Check(plntup)) - elog(ERROR, "plpython: TD[\"new\"] is not a dictionary object"); - Py_INCREF(plntup); - - plkeys = PyDict_Keys(plntup); - natts = PyList_Size(plkeys); - - if (natts != proc->result.out.r.natts) - elog(ERROR, "plpython: TD[\"new\"] has an incorrect number of keys."); - - modattrs = palloc(natts * sizeof(int)); - modvalues = palloc(natts * sizeof(Datum)); - for (i = 0; i < natts; i++) - { - modattrs[i] = i + 1; - modvalues[i] = (Datum) NULL; - } - modnulls = palloc(natts + 1); - memset(modnulls, 'n', natts); - modnulls[natts] = '\0'; - - tupdesc = tdata->tg_relation->rd_att; - - for (j = 0; j < natts; j++) - { - char *src; - - platt = PyList_GetItem(plkeys, j); - if (!PyString_Check(platt)) - elog(ERROR, "plpython: attribute is not a string"); - attn = modattrs[j] = SPI_fnumber(tupdesc, PyString_AsString(platt)); - - if (attn == SPI_ERROR_NOATTRIBUTE) - elog(ERROR, "plpython: invalid attribute `%s' in tuple.", - PyString_AsString(platt)); - atti = attn - 1; - - plval = PyDict_GetItem(plntup, platt); - if (plval == NULL) - elog(FATAL, "plpython: interpreter is probably corrupted"); - - Py_INCREF(plval); - - if (plval != Py_None) - { - plstr = PyObject_Str(plval); - src = PyString_AsString(plstr); - - modvalues[j] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc, - CStringGetDatum(src), - ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem), - Int32GetDatum(tupdesc->attrs[j]->atttypmod)); - modnulls[j] = ' '; - - Py_DECREF(plstr); - plstr = NULL; - } - Py_DECREF(plval); - plval = NULL; - - } - rtup = SPI_modifytuple(tdata->tg_relation, otup, natts, modattrs, - modvalues, modnulls); - - /* FIXME -- these leak if not explicity pfree'd by other elog calls, no? - */ - pfree(modattrs); - pfree(modvalues); - pfree(modnulls); - - if (rtup == NULL) - elog(ERROR, "plpython: SPI_modifytuple failed -- error %d", SPI_result); - - Py_DECREF(plntup); - Py_DECREF(plkeys); - - RESTORE_EXC(); - - return rtup; + return rtup; } PyObject * -PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *rv) -{ - DECLARE_EXC(); - TriggerData *tdata; - PyObject *pltname, *pltevent, *pltwhen, *pltlevel, *pltrelid; - PyObject *pltargs, *pytnew, *pytold; - PyObject * volatile pltdata = NULL; - char *stroid; - - enter(); - - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - - Py_XDECREF(pltdata); - - RERAISE_EXC(); - } - - tdata = (TriggerData *) fcinfo->context; - - pltdata = PyDict_New(); - if (!pltdata) - PLy_elog(ERROR, "Unable to build arguments for trigger procedure"); - - pltname = PyString_FromString(tdata->tg_trigger->tgname); - PyDict_SetItemString(pltdata, "name", pltname); - Py_DECREF(pltname); - - stroid = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(tdata->tg_relation->rd_id))); - pltrelid = PyString_FromString(stroid); - PyDict_SetItemString(pltdata, "relid", pltrelid); - Py_DECREF(pltrelid); - pfree(stroid); - - - - if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) - pltwhen = PyString_FromString("BEFORE"); - else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) - pltwhen = PyString_FromString("AFTER"); - else - pltwhen = PyString_FromString("UNKNOWN"); - PyDict_SetItemString(pltdata, "when", pltwhen); - Py_DECREF(pltwhen); - - if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event)) - pltlevel = PyString_FromString("ROW"); - else if (TRIGGER_FIRED_FOR_STATEMENT(tdata->tg_event)) - pltlevel = PyString_FromString("STATEMENT"); - else - pltlevel = PyString_FromString("UNKNOWN"); - PyDict_SetItemString(pltdata, "level", pltlevel); - Py_DECREF(pltlevel); - - if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) - { - pltevent = PyString_FromString("INSERT"); - PyDict_SetItemString(pltdata, "old", Py_None); - pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, - tdata->tg_relation->rd_att); - PyDict_SetItemString(pltdata, "new", pytnew); - Py_DECREF(pytnew); - *rv = tdata->tg_trigtuple; - } - else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event)) - { - pltevent = PyString_FromString("DELETE"); - PyDict_SetItemString(pltdata, "new", Py_None); - pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, - tdata->tg_relation->rd_att); - PyDict_SetItemString(pltdata, "old", pytold); - Py_DECREF(pytold); - *rv = tdata->tg_trigtuple; - } - else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)) - { - pltevent = PyString_FromString("UPDATE"); - pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_newtuple, - tdata->tg_relation->rd_att); - PyDict_SetItemString(pltdata, "new", pytnew); - Py_DECREF(pytnew); - pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, - tdata->tg_relation->rd_att); - PyDict_SetItemString(pltdata, "old", pytold); - Py_DECREF(pytold); - *rv = tdata->tg_newtuple; - } - else - { - pltevent = PyString_FromString("UNKNOWN"); - PyDict_SetItemString(pltdata, "old", Py_None); - PyDict_SetItemString(pltdata, "new", Py_None); - *rv = tdata->tg_trigtuple; - } - PyDict_SetItemString(pltdata, "event", pltevent); - Py_DECREF(pltevent); - - if (tdata->tg_trigger->tgnargs) - { - /* all strings... - */ - int i; - PyObject *pltarg; - - pltargs = PyList_New(tdata->tg_trigger->tgnargs); - for (i = 0; i < tdata->tg_trigger->tgnargs; i++) - { - pltarg = PyString_FromString(tdata->tg_trigger->tgargs[i]); - /* stolen, don't Py_DECREF - */ - PyList_SetItem(pltargs, i, pltarg); - } - } - else - { - Py_INCREF(Py_None); - pltargs = Py_None; - } - PyDict_SetItemString(pltdata, "args", pltargs); - Py_DECREF(pltargs); - - RESTORE_EXC(); - - return pltdata; +PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *rv) +{ + DECLARE_EXC(); + TriggerData *tdata; + PyObject *pltname, + *pltevent, + *pltwhen, + *pltlevel, + *pltrelid; + PyObject *pltargs, + *pytnew, + *pytold; + PyObject *volatile pltdata = NULL; + char *stroid; + + enter(); + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + + Py_XDECREF(pltdata); + + RERAISE_EXC(); + } + + tdata = (TriggerData *) fcinfo->context; + + pltdata = PyDict_New(); + if (!pltdata) + PLy_elog(ERROR, "Unable to build arguments for trigger procedure"); + + pltname = PyString_FromString(tdata->tg_trigger->tgname); + PyDict_SetItemString(pltdata, "name", pltname); + Py_DECREF(pltname); + + stroid = DatumGetCString(DirectFunctionCall1(oidout, + ObjectIdGetDatum(tdata->tg_relation->rd_id))); + pltrelid = PyString_FromString(stroid); + PyDict_SetItemString(pltdata, "relid", pltrelid); + Py_DECREF(pltrelid); + pfree(stroid); + + + + if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) + pltwhen = PyString_FromString("BEFORE"); + else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) + pltwhen = PyString_FromString("AFTER"); + else + pltwhen = PyString_FromString("UNKNOWN"); + PyDict_SetItemString(pltdata, "when", pltwhen); + Py_DECREF(pltwhen); + + if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event)) + pltlevel = PyString_FromString("ROW"); + else if (TRIGGER_FIRED_FOR_STATEMENT(tdata->tg_event)) + pltlevel = PyString_FromString("STATEMENT"); + else + pltlevel = PyString_FromString("UNKNOWN"); + PyDict_SetItemString(pltdata, "level", pltlevel); + Py_DECREF(pltlevel); + + if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) + { + pltevent = PyString_FromString("INSERT"); + PyDict_SetItemString(pltdata, "old", Py_None); + pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, + tdata->tg_relation->rd_att); + PyDict_SetItemString(pltdata, "new", pytnew); + Py_DECREF(pytnew); + *rv = tdata->tg_trigtuple; + } + else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event)) + { + pltevent = PyString_FromString("DELETE"); + PyDict_SetItemString(pltdata, "new", Py_None); + pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, + tdata->tg_relation->rd_att); + PyDict_SetItemString(pltdata, "old", pytold); + Py_DECREF(pytold); + *rv = tdata->tg_trigtuple; + } + else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)) + { + pltevent = PyString_FromString("UPDATE"); + pytnew = PLyDict_FromTuple(&(proc->result), tdata->tg_newtuple, + tdata->tg_relation->rd_att); + PyDict_SetItemString(pltdata, "new", pytnew); + Py_DECREF(pytnew); + pytold = PLyDict_FromTuple(&(proc->result), tdata->tg_trigtuple, + tdata->tg_relation->rd_att); + PyDict_SetItemString(pltdata, "old", pytold); + Py_DECREF(pytold); + *rv = tdata->tg_newtuple; + } + else + { + pltevent = PyString_FromString("UNKNOWN"); + PyDict_SetItemString(pltdata, "old", Py_None); + PyDict_SetItemString(pltdata, "new", Py_None); + *rv = tdata->tg_trigtuple; + } + PyDict_SetItemString(pltdata, "event", pltevent); + Py_DECREF(pltevent); + + if (tdata->tg_trigger->tgnargs) + { + /* + * all strings... + */ + int i; + PyObject *pltarg; + + pltargs = PyList_New(tdata->tg_trigger->tgnargs); + for (i = 0; i < tdata->tg_trigger->tgnargs; i++) + { + pltarg = PyString_FromString(tdata->tg_trigger->tgargs[i]); + + /* + * stolen, don't Py_DECREF + */ + PyList_SetItem(pltargs, i, pltarg); + } + } + else + { + Py_INCREF(Py_None); + pltargs = Py_None; + } + PyDict_SetItemString(pltdata, "args", pltargs); + Py_DECREF(pltargs); + + RESTORE_EXC(); + + return pltdata; } @@ -729,176 +763,182 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r /* function handler and friends */ Datum -PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure *proc) -{ - DECLARE_EXC(); - Datum rv; - PyObject * volatile plargs = NULL; - PyObject * volatile plrv = NULL; - PyObject * volatile plrv_so = NULL; - char *plrv_sc; - - enter(); - - /* - * setup to catch elog in while building function arguments, - * and DECREF the plargs if the function call fails - */ - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - - Py_XDECREF(plargs); - Py_XDECREF(plrv); - Py_XDECREF(plrv_so); - - RERAISE_EXC(); - } - - plargs = PLy_function_build_args(fcinfo, proc); - plrv = PLy_procedure_call(proc, "args", plargs); - - /* Disconnect from SPI manager and then create the return - * values datum (if the input function does a palloc for it - * this must not be allocated in the SPI memory context - * because SPI_finish would free it). - */ - if (SPI_finish() != SPI_OK_FINISH) - elog(ERROR, "plpython: SPI_finish failed"); - - if (plrv == NULL) - { - elog(FATAL, "Aiieee, PLy_procedure_call returned NULL"); -#if 0 - if (!PLy_restart_in_progress) - PLy_elog(ERROR, "plpython: Function \"%s\" failed.", proc->proname); +PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) +{ + DECLARE_EXC(); + Datum rv; + PyObject *volatile plargs = NULL; + PyObject *volatile plrv = NULL; + PyObject *volatile plrv_so = NULL; + char *plrv_sc; + + enter(); + + /* + * setup to catch elog in while building function arguments, and + * DECREF the plargs if the function call fails + */ + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + + Py_XDECREF(plargs); + Py_XDECREF(plrv); + Py_XDECREF(plrv_so); + + RERAISE_EXC(); + } + + plargs = PLy_function_build_args(fcinfo, proc); + plrv = PLy_procedure_call(proc, "args", plargs); + + /* + * Disconnect from SPI manager and then create the return values datum + * (if the input function does a palloc for it this must not be + * allocated in the SPI memory context because SPI_finish would free + * it). + */ + if (SPI_finish() != SPI_OK_FINISH) + elog(ERROR, "plpython: SPI_finish failed"); - /* FIXME is this dead code? i'm pretty sure it is for unnested - * calls, but not for nested calls - */ - RAISE_EXC(1); + if (plrv == NULL) + { + elog(FATAL, "Aiieee, PLy_procedure_call returned NULL"); +#if 0 + if (!PLy_restart_in_progress) + PLy_elog(ERROR, "plpython: Function \"%s\" failed.", proc->proname); + + /* + * FIXME is this dead code? i'm pretty sure it is for unnested + * calls, but not for nested calls + */ + RAISE_EXC(1); #endif - } - - /* convert the python PyObject to a postgresql Datum - * FIXME returning a NULL, ie PG_RETURN_NULL() blows the backend - * to small messy bits... it this a bug or expected? so just - * call with the string value of None for now - */ - - if (plrv == Py_None) - { - fcinfo->isnull = true; - rv = (Datum) NULL; - } - else - { - fcinfo->isnull = false; - plrv_so = PyObject_Str(plrv); - plrv_sc = PyString_AsString(plrv_so); - rv = FunctionCall3(&proc->result.out.d.typfunc, - PointerGetDatum(plrv_sc), - ObjectIdGetDatum(proc->result.out.d.typelem), - Int32GetDatum(-1)); - } - - RESTORE_EXC(); - - Py_XDECREF(plargs); - Py_DECREF(plrv); - Py_XDECREF(plrv_so); - - return rv; -} + } -PyObject * -PLy_procedure_call(PLyProcedure *proc, char *kargs, PyObject *vargs) -{ - PyObject *rv; - - enter(); + /* + * convert the python PyObject to a postgresql Datum FIXME returning a + * NULL, ie PG_RETURN_NULL() blows the backend to small messy bits... + * it this a bug or expected? so just call with the string value of + * None for now + */ + + if (plrv == Py_None) + { + fcinfo->isnull = true; + rv = (Datum) NULL; + } + else + { + fcinfo->isnull = false; + plrv_so = PyObject_Str(plrv); + plrv_sc = PyString_AsString(plrv_so); + rv = FunctionCall3(&proc->result.out.d.typfunc, + PointerGetDatum(plrv_sc), + ObjectIdGetDatum(proc->result.out.d.typelem), + Int32GetDatum(-1)); + } - PyDict_SetItemString(proc->globals, kargs, vargs); - rv = PyObject_CallFunction(proc->reval, "O", proc->code); + RESTORE_EXC(); - if ((rv == NULL) || (PyErr_Occurred())) - { - Py_XDECREF(rv); - if (!PLy_restart_in_progress) - PLy_elog(ERROR, "Call of function `%s' failed.", proc->proname); - RAISE_EXC(1); - } + Py_XDECREF(plargs); + Py_DECREF(plrv); + Py_XDECREF(plrv_so); - return rv; + return rv; } PyObject * -PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc) +PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs) { - DECLARE_EXC(); - PyObject * volatile arg = NULL; - PyObject * volatile args = NULL; - int i; + PyObject *rv; - enter(); + enter(); - /* FIXME -- if the setjmp setup is expensive, add the arg and - * args field to the procedure struct and cleanup at the - * start of the next call - */ - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - Py_XDECREF(arg); - Py_XDECREF(args); + PyDict_SetItemString(proc->globals, kargs, vargs); + rv = PyObject_CallFunction(proc->reval, "O", proc->code); - RERAISE_EXC(); - } - - args = PyList_New(proc->nargs); - for (i = 0; i < proc->nargs; i++) - { - if (proc->args[i].is_rel == 1) + if ((rv == NULL) || (PyErr_Occurred())) { - TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; - arg = PLyDict_FromTuple(&(proc->args[i]), slot->val, - slot->ttc_tupleDescriptor); + Py_XDECREF(rv); + if (!PLy_restart_in_progress) + PLy_elog(ERROR, "Call of function `%s' failed.", proc->proname); + RAISE_EXC(1); } - else + + return rv; +} + +PyObject * +PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc) +{ + DECLARE_EXC(); + PyObject *volatile arg = NULL; + PyObject *volatile args = NULL; + int i; + + enter(); + + /* + * FIXME -- if the setjmp setup is expensive, add the arg and args + * field to the procedure struct and cleanup at the start of the next + * call + */ + SAVE_EXC(); + if (TRAP_EXC()) { - if (!fcinfo->argnull[i]) - { - char *ct; - Datum dt; + RESTORE_EXC(); + Py_XDECREF(arg); + Py_XDECREF(args); - dt = FunctionCall3(&(proc->args[i].in.d.typfunc), - fcinfo->arg[i], - ObjectIdGetDatum(proc->args[i].in.d.typelem), - Int32GetDatum(-1)); - ct = DatumGetCString(dt); - arg = (proc->args[i].in.d.func)(ct); - pfree(ct); - } - else - arg = NULL; + RERAISE_EXC(); } - if (arg == NULL) + args = PyList_New(proc->nargs); + for (i = 0; i < proc->nargs; i++) { - Py_INCREF(Py_None); - arg = Py_None; - } + if (proc->args[i].is_rel == 1) + { + TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; - /* FIXME -- error check this - */ - PyList_SetItem(args, i, arg); - } + arg = PLyDict_FromTuple(&(proc->args[i]), slot->val, + slot->ttc_tupleDescriptor); + } + else + { + if (!fcinfo->argnull[i]) + { + char *ct; + Datum dt; + + dt = FunctionCall3(&(proc->args[i].in.d.typfunc), + fcinfo->arg[i], + ObjectIdGetDatum(proc->args[i].in.d.typelem), + Int32GetDatum(-1)); + ct = DatumGetCString(dt); + arg = (proc->args[i].in.d.func) (ct); + pfree(ct); + } + else + arg = NULL; + } - RESTORE_EXC(); + if (arg == NULL) + { + Py_INCREF(Py_None); + arg = Py_None; + } - return args; + /* + * FIXME -- error check this + */ + PyList_SetItem(args, i, arg); + } + + RESTORE_EXC(); + + return args; } @@ -907,532 +947,552 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc) static PLyProcedure * PLy_procedure_get(FunctionCallInfo fcinfo, bool is_trigger) { - Oid fn_oid; - HeapTuple procTup; - char key[128]; - PyObject *plproc; - PLyProcedure *proc = NULL; - int rv; - - enter(); - - fn_oid = fcinfo->flinfo->fn_oid; - procTup = SearchSysCache(PROCOID, - ObjectIdGetDatum(fn_oid), - 0, 0, 0); - if (!HeapTupleIsValid(procTup)) - elog(ERROR, "plpython: cache lookup for procedure %u failed", fn_oid); - - rv = snprintf(key, sizeof(key), "%u%s", - fn_oid, - is_trigger ? "_trigger" : ""); - if ((rv >= sizeof(key)) || (rv < 0)) - elog(FATAL, "plpython: Buffer overrun in %s:%d", __FILE__, __LINE__); - - plproc = PyDict_GetItemString(PLy_procedure_cache, key); - - if (plproc != NULL) - { - Py_INCREF(plproc); - if (!PyCObject_Check(plproc)) - elog(FATAL, "plpython: Expected a PyCObject, didn't get one"); - - mark(); - - proc = PyCObject_AsVoidPtr(plproc); - if (proc->me != plproc) - elog(FATAL, "plpython: Aiieee, proc->me != plproc"); - /* did we find an up-to-date cache entry? */ - if (proc->fn_xmin != procTup->t_data->t_xmin || - proc->fn_cmin != procTup->t_data->t_cmin) - { - Py_DECREF(plproc); - proc = NULL; - } - } - - if (proc == NULL) - proc = PLy_procedure_create(fcinfo, is_trigger, procTup, key); - - ReleaseSysCache(procTup); - - return proc; + Oid fn_oid; + HeapTuple procTup; + char key[128]; + PyObject *plproc; + PLyProcedure *proc = NULL; + int rv; + + enter(); + + fn_oid = fcinfo->flinfo->fn_oid; + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fn_oid), + 0, 0, 0); + if (!HeapTupleIsValid(procTup)) + elog(ERROR, "plpython: cache lookup for procedure %u failed", fn_oid); + + rv = snprintf(key, sizeof(key), "%u%s", + fn_oid, + is_trigger ? "_trigger" : ""); + if ((rv >= sizeof(key)) || (rv < 0)) + elog(FATAL, "plpython: Buffer overrun in %s:%d", __FILE__, __LINE__); + + plproc = PyDict_GetItemString(PLy_procedure_cache, key); + + if (plproc != NULL) + { + Py_INCREF(plproc); + if (!PyCObject_Check(plproc)) + elog(FATAL, "plpython: Expected a PyCObject, didn't get one"); + + mark(); + + proc = PyCObject_AsVoidPtr(plproc); + if (proc->me != plproc) + elog(FATAL, "plpython: Aiieee, proc->me != plproc"); + /* did we find an up-to-date cache entry? */ + if (proc->fn_xmin != procTup->t_data->t_xmin || + proc->fn_cmin != procTup->t_data->t_cmin) + { + Py_DECREF(plproc); + proc = NULL; + } + } + + if (proc == NULL) + proc = PLy_procedure_create(fcinfo, is_trigger, procTup, key); + + ReleaseSysCache(procTup); + + return proc; } static PLyProcedure * PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger, HeapTuple procTup, char *key) { - char procName[256]; - DECLARE_EXC(); - Form_pg_proc procStruct; - PLyProcedure *volatile proc; - char *volatile procSource = NULL; - Datum procDatum; - int i, rv; - - enter(); - - procStruct = (Form_pg_proc) GETSTRUCT(procTup); - - rv = snprintf(procName, sizeof(procName), - "__plpython_procedure_%s_%u%s", - NameStr(procStruct->proname), - fcinfo->flinfo->fn_oid, - is_trigger ? "_trigger" : ""); - if ((rv >= sizeof(procName)) || (rv < 0)) - elog(FATAL, "plpython: Procedure name would overrun buffer"); - - proc = PLy_malloc(sizeof(PLyProcedure)); - proc->proname = PLy_malloc(strlen(procName) + 1); - strcpy(proc->proname, procName); - proc->fn_xmin = procTup->t_data->t_xmin; - proc->fn_cmin = procTup->t_data->t_cmin; - PLy_typeinfo_init(&proc->result); - for (i = 0; i < FUNC_MAX_ARGS; i++) - PLy_typeinfo_init(&proc->args[i]); - proc->nargs = 0; - proc->code = proc->interp = proc->reval = proc->statics = NULL; - proc->globals = proc->me = NULL; - - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - PLy_procedure_delete(proc); - if (procSource) + char procName[256]; + + DECLARE_EXC(); + Form_pg_proc procStruct; + PLyProcedure *volatile proc; + char *volatile procSource = NULL; + Datum procDatum; + int i, + rv; + + enter(); + + procStruct = (Form_pg_proc) GETSTRUCT(procTup); + + rv = snprintf(procName, sizeof(procName), + "__plpython_procedure_%s_%u%s", + NameStr(procStruct->proname), + fcinfo->flinfo->fn_oid, + is_trigger ? "_trigger" : ""); + if ((rv >= sizeof(procName)) || (rv < 0)) + elog(FATAL, "plpython: Procedure name would overrun buffer"); + + proc = PLy_malloc(sizeof(PLyProcedure)); + proc->proname = PLy_malloc(strlen(procName) + 1); + strcpy(proc->proname, procName); + proc->fn_xmin = procTup->t_data->t_xmin; + proc->fn_cmin = procTup->t_data->t_cmin; + PLy_typeinfo_init(&proc->result); + for (i = 0; i < FUNC_MAX_ARGS; i++) + PLy_typeinfo_init(&proc->args[i]); + proc->nargs = 0; + proc->code = proc->interp = proc->reval = proc->statics = NULL; + proc->globals = proc->me = NULL; + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + PLy_procedure_delete(proc); + if (procSource) + pfree(procSource); + RERAISE_EXC(); + } + + /* + * get information required for output conversion of the return value, + * but only if this isn't a trigger. + */ + if (!is_trigger) + { + HeapTuple rvTypeTup; + Form_pg_type rvTypeStruct; + Datum rvDatum; + + rvDatum = ObjectIdGetDatum(procStruct->prorettype); + rvTypeTup = SearchSysCache(TYPEOID, rvDatum, 0, 0, 0); + if (!HeapTupleIsValid(rvTypeTup)) + elog(ERROR, "plpython: cache lookup for type \"%u\" failed", + procStruct->prorettype); + + rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup); + if (rvTypeStruct->typrelid == InvalidOid) + PLy_output_datum_func(&proc->result, rvTypeStruct); + else + elog(ERROR, "plpython: tuple return types not supported, yet"); + + ReleaseSysCache(rvTypeTup); + } + else + { + /* + * input/output conversion for trigger tuples. use the result + * TypeInfo variable to store the tuple conversion info. + */ + TriggerData *tdata = (TriggerData *) fcinfo->context; + + PLy_input_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); + PLy_output_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); + } + + /* + * now get information required for input conversion of the procedures + * arguments. + */ + proc->nargs = fcinfo->nargs; + for (i = 0; i < fcinfo->nargs; i++) + { + HeapTuple argTypeTup; + Form_pg_type argTypeStruct; + Datum argDatum; + + argDatum = ObjectIdGetDatum(procStruct->proargtypes[i]); + argTypeTup = SearchSysCache(TYPEOID, argDatum, 0, 0, 0); + if (!HeapTupleIsValid(argTypeTup)) + elog(ERROR, "plpython: cache lookup for type \"%u\" failed", + procStruct->proargtypes[i]); + argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup); + + if (argTypeStruct->typrelid == InvalidOid) + PLy_input_datum_func(&(proc->args[i]), argTypeStruct); + else + { + TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; + + PLy_input_tuple_funcs(&(proc->args[i]), + slot->ttc_tupleDescriptor); + } + + ReleaseSysCache(argTypeTup); + } + + + /* + * get the text of the function. + */ + procDatum = DirectFunctionCall1(textout, + PointerGetDatum(&procStruct->prosrc)); + procSource = DatumGetCString(procDatum); + + PLy_procedure_compile(proc, procSource); + pfree(procSource); - RERAISE_EXC(); - } - - /* get information required for output conversion of the return - * value, but only if this isn't a trigger. - */ - if (!is_trigger) - { - HeapTuple rvTypeTup; - Form_pg_type rvTypeStruct; - Datum rvDatum; - - rvDatum = ObjectIdGetDatum(procStruct->prorettype); - rvTypeTup = SearchSysCache(TYPEOID, rvDatum, 0, 0, 0); - if (!HeapTupleIsValid(rvTypeTup)) - elog(ERROR, "plpython: cache lookup for type \"%u\" failed", - procStruct->prorettype); - - rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup); - if (rvTypeStruct->typrelid == InvalidOid) - PLy_output_datum_func(&proc->result, rvTypeStruct); - else - elog(ERROR, "plpython: tuple return types not supported, yet"); - - ReleaseSysCache(rvTypeTup); - } - else - { - /* input/output conversion for trigger tuples. use the - * result TypeInfo variable to store the tuple conversion - * info. - */ - TriggerData *tdata = (TriggerData *) fcinfo->context; - PLy_input_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); - PLy_output_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); - } - - /* now get information required for input conversion of the - * procedures arguments. - */ - proc->nargs = fcinfo->nargs; - for (i = 0; i < fcinfo->nargs; i++) - { - HeapTuple argTypeTup; - Form_pg_type argTypeStruct; - Datum argDatum; - - argDatum = ObjectIdGetDatum(procStruct->proargtypes[i]); - argTypeTup = SearchSysCache(TYPEOID, argDatum, 0, 0, 0); - if (!HeapTupleIsValid(argTypeTup)) - elog(ERROR, "plpython: cache lookup for type \"%u\" failed", - procStruct->proargtypes[i]); - argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup); - - if (argTypeStruct->typrelid == InvalidOid) - PLy_input_datum_func(&(proc->args[i]), argTypeStruct); - else - { - TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; - PLy_input_tuple_funcs(&(proc->args[i]), - slot->ttc_tupleDescriptor); - } - - ReleaseSysCache(argTypeTup); - } - - - /* get the text of the function. - */ - procDatum = DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc)); - procSource = DatumGetCString(procDatum); - - PLy_procedure_compile(proc, procSource); - - pfree(procSource); - - proc->me = PyCObject_FromVoidPtr(proc, NULL); - PyDict_SetItemString(PLy_procedure_cache, key, proc->me); - - RESTORE_EXC(); - - return proc; + + proc->me = PyCObject_FromVoidPtr(proc, NULL); + PyDict_SetItemString(PLy_procedure_cache, key, proc->me); + + RESTORE_EXC(); + + return proc; } void -PLy_procedure_compile(PLyProcedure *proc, const char *src) -{ - PyObject *module, *crv = NULL; - char *msrc; - - enter(); - - /* get an instance of rexec.RExec for the function - */ - proc->interp = PyObject_CallMethod(PLy_interp_safe, "RExec", NULL); - if ((proc->interp == NULL) || (PyErr_Occurred ())) - PLy_elog(ERROR, "Unable to create rexec.RExec instance"); - - /* tweak the list of permitted modules - */ - PyObject_SetAttrString(proc->interp, "ok_builtin_modules", - PLy_importable_modules); - - proc->reval = PyObject_GetAttrString(proc->interp, "r_eval"); - if ((proc->reval == NULL) || (PyErr_Occurred ())) - PLy_elog(ERROR, "Unable to get method `r_eval' from rexec.RExec"); - - /* add a __main__ module to the function's interpreter - */ - module = PyObject_CallMethod (proc->interp, "add_module", "s", "__main__"); - if ((module == NULL) || (PyErr_Occurred ())) - PLy_elog(ERROR, "Unable to get module `__main__' from rexec.RExec"); - - /* add plpy module to the interpreters main dictionary - */ - proc->globals = PyModule_GetDict (module); - if ((proc->globals == NULL) || (PyErr_Occurred ())) - PLy_elog(ERROR, "Unable to get `__main__.__dict__' from rexec.RExec"); - - /* why the hell won't r_import or r_exec('import plpy') work? - */ - module = PyDict_GetItemString(PLy_interp_globals, "plpy"); - if ((module == NULL) || (PyErr_Occurred())) - PLy_elog(ERROR, "Unable to get `plpy'"); - Py_INCREF(module); - PyDict_SetItemString(proc->globals, "plpy", module); - - /* SD is private preserved data between calls - * GD is global data shared by all functions - */ - proc->statics = PyDict_New(); - PyDict_SetItemString(proc->globals, "SD", proc->statics); - PyDict_SetItemString(proc->globals, "GD", PLy_interp_safe_globals); - - /* insert the function code into the interpreter - */ - msrc = PLy_procedure_munge_source(proc->proname, src); - crv = PyObject_CallMethod(proc->interp, "r_exec", "s", msrc); - free(msrc); - - if ((crv != NULL) && (!PyErr_Occurred ())) - { - int clen; - char call[256]; - - Py_DECREF(crv); - - /* compile a call to the function - */ - clen = snprintf(call, sizeof(call), "%s()", proc->proname); - if ((clen < 0) || (clen >= sizeof(call))) - elog(ERROR, "plpython: string would overflow buffer."); - proc->code = Py_CompileString(call, "<string>", Py_eval_input); - if ((proc->code != NULL) && (!PyErr_Occurred ())) - return; - } - else - Py_XDECREF(crv); - - PLy_elog(ERROR, "Unable to compile function %s", proc->proname); +PLy_procedure_compile(PLyProcedure * proc, const char *src) +{ + PyObject *module, + *crv = NULL; + char *msrc; + + enter(); + + /* + * get an instance of rexec.RExec for the function + */ + proc->interp = PyObject_CallMethod(PLy_interp_safe, "RExec", NULL); + if ((proc->interp == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to create rexec.RExec instance"); + + /* + * tweak the list of permitted modules + */ + PyObject_SetAttrString(proc->interp, "ok_builtin_modules", + PLy_importable_modules); + + proc->reval = PyObject_GetAttrString(proc->interp, "r_eval"); + if ((proc->reval == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to get method `r_eval' from rexec.RExec"); + + /* + * add a __main__ module to the function's interpreter + */ + module = PyObject_CallMethod(proc->interp, "add_module", "s", "__main__"); + if ((module == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to get module `__main__' from rexec.RExec"); + + /* + * add plpy module to the interpreters main dictionary + */ + proc->globals = PyModule_GetDict(module); + if ((proc->globals == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to get `__main__.__dict__' from rexec.RExec"); + + /* + * why the hell won't r_import or r_exec('import plpy') work? + */ + module = PyDict_GetItemString(PLy_interp_globals, "plpy"); + if ((module == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to get `plpy'"); + Py_INCREF(module); + PyDict_SetItemString(proc->globals, "plpy", module); + + /* + * SD is private preserved data between calls GD is global data shared + * by all functions + */ + proc->statics = PyDict_New(); + PyDict_SetItemString(proc->globals, "SD", proc->statics); + PyDict_SetItemString(proc->globals, "GD", PLy_interp_safe_globals); + + /* + * insert the function code into the interpreter + */ + msrc = PLy_procedure_munge_source(proc->proname, src); + crv = PyObject_CallMethod(proc->interp, "r_exec", "s", msrc); + free(msrc); + + if ((crv != NULL) && (!PyErr_Occurred())) + { + int clen; + char call[256]; + + Py_DECREF(crv); + + /* + * compile a call to the function + */ + clen = snprintf(call, sizeof(call), "%s()", proc->proname); + if ((clen < 0) || (clen >= sizeof(call))) + elog(ERROR, "plpython: string would overflow buffer."); + proc->code = Py_CompileString(call, "<string>", Py_eval_input); + if ((proc->code != NULL) && (!PyErr_Occurred())) + return; + } + else + Py_XDECREF(crv); + + PLy_elog(ERROR, "Unable to compile function %s", proc->proname); } char * PLy_procedure_munge_source(const char *name, const char *src) { - char *mrc, *mp; - const char *sp; - size_t mlen, plen; + char *mrc, + *mp; + const char *sp; + size_t mlen, + plen; - enter(); + enter(); - /* room for function source and the def statement - */ - mlen = (strlen (src) * 2) + strlen(name) + 16; + /* + * room for function source and the def statement + */ + mlen = (strlen(src) * 2) + strlen(name) + 16; - mrc = PLy_malloc(mlen); - plen = snprintf(mrc, mlen, "def %s():\n\t", name); - if ((plen < 0) || (plen >= mlen)) - elog(FATAL, "Aiieee, impossible buffer overrun (or snprintf failure)"); + mrc = PLy_malloc(mlen); + plen = snprintf(mrc, mlen, "def %s():\n\t", name); + if ((plen < 0) || (plen >= mlen)) + elog(FATAL, "Aiieee, impossible buffer overrun (or snprintf failure)"); - sp = src; - mp = mrc + plen; + sp = src; + mp = mrc + plen; - while (*sp != '\0') - { - if (*sp == '\n') + while (*sp != '\0') { - *mp++ = *sp++; - *mp++ = '\t'; + if (*sp == '\n') + { + *mp++ = *sp++; + *mp++ = '\t'; + } + else + *mp++ = *sp++; } - else - *mp++ = *sp++; - } - *mp++ = '\n'; - *mp++ = '\n'; - *mp = '\0'; + *mp++ = '\n'; + *mp++ = '\n'; + *mp = '\0'; - if (mp > (mrc + mlen)) - elog(FATAL, "plpython: Buffer overrun in PLy_munge_source"); + if (mp > (mrc + mlen)) + elog(FATAL, "plpython: Buffer overrun in PLy_munge_source"); - return mrc; + return mrc; } void -PLy_procedure_delete(PLyProcedure *proc) -{ - int i; - - enter(); - - Py_XDECREF(proc->code); - Py_XDECREF(proc->interp); - Py_XDECREF(proc->reval); - Py_XDECREF(proc->statics); - Py_XDECREF(proc->globals); - Py_XDECREF(proc->me); - if (proc->proname) - PLy_free(proc->proname); - for (i = 0; i < proc->nargs; i++) - if (proc->args[i].is_rel == 1) - { - if (proc->args[i].in.r.atts) - PLy_free(proc->args[i].in.r.atts); - if (proc->args[i].out.r.atts) - PLy_free(proc->args[i].out.r.atts); - } +PLy_procedure_delete(PLyProcedure * proc) +{ + int i; + + enter(); + + Py_XDECREF(proc->code); + Py_XDECREF(proc->interp); + Py_XDECREF(proc->reval); + Py_XDECREF(proc->statics); + Py_XDECREF(proc->globals); + Py_XDECREF(proc->me); + if (proc->proname) + PLy_free(proc->proname); + for (i = 0; i < proc->nargs; i++) + if (proc->args[i].is_rel == 1) + { + if (proc->args[i].in.r.atts) + PLy_free(proc->args[i].in.r.atts); + if (proc->args[i].out.r.atts) + PLy_free(proc->args[i].out.r.atts); + } - leave(); + leave(); } /* conversion functions. remember output from python is * input to postgresql, and vis versa. */ void -PLy_input_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc) +PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) { - int i; - Datum datum; - - enter (); + int i; + Datum datum; - if (arg->is_rel == 0) - elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum"); + enter(); - arg->is_rel = 1; - arg->in.r.natts = desc->natts; - arg->in.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb)); + if (arg->is_rel == 0) + elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum"); - for (i = 0; i < desc->natts; i++) - { - HeapTuple typeTup; - Form_pg_type typeStruct; + arg->is_rel = 1; + arg->in.r.natts = desc->natts; + arg->in.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb)); - datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); - typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); - if (!HeapTupleIsValid(typeTup)) + for (i = 0; i < desc->natts; i++) { - char *attname = NameStr(desc->attrs[i]->attname); - elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed", - attname, desc->attrs[i]->atttypid); - } + HeapTuple typeTup; + Form_pg_type typeStruct; + + datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); + typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); + if (!HeapTupleIsValid(typeTup)) + { + char *attname = NameStr(desc->attrs[i]->attname); + + elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed", + attname, desc->attrs[i]->atttypid); + } - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = (Form_pg_type) GETSTRUCT(typeTup); - PLy_input_datum_func2(&(arg->in.r.atts[i]), typeStruct); + PLy_input_datum_func2(&(arg->in.r.atts[i]), typeStruct); - ReleaseSysCache(typeTup); - } + ReleaseSysCache(typeTup); + } } void -PLy_output_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc) +PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) { - int i; - Datum datum; - - enter (); + int i; + Datum datum; - if (arg->is_rel == 0) - elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum"); + enter(); - arg->is_rel = 1; - arg->out.r.natts = desc->natts; - arg->out.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb)); + if (arg->is_rel == 0) + elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Datum"); - for (i = 0; i < desc->natts; i++) - { - HeapTuple typeTup; - Form_pg_type typeStruct; + arg->is_rel = 1; + arg->out.r.natts = desc->natts; + arg->out.r.atts = malloc(desc->natts * sizeof(PLyDatumToOb)); - datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); - typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); - if (!HeapTupleIsValid(typeTup)) + for (i = 0; i < desc->natts; i++) { - char *attname = NameStr(desc->attrs[i]->attname); - elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed", - attname, desc->attrs[i]->atttypid); - } + HeapTuple typeTup; + Form_pg_type typeStruct; + + datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); + typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); + if (!HeapTupleIsValid(typeTup)) + { + char *attname = NameStr(desc->attrs[i]->attname); + + elog(ERROR, "plpython: Cache lookup for attribute `%s' type `%u' failed", + attname, desc->attrs[i]->atttypid); + } - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = (Form_pg_type) GETSTRUCT(typeTup); - PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct); + PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct); - ReleaseSysCache(typeTup); - } + ReleaseSysCache(typeTup); + } } void -PLy_output_datum_func(PLyTypeInfo *arg, Form_pg_type typeStruct) +PLy_output_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct) { - enter(); + enter(); - if (arg->is_rel == 1) - elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Tuple"); - arg->is_rel = 0; - PLy_output_datum_func2(&(arg->out.d), typeStruct); + if (arg->is_rel == 1) + elog(FATAL, "plpython: PLyTypeInfo struct is initialized for a Tuple"); + arg->is_rel = 0; + PLy_output_datum_func2(&(arg->out.d), typeStruct); } void -PLy_output_datum_func2(PLyObToDatum *arg, Form_pg_type typeStruct) +PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct) { - enter(); + enter(); - perm_fmgr_info(typeStruct->typinput, &arg->typfunc); - arg->typelem = typeStruct->typelem; - arg->typbyval = typeStruct->typbyval; + perm_fmgr_info(typeStruct->typinput, &arg->typfunc); + arg->typelem = typeStruct->typelem; + arg->typbyval = typeStruct->typbyval; } void -PLy_input_datum_func(PLyTypeInfo *arg, Form_pg_type typeStruct) +PLy_input_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct) { - enter(); + enter(); - if (arg->is_rel == 1) - elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple"); - arg->is_rel = 0; - PLy_input_datum_func2(&(arg->in.d), typeStruct); + if (arg->is_rel == 1) + elog(FATAL, "plpython: PLyTypeInfo struct is initialized for Tuple"); + arg->is_rel = 0; + PLy_input_datum_func2(&(arg->in.d), typeStruct); } void -PLy_input_datum_func2(PLyDatumToOb *arg, Form_pg_type typeStruct) -{ - char *type; - - perm_fmgr_info(typeStruct->typoutput, &arg->typfunc); - arg->typelem = typeStruct->typelem; - arg->typbyval = typeStruct->typbyval; - - /* hmmm, wierd. means this arg will always be converted - * to a python None - */ - if (!OidIsValid(typeStruct->typoutput)) - { - elog(ERROR, "plpython: (FIXME) typeStruct->typoutput is invalid"); - - arg->func = NULL; - return; - } - - type = NameStr(typeStruct->typname); - switch (type[0]) - { - case 'b': - { - if (strcasecmp("bool", type)) - { - arg->func = PLyBool_FromString; - return; - } - break; - } - case 'f': - { - if ((strncasecmp("float", type, 5) == 0) && - ((type[5] == '8') || (type[5] == '4'))) - { - arg->func = PLyFloat_FromString; - return; - } - break; - } - case 'i': - { - if ((strncasecmp("int", type, 3) == 0) && - ((type[3] == '4') || (type[3] == '2')) && - (type[4] == '\0')) - { - arg->func = PLyInt_FromString; - return; - } - else if ( strcasecmp("int8", type) == 0 ) - { - arg->func = PLyLong_FromString; - } - break; - } - case 'n': - { - if (strcasecmp("numeric", type) == 0) - { - arg->func = PLyFloat_FromString; - return; - } - break; - } - default: - break; - } - arg->func = PLyString_FromString; +PLy_input_datum_func2(PLyDatumToOb * arg, Form_pg_type typeStruct) +{ + char *type; + + perm_fmgr_info(typeStruct->typoutput, &arg->typfunc); + arg->typelem = typeStruct->typelem; + arg->typbyval = typeStruct->typbyval; + + /* + * hmmm, wierd. means this arg will always be converted to a python + * None + */ + if (!OidIsValid(typeStruct->typoutput)) + { + elog(ERROR, "plpython: (FIXME) typeStruct->typoutput is invalid"); + + arg->func = NULL; + return; + } + + type = NameStr(typeStruct->typname); + switch (type[0]) + { + case 'b': + { + if (strcasecmp("bool", type)) + { + arg->func = PLyBool_FromString; + return; + } + break; + } + case 'f': + { + if ((strncasecmp("float", type, 5) == 0) && + ((type[5] == '8') || (type[5] == '4'))) + { + arg->func = PLyFloat_FromString; + return; + } + break; + } + case 'i': + { + if ((strncasecmp("int", type, 3) == 0) && + ((type[3] == '4') || (type[3] == '2')) && + (type[4] == '\0')) + { + arg->func = PLyInt_FromString; + return; + } + else if (strcasecmp("int8", type) == 0) + arg->func = PLyLong_FromString; + break; + } + case 'n': + { + if (strcasecmp("numeric", type) == 0) + { + arg->func = PLyFloat_FromString; + return; + } + break; + } + default: + break; + } + arg->func = PLyString_FromString; } void -PLy_typeinfo_init(PLyTypeInfo *arg) +PLy_typeinfo_init(PLyTypeInfo * arg) { - arg->is_rel = -1; - arg->in.r.natts = arg->out.r.natts = 0; - arg->in.r.atts = NULL; - arg->out.r.atts = NULL; + arg->is_rel = -1; + arg->in.r.natts = arg->out.r.natts = 0; + arg->in.r.atts = NULL; + arg->out.r.atts = NULL; } void -PLy_typeinfo_dealloc(PLyTypeInfo *arg) +PLy_typeinfo_dealloc(PLyTypeInfo * arg) { - if (arg->is_rel == 1) - { - if (arg->in.r.atts) - PLy_free(arg->in.r.atts); - if (arg->out.r.atts) - PLy_free(arg->out.r.atts); - } + if (arg->is_rel == 1) + { + if (arg->in.r.atts) + PLy_free(arg->in.r.atts); + if (arg->out.r.atts) + PLy_free(arg->out.r.atts); + } } /* assumes that a bool is always returned as a 't' or 'f' @@ -1440,112 +1500,115 @@ PLy_typeinfo_dealloc(PLyTypeInfo *arg) PyObject * PLyBool_FromString(const char *src) { - enter(); + enter(); - if (src[0] == 't') - return PyInt_FromLong(1); - return PyInt_FromLong(0); + if (src[0] == 't') + return PyInt_FromLong(1); + return PyInt_FromLong(0); } PyObject * PLyFloat_FromString(const char *src) { - double v; - char *eptr; + double v; + char *eptr; + + enter(); - enter(); - - errno = 0; - v = strtod(src, &eptr); - if ((*eptr != '\0') || (errno)) - return NULL; - return PyFloat_FromDouble(v); + errno = 0; + v = strtod(src, &eptr); + if ((*eptr != '\0') || (errno)) + return NULL; + return PyFloat_FromDouble(v); } PyObject * PLyInt_FromString(const char *src) { - long v; - char *eptr; + long v; + char *eptr; - enter(); + enter(); - errno = 0; - v = strtol(src, &eptr, 0); - if ((*eptr != '\0') || (errno)) - return NULL; - return PyInt_FromLong(v); + errno = 0; + v = strtol(src, &eptr, 0); + if ((*eptr != '\0') || (errno)) + return NULL; + return PyInt_FromLong(v); } PyObject * PLyLong_FromString(const char *src) { - return PyLong_FromString((char *)src,NULL,0); + return PyLong_FromString((char *) src, NULL, 0); } PyObject * PLyString_FromString(const char *src) { - return PyString_FromString(src); + return PyString_FromString(src); } PyObject * -PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc) +PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc) { - DECLARE_EXC(); - PyObject *volatile dict; - int i; + DECLARE_EXC(); + PyObject *volatile dict; + int i; - enter(); + enter(); - if (info->is_rel != 1) - elog(FATAL, "plpython: PLyTypeInfo structure describes a datum."); + if (info->is_rel != 1) + elog(FATAL, "plpython: PLyTypeInfo structure describes a datum."); - dict = PyDict_New(); - if (dict == NULL) - PLy_elog(ERROR, "Unable to create tuple dictionary."); + dict = PyDict_New(); + if (dict == NULL) + PLy_elog(ERROR, "Unable to create tuple dictionary."); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - Py_DECREF(dict); - - RERAISE_EXC(); - } - - for (i = 0; i < info->in.r.natts; i++) - { - char *key, *vsrc; - Datum vattr, vdat; - bool is_null; - PyObject *value; + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + Py_DECREF(dict); - key = NameStr(desc->attrs[i]->attname); - vattr = heap_getattr(tuple, (i + 1), desc, &is_null); + RERAISE_EXC(); + } - if ((is_null) || (info->in.r.atts[i].func == NULL)) - PyDict_SetItemString(dict, key, Py_None); - else + for (i = 0; i < info->in.r.natts; i++) { - vdat = FunctionCall3(&info->in.r.atts[i].typfunc, - vattr, - ObjectIdGetDatum(info->in.r.atts[i].typelem), - Int32GetDatum(desc->attrs[i]->atttypmod)); - vsrc = DatumGetCString(vdat); - - /* no exceptions allowed - */ - value = info->in.r.atts[i].func (vsrc); - pfree(vsrc); - PyDict_SetItemString(dict, key, value); - Py_DECREF(value); + char *key, + *vsrc; + Datum vattr, + vdat; + bool is_null; + PyObject *value; + + key = NameStr(desc->attrs[i]->attname); + vattr = heap_getattr(tuple, (i + 1), desc, &is_null); + + if ((is_null) || (info->in.r.atts[i].func == NULL)) + PyDict_SetItemString(dict, key, Py_None); + else + { + vdat = FunctionCall3(&info->in.r.atts[i].typfunc, + vattr, + ObjectIdGetDatum(info->in.r.atts[i].typelem), + Int32GetDatum(desc->attrs[i]->atttypmod)); + vsrc = DatumGetCString(vdat); + + /* + * no exceptions allowed + */ + value = info->in.r.atts[i].func(vsrc); + pfree(vsrc); + PyDict_SetItemString(dict, key, value); + Py_DECREF(value); + } } - } - - RESTORE_EXC(); - return dict; + RESTORE_EXC(); + + return dict; } /* initialization, some python variables function declared here @@ -1572,11 +1635,11 @@ static PyObject *PLy_result_getattr(PyObject *, char *); static PyObject *PLy_result_fetch(PyObject *, PyObject *); static PyObject *PLy_result_nrows(PyObject *, PyObject *); static PyObject *PLy_result_status(PyObject *, PyObject *); -static int PLy_result_length(PyObject *); +static int PLy_result_length(PyObject *); static PyObject *PLy_result_item(PyObject *, int); static PyObject *PLy_result_slice(PyObject *, int, int); -static int PLy_result_ass_item(PyObject *, int, PyObject *); -static int PLy_result_ass_slice(PyObject *, int, int, PyObject *); +static int PLy_result_ass_item(PyObject *, int, PyObject *); +static int PLy_result_ass_slice(PyObject *, int, int, PyObject *); static PyObject *PLy_spi_prepare(PyObject *, PyObject *); @@ -1588,100 +1651,107 @@ static PyObject *PLy_spi_execute_fetch_result(SPITupleTable *, int, int); PyTypeObject PLy_PlanType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "PLyPlan", /*tp_name*/ - sizeof(PLyPlanObject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods - */ - (destructor) PLy_plan_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)PLy_plan_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ - PLy_plan_doc, /*tp_doc*/ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "PLyPlan", /* tp_name */ + sizeof(PLyPlanObject), /* tp_size */ + 0, /* tp_itemsize */ + + /* + * methods + */ + (destructor) PLy_plan_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) PLy_plan_getattr, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_xxx4 */ + PLy_plan_doc, /* tp_doc */ }; PyMethodDef PLy_plan_methods[] = { - { "status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL }, - { NULL, NULL, 0, NULL } + {"status", (PyCFunction) PLy_plan_status, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} }; PySequenceMethods PLy_result_as_sequence = { - (inquiry) PLy_result_length, /* sq_length */ - (binaryfunc) 0, /* sq_concat */ - (intargfunc) 0, /* sq_repeat */ - (intargfunc) PLy_result_item, /* sq_item */ - (intintargfunc) PLy_result_slice, /* sq_slice */ - (intobjargproc) PLy_result_ass_item, /* sq_ass_item */ - (intintobjargproc) PLy_result_ass_slice, /* sq_ass_slice */ + (inquiry) PLy_result_length,/* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (intargfunc) 0, /* sq_repeat */ + (intargfunc) PLy_result_item, /* sq_item */ + (intintargfunc) PLy_result_slice, /* sq_slice */ + (intobjargproc) PLy_result_ass_item, /* sq_ass_item */ + (intintobjargproc) PLy_result_ass_slice, /* sq_ass_slice */ }; PyTypeObject PLy_ResultType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "PLyResult", /*tp_name*/ - sizeof(PLyResultObject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods - */ - (destructor) PLy_result_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) PLy_result_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - &PLy_result_as_sequence, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ - PLy_result_doc, /*tp_doc*/ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "PLyResult", /* tp_name */ + sizeof(PLyResultObject), /* tp_size */ + 0, /* tp_itemsize */ + + /* + * methods + */ + (destructor) PLy_result_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) PLy_result_getattr, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &PLy_result_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_xxx4 */ + PLy_result_doc, /* tp_doc */ }; PyMethodDef PLy_result_methods[] = { - { "fetch", (PyCFunction) PLy_result_fetch, METH_VARARGS, NULL,}, - { "nrows", (PyCFunction) PLy_result_nrows, METH_VARARGS, NULL }, - { "status", (PyCFunction) PLy_result_status, METH_VARARGS, NULL }, - { NULL, NULL, 0, NULL } + {"fetch", (PyCFunction) PLy_result_fetch, METH_VARARGS, NULL,}, + {"nrows", (PyCFunction) PLy_result_nrows, METH_VARARGS, NULL}, + {"status", (PyCFunction) PLy_result_status, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} }; static PyMethodDef PLy_methods[] = { - /* logging methods - */ - { "debug", PLy_debug, METH_VARARGS, NULL }, - { "error", PLy_error, METH_VARARGS, NULL }, - { "fatal", PLy_fatal, METH_VARARGS, NULL }, - { "notice", PLy_notice, METH_VARARGS, NULL }, - - /* create a stored plan - */ - { "prepare", PLy_spi_prepare, METH_VARARGS, NULL }, - - /* execute a plan or query - */ - { "execute", PLy_spi_execute, METH_VARARGS, NULL }, - - { NULL, NULL, 0, NULL } + /* + * logging methods + */ + {"debug", PLy_debug, METH_VARARGS, NULL}, + {"error", PLy_error, METH_VARARGS, NULL}, + {"fatal", PLy_fatal, METH_VARARGS, NULL}, + {"notice", PLy_notice, METH_VARARGS, NULL}, + + /* + * create a stored plan + */ + {"prepare", PLy_spi_prepare, METH_VARARGS, NULL}, + + /* + * execute a plan or query + */ + {"execute", PLy_spi_execute, METH_VARARGS, NULL}, + + {NULL, NULL, 0, NULL} }; @@ -1690,72 +1760,72 @@ static PyMethodDef PLy_methods[] = { PyObject * PLy_plan_new(void) { - PLyPlanObject *ob; - - enter(); + PLyPlanObject *ob; - if ((ob = PyObject_NEW(PLyPlanObject, &PLy_PlanType)) == NULL) - return NULL; + enter(); - ob->plan = NULL; - ob->nargs = 0; - ob->types = NULL; - ob->args = NULL; + if ((ob = PyObject_NEW(PLyPlanObject, &PLy_PlanType)) == NULL) + return NULL; - return (PyObject *) ob; + ob->plan = NULL; + ob->nargs = 0; + ob->types = NULL; + ob->args = NULL; + + return (PyObject *) ob; } void -PLy_plan_dealloc(PyObject *arg) +PLy_plan_dealloc(PyObject * arg) { - PLyPlanObject *ob = (PLyPlanObject *) arg; + PLyPlanObject *ob = (PLyPlanObject *) arg; - enter(); + enter(); - if (ob->plan) - { - /* free the plan... - * pfree(ob->plan); - * - * FIXME -- leaks saved plan on object destruction. can - * this be avoided? - */ - } - if (ob->types) - PLy_free(ob->types); - if (ob->args) - { - int i; + if (ob->plan) + { + /* + * free the plan... pfree(ob->plan); + * + * FIXME -- leaks saved plan on object destruction. can this be + * avoided? + */ + } + if (ob->types) + PLy_free(ob->types); + if (ob->args) + { + int i; - for (i = 0; i < ob->nargs; i++) - PLy_typeinfo_dealloc(&ob->args[i]); - PLy_free(ob->args); - } + for (i = 0; i < ob->nargs; i++) + PLy_typeinfo_dealloc(&ob->args[i]); + PLy_free(ob->args); + } - PyMem_DEL(arg); + PyMem_DEL(arg); - leave(); + leave(); } PyObject * -PLy_plan_getattr(PyObject *self, char *name) +PLy_plan_getattr(PyObject * self, char *name) { - return Py_FindMethod(PLy_plan_methods, self, name); + return Py_FindMethod(PLy_plan_methods, self, name); } PyObject * -PLy_plan_status(PyObject *self, PyObject *args) +PLy_plan_status(PyObject * self, PyObject * args) { - if (PyArg_ParseTuple(args, "")) - { - Py_INCREF(Py_True); - return Py_True; - /* return PyInt_FromLong(self->status); */ - } - PyErr_SetString(PLy_exc_error, "plan.status() takes no arguments"); - return NULL; + if (PyArg_ParseTuple(args, "")) + { + Py_INCREF(Py_True); + return Py_True; + /* return PyInt_FromLong(self->status); */ + } + PyErr_SetString(PLy_exc_error, "plan.status() takes no arguments"); + return NULL; } @@ -1766,626 +1836,649 @@ PLy_plan_status(PyObject *self, PyObject *args) static PyObject * PLy_result_new(void) { - PLyResultObject *ob; - - enter(); + PLyResultObject *ob; + + enter(); - if ((ob = PyObject_NEW(PLyResultObject, &PLy_ResultType)) == NULL) - return NULL; + if ((ob = PyObject_NEW(PLyResultObject, &PLy_ResultType)) == NULL) + return NULL; - /* ob->tuples = NULL; */ + /* ob->tuples = NULL; */ - Py_INCREF(Py_None); - ob->status = Py_None; - ob->nrows = PyInt_FromLong(-1); - ob->rows = PyList_New(0); + Py_INCREF(Py_None); + ob->status = Py_None; + ob->nrows = PyInt_FromLong(-1); + ob->rows = PyList_New(0); - return (PyObject *) ob; + return (PyObject *) ob; } static void -PLy_result_dealloc(PyObject *arg) +PLy_result_dealloc(PyObject * arg) { - PLyResultObject *ob = (PLyResultObject *) arg; + PLyResultObject *ob = (PLyResultObject *) arg; - enter(); + enter(); - Py_XDECREF(ob->nrows); - Py_XDECREF(ob->rows); - Py_XDECREF(ob->status); + Py_XDECREF(ob->nrows); + Py_XDECREF(ob->rows); + Py_XDECREF(ob->status); - PyMem_DEL(ob); + PyMem_DEL(ob); } static PyObject * -PLy_result_getattr(PyObject *self, char *attr) +PLy_result_getattr(PyObject * self, char *attr) { - return NULL; + return NULL; } static PyObject * -PLy_result_fetch(PyObject *self, PyObject *args) +PLy_result_fetch(PyObject * self, PyObject * args) { - return NULL; + return NULL; } static PyObject * -PLy_result_nrows(PyObject *self, PyObject *args) +PLy_result_nrows(PyObject * self, PyObject * args) { - PLyResultObject *ob = (PLyResultObject *) self; - Py_INCREF(ob->nrows); - return ob->nrows; + PLyResultObject *ob = (PLyResultObject *) self; + + Py_INCREF(ob->nrows); + return ob->nrows; } static PyObject * -PLy_result_status(PyObject *self, PyObject *args) +PLy_result_status(PyObject * self, PyObject * args) { - PLyResultObject *ob = (PLyResultObject *) self; - Py_INCREF(ob->status); - return ob->status; + PLyResultObject *ob = (PLyResultObject *) self; + + Py_INCREF(ob->status); + return ob->status; } int -PLy_result_length(PyObject *arg) +PLy_result_length(PyObject * arg) { - PLyResultObject *ob = (PLyResultObject *) arg; - return PyList_Size(ob->rows); + PLyResultObject *ob = (PLyResultObject *) arg; + + return PyList_Size(ob->rows); } PyObject * -PLy_result_item(PyObject *arg, int idx) +PLy_result_item(PyObject * arg, int idx) { - PyObject *rv; - PLyResultObject *ob = (PLyResultObject *) arg; + PyObject *rv; + PLyResultObject *ob = (PLyResultObject *) arg; - rv = PyList_GetItem(ob->rows, idx); - if (rv != NULL) - Py_INCREF(rv); - return rv; + rv = PyList_GetItem(ob->rows, idx); + if (rv != NULL) + Py_INCREF(rv); + return rv; } int -PLy_result_ass_item(PyObject *arg, int idx, PyObject *item) +PLy_result_ass_item(PyObject * arg, int idx, PyObject * item) { - int rv; - PLyResultObject *ob = (PLyResultObject *) arg; + int rv; + PLyResultObject *ob = (PLyResultObject *) arg; - Py_INCREF(item); - rv = PyList_SetItem(ob->rows, idx, item); - return rv; + Py_INCREF(item); + rv = PyList_SetItem(ob->rows, idx, item); + return rv; } PyObject * -PLy_result_slice(PyObject *arg, int lidx, int hidx) +PLy_result_slice(PyObject * arg, int lidx, int hidx) { - PyObject *rv; - PLyResultObject *ob = (PLyResultObject *) arg; - - rv = PyList_GetSlice(ob->rows, lidx, hidx); - if (rv == NULL) - return NULL; - Py_INCREF(rv); - return rv; + PyObject *rv; + PLyResultObject *ob = (PLyResultObject *) arg; + + rv = PyList_GetSlice(ob->rows, lidx, hidx); + if (rv == NULL) + return NULL; + Py_INCREF(rv); + return rv; } int -PLy_result_ass_slice(PyObject *arg, int lidx, int hidx, PyObject *slice) +PLy_result_ass_slice(PyObject * arg, int lidx, int hidx, PyObject * slice) { - int rv; - PLyResultObject *ob = (PLyResultObject *) arg; - - rv = PyList_SetSlice(ob->rows, lidx, hidx, slice); - return rv; + int rv; + PLyResultObject *ob = (PLyResultObject *) arg; + + rv = PyList_SetSlice(ob->rows, lidx, hidx, slice); + return rv; } /* SPI interface */ PyObject * -PLy_spi_prepare(PyObject *self, PyObject *args) -{ - DECLARE_EXC(); - PLyPlanObject *plan; - PyObject *list = NULL; - PyObject * volatile optr = NULL; - char *query; - - enter(); - - if (!PyArg_ParseTuple(args, "s|O", &query, &list)) - { - PyErr_SetString(PLy_exc_spi_error, - "Invalid arguments for plpy.prepare()"); - return NULL; - } - - if ((list) && (!PySequence_Check(list))) - { - PyErr_SetString(PLy_exc_spi_error, - "Second argument in plpy.prepare() must be a sequence"); - return NULL; - } - - - if ((plan = (PLyPlanObject *) PLy_plan_new()) == NULL) - return NULL; - - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - Py_DECREF(plan); - Py_XDECREF(optr); - if (!PyErr_Occurred ()) - PyErr_SetString(PLy_exc_spi_error, - "Unknown error in PLy_spi_prepare."); - return NULL; - } - - if (list != NULL) - { - int nargs, i; - - - nargs = PySequence_Length(list); - if (nargs > 0) - { - plan->nargs = nargs; - plan->types = PLy_malloc(sizeof(Oid) * nargs); - plan->values = PLy_malloc(sizeof(Datum) * nargs); - plan->args = PLy_malloc(sizeof(PLyTypeInfo) * nargs); - - /* the other loop might throw an exception, if PLyTypeInfo - * member isn't properly initialized the Py_DECREF(plan) - * will go boom - */ - for (i = 0; i < nargs; i++) - { - PLy_typeinfo_init(&plan->args[i]); - plan->values[i] = (Datum) NULL; - } - - for (i = 0; i < nargs; i++) - { - char *sptr; - HeapTuple typeTup; - Form_pg_type typeStruct; - - optr = PySequence_GetItem(list, i); - if (!PyString_Check(optr)) - { - PyErr_SetString(PLy_exc_spi_error, - "Type names must be strings."); - RAISE_EXC(1); - } - sptr = PyString_AsString(optr); - typeTup = SearchSysCache(TYPENAME, PointerGetDatum(sptr), - 0, 0, 0); - if (!HeapTupleIsValid(typeTup)) - { - PLy_exception_set(PLy_exc_spi_error, - "Cache lookup for type `%s' failed.", - sptr); - RAISE_EXC(1); - } +PLy_spi_prepare(PyObject * self, PyObject * args) +{ + DECLARE_EXC(); + PLyPlanObject *plan; + PyObject *list = NULL; + PyObject *volatile optr = NULL; + char *query; - Py_DECREF(optr); - optr = NULL; /* this is important */ + enter(); - plan->types[i] = typeTup->t_data->t_oid; - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); - if (typeStruct->typrelid == InvalidOid) - PLy_output_datum_func(&plan->args[i], typeStruct); - else + if (!PyArg_ParseTuple(args, "s|O", &query, &list)) + { + PyErr_SetString(PLy_exc_spi_error, + "Invalid arguments for plpy.prepare()"); + return NULL; + } + + if ((list) && (!PySequence_Check(list))) + { + PyErr_SetString(PLy_exc_spi_error, + "Second argument in plpy.prepare() must be a sequence"); + return NULL; + } + + + if ((plan = (PLyPlanObject *) PLy_plan_new()) == NULL) + return NULL; + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + Py_DECREF(plan); + Py_XDECREF(optr); + if (!PyErr_Occurred()) + PyErr_SetString(PLy_exc_spi_error, + "Unknown error in PLy_spi_prepare."); + return NULL; + } + + if (list != NULL) + { + int nargs, + i; + + + nargs = PySequence_Length(list); + if (nargs > 0) { - PyErr_SetString(PLy_exc_spi_error, - "tuples not handled in plpy.prepare, yet."); - RAISE_EXC(1); + plan->nargs = nargs; + plan->types = PLy_malloc(sizeof(Oid) * nargs); + plan->values = PLy_malloc(sizeof(Datum) * nargs); + plan->args = PLy_malloc(sizeof(PLyTypeInfo) * nargs); + + /* + * the other loop might throw an exception, if PLyTypeInfo + * member isn't properly initialized the Py_DECREF(plan) will + * go boom + */ + for (i = 0; i < nargs; i++) + { + PLy_typeinfo_init(&plan->args[i]); + plan->values[i] = (Datum) NULL; + } + + for (i = 0; i < nargs; i++) + { + char *sptr; + HeapTuple typeTup; + Form_pg_type typeStruct; + + optr = PySequence_GetItem(list, i); + if (!PyString_Check(optr)) + { + PyErr_SetString(PLy_exc_spi_error, + "Type names must be strings."); + RAISE_EXC(1); + } + sptr = PyString_AsString(optr); + typeTup = SearchSysCache(TYPENAME, PointerGetDatum(sptr), + 0, 0, 0); + if (!HeapTupleIsValid(typeTup)) + { + PLy_exception_set(PLy_exc_spi_error, + "Cache lookup for type `%s' failed.", + sptr); + RAISE_EXC(1); + } + + Py_DECREF(optr); + optr = NULL; /* this is important */ + + plan->types[i] = typeTup->t_data->t_oid; + typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + if (typeStruct->typrelid == InvalidOid) + PLy_output_datum_func(&plan->args[i], typeStruct); + else + { + PyErr_SetString(PLy_exc_spi_error, + "tuples not handled in plpy.prepare, yet."); + RAISE_EXC(1); + } + ReleaseSysCache(typeTup); + } } - ReleaseSysCache(typeTup); - } } - } - plan->plan = SPI_prepare(query, plan->nargs, plan->types); - if (plan->plan == NULL) - { - PLy_exception_set(PLy_exc_spi_error, - "Unable to prepare plan. SPI_prepare failed -- %s.", - PLy_spi_error_string(SPI_result)); - RAISE_EXC(1); - } + plan->plan = SPI_prepare(query, plan->nargs, plan->types); + if (plan->plan == NULL) + { + PLy_exception_set(PLy_exc_spi_error, + "Unable to prepare plan. SPI_prepare failed -- %s.", + PLy_spi_error_string(SPI_result)); + RAISE_EXC(1); + } - plan->plan = SPI_saveplan(plan->plan); - if (plan->plan == NULL) - { - PLy_exception_set(PLy_exc_spi_error, - "Unable to save plan. SPI_saveplan failed -- %s.", - PLy_spi_error_string(SPI_result)); - RAISE_EXC(1); - } + plan->plan = SPI_saveplan(plan->plan); + if (plan->plan == NULL) + { + PLy_exception_set(PLy_exc_spi_error, + "Unable to save plan. SPI_saveplan failed -- %s.", + PLy_spi_error_string(SPI_result)); + RAISE_EXC(1); + } - RESTORE_EXC(); + RESTORE_EXC(); - return (PyObject *) plan; + return (PyObject *) plan; } /* execute(query="select * from foo", limit=5) * execute(plan=plan, values=(foo, bar), limit=5) */ PyObject * -PLy_spi_execute(PyObject *self, PyObject *args) +PLy_spi_execute(PyObject * self, PyObject * args) { - char *query; - PyObject *plan; - PyObject *list = NULL; - int limit = 0; + char *query; + PyObject *plan; + PyObject *list = NULL; + int limit = 0; - enter(); + enter(); #if 0 - /* there should - hahaha - be an python exception set so just - * return NULL. FIXME -- is this needed? - */ - if (PLy_restart_in_progress) - return NULL; + + /* + * there should - hahaha - be an python exception set so just return + * NULL. FIXME -- is this needed? + */ + if (PLy_restart_in_progress) + return NULL; #endif - if (PyArg_ParseTuple(args, "s|i", &query, &limit)) - return PLy_spi_execute_query(query, limit); + if (PyArg_ParseTuple(args, "s|i", &query, &limit)) + return PLy_spi_execute_query(query, limit); - PyErr_Clear(); + PyErr_Clear(); + + if ((PyArg_ParseTuple(args, "O|Oi", &plan, &list, &limit)) && + (is_PLyPlanObject(plan))) + { + PyObject *rv = PLy_spi_execute_plan(plan, list, limit); - if ((PyArg_ParseTuple(args, "O|Oi", &plan, &list, &limit)) && - (is_PLyPlanObject(plan))) - { - PyObject *rv = PLy_spi_execute_plan(plan, list, limit); - return rv; - } + return rv; + } - PyErr_SetString(PLy_exc_error, "Expected a query or plan."); - return NULL; + PyErr_SetString(PLy_exc_error, "Expected a query or plan."); + return NULL; } PyObject * -PLy_spi_execute_plan(PyObject *ob, PyObject *list, int limit) +PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit) { - DECLARE_EXC(); - volatile int nargs; - int i, rv; - PLyPlanObject *plan; + DECLARE_EXC(); + volatile int nargs; + int i, + rv; + PLyPlanObject *plan; - enter(); + enter(); - if (list != NULL) - { - if ((!PySequence_Check(list)) || (PyString_Check(list))) + if (list != NULL) { - char *msg = "plpy.execute() takes a sequence as its second argument"; - PyErr_SetString(PLy_exc_spi_error, msg); - return NULL; - } - nargs = PySequence_Length(list); - } - else - nargs = 0; + if ((!PySequence_Check(list)) || (PyString_Check(list))) + { + char *msg = "plpy.execute() takes a sequence as its second argument"; - plan = (PLyPlanObject *) ob; + PyErr_SetString(PLy_exc_spi_error, msg); + return NULL; + } + nargs = PySequence_Length(list); + } + else + nargs = 0; - if (nargs != plan->nargs) - { - char *sv; + plan = (PLyPlanObject *) ob; - PyObject *so = PyObject_Str(list); - sv = PyString_AsString(so); - PLy_exception_set(PLy_exc_spi_error, - "Expected sequence of %d arguments, got %d. %s", - plan->nargs, nargs, sv); - Py_DECREF(so); + if (nargs != plan->nargs) + { + char *sv; - return NULL; - } + PyObject *so = PyObject_Str(list); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); + sv = PyString_AsString(so); + PLy_exception_set(PLy_exc_spi_error, + "Expected sequence of %d arguments, got %d. %s", + plan->nargs, nargs, sv); + Py_DECREF(so); - /* cleanup plan->values array - */ - for (i = 0; i < nargs; i++) - { - if (!plan->args[i].out.d.typbyval && - (plan->values[i] != (Datum) NULL)) - { - pfree(DatumGetPointer(plan->values[i])); - plan->values[i] = (Datum) NULL; - } + return NULL; } - if (!PyErr_Occurred()) - PyErr_SetString(PLy_exc_error, - "Unknown error in PLy_spi_execute_plan"); - return NULL; - } - - if (nargs) - { - for (i = 0; i < nargs; i++) + SAVE_EXC(); + if (TRAP_EXC()) { - PyObject *elem, *so; - char *sv; + RESTORE_EXC(); - elem = PySequence_GetItem(list, i); - so = PyObject_Str(elem); - sv = PyString_AsString(so); + /* + * cleanup plan->values array + */ + for (i = 0; i < nargs; i++) + { + if (!plan->args[i].out.d.typbyval && + (plan->values[i] != (Datum) NULL)) + { + pfree(DatumGetPointer(plan->values[i])); + plan->values[i] = (Datum) NULL; + } + } - /* FIXME -- if this can elog, we have leak - */ - plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc), - CStringGetDatum(sv), - ObjectIdGetDatum(plan->args[i].out.d.typelem), - Int32GetDatum(-1)); + if (!PyErr_Occurred()) + PyErr_SetString(PLy_exc_error, + "Unknown error in PLy_spi_execute_plan"); + return NULL; + } - Py_DECREF(so); - Py_DECREF(elem); + if (nargs) + { + for (i = 0; i < nargs; i++) + { + PyObject *elem, + *so; + char *sv; + + elem = PySequence_GetItem(list, i); + so = PyObject_Str(elem); + sv = PyString_AsString(so); + + /* + * FIXME -- if this can elog, we have leak + */ + plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc), + CStringGetDatum(sv), + ObjectIdGetDatum(plan->args[i].out.d.typelem), + Int32GetDatum(-1)); + + Py_DECREF(so); + Py_DECREF(elem); + } } - } - rv = SPI_execp(plan->plan, plan->values, NULL, limit); - RESTORE_EXC(); + rv = SPI_execp(plan->plan, plan->values, NULL, limit); + RESTORE_EXC(); - for (i = 0; i < nargs; i++) - { - if (!plan->args[i].out.d.typbyval && - (plan->values[i] != (Datum) NULL)) + for (i = 0; i < nargs; i++) { - pfree(DatumGetPointer(plan->values[i])); - plan->values[i] = (Datum) NULL; + if (!plan->args[i].out.d.typbyval && + (plan->values[i] != (Datum) NULL)) + { + pfree(DatumGetPointer(plan->values[i])); + plan->values[i] = (Datum) NULL; + } } - } - if (rv < 0) - { - PLy_exception_set(PLy_exc_spi_error, - "Unable to execute plan. SPI_execp failed -- %s", - PLy_spi_error_string(rv)); - return NULL; - } + if (rv < 0) + { + PLy_exception_set(PLy_exc_spi_error, + "Unable to execute plan. SPI_execp failed -- %s", + PLy_spi_error_string(rv)); + return NULL; + } - return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv); + return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv); } PyObject * PLy_spi_execute_query(char *query, int limit) { - DECLARE_EXC(); - int rv; + DECLARE_EXC(); + int rv; + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); + if ((!PLy_restart_in_progress) && (!PyErr_Occurred())) + PyErr_SetString(PLy_exc_spi_error, + "Unknown error in PLy_spi_execute_query."); + return NULL; + } - if ((!PLy_restart_in_progress) && (!PyErr_Occurred())) - PyErr_SetString(PLy_exc_spi_error, - "Unknown error in PLy_spi_execute_query."); - return NULL; - } - - rv = SPI_exec(query, limit); - RESTORE_EXC(); + rv = SPI_exec(query, limit); + RESTORE_EXC(); - if (rv < 0) - { - PLy_exception_set(PLy_exc_spi_error, - "Unable to execute query. SPI_exec failed -- %s", - PLy_spi_error_string(rv)); - return NULL; - } + if (rv < 0) + { + PLy_exception_set(PLy_exc_spi_error, + "Unable to execute query. SPI_exec failed -- %s", + PLy_spi_error_string(rv)); + return NULL; + } - return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv); + return PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv); } PyObject * PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status) { - PLyResultObject *result; - - enter(); - - result = (PLyResultObject *) PLy_result_new(); - Py_DECREF(result->status); - result->status = PyInt_FromLong(status); + PLyResultObject *result; - if (status == SPI_OK_UTILITY) - { - Py_DECREF(result->nrows); - result->nrows = PyInt_FromLong(0); - } - else if (status != SPI_OK_SELECT) - { - Py_DECREF(result->nrows); - result->nrows = PyInt_FromLong(rows); - } - else - { - DECLARE_EXC(); - PLyTypeInfo args; - int i; + enter(); - PLy_typeinfo_init(&args); - Py_DECREF(result->nrows); - result->nrows = PyInt_FromLong(rows); + result = (PLyResultObject *) PLy_result_new(); + Py_DECREF(result->status); + result->status = PyInt_FromLong(status); - SAVE_EXC(); - if (TRAP_EXC()) + if (status == SPI_OK_UTILITY) { - RESTORE_EXC(); - - if (!PyErr_Occurred()) - PyErr_SetString(PLy_exc_error, - "Unknown error in PLy_spi_execute_fetch_result"); - Py_DECREF(result); - PLy_typeinfo_dealloc(&args); - return NULL; + Py_DECREF(result->nrows); + result->nrows = PyInt_FromLong(0); + } + else if (status != SPI_OK_SELECT) + { + Py_DECREF(result->nrows); + result->nrows = PyInt_FromLong(rows); } - - if (rows) + else { - Py_DECREF(result->rows); - result->rows = PyList_New(rows); + DECLARE_EXC(); + PLyTypeInfo args; + int i; + + PLy_typeinfo_init(&args); + Py_DECREF(result->nrows); + result->nrows = PyInt_FromLong(rows); + + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + + if (!PyErr_Occurred()) + PyErr_SetString(PLy_exc_error, + "Unknown error in PLy_spi_execute_fetch_result"); + Py_DECREF(result); + PLy_typeinfo_dealloc(&args); + return NULL; + } - PLy_input_tuple_funcs(&args, tuptable->tupdesc); - for (i = 0; i < rows; i++) - { - PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i], - tuptable->tupdesc); - PyList_SetItem(result->rows, i, row); - } - PLy_typeinfo_dealloc(&args); + if (rows) + { + Py_DECREF(result->rows); + result->rows = PyList_New(rows); + + PLy_input_tuple_funcs(&args, tuptable->tupdesc); + for (i = 0; i < rows; i++) + { + PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i], + tuptable->tupdesc); + + PyList_SetItem(result->rows, i, row); + } + PLy_typeinfo_dealloc(&args); + } + RESTORE_EXC(); } - RESTORE_EXC(); - } - return (PyObject *) result; + return (PyObject *) result; } const char * PLy_spi_error_string(int code) { - switch (code) - { - case SPI_ERROR_TYPUNKNOWN: - return "SPI_ERROR_TYPUNKNOWN"; - case SPI_ERROR_NOOUTFUNC: - return "SPI_ERROR_NOOUTFUNC"; - case SPI_ERROR_NOATTRIBUTE: - return "SPI_ERROR_NOATTRIBUTE"; - case SPI_ERROR_TRANSACTION: - return "SPI_ERROR_TRANSACTION"; - case SPI_ERROR_PARAM: - return "SPI_ERROR_PARAM"; - case SPI_ERROR_ARGUMENT: - return "SPI_ERROR_ARGUMENT"; - case SPI_ERROR_CURSOR: - return "SPI_ERROR_CURSOR"; - case SPI_ERROR_UNCONNECTED: - return "SPI_ERROR_UNCONNECTED"; - case SPI_ERROR_OPUNKNOWN: - return "SPI_ERROR_OPUNKNOWN"; - case SPI_ERROR_COPY: - return "SPI_ERROR_COPY"; - case SPI_ERROR_CONNECT: - return "SPI_ERROR_CONNECT"; - } - return "Unknown or Invalid code"; + switch (code) + { + case SPI_ERROR_TYPUNKNOWN: + return "SPI_ERROR_TYPUNKNOWN"; + case SPI_ERROR_NOOUTFUNC: + return "SPI_ERROR_NOOUTFUNC"; + case SPI_ERROR_NOATTRIBUTE: + return "SPI_ERROR_NOATTRIBUTE"; + case SPI_ERROR_TRANSACTION: + return "SPI_ERROR_TRANSACTION"; + case SPI_ERROR_PARAM: + return "SPI_ERROR_PARAM"; + case SPI_ERROR_ARGUMENT: + return "SPI_ERROR_ARGUMENT"; + case SPI_ERROR_CURSOR: + return "SPI_ERROR_CURSOR"; + case SPI_ERROR_UNCONNECTED: + return "SPI_ERROR_UNCONNECTED"; + case SPI_ERROR_OPUNKNOWN: + return "SPI_ERROR_OPUNKNOWN"; + case SPI_ERROR_COPY: + return "SPI_ERROR_COPY"; + case SPI_ERROR_CONNECT: + return "SPI_ERROR_CONNECT"; + } + return "Unknown or Invalid code"; } /* language handler and interpreter initialization */ -void PLy_init_all(void) +void +PLy_init_all(void) { - static volatile int init_active = 0; + static volatile int init_active = 0; - enter(); + enter(); - if (init_active) - elog(FATAL, "plpython: Initialization of language module failed."); - init_active = 1; + if (init_active) + elog(FATAL, "plpython: Initialization of language module failed."); + init_active = 1; - Py_Initialize(); - PLy_init_interp(); - PLy_init_plpy(); - PLy_init_safe_interp(); - if (PyErr_Occurred()) - PLy_elog(FATAL, "Untrapped error in initialization."); - PLy_procedure_cache = PyDict_New(); - if (PLy_procedure_cache == NULL) - PLy_elog(ERROR, "Unable to create procedure cache."); + Py_Initialize(); + PLy_init_interp(); + PLy_init_plpy(); + PLy_init_safe_interp(); + if (PyErr_Occurred()) + PLy_elog(FATAL, "Untrapped error in initialization."); + PLy_procedure_cache = PyDict_New(); + if (PLy_procedure_cache == NULL) + PLy_elog(ERROR, "Unable to create procedure cache."); - PLy_first_call = 0; + PLy_first_call = 0; - leave(); + leave(); } void PLy_init_interp(void) { - PyObject *mainmod; + PyObject *mainmod; - enter(); + enter(); - mainmod = PyImport_AddModule("__main__"); - if ((mainmod == NULL) || (PyErr_Occurred())) - PLy_elog(ERROR, "Unable to import '__main__' module."); - Py_INCREF(mainmod); - PLy_interp_globals = PyModule_GetDict(mainmod); - Py_DECREF(mainmod); - if ((PLy_interp_globals == NULL) || (PyErr_Occurred())) - PLy_elog(ERROR, "Unable to initialize globals."); + mainmod = PyImport_AddModule("__main__"); + if ((mainmod == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to import '__main__' module."); + Py_INCREF(mainmod); + PLy_interp_globals = PyModule_GetDict(mainmod); + Py_DECREF(mainmod); + if ((PLy_interp_globals == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to initialize globals."); } void PLy_init_plpy(void) { - PyObject *main_mod, *main_dict, *plpy_mod; - PyObject *plpy, *plpy_dict; - - enter(); - - /* initialize plpy module - */ - PLy_PlanType.ob_type = PLy_ResultType.ob_type = &PyType_Type; - plpy = Py_InitModule("plpy", PLy_methods); - plpy_dict = PyModule_GetDict(plpy); - - /* PyDict_SetItemString(plpy, "PlanType", (PyObject *) &PLy_PlanType); */ - - PLy_exc_error = PyErr_NewException("plpy.Error", NULL, NULL); - PLy_exc_fatal = PyErr_NewException("plpy.Fatal", NULL, NULL); - PLy_exc_spi_error = PyErr_NewException("plpy.SPIError", NULL, NULL); - PyDict_SetItemString(plpy_dict, "Error", PLy_exc_error); - PyDict_SetItemString(plpy_dict, "Fatal", PLy_exc_fatal); - PyDict_SetItemString(plpy_dict, "SPIError", PLy_exc_spi_error); - - /* initialize main module, and add plpy - */ - main_mod = PyImport_AddModule("__main__"); - main_dict = PyModule_GetDict(main_mod); - plpy_mod = PyImport_AddModule("plpy"); - PyDict_SetItemString(main_dict, "plpy", plpy_mod); - if (PyErr_Occurred ()) - elog(ERROR, "Unable to init plpy."); + PyObject *main_mod, + *main_dict, + *plpy_mod; + PyObject *plpy, + *plpy_dict; + + enter(); + + /* + * initialize plpy module + */ + PLy_PlanType.ob_type = PLy_ResultType.ob_type = &PyType_Type; + plpy = Py_InitModule("plpy", PLy_methods); + plpy_dict = PyModule_GetDict(plpy); + + /* PyDict_SetItemString(plpy, "PlanType", (PyObject *) &PLy_PlanType); */ + + PLy_exc_error = PyErr_NewException("plpy.Error", NULL, NULL); + PLy_exc_fatal = PyErr_NewException("plpy.Fatal", NULL, NULL); + PLy_exc_spi_error = PyErr_NewException("plpy.SPIError", NULL, NULL); + PyDict_SetItemString(plpy_dict, "Error", PLy_exc_error); + PyDict_SetItemString(plpy_dict, "Fatal", PLy_exc_fatal); + PyDict_SetItemString(plpy_dict, "SPIError", PLy_exc_spi_error); + + /* + * initialize main module, and add plpy + */ + main_mod = PyImport_AddModule("__main__"); + main_dict = PyModule_GetDict(main_mod); + plpy_mod = PyImport_AddModule("plpy"); + PyDict_SetItemString(main_dict, "plpy", plpy_mod); + if (PyErr_Occurred()) + elog(ERROR, "Unable to init plpy."); } void PLy_init_safe_interp(void) { - PyObject *rmod; - char *rname = "rexec"; - int i, imax; + PyObject *rmod; + char *rname = "rexec"; + int i, + imax; - enter(); + enter(); - rmod = PyImport_ImportModuleEx(rname, PLy_interp_globals, - PLy_interp_globals, Py_None); - if ((rmod == NULL) || (PyErr_Occurred ())) - PLy_elog(ERROR, "Unable to import %s.", rname); - PyDict_SetItemString(PLy_interp_globals, rname, rmod); - PLy_interp_safe = rmod; + rmod = PyImport_ImportModuleEx(rname, PLy_interp_globals, + PLy_interp_globals, Py_None); + if ((rmod == NULL) || (PyErr_Occurred())) + PLy_elog(ERROR, "Unable to import %s.", rname); + PyDict_SetItemString(PLy_interp_globals, rname, rmod); + PLy_interp_safe = rmod; - imax = sizeof(PLy_importable_modules_list) / sizeof(char *); - PLy_importable_modules = PyTuple_New(imax); - for (i = 0; i < imax; i++) - { - PyObject *m = PyString_FromString(PLy_importable_modules_list[i]); - PyTuple_SetItem(PLy_importable_modules, i, m); - } + imax = sizeof(PLy_importable_modules_list) / sizeof(char *); + PLy_importable_modules = PyTuple_New(imax); + for (i = 0; i < imax; i++) + { + PyObject *m = PyString_FromString(PLy_importable_modules_list[i]); + + PyTuple_SetItem(PLy_importable_modules, i, m); + } - PLy_interp_safe_globals = PyDict_New(); - if (PLy_interp_safe_globals == NULL) - PLy_elog(ERROR, "Unable to create shared global dictionary."); + PLy_interp_safe_globals = PyDict_New(); + if (PLy_interp_safe_globals == NULL) + PLy_elog(ERROR, "Unable to create shared global dictionary."); } @@ -2396,95 +2489,98 @@ PLy_init_safe_interp(void) static PyObject *PLy_log(int, PyObject *, PyObject *); PyObject * -PLy_debug(PyObject *self, PyObject *args) +PLy_debug(PyObject * self, PyObject * args) { - return PLy_log(DEBUG, self, args); + return PLy_log(DEBUG, self, args); } PyObject * -PLy_error(PyObject *self, PyObject *args) +PLy_error(PyObject * self, PyObject * args) { - return PLy_log(ERROR, self, args); + return PLy_log(ERROR, self, args); } PyObject * -PLy_fatal(PyObject *self, PyObject *args) +PLy_fatal(PyObject * self, PyObject * args) { - return PLy_log(FATAL, self, args); + return PLy_log(FATAL, self, args); } PyObject * -PLy_notice(PyObject *self, PyObject *args) +PLy_notice(PyObject * self, PyObject * args) { - return PLy_log(NOTICE, self, args); + return PLy_log(NOTICE, self, args); } PyObject * -PLy_log(volatile int level, PyObject *self, PyObject *args) -{ - DECLARE_EXC(); - PyObject *so; - char * volatile sv; - - enter(); - - if (args == NULL) - elog(NOTICE, "plpython, args is NULL in %s", __FUNCTION__); - - so = PyObject_Str(args); - if ((so == NULL) || ((sv = PyString_AsString(so)) == NULL)) - { - level = ERROR; - sv = "Unable to parse error message in `plpy.elog'"; - } - - /* returning NULL here causes the python interpreter to bail. - * when control passes back into plpython_*_handler, we - * check for python exceptions and do the actual elog - * call. actually PLy_elog. - */ - if (level == ERROR) - { - PyErr_SetString(PLy_exc_error, sv); - return NULL; - } - else if (level >= FATAL) - { - PyErr_SetString(PLy_exc_fatal, sv); - return NULL; - } - - /* ok, this is a NOTICE, or DEBUG message - * - * but just in case DON'T long jump out of the interpreter! - */ - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - - Py_XDECREF(so); - - /* the real error message should already be written into - * the postgresql log, no? whatever, this shouldn't happen - * so die hideously. - */ - elog(FATAL, "plpython: Aiieee, elog threw an unknown exception!"); - return NULL; - } - - elog(level, sv); - - RESTORE_EXC(); - - Py_XDECREF(so); - Py_INCREF(Py_None); - - /* return a legal object so the interpreter will continue on its - * merry way - */ - return Py_None; +PLy_log(volatile int level, PyObject * self, PyObject * args) +{ + DECLARE_EXC(); + PyObject *so; + char *volatile sv; + + enter(); + + if (args == NULL) + elog(NOTICE, "plpython, args is NULL in %s", __FUNCTION__); + + so = PyObject_Str(args); + if ((so == NULL) || ((sv = PyString_AsString(so)) == NULL)) + { + level = ERROR; + sv = "Unable to parse error message in `plpy.elog'"; + } + + /* + * returning NULL here causes the python interpreter to bail. when + * control passes back into plpython_*_handler, we check for python + * exceptions and do the actual elog call. actually PLy_elog. + */ + if (level == ERROR) + { + PyErr_SetString(PLy_exc_error, sv); + return NULL; + } + else if (level >= FATAL) + { + PyErr_SetString(PLy_exc_fatal, sv); + return NULL; + } + + /* + * ok, this is a NOTICE, or DEBUG message + * + * but just in case DON'T long jump out of the interpreter! + */ + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + + Py_XDECREF(so); + + /* + * the real error message should already be written into the + * postgresql log, no? whatever, this shouldn't happen so die + * hideously. + */ + elog(FATAL, "plpython: Aiieee, elog threw an unknown exception!"); + return NULL; + } + + elog(level, sv); + + RESTORE_EXC(); + + Py_XDECREF(so); + Py_INCREF(Py_None); + + /* + * return a legal object so the interpreter will continue on its merry + * way + */ + return Py_None; } @@ -2494,152 +2590,164 @@ PLy_log(volatile int level, PyObject *self, PyObject *args) static char *PLy_traceback(int *); static char *PLy_vprintf(const char *fmt, va_list ap); -static char *PLy_printf(const char *fmt, ...); +static char *PLy_printf(const char *fmt,...); void -PLy_exception_set(PyObject *exc, const char *fmt, ...) +PLy_exception_set(PyObject * exc, const char *fmt,...) { - char buf[1024]; - va_list ap; + char buf[1024]; + va_list ap; - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); - PyErr_SetString(exc, buf); + PyErr_SetString(exc, buf); } void PLy_elog(int elevel, const char *fmt,...) { - DECLARE_EXC(); - va_list ap; - char *xmsg, *emsg; - int xlevel; + DECLARE_EXC(); + va_list ap; + char *xmsg, + *emsg; + int xlevel; - enter(); + enter(); - xmsg = PLy_traceback(&xlevel); + xmsg = PLy_traceback(&xlevel); - va_start(ap, fmt); - emsg = PLy_vprintf(fmt, ap); - va_end(ap); + va_start(ap, fmt); + emsg = PLy_vprintf(fmt, ap); + va_end(ap); - SAVE_EXC(); - if (TRAP_EXC()) - { - RESTORE_EXC(); - mark(); - /* elog called siglongjmp. cleanup, restore and reraise - */ - PLy_restart_in_progress += 1; - PLy_free(emsg); - PLy_free(xmsg); - RERAISE_EXC(); - } + SAVE_EXC(); + if (TRAP_EXC()) + { + RESTORE_EXC(); + mark(); + + /* + * elog called siglongjmp. cleanup, restore and reraise + */ + PLy_restart_in_progress += 1; + PLy_free(emsg); + PLy_free(xmsg); + RERAISE_EXC(); + } - if (xmsg) - { - elog(elevel, "plpython: %s\n%s", emsg, xmsg); - PLy_free(xmsg); - } - else - elog(elevel, "plpython: %s", emsg); - PLy_free(emsg); + if (xmsg) + { + elog(elevel, "plpython: %s\n%s", emsg, xmsg); + PLy_free(xmsg); + } + else + elog(elevel, "plpython: %s", emsg); + PLy_free(emsg); - leave(); + leave(); - RESTORE_EXC(); + RESTORE_EXC(); } char * PLy_traceback(int *xlevel) { - PyObject *e, *v, *tb; - PyObject *eob, *vob = NULL; - char *vstr, *estr, *xstr = NULL; - - enter(); - - /* get the current exception - */ - PyErr_Fetch(&e, &v, &tb); - - /* oops, no exception, return - */ - if (e == NULL) - { - *xlevel = NOTICE; - return NULL; - } + PyObject *e, + *v, + *tb; + PyObject *eob, + *vob = NULL; + char *vstr, + *estr, + *xstr = NULL; + + enter(); + + /* + * get the current exception + */ + PyErr_Fetch(&e, &v, &tb); + + /* + * oops, no exception, return + */ + if (e == NULL) + { + *xlevel = NOTICE; + return NULL; + } - PyErr_NormalizeException(&e, &v, &tb); + PyErr_NormalizeException(&e, &v, &tb); - eob = PyObject_Str(e); - if ((v) && ((vob = PyObject_Str(v)) != NULL)) - vstr = PyString_AsString(vob); - else - vstr = "Unknown"; + eob = PyObject_Str(e); + if ((v) && ((vob = PyObject_Str(v)) != NULL)) + vstr = PyString_AsString(vob); + else + vstr = "Unknown"; - estr = PyString_AsString(eob); - xstr = PLy_printf("%s: %s", estr, vstr); + estr = PyString_AsString(eob); + xstr = PLy_printf("%s: %s", estr, vstr); - Py_DECREF(eob); - Py_XDECREF(vob); + Py_DECREF(eob); + Py_XDECREF(vob); - /* intuit an appropriate error level for based on the exception type - */ - if ((PLy_exc_error) && (PyErr_GivenExceptionMatches(e, PLy_exc_error))) - *xlevel = ERROR; - else if ((PLy_exc_fatal) && (PyErr_GivenExceptionMatches(e, PLy_exc_fatal))) - *xlevel = FATAL; - else - *xlevel = ERROR; + /* + * intuit an appropriate error level for based on the exception type + */ + if ((PLy_exc_error) && (PyErr_GivenExceptionMatches(e, PLy_exc_error))) + *xlevel = ERROR; + else if ((PLy_exc_fatal) && (PyErr_GivenExceptionMatches(e, PLy_exc_fatal))) + *xlevel = FATAL; + else + *xlevel = ERROR; - leave(); + leave(); - return xstr; + return xstr; } char * -PLy_printf(const char *fmt, ...) +PLy_printf(const char *fmt,...) { - va_list ap; - char *emsg; + va_list ap; + char *emsg; - va_start(ap, fmt); - emsg = PLy_vprintf(fmt, ap); - va_end(ap); - return emsg; + va_start(ap, fmt); + emsg = PLy_vprintf(fmt, ap); + va_end(ap); + return emsg; } char * PLy_vprintf(const char *fmt, va_list ap) { - size_t blen; - int bchar, tries = 2; - char *buf; - - blen = strlen(fmt) * 2; - if (blen < 256) - blen = 256; - buf = PLy_malloc(blen * sizeof(char)); - - while (1) - { - bchar = vsnprintf(buf, blen, fmt, ap); - if ((bchar > 0) && (bchar < blen)) - return buf; - if (tries-- <= 0) - break; - if (blen > 0) - blen = bchar + 1; - else - blen *= 2; - buf = PLy_realloc(buf, blen); - } - PLy_free(buf); - return NULL; + size_t blen; + int bchar, + tries = 2; + char *buf; + + blen = strlen(fmt) * 2; + if (blen < 256) + blen = 256; + buf = PLy_malloc(blen * sizeof(char)); + + while (1) + { + bchar = vsnprintf(buf, blen, fmt, ap); + if ((bchar > 0) && (bchar < blen)) + return buf; + if (tries-- <= 0) + break; + if (blen > 0) + blen = bchar + 1; + else + blen *= 2; + buf = PLy_realloc(buf, blen); + } + PLy_free(buf); + return NULL; } /* python module code @@ -2652,19 +2760,21 @@ PLy_vprintf(const char *fmt, va_list ap) void * PLy_malloc(size_t bytes) { - void *ptr = malloc(bytes); - if (ptr == NULL) - elog(FATAL, "plpython: Memory exhausted."); - return ptr; + void *ptr = malloc(bytes); + + if (ptr == NULL) + elog(FATAL, "plpython: Memory exhausted."); + return ptr; } void * PLy_realloc(void *optr, size_t bytes) { - void *nptr = realloc(optr, bytes); - if (nptr == NULL) - elog(FATAL, "plpython: Memory exhausted."); - return nptr; + void *nptr = realloc(optr, bytes); + + if (nptr == NULL) + elog(FATAL, "plpython: Memory exhausted."); + return nptr; } /* define this away @@ -2672,5 +2782,5 @@ PLy_realloc(void *optr, size_t bytes) void PLy_free(void *ptr) { - free(ptr); + free(ptr); } diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h index d0d84265f5..266640efc8 100644 --- a/src/pl/plpython/plpython.h +++ b/src/pl/plpython/plpython.h @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.2 2001/05/12 01:30:30 petere Exp $ */ +/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.3 2001/10/25 05:50:21 momjian Exp $ */ #ifndef PLPYTHON_H #define PLPYTHON_H @@ -10,22 +10,22 @@ #define TRAP_N_EXC(N) ((rv_##N = sigsetjmp(Warn_restart, 1)) != 0) #if !DEBUG_EXC -# define RESTORE_N_EXC(N) memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf)) -# define SAVE_N_EXC(N) memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf)) -# define RERAISE_N_EXC(N) siglongjmp(Warn_restart, rv_##N) -# define RAISE_EXC(V) siglongjmp(Warn_restart, (V)) +#define RESTORE_N_EXC(N) memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf)) +#define SAVE_N_EXC(N) memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf)) +#define RERAISE_N_EXC(N) siglongjmp(Warn_restart, rv_##N) +#define RAISE_EXC(V) siglongjmp(Warn_restart, (V)) #else -# define RESTORE_N_EXC(N) do { \ +#define RESTORE_N_EXC(N) do { \ elog(NOTICE, "exception (%d,%d) restore at %s:%d",\ - PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__));\ + PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__));\ exc_save_calls -= 1; \ memcpy(&Warn_restart, &(buf_##N), sizeof(sigjmp_buf)); } while (0) -# define SAVE_N_EXC(N) do { \ +#define SAVE_N_EXC(N) do { \ exc_save_calls += 1; \ elog(NOTICE, "exception (%d,%d) save at %s:%d", \ - PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \ + PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \ memcpy(&(buf_##N), &Warn_restart, sizeof(sigjmp_buf)); } while (0) -# define RERAISE_N_EXC(N) do { \ +#define RERAISE_N_EXC(N) do { \ elog(NOTICE, "exception (%d,%d) reraise at %s:%d", \ PLy_call_level, exc_save_calls, __FUNCTION__, (__LINE__)); \ siglongjmp(Warn_restart, rv_##N); } while (0) @@ -42,27 +42,26 @@ #define TRAP_EXC() TRAP_N_EXC(save_restart) #if DEBUG_LEVEL -# define CALL_LEVEL_INC() do { PLy_call_level += 1; \ - elog(NOTICE, "Level: %d", PLy_call_level); } while (0) -# define CALL_LEVEL_DEC() do { elog(NOTICE, "Level: %d", PLy_call_level); \ - PLy_call_level -= 1; } while (0) +#define CALL_LEVEL_INC() do { PLy_call_level += 1; \ + elog(NOTICE, "Level: %d", PLy_call_level); } while (0) +#define CALL_LEVEL_DEC() do { elog(NOTICE, "Level: %d", PLy_call_level); \ + PLy_call_level -= 1; } while (0) #else -# define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0) -# define CALL_LEVEL_DEC() do { PLy_call_level -= 1; } while (0) +#define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0) +#define CALL_LEVEL_DEC() do { PLy_call_level -= 1; } while (0) #endif /* temporary debugging macros */ #if DEBUG_LEVEL -# define enter() elog(NOTICE, "Enter(%d): %s", func_enter_calls++,__FUNCTION__) -# define leave() elog(NOTICE, "Leave(%d): %s", func_leave_calls++,__FUNCTION__) -# define mark() elog(NOTICE, "Mark: %s:%d", __FUNCTION__, __LINE__); -# define refc(O) elog(NOTICE, "Ref<%p>:<%d>:%s:%d", (O), (((O) == NULL) ? -1 : (O)->ob_refcnt), __FUNCTION__, __LINE__) +#define enter() elog(NOTICE, "Enter(%d): %s", func_enter_calls++,__FUNCTION__) +#define leave() elog(NOTICE, "Leave(%d): %s", func_leave_calls++,__FUNCTION__) +#define mark() elog(NOTICE, "Mark: %s:%d", __FUNCTION__, __LINE__); +#define refc(O) elog(NOTICE, "Ref<%p>:<%d>:%s:%d", (O), (((O) == NULL) ? -1 : (O)->ob_refcnt), __FUNCTION__, __LINE__) #else -# define enter() -# define leave() -# define mark() -# define refc(O) +#define enter() +#define leave() +#define mark() +#define refc(O) #endif - -#endif /* PLPYTHON_H */ +#endif /* PLPYTHON_H */ diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 0d04e1a76b..37c8c3a53a 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.46 2001/10/19 19:43:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.47 2001/10/25 05:50:21 momjian Exp $ * **********************************************************************/ @@ -67,31 +67,33 @@ static pg_enconv *tcl_enconv; static unsigned char * -utf_u2e(unsigned char *src) { - return pg_do_encoding_conversion(src,strlen(src), - NULL,tcl_enconv->from_unicode); +utf_u2e(unsigned char *src) +{ + return pg_do_encoding_conversion(src, strlen(src), + NULL, tcl_enconv->from_unicode); } static unsigned char * -utf_e2u(unsigned char *src) { - return pg_do_encoding_conversion(src,strlen(src), - tcl_enconv->to_unicode,NULL); +utf_e2u(unsigned char *src) +{ + return pg_do_encoding_conversion(src, strlen(src), + tcl_enconv->to_unicode, NULL); } -# define PLTCL_UTF -# define UTF_BEGIN do { \ +#define PLTCL_UTF +#define UTF_BEGIN do { \ unsigned char *_pltcl_utf_src; \ unsigned char *_pltcl_utf_dst -# define UTF_END if (_pltcl_utf_src!=_pltcl_utf_dst) \ +#define UTF_END if (_pltcl_utf_src!=_pltcl_utf_dst) \ pfree(_pltcl_utf_dst); } while (0) -# define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x))) -# define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x))) -#else /* PLTCL_UTF */ -# define UTF_BEGIN -# define UTF_END -# define UTF_U2E(x) (x) -# define UTF_E2U(x) (x) -#endif /* PLTCL_UTF */ +#define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x))) +#define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x))) +#else /* PLTCL_UTF */ +#define UTF_BEGIN +#define UTF_END +#define UTF_U2E(x) (x) +#define UTF_E2U(x) (x) +#endif /* PLTCL_UTF */ /********************************************************************** * The information we cache about loaded procedures @@ -179,7 +181,7 @@ static void pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, Tcl_DString *retval); static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, - int argc, char *argv[]); + int argc, char *argv[]); /* * This routine is a crock, and so is everyplace that calls it. The problem @@ -215,7 +217,7 @@ pltcl_init_all(void) * Do unicode conversion initialization ************************************************************/ - tcl_enconv=pg_get_enconv_by_encoding(GetDatabaseEncoding()); + tcl_enconv = pg_get_enconv_by_encoding(GetDatabaseEncoding()); #endif /************************************************************ @@ -288,7 +290,7 @@ pltcl_init_interp(Tcl_Interp *interp) pltcl_SPI_execp, NULL, NULL); Tcl_CreateCommand(interp, "spi_lastoid", pltcl_SPI_lastoid, NULL, NULL); - + /************************************************************ * Try to load the unknown procedure from pltcl_modules ************************************************************/ @@ -556,8 +558,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS) pltcl_restart_in_progress = 0; UTF_BEGIN; elog(ERROR, "pltcl: %s\n%s", interp->result, - UTF_U2E(Tcl_GetVar(interp,"errorInfo", - TCL_GLOBAL_ONLY))); + UTF_U2E(Tcl_GetVar(interp, "errorInfo", + TCL_GLOBAL_ONLY))); UTF_END; } if (--pltcl_call_level == 0) @@ -789,8 +791,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) pltcl_restart_in_progress = 0; UTF_BEGIN; elog(ERROR, "pltcl: %s\n%s", interp->result, - UTF_U2E(Tcl_GetVar(interp,"errorInfo", - TCL_GLOBAL_ONLY))); + UTF_U2E(Tcl_GetVar(interp, "errorInfo", + TCL_GLOBAL_ONLY))); UTF_END; } if (--pltcl_call_level == 0) @@ -1054,7 +1056,7 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger) if (!is_trigger) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -1093,7 +1095,7 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger) for (i = 0; i < prodesc->nargs; i++) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes[i]), + ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -2257,15 +2259,16 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp, /********************************************************************** - * pltcl_SPI_lastoid() - return the last oid. To - * be used after insert queries + * pltcl_SPI_lastoid() - return the last oid. To + * be used after insert queries **********************************************************************/ static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { - char buf[64]; - sprintf(buf,"%u",SPI_lastoid); + char buf[64]; + + sprintf(buf, "%u", SPI_lastoid); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } @@ -2353,7 +2356,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, outputstr = DatumGetCString(OidFunctionCall3(typoutput, attr, ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->atttypmod))); + Int32GetDatum(tupdesc->attrs[i]->atttypmod))); UTF_BEGIN; Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0); UTF_END; @@ -2425,7 +2428,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, outputstr = DatumGetCString(OidFunctionCall3(typoutput, attr, ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->atttypmod))); + Int32GetDatum(tupdesc->attrs[i]->atttypmod))); Tcl_DStringAppendElement(retval, attname); UTF_BEGIN; Tcl_DStringAppendElement(retval, UTF_E2U(outputstr)); diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c index aa7f5a2e9e..b3678005f5 100644 --- a/src/test/examples/testlibpq.c +++ b/src/test/examples/testlibpq.c @@ -28,7 +28,6 @@ main() #ifdef DEBUG FILE *debug; - #endif /* DEBUG */ PGconn *conn; diff --git a/src/test/locale/test-ctype.c b/src/test/locale/test-ctype.c index 8cf5e17da7..684b73c9e1 100644 --- a/src/test/locale/test-ctype.c +++ b/src/test/locale/test-ctype.c @@ -39,7 +39,7 @@ flag(int b) void describe_char(int c) { - unsigned char cp = c, + unsigned char cp = c, up = toupper(c), lo = tolower(c); diff --git a/src/tools/entab/entab.c b/src/tools/entab/entab.c index 0ed1e52069..6350a11b1d 100644 --- a/src/tools/entab/entab.c +++ b/src/tools/entab/entab.c @@ -130,7 +130,6 @@ char **argv; if (col_in_tab == tab_size) { - /* * Is the next character going to be a tab? Needed * to do tab replacement in current spot if next diff --git a/src/tutorial/complex.c b/src/tutorial/complex.c index 0a8f140827..02a6205681 100644 --- a/src/tutorial/complex.c +++ b/src/tutorial/complex.c @@ -30,7 +30,7 @@ int4 complex_abs_cmp(Complex * a, Complex * b); * Input/Output functions *****************************************************************************/ -Complex * +Complex * complex_in(char *str) { double x, @@ -73,7 +73,7 @@ complex_out(Complex * complex) * New Operators *****************************************************************************/ -Complex * +Complex * complex_add(Complex * a, Complex * b) { Complex *result; diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c index cb3de3e6e7..d2c123a009 100644 --- a/src/tutorial/funcs.c +++ b/src/tutorial/funcs.c @@ -62,7 +62,6 @@ makepoint(Point *pointx, Point *pointy) text * copytext(text *t) { - /* * VARSIZE is the total size of the struct in bytes. */ diff --git a/src/utils/dllinit.c b/src/utils/dllinit.c index 0d3a55214b..83439c0865 100644 --- a/src/utils/dllinit.c +++ b/src/utils/dllinit.c @@ -52,7 +52,6 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, DECLARE_CYGWIN_DLL(DllMain); /* save hInstance from DllMain */ HINSTANCE __hDllInstance_base; - #endif /* __CYGWIN__ */ struct _reent *_impure_ptr; @@ -105,5 +104,4 @@ DllMain( } return TRUE; } - #endif /* CYGWIN_VERSION_DLL_MAJOR < 1001 */ diff --git a/src/utils/getopt.c b/src/utils/getopt.c index 8aa46c72f7..108f2d85f5 100644 --- a/src/utils/getopt.c +++ b/src/utils/getopt.c @@ -33,7 +33,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; - #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -82,7 +81,6 @@ const char *ostr; if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) { - /* * if the user didn't specify '-' as an option, assume it means * -1. |