diff options
author | Bruce Momjian | 1997-09-08 02:41:22 +0000 |
---|---|---|
committer | Bruce Momjian | 1997-09-08 02:41:22 +0000 |
commit | 319dbfa7364721d3343af03a7ce063c2a2c9d385 (patch) | |
tree | a2146fe02c49ce1e497b7c287dfcaa367a703ae4 | |
parent | a90f12fd9d6886da4f0734288496361a304d3882 (diff) |
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
632 files changed, 28319 insertions, 28238 deletions
diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c index c0c61f0b6a..23478fb738 100644 --- a/contrib/array/array_iterator.c +++ b/contrib/array/array_iterator.c @@ -40,21 +40,21 @@ #include "utils/builtins.h" #include "utils/elog.h" -static int32 +static int32 array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value) { - HeapTuple typ_tuple; - TypeTupleForm typ_struct; - bool typbyval; - int typlen; - func_ptr proc_fn; - int pronargs; - int nitems, - i, - result; - int ndim, - *dim; - char *p; + HeapTuple typ_tuple; + TypeTupleForm typ_struct; + bool typbyval; + int typlen; + func_ptr proc_fn; + int pronargs; + int nitems, + i, + result; + int ndim, + *dim; + char *p; /* Sanity checks */ if ((array == (ArrayType *) NULL) @@ -101,16 +101,16 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType * array, Datum value) { switch (typlen) { - case 1: - result = (int) (*proc_fn) (*p, value); - break; - case 2: - result = (int) (*proc_fn) (*(int16 *) p, value); - break; - case 3: - case 4: - result = (int) (*proc_fn) (*(int32 *) p, value); - break; + case 1: + result = (int) (*proc_fn) (*p, value); + break; + case 2: + result = (int) (*proc_fn) (*(int16 *) p, value); + break; + case 3: + case 4: + result = (int) (*proc_fn) (*(int32 *) p, value); + break; } p += typlen; } diff --git a/contrib/datetime/datetime_functions.c b/contrib/datetime/datetime_functions.c index 08e7250700..a59bd20db6 100644 --- a/contrib/datetime/datetime_functions.c +++ b/contrib/datetime/datetime_functions.c @@ -13,33 +13,34 @@ #include "utils/datetime.h" -TimeADT * +TimeADT * time_difference(TimeADT * time1, TimeADT * time2) { - TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT)); + TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT)); *result = *time1 - *time2; return (result); } -TimeADT * +TimeADT * currenttime() { - time_t current_time; - struct tm *tm; - TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT)); + time_t current_time; + struct tm *tm; + TimeADT *result = (TimeADT *) palloc(sizeof(TimeADT)); current_time = time(NULL); tm = localtime(¤t_time); *result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec); return (result); } + DateADT currentdate() { - time_t current_time; - struct tm *tm; - DateADT result; + time_t current_time; + struct tm *tm; + DateADT result; current_time = time(NULL); tm = localtime(¤t_time); @@ -48,6 +49,7 @@ currentdate() date2j(100, 1, 1); return (result); } + int4 hours(TimeADT * time) { @@ -65,47 +67,52 @@ seconds(TimeADT * time) { return (((int) *time) % 60); } + int4 day(DateADT * date) { - struct tm tm; + struct tm tm; j2date((*date + date2j(2000, 1, 1)), &tm.tm_year, &tm.tm_mon, &tm.tm_mday); return (tm.tm_mday); } + int4 month(DateADT * date) { - struct tm tm; + struct tm tm; j2date((*date + date2j(2000, 1, 1)), &tm.tm_year, &tm.tm_mon, &tm.tm_mday); return (tm.tm_mon); } + int4 year(DateADT * date) { - struct tm tm; + struct tm tm; j2date((*date + date2j(2000, 1, 1)), &tm.tm_year, &tm.tm_mon, &tm.tm_mday); return (tm.tm_year); } + int4 asminutes(TimeADT * time) { - int seconds = (int) *time; + int seconds = (int) *time; return (seconds / 60); } + int4 asseconds(TimeADT * time) { - int seconds = (int) *time; + int seconds = (int) *time; return (seconds); } diff --git a/contrib/int8/int8.c b/contrib/int8/int8.c index a73986beeb..ac59515a2c 100644 --- a/contrib/int8/int8.c +++ b/contrib/int8/int8.c @@ -26,7 +26,7 @@ #endif #ifndef HAVE_64BIT_INTS -typedef char [8] int64; +typedef char[8] int64; #elif defined(__alpha) typedef long int int64; @@ -44,40 +44,40 @@ typedef long int int64; #define INT64_FORMAT "%ld" #endif -int64 *int8in(char *str); -char *int8out(int64 * val); +int64 *int8in(char *str); +char *int8out(int64 * val); -bool int8eq(int64 * val1, int64 * val2); -bool int8ne(int64 * val1, int64 * val2); -bool int8lt(int64 * val1, int64 * val2); -bool int8gt(int64 * val1, int64 * val2); -bool int8le(int64 * val1, int64 * val2); -bool int8ge(int64 * val1, int64 * val2); +bool int8eq(int64 * val1, int64 * val2); +bool int8ne(int64 * val1, int64 * val2); +bool int8lt(int64 * val1, int64 * val2); +bool int8gt(int64 * val1, int64 * val2); +bool int8le(int64 * val1, int64 * val2); +bool int8ge(int64 * val1, int64 * val2); -bool int84eq(int64 * val1, int32 val2); -bool int84ne(int64 * val1, int32 val2); -bool int84lt(int64 * val1, int32 val2); -bool int84gt(int64 * val1, int32 val2); -bool int84le(int64 * val1, int32 val2); -bool int84ge(int64 * val1, int32 val2); +bool int84eq(int64 * val1, int32 val2); +bool int84ne(int64 * val1, int32 val2); +bool int84lt(int64 * val1, int32 val2); +bool int84gt(int64 * val1, int32 val2); +bool int84le(int64 * val1, int32 val2); +bool int84ge(int64 * val1, int32 val2); -int64 *int8um(int64 * val); -int64 *int8pl(int64 * val1, int64 * val2); -int64 *int8mi(int64 * val1, int64 * val2); -int64 *int8mul(int64 * val1, int64 * val2); -int64 *int8div(int64 * val1, int64 * val2); +int64 *int8um(int64 * val); +int64 *int8pl(int64 * val1, int64 * val2); +int64 *int8mi(int64 * val1, int64 * val2); +int64 *int8mul(int64 * val1, int64 * val2); +int64 *int8div(int64 * val1, int64 * val2); -int64 *int48(int32 val); -int32 int84(int64 * val); +int64 *int48(int32 val); +int32 int84(int64 * val); #if FALSE -int64 *int28(int16 val); -int16 int82(int64 * val); +int64 *int28(int16 val); +int16 int82(int64 * val); #endif -float64 i8tod(int64 * val); -int64 *dtoi8(float64 val); +float64 i8tod(int64 * val); +int64 *dtoi8(float64 val); #if USE_LOCAL_CODE @@ -103,10 +103,10 @@ int64 *dtoi8(float64 val); /* int8in() */ -int64 * +int64 * int8in(char *str) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); #if HAVE_64BIT_INTS if (!PointerIsValid(str)) @@ -126,13 +126,13 @@ int8in(char *str) /* int8out() */ -char * +char * int8out(int64 * val) { - char *result; + char *result; - int len; - char buf[MAXINT8LEN + 1]; + int len; + char buf[MAXINT8LEN + 1]; #if HAVE_64BIT_INTS if (!PointerIsValid(val)) @@ -242,10 +242,10 @@ int84ge(int64 * val1, int32 val2) * Arithmetic operators on 64-bit integers. *---------------------------------------------------------*/ -int64 * +int64 * int8um(int64 * val) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if (!PointerIsValid(val)) return NULL; @@ -255,10 +255,10 @@ int8um(int64 * val) return (result); } /* int8um() */ -int64 * +int64 * int8pl(int64 * val1, int64 * val2) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) return NULL; @@ -268,10 +268,10 @@ int8pl(int64 * val1, int64 * val2) return (result); } /* int8pl() */ -int64 * +int64 * int8mi(int64 * val1, int64 * val2) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) return NULL; @@ -281,10 +281,10 @@ int8mi(int64 * val1, int64 * val2) return (result); } /* int8mi() */ -int64 * +int64 * int8mul(int64 * val1, int64 * val2) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) return NULL; @@ -294,10 +294,10 @@ int8mul(int64 * val1, int64 * val2) return (result); } /* int8mul() */ -int64 * +int64 * int8div(int64 * val1, int64 * val2) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) return NULL; @@ -312,10 +312,10 @@ int8div(int64 * val1, int64 * val2) * Conversion operators. *---------------------------------------------------------*/ -int64 * +int64 * int48(int32 val) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); *result = val; @@ -325,7 +325,7 @@ int48(int32 val) int32 int84(int64 * val) { - int32 result; + int32 result; if (!PointerIsValid(val)) elog(WARN, "Invalid (null) int64, can't convert int8 to int4", NULL); @@ -339,10 +339,10 @@ int84(int64 * val) } /* int84() */ #if FALSE -int64 * +int64 * int28(int16 val) { - int64 *result; + int64 *result; if (!PointerIsValid(result = PALLOCTYPE(int64))) elog(WARN, "Memory allocation failed, can't convert int8 to int2", NULL); @@ -355,7 +355,7 @@ int28(int16 val) int16 int82(int64 * val) { - int16 result; + int16 result; if (!PointerIsValid(val)) elog(WARN, "Invalid (null) int8, can't convert to int2", NULL); @@ -370,17 +370,17 @@ int82(int64 * val) float64 i8tod(int64 * val) { - float64 result = PALLOCTYPE(float64data); + float64 result = PALLOCTYPE(float64data); *result = *val; return (result); } /* i8tod() */ -int64 * +int64 * dtoi8(float64 val) { - int64 *result = PALLOCTYPE(int64); + int64 *result = PALLOCTYPE(int64); if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1))) elog(WARN, "Floating point conversion to int64 is out of range", NULL); diff --git a/contrib/pginterface/halt.c b/contrib/pginterface/halt.c index 000e4a9c40..a9db390de7 100644 --- a/contrib/pginterface/halt.c +++ b/contrib/pginterface/halt.c @@ -24,10 +24,10 @@ void halt(va_alist) va_dcl { - va_list arg_ptr; - char *format, - *pstr; - void (*sig_func) (); + va_list arg_ptr; + char *format, + *pstr; + void (*sig_func) (); va_start(arg_ptr); format = va_arg(arg_ptr, char *); diff --git a/contrib/pginterface/halt.h b/contrib/pginterface/halt.h index 8e1af05e4c..8d83ede83a 100644 --- a/contrib/pginterface/halt.h +++ b/contrib/pginterface/halt.h @@ -3,4 +3,4 @@ ** */ -void halt(); +void halt(); diff --git a/contrib/pginterface/pginsert.c b/contrib/pginterface/pginsert.c index 9946b258ff..82838c2f8c 100644 --- a/contrib/pginterface/pginsert.c +++ b/contrib/pginterface/pginsert.c @@ -13,17 +13,17 @@ int main(int argc, char **argv) { - char query[4000]; - int row = 1; - int aint; - float afloat; - double adouble; - char achar[11], - achar16[17], - abpchar[11], - avarchar[51], - atext[51]; - time_t aabstime; + char query[4000]; + int row = 1; + int aint; + float afloat; + double adouble; + char achar[11], + achar16[17], + abpchar[11], + avarchar[51], + atext[51]; + time_t aabstime; if (argc != 2) halt("Usage: %s database\n", argv[0]); diff --git a/contrib/pginterface/pginterface.c b/contrib/pginterface/pginterface.c index f1ade9dcd4..cdc419352a 100644 --- a/contrib/pginterface/pginterface.c +++ b/contrib/pginterface/pginterface.c @@ -12,31 +12,31 @@ #include "halt.h" #include "pginterface.h" -static void sig_disconnect(); -static void set_signals(); +static void sig_disconnect(); +static void set_signals(); #define NUL '\0' /* GLOBAL VARIABLES */ -static PGconn *conn; +static PGconn *conn; static PGresult *res = NULL; #define ON_ERROR_STOP 0 #define ON_ERROR_CONTINUE 1 -static int on_error_state = ON_ERROR_STOP; +static int on_error_state = ON_ERROR_STOP; /* LOCAL VARIABLES */ static sigset_t block_sigs, - unblock_sigs; -static int tuple; + unblock_sigs; +static int tuple; /* ** ** connectdb - returns PGconn structure ** */ -PGconn * +PGconn * connectdb(char *dbName, char *pghost, char *pgport, @@ -68,7 +68,7 @@ disconnectdb() ** doquery - returns PGresult structure ** */ -PGresult * +PGresult * doquery(char *query) { if (res != NULL) @@ -104,9 +104,9 @@ doquery(char *query) int fetch(void *param,...) { - va_list ap; - int arg, - num_fields; + va_list ap; + int arg, + num_fields; num_fields = PQnfields(res); @@ -142,9 +142,9 @@ fetch(void *param,...) int fetchwithnulls(void *param,...) { - va_list ap; - int arg, - num_fields; + va_list ap; + int arg, + num_fields; num_fields = PQnfields(res); diff --git a/contrib/pginterface/pginterface.h b/contrib/pginterface/pginterface.h index 65894eae34..ad8320aca9 100644 --- a/contrib/pginterface/pginterface.h +++ b/contrib/pginterface/pginterface.h @@ -3,12 +3,12 @@ * */ -PGresult *doquery(char *query); -PGconn *connectdb(); -void disconnectdb(); -int fetch(void *param,...); -int fetchwithnulls(void *param,...); -void on_error_continue(); -void on_error_stop(); +PGresult *doquery(char *query); +PGconn *connectdb(); +void disconnectdb(); +int fetch(void *param,...); +int fetchwithnulls(void *param,...); +void on_error_continue(); +void on_error_stop(); #define END_OF_TUPLES (-1) diff --git a/contrib/pginterface/pgnulltest.c b/contrib/pginterface/pgnulltest.c index 2622edcaf6..96873ca7c8 100644 --- a/contrib/pginterface/pgnulltest.c +++ b/contrib/pginterface/pgnulltest.c @@ -15,26 +15,26 @@ int main(int argc, char **argv) { - char query[4000]; - int row = 1; - int aint; - float afloat; - double adouble; - char achar[11], - achar16[17], - abpchar[11], - avarchar[51], - atext[51]; - time_t aabstime; - int aint_null, - afloat_null, - adouble_null, - achar_null, - achar16_null, - abpchar_null, - avarchar_null, - atext_null, - aabstime_null; + char query[4000]; + int row = 1; + int aint; + float afloat; + double adouble; + char achar[11], + achar16[17], + abpchar[11], + avarchar[51], + atext[51]; + time_t aabstime; + int aint_null, + afloat_null, + adouble_null, + achar_null, + achar16_null, + abpchar_null, + avarchar_null, + atext_null, + aabstime_null; if (argc != 2) halt("Usage: %s database\n", argv[0]); diff --git a/contrib/pginterface/pgwordcount.c b/contrib/pginterface/pgwordcount.c index c447cdcaa0..859cf90b2a 100644 --- a/contrib/pginterface/pgwordcount.c +++ b/contrib/pginterface/pgwordcount.c @@ -13,10 +13,10 @@ int main(int argc, char **argv) { - char query[4000]; - int row = 0; - int count; - char line[4000]; + char query[4000]; + int row = 0; + int count; + char line[4000]; if (argc != 2) halt("Usage: %s database\n", argv[0]); diff --git a/contrib/soundex/soundex.c b/contrib/soundex/soundex.c index 44ad25808d..9b06808fa2 100644 --- a/contrib/soundex/soundex.c +++ b/contrib/soundex/soundex.c @@ -11,18 +11,18 @@ #include <ctype.h> /* prototype for soundex function */ -char *soundex(char *instr, char *outstr); +char *soundex(char *instr, char *outstr); -text * +text * text_soundex(text * t) { /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ - char *table = "01230120022455012623010202"; - int count = 0; - text *new_t; + char *table = "01230120022455012623010202"; + int count = 0; + text *new_t; - char outstr[6 + 1]; /* max length of soundex is 6 */ - char *instr; + char outstr[6 + 1]; /* max length of soundex is 6 */ + char *instr; /* make a null-terminated string */ instr = palloc(VARSIZE(t) + 1); @@ -47,11 +47,11 @@ text_soundex(text * t) return (new_t); } -char * +char * soundex(char *instr, char *outstr) { /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ - char *table = "01230120022455012623010202"; - int count = 0; + char *table = "01230120022455012623010202"; + int count = 0; while (!isalpha(instr[0]) && instr[0]) ++instr; diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c index e2cb2017c6..c45db69187 100644 --- a/contrib/string/string_io.c +++ b/contrib/string/string_io.c @@ -45,15 +45,15 @@ * representation of data. */ -char * +char * string_output(char *data, int size) { register unsigned char c, - *p, - *r, - *result; - register int l, - len; + *p, + *r, + *result; + register int l, + len; if (data == NULL) { @@ -74,23 +74,23 @@ string_output(char *data, int size) { switch (*p) { - case '\\': - case '"': - case '{': - case '}': - case '\b': - case '\f': - case '\n': - case '\r': - case '\t': - case '\v': - len++; - break; - default: - if (NOTPRINTABLE(*p)) - { - len += 3; - } + case '\\': + case '"': + case '{': + case '}': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + case '\v': + len++; + break; + default: + if (NOTPRINTABLE(*p)) + { + len += 3; + } } } len++; @@ -101,53 +101,53 @@ string_output(char *data, int size) { switch (c) { - case '\\': - case '"': - case '{': - case '}': - *r++ = '\\'; - *r++ = c; - break; - case '\b': - *r++ = '\\'; - *r++ = 'b'; - break; - case '\f': - *r++ = '\\'; - *r++ = 'f'; - break; - case '\n': - *r++ = '\\'; - *r++ = 'n'; - break; - case '\r': - *r++ = '\\'; - *r++ = 'r'; - break; - case '\t': - *r++ = '\\'; - *r++ = 't'; - break; - case '\v': - *r++ = '\\'; - *r++ = 'v'; - break; - default: - if (NOTPRINTABLE(c)) - { - *r = '\\'; - r += 3; - *r-- = DIGIT(c & 07); - c >>= 3; - *r-- = DIGIT(c & 07); - c >>= 3; - *r = DIGIT(c & 03); - r += 3; - } - else - { + case '\\': + case '"': + case '{': + case '}': + *r++ = '\\'; *r++ = c; - } + break; + case '\b': + *r++ = '\\'; + *r++ = 'b'; + break; + case '\f': + *r++ = '\\'; + *r++ = 'f'; + break; + case '\n': + *r++ = '\\'; + *r++ = 'n'; + break; + case '\r': + *r++ = '\\'; + *r++ = 'r'; + break; + case '\t': + *r++ = '\\'; + *r++ = 't'; + break; + case '\v': + *r++ = '\\'; + *r++ = 'v'; + break; + default: + if (NOTPRINTABLE(c)) + { + *r = '\\'; + r += 3; + *r-- = DIGIT(c & 07); + c >>= 3; + *r-- = DIGIT(c & 07); + c >>= 3; + *r = DIGIT(c & 03); + r += 3; + } + else + { + *r++ = c; + } } } *r = '\0'; @@ -181,13 +181,13 @@ string_output(char *data, int size) * a pointer to the new string or the header. */ -char * +char * string_input(char *str, int size, int hdrsize, int *rtn_size) { register unsigned char *p, - *r; - unsigned char *result; - int len; + *r; + unsigned char *result; + int len; if ((str == NULL) || (hdrsize < 0)) { @@ -247,48 +247,48 @@ string_input(char *str, int size, int hdrsize, int *rtn_size) { switch (c = *p++) { - case '\0': - p--; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c = VALUE(c); - if (isdigit(*p)) - { - c = (c << 3) + VALUE(*p++); - } - if (isdigit(*p)) - { - c = (c << 3) + VALUE(*p++); - } - *r++ = c; - break; - case 'b': - *r++ = '\b'; - break; - case 'f': - *r++ = '\f'; - break; - case 'n': - *r++ = '\n'; - break; - case 'r': - *r++ = '\r'; - break; - case 't': - *r++ = '\t'; - break; - case 'v': - *r++ = '\v'; - break; - default: - *r++ = c; + case '\0': + p--; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + c = VALUE(c); + if (isdigit(*p)) + { + c = (c << 3) + VALUE(*p++); + } + if (isdigit(*p)) + { + c = (c << 3) + VALUE(*p++); + } + *r++ = c; + break; + case 'b': + *r++ = '\b'; + break; + case 'f': + *r++ = '\f'; + break; + case 'n': + *r++ = '\n'; + break; + case 'r': + *r++ = '\r'; + break; + case 't': + *r++ = '\t'; + break; + case 'v': + *r++ = '\v'; + break; + default: + *r++ = c; } } else @@ -300,10 +300,10 @@ string_input(char *str, int size, int hdrsize, int *rtn_size) return ((char *) result); } -char * +char * c_charout(int32 c) { - char str[2]; + char str[2]; str[0] = (char) c; str[1] = '\0'; @@ -311,25 +311,25 @@ c_charout(int32 c) return (string_output(str, 1)); } -char * +char * c_char2out(uint16 s) { return (string_output((char *) &s, 2)); } -char * +char * c_char4out(uint32 s) { return (string_output((char *) &s, 4)); } -char * +char * c_char8out(char *s) { return (string_output(s, 8)); } -char * +char * c_char16out(char *s) { return (string_output(s, 16)); @@ -339,11 +339,11 @@ c_char16out(char *s) * This can be used for text, bytea, SET and unknown data types */ -char * +char * c_textout(struct varlena * vlena) { - int len = 0; - char *s = NULL; + int len = 0; + char *s = NULL; if (vlena) { @@ -357,10 +357,10 @@ c_textout(struct varlena * vlena) * This can be used for varchar and bpchar strings */ -char * +char * c_varcharout(char *s) { - int len; + int len; if (s) { @@ -375,7 +375,7 @@ struct varlena * c_textin(char *str) { struct varlena *result; - int len; + int len; if (str == NULL) { @@ -388,7 +388,7 @@ c_textin(char *str) return (result); } -char * +char * c_char16in(char *str) { return (string_input(str, 16, 0, NULL)); diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 1725769030..9ce59d8165 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.22 1997/09/07 04:37:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.23 1997/09/08 02:19:47 momjian Exp $ * * NOTES * The old interface functions have been converted to macros @@ -53,9 +53,9 @@ ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]) { - uint32 data_length; - int i; - int numberOfAttributes = tupleDesc->natts; + uint32 data_length; + int i; + int numberOfAttributes = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; for (data_length = 0, i = 0; i < numberOfAttributes; i++) @@ -65,41 +65,41 @@ ComputeDataSize(TupleDesc tupleDesc, switch (att[i]->attlen) { - case -1: + case -1: - /* - * This is the size of the disk representation and so must - * include the additional sizeof long. - */ - if (att[i]->attalign == 'd') - { - data_length = DOUBLEALIGN(data_length) - + VARSIZE(DatumGetPointer(value[i])); - } - else - { - data_length = INTALIGN(data_length) - + VARSIZE(DatumGetPointer(value[i])); - } - break; - case sizeof(char): - data_length++; - break; - case sizeof(short): - data_length = SHORTALIGN(data_length + sizeof(short)); - break; - case sizeof(int32): - data_length = INTALIGN(data_length + sizeof(int32)); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, "ComputeDataSize: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - data_length = DOUBLEALIGN(data_length) + att[i]->attlen; - else - data_length = LONGALIGN(data_length) + att[i]->attlen; - break; + /* + * This is the size of the disk representation and so must + * include the additional sizeof long. + */ + if (att[i]->attalign == 'd') + { + data_length = DOUBLEALIGN(data_length) + + VARSIZE(DatumGetPointer(value[i])); + } + else + { + data_length = INTALIGN(data_length) + + VARSIZE(DatumGetPointer(value[i])); + } + break; + case sizeof(char): + data_length++; + break; + case sizeof(short): + data_length = SHORTALIGN(data_length + sizeof(short)); + break; + case sizeof(int32): + data_length = INTALIGN(data_length + sizeof(int32)); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, "ComputeDataSize: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + data_length = DOUBLEALIGN(data_length) + att[i]->attlen; + else + data_length = LONGALIGN(data_length) + att[i]->attlen; + break; } } @@ -118,11 +118,11 @@ DataFill(char *data, char *infomask, bits8 * bit) { - bits8 *bitP = 0; - int bitmask = 0; - uint32 data_length; - int i; - int numberOfAttributes = tupleDesc->natts; + bits8 *bitP = 0; + int bitmask = 0; + uint32 data_length; + int i; + int numberOfAttributes = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; if (bit != NULL) @@ -159,58 +159,58 @@ DataFill(char *data, switch (att[i]->attlen) { - case -1: - *infomask |= HEAP_HASVARLENA; - if (att[i]->attalign == 'd') - { - data = (char *) DOUBLEALIGN(data); - } - else - { + case -1: + *infomask |= HEAP_HASVARLENA; + if (att[i]->attalign == 'd') + { + data = (char *) DOUBLEALIGN(data); + } + else + { + data = (char *) INTALIGN(data); + } + data_length = VARSIZE(DatumGetPointer(value[i])); + memmove(data, DatumGetPointer(value[i]), data_length); + data += data_length; + break; + case sizeof(char): + *data = att[i]->attbyval ? + DatumGetChar(value[i]) : *((char *) value[i]); + data += sizeof(char); + break; + case sizeof(int16): + data = (char *) SHORTALIGN(data); + *(short *) data = (att[i]->attbyval ? + DatumGetInt16(value[i]) : + *((short *) value[i])); + data += sizeof(short); + break; + case sizeof(int32): data = (char *) INTALIGN(data); - } - data_length = VARSIZE(DatumGetPointer(value[i])); - memmove(data, DatumGetPointer(value[i]), data_length); - data += data_length; - break; - case sizeof(char): - *data = att[i]->attbyval ? - DatumGetChar(value[i]) : *((char *) value[i]); - data += sizeof(char); - break; - case sizeof(int16): - data = (char *) SHORTALIGN(data); - *(short *) data = (att[i]->attbyval ? - DatumGetInt16(value[i]) : - *((short *) value[i])); - data += sizeof(short); - break; - case sizeof(int32): - data = (char *) INTALIGN(data); - *(int32 *) data = (att[i]->attbyval ? - DatumGetInt32(value[i]) : - *((int32 *) value[i])); - data += sizeof(int32); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, "DataFill: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - { - data = (char *) DOUBLEALIGN(data); - memmove(data, DatumGetPointer(value[i]), - att[i]->attlen); - data += att[i]->attlen; - } - else - { - data = (char *) LONGALIGN(data); - memmove(data, DatumGetPointer(value[i]), - att[i]->attlen); - data += att[i]->attlen; - } - break; + *(int32 *) data = (att[i]->attbyval ? + DatumGetInt32(value[i]) : + *((int32 *) value[i])); + data += sizeof(int32); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, "DataFill: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + { + data = (char *) DOUBLEALIGN(data); + memmove(data, DatumGetPointer(value[i]), + att[i]->attlen); + data += att[i]->attlen; + } + else + { + data = (char *) LONGALIGN(data); + memmove(data, DatumGetPointer(value[i]), + att[i]->attlen); + data += att[i]->attlen; + } + break; } } } @@ -240,24 +240,24 @@ heap_attisnull(HeapTuple tup, int attnum) else switch (attnum) { - case SelfItemPointerAttributeNumber: - case ObjectIdAttributeNumber: - case MinTransactionIdAttributeNumber: - case MinCommandIdAttributeNumber: - case MaxTransactionIdAttributeNumber: - case MaxCommandIdAttributeNumber: - case ChainItemPointerAttributeNumber: - case AnchorItemPointerAttributeNumber: - case MinAbsoluteTimeAttributeNumber: - case MaxAbsoluteTimeAttributeNumber: - case VersionTypeAttributeNumber: - break; + case SelfItemPointerAttributeNumber: + case ObjectIdAttributeNumber: + case MinTransactionIdAttributeNumber: + case MinCommandIdAttributeNumber: + case MaxTransactionIdAttributeNumber: + case MaxCommandIdAttributeNumber: + case ChainItemPointerAttributeNumber: + case AnchorItemPointerAttributeNumber: + case MinAbsoluteTimeAttributeNumber: + case MaxAbsoluteTimeAttributeNumber: + case VersionTypeAttributeNumber: + break; - case 0: - elog(WARN, "heap_attisnull: zero attnum disallowed"); + case 0: + elog(WARN, "heap_attisnull: zero attnum disallowed"); - default: - elog(WARN, "heap_attisnull: undefined negative attnum"); + default: + elog(WARN, "heap_attisnull: undefined negative attnum"); } return (0); @@ -277,38 +277,38 @@ heap_attisnull(HeapTuple tup, int attnum) int heap_sysattrlen(AttrNumber attno) { - HeapTupleData *f = NULL; + HeapTupleData *f = NULL; switch (attno) { - case SelfItemPointerAttributeNumber: - return sizeof f->t_ctid; - case ObjectIdAttributeNumber: - return sizeof f->t_oid; - case MinTransactionIdAttributeNumber: - return sizeof f->t_xmin; - case MinCommandIdAttributeNumber: - return sizeof f->t_cmin; - case MaxTransactionIdAttributeNumber: - return sizeof f->t_xmax; - case MaxCommandIdAttributeNumber: - return sizeof f->t_cmax; - case ChainItemPointerAttributeNumber: - return sizeof f->t_chain; - case MinAbsoluteTimeAttributeNumber: - return sizeof f->t_tmin; - case MaxAbsoluteTimeAttributeNumber: - return sizeof f->t_tmax; - case VersionTypeAttributeNumber: - return sizeof f->t_vtype; - - case AnchorItemPointerAttributeNumber: - elog(WARN, "heap_sysattrlen: field t_anchor does not exist!"); - return 0; - - default: - elog(WARN, "sysattrlen: System attribute number %d unknown.", attno); - return 0; + case SelfItemPointerAttributeNumber: + return sizeof f->t_ctid; + case ObjectIdAttributeNumber: + return sizeof f->t_oid; + case MinTransactionIdAttributeNumber: + return sizeof f->t_xmin; + case MinCommandIdAttributeNumber: + return sizeof f->t_cmin; + case MaxTransactionIdAttributeNumber: + return sizeof f->t_xmax; + case MaxCommandIdAttributeNumber: + return sizeof f->t_cmax; + case ChainItemPointerAttributeNumber: + return sizeof f->t_chain; + case MinAbsoluteTimeAttributeNumber: + return sizeof f->t_tmin; + case MaxAbsoluteTimeAttributeNumber: + return sizeof f->t_tmax; + case VersionTypeAttributeNumber: + return sizeof f->t_vtype; + + case AnchorItemPointerAttributeNumber: + elog(WARN, "heap_sysattrlen: field t_anchor does not exist!"); + return 0; + + default: + elog(WARN, "sysattrlen: System attribute number %d unknown.", attno); + return 0; } } @@ -321,48 +321,48 @@ heap_sysattrlen(AttrNumber attno) bool heap_sysattrbyval(AttrNumber attno) { - bool byval; + bool byval; switch (attno) { - case SelfItemPointerAttributeNumber: - byval = false; - break; - case ObjectIdAttributeNumber: - byval = true; - break; - case MinTransactionIdAttributeNumber: - byval = true; - break; - case MinCommandIdAttributeNumber: - byval = true; - break; - case MaxTransactionIdAttributeNumber: - byval = true; - break; - case MaxCommandIdAttributeNumber: - byval = true; - break; - case ChainItemPointerAttributeNumber: - byval = false; - break; - case AnchorItemPointerAttributeNumber: - byval = false; - break; - case MinAbsoluteTimeAttributeNumber: - byval = true; - break; - case MaxAbsoluteTimeAttributeNumber: - byval = true; - break; - case VersionTypeAttributeNumber: - byval = true; - break; - default: - byval = true; - elog(WARN, "sysattrbyval: System attribute number %d unknown.", - attno); - break; + case SelfItemPointerAttributeNumber: + byval = false; + break; + case ObjectIdAttributeNumber: + byval = true; + break; + case MinTransactionIdAttributeNumber: + byval = true; + break; + case MinCommandIdAttributeNumber: + byval = true; + break; + case MaxTransactionIdAttributeNumber: + byval = true; + break; + case MaxCommandIdAttributeNumber: + byval = true; + break; + case ChainItemPointerAttributeNumber: + byval = false; + break; + case AnchorItemPointerAttributeNumber: + byval = false; + break; + case MinAbsoluteTimeAttributeNumber: + byval = true; + break; + case MaxAbsoluteTimeAttributeNumber: + byval = true; + break; + case VersionTypeAttributeNumber: + byval = true; + break; + default: + byval = true; + elog(WARN, "sysattrbyval: System attribute number %d unknown.", + attno); + break; } return byval; @@ -372,57 +372,57 @@ heap_sysattrbyval(AttrNumber attno) * heap_getsysattr * ---------------- */ -char * +char * heap_getsysattr(HeapTuple tup, Buffer b, int attnum) { switch (attnum) { - case SelfItemPointerAttributeNumber: - return ((char *) &tup->t_ctid); - case ObjectIdAttributeNumber: - return ((char *) (long) tup->t_oid); - case MinTransactionIdAttributeNumber: - return ((char *) (long) tup->t_xmin); - case MinCommandIdAttributeNumber: - return ((char *) (long) tup->t_cmin); - case MaxTransactionIdAttributeNumber: - return ((char *) (long) tup->t_xmax); - case MaxCommandIdAttributeNumber: - return ((char *) (long) tup->t_cmax); - case ChainItemPointerAttributeNumber: - return ((char *) &tup->t_chain); - case AnchorItemPointerAttributeNumber: - elog(WARN, "heap_getsysattr: t_anchor does not exist!"); - break; + case SelfItemPointerAttributeNumber: + return ((char *) &tup->t_ctid); + case ObjectIdAttributeNumber: + return ((char *) (long) tup->t_oid); + case MinTransactionIdAttributeNumber: + return ((char *) (long) tup->t_xmin); + case MinCommandIdAttributeNumber: + return ((char *) (long) tup->t_cmin); + case MaxTransactionIdAttributeNumber: + return ((char *) (long) tup->t_xmax); + case MaxCommandIdAttributeNumber: + return ((char *) (long) tup->t_cmax); + case ChainItemPointerAttributeNumber: + return ((char *) &tup->t_chain); + case AnchorItemPointerAttributeNumber: + elog(WARN, "heap_getsysattr: t_anchor does not exist!"); + break; - /* - * For tmin and tmax, we need to do some extra work. These don't - * get filled in until the vacuum cleaner runs (or we manage to - * flush a page after setting the value correctly below). If the - * vacuum cleaner hasn't run yet, then the times stored in the - * tuple are wrong, and we need to look up the commit time of the - * transaction. We cache this value in the tuple to avoid doing - * the work more than once. - */ + /* + * For tmin and tmax, we need to do some extra work. These + * don't get filled in until the vacuum cleaner runs (or we + * manage to flush a page after setting the value correctly + * below). If the vacuum cleaner hasn't run yet, then the + * times stored in the tuple are wrong, and we need to look up + * the commit time of the transaction. We cache this value in + * the tuple to avoid doing the work more than once. + */ - case MinAbsoluteTimeAttributeNumber: - if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) && - TransactionIdDidCommit(tup->t_xmin)) - tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin); - return ((char *) (long) tup->t_tmin); - case MaxAbsoluteTimeAttributeNumber: - if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax)) - { - if (TransactionIdDidCommit(tup->t_xmax)) - tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax); - else - tup->t_tmax = CURRENT_ABSTIME; - } - return ((char *) (long) tup->t_tmax); - case VersionTypeAttributeNumber: - return ((char *) (long) tup->t_vtype); - default: - elog(WARN, "heap_getsysattr: undefined attnum %d", attnum); + case MinAbsoluteTimeAttributeNumber: + if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) && + TransactionIdDidCommit(tup->t_xmin)) + tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin); + return ((char *) (long) tup->t_tmin); + case MaxAbsoluteTimeAttributeNumber: + if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax)) + { + if (TransactionIdDidCommit(tup->t_xmax)) + tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax); + else + tup->t_tmax = CURRENT_ABSTIME; + } + return ((char *) (long) tup->t_tmax); + case VersionTypeAttributeNumber: + return ((char *) (long) tup->t_vtype); + default: + elog(WARN, "heap_getsysattr: undefined attnum %d", attnum); } return (NULL); } @@ -444,15 +444,15 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum) * the same attribute descriptor will go much quicker. -cim 5/4/91 * ---------------- */ -char * +char * fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool * isnull) { - char *tp; /* ptr to att in tuple */ - bits8 *bp = NULL; /* ptr to att in tuple */ - int slow; /* do we have to walk nulls? */ + char *tp; /* ptr to att in tuple */ + bits8 *bp = NULL; /* ptr to att in tuple */ + int slow; /* do we have to walk nulls? */ AttributeTupleForm *att = tupleDesc->attrs; /* ---------------- @@ -526,7 +526,7 @@ fastgetattr(HeapTuple tup, */ { - register int i = 0; /* current offset in bp */ + register int i = 0; /* current offset in bp */ for (i = 0; i < attnum && !slow; i++) { @@ -554,7 +554,7 @@ fastgetattr(HeapTuple tup, } else if (!HeapTupleAllFixed(tup)) { - register int j = 0; + register int j = 0; for (j = 0; j < attnum && !slow; j++) if (att[j]->attlen < 1) @@ -569,8 +569,8 @@ fastgetattr(HeapTuple tup, */ if (!slow) { - register int j = 1; - register long off; + register int j = 1; + register long off; /* * need to set cache for some atts @@ -587,30 +587,30 @@ fastgetattr(HeapTuple tup, { switch (att[j]->attlen) { - case -1: - off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[j]->attlen < sizeof(int32)) - { - elog(WARN, - "fastgetattr: attribute %d has len %d", - j, att[j]->attlen); - } - if (att[j]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[j]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[j]->attlen < sizeof(int32)) + { + elog(WARN, + "fastgetattr: attribute %d has len %d", + j, att[j]->attlen); + } + if (att[j]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } att[j]->attcacheoff = off; @@ -622,9 +622,9 @@ fastgetattr(HeapTuple tup, } else { - register bool usecache = true; - register int off = 0; - register int i; + register bool usecache = true; + register int off = 0; + register int i; /* * Now we know that we have to walk the tuple CAREFULLY. @@ -648,28 +648,28 @@ fastgetattr(HeapTuple tup, } switch (att[i]->attlen) { - case -1: - off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, - "fastgetattr2: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[i]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, + "fastgetattr2: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } if (usecache && att[i]->attcacheoff > 0) { @@ -687,47 +687,47 @@ fastgetattr(HeapTuple tup, switch (att[i]->attlen) { + case sizeof(char): + off++; + break; + case sizeof(int16): + off += sizeof(int16); + break; + case sizeof(int32): + off += sizeof(int32); + break; + case -1: + usecache = false; + off += VARSIZE(tp + off); + break; + default: + off += att[i]->attlen; + break; + } + } + switch (att[attnum]->attlen) + { + case -1: + off = (att[attnum]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; case sizeof(char): - off++; break; - case sizeof(int16): - off += sizeof(int16); + case sizeof(short): + off = SHORTALIGN(off); break; case sizeof(int32): - off += sizeof(int32); - break; - case -1: - usecache = false; - off += VARSIZE(tp + off); + off = INTALIGN(off); break; default: - off += att[i]->attlen; + if (att[attnum]->attlen < sizeof(int32)) + elog(WARN, "fastgetattr3: attribute %d has len %d", + attnum, att[attnum]->attlen); + if (att[attnum]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); break; - } - } - switch (att[attnum]->attlen) - { - case -1: - off = (att[attnum]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[attnum]->attlen < sizeof(int32)) - elog(WARN, "fastgetattr3: attribute %d has len %d", - attnum, att[attnum]->attlen); - if (att[attnum]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; } return ((char *) fetchatt(&(att[attnum]), tp + off)); } @@ -742,7 +742,7 @@ fastgetattr(HeapTuple tup, HeapTuple heap_copytuple(HeapTuple tuple) { - HeapTuple newTuple; + HeapTuple newTuple; if (!HeapTupleIsValid(tuple)) return (NULL); @@ -772,15 +772,15 @@ heap_deformtuple(HeapTuple tuple, Datum values[], char nulls[]) { - int i; - int natts; + int i; + int natts; Assert(HeapTupleIsValid(tuple)); natts = tuple->t_natts; for (i = 0; i < natts; i++) { - bool isnull; + bool isnull; values[i] = (Datum) heap_getattr(tuple, InvalidBuffer, @@ -819,14 +819,14 @@ heap_formtuple(TupleDesc tupleDescriptor, Datum value[], char nulls[]) { - char *tp; /* tuple pointer */ - HeapTuple tuple; /* return tuple */ - int bitmaplen; - long len; - int hoff; - bool hasnull = false; - int i; - int numberOfAttributes = tupleDescriptor->natts; + char *tp; /* tuple pointer */ + HeapTuple tuple; /* return tuple */ + int bitmaplen; + long len; + int hoff; + bool hasnull = false; + int i; + int numberOfAttributes = tupleDescriptor->natts; len = sizeof *tuple - sizeof tuple->t_bits; @@ -885,14 +885,14 @@ heap_modifytuple(HeapTuple tuple, char replNull[], char repl[]) { - int attoff; - int numberOfAttributes; - Datum *value; - char *nulls; - bool isNull; - HeapTuple newTuple; - int madecopy; - uint8 infomask; + int attoff; + int numberOfAttributes; + Datum *value; + char *nulls; + bool isNull; + HeapTuple newTuple; + int madecopy; + uint8 infomask; /* ---------------- * sanity checks @@ -936,7 +936,7 @@ heap_modifytuple(HeapTuple tuple, if (repl[attoff] == ' ') { - char *attr; + char *attr; attr = heap_getattr(tuple, @@ -1001,10 +1001,10 @@ heap_addheader(uint32 natts, /* max domain index */ int structlen, /* its length */ char *structure) /* pointer to the struct */ { - register char *tp; /* tuple data pointer */ - HeapTuple tup; - long len; - int hoff; + register char *tp; /* tuple data pointer */ + HeapTuple tup; + long len; + int hoff; AssertArg(natts > 0); diff --git a/src/backend/access/common/heapvalid.c b/src/backend/access/common/heapvalid.c index 0caeb54e17..ce0cb58d7d 100644 --- a/src/backend/access/common/heapvalid.c +++ b/src/backend/access/common/heapvalid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.17 1997/09/07 04:37:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.18 1997/09/08 02:19:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,9 +36,9 @@ heap_keytest(HeapTuple t, int nkeys, ScanKey keys) { - bool isnull; - Datum atp; - int test; + bool isnull; + Datum atp; + int test; for (; nkeys--; keys++) { @@ -101,11 +101,11 @@ heap_tuple_satisfies(ItemId itemId, int nKeys, ScanKey key) { - HeapTuple tuple, - result; - bool res; - TransactionId old_tmin, - old_tmax; + HeapTuple tuple, + result; + bool res; + TransactionId old_tmin, + old_tmax; if (!ItemIdIsUsed(itemId)) return NULL; diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index c133693801..e0a6e2ba5c 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.16 1997/09/07 04:37:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.17 1997/09/08 02:19:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ #include <string.h> #endif -static Size IndexInfoFindDataOffset(unsigned short t_info); -static char * +static Size IndexInfoFindDataOffset(unsigned short t_info); +static char * fastgetiattr(IndexTuple tup, int attnum, TupleDesc att, bool * isnull); @@ -45,15 +45,15 @@ index_formtuple(TupleDesc tupleDescriptor, Datum value[], char null[]) { - register char *tp; /* tuple pointer */ - IndexTuple tuple; /* return tuple */ - Size size, - hoff; - int i; - unsigned short infomask = 0; - bool hasnull = false; - char tupmask = 0; - int numberOfAttributes = tupleDescriptor->natts; + register char *tp; /* tuple pointer */ + IndexTuple tuple; /* return tuple */ + Size size, + hoff; + int i; + unsigned short infomask = 0; + bool hasnull = false; + char tupmask = 0; + int numberOfAttributes = tupleDescriptor->natts; if (numberOfAttributes > MaxIndexAttributeNumber) elog(WARN, "index_formtuple: numberOfAttributes of %d > %d", @@ -133,16 +133,16 @@ index_formtuple(TupleDesc tupleDescriptor, * the same attribute descriptor will go much quicker. -cim 5/4/91 * ---------------- */ -static char * +static char * fastgetiattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool * isnull) { - register char *tp; /* ptr to att in tuple */ - register char *bp = NULL; /* ptr to att in tuple */ - int slow; /* do we have to walk nulls? */ - register int data_off; /* tuple data offset */ + register char *tp; /* ptr to att in tuple */ + register char *bp = NULL; /* ptr to att in tuple */ + int slow; /* do we have to walk nulls? */ + register int data_off; /* tuple data offset */ AttributeTupleForm *att = tupleDesc->attrs; /* ---------------- @@ -212,11 +212,11 @@ fastgetiattr(IndexTuple tup, * ---------------- */ { - register int i = 0; /* current offset in bp */ - register int mask; /* bit in byte we're looking at */ - register char n; /* current byte in bp */ - register int byte, - finalbit; + register int i = 0; /* current offset in bp */ + register int mask; /* bit in byte we're looking at */ + register char n; /* current byte in bp */ + register int byte, + finalbit; byte = attnum >> 3; finalbit = attnum & 0x07; @@ -256,7 +256,7 @@ fastgetiattr(IndexTuple tup, } else if (!IndexTupleAllFixed(tup)) { - register int j = 0; + register int j = 0; for (j = 0; j < attnum && !slow; j++) if (att[j]->attlen < 1) @@ -272,8 +272,8 @@ fastgetiattr(IndexTuple tup, if (!slow) { - register int j = 1; - register long off; + register int j = 1; + register long off; /* * need to set cache for some atts @@ -297,26 +297,26 @@ fastgetiattr(IndexTuple tup, switch (att[j]->attlen) { - case -1: - off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[j]->attlen > sizeof(int32)) + case -1: off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : LONGALIGN(off); - else - elog(WARN, "fastgetiattr: attribute %d has len %d", - j, att[j]->attlen); - break; + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[j]->attlen > sizeof(int32)) + off = (att[j]->attalign == 'd') ? + DOUBLEALIGN(off) : LONGALIGN(off); + else + elog(WARN, "fastgetiattr: attribute %d has len %d", + j, att[j]->attlen); + break; } @@ -329,9 +329,9 @@ fastgetiattr(IndexTuple tup, } else { - register bool usecache = true; - register int off = 0; - register int i; + register bool usecache = true; + register int off = 0; + register int i; /* * Now we know that we have to walk the tuple CAREFULLY. @@ -361,31 +361,31 @@ fastgetiattr(IndexTuple tup, att[i]->attcacheoff = off; switch (att[i]->attlen) { - case sizeof(char): - off++; - break; - case sizeof(short): - off = SHORTALIGN(off) +sizeof(short); - break; - case sizeof(int32): - off = INTALIGN(off) + sizeof(int32); - break; - case -1: - usecache = false; - off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - off += VARSIZE(tp + off); - break; - default: - if (att[i]->attlen > sizeof(int32)) + case sizeof(char): + off++; + break; + case sizeof(short): + off = SHORTALIGN(off) +sizeof(short); + break; + case sizeof(int32): + off = INTALIGN(off) + sizeof(int32); + break; + case -1: + usecache = false; off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) + att[i]->attlen : - LONGALIGN(off) + att[i]->attlen; - else - elog(WARN, "fastgetiattr2: attribute %d has len %d", - i, att[i]->attlen); - - break; + DOUBLEALIGN(off) : INTALIGN(off); + off += VARSIZE(tp + off); + break; + default: + if (att[i]->attlen > sizeof(int32)) + off = (att[i]->attalign == 'd') ? + DOUBLEALIGN(off) + att[i]->attlen : + LONGALIGN(off) + att[i]->attlen; + else + elog(WARN, "fastgetiattr2: attribute %d has len %d", + i, att[i]->attlen); + + break; } } @@ -395,27 +395,27 @@ fastgetiattr(IndexTuple tup, */ switch (att[attnum]->attlen) { - case -1: - off = (att[attnum]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[attnum]->attlen < sizeof(int32)) - elog(WARN, "fastgetattr3: attribute %d has len %d", - attnum, att[attnum]->attlen); - if (att[attnum]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[attnum]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[attnum]->attlen < sizeof(int32)) + elog(WARN, "fastgetattr3: attribute %d has len %d", + attnum, att[attnum]->attlen); + if (att[attnum]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } return (fetchatt(&att[attnum], tp + off)); @@ -461,14 +461,14 @@ FormRetrieveIndexResult(ItemPointer indexItemPointer, * * Change me if adding an attribute to IndexTuples!!!!!!!!!!! */ -static Size +static Size IndexInfoFindDataOffset(unsigned short t_info) { if (!(t_info & INDEX_NULL_MASK)) return ((Size) sizeof(IndexTupleData)); else { - Size size = sizeof(IndexTupleData); + Size size = sizeof(IndexTupleData); if (t_info & INDEX_NULL_MASK) { @@ -485,8 +485,8 @@ IndexInfoFindDataOffset(unsigned short t_info) void CopyIndexTuple(IndexTuple source, IndexTuple * target) { - Size size; - IndexTuple ret; + Size size; + IndexTuple ret; size = IndexTupleSize(source); if (*target == NULL) diff --git a/src/backend/access/common/indexvalid.c b/src/backend/access/common/indexvalid.c index 9f8501beb2..5a9f351568 100644 --- a/src/backend/access/common/indexvalid.c +++ b/src/backend/access/common/indexvalid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.15 1997/09/07 04:37:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.16 1997/09/08 02:19:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ * index scan key qualification code * ---------------------------------------------------------------- */ -int NIndexTupleProcessed; +int NIndexTupleProcessed; /* ---------------- * index_keytest @@ -40,9 +40,9 @@ index_keytest(IndexTuple tuple, int scanKeySize, ScanKey key) { - bool isNull; - Datum datum; - int test; + bool isNull; + Datum datum; + int test; IncrIndexProcessed(); diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 599ac59a45..f8ff685e38 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.16 1997/09/07 04:37:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.17 1997/09/08 02:19:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ Oid typtoout(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -52,7 +52,7 @@ typtoout(Oid type) Oid gettypelem(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -73,13 +73,13 @@ gettypelem(Oid type) void printtup(HeapTuple tuple, TupleDesc typeinfo) { - int i, - j, - k; - char *outputstr, - *attr; - bool isnull; - Oid typoutput; + int i, + j, + k; + char *outputstr, + *attr; + bool isnull; + Oid typoutput; /* ---------------- * tell the frontend to expect new tuple data @@ -158,8 +158,8 @@ printatt(unsigned attributeId, void showatts(char *name, TupleDesc tupleDesc) { - int i; - int natts = tupleDesc->natts; + int i; + int natts = tupleDesc->natts; AttributeTupleForm *attinfo = tupleDesc->attrs; puts(name); @@ -175,11 +175,11 @@ showatts(char *name, TupleDesc tupleDesc) void debugtup(HeapTuple tuple, TupleDesc typeinfo) { - register int i; - char *attr, - *value; - bool isnull; - Oid typoutput; + register int i; + char *attr, + *value; + bool isnull; + Oid typoutput; for (i = 0; i < tuple->t_natts; ++i) { @@ -209,11 +209,11 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo) void printtup_internal(HeapTuple tuple, TupleDesc typeinfo) { - int i, - j, - k; - char *attr; - bool isnull; + int i, + j, + k; + char *attr; + bool isnull; /* ---------------- * tell the frontend to expect new tuple data @@ -254,7 +254,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) #endif for (i = 0; i < tuple->t_natts; ++i) { - int32 len = typeinfo->attrs[i]->attlen; + int32 len = typeinfo->attrs[i]->attlen; attr = heap_getattr(tuple, InvalidBuffer, i + 1, typeinfo, &isnull); if (!isnull) @@ -269,7 +269,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) pq_putnchar(VARDATA(attr), len); #ifdef IPORTAL_DEBUG { - char *d = VARDATA(attr); + char *d = VARDATA(attr); fprintf(stderr, "length %d data %x%x%x%x\n", len, *d, *(d + 1), *(d + 2), *(d + 3)); @@ -281,25 +281,25 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) /* fixed size */ if (typeinfo->attrs[i]->attbyval) { - int8 i8; - int16 i16; - int32 i32; + int8 i8; + int16 i16; + int32 i32; pq_putint(len, sizeof(int32)); switch (len) { - case sizeof(int8): - i8 = DatumGetChar(attr); - pq_putnchar((char *) &i8, len); - break; - case sizeof(int16): - i16 = DatumGetInt16(attr); - pq_putnchar((char *) &i16, len); - break; - case sizeof(int32): - i32 = DatumGetInt32(attr); - pq_putnchar((char *) &i32, len); - break; + case sizeof(int8): + i8 = DatumGetChar(attr); + pq_putnchar((char *) &i8, len); + break; + case sizeof(int16): + i16 = DatumGetInt16(attr); + pq_putnchar((char *) &i16, len); + break; + case sizeof(int32): + i32 = DatumGetInt32(attr); + pq_putnchar((char *) &i32, len); + break; } #ifdef IPORTAL_DEBUG fprintf(stderr, "byval length %d data %d\n", len, attr); diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index e616702a8e..d4b5e893bd 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.20 1997/09/07 04:37:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.21 1997/09/08 02:19:56 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -42,8 +42,8 @@ TupleDesc CreateTemplateTupleDesc(int natts) { - uint32 size; - TupleDesc desc; + uint32 size; + TupleDesc desc; /* ---------------- * sanity checks @@ -77,7 +77,7 @@ CreateTemplateTupleDesc(int natts) TupleDesc CreateTupleDesc(int natts, AttributeTupleForm * attrs) { - TupleDesc desc; + TupleDesc desc; /* ---------------- * sanity checks @@ -105,9 +105,9 @@ CreateTupleDesc(int natts, AttributeTupleForm * attrs) TupleDesc CreateTupleDescCopy(TupleDesc tupdesc) { - TupleDesc desc; - int i, - size; + TupleDesc desc; + int i, + size; desc = (TupleDesc) palloc(sizeof(struct tupleDesc)); desc->natts = tupdesc->natts; @@ -139,10 +139,10 @@ CreateTupleDescCopy(TupleDesc tupdesc) TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc) { - TupleDesc desc; - TupleConstr *constr = tupdesc->constr; - int i, - size; + TupleDesc desc; + TupleConstr *constr = tupdesc->constr; + int i, + size; desc = (TupleDesc) palloc(sizeof(struct tupleDesc)); desc->natts = tupdesc->natts; @@ -158,7 +158,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) } if (constr) { - TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr)); + TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr)); cpy->has_not_null = constr->has_not_null; @@ -201,7 +201,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) void FreeTupleDesc(TupleDesc tupdesc) { - int i; + int i; for (i = 0; i < tupdesc->natts; i++) pfree(tupdesc->attrs[i]); @@ -210,7 +210,7 @@ FreeTupleDesc(TupleDesc tupdesc) { if (tupdesc->constr->num_defval > 0) { - AttrDefault *attrdef = tupdesc->constr->defval; + AttrDefault *attrdef = tupdesc->constr->defval; for (i = tupdesc->constr->num_defval - 1; i >= 0; i--) { @@ -223,7 +223,7 @@ FreeTupleDesc(TupleDesc tupdesc) } if (tupdesc->constr->num_check > 0) { - ConstrCheck *check = tupdesc->constr->check; + ConstrCheck *check = tupdesc->constr->check; for (i = tupdesc->constr->num_check - 1; i >= 0; i--) { @@ -258,8 +258,8 @@ TupleDescInitEntry(TupleDesc desc, int attdim, bool attisset) { - HeapTuple tuple; - TypeTupleForm typeForm; + HeapTuple tuple; + TypeTupleForm typeForm; AttributeTupleForm att; /* ---------------- @@ -378,7 +378,7 @@ TupleDescInitEntry(TupleDesc desc, */ if (attisset) { - Type t = type("oid"); + Type t = type("oid"); att->attlen = tlen(t); att->attbyval = tbyval(t); @@ -411,7 +411,7 @@ TupleDescMakeSelfReference(TupleDesc desc, char *relname) { AttributeTupleForm att; - Type t = type("oid"); + Type t = type("oid"); att = desc->attrs[attnum - 1]; att->atttypid = TypeShellMake(relname); @@ -439,17 +439,17 @@ TupleDescMakeSelfReference(TupleDesc desc, TupleDesc BuildDescForRelation(List * schema, char *relname) { - int natts; - AttrNumber attnum; - List *p; - TupleDesc desc; - AttrDefault *attrdef = NULL; - TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); - char *attname; - char *typename; - int attdim; - int ndef = 0; - bool attisset; + int natts; + AttrNumber attnum; + List *p; + TupleDesc desc; + AttrDefault *attrdef = NULL; + TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); + char *attname; + char *typename; + int attdim; + int ndef = 0; + bool attisset; /* ---------------- * allocate a new tuple descriptor @@ -465,8 +465,8 @@ BuildDescForRelation(List * schema, char *relname) foreach(p, schema) { - ColumnDef *entry; - List *arry; + ColumnDef *entry; + List *arry; /* ---------------- * for each entry in the list, get the name and type diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 598f9ed8f0..d12e4e5c6e 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -55,7 +55,7 @@ gistSplit(Relation r, Buffer buffer, static void gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt); -static void GISTInitBuffer(Buffer b, uint32 f); +static void GISTInitBuffer(Buffer b, uint32 f); static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, int level, GISTSTATE * giststate, @@ -63,13 +63,13 @@ gistChooseSubtree(Relation r, IndexTuple itup, int level, static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE * giststate); -static int gistnospace(Page p, IndexTuple it); -void gistdelete(Relation r, ItemPointer tid); +static int gistnospace(Page p, IndexTuple it); +void gistdelete(Relation r, ItemPointer tid); static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t); static void gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l); -static char *int_range_out(INTRANGE * r); +static char *int_range_out(INTRANGE * r); /* ** routine to build an index. Basically calls insert over and over @@ -85,33 +85,33 @@ gistbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc scan; - Buffer buffer; - AttrNumber i; - HeapTuple htup; - IndexTuple itup; - TupleDesc hd, - id; + HeapScanDesc scan; + Buffer buffer; + AttrNumber i; + HeapTuple htup; + IndexTuple itup; + TupleDesc hd, + id; InsertIndexResult res; - Datum *d; - bool *nulls; - int nb, - nh, - ni; + Datum *d; + bool *nulls; + int nb, + nh, + ni; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - GISTSTATE giststate; - GISTENTRY tmpcentry; - bool *compvec; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + GISTSTATE giststate; + GISTENTRY tmpcentry; + bool *compvec; /* GiSTs only know how to do stupid locking now */ RelationSetLockForWrite(index); @@ -220,8 +220,8 @@ gistbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -331,11 +331,11 @@ InsertIndexResult gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { InsertIndexResult res; - IndexTuple itup; - GISTSTATE giststate; - GISTENTRY tmpentry; - int i; - bool *compvec; + IndexTuple itup; + GISTSTATE giststate; + GISTENTRY tmpentry; + int i; + bool *compvec; initGISTstate(&giststate, r); @@ -373,7 +373,7 @@ gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation ** that knowledge (some compression routines may want to fish around ** on the page, for example, or do something special for leaf nodes.) */ -static OffsetNumber +static OffsetNumber gistPageAddItem(GISTSTATE * giststate, Relation r, Page page, @@ -384,8 +384,8 @@ gistPageAddItem(GISTSTATE * giststate, GISTENTRY * dentry, IndexTuple * newtup) { - GISTENTRY tmpcentry; - IndexTuple itup = (IndexTuple) item; + GISTENTRY tmpcentry; + IndexTuple itup = (IndexTuple) item; /* * recompress the item given that we now know the exact page and @@ -408,20 +408,20 @@ gistPageAddItem(GISTSTATE * giststate, } -static InsertIndexResult +static InsertIndexResult gistdoinsert(Relation r, IndexTuple itup, /* itup contains compressed entry */ GISTSTATE * giststate) { - GISTENTRY tmpdentry; + GISTENTRY tmpdentry; InsertIndexResult res; - OffsetNumber l; - GISTSTACK *stack; - Buffer buffer; - BlockNumber blk; - Page page; - OffsetNumber off; - IndexTuple newtup; + OffsetNumber l; + GISTSTACK *stack; + Buffer buffer; + BlockNumber blk; + Page page; + OffsetNumber off; + IndexTuple newtup; /* 3rd arg is ignored for now */ blk = gistChooseSubtree(r, itup, 0, giststate, &stack, &buffer); @@ -464,7 +464,7 @@ gistdoinsert(Relation r, } -static BlockNumber +static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed * entry */ int level, @@ -472,12 +472,12 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed GISTSTACK ** retstack /* out */ , Buffer * leafbuf /* out */ ) { - Buffer buffer; - BlockNumber blk; - GISTSTACK *stack; - Page page; - GISTPageOpaque opaque; - IndexTuple which; + Buffer buffer; + BlockNumber blk; + GISTSTACK *stack; + Page page; + GISTPageOpaque opaque; + IndexTuple which; blk = GISTP_ROOT; buffer = InvalidBuffer; @@ -496,8 +496,8 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed opaque = (GISTPageOpaque) PageGetSpecialPointer(page); if (!(opaque->flags & F_LEAF)) { - GISTSTACK *n; - ItemId iid; + GISTSTACK *n; + ItemId iid; n = (GISTSTACK *) palloc(sizeof(GISTSTACK)); n->gs_parent = stack; @@ -526,17 +526,17 @@ gistAdjustKeys(Relation r, int att_size, GISTSTATE * giststate) { - char *oldud; - Page p; - Buffer b; - bool result; - bytea *evec; - GISTENTRY centry, - *ev0p, - *ev1p; - int size, - datumsize; - IndexTuple tid; + char *oldud; + Page p; + Buffer b; + bool result; + bytea *evec; + GISTENTRY centry, + *ev0p, + *ev1p; + int size, + datumsize; + IndexTuple tid; if (stk == (GISTSTACK *) NULL) return; @@ -570,7 +570,7 @@ gistAdjustKeys(Relation r, (giststate->equalFn) (ev0p->pred, datum, &result); if (!result) { - TupleDesc td = RelationGetTupleDescriptor(r); + TupleDesc td = RelationGetTupleDescriptor(r); /* compress datum for storage on page */ gistcentryinit(giststate, ¢ry, datum, ev0p->rel, ev0p->page, @@ -595,10 +595,10 @@ gistAdjustKeys(Relation r, * delete the old entry and insert the new * one. Note that * this may cause a split here! */ - IndexTuple newtup; + IndexTuple newtup; ItemPointerData oldtid; - char *isnull; - TupleDesc tupDesc; + char *isnull; + TupleDesc tupDesc; InsertIndexResult res; /* delete old tuple */ @@ -641,41 +641,41 @@ gistAdjustKeys(Relation r, * gistSplit -- split a page in the tree. * */ -static InsertIndexResult +static InsertIndexResult gistSplit(Relation r, Buffer buffer, GISTSTACK * stack, IndexTuple itup, /* contains compressed entry */ GISTSTATE * giststate) { - Page p; - Buffer leftbuf, - rightbuf; - Page left, - right; - ItemId itemid; - IndexTuple item; - IndexTuple ltup, - rtup, - newtup; - OffsetNumber maxoff; - OffsetNumber i; - OffsetNumber leftoff, - rightoff; - BlockNumber lbknum, - rbknum; - BlockNumber bufblock; - GISTPageOpaque opaque; - int blank; + Page p; + Buffer leftbuf, + rightbuf; + Page left, + right; + ItemId itemid; + IndexTuple item; + IndexTuple ltup, + rtup, + newtup; + OffsetNumber maxoff; + OffsetNumber i; + OffsetNumber leftoff, + rightoff; + BlockNumber lbknum, + rbknum; + BlockNumber bufblock; + GISTPageOpaque opaque; + int blank; InsertIndexResult res; - char *isnull; - GIST_SPLITVEC v; - TupleDesc tupDesc; - bytea *entryvec; - bool *decompvec; - IndexTuple item_1; - GISTENTRY tmpdentry, - tmpentry; + char *isnull; + GIST_SPLITVEC v; + TupleDesc tupDesc; + bytea *entryvec; + bool *decompvec; + IndexTuple item_1; + GISTENTRY tmpdentry, + tmpentry; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -911,11 +911,11 @@ static void gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup, IndexTuple rtup, GISTSTATE * giststate) { - Buffer b; - Page p; + Buffer b; + Page p; InsertIndexResult res; - GISTENTRY tmpentry; - IndexTuple newtup; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, stk->gs_blk); p = BufferGetPage(b); @@ -949,16 +949,16 @@ gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup, /* ** Insert an entry onto a page */ -static InsertIndexResult +static InsertIndexResult gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup, GISTSTATE * giststate) { - Buffer b; - Page p; + Buffer b; + Page p; InsertIndexResult res; - OffsetNumber off; - GISTENTRY tmpentry; - IndexTuple newtup; + OffsetNumber off; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, stk->gs_blk); p = BufferGetPage(b); @@ -992,10 +992,10 @@ gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup, static void gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt) { - Buffer b; - Page p; - GISTENTRY tmpentry; - IndexTuple newtup; + Buffer b; + Page p; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, GISTP_ROOT); GISTInitBuffer(b, 0); @@ -1022,9 +1022,9 @@ gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt) static void GISTInitBuffer(Buffer b, uint32 f) { - GISTPageOpaque opaque; - Page page; - Size pageSize; + GISTPageOpaque opaque; + Page page; + Size pageSize; pageSize = BufferGetPageSize(b); @@ -1040,21 +1040,21 @@ GISTInitBuffer(Buffer b, uint32 f) /* ** find entry with lowest penalty */ -static OffsetNumber +static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */ GISTSTATE * giststate) { - OffsetNumber maxoff; - OffsetNumber i; - char *id; - char *datum; - float usize; - OffsetNumber which; - float which_grow; - GISTENTRY entry, - identry; - int size, - idsize; + OffsetNumber maxoff; + OffsetNumber i; + char *id; + char *datum; + float usize; + OffsetNumber which; + float which_grow; + GISTENTRY entry, + identry; + int size, + idsize; idsize = IndexTupleSize(it) - sizeof(IndexTupleData); id = ((char *) it) + sizeof(IndexTupleData); @@ -1097,7 +1097,7 @@ gistnospace(Page p, IndexTuple it) void gistfreestack(GISTSTACK * s) { - GISTSTACK *p; + GISTSTACK *p; while (s != (GISTSTACK *) NULL) { @@ -1114,10 +1114,10 @@ gistfreestack(GISTSTACK * s) void gistdelete(Relation r, ItemPointer tid) { - BlockNumber blkno; - OffsetNumber offnum; - Buffer buf; - Page page; + BlockNumber blkno; + OffsetNumber offnum; + Buffer buf; + Page page; /* must write-lock on delete */ RelationSetLockForWrite(r); @@ -1142,17 +1142,17 @@ gistdelete(Relation r, ItemPointer tid) void initGISTstate(GISTSTATE * giststate, Relation index) { - RegProcedure consistent_proc, - union_proc, - compress_proc, - decompress_proc; - RegProcedure penalty_proc, - picksplit_proc, - equal_proc; - func_ptr user_fn; - int pronargs; - HeapTuple htup; - IndexTupleForm itupform; + RegProcedure consistent_proc, + union_proc, + compress_proc, + decompress_proc; + RegProcedure penalty_proc, + picksplit_proc, + equal_proc; + func_ptr user_fn; + int pronargs; + HeapTuple htup; + IndexTupleForm itupform; consistent_proc = index_getprocid(index, 1, GIST_CONSISTENT_PROC); union_proc = index_getprocid(index, 1, GIST_UNION_PROC); @@ -1209,10 +1209,10 @@ initGISTstate(GISTSTATE * giststate, Relation index) ** the key with another key, which may involve generating a new IndexTuple ** if the sizes don't match */ -static IndexTuple +static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t) { - char *datum = (((char *) t) + sizeof(IndexTupleData)); + char *datum = (((char *) t) + sizeof(IndexTupleData)); /* if new entry fits in index tuple, copy it in */ if (entry.bytes < IndexTupleSize(t) - sizeof(IndexTupleData)) @@ -1228,10 +1228,10 @@ gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t) else { /* generate a new index tuple for the compressed entry */ - TupleDesc tupDesc = r->rd_att; - IndexTuple newtup; - char *isnull; - int blank; + TupleDesc tupDesc = r->rd_att; + IndexTuple newtup; + char *isnull; + int blank; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -1253,7 +1253,7 @@ void gistdentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l) { - GISTENTRY *dep; + GISTENTRY *dep; gistentryinit(*e, pr, r, pg, o, b, l); if (giststate->haskeytype) @@ -1274,7 +1274,7 @@ static void gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l) { - GISTENTRY *cep; + GISTENTRY *cep; gistentryinit(*e, pr, r, pg, o, b, l); if (giststate->haskeytype) @@ -1299,18 +1299,18 @@ gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, void _gistdump(Relation r) { - Buffer buf; - Page page; - OffsetNumber offnum, - maxoff; - BlockNumber blkno; - BlockNumber nblocks; - GISTPageOpaque po; - IndexTuple itup; - BlockNumber itblkno; - OffsetNumber itoffno; - char *datum; - char *itkey; + Buffer buf; + Page page; + OffsetNumber offnum, + maxoff; + BlockNumber blkno; + BlockNumber nblocks; + GISTPageOpaque po; + IndexTuple itup; + BlockNumber itblkno; + OffsetNumber itoffno; + char *datum; + char *itkey; nblocks = RelationGetNumberOfBlocks(r); for (blkno = 0; blkno < nblocks; blkno++) @@ -1350,12 +1350,12 @@ _gistdump(Relation r) } #ifdef NOT_USED -static char * +static char * text_range_out(TXTRANGE * r) { - char *result; - char *lower, - *upper; + char *result; + char *lower, + *upper; if (r == NULL) return (NULL); @@ -1377,10 +1377,10 @@ text_range_out(TXTRANGE * r) #endif -static char * +static char * int_range_out(INTRANGE * r) { - char *result; + char *result; if (r == NULL) return (NULL); diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index cad4cef267..0820389ff4 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -62,19 +62,19 @@ gistgettuple(IndexScanDesc s, ScanDirection dir) return (res); } -static RetrieveIndexResult +static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTACK *stk; - BlockNumber blk; - IndexTuple it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTACK *stk; + BlockNumber blk; + IndexTuple it; b = ReadBuffer(s->relation, GISTP_ROOT); p = BufferGetPage(b); @@ -145,19 +145,19 @@ gistfirst(IndexScanDesc s, ScanDirection dir) } } -static RetrieveIndexResult +static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTACK *stk; - BlockNumber blk; - IndexTuple it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTACK *stk; + BlockNumber blk; + IndexTuple it; blk = ItemPointerGetBlockNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -247,7 +247,7 @@ gistnext(IndexScanDesc s, ScanDirection dir) } /* Similar to index_keytest, but decompresses the key in the IndexTuple */ -static bool +static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc, int scanKeySize, @@ -257,10 +257,10 @@ gistindex_keytest(IndexTuple tuple, Page p, OffsetNumber offset) { - bool isNull; - Datum datum; - int test; - GISTENTRY de; + bool isNull; + Datum datum; + int test; + GISTENTRY de; IncrIndexProcessed(); @@ -308,14 +308,14 @@ gistindex_keytest(IndexTuple tuple, } -static OffsetNumber +static OffsetNumber gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) { - OffsetNumber maxoff; - char *it; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTATE *giststate; + OffsetNumber maxoff; + char *it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTATE *giststate; maxoff = PageGetMaxOffsetNumber(p); po = (GISTPageOpaque) PageGetSpecialPointer(p); @@ -355,11 +355,11 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) return (n); } -static RetrieveIndexResult +static RetrieveIndexResult gistscancache(IndexScanDesc s, ScanDirection dir) { RetrieveIndexResult res; - ItemPointer ip; + ItemPointer ip; if (!(ScanDirectionIsNoMovement(dir) && ItemPointerIsValid(&(s->currentItemData)))) @@ -384,14 +384,14 @@ gistscancache(IndexScanDesc s, ScanDirection dir) * gistheapptr returns the item pointer to the tuple in the heap relation * for which itemp is the index relation item pointer. */ -static ItemPointer +static ItemPointer gistheapptr(Relation r, ItemPointer itemp) { - Buffer b; - Page p; - IndexTuple it; - ItemPointer ip; - OffsetNumber n; + Buffer b; + Page p; + IndexTuple it; + ItemPointer ip; + OffsetNumber n; ip = (ItemPointer) palloc(sizeof(ItemPointerData)); if (ItemPointerIsValid(itemp)) diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index ec680558d8..6707099775 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -27,8 +27,8 @@ #endif /* routines defined and used here */ -static void gistregscan(IndexScanDesc s); -static void gistdropscan(IndexScanDesc s); +static void gistregscan(IndexScanDesc s); +static void gistdropscan(IndexScanDesc s); static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno, OffsetNumber offnum); @@ -51,9 +51,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct GISTScanListData { - IndexScanDesc gsl_scan; + IndexScanDesc gsl_scan; struct GISTScanListData *gsl_next; -} GISTScanListData; +} GISTScanListData; typedef GISTScanListData *GISTScanList; @@ -66,7 +66,7 @@ gistbeginscan(Relation r, uint16 nkeys, ScanKey key) { - IndexScanDesc s; + IndexScanDesc s; RelationSetLockForRead(r); s = RelationGetIndexScan(r, fromEnd, nkeys, key); @@ -78,8 +78,8 @@ gistbeginscan(Relation r, void gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key) { - GISTScanOpaque p; - int i; + GISTScanOpaque p; + int i; if (!IndexScanIsValid(s)) { @@ -173,10 +173,10 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key) void gistmarkpos(IndexScanDesc s) { - GISTScanOpaque p; - GISTSTACK *o, - *n, - *tmp; + GISTScanOpaque p; + GISTSTACK *o, + *n, + *tmp; s->currentMarkData = s->currentItemData; p = (GISTScanOpaque) s->opaque; @@ -206,10 +206,10 @@ gistmarkpos(IndexScanDesc s) void gistrestrpos(IndexScanDesc s) { - GISTScanOpaque p; - GISTSTACK *o, - *n, - *tmp; + GISTScanOpaque p; + GISTSTACK *o, + *n, + *tmp; s->currentItemData = s->currentMarkData; p = (GISTScanOpaque) s->opaque; @@ -239,7 +239,7 @@ gistrestrpos(IndexScanDesc s) void gistendscan(IndexScanDesc s) { - GISTScanOpaque p; + GISTScanOpaque p; p = (GISTScanOpaque) s->opaque; @@ -257,7 +257,7 @@ gistendscan(IndexScanDesc s) static void gistregscan(IndexScanDesc s) { - GISTScanList l; + GISTScanList l; l = (GISTScanList) palloc(sizeof(GISTScanListData)); l->gsl_scan = s; @@ -268,8 +268,8 @@ gistregscan(IndexScanDesc s) static void gistdropscan(IndexScanDesc s) { - GISTScanList l; - GISTScanList prev; + GISTScanList l; + GISTScanList prev; prev = (GISTScanList) NULL; @@ -294,8 +294,8 @@ gistdropscan(IndexScanDesc s) void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) { - GISTScanList l; - Oid relid; + GISTScanList l; + Oid relid; relid = r->rd_id; for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next) @@ -321,7 +321,7 @@ gistadjone(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - GISTScanOpaque so; + GISTScanOpaque so; adjustiptr(s, &(s->currentItemData), op, blkno, offnum); adjustiptr(s, &(s->currentMarkData), op, blkno, offnum); @@ -349,8 +349,8 @@ adjustiptr(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - OffsetNumber curoff; - GISTScanOpaque so; + OffsetNumber curoff; + GISTScanOpaque so; if (ItemPointerIsValid(iptr)) { @@ -361,39 +361,43 @@ adjustiptr(IndexScanDesc s, switch (op) { - case GISTOP_DEL: - /* back up one if we need to */ - if (curoff >= offnum) - { - - if (curoff > FirstOffsetNumber) - { - /* just adjust the item pointer */ - ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); - } - else + case GISTOP_DEL: + /* back up one if we need to */ + if (curoff >= offnum) { - /* remember that we're before the current tuple */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags |= GS_CURBEFORE; + + if (curoff > FirstOffsetNumber) + { + /* just adjust the item pointer */ + ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); + } else - so->s_flags |= GS_MRKBEFORE; + { + + /* + * remember that we're before the current + * tuple + */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags |= GS_CURBEFORE; + else + so->s_flags |= GS_MRKBEFORE; + } } - } - break; - - case GISTOP_SPLIT: - /* back to start of page on split */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags &= ~GS_CURBEFORE; - else - so->s_flags &= ~GS_MRKBEFORE; - break; - - default: - elog(WARN, "Bad operation in GiST scan adjust: %d", op); + break; + + case GISTOP_SPLIT: + /* back to start of page on split */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags &= ~GS_CURBEFORE; + else + so->s_flags &= ~GS_MRKBEFORE; + break; + + default: + elog(WARN, "Bad operation in GiST scan adjust: %d", op); } } } diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index e13539c4ad..97e1a631a1 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.13 1997/09/07 04:37:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.14 1997/09/08 02:20:10 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -31,7 +31,7 @@ #include <string.h> #endif -bool BuildingHash = false; +bool BuildingHash = false; /* * hashbuild() -- build a new hash index. @@ -52,30 +52,30 @@ hashbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc hscan; - Buffer buffer; - HeapTuple htup; - IndexTuple itup; - TupleDesc htupdesc, - itupdesc; - Datum *attdata; - bool *nulls; + HeapScanDesc hscan; + Buffer buffer; + HeapTuple htup; + IndexTuple itup; + TupleDesc htupdesc, + itupdesc; + Datum *attdata; + bool *nulls; InsertIndexResult res; - int nhtups, - nitups; - int i; - HashItem hitem; + int nhtups, + nitups; + int i; + HashItem hitem; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; + Oid hrelid, + irelid; + Node *pred, + *oldPred; /* note that this is a new btree */ BuildingHash = true; @@ -171,8 +171,8 @@ hashbuild(Relation heap, */ for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -280,8 +280,8 @@ hashbuild(Relation heap, InsertIndexResult hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { - HashItem hitem; - IndexTuple itup; + HashItem hitem; + IndexTuple itup; InsertIndexResult res; @@ -306,7 +306,7 @@ hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relati /* * hashgettuple() -- Get the next tuple in the scan. */ -char * +char * hashgettuple(IndexScanDesc scan, ScanDirection dir) { RetrieveIndexResult res; @@ -329,14 +329,14 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir) /* * hashbeginscan() -- start a scan on a hash index */ -char * +char * hashbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) { - IndexScanDesc scan; - HashScanOpaque so; + IndexScanDesc scan; + HashScanOpaque so; scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey); so = (HashScanOpaque) palloc(sizeof(HashScanOpaqueData)); @@ -356,8 +356,8 @@ hashbeginscan(Relation rel, void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; so = (HashScanOpaque) scan->opaque; @@ -391,8 +391,8 @@ void hashendscan(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; so = (HashScanOpaque) scan->opaque; @@ -426,8 +426,8 @@ hashendscan(IndexScanDesc scan) void hashmarkpos(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; /* * see if we ever call this code. if we do, then so_mrkbuf a useful @@ -463,8 +463,8 @@ hashmarkpos(IndexScanDesc scan) void hashrestrpos(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; /* * see if we ever call this code. if we do, then so_mrkbuf a useful diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index a3cbaa1a94..1178586769 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.4 1997/09/07 04:37:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.5 1997/09/08 02:20:13 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -36,10 +36,10 @@ hashint4(uint32 key) uint32 hashfloat4(float32 keyp) { - int len; - int loop; - uint32 h; - char *kp = (char *) keyp; + int len; + int loop; + uint32 h; + char *kp = (char *) keyp; len = sizeof(float32data); @@ -55,25 +55,25 @@ hashfloat4(float32 keyp) switch (len & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASH4; - case 7: - HASH4; - case 6: - HASH4; - case 5: - HASH4; - case 4: - HASH4; - case 3: - HASH4; - case 2: - HASH4; - case 1: - HASH4; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASH4; + case 7: + HASH4; + case 6: + HASH4; + case 5: + HASH4; + case 4: + HASH4; + case 3: + HASH4; + case 2: + HASH4; + case 1: + HASH4; + } while (--loop); } } return (h); @@ -83,10 +83,10 @@ hashfloat4(float32 keyp) uint32 hashfloat8(float64 keyp) { - int len; - int loop; - uint32 h; - char *kp = (char *) keyp; + int len; + int loop; + uint32 h; + char *kp = (char *) keyp; len = sizeof(float64data); @@ -102,25 +102,25 @@ hashfloat8(float64 keyp) switch (len & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASH4; - case 7: - HASH4; - case 6: - HASH4; - case 5: - HASH4; - case 4: - HASH4; - case 3: - HASH4; - case 2: - HASH4; - case 1: - HASH4; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASH4; + case 7: + HASH4; + case 6: + HASH4; + case 5: + HASH4; + case 4: + HASH4; + case 3: + HASH4; + case 2: + HASH4; + case 1: + HASH4; + } while (--loop); } } return (h); @@ -137,8 +137,8 @@ hashoid(Oid key) uint32 hashchar(char key) { - int len; - uint32 h; + int len; + uint32 h; len = sizeof(char); @@ -156,9 +156,9 @@ hashchar(char key) uint32 hashchar2(uint16 intkey) { - uint32 h; - int len; - char *key = (char *) &intkey; + uint32 h; + int len; + char *key = (char *) &intkey; h = 0; len = sizeof(uint16); @@ -173,9 +173,9 @@ hashchar2(uint16 intkey) uint32 hashchar4(uint32 intkey) { - uint32 h; - int len; - char *key = (char *) &intkey; + uint32 h; + int len; + char *key = (char *) &intkey; h = 0; len = sizeof(uint32); @@ -190,8 +190,8 @@ hashchar4(uint32 intkey) uint32 hashchar8(char *key) { - uint32 h; - int len; + uint32 h; + int len; h = 0; len = sizeof(char8); @@ -206,9 +206,9 @@ hashchar8(char *key) uint32 hashname(NameData * n) { - uint32 h; - int len; - char *key; + uint32 h; + int len; + char *key; key = n->data; @@ -226,8 +226,8 @@ hashname(NameData * n) uint32 hashchar16(char *key) { - uint32 h; - int len; + uint32 h; + int len; h = 0; len = sizeof(char16); @@ -254,10 +254,10 @@ hashchar16(char *key) uint32 hashtext(struct varlena * key) { - int keylen; - char *keydata; - uint32 n; - int loop; + int keylen; + char *keydata; + uint32 n; + int loop; keydata = VARDATA(key); keylen = VARSIZE(key); @@ -274,25 +274,25 @@ hashtext(struct varlena * key) switch (keylen & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASHC; + case 7: + HASHC; + case 6: + HASHC; + case 5: + HASHC; + case 4: + HASHC; + case 3: + HASHC; + case 2: + HASHC; + case 1: + HASHC; + } while (--loop); } } return (n); diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index 4829093589..f76aba4179 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.9 1997/09/07 04:37:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.10 1997/09/08 02:20:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,15 +32,15 @@ static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem) { - Buffer buf; - Buffer metabuf; - BlockNumber blkno; - HashMetaPage metap; - IndexTuple itup; + Buffer buf; + Buffer metabuf; + BlockNumber blkno; + HashMetaPage metap; + IndexTuple itup; InsertIndexResult res; - ScanKey itup_scankey; - int natts; - Page page; + ScanKey itup_scankey; + int natts; + Page page; metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ); metap = (HashMetaPage) BufferGetPage(metabuf); @@ -101,7 +101,7 @@ _hash_doinsert(Relation rel, HashItem hitem) * we will have dropped both the pin and the write lock on the buffer. * */ -static InsertIndexResult +static InsertIndexResult _hash_insertonpg(Relation rel, Buffer buf, int keysz, @@ -110,15 +110,15 @@ _hash_insertonpg(Relation rel, Buffer metabuf) { InsertIndexResult res; - Page page; - BlockNumber itup_blkno; - OffsetNumber itup_off; - int itemsz; - HashPageOpaque pageopaque; - bool do_expand = false; - Buffer ovflbuf; - HashMetaPage metap; - Bucket bucket; + Page page; + BlockNumber itup_blkno; + OffsetNumber itup_off; + int itemsz; + HashPageOpaque pageopaque; + bool do_expand = false; + Buffer ovflbuf; + HashMetaPage metap; + Bucket bucket; metap = (HashMetaPage) BufferGetPage(metabuf); _hash_checkpage((Page) metap, LH_META_PAGE); @@ -218,7 +218,7 @@ _hash_insertonpg(Relation rel, * write lock and reference associated with the page's buffer. It is * an error to call pgaddtup() without a write lock and reference. */ -static OffsetNumber +static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, @@ -226,8 +226,8 @@ _hash_pgaddtup(Relation rel, Size itemsize, HashItem hitem) { - OffsetNumber itup_off; - Page page; + OffsetNumber itup_off; + Page page; page = BufferGetPage(buf); _hash_checkpage(page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index b6882d4d3e..5d764b3472 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.10 1997/09/07 04:37:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.11 1997/09/08 02:20:17 momjian Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -27,7 +27,7 @@ #endif static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp); -static uint32 _hash_firstfreebit(uint32 map); +static uint32 _hash_firstfreebit(uint32 map); /* * _hash_addovflpage @@ -44,13 +44,13 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf) { OverflowPageAddress oaddr; - BlockNumber ovflblkno; - Buffer ovflbuf; - HashMetaPage metap; - HashPageOpaque ovflopaque; - HashPageOpaque pageopaque; - Page page; - Page ovflpage; + BlockNumber ovflblkno; + Buffer ovflbuf; + HashMetaPage metap; + HashPageOpaque ovflopaque; + HashPageOpaque pageopaque; + Page page; + Page ovflpage; /* this had better be the last page in a bucket chain */ page = BufferGetPage(buf); @@ -99,24 +99,24 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf) * is exchanged for a read lock. * */ -static OverflowPageAddress +static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp) { - HashMetaPage metap; - Buffer mapbuf = 0; - BlockNumber blkno; - PageOffset offset; + HashMetaPage metap; + Buffer mapbuf = 0; + BlockNumber blkno; + PageOffset offset; OverflowPageAddress oaddr; - SplitNumber splitnum; - uint32 *freep = NULL; - uint32 max_free; - uint32 bit; - uint32 first_page; - uint32 free_bit; - uint32 free_page; - uint32 in_use_bits; - uint32 i, - j; + SplitNumber splitnum; + uint32 *freep = NULL; + uint32 max_free; + uint32 bit; + uint32 first_page; + uint32 free_bit; + uint32 free_page; + uint32 in_use_bits; + uint32 i, + j; metap = (HashMetaPage) _hash_chgbufaccess(rel, metabufp, HASH_READ, HASH_WRITE); @@ -130,7 +130,7 @@ _hash_getovfladdr(Relation rel, Buffer * metabufp) first_page = metap->LAST_FREED >> (metap->BSHIFT + BYTE_TO_BIT); for (i = first_page; i <= free_page; i++) { - Page mappage; + Page mappage; blkno = metap->hashm_mapp[i]; mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE); @@ -279,11 +279,11 @@ found: * splitnumber. * */ -static uint32 +static uint32 _hash_firstfreebit(uint32 map) { - uint32 i, - mask; + uint32 i, + mask; mask = 0x1; for (i = 0; i < BITS_PER_MAP; i++) @@ -306,22 +306,22 @@ _hash_firstfreebit(uint32 map) Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf) { - HashMetaPage metap; - Buffer metabuf; - Buffer mapbuf; - BlockNumber prevblkno; - BlockNumber blkno; - BlockNumber nextblkno; - HashPageOpaque ovflopaque; - Page ovflpage; - Page mappage; + HashMetaPage metap; + Buffer metabuf; + Buffer mapbuf; + BlockNumber prevblkno; + BlockNumber blkno; + BlockNumber nextblkno; + HashPageOpaque ovflopaque; + Page ovflpage; + Page mappage; OverflowPageAddress addr; - SplitNumber splitnum; - uint32 *freep; - uint32 ovflpgno; - int32 bitmappage, - bitmapbit; - Bucket bucket; + SplitNumber splitnum; + uint32 *freep; + uint32 ovflpgno; + int32 bitmappage, + bitmapbit; + Bucket bucket; metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE); metap = (HashMetaPage) BufferGetPage(metabuf); @@ -348,9 +348,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf) */ if (BlockNumberIsValid(prevblkno)) { - Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE); - Page prevpage = BufferGetPage(prevbuf); - HashPageOpaque prevopaque = + Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE); + Page prevpage = BufferGetPage(prevbuf); + HashPageOpaque prevopaque = (HashPageOpaque) PageGetSpecialPointer(prevpage); _hash_checkpage(prevpage, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); @@ -360,9 +360,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf) } if (BlockNumberIsValid(nextblkno)) { - Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE); - Page nextpage = BufferGetPage(nextbuf); - HashPageOpaque nextopaque = + Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE); + Page nextpage = BufferGetPage(nextbuf); + HashPageOpaque nextopaque = (HashPageOpaque) PageGetSpecialPointer(nextpage); _hash_checkpage(nextpage, LH_OVERFLOW_PAGE); @@ -436,13 +436,13 @@ _hash_initbitmap(Relation rel, int32 nbits, int32 ndx) { - Buffer buf; - BlockNumber blkno; - Page pg; - HashPageOpaque op; - uint32 *freep; - int clearbytes, - clearints; + Buffer buf; + BlockNumber blkno; + Page pg; + HashPageOpaque op; + uint32 *freep; + int clearbytes, + clearints; blkno = OADDR_TO_BLKNO(pnum); buf = _hash_getbuf(rel, blkno, HASH_WRITE); @@ -496,18 +496,18 @@ _hash_squeezebucket(Relation rel, HashMetaPage metap, Bucket bucket) { - Buffer wbuf; - Buffer rbuf = 0; - BlockNumber wblkno; - BlockNumber rblkno; - Page wpage; - Page rpage; - HashPageOpaque wopaque; - HashPageOpaque ropaque; - OffsetNumber woffnum; - OffsetNumber roffnum; - HashItem hitem; - int itemsz; + Buffer wbuf; + Buffer rbuf = 0; + BlockNumber wblkno; + BlockNumber rblkno; + Page wpage; + Page rpage; + HashPageOpaque wopaque; + HashPageOpaque ropaque; + OffsetNumber woffnum; + OffsetNumber roffnum; + HashItem hitem; + int itemsz; /* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */ diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 6c819b652d..17fdaab37f 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.10 1997/09/07 04:38:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.11 1997/09/08 02:20:18 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -38,9 +38,9 @@ #include <string.h> #endif -static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access); -static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access); -static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket); +static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access); +static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access); +static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket); /* * We use high-concurrency locking on hash indices. There are two cases in @@ -68,16 +68,16 @@ static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucke void _hash_metapinit(Relation rel) { - HashMetaPage metap; - HashPageOpaque pageopaque; - Buffer metabuf; - Buffer buf; - Page pg; - int nbuckets; - uint32 nelem; /* number elements */ - uint32 lg2nelem; /* _hash_log2(nelem) */ - uint32 nblocks; - uint16 i; + HashMetaPage metap; + HashPageOpaque pageopaque; + Buffer metabuf; + Buffer buf; + Page pg; + int nbuckets; + uint32 nelem; /* number elements */ + uint32 lg2nelem; /* _hash_log2(nelem) */ + uint32 nblocks; + uint16 i; /* can't be sharing this with anyone, now... */ if (USELOCKING) @@ -188,7 +188,7 @@ _hash_metapinit(Relation rel) Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access) { - Buffer buf; + Buffer buf; if (blkno == P_NEW) { @@ -196,14 +196,14 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access) } switch (access) { - case HASH_WRITE: - case HASH_READ: - _hash_setpagelock(rel, blkno, access); - break; - default: - elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s", - access, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + case HASH_READ: + _hash_setpagelock(rel, blkno, access); + break; + default: + elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s", + access, RelationGetRelationName(rel)); + break; } buf = ReadBuffer(rel, blkno); @@ -217,19 +217,19 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access) void _hash_relbuf(Relation rel, Buffer buf, int access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); switch (access) { - case HASH_WRITE: - case HASH_READ: - _hash_unsetpagelock(rel, blkno, access); - break; - default: - elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); + case HASH_WRITE: + case HASH_READ: + _hash_unsetpagelock(rel, blkno, access); + break; + default: + elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); } ReleaseBuffer(buf); @@ -245,7 +245,7 @@ _hash_relbuf(Relation rel, Buffer buf, int access) void _hash_wrtbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteBuffer(buf); @@ -262,7 +262,7 @@ _hash_wrtbuf(Relation rel, Buffer buf) void _hash_wrtnorelbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteNoReleaseBuffer(buf); @@ -274,22 +274,22 @@ _hash_chgbufaccess(Relation rel, int from_access, int to_access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(*bufp); switch (from_access) { - case HASH_WRITE: - _hash_wrtbuf(rel, *bufp); - break; - case HASH_READ: - _hash_relbuf(rel, *bufp, from_access); - break; - default: - elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s", - from_access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + _hash_wrtbuf(rel, *bufp); + break; + case HASH_READ: + _hash_relbuf(rel, *bufp, from_access); + break; + default: + elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s", + from_access, blkno, RelationGetRelationName(rel)); + break; } *bufp = _hash_getbuf(rel, blkno, to_access); return (BufferGetPage(*bufp)); @@ -328,16 +328,16 @@ _hash_setpagelock(Relation rel, switch (access) { - case HASH_WRITE: - RelationSetSingleWLockPage(rel, &iptr); - break; - case HASH_READ: - RelationSetSingleRLockPage(rel, &iptr); - break; - default: - elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + RelationSetSingleWLockPage(rel, &iptr); + break; + case HASH_READ: + RelationSetSingleRLockPage(rel, &iptr); + break; + default: + elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); + break; } } } @@ -355,16 +355,16 @@ _hash_unsetpagelock(Relation rel, switch (access) { - case HASH_WRITE: - RelationUnsetSingleWLockPage(rel, &iptr); - break; - case HASH_READ: - RelationUnsetSingleRLockPage(rel, &iptr); - break; - default: - elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + RelationUnsetSingleWLockPage(rel, &iptr); + break; + case HASH_READ: + RelationUnsetSingleRLockPage(rel, &iptr); + break; + default: + elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); + break; } } } @@ -372,13 +372,13 @@ _hash_unsetpagelock(Relation rel, void _hash_pagedel(Relation rel, ItemPointer tid) { - Buffer buf; - Buffer metabuf; - Page page; - BlockNumber blkno; - OffsetNumber offno; - HashMetaPage metap; - HashPageOpaque opaque; + Buffer buf; + Buffer metabuf; + Page page; + BlockNumber blkno; + OffsetNumber offno; + HashMetaPage metap; + HashPageOpaque opaque; blkno = ItemPointerGetBlockNumber(tid); offno = ItemPointerGetOffsetNumber(tid); @@ -414,10 +414,10 @@ _hash_pagedel(Relation rel, ItemPointer tid) void _hash_expandtable(Relation rel, Buffer metabuf) { - HashMetaPage metap; - Bucket old_bucket; - Bucket new_bucket; - uint32 spare_ndx; + HashMetaPage metap; + Bucket old_bucket; + Bucket new_bucket; + uint32 spare_ndx; /* elog(DEBUG, "_hash_expandtable: expanding..."); */ @@ -472,26 +472,26 @@ _hash_splitpage(Relation rel, Bucket obucket, Bucket nbucket) { - Bucket bucket; - Buffer obuf; - Buffer nbuf; - Buffer ovflbuf; - BlockNumber oblkno; - BlockNumber nblkno; - bool null; - Datum datum; - HashItem hitem; - HashPageOpaque oopaque; - HashPageOpaque nopaque; - HashMetaPage metap; - IndexTuple itup; - int itemsz; - OffsetNumber ooffnum; - OffsetNumber noffnum; - OffsetNumber omaxoffnum; - Page opage; - Page npage; - TupleDesc itupdesc; + Bucket bucket; + Buffer obuf; + Buffer nbuf; + Buffer ovflbuf; + BlockNumber oblkno; + BlockNumber nblkno; + bool null; + Datum datum; + HashItem hitem; + HashPageOpaque oopaque; + HashPageOpaque nopaque; + HashMetaPage metap; + IndexTuple itup; + int itemsz; + OffsetNumber ooffnum; + OffsetNumber noffnum; + OffsetNumber omaxoffnum; + Page opage; + Page npage; + TupleDesc itupdesc; /* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d", obucket, obucket, nbucket); diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c index 79fa33f747..de64ebdd06 100644 --- a/src/backend/access/hash/hashscan.c +++ b/src/backend/access/hash/hashscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.9 1997/09/07 04:38:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.10 1997/09/08 02:20:20 momjian Exp $ * * NOTES * Because we can be doing an index scan on a relation while we @@ -31,14 +31,14 @@ #include <access/hash.h> -static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); -static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); typedef struct HashScanListData { - IndexScanDesc hashsl_scan; + IndexScanDesc hashsl_scan; struct HashScanListData *hashsl_next; -} HashScanListData; +} HashScanListData; typedef HashScanListData *HashScanList; @@ -50,7 +50,7 @@ static HashScanList HashScans = (HashScanList) NULL; void _hash_regscan(IndexScanDesc scan) { - HashScanList new_el; + HashScanList new_el; new_el = (HashScanList) palloc(sizeof(HashScanListData)); new_el->hashsl_scan = scan; @@ -64,8 +64,8 @@ _hash_regscan(IndexScanDesc scan) void _hash_dropscan(IndexScanDesc scan) { - HashScanList chk, - last; + HashScanList chk, + last; last = (HashScanList) NULL; for (chk = HashScans; @@ -89,8 +89,8 @@ _hash_dropscan(IndexScanDesc scan) void _hash_adjscans(Relation rel, ItemPointer tid) { - HashScanList l; - Oid relid; + HashScanList l; + Oid relid; relid = rel->rd_id; for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next) @@ -104,10 +104,10 @@ _hash_adjscans(Relation rel, ItemPointer tid) static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; - Buffer buf; - Buffer metabuf; - HashScanOpaque so; + ItemPointer current; + Buffer buf; + Buffer metabuf; + HashScanOpaque so; if (!_hash_scantouched(scan, blkno, offno)) return; @@ -144,12 +144,12 @@ _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) } } -static bool +static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; + ItemPointer current; current = &(scan->currentItemData); if (ItemPointerIsValid(current) diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 0a42ad0506..7c3b91b9c0 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.11 1997/09/07 04:38:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.12 1997/09/08 02:20:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ _hash_search(Relation rel, Buffer * bufP, HashMetaPage metap) { - BlockNumber blkno; - Datum keyDatum; - Bucket bucket; + BlockNumber blkno; + Datum keyDatum; + Bucket bucket; if (scankey == (ScanKey) NULL || (keyDatum = scankey[0].sk_argument) == (Datum) NULL) @@ -70,16 +70,16 @@ _hash_search(Relation rel, RetrieveIndexResult _hash_next(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Buffer metabuf; - Page page; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Buffer metabuf; + Page page; + OffsetNumber offnum; RetrieveIndexResult res; - ItemPointer current; - HashItem hitem; - IndexTuple itup; - HashScanOpaque so; + ItemPointer current; + HashItem hitem; + IndexTuple itup; + HashScanOpaque so; rel = scan->relation; so = (HashScanOpaque) scan->opaque; @@ -129,7 +129,7 @@ static void _hash_readnext(Relation rel, Buffer * bufp, Page * pagep, HashPageOpaque * opaquep) { - BlockNumber blkno; + BlockNumber blkno; blkno = (*opaquep)->hasho_nextblkno; _hash_relbuf(rel, *bufp, HASH_READ); @@ -148,7 +148,7 @@ static void _hash_readprev(Relation rel, Buffer * bufp, Page * pagep, HashPageOpaque * opaquep) { - BlockNumber blkno; + BlockNumber blkno; blkno = (*opaquep)->hasho_prevblkno; _hash_relbuf(rel, *bufp, HASH_READ); @@ -180,18 +180,18 @@ _hash_readprev(Relation rel, RetrieveIndexResult _hash_first(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Buffer metabuf; - Page page; - HashPageOpaque opaque; - HashMetaPage metap; - HashItem hitem; - IndexTuple itup; - ItemPointer current; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Buffer metabuf; + Page page; + HashPageOpaque opaque; + HashMetaPage metap; + HashItem hitem; + IndexTuple itup; + ItemPointer current; + OffsetNumber offnum; RetrieveIndexResult res; - HashScanOpaque so; + HashScanOpaque so; rel = scan->relation; so = (HashScanOpaque) scan->opaque; @@ -286,20 +286,20 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) bool _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf) { - Relation rel; - ItemPointer current; - HashScanOpaque so; - int allbuckets; - HashMetaPage metap; - Buffer buf; - Page page; - HashPageOpaque opaque; - OffsetNumber maxoff; - OffsetNumber offnum; - Bucket bucket; - BlockNumber blkno; - HashItem hitem; - IndexTuple itup; + Relation rel; + ItemPointer current; + HashScanOpaque so; + int allbuckets; + HashMetaPage metap; + Buffer buf; + Page page; + HashPageOpaque opaque; + OffsetNumber maxoff; + OffsetNumber offnum; + Bucket bucket; + BlockNumber blkno; + HashItem hitem; + IndexTuple itup; rel = scan->relation; current = &(scan->currentItemData); @@ -341,107 +341,107 @@ _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf) switch (dir) { - case ForwardScanDirection: - if (offnum != InvalidOffsetNumber) - { - offnum = OffsetNumberNext(offnum); /* move forward */ - } - else - { - offnum = FirstOffsetNumber; /* new page */ - } - while (offnum > maxoff) - { + case ForwardScanDirection: + if (offnum != InvalidOffsetNumber) + { + offnum = OffsetNumberNext(offnum); /* move forward */ + } + else + { + offnum = FirstOffsetNumber; /* new page */ + } + while (offnum > maxoff) + { - /* - * either this page is empty (maxoff == - * InvalidOffsetNumber) or we ran off the end. - */ - _hash_readnext(rel, &buf, &page, &opaque); - if (BufferIsInvalid(buf)) - { /* end of chain */ - if (allbuckets && bucket < metap->hashm_maxbucket) - { - ++bucket; - blkno = BUCKET_TO_BLKNO(bucket); - buf = _hash_getbuf(rel, blkno, HASH_READ); - page = BufferGetPage(buf); - _hash_checkpage(page, LH_BUCKET_PAGE); - opaque = (HashPageOpaque) PageGetSpecialPointer(page); - Assert(opaque->hasho_bucket == bucket); - while (PageIsEmpty(page) && + /* + * either this page is empty (maxoff == + * InvalidOffsetNumber) or we ran off the end. + */ + _hash_readnext(rel, &buf, &page, &opaque); + if (BufferIsInvalid(buf)) + { /* end of chain */ + if (allbuckets && bucket < metap->hashm_maxbucket) + { + ++bucket; + blkno = BUCKET_TO_BLKNO(bucket); + buf = _hash_getbuf(rel, blkno, HASH_READ); + page = BufferGetPage(buf); + _hash_checkpage(page, LH_BUCKET_PAGE); + opaque = (HashPageOpaque) PageGetSpecialPointer(page); + Assert(opaque->hasho_bucket == bucket); + while (PageIsEmpty(page) && BlockNumberIsValid(opaque->hasho_nextblkno)) + { + _hash_readnext(rel, &buf, &page, &opaque); + } + maxoff = PageGetMaxOffsetNumber(page); + offnum = FirstOffsetNumber; + } + else { - _hash_readnext(rel, &buf, &page, &opaque); + maxoff = offnum = InvalidOffsetNumber; + break; /* while */ } - maxoff = PageGetMaxOffsetNumber(page); - offnum = FirstOffsetNumber; } else { - maxoff = offnum = InvalidOffsetNumber; - break; /* while */ + /* _hash_readnext never returns an empty page */ + maxoff = PageGetMaxOffsetNumber(page); + offnum = FirstOffsetNumber; } } + break; + case BackwardScanDirection: + if (offnum != InvalidOffsetNumber) + { + offnum = OffsetNumberPrev(offnum); /* move back */ + } else { - /* _hash_readnext never returns an empty page */ - maxoff = PageGetMaxOffsetNumber(page); - offnum = FirstOffsetNumber; + offnum = maxoff; /* new page */ } - } - break; - case BackwardScanDirection: - if (offnum != InvalidOffsetNumber) - { - offnum = OffsetNumberPrev(offnum); /* move back */ - } - else - { - offnum = maxoff;/* new page */ - } - while (offnum < FirstOffsetNumber) - { + while (offnum < FirstOffsetNumber) + { - /* - * either this page is empty (offnum == - * InvalidOffsetNumber) or we ran off the end. - */ - _hash_readprev(rel, &buf, &page, &opaque); - if (BufferIsInvalid(buf)) - { /* end of chain */ - if (allbuckets && bucket > 0) - { - --bucket; - blkno = BUCKET_TO_BLKNO(bucket); - buf = _hash_getbuf(rel, blkno, HASH_READ); - page = BufferGetPage(buf); - _hash_checkpage(page, LH_BUCKET_PAGE); - opaque = (HashPageOpaque) PageGetSpecialPointer(page); - Assert(opaque->hasho_bucket == bucket); - while (BlockNumberIsValid(opaque->hasho_nextblkno)) + /* + * either this page is empty (offnum == + * InvalidOffsetNumber) or we ran off the end. + */ + _hash_readprev(rel, &buf, &page, &opaque); + if (BufferIsInvalid(buf)) + { /* end of chain */ + if (allbuckets && bucket > 0) { - _hash_readnext(rel, &buf, &page, &opaque); + --bucket; + blkno = BUCKET_TO_BLKNO(bucket); + buf = _hash_getbuf(rel, blkno, HASH_READ); + page = BufferGetPage(buf); + _hash_checkpage(page, LH_BUCKET_PAGE); + opaque = (HashPageOpaque) PageGetSpecialPointer(page); + Assert(opaque->hasho_bucket == bucket); + while (BlockNumberIsValid(opaque->hasho_nextblkno)) + { + _hash_readnext(rel, &buf, &page, &opaque); + } + maxoff = offnum = PageGetMaxOffsetNumber(page); + } + else + { + maxoff = offnum = InvalidOffsetNumber; + break; /* while */ } - maxoff = offnum = PageGetMaxOffsetNumber(page); } else { - maxoff = offnum = InvalidOffsetNumber; - break; /* while */ + /* _hash_readprev never returns an empty page */ + maxoff = offnum = PageGetMaxOffsetNumber(page); } } - else - { - /* _hash_readprev never returns an empty page */ - maxoff = offnum = PageGetMaxOffsetNumber(page); - } - } - break; - default: - /* NoMovementScanDirection */ - /* this should not be reached */ - break; + break; + default: + /* NoMovementScanDirection */ + /* this should not be reached */ + break; } /* we ran off the end of the world without finding a match */ diff --git a/src/backend/access/hash/hashstrat.c b/src/backend/access/hash/hashstrat.c index f1bdbdb8a3..a3a3656d76 100644 --- a/src/backend/access/hash/hashstrat.c +++ b/src/backend/access/hash/hashstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.10 1997/09/07 04:38:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.11 1997/09/08 02:20:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,12 +52,12 @@ static StrategyEvaluationData HTEvaluationData = { */ #ifdef NOT_USED -static StrategyNumber +static StrategyNumber _hash_getstrat(Relation rel, AttrNumber attno, RegProcedure proc) { - StrategyNumber strat; + StrategyNumber strat; strat = RelationGetStrategy(rel, attno, &HTEvaluationData, proc); @@ -69,7 +69,7 @@ _hash_getstrat(Relation rel, #endif #ifdef NOT_USED -static bool +static bool _hash_invokestrat(Relation rel, AttrNumber attno, StrategyNumber strat, diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index f9fbe0e2d1..573c6c2dd4 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.10 1997/09/07 04:38:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.11 1997/09/08 02:20:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ ScanKey _hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap) { - ScanKey skey; - TupleDesc itupdesc; - int natts; - AttrNumber i; - Datum arg; - RegProcedure proc; - bool null; + ScanKey skey; + TupleDesc itupdesc; + int natts; + AttrNumber i; + Datum arg; + RegProcedure proc; + bool null; natts = rel->rd_rel->relnatts; itupdesc = RelationGetTupleDescriptor(rel); @@ -73,9 +73,9 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup) HashItem _hash_formitem(IndexTuple itup) { - int nbytes_hitem; - HashItem hitem; - Size tuplen; + int nbytes_hitem; + HashItem hitem; + Size tuplen; /* disallow nulls in hash keys */ if (itup->t_info & INDEX_NULL_MASK) @@ -95,9 +95,9 @@ _hash_formitem(IndexTuple itup) Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key) { - uint32 n; - Bucket bucket; - RegProcedure proc; + uint32 n; + Bucket bucket; + RegProcedure proc; proc = metap->hashm_procid; n = (uint32) fmgr(proc, key); @@ -113,8 +113,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key) uint32 _hash_log2(uint32 num) { - uint32 i, - limit; + uint32 i, + limit; limit = 1; for (i = 0; limit < num; limit = limit << 1, i++) @@ -128,7 +128,7 @@ _hash_log2(uint32 num) void _hash_checkpage(Page page, int flags) { - HashPageOpaque opaque; + HashPageOpaque opaque; Assert(page); Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData))); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b7ab862514..fa4dbae7ae 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.16 1997/09/07 04:38:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.17 1997/09/08 02:20:28 momjian Exp $ * * * INTERFACE ROUTINES @@ -96,7 +96,7 @@ #include <string.h> #endif -static bool ImmediateInvalidation; +static bool ImmediateInvalidation; /* ---------------------------------------------------------------- * heap support routines @@ -210,7 +210,7 @@ nextpage(int page, int dir) * real work in scanning tuples. * ---------------- */ -static HeapTuple +static HeapTuple heapgettup(Relation relation, ItemPointer tid, int dir, @@ -219,14 +219,14 @@ heapgettup(Relation relation, int nkeys, ScanKey key) { - ItemId lpp; - Page dp; - int page; - int pages; - int lines; - HeapTuple rtup; - OffsetNumber lineoff; - int linesleft; + ItemId lpp; + Page dp; + int page; + int pages; + int lines; + HeapTuple rtup; + OffsetNumber lineoff; + int linesleft; /* ---------------- * increment access statistics @@ -432,7 +432,7 @@ heapgettup(Relation relation, if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp, timeQual, nkeys, key)) != NULL) { - ItemPointer iptr = &(rtup->t_ctid); + ItemPointer iptr = &(rtup->t_ctid); if (ItemPointerGetBlockNumber(iptr) != page) { @@ -541,7 +541,7 @@ SetHeapAccessMethodImmediateInvalidation(bool on) Relation heap_open(Oid relationId) { - Relation r; + Relation r; /* ---------------- * increment access statistics @@ -570,7 +570,7 @@ heap_open(Oid relationId) Relation heap_openr(char *relationName) { - Relation r; + Relation r; /* ---------------- * increment access statistics @@ -621,7 +621,7 @@ heap_beginscan(Relation relation, unsigned nkeys, ScanKey key) { - HeapScanDesc sdesc; + HeapScanDesc sdesc; /* ---------------- * increment access statistics @@ -808,7 +808,7 @@ heap_getnext(HeapScanDesc scandesc, Buffer * b) { register HeapScanDesc sdesc = scandesc; - Buffer localb; + Buffer localb; /* ---------------- * increment access statistics @@ -880,7 +880,7 @@ heap_getnext(HeapScanDesc scandesc, } else { /* NONTUP */ - ItemPointer iptr; + ItemPointer iptr; iptr = (sdesc->rs_ctup != NULL) ? &(sdesc->rs_ctup->t_ctid) : (ItemPointer) NULL; @@ -967,7 +967,7 @@ heap_getnext(HeapScanDesc scandesc, } else { /* NONTUP */ - ItemPointer iptr; + ItemPointer iptr; iptr = (sdesc->rs_ctup != NULL) ? &sdesc->rs_ctup->t_ctid : (ItemPointer) NULL; @@ -1035,11 +1035,11 @@ heap_fetch(Relation relation, ItemPointer tid, Buffer * b) { - ItemId lp; - Buffer buffer; - PageHeader dp; - HeapTuple tuple; - OffsetNumber offnum; + ItemId lp; + Buffer buffer; + PageHeader dp; + HeapTuple tuple; + OffsetNumber offnum; /* ---------------- * increment access statistics @@ -1203,10 +1203,10 @@ heap_insert(Relation relation, HeapTuple tup) int heap_delete(Relation relation, ItemPointer tid) { - ItemId lp; - HeapTuple tp; - PageHeader dp; - Buffer b; + ItemId lp; + HeapTuple tp; + PageHeader dp; + Buffer b; /* ---------------- * increment access statistics @@ -1313,10 +1313,10 @@ heap_delete(Relation relation, ItemPointer tid) int heap_replace(Relation relation, ItemPointer otid, HeapTuple tup) { - ItemId lp; - HeapTuple tp; - Page dp; - Buffer buffer; + ItemId lp; + HeapTuple tp; + Page dp; + Buffer buffer; /* ---------------- * increment access statistics diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 0854b69bf0..21202b1537 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.10 1997/09/07 04:38:11 momjian Exp $ + * $Id: hio.c,v 1.11 1997/09/08 02:20:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,13 +35,13 @@ RelationPutHeapTuple(Relation relation, BlockNumber blockIndex, HeapTuple tuple) { - Buffer buffer; - Page pageHeader; - BlockNumber numberOfBlocks; - OffsetNumber offnum; - unsigned int len; - ItemId itemId; - Item item; + Buffer buffer; + Page pageHeader; + BlockNumber numberOfBlocks; + OffsetNumber offnum; + unsigned int len; + ItemId itemId; + Item item; /* ---------------- * increment access statistics @@ -108,13 +108,13 @@ RelationPutHeapTuple(Relation relation, void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) { - Buffer buffer; - Page pageHeader; - BlockNumber lastblock; - OffsetNumber offnum; - unsigned int len; - ItemId itemId; - Item item; + Buffer buffer; + Page pageHeader; + BlockNumber lastblock; + OffsetNumber offnum; + unsigned int len; + ItemId itemId; + Item item; Assert(RelationIsValid(relation)); Assert(HeapTupleIsValid(tuple)); diff --git a/src/backend/access/heap/stats.c b/src/backend/access/heap/stats.c index aa16803779..2bebfd9b0b 100644 --- a/src/backend/access/heap/stats.c +++ b/src/backend/access/heap/stats.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.12 1997/09/07 04:38:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.13 1997/09/08 02:20:31 momjian Exp $ * * NOTES * initam should be moved someplace else. @@ -28,7 +28,7 @@ #include <string.h> #endif -static void InitHeapAccessStatistics(void); +static void InitHeapAccessStatistics(void); /* ---------------- * InitHeapAccessStatistics @@ -39,7 +39,7 @@ HeapAccessStatistics heap_access_stats = (HeapAccessStatistics) NULL; static void InitHeapAccessStatistics() { - MemoryContext oldContext; + MemoryContext oldContext; HeapAccessStatistics stats; /* ---------------- diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index da7fc0dc09..83655b7d61 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.8 1997/09/07 04:38:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.9 1997/09/08 02:20:33 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -98,7 +98,7 @@ RelationGetIndexScan(Relation relation, uint16 numberOfKeys, ScanKey key) { - IndexScanDesc scan; + IndexScanDesc scan; if (!RelationIsValid(relation)) elog(WARN, "RelationGetIndexScan: relation invalid"); diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 6841899fa3..9d0eee39b6 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.14 1997/09/07 04:38:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.15 1997/09/08 02:20:37 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relationId @@ -167,7 +167,7 @@ index_insert(Relation relation, ItemPointer heap_t_ctid, Relation heapRel) { - RegProcedure procedure; + RegProcedure procedure; InsertIndexResult specificResult; RELATION_CHECKS; @@ -207,7 +207,7 @@ index_insert(Relation relation, void index_delete(Relation relation, ItemPointer indexItem) { - RegProcedure procedure; + RegProcedure procedure; RELATION_CHECKS; GET_REL_PROCEDURE(delete, amdelete); @@ -225,8 +225,8 @@ index_beginscan(Relation relation, uint16 numberOfKeys, ScanKey key) { - IndexScanDesc scandesc; - RegProcedure procedure; + IndexScanDesc scandesc; + RegProcedure procedure; RELATION_CHECKS; GET_REL_PROCEDURE(beginscan, ambeginscan); @@ -246,7 +246,7 @@ index_beginscan(Relation relation, void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(rescan, amrescan); @@ -261,7 +261,7 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key) void index_endscan(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(endscan, amendscan); @@ -279,7 +279,7 @@ index_endscan(IndexScanDesc scan) void index_markpos(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(markpos, ammarkpos); @@ -297,7 +297,7 @@ index_markpos(IndexScanDesc scan) void index_restrpos(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(restrpos, amrestrpos); @@ -317,7 +317,7 @@ RetrieveIndexResult index_getnext(IndexScanDesc scan, ScanDirection direction) { - RegProcedure procedure; + RegProcedure procedure; RetrieveIndexResult result; SCAN_CHECKS; @@ -354,8 +354,8 @@ index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum) { - RegProcedure *loc; - int natts; + RegProcedure *loc; + int natts; natts = irel->rd_rel->relnatts; @@ -375,13 +375,13 @@ GetIndexValue(HeapTuple tuple, bool * attNull, Buffer buffer) { - Datum returnVal; - bool isNull; + Datum returnVal; + bool isNull; if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid) { - int i; - Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum)); + int i; + Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum)); for (i = 0; i < FIgetnArgs(fInfo); i++) { diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c index 35158c2217..9cc9c06e98 100644 --- a/src/backend/access/index/istrat.c +++ b/src/backend/access/index/istrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.10 1997/09/07 04:38:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.11 1997/09/08 02:20:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ #include <fmgr.h> #ifndef NO_ASSERT_CHECKING -static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); +static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); static bool StrategyExpressionIsValid(StrategyExpression expression, StrategyNumber maxStrategy); @@ -68,7 +68,7 @@ StrategyTermIsValid(StrategyTerm term, * Assumes that the index strategy number is valid. * Bounds checking should be done outside this routine. */ -static ScanKey +static ScanKey StrategyMapGetScanKeyEntry(StrategyMap map, StrategyNumber strategyNumber) { @@ -122,7 +122,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber, * StrategyOperatorIsValid * ---------------- */ -static bool +static bool StrategyOperatorIsValid(StrategyOperator operator, StrategyNumber maxStrategy) { @@ -136,11 +136,11 @@ StrategyOperatorIsValid(StrategyOperator operator, * StrategyTermIsValid * ---------------- */ -static bool +static bool StrategyTermIsValid(StrategyTerm term, StrategyNumber maxStrategy) { - Index index; + Index index; if (!PointerIsValid(term) || term->degree == 0) return false; @@ -162,11 +162,11 @@ StrategyTermIsValid(StrategyTerm term, * StrategyExpressionIsValid * ---------------- */ -static bool +static bool StrategyExpressionIsValid(StrategyExpression expression, StrategyNumber maxStrategy) { - StrategyTerm *termP; + StrategyTerm *termP; if (!PointerIsValid(expression)) return true; @@ -186,10 +186,10 @@ StrategyExpressionIsValid(StrategyExpression expression, * StrategyEvaluationIsValid * ---------------- */ -static bool +static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation) { - Index index; + Index index; if (!PointerIsValid(evaluation) || !StrategyNumberIsValid(evaluation->maxStrategy) || @@ -219,17 +219,17 @@ StrategyEvaluationIsValid(StrategyEvaluation evaluation) * StrategyTermEvaluate * ---------------- */ -static bool +static bool StrategyTermEvaluate(StrategyTerm term, StrategyMap map, Datum left, Datum right) { - Index index; - long tmpres = 0; - bool result = 0; + Index index; + long tmpres = 0; + bool result = 0; StrategyOperator operator; - ScanKey entry; + ScanKey entry; for (index = 0, operator = &term->operatorData[0]; index < term->degree; index += 1, operator += 1) @@ -241,29 +241,29 @@ StrategyTermEvaluate(StrategyTerm term, switch (operator->flags ^ entry->sk_flags) { - case 0x0: - tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, - left, right); - break; - - case SK_NEGATE: - tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, - left, right); - break; - - case SK_COMMUTE: - tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, - right, left); - break; - - case SK_NEGATE | SK_COMMUTE: - tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, - right, left); - break; - - default: - elog(FATAL, "StrategyTermEvaluate: impossible case %d", - operator->flags ^ entry->sk_flags); + case 0x0: + tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, + left, right); + break; + + case SK_NEGATE: + tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, + left, right); + break; + + case SK_COMMUTE: + tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, + right, left); + break; + + case SK_NEGATE | SK_COMMUTE: + tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, + right, left); + break; + + default: + elog(FATAL, "StrategyTermEvaluate: impossible case %d", + operator->flags ^ entry->sk_flags); } result = (bool) tmpres; @@ -285,11 +285,11 @@ RelationGetStrategy(Relation relation, StrategyEvaluation evaluation, RegProcedure procedure) { - StrategyNumber strategy; - StrategyMap strategyMap; - ScanKey entry; - Index index; - int numattrs; + StrategyNumber strategy; + StrategyMap strategyMap; + ScanKey entry; + Index index; + int numattrs; Assert(RelationIsValid(relation)); numattrs = RelationGetNumberOfAttributes(relation); @@ -325,23 +325,23 @@ RelationGetStrategy(Relation relation, switch (entry->sk_flags & (SK_NEGATE | SK_COMMUTE)) { - case 0x0: - return strategy; + case 0x0: + return strategy; - case SK_NEGATE: - strategy = evaluation->negateTransform->strategy[strategy - 1]; - break; + case SK_NEGATE: + strategy = evaluation->negateTransform->strategy[strategy - 1]; + break; - case SK_COMMUTE: - strategy = evaluation->commuteTransform->strategy[strategy - 1]; - break; + case SK_COMMUTE: + strategy = evaluation->commuteTransform->strategy[strategy - 1]; + break; - case SK_NEGATE | SK_COMMUTE: - strategy = evaluation->negateCommuteTransform->strategy[strategy - 1]; - break; + case SK_NEGATE | SK_COMMUTE: + strategy = evaluation->negateCommuteTransform->strategy[strategy - 1]; + break; - default: - elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags); + default: + elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags); } @@ -368,11 +368,11 @@ RelationInvokeStrategy(Relation relation, Datum left, Datum right) { - StrategyNumber newStrategy; - StrategyMap strategyMap; - ScanKey entry; + StrategyNumber newStrategy; + StrategyMap strategyMap; + ScanKey entry; StrategyTermData termData; - int numattrs; + int numattrs; Assert(RelationIsValid(relation)); Assert(relation->rd_rel->relkind == RELKIND_INDEX); /* XXX use accessor */ @@ -453,12 +453,12 @@ RelationInvokeStrategy(Relation relation, if (PointerIsValid(evaluation->expression[strategy - 1])) { - StrategyTerm *termP; + StrategyTerm *termP; termP = &evaluation->expression[strategy - 1]->term[0]; while (PointerIsValid(*termP)) { - Index index; + Index index; for (index = 0; index < (*termP)->degree; index += 1) { @@ -499,9 +499,9 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, Oid operatorObjectId, ScanKey entry) { - HeapScanDesc scan; - ScanKeyData scanKeyData; - HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData scanKeyData; + HeapTuple tuple; ScanKeyEntryInitialize(&scanKeyData, 0, ObjectIdAttributeNumber, @@ -547,15 +547,15 @@ IndexSupportInitialize(IndexStrategy indexStrategy, StrategyNumber maxSupportNumber, AttrNumber maxAttributeNumber) { - Relation relation; - Relation operatorRelation; - HeapScanDesc scan; - HeapTuple tuple; - ScanKeyData entry[2]; - StrategyMap map; - AttrNumber attributeNumber; - int attributeIndex; - Oid operatorClassObjectId[MaxIndexAttributeNumber]; + Relation relation; + Relation operatorRelation; + HeapScanDesc scan; + HeapTuple tuple; + ScanKeyData entry[2]; + StrategyMap map; + AttrNumber attributeNumber; + int attributeIndex; + Oid operatorClassObjectId[MaxIndexAttributeNumber]; maxStrategyNumber = AMStrategies(maxStrategyNumber); @@ -575,7 +575,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, */ for (attributeIndex = 0; attributeIndex < maxAttributeNumber; attributeIndex++) { - IndexTupleForm iform; + IndexTupleForm iform; iform = (IndexTupleForm) GETSTRUCT(tuple); @@ -614,9 +614,9 @@ IndexSupportInitialize(IndexStrategy indexStrategy, attributeNumber--) { - int16 support; - Form_pg_amproc form; - RegProcedure *loc; + int16 support; + Form_pg_amproc form; + RegProcedure *loc; loc = &indexSupport[((attributeNumber - 1) * maxSupportNumber)]; @@ -659,7 +659,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, attributeNumber--) { - StrategyNumber strategy; + StrategyNumber strategy; entry[1].sk_argument = ObjectIdGetDatum(operatorClassObjectId[attributeNumber - 1]); @@ -676,7 +676,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, while (tuple = heap_getnext(scan, 0, (Buffer *) NULL), HeapTupleIsValid(tuple)) { - Form_pg_amop form; + Form_pg_amop form; form = (Form_pg_amop) GETSTRUCT(tuple); @@ -702,9 +702,9 @@ IndexStrategyDisplay(IndexStrategy indexStrategy, StrategyNumber numberOfStrategies, int numberOfAttributes) { - StrategyMap strategyMap; - AttrNumber attributeNumber; - StrategyNumber strategyNumber; + StrategyMap strategyMap; + AttrNumber attributeNumber; + StrategyNumber strategyNumber; for (attributeNumber = 1; attributeNumber <= numberOfAttributes; attributeNumber += 1) diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index 0312bbb69d..f107e2138a 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.11 1997/09/07 04:38:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.12 1997/09/08 02:20:44 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -134,13 +134,13 @@ btnamecmp(NameData * a, NameData * b) int32 bttextcmp(struct varlena * a, struct varlena * b) { - int res; - unsigned char *ap, - *bp; + int res; + unsigned char *ap, + *bp; #ifdef USE_LOCALE - int la = VARSIZE(a) - VARHDRSZ; - int lb = VARSIZE(b) - VARHDRSZ; + int la = VARSIZE(a) - VARHDRSZ; + int lb = VARSIZE(b) - VARHDRSZ; ap = (unsigned char *) palloc(la + 1); bp = (unsigned char *) palloc(lb + 1); @@ -156,7 +156,7 @@ bttextcmp(struct varlena * a, struct varlena * b) pfree(bp); #else - int len = VARSIZE(a); + int len = VARSIZE(a); /* len is the length of the shorter of the two strings */ if (len > VARSIZE(b)) diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 4bafbc2ddb..53c56d43ec 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.18 1997/09/07 04:38:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.19 1997/09/08 02:20:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ #endif static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem); -static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright); +static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright); static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit); -static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf); +static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf); static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem); -static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem); -static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem); -static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey); +static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem); +static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem); +static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey); /* * _bt_doinsert() -- Handle insertion of a single btitem in the tree. @@ -46,12 +46,12 @@ static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int InsertIndexResult _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel) { - ScanKey itup_scankey; - IndexTuple itup; - BTStack stack; - Buffer buf; - BlockNumber blkno; - int natts = rel->rd_rel->relnatts; + ScanKey itup_scankey; + IndexTuple itup; + BTStack stack; + Buffer buf; + BlockNumber blkno; + int natts = rel->rd_rel->relnatts; InsertIndexResult res; itup = &(btitem->bti_itup); @@ -82,9 +82,9 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel /* already in the node */ if (index_is_unique) { - OffsetNumber offset, - maxoff; - Page page; + OffsetNumber offset, + maxoff; + Page page; page = BufferGetPage(buf); maxoff = PageGetMaxOffsetNumber(page); @@ -95,13 +95,13 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel /* key on the page before trying to compare it */ if (!PageIsEmpty(page) && offset <= maxoff) { - TupleDesc itupdesc; - BTItem btitem; - IndexTuple itup; - HeapTuple htup; - BTPageOpaque opaque; - Buffer nbuf; - BlockNumber blkno; + TupleDesc itupdesc; + BTItem btitem; + IndexTuple itup; + HeapTuple htup; + BTPageOpaque opaque; + Buffer nbuf; + BlockNumber blkno; itupdesc = RelationGetTupleDescriptor(rel); nbuf = InvalidBuffer; @@ -213,7 +213,7 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel * 'afteritem' parameter to position ourselves correctly for the * insertion on internal pages. */ -static InsertIndexResult +static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, @@ -223,14 +223,14 @@ _bt_insertonpg(Relation rel, BTItem afteritem) { InsertIndexResult res; - Page page; - BTPageOpaque lpageop; - BlockNumber itup_blkno; - OffsetNumber itup_off; - OffsetNumber firstright = InvalidOffsetNumber; - int itemsz; - bool do_split = false; - bool keys_equal = false; + Page page; + BTPageOpaque lpageop; + BlockNumber itup_blkno; + OffsetNumber itup_off; + OffsetNumber firstright = InvalidOffsetNumber; + int itemsz; + bool do_split = false; + bool keys_equal = false; page = BufferGetPage(buf); lpageop = (BTPageOpaque) PageGetSpecialPointer(page); @@ -251,9 +251,9 @@ _bt_insertonpg(Relation rel, */ if (lpageop->btpo_flags & BTP_CHAIN) { - OffsetNumber maxoff = PageGetMaxOffsetNumber(page); - ItemId hitemid; - BTItem hitem; + OffsetNumber maxoff = PageGetMaxOffsetNumber(page); + ItemId hitemid; + BTItem hitem; Assert(!P_RIGHTMOST(lpageop)); hitemid = PageGetItemId(page, P_HIKEY); @@ -280,8 +280,8 @@ _bt_insertonpg(Relation rel, else /* "eat" page */ { - Buffer pbuf; - Page ppage; + Buffer pbuf; + Page ppage; itup_blkno = BufferGetBlockNumber(buf); itup_off = PageAddItem(page, (Item) btitem, itemsz, @@ -315,13 +315,13 @@ _bt_insertonpg(Relation rel, do_split = true; else if (PageGetFreeSpace(page) < 3 * itemsz + 2 * sizeof(ItemIdData)) { - OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; - OffsetNumber maxoff = PageGetMaxOffsetNumber(page); - ItemId itid; - BTItem previtem, - chkitem; - Size maxsize; - Size currsize; + OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; + OffsetNumber maxoff = PageGetMaxOffsetNumber(page); + ItemId itid; + BTItem previtem, + chkitem; + Size maxsize; + Size currsize; itid = PageGetItemId(page, offnum); previtem = (BTItem) PageGetItem(page, itid); @@ -351,19 +351,19 @@ _bt_insertonpg(Relation rel, if (do_split) { - Buffer rbuf; - Page rpage; - BTItem ritem; - BlockNumber rbknum; - BTPageOpaque rpageop; - Buffer pbuf; - Page ppage; - BTPageOpaque ppageop; - BlockNumber bknum = BufferGetBlockNumber(buf); - BTItem lowLeftItem; - OffsetNumber maxoff; - bool shifted = false; - bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false; + Buffer rbuf; + Page rpage; + BTItem ritem; + BlockNumber rbknum; + BTPageOpaque rpageop; + Buffer pbuf; + Page ppage; + BTPageOpaque ppageop; + BlockNumber bknum = BufferGetBlockNumber(buf); + BTItem lowLeftItem; + OffsetNumber maxoff; + bool shifted = false; + bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false; /* * If we have to split leaf page in the chain of duplicates by new @@ -372,7 +372,7 @@ _bt_insertonpg(Relation rel, if ((lpageop->btpo_flags & BTP_CHAIN) && (lpageop->btpo_flags & BTP_LEAF) && keys_equal) { - bool use_left = true; + bool use_left = true; rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE); rpage = BufferGetPage(rbuf); @@ -429,8 +429,8 @@ _bt_insertonpg(Relation rel, */ else if (!(lpageop->btpo_flags & BTP_CHAIN)) { - OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; - Size llimit; + OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; + Size llimit; maxoff = PageGetMaxOffsetNumber(page); llimit = PageGetPageSize(page) - sizeof(PageHeaderData) - @@ -547,13 +547,13 @@ _bt_insertonpg(Relation rel, } else { - ScanKey newskey; + ScanKey newskey; InsertIndexResult newres; - BTItem new_item; - OffsetNumber upditem_offset = P_HIKEY; - bool do_update = false; - bool update_in_place = true; - bool parent_chained; + BTItem new_item; + OffsetNumber upditem_offset = P_HIKEY; + bool do_update = false; + bool update_in_place = true; + bool parent_chained; /* form a index tuple that points at the new right page */ rbknum = BufferGetBlockNumber(rbuf); @@ -790,27 +790,27 @@ _bt_insertonpg(Relation rel, * Returns the new right sibling of buf, pinned and write-locked. The * pin and lock on buf are maintained. */ -static Buffer +static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) { - Buffer rbuf; - Page origpage; - Page leftpage, - rightpage; - BTPageOpaque ropaque, - lopaque, - oopaque; - Buffer sbuf; - Page spage; - BTPageOpaque sopaque; - Size itemsz; - ItemId itemid; - BTItem item; - OffsetNumber leftoff, - rightoff; - OffsetNumber start; - OffsetNumber maxoff; - OffsetNumber i; + Buffer rbuf; + Page origpage; + Page leftpage, + rightpage; + BTPageOpaque ropaque, + lopaque, + oopaque; + Buffer sbuf; + Page spage; + BTPageOpaque sopaque; + Size itemsz; + ItemId itemid; + BTItem item; + OffsetNumber leftoff, + rightoff; + OffsetNumber start; + OffsetNumber maxoff; + OffsetNumber i; rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); origpage = BufferGetPage(buf); @@ -871,7 +871,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) maxoff = PageGetMaxOffsetNumber(origpage); if (firstright == InvalidOffsetNumber) { - Size llimit = PageGetFreeSpace(leftpage) / 2; + Size llimit = PageGetFreeSpace(leftpage) / 2; firstright = _bt_findsplitloc(rel, origpage, start, maxoff, llimit); } @@ -987,21 +987,21 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) * may be split as * [2 2 2 2] [2 3 4]. */ -static OffsetNumber +static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit) { - OffsetNumber i; - OffsetNumber saferight; - ItemId nxtitemid, - safeitemid; - BTItem safeitem, - nxtitem; - Size nbytes; - int natts; + OffsetNumber i; + OffsetNumber saferight; + ItemId nxtitemid, + safeitemid; + BTItem safeitem, + nxtitem; + Size nbytes; + int natts; if (start >= maxoff) elog(FATAL, "btree: cannot split if start (%d) >= maxoff (%d)", @@ -1072,18 +1072,18 @@ _bt_findsplitloc(Relation rel, static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) { - Buffer rootbuf; - Page lpage, - rpage, - rootpage; - BlockNumber lbkno, - rbkno; - BlockNumber rootbknum; - BTPageOpaque rootopaque; - ItemId itemid; - BTItem item; - Size itemsz; - BTItem new_item; + Buffer rootbuf; + Page lpage, + rpage, + rootpage; + BlockNumber lbkno, + rbkno; + BlockNumber rootbknum; + BTPageOpaque rootopaque; + ItemId itemid; + BTItem item; + Size itemsz; + BTItem new_item; /* get a new root page */ rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); @@ -1158,7 +1158,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) * to follow. Otherwise, we do a binary search for the correct place * and insert the new item there. */ -static OffsetNumber +static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, @@ -1167,11 +1167,11 @@ _bt_pgaddtup(Relation rel, BTItem btitem, BTItem afteritem) { - OffsetNumber itup_off; - OffsetNumber first; - Page page; - BTPageOpaque opaque; - BTItem chkitem; + OffsetNumber itup_off; + OffsetNumber first; + Page page; + BTPageOpaque opaque; + BTItem chkitem; page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -1213,20 +1213,20 @@ _bt_pgaddtup(Relation rel, * + the item it is to follow ("afteritem") appears on this * page. */ -static bool +static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem) { - Page page; - ItemId hikey; - BTPageOpaque opaque; - BTItem chkitem; - OffsetNumber offnum, - maxoff; - bool found; + Page page; + ItemId hikey; + BTPageOpaque opaque; + BTItem chkitem; + OffsetNumber offnum, + maxoff; + bool found; page = BufferGetPage(buf); @@ -1314,16 +1314,16 @@ _bt_itemcmp(Relation rel, BTItem item2, StrategyNumber strat) { - TupleDesc tupDes; - IndexTuple indexTuple1, - indexTuple2; - Datum attrDatum1, - attrDatum2; - int i; - bool isFirstNull, - isSecondNull; - bool compare; - bool useEqual = false; + TupleDesc tupDes; + IndexTuple indexTuple1, + indexTuple2; + Datum attrDatum1, + attrDatum2; + int i; + bool isFirstNull, + isSecondNull; + bool compare; + bool useEqual = false; if (strat == BTLessEqualStrategyNumber) { @@ -1406,14 +1406,14 @@ _bt_updateitem(Relation rel, BTItem oldItem, BTItem newItem) { - Page page; - OffsetNumber maxoff; - OffsetNumber i; + Page page; + OffsetNumber maxoff; + OffsetNumber i; ItemPointerData itemPtrData; - BTItem item; - IndexTuple oldIndexTuple, - newIndexTuple; - int first; + BTItem item; + IndexTuple oldIndexTuple, + newIndexTuple; + int first; page = BufferGetPage(buf); maxoff = PageGetMaxOffsetNumber(page); @@ -1460,18 +1460,18 @@ _bt_updateitem(Relation rel, * * Rule is simple: NOT_NULL not equal NULL, NULL not_equal NULL too. */ -static bool +static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey) { - Datum datum; - BTItem btitem; - IndexTuple itup; - ScanKey entry; - AttrNumber attno; - long result; - int i; - bool null; + Datum datum; + BTItem btitem; + IndexTuple itup; + ScanKey entry; + AttrNumber attno; + long result; + int i; + bool null; btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum)); itup = &(btitem->bti_itup); @@ -1504,27 +1504,27 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, * * NOTE: tested for shifting leftmost page only, having btitem < hikey. */ -static InsertIndexResult +static InsertIndexResult _bt_shift(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem hikey) { InsertIndexResult res; - int itemsz; - Page page; - BlockNumber bknum; - BTPageOpaque pageop; - Buffer rbuf; - Page rpage; - BTPageOpaque rpageop; - Buffer pbuf; - Page ppage; - BTPageOpaque ppageop; - Buffer nbuf; - Page npage; - BTPageOpaque npageop; - BlockNumber nbknum; - BTItem nitem; - OffsetNumber afteroff; + int itemsz; + Page page; + BlockNumber bknum; + BTPageOpaque pageop; + Buffer rbuf; + Page rpage; + BTPageOpaque rpageop; + Buffer pbuf; + Page ppage; + BTPageOpaque ppageop; + Buffer nbuf; + Page npage; + BTPageOpaque npageop; + BlockNumber nbknum; + BTItem nitem; + OffsetNumber afteroff; btitem = _bt_formitem(&(btitem->bti_itup)); hikey = _bt_formitem(&(hikey->bti_itup)); diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 6551af4c17..fe3bebbccd 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.10 1997/09/07 04:38:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.11 1997/09/08 02:20:49 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -36,8 +36,8 @@ #include <string.h> #endif -static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access); -static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); +static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access); +static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); #define BTREE_METAPAGE 0 #define BTREE_MAGIC 0x053162 @@ -50,18 +50,18 @@ static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); typedef struct BTMetaPageData { - uint32 btm_magic; - uint32 btm_version; - BlockNumber btm_root; + uint32 btm_magic; + uint32 btm_version; + BlockNumber btm_root; #ifdef BTREE_VERSION_1 - int32 btm_level; + int32 btm_level; #endif -} BTMetaPageData; +} BTMetaPageData; #define BTPageGetMeta(p) \ ((BTMetaPageData *) &((PageHeader) p)->pd_linp[0]) -extern bool BuildingBtree; +extern bool BuildingBtree; /* * We use high-concurrency locking on btrees. There are two cases in @@ -85,11 +85,11 @@ extern bool BuildingBtree; void _bt_metapinit(Relation rel) { - Buffer buf; - Page pg; - int nblocks; - BTMetaPageData metad; - BTPageOpaque op; + Buffer buf; + Page pg; + int nblocks; + BTMetaPageData metad; + BTPageOpaque op; /* can't be sharing this with anyone, now... */ if (USELOCKING) @@ -131,11 +131,11 @@ _bt_metapinit(Relation rel) void _bt_checkmeta(Relation rel) { - Buffer metabuf; - Page metap; + Buffer metabuf; + Page metap; BTMetaPageData *metad; - BTPageOpaque op; - int nblocks; + BTPageOpaque op; + int nblocks; /* if the relation is empty, this is init time; don't complain */ if ((nblocks = RelationGetNumberOfBlocks(rel)) == 0) @@ -187,13 +187,13 @@ _bt_checkmeta(Relation rel) Buffer _bt_getroot(Relation rel, int access) { - Buffer metabuf; - Page metapg; - BTPageOpaque metaopaque; - Buffer rootbuf; - Page rootpg; - BTPageOpaque rootopaque; - BlockNumber rootblkno; + Buffer metabuf; + Page metapg; + BTPageOpaque metaopaque; + Buffer rootbuf; + Page rootpg; + BTPageOpaque rootopaque; + BlockNumber rootblkno; BTMetaPageData *metad; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ); @@ -319,8 +319,8 @@ _bt_getroot(Relation rel, int access) Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access) { - Buffer buf; - Page page; + Buffer buf; + Page page; /* * If we want a new block, we can't set a lock of the appropriate type @@ -359,7 +359,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) void _bt_relbuf(Relation rel, Buffer buf, int access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); @@ -382,7 +382,7 @@ _bt_relbuf(Relation rel, Buffer buf, int access) void _bt_wrtbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteBuffer(buf); @@ -399,7 +399,7 @@ _bt_wrtbuf(Relation rel, Buffer buf) void _bt_wrtnorelbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteNoReleaseBuffer(buf); @@ -439,9 +439,9 @@ _bt_pageinit(Page page, Size size) void _bt_metaproot(Relation rel, BlockNumber rootbknum, int level) { - Buffer metabuf; - Page metap; - BTPageOpaque metaopaque; + Buffer metabuf; + Page metap; + BTPageOpaque metaopaque; BTMetaPageData *metad; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); @@ -473,18 +473,18 @@ _bt_metaproot(Relation rel, BlockNumber rootbknum, int level) Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access) { - Buffer buf; - BlockNumber blkno; - OffsetNumber start, - offnum, - maxoff; - OffsetNumber i; - Page page; - ItemId itemid; - BTItem item; - BTPageOpaque opaque; - BTItem item_save; - int item_nbytes; + Buffer buf; + BlockNumber blkno; + OffsetNumber start, + offnum, + maxoff; + OffsetNumber i; + Page page; + ItemId itemid; + BTItem item; + BTPageOpaque opaque; + BTItem item_save; + int item_nbytes; blkno = stack->bts_blkno; buf = _bt_getbuf(rel, blkno, access); @@ -603,10 +603,10 @@ _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access) void _bt_pagedel(Relation rel, ItemPointer tid) { - Buffer buf; - Page page; - BlockNumber blkno; - OffsetNumber offno; + Buffer buf; + Page page; + BlockNumber blkno; + OffsetNumber offno; blkno = ItemPointerGetBlockNumber(tid); offno = ItemPointerGetOffsetNumber(tid); diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index dccbd77b35..9f7b59327a 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.20 1997/09/07 04:38:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.21 1997/09/08 02:20:50 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -35,14 +35,14 @@ #ifdef BTREE_BUILD_STATS #include <tcop/tcopprot.h> -extern int ShowExecutorStats; +extern int ShowExecutorStats; #endif -bool BuildingBtree = false; /* see comment in btbuild() */ -bool FastBuild = true; /* use sort/build instead of - * insertion build */ +bool BuildingBtree = false; /* see comment in btbuild() */ +bool FastBuild = true; /* use sort/build instead of insertion + * build */ /* * btbuild() -- build a new btree index. @@ -63,33 +63,33 @@ btbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc hscan; - Buffer buffer; - HeapTuple htup; - IndexTuple itup; - TupleDesc htupdesc, - itupdesc; - Datum *attdata; - bool *nulls; + HeapScanDesc hscan; + Buffer buffer; + HeapTuple htup; + IndexTuple itup; + TupleDesc htupdesc, + itupdesc; + Datum *attdata; + bool *nulls; InsertIndexResult res = 0; - int nhtups, - nitups; - int i; - BTItem btitem; + int nhtups, + nitups; + int i; + BTItem btitem; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext = (ExprContext *) NULL; - TupleTable tupleTable = (TupleTable) NULL; + ExprContext *econtext = (ExprContext *) NULL; + TupleTable tupleTable = (TupleTable) NULL; TupleTableSlot *slot = (TupleTableSlot *) NULL; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - void *spool = (void *) NULL; - bool isunique; - bool usefast; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + void *spool = (void *) NULL; + bool isunique; + bool usefast; /* note that this is a new btree */ BuildingBtree = true; @@ -211,8 +211,8 @@ btbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -358,8 +358,8 @@ btbuild(Relation heap, InsertIndexResult btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { - BTItem btitem; - IndexTuple itup; + BTItem btitem; + IndexTuple itup; InsertIndexResult res; /* generate an index tuple */ @@ -389,7 +389,7 @@ btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation /* * btgettuple() -- Get the next tuple in the scan. */ -char * +char * btgettuple(IndexScanDesc scan, ScanDirection dir) { RetrieveIndexResult res; @@ -411,10 +411,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir) /* * btbeginscan() -- start a scan on a btree index */ -char * +char * btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) { - IndexScanDesc scan; + IndexScanDesc scan; /* get the scan */ scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey); @@ -431,8 +431,8 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -483,8 +483,8 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) void btmovescan(IndexScanDesc scan, Datum v) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -506,8 +506,8 @@ btmovescan(IndexScanDesc scan, Datum v) void btendscan(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -541,8 +541,8 @@ btendscan(IndexScanDesc scan) void btmarkpos(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -570,8 +570,8 @@ btmarkpos(IndexScanDesc scan) void btrestrpos(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; diff --git a/src/backend/access/nbtree/nbtscan.c b/src/backend/access/nbtree/nbtscan.c index 8a2042403a..4f3ee1ffe6 100644 --- a/src/backend/access/nbtree/nbtscan.c +++ b/src/backend/access/nbtree/nbtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.8 1997/09/07 04:38:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.9 1997/09/08 02:20:52 momjian Exp $ * * * NOTES @@ -34,16 +34,16 @@ typedef struct BTScanListData { - IndexScanDesc btsl_scan; + IndexScanDesc btsl_scan; struct BTScanListData *btsl_next; -} BTScanListData; +} BTScanListData; typedef BTScanListData *BTScanList; static BTScanList BTScans = (BTScanList) NULL; -static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno); -static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno); +static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); /* * _bt_regscan() -- register a new scan. @@ -51,7 +51,7 @@ static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber void _bt_regscan(IndexScanDesc scan) { - BTScanList new_el; + BTScanList new_el; new_el = (BTScanList) palloc(sizeof(BTScanListData)); new_el->btsl_scan = scan; @@ -65,8 +65,8 @@ _bt_regscan(IndexScanDesc scan) void _bt_dropscan(IndexScanDesc scan) { - BTScanList chk, - last; + BTScanList chk, + last; last = (BTScanList) NULL; for (chk = BTScans; @@ -94,8 +94,8 @@ _bt_dropscan(IndexScanDesc scan) void _bt_adjscans(Relation rel, ItemPointer tid, int op) { - BTScanList l; - Oid relid; + BTScanList l; + Oid relid; relid = rel->rd_id; for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next) @@ -130,9 +130,9 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op) static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; - Buffer buf; - BTScanOpaque so; + ItemPointer current; + Buffer buf; + BTScanOpaque so; if (!_bt_scantouched(scan, blkno, offno)) return; @@ -147,15 +147,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) { switch (op) { - case BT_INSERT: - _bt_step(scan, &buf, ForwardScanDirection); - break; - case BT_DELETE: - _bt_step(scan, &buf, BackwardScanDirection); - break; - default: - elog(WARN, "_bt_scandel: bad operation '%d'", op); - /* NOTREACHED */ + case BT_INSERT: + _bt_step(scan, &buf, ForwardScanDirection); + break; + case BT_DELETE: + _bt_step(scan, &buf, BackwardScanDirection); + break; + default: + elog(WARN, "_bt_scandel: bad operation '%d'", op); + /* NOTREACHED */ } so->btso_curbuf = buf; } @@ -172,15 +172,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) scan->currentItemData = tmp; switch (op) { - case BT_INSERT: - _bt_step(scan, &buf, ForwardScanDirection); - break; - case BT_DELETE: - _bt_step(scan, &buf, BackwardScanDirection); - break; - default: - elog(WARN, "_bt_scandel: bad operation '%d'", op); - /* NOTREACHED */ + case BT_INSERT: + _bt_step(scan, &buf, ForwardScanDirection); + break; + case BT_DELETE: + _bt_step(scan, &buf, BackwardScanDirection); + break; + default: + elog(WARN, "_bt_scandel: bad operation '%d'", op); + /* NOTREACHED */ } so->btso_mrkbuf = buf; tmp = *current; @@ -193,10 +193,10 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) * _bt_scantouched() -- check to see if a scan is affected by a given * change to the index */ -static bool +static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; + ItemPointer current; current = &(scan->currentItemData); if (ItemPointerIsValid(current) diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 8b1f75b753..50f2031779 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.24 1997/09/07 04:38:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.25 1997/09/08 02:20:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,19 +28,19 @@ #endif -static BTStack +static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey, Buffer * bufP, BTStack stack_in); -static OffsetNumber +static OffsetNumber _bt_firsteq(Relation rel, TupleDesc itupdesc, Page page, Size keysz, ScanKey scankey, OffsetNumber offnum); static int _bt_compare(Relation rel, TupleDesc itupdesc, Page page, int keysz, ScanKey scankey, OffsetNumber offnum); -static bool - _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); -static RetrieveIndexResult - _bt_endpoint(IndexScanDesc scan, ScanDirection dir); +static bool + _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); +static RetrieveIndexResult + _bt_endpoint(IndexScanDesc scan, ScanDirection dir); /* * _bt_search() -- Search for a scan key in the index. @@ -58,24 +58,24 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP) /* * _bt_searchr() -- Search the tree recursively for a particular scankey. */ -static BTStack +static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey, Buffer * bufP, BTStack stack_in) { - BTStack stack; - OffsetNumber offnum; - Page page; - BTPageOpaque opaque; - BlockNumber par_blkno; - BlockNumber blkno; - ItemId itemid; - BTItem btitem; - BTItem item_save; - int item_nbytes; - IndexTuple itup; + BTStack stack; + OffsetNumber offnum; + Page page; + BTPageOpaque opaque; + BlockNumber par_blkno; + BlockNumber blkno; + ItemId itemid; + BTItem btitem; + BTItem item_save; + int item_nbytes; + IndexTuple itup; /* if this is a leaf page, we're done */ page = BufferGetPage(*bufP); @@ -155,11 +155,11 @@ _bt_moveright(Relation rel, ScanKey scankey, int access) { - Page page; - BTPageOpaque opaque; - ItemId hikey; - BlockNumber rblkno; - int natts = rel->rd_rel->relnatts; + Page page; + BTPageOpaque opaque; + ItemId hikey; + BlockNumber rblkno; + int natts = rel->rd_rel->relnatts; page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -183,7 +183,7 @@ _bt_moveright(Relation rel, /* move right as long as we need to */ do { - OffsetNumber offmax = PageGetMaxOffsetNumber(page); + OffsetNumber offmax = PageGetMaxOffsetNumber(page); /* * If this page consists of all duplicate keys (hikey and @@ -197,8 +197,8 @@ _bt_moveright(Relation rel, * if number of attrs > keysize. Example: (2,0) - last items * on this page, (2,1) - first item on next page (hikey), our * scankey is x = 2. Scankey == (2,1) because of we compare - * first attrs only, but we shouldn't to move right of here. - * - vadim 04/15/97 + * first attrs only, but we shouldn't to move right of here. - + * vadim 04/15/97 */ if (_bt_skeycmp(rel, keysz, scankey, page, hikey, @@ -268,17 +268,17 @@ _bt_skeycmp(Relation rel, ItemId itemid, StrategyNumber strat) { - BTItem item; - IndexTuple indexTuple; - TupleDesc tupDes; - ScanKey entry; - int i; - Datum attrDatum; - Datum keyDatum; - bool compare; - bool isNull; - bool useEqual = false; - bool keyNull; + BTItem item; + IndexTuple indexTuple; + TupleDesc tupDes; + ScanKey entry; + int i; + Datum attrDatum; + Datum keyDatum; + bool compare; + bool isNull; + bool useEqual = false; + bool keyNull; if (strat == BTLessEqualStrategyNumber) { @@ -382,14 +382,14 @@ _bt_binsrch(Relation rel, ScanKey scankey, int srchtype) { - TupleDesc itupdesc; - Page page; - BTPageOpaque opaque; - OffsetNumber low, - mid, - high; - int natts = rel->rd_rel->relnatts; - int result; + TupleDesc itupdesc; + Page page; + BTPageOpaque opaque; + OffsetNumber low, + mid, + high; + int natts = rel->rd_rel->relnatts; + int result; itupdesc = RelationGetTupleDescriptor(rel); page = BufferGetPage(buf); @@ -515,7 +515,7 @@ _bt_binsrch(Relation rel, } } -static OffsetNumber +static OffsetNumber _bt_firsteq(Relation rel, TupleDesc itupdesc, Page page, @@ -523,8 +523,8 @@ _bt_firsteq(Relation rel, ScanKey scankey, OffsetNumber offnum) { - BTPageOpaque opaque; - OffsetNumber limit; + BTPageOpaque opaque; + OffsetNumber limit; opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -572,16 +572,16 @@ _bt_compare(Relation rel, ScanKey scankey, OffsetNumber offnum) { - Datum datum; - BTItem btitem; - ItemId itemid; - IndexTuple itup; - BTPageOpaque opaque; - ScanKey entry; - AttrNumber attno; - int result; - int i; - bool null; + Datum datum; + BTItem btitem; + ItemId itemid; + IndexTuple itup; + BTPageOpaque opaque; + ScanKey entry; + AttrNumber attno; + int result; + int i; + bool null; /* * If this is a leftmost internal page, and if our comparison is with @@ -650,7 +650,7 @@ _bt_compare(Relation rel, for (i = 1; i <= keysz; i++) { - long tmpres; + long tmpres; entry = &scankey[i - 1]; attno = entry->sk_attno; @@ -697,16 +697,16 @@ _bt_compare(Relation rel, RetrieveIndexResult _bt_next(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Page page; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Page page; + OffsetNumber offnum; RetrieveIndexResult res; - ItemPointer current; - BTItem btitem; - IndexTuple itup; - BTScanOpaque so; - Size keysok; + ItemPointer current; + BTItem btitem; + IndexTuple itup; + BTScanOpaque so; + Size keysok; rel = scan->relation; so = (BTScanOpaque) scan->opaque; @@ -769,26 +769,26 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) RetrieveIndexResult _bt_first(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - TupleDesc itupdesc; - Buffer buf; - Page page; - BTPageOpaque pop; - BTStack stack; - OffsetNumber offnum, - maxoff; - bool offGmax = false; - BTItem btitem; - IndexTuple itup; - ItemPointer current; - BlockNumber blkno; - StrategyNumber strat; + Relation rel; + TupleDesc itupdesc; + Buffer buf; + Page page; + BTPageOpaque pop; + BTStack stack; + OffsetNumber offnum, + maxoff; + bool offGmax = false; + BTItem btitem; + IndexTuple itup; + ItemPointer current; + BlockNumber blkno; + StrategyNumber strat; RetrieveIndexResult res; - RegProcedure proc; - int result; - BTScanOpaque so; - ScanKeyData skdata; - Size keysok; + RegProcedure proc; + int result; + BTScanOpaque so; + ScanKeyData skdata; + Size keysok; rel = scan->relation; so = (BTScanOpaque) scan->opaque; @@ -915,69 +915,69 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) switch (strat) { - case BTLessStrategyNumber: - if (result <= 0) - { - do + case BTLessStrategyNumber: + if (result <= 0) { - if (!_bt_twostep(scan, &buf, BackwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, BackwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result <= 0); + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result <= 0); - /* if this is true, the key we just looked at is gone */ - if (result > 0) - _bt_twostep(scan, &buf, ForwardScanDirection); - } - break; + /* if this is true, the key we just looked at is gone */ + if (result > 0) + _bt_twostep(scan, &buf, ForwardScanDirection); + } + break; - case BTLessEqualStrategyNumber: - if (result >= 0) - { - do + case BTLessEqualStrategyNumber: + if (result >= 0) { - if (!_bt_twostep(scan, &buf, ForwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, ForwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result >= 0); + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result >= 0); - if (result < 0) - _bt_twostep(scan, &buf, BackwardScanDirection); - } - break; + if (result < 0) + _bt_twostep(scan, &buf, BackwardScanDirection); + } + break; - case BTEqualStrategyNumber: - if (result != 0) - { - _bt_relbuf(scan->relation, buf, BT_READ); - so->btso_curbuf = InvalidBuffer; - ItemPointerSetInvalid(&(scan->currentItemData)); - return ((RetrieveIndexResult) NULL); - } - break; + case BTEqualStrategyNumber: + if (result != 0) + { + _bt_relbuf(scan->relation, buf, BT_READ); + so->btso_curbuf = InvalidBuffer; + ItemPointerSetInvalid(&(scan->currentItemData)); + return ((RetrieveIndexResult) NULL); + } + break; - case BTGreaterEqualStrategyNumber: - if (offGmax) - { - if (result < 0) + case BTGreaterEqualStrategyNumber: + if (offGmax) { - Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY); - if (!_bt_step(scan, &buf, ForwardScanDirection)) + if (result < 0) { - _bt_relbuf(scan->relation, buf, BT_READ); - so->btso_curbuf = InvalidBuffer; - ItemPointerSetInvalid(&(scan->currentItemData)); - return ((RetrieveIndexResult) NULL); + Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY); + if (!_bt_step(scan, &buf, ForwardScanDirection)) + { + _bt_relbuf(scan->relation, buf, BT_READ); + so->btso_curbuf = InvalidBuffer; + ItemPointerSetInvalid(&(scan->currentItemData)); + return ((RetrieveIndexResult) NULL); + } } - } - else if (result > 0) - { /* Just remember: _bt_binsrch() returns + else if (result > 0) + { /* Just remember: _bt_binsrch() returns * the OffsetNumber of the first matching * key on the page, or the OffsetNumber at * which the matching key WOULD APPEAR IF @@ -985,41 +985,41 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) * page, but offnum from _bt_binsrch() * greater maxoff - have to move right. - * vadim 12/06/96 */ - _bt_twostep(scan, &buf, ForwardScanDirection); + _bt_twostep(scan, &buf, ForwardScanDirection); + } } - } - else if (result < 0) - { - do + else if (result < 0) { - if (!_bt_twostep(scan, &buf, BackwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, BackwardScanDirection)) + break; - page = BufferGetPage(buf); - offnum = ItemPointerGetOffsetNumber(current); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result < 0); + page = BufferGetPage(buf); + offnum = ItemPointerGetOffsetNumber(current); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result < 0); - if (result > 0) - _bt_twostep(scan, &buf, ForwardScanDirection); - } - break; + if (result > 0) + _bt_twostep(scan, &buf, ForwardScanDirection); + } + break; - case BTGreaterStrategyNumber: - /* offGmax helps as above */ - if (result >= 0 || offGmax) - { - do + case BTGreaterStrategyNumber: + /* offGmax helps as above */ + if (result >= 0 || offGmax) { - if (!_bt_twostep(scan, &buf, ForwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, ForwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result >= 0); - } - break; + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result >= 0); + } + break; } /* okay, current item pointer for the scan is right */ @@ -1062,16 +1062,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) bool _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) { - Page page; - BTPageOpaque opaque; - OffsetNumber offnum, - maxoff; - OffsetNumber start; - BlockNumber blkno; - BlockNumber obknum; - BTScanOpaque so; - ItemPointer current; - Relation rel; + Page page; + BTPageOpaque opaque; + OffsetNumber offnum, + maxoff; + OffsetNumber start; + BlockNumber blkno; + BlockNumber obknum; + BTScanOpaque so; + ItemPointer current; + Relation rel; rel = scan->relation; current = &(scan->currentItemData); @@ -1235,20 +1235,20 @@ _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) * proper state and acquires a lock and pin on *bufP. If the twostep * succeeded, we return true; otherwise, we return false. */ -static bool +static bool _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) { - Page page; - BTPageOpaque opaque; - OffsetNumber offnum, - maxoff; - OffsetNumber start; - ItemPointer current; - ItemId itemid; - int itemsz; - BTItem btitem; - BTItem svitem; - BlockNumber blkno; + Page page; + BTPageOpaque opaque; + OffsetNumber offnum, + maxoff; + OffsetNumber start; + ItemPointer current; + ItemId itemid; + int itemsz; + BTItem btitem; + BTItem svitem; + BlockNumber blkno; blkno = BufferGetBlockNumber(*bufP); page = BufferGetPage(*bufP); @@ -1333,23 +1333,23 @@ _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) /* * _bt_endpoint() -- Find the first or last key in the index. */ -static RetrieveIndexResult +static RetrieveIndexResult _bt_endpoint(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Page page; - BTPageOpaque opaque; - ItemPointer current; - OffsetNumber offnum, - maxoff; - OffsetNumber start = 0; - BlockNumber blkno; - BTItem btitem; - IndexTuple itup; - BTScanOpaque so; + Relation rel; + Buffer buf; + Page page; + BTPageOpaque opaque; + ItemPointer current; + OffsetNumber offnum, + maxoff; + OffsetNumber start = 0; + BlockNumber blkno; + BTItem btitem; + IndexTuple itup; + BTScanOpaque so; RetrieveIndexResult res; - Size keysok; + Size keysok; rel = scan->relation; current = &(scan->currentItemData); diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 09cb43769f..fae0fc27da 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -5,7 +5,7 @@ * * * IDENTIFICATION - * $Id: nbtsort.c,v 1.20 1997/09/07 04:39:02 momjian Exp $ + * $Id: nbtsort.c,v 1.21 1997/09/08 02:20:58 momjian Exp $ * * NOTES * @@ -65,14 +65,14 @@ #ifdef BTREE_BUILD_STATS #include <tcop/tcopprot.h> -extern int ShowExecutorStats; +extern int ShowExecutorStats; #endif -static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags); -static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend); -static void *_bt_pagestate(Relation index, int flags, int level, bool doupper); -static void _bt_uppershutdown(Relation index, BTPageState * state); +static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags); +static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend); +static void *_bt_pagestate(Relation index, int flags, int level, bool doupper); +static void _bt_uppershutdown(Relation index, BTPageState * state); /* * turn on debugging output. @@ -88,9 +88,9 @@ static void _bt_uppershutdown(Relation index, BTPageState * state); #define TAPEBLCKSZ (MAXBLCKSZ << 2) #define TAPETEMP "pg_btsortXXXXXX" -extern int NDirectFileRead; -extern int NDirectFileWrite; -extern char *mktemp(char *template); +extern int NDirectFileRead; +extern int NDirectFileWrite; +extern char *mktemp(char *template); /* * this is what we use to shovel BTItems in and out of memory. it's @@ -107,13 +107,13 @@ extern char *mktemp(char *template); */ typedef struct { - int bttb_magic; /* magic number */ - int bttb_fd; /* file descriptor */ - int bttb_top; /* top of free space within bttb_data */ - short bttb_ntup; /* number of tuples in this block */ - short bttb_eor; /* End-Of-Run marker */ - char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)]; -} BTTapeBlock; + int bttb_magic; /* magic number */ + int bttb_fd; /* file descriptor */ + int bttb_top; /* top of free space within bttb_data */ + short bttb_ntup; /* number of tuples in this block */ + short bttb_eor; /* End-Of-Run marker */ + char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)]; +} BTTapeBlock; /* * this structure holds the bookkeeping for a simple balanced multiway @@ -124,12 +124,12 @@ typedef struct */ typedef struct { - int bts_ntapes; - int bts_tape; - BTTapeBlock **bts_itape; /* input tape blocks */ - BTTapeBlock **bts_otape; /* output tape blocks */ - bool isunique; -} BTSpool; + int bts_ntapes; + int bts_tape; + BTTapeBlock **bts_itape; /* input tape blocks */ + BTTapeBlock **bts_otape; /* output tape blocks */ + bool isunique; +} BTSpool; /*------------------------------------------------------------------------- * sorting comparison routine - returns {-1,0,1} depending on whether @@ -151,13 +151,13 @@ typedef struct */ typedef struct { - Datum *btsk_datum; - char *btsk_nulls; - BTItem btsk_item; -} BTSortKey; + Datum *btsk_datum; + char *btsk_nulls; + BTItem btsk_item; +} BTSortKey; static Relation _bt_sortrel; -static int _bt_nattr; +static int _bt_nattr; static BTSpool *_bt_inspool; static void @@ -171,12 +171,12 @@ _bt_isortcmpinit(Relation index, BTSpool * spool) static int _bt_isortcmp(BTSortKey * k1, BTSortKey * k2) { - Datum *k1_datum = k1->btsk_datum; - Datum *k2_datum = k2->btsk_datum; - char *k1_nulls = k1->btsk_nulls; - char *k2_nulls = k2->btsk_nulls; - bool equal_isnull = false; - int i; + Datum *k1_datum = k1->btsk_datum; + Datum *k2_datum = k2->btsk_datum; + char *k1_nulls = k1->btsk_nulls; + char *k2_nulls = k2->btsk_nulls; + bool equal_isnull = false; + int i; if (k1->btsk_item == (BTItem) NULL) { @@ -226,12 +226,12 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk) if (bti != (BTItem) NULL) { - IndexTuple it = &(bti->bti_itup); - TupleDesc itdesc = index->rd_att; - Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum)); - char *np = (char *) palloc(_bt_nattr * sizeof(char)); - bool isnull; - int i; + IndexTuple it = &(bti->bti_itup); + TupleDesc itdesc = index->rd_att; + Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum)); + char *np = (char *) palloc(_bt_nattr * sizeof(char)); + bool isnull; + int i; for (i = 0; i < _bt_nattr; i++) { @@ -260,17 +260,17 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk) */ typedef struct { - int btpqe_tape; /* tape identifier */ - BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */ -} BTPriQueueElem; + int btpqe_tape; /* tape identifier */ + BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */ +} BTPriQueueElem; #define MAXELEM MAXTAPES typedef struct { - int btpq_nelem; - BTPriQueueElem btpq_queue[MAXELEM]; - Relation btpq_rel; -} BTPriQueue; + int btpq_nelem; + BTPriQueueElem btpq_queue[MAXELEM]; + Relation btpq_rel; +} BTPriQueue; /* be sure to call _bt_isortcmpinit first */ #define GREATER(a, b) \ @@ -279,8 +279,8 @@ typedef struct static void _bt_pqsift(BTPriQueue * q, int parent) { - int child; - BTPriQueueElem e; + int child; + BTPriQueueElem e; for (child = parent * 2 + 1; child < q->btpq_nelem; @@ -328,8 +328,8 @@ _bt_pqnext(BTPriQueue * q, BTPriQueueElem * e) static void _bt_pqadd(BTPriQueue * q, BTPriQueueElem * e) { - int child, - parent; + int child, + parent; if (q->btpq_nelem >= MAXELEM) { @@ -422,7 +422,7 @@ _bt_tapeclear(BTTapeBlock * tape) static BTTapeBlock * _bt_tapecreate(char *fname) { - BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock)); + BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock)); if (tape == (BTTapeBlock *) NULL) { @@ -474,8 +474,8 @@ _bt_tapewrite(BTTapeBlock * tape, int eor) static int _bt_taperead(BTTapeBlock * tape) { - int fd; - int nread; + int fd; + int nread; if (tape->bttb_eor) { @@ -510,11 +510,11 @@ _bt_taperead(BTTapeBlock * tape) * side effects: * - sets 'pos' to the current position within the block. */ -static BTItem +static BTItem _bt_tapenext(BTTapeBlock * tape, char **pos) { - Size itemsz; - BTItem bti; + Size itemsz; + BTItem bti; if (*pos >= tape->bttb_data + tape->bttb_top) { @@ -554,12 +554,12 @@ _bt_tapeadd(BTTapeBlock * tape, BTItem item, int itemsz) * create and initialize a spool structure, including the underlying * files. */ -void * +void * _bt_spoolinit(Relation index, int ntapes, bool isunique) { - BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); - int i; - char *fname = (char *) palloc(sizeof(TAPETEMP) + 1); + BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); + int i; + char *fname = (char *) palloc(sizeof(TAPETEMP) + 1); if (btspool == (BTSpool *) NULL || fname == (char *) NULL) { @@ -600,8 +600,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique) void _bt_spooldestroy(void *spool) { - BTSpool *btspool = (BTSpool *) spool; - int i; + BTSpool *btspool = (BTSpool *) spool; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -617,7 +617,7 @@ _bt_spooldestroy(void *spool) static void _bt_spoolflush(BTSpool * btspool) { - int i; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -637,10 +637,10 @@ _bt_spoolflush(BTSpool * btspool) static void _bt_spoolswap(BTSpool * btspool) { - File tmpfd; - BTTapeBlock *itape; - BTTapeBlock *otape; - int i; + File tmpfd; + BTTapeBlock *itape; + BTTapeBlock *otape; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -682,9 +682,9 @@ _bt_spoolswap(BTSpool * btspool) void _bt_spool(Relation index, BTItem btitem, void *spool) { - BTSpool *btspool = (BTSpool *) spool; - BTTapeBlock *itape; - Size itemsz; + BTSpool *btspool = (BTSpool *) spool; + BTTapeBlock *itape; + Size itemsz; _bt_isortcmpinit(index, btspool); @@ -699,13 +699,13 @@ _bt_spool(Relation index, BTItem btitem, void *spool) */ if (btitem == (BTItem) NULL || SPCLEFT(itape) < itemsz) { - BTSortKey *parray = (BTSortKey *) NULL; - BTTapeBlock *otape; - BTItem bti; - char *pos; - int btisz; - int it_ntup = itape->bttb_ntup; - int i; + BTSortKey *parray = (BTSortKey *) NULL; + BTTapeBlock *otape; + BTItem bti; + char *pos; + int btisz; + int it_ntup = itape->bttb_ntup; + int i; /* * build an array of pointers to the BTItemDatas on the input @@ -745,9 +745,9 @@ _bt_spool(Relation index, BTItem btitem, void *spool) _bt_tapeadd(otape, bti, btisz); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_SPOOL) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, - &isnull); + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, + &isnull); printf("_bt_spool: inserted <%x> into output tape %d\n", d, btspool->bts_tape); @@ -802,7 +802,7 @@ _bt_spool(Relation index, BTItem btitem, void *spool) static void _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags) { - BTPageOpaque opaque; + BTPageOpaque opaque; *buf = _bt_getbuf(index, P_NEW, BT_WRITE); #if 0 @@ -824,10 +824,10 @@ _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags) static void _bt_slideleft(Relation index, Buffer buf, Page page) { - OffsetNumber off; - OffsetNumber maxoff; - ItemId previi; - ItemId thisii; + OffsetNumber off; + OffsetNumber maxoff; + ItemId previi; + ItemId thisii; if (!PageIsEmpty(page)) { @@ -847,10 +847,10 @@ _bt_slideleft(Relation index, Buffer buf, Page page) * allocate and initialize a new BTPageState. the returned structure * is suitable for immediate use by _bt_buildadd. */ -static void * +static void * _bt_pagestate(Relation index, int flags, int level, bool doupper) { - BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState)); + BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState)); memset((char *) state, 0, sizeof(BTPageState)); _bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags); @@ -870,12 +870,12 @@ _bt_pagestate(Relation index, int flags, int level, bool doupper) * the page to which the item used to point, e.g., a heap page if * 'opage' is a leaf page). */ -static BTItem +static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend) { - OffsetNumber off; - BTItem obti; - BTItem nbti; + OffsetNumber off; + BTItem obti; + BTItem nbti; off = atend ? P_HIKEY : P_FIRSTKEY; obti = (BTItem) PageGetItem(opage, PageGetItemId(opage, off)); @@ -924,18 +924,18 @@ _bt_minitem(Page opage, BlockNumber oblkno, int atend) * * if all keys are unique, 'first' will always be the same as 'last'. */ -static BTItem +static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) { - BTPageState *state = (BTPageState *) pstate; - Buffer nbuf; - Page npage; - BTItem last_bti; - OffsetNumber first_off; - OffsetNumber last_off; - OffsetNumber off; - Size pgspc; - Size btisz; + BTPageState *state = (BTPageState *) pstate; + Buffer nbuf; + Page npage; + BTItem last_bti; + OffsetNumber first_off; + OffsetNumber last_off; + OffsetNumber off; + Size pgspc; + Size btisz; nbuf = state->btps_buf; npage = state->btps_page; @@ -948,12 +948,12 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) btisz = DOUBLEALIGN(btisz); if (pgspc < btisz) { - Buffer obuf = nbuf; - Page opage = npage; - OffsetNumber o, - n; - ItemId ii; - ItemId hii; + Buffer obuf = nbuf; + Page opage = npage; + OffsetNumber o, + n; + ItemId ii; + ItemId hii; _bt_blnewpage(index, &nbuf, &npage, flags); @@ -989,11 +989,11 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) #if 0 #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - BTItem tmpbti = + bool isnull; + BTItem tmpbti = (BTItem) PageGetItem(npage, PageGetItemId(npage, n)); - Datum d = index_getattr(&(tmpbti->bti_itup), 1, - index->rd_att, &isnull); + Datum d = index_getattr(&(tmpbti->bti_itup), 1, + index->rd_att, &isnull); printf("_bt_buildadd: moved <%x> to offset %d at level %d\n", d, n, state->btps_level); @@ -1026,8 +1026,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) * set the page (side link) pointers. */ { - BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage); - BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage); + BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage); + BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage); oopaque->btpo_next = BufferGetBlockNumber(nbuf); nopaque->btpo_prev = BufferGetBlockNumber(obuf); @@ -1047,7 +1047,7 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) */ if (state->btps_doupper) { - BTItem nbti; + BTItem nbti; if (state->btps_next == (BTPageState *) NULL) { @@ -1077,8 +1077,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) #if 0 #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_buildadd: inserted <%x> at offset %d at level %d\n", d, off, state->btps_level); @@ -1109,10 +1109,10 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) static void _bt_uppershutdown(Relation index, BTPageState * state) { - BTPageState *s; - BlockNumber blkno; - BTPageOpaque opaque; - BTItem bti; + BTPageState *s; + BlockNumber blkno; + BTPageOpaque opaque; + BTItem bti; for (s = state; s != (BTPageState *) NULL; s = s->btps_next) { @@ -1160,21 +1160,21 @@ _bt_uppershutdown(Relation index, BTPageState * state) static void _bt_merge(Relation index, BTSpool * btspool) { - BTPageState *state; - BTPriQueue q; - BTPriQueueElem e; - BTSortKey btsk; - BTItem bti; - BTTapeBlock *itape; - BTTapeBlock *otape; - char *tapepos[MAXTAPES]; - int tapedone[MAXTAPES]; - int t; - int goodtapes; - int npass; - int nruns; - Size btisz; - bool doleaf = false; + BTPageState *state; + BTPriQueue q; + BTPriQueueElem e; + BTSortKey btsk; + BTItem bti; + BTTapeBlock *itape; + BTTapeBlock *otape; + char *tapepos[MAXTAPES]; + int tapedone[MAXTAPES]; + int t; + int goodtapes; + int npass; + int nruns; + Size btisz; + bool doleaf = false; /* * initialize state needed for the merge into the btree leaf pages. @@ -1279,8 +1279,8 @@ _bt_merge(Relation index, BTSpool * btspool) _bt_buildadd(index, state, bti, BTP_LEAF); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into block %d\n", @@ -1308,8 +1308,8 @@ _bt_merge(Relation index, BTSpool * btspool) _bt_tapeadd(otape, bti, btisz); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into output tape %d\n", @@ -1328,7 +1328,7 @@ _bt_merge(Relation index, BTSpool * btspool) itape = btspool->bts_itape[t]; if (!tapedone[t]) { - BTItem newbti = _bt_tapenext(itape, &tapepos[t]); + BTItem newbti = _bt_tapenext(itape, &tapepos[t]); if (newbti == (BTItem) NULL) { @@ -1347,7 +1347,7 @@ _bt_merge(Relation index, BTSpool * btspool) } if (newbti != (BTItem) NULL) { - BTPriQueueElem nexte; + BTPriQueueElem nexte; nexte.btpqe_tape = t; _bt_setsortkey(index, newbti, &(nexte.btpqe_item)); @@ -1397,12 +1397,12 @@ _bt_merge(Relation index, BTSpool * btspool) void _bt_upperbuild(Relation index) { - Buffer rbuf; - BlockNumber blk; - Page rpage; - BTPageOpaque ropaque; - BTPageState *state; - BTItem nbti; + Buffer rbuf; + BlockNumber blk; + Page rpage; + BTPageOpaque ropaque; + BTPageState *state; + BTItem nbti; /* * find the first leaf block. while we're at it, clear the BTP_ROOT @@ -1438,9 +1438,9 @@ _bt_upperbuild(Relation index) nbti = _bt_minitem(rpage, blk, P_RIGHTMOST(ropaque)); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att, - &isnull); + bool isnull; + Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att, + &isnull); printf("_bt_upperbuild: inserting <%x> at %d\n", d, state->btps_level); diff --git a/src/backend/access/nbtree/nbtstrat.c b/src/backend/access/nbtree/nbtstrat.c index 5215d2000d..6af9df2b65 100644 --- a/src/backend/access/nbtree/nbtstrat.c +++ b/src/backend/access/nbtree/nbtstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.5 1997/09/07 04:39:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.6 1997/09/08 02:20:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ static StrategyNumber BTNegateCommute[5] = { BTGreaterEqualStrategyNumber }; -static uint16 BTLessTermData[] = { /* XXX type clash */ +static uint16 BTLessTermData[] = { /* XXX type clash */ 2, BTLessStrategyNumber, SK_NEGATE, @@ -55,7 +55,7 @@ static uint16 BTLessTermData[] = { /* XXX type clash */ SK_NEGATE | SK_COMMUTE }; -static uint16 BTLessEqualTermData[] = { /* XXX type clash */ +static uint16 BTLessEqualTermData[] = { /* XXX type clash */ 2, BTLessEqualStrategyNumber, 0x0, @@ -63,7 +63,7 @@ static uint16 BTLessEqualTermData[] = { /* XXX type clash */ SK_COMMUTE }; -static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ +static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ 2, BTGreaterEqualStrategyNumber, 0x0, @@ -71,7 +71,7 @@ static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ SK_COMMUTE }; -static uint16 BTGreaterTermData[] = { /* XXX type clash */ +static uint16 BTGreaterTermData[] = { /* XXX type clash */ 2, BTGreaterStrategyNumber, SK_NEGATE, @@ -109,7 +109,7 @@ _bt_getstrat(Relation rel, AttrNumber attno, RegProcedure proc) { - StrategyNumber strat; + StrategyNumber strat; strat = RelationGetStrategy(rel, attno, &BTEvaluationData, proc); diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 096f1d2691..0ee1ef9d32 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.12 1997/09/07 04:39:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.13 1997/09/08 02:21:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #include <catalog/pg_proc.h> #include <executor/execdebug.h> -extern int NIndexTupleProcessed; +extern int NIndexTupleProcessed; #ifndef HAVE_MEMMOVE @@ -35,14 +35,14 @@ extern int NIndexTupleProcessed; ScanKey _bt_mkscankey(Relation rel, IndexTuple itup) { - ScanKey skey; - TupleDesc itupdesc; - int natts; - int i; - Datum arg; - RegProcedure proc; - bool null; - bits16 flag; + ScanKey skey; + TupleDesc itupdesc; + int natts; + int i; + Datum arg; + RegProcedure proc; + bool null; + bits16 flag; natts = rel->rd_rel->relnatts; itupdesc = RelationGetTupleDescriptor(rel); @@ -78,7 +78,7 @@ _bt_freeskey(ScanKey skey) void _bt_freestack(BTStack stack) { - BTStack ostack; + BTStack ostack; while (stack != (BTStack) NULL) { @@ -99,18 +99,18 @@ _bt_freestack(BTStack stack) void _bt_orderkeys(Relation relation, BTScanOpaque so) { - ScanKey xform; - ScanKeyData *cur; - StrategyMap map; - int nbytes; - long test; - int i, - j; - int init[BTMaxStrategyNumber + 1]; - ScanKey key; - uint16 numberOfKeys = so->numberOfKeys; - uint16 new_numberOfKeys = 0; - AttrNumber attno = 1; + ScanKey xform; + ScanKeyData *cur; + StrategyMap map; + int nbytes; + long test; + int i, + j; + int init[BTMaxStrategyNumber + 1]; + ScanKey key; + uint16 numberOfKeys = so->numberOfKeys; + uint16 new_numberOfKeys = 0; + AttrNumber attno = 1; if (numberOfKeys < 1) return; @@ -169,8 +169,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) */ if (init[BTEqualStrategyNumber - 1]) { - ScanKeyData *eq, - *chk; + ScanKeyData *eq, + *chk; eq = &xform[BTEqualStrategyNumber - 1]; for (j = BTMaxStrategyNumber; --j >= 0;) @@ -192,8 +192,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) if (init[BTLessStrategyNumber - 1] && init[BTLessEqualStrategyNumber - 1]) { - ScanKeyData *lt, - *le; + ScanKeyData *lt, + *le; lt = &xform[BTLessStrategyNumber - 1]; le = &xform[BTLessEqualStrategyNumber - 1]; @@ -216,8 +216,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) if (init[BTGreaterStrategyNumber - 1] && init[BTGreaterEqualStrategyNumber - 1]) { - ScanKeyData *gt, - *ge; + ScanKeyData *gt, + *ge; gt = &xform[BTGreaterStrategyNumber - 1]; ge = &xform[BTGreaterEqualStrategyNumber - 1]; @@ -288,10 +288,10 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) BTItem _bt_formitem(IndexTuple itup) { - int nbytes_btitem; - BTItem btitem; - Size tuplen; - extern Oid newoid(); + int nbytes_btitem; + BTItem btitem; + Size tuplen; + extern Oid newoid(); /* * see comments in btbuild @@ -318,7 +318,7 @@ _bt_formitem(IndexTuple itup) bool _bt_checkqual(IndexScanDesc scan, IndexTuple itup) { - BTScanOpaque so; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; if (so->numberOfKeys > 0) @@ -334,7 +334,7 @@ _bt_checkqual(IndexScanDesc scan, IndexTuple itup) bool _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz) { - BTScanOpaque so; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; if (keysz > 0 && so->numberOfKeys >= keysz) @@ -349,13 +349,13 @@ _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz) bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok) { - BTScanOpaque so = (BTScanOpaque) scan->opaque; - Size keysz = so->numberOfKeys; - TupleDesc tupdesc; - ScanKey key; - Datum datum; - bool isNull; - int test; + BTScanOpaque so = (BTScanOpaque) scan->opaque; + Size keysz = so->numberOfKeys; + TupleDesc tupdesc; + ScanKey key; + Datum datum; + bool isNull; + int test; *keysok = 0; if (keysz == 0) diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c index eaf16c1ae9..6a13b81a1f 100644 --- a/src/backend/access/rtree/rtget.c +++ b/src/backend/access/rtree/rtget.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.8 1997/09/07 04:39:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.9 1997/09/08 02:21:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,19 +57,19 @@ rtgettuple(IndexScanDesc s, ScanDirection dir) return (res); } -static RetrieveIndexResult +static RetrieveIndexResult rtfirst(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; RTreePageOpaque po; RTreeScanOpaque so; - RTSTACK *stk; - BlockNumber blk; - IndexTuple it; + RTSTACK *stk; + BlockNumber blk; + IndexTuple it; b = ReadBuffer(s->relation, P_ROOT); p = BufferGetPage(b); @@ -140,19 +140,19 @@ rtfirst(IndexScanDesc s, ScanDirection dir) } } -static RetrieveIndexResult +static RetrieveIndexResult rtnext(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; RTreePageOpaque po; RTreeScanOpaque so; - RTSTACK *stk; - BlockNumber blk; - IndexTuple it; + RTSTACK *stk; + BlockNumber blk; + IndexTuple it; blk = ItemPointerGetBlockNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -241,11 +241,11 @@ rtnext(IndexScanDesc s, ScanDirection dir) } } -static OffsetNumber +static OffsetNumber findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) { - OffsetNumber maxoff; - IndexTuple it; + OffsetNumber maxoff; + IndexTuple it; RTreePageOpaque po; RTreeScanOpaque so; @@ -295,11 +295,11 @@ findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) return (n); } -static RetrieveIndexResult +static RetrieveIndexResult rtscancache(IndexScanDesc s, ScanDirection dir) { RetrieveIndexResult res; - ItemPointer ip; + ItemPointer ip; if (!(ScanDirectionIsNoMovement(dir) && ItemPointerIsValid(&(s->currentItemData)))) @@ -324,14 +324,14 @@ rtscancache(IndexScanDesc s, ScanDirection dir) * rtheapptr returns the item pointer to the tuple in the heap relation * for which itemp is the index relation item pointer. */ -static ItemPointer +static ItemPointer rtheapptr(Relation r, ItemPointer itemp) { - Buffer b; - Page p; - IndexTuple it; - ItemPointer ip; - OffsetNumber n; + Buffer b; + Page p; + IndexTuple it; + ItemPointer ip; + OffsetNumber n; ip = (ItemPointer) palloc(sizeof(ItemPointerData)); if (ItemPointerIsValid(itemp)) diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c index 4b7a9f2a26..5f1d4846f6 100644 --- a/src/backend/access/rtree/rtproc.c +++ b/src/backend/access/rtree/rtproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.8 1997/09/07 04:39:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.9 1997/09/08 02:21:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ BOX * rt_box_union(BOX * a, BOX * b) { - BOX *n; + BOX *n; if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL) elog(WARN, "Cannot allocate box for union"); @@ -38,10 +38,10 @@ BOX return (n); } -BOX * +BOX * rt_box_inter(BOX * a, BOX * b) { - BOX *n; + BOX *n; if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL) elog(WARN, "Cannot allocate box for union"); @@ -85,10 +85,10 @@ rt_bigbox_size(BOX * a, float *size) rt_box_size(a, size); } -POLYGON * +POLYGON * rt_poly_union(POLYGON * a, POLYGON * b) { - POLYGON *p; + POLYGON *p; p = (POLYGON *) PALLOCTYPE(POLYGON); @@ -108,8 +108,8 @@ rt_poly_union(POLYGON * a, POLYGON * b) void rt_poly_size(POLYGON * a, float *size) { - double xdim, - ydim; + double xdim, + ydim; size = (float *) palloc(sizeof(float)); if (a == (POLYGON *) NULL || @@ -127,10 +127,10 @@ rt_poly_size(POLYGON * a, float *size) return; } -POLYGON * +POLYGON * rt_poly_inter(POLYGON * a, POLYGON * b) { - POLYGON *p; + POLYGON *p; p = (POLYGON *) PALLOCTYPE(POLYGON); diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index ae92ea2013..8b1aa533e8 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.14 1997/09/07 04:39:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.15 1997/09/08 02:21:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,20 +34,20 @@ typedef struct SPLITVEC { - OffsetNumber *spl_left; - int spl_nleft; - char *spl_ldatum; - OffsetNumber *spl_right; - int spl_nright; - char *spl_rdatum; -} SPLITVEC; + OffsetNumber *spl_left; + int spl_nleft; + char *spl_ldatum; + OffsetNumber *spl_right; + int spl_nright; + char *spl_rdatum; +} SPLITVEC; typedef struct RTSTATE { - func_ptr unionFn; /* union function */ - func_ptr sizeFn; /* size function */ - func_ptr interFn; /* intersection function */ -} RTSTATE; + func_ptr unionFn; /* union function */ + func_ptr sizeFn; /* size function */ + func_ptr interFn; /* intersection function */ +} RTSTATE; /* non-export function prototypes */ static InsertIndexResult @@ -62,16 +62,16 @@ dosplit(Relation r, Buffer buffer, RTSTACK * stack, static void rtintinsert(Relation r, RTSTACK * stk, IndexTuple ltup, IndexTuple rtup, RTSTATE * rtstate); -static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt); +static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt); static void picksplit(Relation r, Page page, SPLITVEC * v, IndexTuple itup, RTSTATE * rtstate); -static void RTInitBuffer(Buffer b, uint32 f); +static void RTInitBuffer(Buffer b, uint32 f); static OffsetNumber choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate); -static int nospace(Page p, IndexTuple it); -static void initRtstate(RTSTATE * rtstate, Relation index); +static int nospace(Page p, IndexTuple it); +static void initRtstate(RTSTATE * rtstate, Relation index); void @@ -85,31 +85,31 @@ rtbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc scan; - Buffer buffer; - AttrNumber i; - HeapTuple htup; - IndexTuple itup; - TupleDesc hd, - id; + HeapScanDesc scan; + Buffer buffer; + AttrNumber i; + HeapTuple htup; + IndexTuple itup; + TupleDesc hd, + id; InsertIndexResult res; - Datum *d; - bool *nulls; - int nb, - nh, - ni; + Datum *d; + bool *nulls; + int nb, + nh, + ni; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - RTSTATE rtState; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + RTSTATE rtState; initRtstate(&rtState, index); @@ -215,8 +215,8 @@ rtbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -308,8 +308,8 @@ InsertIndexResult rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { InsertIndexResult res; - IndexTuple itup; - RTSTATE rtState; + IndexTuple itup; + RTSTATE rtState; /* generate an index tuple */ itup = index_formtuple(RelationGetTupleDescriptor(r), datum, nulls); @@ -323,18 +323,18 @@ rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation h return (res); } -static InsertIndexResult +static InsertIndexResult rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate) { - Page page; - Buffer buffer; - BlockNumber blk; - IndexTuple which; - OffsetNumber l; - RTSTACK *stack; + Page page; + Buffer buffer; + BlockNumber blk; + IndexTuple which; + OffsetNumber l; + RTSTACK *stack; InsertIndexResult res; RTreePageOpaque opaque; - char *datum; + char *datum; blk = P_ROOT; buffer = InvalidBuffer; @@ -353,8 +353,8 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate) opaque = (RTreePageOpaque) PageGetSpecialPointer(page); if (!(opaque->flags & F_LEAF)) { - RTSTACK *n; - ItemId iid; + RTSTACK *n; + ItemId iid; n = (RTSTACK *) palloc(sizeof(RTSTACK)); n->rts_parent = stack; @@ -414,12 +414,12 @@ rttighten(Relation r, int att_size, RTSTATE * rtstate) { - char *oldud; - char *tdatum; - Page p; - float old_size, - newd_size; - Buffer b; + char *oldud; + char *tdatum; + Page p; + float old_size, + newd_size; + Buffer b; if (stk == (RTSTACK *) NULL) return; @@ -437,7 +437,7 @@ rttighten(Relation r, if (newd_size != old_size) { - TupleDesc td = RelationGetTupleDescriptor(r); + TupleDesc td = RelationGetTupleDescriptor(r); if (td->attrs[0]->attlen < 0) { @@ -480,35 +480,35 @@ rttighten(Relation r, * his paper. The reason we chose it is that you can implement this * with less information about the data types on which you're operating. */ -static InsertIndexResult +static InsertIndexResult dosplit(Relation r, Buffer buffer, RTSTACK * stack, IndexTuple itup, RTSTATE * rtstate) { - Page p; - Buffer leftbuf, - rightbuf; - Page left, - right; - ItemId itemid; - IndexTuple item; - IndexTuple ltup, - rtup; - OffsetNumber maxoff; - OffsetNumber i; - OffsetNumber leftoff, - rightoff; - BlockNumber lbknum, - rbknum; - BlockNumber bufblock; + Page p; + Buffer leftbuf, + rightbuf; + Page left, + right; + ItemId itemid; + IndexTuple item; + IndexTuple ltup, + rtup; + OffsetNumber maxoff; + OffsetNumber i; + OffsetNumber leftoff, + rightoff; + BlockNumber lbknum, + rbknum; + BlockNumber bufblock; RTreePageOpaque opaque; - int blank; + int blank; InsertIndexResult res; - char *isnull; - SPLITVEC v; - TupleDesc tupDesc; + char *isnull; + SPLITVEC v; + TupleDesc tupDesc; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -638,12 +638,12 @@ rtintinsert(Relation r, IndexTuple rtup, RTSTATE * rtstate) { - IndexTuple old; - Buffer b; - Page p; - char *ldatum, - *rdatum, - *newdatum; + IndexTuple old; + Buffer b; + Page p; + char *ldatum, + *rdatum, + *newdatum; InsertIndexResult res; if (stk == (RTSTACK *) NULL) @@ -698,8 +698,8 @@ rtintinsert(Relation r, static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt) { - Buffer b; - Page p; + Buffer b; + Page p; b = ReadBuffer(r, P_ROOT); RTInitBuffer(b, 0); @@ -718,33 +718,33 @@ picksplit(Relation r, IndexTuple itup, RTSTATE * rtstate) { - OffsetNumber maxoff; - OffsetNumber i, - j; - IndexTuple item_1, - item_2; - char *datum_alpha, - *datum_beta; - char *datum_l, - *datum_r; - char *union_d, - *union_dl, - *union_dr; - char *inter_d; - bool firsttime; - float size_alpha, - size_beta, - size_union, - size_inter; - float size_waste, - waste; - float size_l, - size_r; - int nbytes; - OffsetNumber seed_1 = 0, - seed_2 = 0; - OffsetNumber *left, - *right; + OffsetNumber maxoff; + OffsetNumber i, + j; + IndexTuple item_1, + item_2; + char *datum_alpha, + *datum_beta; + char *datum_l, + *datum_r; + char *union_d, + *union_dl, + *union_dr; + char *inter_d; + bool firsttime; + float size_alpha, + size_beta, + size_union, + size_inter; + float size_waste, + waste; + float size_l, + size_r; + int nbytes; + OffsetNumber seed_1 = 0, + seed_2 = 0; + OffsetNumber *left, + *right; maxoff = PageGetMaxOffsetNumber(page); @@ -886,8 +886,8 @@ static void RTInitBuffer(Buffer b, uint32 f) { RTreePageOpaque opaque; - Page page; - Size pageSize; + Page page; + Size pageSize; pageSize = BufferGetPageSize(b); @@ -899,18 +899,18 @@ RTInitBuffer(Buffer b, uint32 f) opaque->flags = f; } -static OffsetNumber +static OffsetNumber choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate) { - OffsetNumber maxoff; - OffsetNumber i; - char *ud, - *id; - char *datum; - float usize, - dsize; - OffsetNumber which; - float which_grow; + OffsetNumber maxoff; + OffsetNumber i; + char *ud, + *id; + char *datum; + float usize, + dsize; + OffsetNumber which; + float which_grow; id = ((char *) it) + sizeof(IndexTupleData); maxoff = PageGetMaxOffsetNumber(p); @@ -946,7 +946,7 @@ nospace(Page p, IndexTuple it) void freestack(RTSTACK * s) { - RTSTACK *p; + RTSTACK *p; while (s != (RTSTACK *) NULL) { @@ -956,13 +956,13 @@ freestack(RTSTACK * s) } } -char * +char * rtdelete(Relation r, ItemPointer tid) { - BlockNumber blkno; - OffsetNumber offnum; - Buffer buf; - Page page; + BlockNumber blkno; + OffsetNumber offnum; + Buffer buf; + Page page; /* must write-lock on delete */ RelationSetLockForWrite(r); @@ -988,11 +988,11 @@ rtdelete(Relation r, ItemPointer tid) static void initRtstate(RTSTATE * rtstate, Relation index) { - RegProcedure union_proc, - size_proc, - inter_proc; - func_ptr user_fn; - int pronargs; + RegProcedure union_proc, + size_proc, + inter_proc; + func_ptr user_fn; + int pronargs; union_proc = index_getprocid(index, 1, RT_UNION_PROC); size_proc = index_getprocid(index, 1, RT_SIZE_PROC); @@ -1011,18 +1011,18 @@ initRtstate(RTSTATE * rtstate, Relation index) void _rtdump(Relation r) { - Buffer buf; - Page page; - OffsetNumber offnum, - maxoff; - BlockNumber blkno; - BlockNumber nblocks; + Buffer buf; + Page page; + OffsetNumber offnum, + maxoff; + BlockNumber blkno; + BlockNumber nblocks; RTreePageOpaque po; - IndexTuple itup; - BlockNumber itblkno; - OffsetNumber itoffno; - char *datum; - char *itkey; + IndexTuple itup; + BlockNumber itblkno; + OffsetNumber itoffno; + char *datum; + char *itkey; nblocks = RelationGetNumberOfBlocks(r); for (blkno = 0; blkno < nblocks; blkno++) diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c index 26590059d6..2a4810ccae 100644 --- a/src/backend/access/rtree/rtscan.c +++ b/src/backend/access/rtree/rtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.11 1997/09/07 04:39:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.12 1997/09/08 02:21:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,8 +28,8 @@ /* routines defined and used here */ -static void rtregscan(IndexScanDesc s); -static void rtdropscan(IndexScanDesc s); +static void rtregscan(IndexScanDesc s); +static void rtdropscan(IndexScanDesc s); static void rtadjone(IndexScanDesc s, int op, BlockNumber blkno, OffsetNumber offnum); @@ -52,9 +52,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct RTScanListData { - IndexScanDesc rtsl_scan; + IndexScanDesc rtsl_scan; struct RTScanListData *rtsl_next; -} RTScanListData; +} RTScanListData; typedef RTScanListData *RTScanList; @@ -67,7 +67,7 @@ rtbeginscan(Relation r, uint16 nkeys, ScanKey key) { - IndexScanDesc s; + IndexScanDesc s; RelationSetLockForRead(r); s = RelationGetIndexScan(r, fromEnd, nkeys, key); @@ -80,8 +80,8 @@ void rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key) { RTreeScanOpaque p; - RegProcedure internal_proc; - int i; + RegProcedure internal_proc; + int i; if (!IndexScanIsValid(s)) { @@ -177,9 +177,9 @@ void rtmarkpos(IndexScanDesc s) { RTreeScanOpaque p; - RTSTACK *o, - *n, - *tmp; + RTSTACK *o, + *n, + *tmp; s->currentMarkData = s->currentItemData; p = (RTreeScanOpaque) s->opaque; @@ -210,9 +210,9 @@ void rtrestrpos(IndexScanDesc s) { RTreeScanOpaque p; - RTSTACK *o, - *n, - *tmp; + RTSTACK *o, + *n, + *tmp; s->currentItemData = s->currentMarkData; p = (RTreeScanOpaque) s->opaque; @@ -260,7 +260,7 @@ rtendscan(IndexScanDesc s) static void rtregscan(IndexScanDesc s) { - RTScanList l; + RTScanList l; l = (RTScanList) palloc(sizeof(RTScanListData)); l->rtsl_scan = s; @@ -271,8 +271,8 @@ rtregscan(IndexScanDesc s) static void rtdropscan(IndexScanDesc s) { - RTScanList l; - RTScanList prev; + RTScanList l; + RTScanList prev; prev = (RTScanList) NULL; @@ -297,8 +297,8 @@ rtdropscan(IndexScanDesc s) void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) { - RTScanList l; - Oid relid; + RTScanList l; + Oid relid; relid = r->rd_id; for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next) @@ -352,7 +352,7 @@ adjustiptr(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - OffsetNumber curoff; + OffsetNumber curoff; RTreeScanOpaque so; if (ItemPointerIsValid(iptr)) @@ -364,39 +364,43 @@ adjustiptr(IndexScanDesc s, switch (op) { - case RTOP_DEL: - /* back up one if we need to */ - if (curoff >= offnum) - { - - if (curoff > FirstOffsetNumber) - { - /* just adjust the item pointer */ - ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); - } - else + case RTOP_DEL: + /* back up one if we need to */ + if (curoff >= offnum) { - /* remember that we're before the current tuple */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags |= RTS_CURBEFORE; + + if (curoff > FirstOffsetNumber) + { + /* just adjust the item pointer */ + ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); + } else - so->s_flags |= RTS_MRKBEFORE; + { + + /* + * remember that we're before the current + * tuple + */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags |= RTS_CURBEFORE; + else + so->s_flags |= RTS_MRKBEFORE; + } } - } - break; - - case RTOP_SPLIT: - /* back to start of page on split */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags &= ~RTS_CURBEFORE; - else - so->s_flags &= ~RTS_MRKBEFORE; - break; - - default: - elog(WARN, "Bad operation in rtree scan adjust: %d", op); + break; + + case RTOP_SPLIT: + /* back to start of page on split */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags &= ~RTS_CURBEFORE; + else + so->s_flags &= ~RTS_MRKBEFORE; + break; + + default: + elog(WARN, "Bad operation in rtree scan adjust: %d", op); } } } diff --git a/src/backend/access/rtree/rtstrat.c b/src/backend/access/rtree/rtstrat.c index c71059d3f0..028625d48a 100644 --- a/src/backend/access/rtree/rtstrat.c +++ b/src/backend/access/rtree/rtstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.7 1997/09/07 04:39:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.8 1997/09/08 02:21:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -118,7 +118,7 @@ static StrategyNumber RTNegateCommute[RTNStrategies] = { */ /* if you only have "contained-by", how do you determine equality? */ -static uint16 RTContainedByTermData[] = { +static uint16 RTContainedByTermData[] = { 2, /* make two comparisons */ RTContainedByStrategyNumber,/* use "a contained-by b" */ 0x0, /* without any magic */ @@ -127,7 +127,7 @@ static uint16 RTContainedByTermData[] = { }; /* if you only have "contains", how do you determine equality? */ -static uint16 RTContainsTermData[] = { +static uint16 RTContainsTermData[] = { 2, /* make two comparisons */ RTContainsStrategyNumber, /* use "a contains b" */ 0x0, /* without any magic */ @@ -204,7 +204,7 @@ static StrategyNumber RTOperMap[RTNStrategies] = { RTOverlapStrategyNumber }; -static StrategyNumber +static StrategyNumber RelationGetRTStrategy(Relation r, AttrNumber attnum, RegProcedure proc) @@ -231,8 +231,8 @@ RTMapOperator(Relation r, AttrNumber attnum, RegProcedure proc) { - StrategyNumber procstrat; - StrategyMap strategyMap; + StrategyNumber procstrat; + StrategyMap strategyMap; procstrat = RelationGetRTStrategy(r, attnum, proc); strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(r), diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 6d721fe96a..03b82872fd 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.10 1997/09/07 04:39:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.11 1997/09/08 02:21:14 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -26,9 +26,9 @@ #include <storage/spin.h> #include <commands/vacuum.h> -static int RecoveryCheckingEnabled(void); -static void TransRecover(Relation logRelation); -static bool TransactionLogTest(TransactionId transactionId, XidStatus status); +static int RecoveryCheckingEnabled(void); +static void TransRecover(Relation logRelation); +static bool TransactionLogTest(TransactionId transactionId, XidStatus status); static void TransactionLogUpdate(TransactionId transactionId, XidStatus status); @@ -40,18 +40,18 @@ TransactionLogUpdate(TransactionId transactionId, * ---------------- */ -Relation LogRelation = (Relation) NULL; -Relation TimeRelation = (Relation) NULL; -Relation VariableRelation = (Relation) NULL; +Relation LogRelation = (Relation) NULL; +Relation TimeRelation = (Relation) NULL; +Relation VariableRelation = (Relation) NULL; /* ---------------- * global variables holding cached transaction id's and statuses. * ---------------- */ -TransactionId cachedGetCommitTimeXid; -AbsoluteTime cachedGetCommitTime; -TransactionId cachedTestXid; -XidStatus cachedTestXidStatus; +TransactionId cachedGetCommitTimeXid; +AbsoluteTime cachedGetCommitTime; +TransactionId cachedTestXid; +XidStatus cachedTestXidStatus; /* ---------------- * transaction system constants @@ -65,11 +65,11 @@ XidStatus cachedTestXidStatus; * FirstTransactionId. -cim 3/23/90 * ---------------------------------------------------------------- */ -TransactionId NullTransactionId = (TransactionId) 0; +TransactionId NullTransactionId = (TransactionId) 0; -TransactionId AmiTransactionId = (TransactionId) 512; +TransactionId AmiTransactionId = (TransactionId) 512; -TransactionId FirstTransactionId = (TransactionId) 514; +TransactionId FirstTransactionId = (TransactionId) 514; /* ---------------- * transaction recovery state variables @@ -83,19 +83,19 @@ TransactionId FirstTransactionId = (TransactionId) 514; * goes from zero to one. -cim 3/21/90 * ---------------- */ -int RecoveryCheckingEnableState = 0; +int RecoveryCheckingEnableState = 0; /* ------------------ * spinlock for oid generation * ----------------- */ -extern int OidGenLockId; +extern int OidGenLockId; /* ---------------- * globals that must be reset at abort * ---------------- */ -extern bool BuildingBtree; +extern bool BuildingBtree; /* ---------------- @@ -134,14 +134,14 @@ SetRecoveryCheckingEnabled(bool state) * -------------------------------- */ -static bool /* true/false: does transaction id have +static bool /* true/false: does transaction id have * specified status? */ TransactionLogTest(TransactionId transactionId, /* transaction id to test */ XidStatus status) /* transaction status */ { - BlockNumber blockNumber; - XidStatus xidstatus; /* recorded status of xid */ - bool fail = false; /* success/failure */ + BlockNumber blockNumber; + XidStatus xidstatus; /* recorded status of xid */ + bool fail = false; /* success/failure */ /* ---------------- * during initialization consider all transactions @@ -202,9 +202,9 @@ static void TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ XidStatus status) /* new trans status */ { - BlockNumber blockNumber; - bool fail = false; /* success/failure */ - AbsoluteTime currentTime;/* time of this transaction */ + BlockNumber blockNumber; + bool fail = false; /* success/failure */ + AbsoluteTime currentTime; /* time of this transaction */ /* ---------------- * during initialization we don't record any updates. @@ -276,9 +276,9 @@ AbsoluteTime /* commit time of transaction id */ TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to * test */ { - BlockNumber blockNumber; - AbsoluteTime commitTime; /* commit time */ - bool fail = false; /* success/failure */ + BlockNumber blockNumber; + AbsoluteTime commitTime; /* commit time */ + bool fail = false; /* success/failure */ /* ---------------- * return invalid if we aren't running yet... @@ -471,9 +471,9 @@ TransRecover(Relation logRelation) void InitializeTransactionLog(void) { - Relation logRelation; - Relation timeRelation; - MemoryContext oldContext; + Relation logRelation; + Relation timeRelation; + MemoryContext oldContext; /* ---------------- * don't do anything during bootstrapping diff --git a/src/backend/access/transam/transsup.c b/src/backend/access/transam/transsup.c index 9809190c94..acdfe93ea9 100644 --- a/src/backend/access/transam/transsup.c +++ b/src/backend/access/transam/transsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.10 1997/09/07 04:39:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.11 1997/09/08 02:21:18 momjian Exp $ * * NOTES * This file contains support functions for the high @@ -63,7 +63,7 @@ TransComputeBlockNumber(Relation relation, /* relation to test */ * test */ BlockNumber * blockNumberOutP) { - long itemsPerBlock = 0; + long itemsPerBlock = 0; /* ---------------- * we calculate the block number of our transaction @@ -108,17 +108,17 @@ TransComputeBlockNumber(Relation relation, /* relation to test */ */ #ifdef NOT_USED -static XidStatus +static XidStatus TransBlockGetLastTransactionIdStatus(Block tblock, TransactionId baseXid, TransactionId * returnXidP) { - Index index; - Index maxIndex; - bits8 bit1; - bits8 bit2; - BitIndex offset; - XidStatus xstatus; + Index index; + Index maxIndex; + bits8 bit1; + bits8 bit2; + BitIndex offset; + XidStatus xstatus; /* ---------------- * sanity check @@ -188,14 +188,14 @@ TransBlockGetLastTransactionIdStatus(Block tblock, * -------------------------------- */ -static XidStatus +static XidStatus TransBlockGetXidStatus(Block tblock, TransactionId transactionId) { - Index index; - bits8 bit1; - bits8 bit2; - BitIndex offset; + Index index; + bits8 bit1; + bits8 bit2; + BitIndex offset; /* ---------------- * sanity check @@ -245,8 +245,8 @@ TransBlockSetXidStatus(Block tblock, TransactionId transactionId, XidStatus xstatus) { - Index index; - BitIndex offset; + Index index; + BitIndex offset; /* ---------------- * sanity check @@ -275,23 +275,23 @@ TransBlockSetXidStatus(Block tblock, */ switch (xstatus) { - case XID_COMMIT: /* set 10 */ - BitArraySetBit((BitArray) tblock, offset); - BitArrayClearBit((BitArray) tblock, offset + 1); - break; - case XID_ABORT: /* set 01 */ - BitArrayClearBit((BitArray) tblock, offset); - BitArraySetBit((BitArray) tblock, offset + 1); - break; - case XID_INPROGRESS: /* set 00 */ - BitArrayClearBit((BitArray) tblock, offset); - BitArrayClearBit((BitArray) tblock, offset + 1); - break; - default: - elog(NOTICE, - "TransBlockSetXidStatus: invalid status: %d (ignored)", - xstatus); - break; + case XID_COMMIT: /* set 10 */ + BitArraySetBit((BitArray) tblock, offset); + BitArrayClearBit((BitArray) tblock, offset + 1); + break; + case XID_ABORT: /* set 01 */ + BitArrayClearBit((BitArray) tblock, offset); + BitArraySetBit((BitArray) tblock, offset + 1); + break; + case XID_INPROGRESS: /* set 00 */ + BitArrayClearBit((BitArray) tblock, offset); + BitArrayClearBit((BitArray) tblock, offset + 1); + break; + default: + elog(NOTICE, + "TransBlockSetXidStatus: invalid status: %d (ignored)", + xstatus); + break; } } @@ -302,12 +302,12 @@ TransBlockSetXidStatus(Block tblock, * specified transaction id in the trans block. * -------------------------------- */ -static AbsoluteTime +static AbsoluteTime TransBlockGetCommitTime(Block tblock, TransactionId transactionId) { - Index index; - AbsoluteTime *timeArray; + Index index; + AbsoluteTime *timeArray; /* ---------------- * sanity check @@ -348,8 +348,8 @@ TransBlockSetCommitTime(Block tblock, TransactionId transactionId, AbsoluteTime commitTime) { - Index index; - AbsoluteTime *timeArray; + Index index; + AbsoluteTime *timeArray; /* ---------------- * sanity check @@ -394,10 +394,10 @@ TransBlockNumberGetXidStatus(Relation relation, TransactionId xid, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xstatus */ - XidStatus xstatus; /* recorded status of xid */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xstatus */ + XidStatus xstatus; /* recorded status of xid */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY place a read lock on the log relation @@ -451,9 +451,9 @@ TransBlockNumberSetXidStatus(Relation relation, XidStatus xstatus, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xstatus */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xstatus */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY gain exclusive access to the log relation @@ -504,10 +504,10 @@ TransBlockNumberGetCommitTime(Relation relation, TransactionId xid, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ - AbsoluteTime xtime; /* commit time */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing commit time */ + bool localfail; /* bool used if failP = NULL */ + AbsoluteTime xtime; /* commit time */ /* ---------------- * SOMEDAY place a read lock on the time relation @@ -565,9 +565,9 @@ TransBlockNumberSetCommitTime(Relation relation, AbsoluteTime xtime, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing commit time */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY gain exclusive access to the time relation @@ -620,11 +620,11 @@ TransGetLastRecordedTransaction(Relation relation, * id */ bool * failP) { - BlockNumber blockNumber;/* block number */ - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xid status */ - BlockNumber n; /* number of blocks in the relation */ - TransactionId baseXid; + BlockNumber blockNumber; /* block number */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xid status */ + BlockNumber n; /* number of blocks in the relation */ + TransactionId baseXid; (*failP) = false; diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 8b4b8557eb..fb44b210be 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.10 1997/09/07 04:39:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.11 1997/09/08 02:21:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,18 +20,18 @@ #include <access/heapam.h> #include <catalog/catname.h> -static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size); -static void VariableRelationGetNextOid(Oid * oid_return); -static void VariableRelationGetNextXid(TransactionId * xidP); -static void VariableRelationPutLastXid(TransactionId xid); -static void VariableRelationPutNextOid(Oid * oidP); -static void VariableRelationGetLastXid(TransactionId * xidP); +static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size); +static void VariableRelationGetNextOid(Oid * oid_return); +static void VariableRelationGetNextXid(TransactionId * xidP); +static void VariableRelationPutLastXid(TransactionId xid); +static void VariableRelationPutNextOid(Oid * oidP); +static void VariableRelationGetLastXid(TransactionId * xidP); /* --------------------- * spin lock for oid generation * --------------------- */ -int OidGenLockId; +int OidGenLockId; /* ---------------------------------------------------------------- * variable relation query/update routines @@ -45,7 +45,7 @@ int OidGenLockId; static void VariableRelationGetNextXid(TransactionId * xidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -87,7 +87,7 @@ VariableRelationGetNextXid(TransactionId * xidP) static void VariableRelationGetLastXid(TransactionId * xidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -130,9 +130,9 @@ VariableRelationGetLastXid(TransactionId * xidP) void VariableRelationPutNextXid(TransactionId xid) { - Buffer buf; + Buffer buf; VariableRelationContents var; - int flushmode; + int flushmode; /* ---------------- * We assume that a spinlock has been acquire to guarantee @@ -176,7 +176,7 @@ VariableRelationPutNextXid(TransactionId xid) static void VariableRelationPutLastXid(TransactionId xid) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -219,7 +219,7 @@ VariableRelationPutLastXid(TransactionId xid) static void VariableRelationGetNextOid(Oid * oid_return) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -289,7 +289,7 @@ VariableRelationGetNextOid(Oid * oid_return) static void VariableRelationPutNextOid(Oid * oidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -383,13 +383,13 @@ VariableRelationPutNextOid(Oid * oidP) #define VAR_XID_PREFETCH 32 -static int prefetched_xid_count = 0; +static int prefetched_xid_count = 0; static TransactionId next_prefetched_xid; void GetNewTransactionId(TransactionId * xid) { - TransactionId nextid; + TransactionId nextid; /* ---------------- * during bootstrap initialization, we return the special @@ -457,7 +457,7 @@ GetNewTransactionId(TransactionId * xid) void UpdateLastCommittedXid(TransactionId xid) { - TransactionId lastid; + TransactionId lastid; /* @@ -501,7 +501,7 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object * id */ int oid_block_size) /* number of oids desired */ { - Oid nextoid; + Oid nextoid; /* ---------------- * SOMEDAY obtain exclusive access to the variable relation page @@ -554,8 +554,8 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object #define VAR_OID_PREFETCH 32 -static int prefetched_oid_count = 0; -static Oid next_prefetched_oid; +static int prefetched_oid_count = 0; +static Oid next_prefetched_oid; void GetNewObjectId(Oid * oid_return)/* place to return the new object id */ @@ -568,7 +568,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */ if (prefetched_oid_count == 0) { - int oid_block_size = VAR_OID_PREFETCH; + int oid_block_size = VAR_OID_PREFETCH; /* ---------------- * during bootstrap time, we want to allocate oids @@ -609,7 +609,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */ void CheckMaxObjectId(Oid assigned_oid) { - Oid pass_oid; + Oid pass_oid; if (prefetched_oid_count == 0) /* make sure next/max is set, or diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index da32570d87..b6ff2dd296 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.14 1997/09/07 04:39:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.15 1997/09/08 02:21:22 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -151,20 +151,20 @@ #include <commands/async.h> #include <commands/sequence.h> -static void AbortTransaction(void); -static void AtAbort_Cache(void); -static void AtAbort_Locks(void); -static void AtAbort_Memory(void); -static void AtCommit_Cache(void); -static void AtCommit_Locks(void); -static void AtCommit_Memory(void); -static void AtStart_Cache(void); -static void AtStart_Locks(void); -static void AtStart_Memory(void); -static void CommitTransaction(void); -static void RecordTransactionAbort(void); -static void RecordTransactionCommit(void); -static void StartTransaction(void); +static void AbortTransaction(void); +static void AtAbort_Cache(void); +static void AtAbort_Locks(void); +static void AtAbort_Memory(void); +static void AtCommit_Cache(void); +static void AtCommit_Locks(void); +static void AtCommit_Memory(void); +static void AtStart_Cache(void); +static void AtStart_Locks(void); +static void AtStart_Memory(void); +static void CommitTransaction(void); +static void RecordTransactionAbort(void); +static void RecordTransactionCommit(void); +static void StartTransaction(void); /* ---------------- * global variables holding the current transaction state. @@ -202,17 +202,17 @@ TransactionState CurrentTransactionState = * V1 transaction system. -cim 3/18/90 * ---------------- */ -TransactionId DisabledTransactionId = (TransactionId) - 1; +TransactionId DisabledTransactionId = (TransactionId) - 1; -CommandId DisabledCommandId = (CommandId) - 1; +CommandId DisabledCommandId = (CommandId) - 1; -AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */ +AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */ /* ---------------- * overflow flag * ---------------- */ -bool CommandIdCounterOverflowFlag; +bool CommandIdCounterOverflowFlag; /* ---------------- * catalog creation transaction bootstrapping flag. @@ -220,7 +220,7 @@ bool CommandIdCounterOverflowFlag; * state stuff. -cim 3/19/90 * ---------------- */ -bool AMI_OVERRIDE = false; +bool AMI_OVERRIDE = false; /* ---------------------------------------------------------------- * transaction state accessors @@ -239,7 +239,7 @@ bool AMI_OVERRIDE = false; * only do writes as necessary. * -------------------------------- */ -static int TransactionFlushState = 1; +static int TransactionFlushState = 1; int TransactionFlushEnabled(void) @@ -270,18 +270,18 @@ IsTransactionState(void) switch (s->state) { - case TRANS_DEFAULT: - return false; - case TRANS_START: - return true; - case TRANS_INPROGRESS: - return true; - case TRANS_COMMIT: - return true; - case TRANS_ABORT: - return true; - case TRANS_DISABLED: - return false; + case TRANS_DEFAULT: + return false; + case TRANS_START: + return true; + case TRANS_INPROGRESS: + return true; + case TRANS_COMMIT: + return true; + case TRANS_ABORT: + return true; + case TRANS_DISABLED: + return false; } /* @@ -317,7 +317,7 @@ IsAbortedTransactionBlockState() * themselves. * -------------------------------- */ -int SavedTransactionState; +int SavedTransactionState; void OverrideTransactionSystem(bool flag) @@ -564,8 +564,8 @@ AtStart_Locks() static void AtStart_Memory() { - Portal portal; - MemoryContext portalContext; + Portal portal; + MemoryContext portalContext; /* ---------------- * get the blank portal and its memory context @@ -601,8 +601,8 @@ AtStart_Memory() static void RecordTransactionCommit() { - TransactionId xid; - int leak; + TransactionId xid; + int leak; /* ---------------- * get the current transaction id @@ -701,7 +701,7 @@ AtCommit_Memory() static void RecordTransactionAbort() { - TransactionId xid; + TransactionId xid; /* ---------------- * get the current transaction id @@ -994,73 +994,73 @@ StartTransactionCommand() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual start transaction. - * ---------------- - */ - case TBLOCK_DEFAULT: - StartTransaction(); - break; - - /* ---------------- - * We should never experience this -- if we do it - * means the BEGIN state was not changed in the previous - * CommitTransactionCommand(). If we get it, we print - * a warning and change to the in-progress state. - * ---------------- - */ - case TBLOCK_BEGIN: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN"); - s->blockState = TBLOCK_INPROGRESS; - break; - - /* ---------------- - * This is the case when are somewhere in a transaction - * block and about to start a new command. For now we - * do nothing but someday we may do command-local resource - * initialization. - * ---------------- - */ - case TBLOCK_INPROGRESS: - break; - - /* ---------------- - * As with BEGIN, we should never experience this -- - * if we do it means the END state was not changed in the - * previous CommitTransactionCommand(). If we get it, we - * print a warning, commit the transaction, start a new - * transaction and change to the default state. - * ---------------- - */ - case TBLOCK_END: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END"); - s->blockState = TBLOCK_DEFAULT; - CommitTransaction(); - StartTransaction(); - break; - - /* ---------------- - * Here we are in the middle of a transaction block but - * one of the commands caused an abort so we do nothing - * but remain in the abort state. Eventually we will get - * to the "END TRANSACTION" which will set things straight. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * This means we somehow aborted and the last call to - * CommitTransactionCommand() didn't clear the state so - * we remain in the ENDABORT state and mabey next time - * we get to CommitTransactionCommand() the state will - * get reset to default. - * ---------------- - */ - case TBLOCK_ENDABORT: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT"); - break; + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual start transaction. + * ---------------- + */ + case TBLOCK_DEFAULT: + StartTransaction(); + break; + + /* ---------------- + * We should never experience this -- if we do it + * means the BEGIN state was not changed in the previous + * CommitTransactionCommand(). If we get it, we print + * a warning and change to the in-progress state. + * ---------------- + */ + case TBLOCK_BEGIN: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN"); + s->blockState = TBLOCK_INPROGRESS; + break; + + /* ---------------- + * This is the case when are somewhere in a transaction + * block and about to start a new command. For now we + * do nothing but someday we may do command-local resource + * initialization. + * ---------------- + */ + case TBLOCK_INPROGRESS: + break; + + /* ---------------- + * As with BEGIN, we should never experience this -- + * if we do it means the END state was not changed in the + * previous CommitTransactionCommand(). If we get it, we + * print a warning, commit the transaction, start a new + * transaction and change to the default state. + * ---------------- + */ + case TBLOCK_END: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END"); + s->blockState = TBLOCK_DEFAULT; + CommitTransaction(); + StartTransaction(); + break; + + /* ---------------- + * Here we are in the middle of a transaction block but + * one of the commands caused an abort so we do nothing + * but remain in the abort state. Eventually we will get + * to the "END TRANSACTION" which will set things straight. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * This means we somehow aborted and the last call to + * CommitTransactionCommand() didn't clear the state so + * we remain in the ENDABORT state and mabey next time + * we get to CommitTransactionCommand() the state will + * get reset to default. + * ---------------- + */ + case TBLOCK_ENDABORT: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT"); + break; } } @@ -1075,75 +1075,75 @@ CommitTransactionCommand() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual transaction commit - * ---------------- - */ - case TBLOCK_DEFAULT: - CommitTransaction(); - break; - - /* ---------------- - * This is the case right after we get a "BEGIN TRANSACTION" - * command, but the user hasn't done anything else yet, so - * we change to the "transaction block in progress" state - * and return. - * ---------------- - */ - case TBLOCK_BEGIN: - s->blockState = TBLOCK_INPROGRESS; - break; - - /* ---------------- - * This is the case when we have finished executing a command - * someplace within a transaction block. We increment the - * command counter and return. Someday we may free resources - * local to the command. - * - * That someday is today, at least for memory allocated by - * command in the BlankPortal' HeapMemory context. - * - vadim 03/25/97 - * ---------------- - */ - case TBLOCK_INPROGRESS: - CommandCounterIncrement(); + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual transaction commit + * ---------------- + */ + case TBLOCK_DEFAULT: + CommitTransaction(); + break; + + /* ---------------- + * This is the case right after we get a "BEGIN TRANSACTION" + * command, but the user hasn't done anything else yet, so + * we change to the "transaction block in progress" state + * and return. + * ---------------- + */ + case TBLOCK_BEGIN: + s->blockState = TBLOCK_INPROGRESS; + break; + + /* ---------------- + * This is the case when we have finished executing a command + * someplace within a transaction block. We increment the + * command counter and return. Someday we may free resources + * local to the command. + * + * That someday is today, at least for memory allocated by + * command in the BlankPortal' HeapMemory context. + * - vadim 03/25/97 + * ---------------- + */ + case TBLOCK_INPROGRESS: + CommandCounterIncrement(); #ifdef TBL_FREE_CMD_MEMORY - EndPortalAllocMode(); - StartPortalAllocMode(DefaultAllocMode, 0); + EndPortalAllocMode(); + StartPortalAllocMode(DefaultAllocMode, 0); #endif - break; - - /* ---------------- - * This is the case when we just got the "END TRANSACTION" - * statement, so we go back to the default state and - * commit the transaction. - * ---------------- - */ - case TBLOCK_END: - s->blockState = TBLOCK_DEFAULT; - CommitTransaction(); - break; - - /* ---------------- - * Here we are in the middle of a transaction block but - * one of the commands caused an abort so we do nothing - * but remain in the abort state. Eventually we will get - * to the "END TRANSACTION" which will set things straight. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * Here we were in an aborted transaction block which - * just processed the "END TRANSACTION" command from the - * user, so now we return the to default state. - * ---------------- - */ - case TBLOCK_ENDABORT: - s->blockState = TBLOCK_DEFAULT; - break; + break; + + /* ---------------- + * This is the case when we just got the "END TRANSACTION" + * statement, so we go back to the default state and + * commit the transaction. + * ---------------- + */ + case TBLOCK_END: + s->blockState = TBLOCK_DEFAULT; + CommitTransaction(); + break; + + /* ---------------- + * Here we are in the middle of a transaction block but + * one of the commands caused an abort so we do nothing + * but remain in the abort state. Eventually we will get + * to the "END TRANSACTION" which will set things straight. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * Here we were in an aborted transaction block which + * just processed the "END TRANSACTION" command from the + * user, so now we return the to default state. + * ---------------- + */ + case TBLOCK_ENDABORT: + s->blockState = TBLOCK_DEFAULT; + break; } } @@ -1158,71 +1158,71 @@ AbortCurrentTransaction() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual abort transaction. - * ---------------- - */ - case TBLOCK_DEFAULT: - AbortTransaction(); - break; - - /* ---------------- - * If we are in the TBLOCK_BEGIN it means something - * screwed up right after reading "BEGIN TRANSACTION" - * so we enter the abort state. Eventually an "END - * TRANSACTION" will fix things. - * ---------------- - */ - case TBLOCK_BEGIN: - s->blockState = TBLOCK_ABORT; - AbortTransaction(); - break; - - /* ---------------- - * This is the case when are somewhere in a transaction - * block which aborted so we abort the transaction and - * set the ABORT state. Eventually an "END TRANSACTION" - * will fix things and restore us to a normal state. - * ---------------- - */ - case TBLOCK_INPROGRESS: - s->blockState = TBLOCK_ABORT; - AbortTransaction(); - break; - - /* ---------------- - * Here, the system was fouled up just after the - * user wanted to end the transaction block so we - * abort the transaction and put us back into the - * default state. - * ---------------- - */ - case TBLOCK_END: - s->blockState = TBLOCK_DEFAULT; - AbortTransaction(); - break; - - /* ---------------- - * Here, we are already in an aborted transaction - * state and are waiting for an "END TRANSACTION" to - * come along and lo and behold, we abort again! - * So we just remain in the abort state. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * Here we were in an aborted transaction block which - * just processed the "END TRANSACTION" command but somehow - * aborted again.. since we must have done the abort - * processing, we return to the default state. - * ---------------- - */ - case TBLOCK_ENDABORT: - s->blockState = TBLOCK_DEFAULT; - break; + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual abort transaction. + * ---------------- + */ + case TBLOCK_DEFAULT: + AbortTransaction(); + break; + + /* ---------------- + * If we are in the TBLOCK_BEGIN it means something + * screwed up right after reading "BEGIN TRANSACTION" + * so we enter the abort state. Eventually an "END + * TRANSACTION" will fix things. + * ---------------- + */ + case TBLOCK_BEGIN: + s->blockState = TBLOCK_ABORT; + AbortTransaction(); + break; + + /* ---------------- + * This is the case when are somewhere in a transaction + * block which aborted so we abort the transaction and + * set the ABORT state. Eventually an "END TRANSACTION" + * will fix things and restore us to a normal state. + * ---------------- + */ + case TBLOCK_INPROGRESS: + s->blockState = TBLOCK_ABORT; + AbortTransaction(); + break; + + /* ---------------- + * Here, the system was fouled up just after the + * user wanted to end the transaction block so we + * abort the transaction and put us back into the + * default state. + * ---------------- + */ + case TBLOCK_END: + s->blockState = TBLOCK_DEFAULT; + AbortTransaction(); + break; + + /* ---------------- + * Here, we are already in an aborted transaction + * state and are waiting for an "END TRANSACTION" to + * come along and lo and behold, we abort again! + * So we just remain in the abort state. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * Here we were in an aborted transaction block which + * just processed the "END TRANSACTION" command but somehow + * aborted again.. since we must have done the abort + * processing, we return to the default state. + * ---------------- + */ + case TBLOCK_ENDABORT: + s->blockState = TBLOCK_DEFAULT; + break; } } diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c index 910d6ac732..9cfc8235d4 100644 --- a/src/backend/access/transam/xid.c +++ b/src/backend/access/transam/xid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.8 1997/09/07 04:39:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.9 1997/09/08 02:21:24 momjian Exp $ * * OLD COMMENTS * XXX WARNING @@ -50,11 +50,11 @@ xidin(char *representation) } /* XXX char16 name for catalogs */ -char * +char * xidout(TransactionId transactionId) { /* return(TransactionIdFormString(transactionId)); */ - char *representation; + char *representation; /* maximum 32 bit unsigned integer representation takes 10 chars */ representation = palloc(11); diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 9fd4bf719b..f96abbd4cb 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -7,7 +7,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.22 1997/09/07 04:39:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.23 1997/09/08 02:21:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,14 +103,14 @@ #define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t)) #define FIRST_TYPE_OID 16 /* OID of the first type */ -extern int Int_yyparse(void); +extern int Int_yyparse(void); static hashnode *AddStr(char *str, int strlength, int mderef); static AttributeTupleForm AllocateAttribute(void); -static bool BootstrapAlreadySeen(Oid id); -static int CompHash(char *str, int len); +static bool BootstrapAlreadySeen(Oid id); +static int CompHash(char *str, int len); static hashnode *FindStr(char *str, int length, hashnode * mderef); -static int gettype(char *type); -static void cleanup(void); +static int gettype(char *type); +static void cleanup(void); /* ---------------- * global variables @@ -134,11 +134,10 @@ static void cleanup(void); #define NUMSQR 529 #define NUMCUBE 12167 -char *strtable[STRTABLESIZE]; -hashnode *hashtable[HASHTABLESIZE]; +char *strtable[STRTABLESIZE]; +hashnode *hashtable[HASHTABLESIZE]; -static int strtable_end = -1; /* Tells us last occupied string - * space */ +static int strtable_end = -1; /* Tells us last occupied string space */ /*- * Basic information associated with each type. This is used before @@ -150,12 +149,12 @@ static int strtable_end = -1; /* Tells us last occupied string */ struct typinfo { - char name[NAMEDATALEN]; - Oid oid; - Oid elem; - int16 len; - Oid inproc; - Oid outproc; + char name[NAMEDATALEN]; + Oid oid; + Oid elem; + int16 len; + Oid inproc; + Oid outproc; }; static struct typinfo Procid[] = { @@ -180,29 +179,29 @@ static struct typinfo Procid[] = { {"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT} }; -static int n_types = sizeof(Procid) / sizeof(struct typinfo); +static int n_types = sizeof(Procid) / sizeof(struct typinfo); struct typmap { /* a hack */ - Oid am_oid; + Oid am_oid; TypeTupleFormData am_typ; }; static struct typmap **Typ = (struct typmap **) NULL; static struct typmap *Ap = (struct typmap *) NULL; -static int Warnings = 0; -static char Blanks[MAXATTR]; +static int Warnings = 0; +static char Blanks[MAXATTR]; -static char *relname; /* current relation name */ +static char *relname; /* current relation name */ AttributeTupleForm attrtypes[MAXATTR]; /* points to attribute info */ -static char *values[MAXATTR];/* cooresponding attribute values */ -int numattr; /* number of attributes for cur. rel */ -extern int fsyncOff; /* do not fsync the database */ +static char *values[MAXATTR]; /* cooresponding attribute values */ +int numattr; /* number of attributes for cur. rel */ +extern int fsyncOff; /* do not fsync the database */ #ifndef HAVE_SIGSETJMP -static jmp_buf Warn_restart; +static jmp_buf Warn_restart; #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp @@ -211,12 +210,12 @@ static sigjmp_buf Warn_restart; #endif -int DebugMode; +int DebugMode; static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem * context */ -extern int optind; -extern char *optarg; +extern int optind; +extern char *optarg; /* * At bootstrap time, we first declare all the indices to be built, and @@ -226,20 +225,20 @@ extern char *optarg; typedef struct _IndexList { - char *il_heap; - char *il_ind; - int il_natts; - AttrNumber *il_attnos; - uint16 il_nparams; - Datum *il_params; - FuncIndexInfo *il_finfo; - PredInfo *il_predInfo; + char *il_heap; + char *il_ind; + int il_natts; + AttrNumber *il_attnos; + uint16 il_nparams; + Datum *il_params; + FuncIndexInfo *il_finfo; + PredInfo *il_predInfo; struct _IndexList *il_next; -} IndexList; +} IndexList; static IndexList *ILHead = (IndexList *) NULL; -typedef void (*sig_func) (); +typedef void (*sig_func) (); @@ -293,15 +292,15 @@ BootstrapMain(int argc, char *argv[]) * ---------------------------------------------------------------- */ { - int i; - int portFd = -1; - char *dbName; - int flag; - int override = 1; /* use BootstrapProcessing or - * InitProcessing mode */ + int i; + int portFd = -1; + char *dbName; + int flag; + int override = 1; /* use BootstrapProcessing or + * InitProcessing mode */ - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; /* ---------------- * initialize signal handlers @@ -335,30 +334,30 @@ BootstrapMain(int argc, char *argv[]) { switch (flag) { - case 'D': - DataDir = optarg; - break; - case 'd': - DebugMode = 1; /* print out debugging info while parsing */ - break; - case 'C': - Noversion = 1; - break; - case 'F': - fsyncOff = 1; - break; - case 'O': - override = true; - break; - case 'Q': - Quiet = 1; - break; - case 'P': /* specify port */ - portFd = atoi(optarg); - break; - default: - usage(); - break; + case 'D': + DataDir = optarg; + break; + case 'd': + DebugMode = 1; /* print out debugging info while parsing */ + break; + case 'C': + Noversion = 1; + break; + case 'F': + fsyncOff = 1; + break; + case 'O': + override = true; + break; + case 'Q': + Quiet = 1; + break; + case 'P': /* specify port */ + portFd = atoi(optarg); + break; + default: + usage(); + break; } } /* while */ @@ -475,11 +474,11 @@ BootstrapMain(int argc, char *argv[]) void boot_openrel(char *relname) { - int i; + int i; struct typmap **app; - Relation rdesc; - HeapScanDesc sdesc; - HeapTuple tup; + Relation rdesc; + HeapScanDesc sdesc; + HeapTuple tup; if (strlen(relname) > 15) relname[15] = '\000'; @@ -603,8 +602,8 @@ closerel(char *name) void DefineAttr(char *name, char *type, int attnum) { - int attlen; - int t; + int attlen; + int t; if (reldesc != NULL) { @@ -646,10 +645,10 @@ DefineAttr(char *name, char *type, int attnum) void InsertOneTuple(Oid objectid) { - HeapTuple tuple; - TupleDesc tupDesc; + HeapTuple tuple; + TupleDesc tupDesc; - int i; + int i; if (DebugMode) { @@ -687,8 +686,8 @@ InsertOneTuple(Oid objectid) void InsertOneValue(Oid objectid, char *value, int i) { - int typeindex; - char *prt; + int typeindex; + char *prt; struct typmap **app; if (DebugMode) @@ -701,7 +700,7 @@ InsertOneValue(Oid objectid, char *value, int i) if (Typ != (struct typmap **) NULL) { - struct typmap *ap; + struct typmap *ap; if (DebugMode) puts("Typ != NULL"); @@ -767,13 +766,13 @@ InsertOneNull(int i) #define MORE_THAN_THE_NUMBER_OF_CATALOGS 256 -static bool +static bool BootstrapAlreadySeen(Oid id) { - static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS]; - static int nseen = 0; - bool seenthis; - int i; + static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS]; + static int nseen = 0; + bool seenthis; + int i; seenthis = false; @@ -800,7 +799,7 @@ BootstrapAlreadySeen(Oid id) static void cleanup() { - static int beenhere = 0; + static int beenhere = 0; if (!beenhere) beenhere = 1; @@ -824,10 +823,10 @@ cleanup() static int gettype(char *type) { - int i; - Relation rdesc; - HeapScanDesc sdesc; - HeapTuple tup; + int i; + Relation rdesc; + HeapScanDesc sdesc; + HeapTuple tup; struct typmap **app; if (Typ != (struct typmap **) NULL) @@ -885,7 +884,7 @@ gettype(char *type) * AllocateAttribute * ---------------- */ -static AttributeTupleForm /* XXX */ +static AttributeTupleForm /* XXX */ AllocateAttribute() { AttributeTupleForm attribute = @@ -914,13 +913,13 @@ AllocateAttribute() * be freed by the CALLER. * ---------------- */ -char * +char * MapArrayTypeName(char *s) { - int i, - j; - static char newStr[NAMEDATALEN]; /* array type names < - * NAMEDATALEN long */ + int i, + j; + static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN + * long */ if (s == NULL || s[0] == '\0') return s; @@ -944,8 +943,8 @@ MapArrayTypeName(char *s) int EnterString(char *str) { - hashnode *node; - int len; + hashnode *node; + int len; len = strlen(str); @@ -967,7 +966,7 @@ EnterString(char *str) * associated with the idnum * ---------------- */ -char * +char * LexIDStr(int ident_num) { return (strtable[ident_num]); @@ -986,7 +985,7 @@ LexIDStr(int ident_num) static int CompHash(char *str, int len) { - register int result; + register int result; result = (NUM * str[0] + NUMSQR * str[len - 1] + NUMCUBE * str[(len - 1) / 2]); @@ -1005,7 +1004,7 @@ CompHash(char *str, int len) static hashnode * FindStr(char *str, int length, hashnode * mderef) { - hashnode *node; + hashnode *node; node = hashtable[CompHash(str, length)]; while (node != NULL) @@ -1040,11 +1039,11 @@ FindStr(char *str, int length, hashnode * mderef) static hashnode * AddStr(char *str, int strlength, int mderef) { - hashnode *temp, - *trail, - *newnode; - int hashresult; - int len; + hashnode *temp, + *trail, + *newnode; + int hashresult; + int len; if (++strtable_end == STRTABLESIZE) { @@ -1118,10 +1117,10 @@ index_register(char *heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - Datum *v; - IndexList *newind; - int len; - MemoryContext oldcxt; + Datum *v; + IndexList *newind; + int len; + MemoryContext oldcxt; /* * XXX mao 10/31/92 -- don't gc index reldescs, associated info at @@ -1193,8 +1192,8 @@ index_register(char *heap, void build_indices() { - Relation heap; - Relation ind; + Relation heap; + Relation ind; for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next) { diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index a8abbb01ee..779dfec4b2 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.8 1997/09/07 04:40:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.9 1997/09/08 02:21:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,10 +26,10 @@ * relpath - path to the relation * Perhaps this should be in-line code in relopen(). */ -char * +char * relpath(char relname[]) { - char *path; + char *path; if (IsSharedSystemRelationName(relname)) { @@ -91,7 +91,7 @@ IsSystemRelationName(char *relname) bool IsSharedSystemRelationName(char *relname) { - int i; + int i; /* * Quick out: if it's not a system relation, it can't be a shared @@ -128,7 +128,7 @@ IsSharedSystemRelationName(char *relname) Oid newoid() { - Oid lastoid; + Oid lastoid; GetNewObjectId(&lastoid); if (!OidIsValid(lastoid)) @@ -156,9 +156,9 @@ fillatt(TupleDesc tupleDesc) { AttributeTupleForm *attributeP; register TypeTupleForm typp; - HeapTuple tuple; - int i; - int natts = tupleDesc->natts; + HeapTuple tuple; + int i; + int natts = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; if (natts < 0 || natts > MaxHeapAttributeNumber) diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index c80ddb9727..1fbb505400 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.25 1997/09/07 04:40:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.26 1997/09/08 02:21:37 momjian Exp $ * * INTERFACE ROUTINES * heap_creatr() - Create an uncataloged heap relation @@ -61,17 +61,17 @@ static void AddPgRelationTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, int arch, unsigned natts); -static void AddToTempRelList(Relation r); -static void DeletePgAttributeTuples(Relation rdesc); -static void DeletePgRelationTuple(Relation rdesc); -static void DeletePgTypeTuple(Relation rdesc); -static int RelationAlreadyExists(Relation pg_class_desc, char relname[]); -static void RelationRemoveIndexes(Relation relation); -static void RelationRemoveInheritance(Relation relation); -static void RemoveFromTempRelList(Relation r); -static void addNewRelationType(char *typeName, Oid new_rel_oid); -static void StoreConstraints(Relation rel); -static void RemoveConstraints(Relation rel); +static void AddToTempRelList(Relation r); +static void DeletePgAttributeTuples(Relation rdesc); +static void DeletePgRelationTuple(Relation rdesc); +static void DeletePgTypeTuple(Relation rdesc); +static int RelationAlreadyExists(Relation pg_class_desc, char relname[]); +static void RelationRemoveIndexes(Relation relation); +static void RelationRemoveInheritance(Relation relation); +static void RemoveFromTempRelList(Relation r); +static void addNewRelationType(char *typeName, Oid new_rel_oid); +static void StoreConstraints(Relation rel); +static void RemoveConstraints(Relation rel); /* ---------------------------------------------------------------- @@ -160,11 +160,11 @@ static AttributeTupleForm HeapAtt[] = */ typedef struct tempRelList { - Relation *rels; /* array of relation descriptors */ - int num; /* number of temporary relations */ - int size; /* size of space allocated for the rels + Relation *rels; /* array of relation descriptors */ + int num; /* number of temporary relations */ + int size; /* size of space allocated for the rels * array */ -} TempRelList; +} TempRelList; #define TEMP_REL_LIST_SIZE 32 @@ -194,19 +194,19 @@ heap_creatr(char *name, TupleDesc tupDesc) { register unsigned i; - Oid relid; - Relation rdesc; - int len; - bool nailme = false; - char *relname = name; - char tempname[40]; - int isTemp = 0; - int natts = tupDesc->natts; + Oid relid; + Relation rdesc; + int len; + bool nailme = false; + char *relname = name; + char tempname[40]; + int isTemp = 0; + int natts = tupDesc->natts; /* AttributeTupleForm *att = tupDesc->attrs; */ extern GlobalMemory CacheCxt; - MemoryContext oldcxt; + MemoryContext oldcxt; /* ---------------- * sanity checks @@ -425,9 +425,9 @@ heap_creatr(char *name, static void CheckAttributeNames(TupleDesc tupdesc) { - unsigned i; - unsigned j; - int natts = tupdesc->natts; + unsigned i; + unsigned j; + int natts = tupdesc->natts; /* ---------------- * first check for collision with system attribute names @@ -487,9 +487,9 @@ CheckAttributeNames(TupleDesc tupdesc) static int RelationAlreadyExists(Relation pg_class_desc, char relname[]) { - ScanKeyData key; - HeapScanDesc pg_class_scan; - HeapTuple tup; + ScanKeyData key; + HeapScanDesc pg_class_scan; + HeapTuple tup; /* * If this is not bootstrap (initdb) time, use the catalog index on @@ -558,12 +558,12 @@ AddNewAttributeTuples(Oid new_rel_oid, TupleDesc tupdesc) { AttributeTupleForm *dpp; - unsigned i; - HeapTuple tup; - Relation rdesc; - bool hasindex; - Relation idescs[Num_pg_attr_indices]; - int natts = tupdesc->natts; + unsigned i; + HeapTuple tup; + Relation rdesc; + bool hasindex; + Relation idescs[Num_pg_attr_indices]; + int natts = tupdesc->natts; /* ---------------- * open pg_attribute @@ -659,12 +659,12 @@ AddPgRelationTuple(Relation pg_class_desc, int arch, unsigned natts) { - Form_pg_class new_rel_reltup; - HeapTuple tup; - Relation idescs[Num_pg_class_indices]; - bool isBootstrap; - extern bool ItsSequenceCreation; /* It's hack, I know... - - * vadim 03/28/97 */ + Form_pg_class new_rel_reltup; + HeapTuple tup; + Relation idescs[Num_pg_class_indices]; + bool isBootstrap; + extern bool ItsSequenceCreation; /* It's hack, I know... - vadim + * 03/28/97 */ /* ---------------- * first we munge some of the information in our @@ -737,7 +737,7 @@ AddPgRelationTuple(Relation pg_class_desc, static void addNewRelationType(char *typeName, Oid new_rel_oid) { - Oid new_type_oid; + Oid new_type_oid; /* * The sizes are set to oid size because it makes implementing sets @@ -778,12 +778,12 @@ heap_create(char relname[], unsigned smgr, TupleDesc tupdesc) { - Relation pg_class_desc; - Relation new_rel_desc; - Oid new_rel_oid; + Relation pg_class_desc; + Relation new_rel_desc; + Oid new_rel_oid; /* NameData typeNameData; */ - int natts = tupdesc->natts; + int natts = tupdesc->natts; /* ---------------- * sanity checks @@ -906,10 +906,10 @@ heap_create(char relname[], static void RelationRemoveInheritance(Relation relation) { - Relation catalogRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation catalogRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; /* ---------------- * open pg_inherits @@ -1010,10 +1010,10 @@ RelationRemoveInheritance(Relation relation) static void RelationRemoveIndexes(Relation relation) { - Relation indexRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation indexRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; indexRelation = heap_openr(IndexRelationName); @@ -1050,10 +1050,10 @@ RelationRemoveIndexes(Relation relation) static void DeletePgRelationTuple(Relation rdesc) { - Relation pg_class_desc; - HeapScanDesc pg_class_scan; - ScanKeyData key; - HeapTuple tup; + Relation pg_class_desc; + HeapScanDesc pg_class_scan; + ScanKeyData key; + HeapTuple tup; /* ---------------- * open pg_class @@ -1108,10 +1108,10 @@ DeletePgRelationTuple(Relation rdesc) static void DeletePgAttributeTuples(Relation rdesc) { - Relation pg_attribute_desc; - HeapScanDesc pg_attribute_scan; - ScanKeyData key; - HeapTuple tup; + Relation pg_attribute_desc; + HeapScanDesc pg_attribute_scan; + ScanKeyData key; + HeapTuple tup; /* ---------------- * open pg_attribute @@ -1178,15 +1178,15 @@ DeletePgAttributeTuples(Relation rdesc) static void DeletePgTypeTuple(Relation rdesc) { - Relation pg_type_desc; - HeapScanDesc pg_type_scan; - Relation pg_attribute_desc; - HeapScanDesc pg_attribute_scan; - ScanKeyData key; - ScanKeyData attkey; - HeapTuple tup; - HeapTuple atttup; - Oid typoid; + Relation pg_type_desc; + HeapScanDesc pg_type_scan; + Relation pg_attribute_desc; + HeapScanDesc pg_attribute_scan; + ScanKeyData key; + ScanKeyData attkey; + HeapTuple tup; + HeapTuple atttup; + Oid typoid; /* ---------------- * open pg_type @@ -1254,7 +1254,7 @@ DeletePgTypeTuple(Relation rdesc) if (PointerIsValid(atttup)) { - Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid; + Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid; heap_endscan(pg_type_scan); heap_close(pg_type_desc); @@ -1287,8 +1287,8 @@ DeletePgTypeTuple(Relation rdesc) void heap_destroy(char *relname) { - Relation rdesc; - Oid rid; + Relation rdesc; + Oid rid; /* ---------------- * first open the relation. if the relation does exist, @@ -1458,7 +1458,7 @@ InitTempRelList(void) static void RemoveFromTempRelList(Relation r) { - int i; + int i; if (!tempRels) return; @@ -1500,8 +1500,8 @@ AddToTempRelList(Relation r) void DestroyTempRels(void) { - int i; - Relation rdesc; + int i; + Relation rdesc; if (!tempRels) return; @@ -1518,30 +1518,30 @@ DestroyTempRels(void) tempRels = NULL; } -extern List *flatten_tlist(List * tlist); -extern List * +extern List *flatten_tlist(List * tlist); +extern List * pg_plan(char *query_string, Oid * typev, int nargs, QueryTreeList ** queryListP, CommandDest dest); static void StoreAttrDefault(Relation rel, AttrDefault * attrdef) { - char str[MAX_PARSE_BUFFER]; - char cast[2 * NAMEDATALEN] = {0}; + char str[MAX_PARSE_BUFFER]; + char cast[2 * NAMEDATALEN] = {0}; AttributeTupleForm atp = rel->rd_att->attrs[attrdef->adnum - 1]; - QueryTreeList *queryTree_list; - Query *query; - List *planTree_list; - TargetEntry *te; - Resdom *resdom; - Node *expr; - char *adbin; - MemoryContext oldcxt; - Relation adrel; - Relation idescs[Num_pg_attrdef_indices]; - HeapTuple tuple; - Datum values[4]; - char nulls[4] = {' ', ' ', ' ', ' '}; + QueryTreeList *queryTree_list; + Query *query; + List *planTree_list; + TargetEntry *te; + Resdom *resdom; + Node *expr; + char *adbin; + MemoryContext oldcxt; + Relation adrel; + Relation idescs[Num_pg_attrdef_indices]; + HeapTuple tuple; + Datum values[4]; + char nulls[4] = {' ', ' ', ' ', ' '}; extern GlobalMemory CacheCxt; start:; @@ -1600,19 +1600,19 @@ start:; static void StoreRelCheck(Relation rel, ConstrCheck * check) { - char str[MAX_PARSE_BUFFER]; - QueryTreeList *queryTree_list; - Query *query; - List *planTree_list; - Plan *plan; - List *qual; - char *ccbin; - MemoryContext oldcxt; - Relation rcrel; - Relation idescs[Num_pg_relcheck_indices]; - HeapTuple tuple; - Datum values[4]; - char nulls[4] = {' ', ' ', ' ', ' '}; + char str[MAX_PARSE_BUFFER]; + QueryTreeList *queryTree_list; + Query *query; + List *planTree_list; + Plan *plan; + List *qual; + char *ccbin; + MemoryContext oldcxt; + Relation rcrel; + Relation idescs[Num_pg_relcheck_indices]; + HeapTuple tuple; + Datum values[4]; + char nulls[4] = {' ', ' ', ' ', ' '}; extern GlobalMemory CacheCxt; sprintf(str, "select 1 from %.*s where %s", @@ -1659,8 +1659,8 @@ StoreRelCheck(Relation rel, ConstrCheck * check) static void StoreConstraints(Relation rel) { - TupleConstr *constr = rel->rd_att->constr; - int i; + TupleConstr *constr = rel->rd_att->constr; + int i; if (!constr) return; @@ -1683,10 +1683,10 @@ StoreConstraints(Relation rel) static void RemoveAttrDefault(Relation rel) { - Relation adrel; - HeapScanDesc adscan; - ScanKeyData key; - HeapTuple tup; + Relation adrel; + HeapScanDesc adscan; + ScanKeyData key; + HeapTuple tup; adrel = heap_openr(AttrDefaultRelationName); @@ -1710,10 +1710,10 @@ RemoveAttrDefault(Relation rel) static void RemoveRelCheck(Relation rel) { - Relation rcrel; - HeapScanDesc rcscan; - ScanKeyData key; - HeapTuple tup; + Relation rcrel; + HeapScanDesc rcscan; + ScanKeyData key; + HeapTuple tup; rcrel = heap_openr(RelCheckRelationName); @@ -1737,7 +1737,7 @@ RemoveRelCheck(Relation rel) static void RemoveConstraints(Relation rel) { - TupleConstr *constr = rel->rd_att->constr; + TupleConstr *constr = rel->rd_att->constr; if (!constr) return; diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 6dd7574279..d6459fbe2b 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.20 1997/09/07 04:40:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.21 1997/09/08 02:21:40 momjian Exp $ * * * INTERFACE ROUTINES @@ -66,21 +66,21 @@ static Oid RelationNameGetObjectId(char *relationName, Relation pg_class, bool setHasIndexAttribute); -static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName); +static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName); static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo); static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, List * attributeList, int numatts, AttrNumber attNums[]); -static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); -static Oid UpdateRelationRelation(Relation indexRelation); +static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); +static Oid UpdateRelationRelation(Relation indexRelation); static void InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid); static void - AppendAttributeTuples(Relation indexRelation, int numatts); + AppendAttributeTuples(Relation indexRelation, int numatts); static void UpdateIndexRelation(Oid indexoid, Oid heapoid, FuncIndexInfo * funcInfo, int natts, @@ -144,16 +144,16 @@ static FormData_pg_attribute sysatts[] = { * Assumes relation descriptor is valid. * ---------------------------------------------------------------- */ -static Oid +static Oid RelationNameGetObjectId(char *relationName, Relation pg_class, bool setHasIndexAttribute) { - HeapScanDesc pg_class_scan; - HeapTuple pg_class_tuple; - Oid relationObjectId; - Buffer buffer; - ScanKeyData key; + HeapScanDesc pg_class_scan; + HeapTuple pg_class_tuple; + Oid relationObjectId; + Buffer buffer; + ScanKeyData key; /* * If this isn't bootstrap time, we can use the system catalogs to @@ -217,12 +217,12 @@ RelationNameGetObjectId(char *relationName, * GetHeapRelationOid * ---------------------------------------------------------------- */ -static Oid +static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName) { - Relation pg_class; - Oid indoid; - Oid heapoid; + Relation pg_class; + Oid indoid; + Oid heapoid; /* ---------------- * XXX ADD INDEXING HERE @@ -268,15 +268,15 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName) return heapoid; } -static TupleDesc +static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo) { - HeapTuple tuple; - TupleDesc funcTupDesc; - Oid retType; - char *funcname; - int4 nargs; - Oid *argtypes; + HeapTuple tuple; + TupleDesc funcTupDesc; + Oid retType; + char *funcname; + int4 nargs; + Oid *argtypes; /* * Allocate and zero a tuple descriptor. @@ -331,23 +331,23 @@ BuildFuncTupleDesc(FuncIndexInfo * funcInfo) * ConstructTupleDescriptor * ---------------------------------------------------------------- */ -static TupleDesc +static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, List * attributeList, int numatts, AttrNumber attNums[]) { - TupleDesc heapTupDesc; - TupleDesc indexTupDesc; - IndexElem *IndexKey; - TypeName *IndexKeyType; - AttrNumber atnum; /* attributeNumber[attributeOffset] */ - AttrNumber atind; - int natts; /* RelationTupleForm->relnatts */ - char *from; /* used to simplify memcpy below */ - char *to; /* used to simplify memcpy below */ - int i; + TupleDesc heapTupDesc; + TupleDesc indexTupDesc; + IndexElem *IndexKey; + TypeName *IndexKeyType; + AttrNumber atnum; /* attributeNumber[attributeOffset] */ + AttrNumber atind; + int natts; /* RelationTupleForm->relnatts */ + char *from; /* used to simplify memcpy below */ + char *to; /* used to simplify memcpy below */ + int i; /* ---------------- * allocate the new tuple descriptor @@ -447,7 +447,7 @@ ConstructTupleDescriptor(Oid heapoid, */ if (IndexKeyType != NULL) { - HeapTuple tup; + HeapTuple tup; tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(IndexKeyType->name), @@ -491,11 +491,11 @@ ConstructTupleDescriptor(Oid heapoid, Form_pg_am AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId) { - Relation pg_am_desc; - HeapScanDesc pg_am_scan; - HeapTuple pg_am_tuple; - ScanKeyData key; - Form_pg_am form; + Relation pg_am_desc; + HeapScanDesc pg_am_scan; + HeapTuple pg_am_tuple; + ScanKeyData key; + Form_pg_am form; /* ---------------- * form a scan key for the pg_am relation @@ -546,7 +546,7 @@ static void ConstructIndexReldesc(Relation indexRelation, Oid amoid) { extern GlobalMemory CacheCxt; - MemoryContext oldcxt; + MemoryContext oldcxt; /* ---------------- * here we make certain to allocate the access method @@ -583,13 +583,13 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid) * UpdateRelationRelation * ---------------------------------------------------------------- */ -static Oid +static Oid UpdateRelationRelation(Relation indexRelation) { - Relation pg_class; - HeapTuple tuple; - Oid tupleOid; - Relation idescs[Num_pg_class_indices]; + Relation pg_class; + HeapTuple tuple; + Oid tupleOid; + Relation idescs[Num_pg_class_indices]; pg_class = heap_openr(RelationRelationName); @@ -637,8 +637,8 @@ InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid) { - TupleDesc tupleDescriptor; - int i; + TupleDesc tupleDescriptor; + int i; tupleDescriptor = RelationGetTupleDescriptor(indexRelation); @@ -655,18 +655,18 @@ InitializeAttributeOids(Relation indexRelation, static void AppendAttributeTuples(Relation indexRelation, int numatts) { - Relation pg_attribute; - HeapTuple tuple; - HeapTuple newtuple; - bool hasind; - Relation idescs[Num_pg_attr_indices]; + Relation pg_attribute; + HeapTuple tuple; + HeapTuple newtuple; + bool hasind; + Relation idescs[Num_pg_attr_indices]; - Datum value[Natts_pg_attribute]; - char nullv[Natts_pg_attribute]; - char replace[Natts_pg_attribute]; + Datum value[Natts_pg_attribute]; + char nullv[Natts_pg_attribute]; + char replace[Natts_pg_attribute]; - TupleDesc indexTupDesc; - int i; + TupleDesc indexTupDesc; + int i; /* ---------------- * open the attribute relation @@ -786,15 +786,15 @@ UpdateIndexRelation(Oid indexoid, bool islossy, bool unique) { - IndexTupleForm indexForm; - IndexElem *IndexKey; - char *predString; - text *predText; - int predLen, - itupLen; - Relation pg_index; - HeapTuple tuple; - int i; + IndexTupleForm indexForm; + IndexElem *IndexKey; + char *predString; + text *predText; + int predLen, + itupLen; + Relation pg_index; + HeapTuple tuple; + int i; /* ---------------- * allocate an IndexTupleForm big enough to hold the @@ -903,19 +903,19 @@ UpdateIndexRelation(Oid indexoid, void UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate) { - Node *newPred; - char *predString; - text *predText; - Relation pg_index; - HeapTuple tuple; - HeapTuple newtup; - ScanKeyData entry; - HeapScanDesc scan; - Buffer buffer; - int i; - Datum values[Natts_pg_index]; - char nulls[Natts_pg_index]; - char replace[Natts_pg_index]; + Node *newPred; + char *predString; + text *predText; + Relation pg_index; + HeapTuple tuple; + HeapTuple newtup; + ScanKeyData entry; + HeapScanDesc scan; + Buffer buffer; + int i; + Datum values[Natts_pg_index]; + char nulls[Natts_pg_index]; + char replace[Natts_pg_index]; /* * Construct newPred as a CNF expression equivalent to the OR of the @@ -988,12 +988,12 @@ InitIndexStrategy(int numatts, Relation indexRelation, Oid accessMethodObjectId) { - IndexStrategy strategy; - RegProcedure *support; - uint16 amstrategies; - uint16 amsupport; - Oid attrelid; - Size strsize; + IndexStrategy strategy; + RegProcedure *support; + uint16 amstrategies; + uint16 amsupport; + Oid attrelid; + Size strsize; extern GlobalMemory CacheCxt; /* ---------------- @@ -1077,12 +1077,12 @@ index_create(char *heapRelationName, bool islossy, bool unique) { - Relation heapRelation; - Relation indexRelation; - TupleDesc indexTupDesc; - Oid heapoid; - Oid indexoid; - PredInfo *predInfo; + Relation heapRelation; + Relation indexRelation; + TupleDesc indexTupDesc; + Oid heapoid; + Oid indexoid; + PredInfo *predInfo; /* ---------------- * check parameters @@ -1150,7 +1150,7 @@ index_create(char *heapRelationName, if (PointerIsValid(funcInfo)) { - HeapTuple proc_tup; + HeapTuple proc_tup; proc_tup = SearchSysCacheTuple(PRONAME, PointerGetDatum(FIgetname(funcInfo)), @@ -1231,11 +1231,11 @@ index_create(char *heapRelationName, void index_destroy(Oid indexId) { - Relation indexRelation; - Relation catalogRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation indexRelation; + Relation catalogRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; Assert(OidIsValid(indexId)); @@ -1325,9 +1325,9 @@ FormIndexDatum(int numberOfAttributes, char *nullv, FuncIndexInfoPtr fInfo) { - AttrNumber i; - int offset; - bool isNull; + AttrNumber i; + int offset; + bool isNull; /* ---------------- * for each attribute we need from the heap tuple, @@ -1361,23 +1361,23 @@ FormIndexDatum(int numberOfAttributes, void UpdateStats(Oid relid, long reltuples, bool hasindex) { - Relation whichRel; - Relation pg_class; - HeapScanDesc pg_class_scan; - HeapTuple htup; - HeapTuple newtup; - long relpages; - Buffer buffer; - int i; - Form_pg_class rd_rel; - Relation idescs[Num_pg_class_indices]; + Relation whichRel; + Relation pg_class; + HeapScanDesc pg_class_scan; + HeapTuple htup; + HeapTuple newtup; + long relpages; + Buffer buffer; + int i; + Form_pg_class rd_rel; + Relation idescs[Num_pg_class_indices]; static ScanKeyData key[1] = { {0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure} }; - Datum values[Natts_pg_class]; - char nulls[Natts_pg_class]; - char replace[Natts_pg_class]; + Datum values[Natts_pg_class]; + char nulls[Natts_pg_class]; + char replace[Natts_pg_class]; fmgr_info(ObjectIdEqualRegProcedure, (func_ptr *) & key[0].sk_func, &key[0].sk_nargs); @@ -1534,26 +1534,26 @@ DefaultBuild(Relation heapRelation, FuncIndexInfoPtr funcInfo, PredInfo * predInfo) { - HeapScanDesc scan; - HeapTuple heapTuple; - Buffer buffer; - - IndexTuple indexTuple; - TupleDesc heapDescriptor; - TupleDesc indexDescriptor; - Datum *datum; - char *nullv; - long reltuples, - indtuples; + HeapScanDesc scan; + HeapTuple heapTuple; + Buffer buffer; + + IndexTuple indexTuple; + TupleDesc heapDescriptor; + TupleDesc indexDescriptor; + Datum *datum; + char *nullv; + long reltuples, + indtuples; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Node *predicate; - Node *oldPred; + Node *predicate; + Node *oldPred; InsertIndexResult insertResult; @@ -1736,7 +1736,7 @@ index_build(Relation heapRelation, FuncIndexInfo * funcInfo, PredInfo * predInfo) { - RegProcedure procedure; + RegProcedure procedure; /* ---------------- * sanity checks @@ -1781,8 +1781,8 @@ index_build(Relation heapRelation, bool IndexIsUnique(Oid indexId) { - HeapTuple tuple; - IndexTupleForm index; + HeapTuple tuple; + IndexTupleForm index; tuple = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(indexId), @@ -1813,12 +1813,12 @@ IndexIsUnique(Oid indexId) bool IndexIsUniqueNoCache(Oid indexId) { - Relation pg_index; - ScanKeyData skey[1]; - HeapScanDesc scandesc; - HeapTuple tuple; - IndexTupleForm index; - bool isunique; + Relation pg_index; + ScanKeyData skey[1]; + HeapScanDesc scandesc; + HeapTuple tuple; + IndexTupleForm index; + bool isunique; pg_index = heap_openr(IndexRelationName); diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 6a89258d97..5dca2e3d9a 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.12 1997/09/07 04:40:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.13 1997/09/08 02:21:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,21 +44,21 @@ * pg_trigger */ -char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, +char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, AttributeNumIndex, AttributeRelidIndex}; -char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, +char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, ProcedureOidIndex, ProcedureSrcIndex}; -char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, +char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, TypeOidIndex}; -char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, +char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, ClassOidIndex}; -char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; +char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; -char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; +char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; -char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; +char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; static HeapTuple @@ -76,7 +76,7 @@ CatalogIndexFetchTuple(Relation heapRelation, void CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]) { - int i; + int i; for (i = 0; i < nIndices; i++) { @@ -90,7 +90,7 @@ CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]) void CatalogCloseIndices(int nIndices, Relation * idescs) { - int i; + int i; for (i = 0; i < nIndices; i++) index_close(idescs[i]); @@ -108,22 +108,22 @@ CatalogIndexInsert(Relation * idescs, Relation heapRelation, HeapTuple heapTuple) { - HeapTuple pgIndexTup; - TupleDesc heapDescriptor; - IndexTupleForm pgIndexP; - Datum datum; - int natts; - AttrNumber *attnumP; - FuncIndexInfo finfo, - *finfoP; - char nulls[INDEX_MAX_KEYS]; - int i; + HeapTuple pgIndexTup; + TupleDesc heapDescriptor; + IndexTupleForm pgIndexP; + Datum datum; + int natts; + AttrNumber *attnumP; + FuncIndexInfo finfo, + *finfoP; + char nulls[INDEX_MAX_KEYS]; + int i; heapDescriptor = RelationGetTupleDescriptor(heapRelation); for (i = 0; i < nIndices; i++) { - TupleDesc indexDescriptor; + TupleDesc indexDescriptor; InsertIndexResult indexRes; indexDescriptor = RelationGetTupleDescriptor(idescs[i]); @@ -176,10 +176,10 @@ CatalogIndexInsert(Relation * idescs, bool CatalogHasIndex(char *catName, Oid catId) { - Relation pg_class; - HeapTuple htup; - Form_pg_class pgRelP; - int i; + Relation pg_class; + HeapTuple htup; + Form_pg_class pgRelP; + int i; Assert(IsSystemRelationName(catName)); @@ -221,15 +221,15 @@ CatalogHasIndex(char *catName, Oid catId) * iterate until we find a tuple that's valid and satisfies the scan * key. */ -static HeapTuple +static HeapTuple CatalogIndexFetchTuple(Relation heapRelation, Relation idesc, ScanKey skey) { - IndexScanDesc sd; + IndexScanDesc sd; RetrieveIndexResult indexRes; - HeapTuple tuple; - Buffer buffer; + HeapTuple tuple; + Buffer buffer; sd = index_beginscan(idesc, false, 1, skey); tuple = (HeapTuple) NULL; @@ -239,7 +239,7 @@ CatalogIndexFetchTuple(Relation heapRelation, indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -271,10 +271,10 @@ AttributeNameIndexScan(Relation heapRelation, Oid relid, char *attname) { - Relation idesc; - ScanKeyData skey; - OidName keyarg; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + OidName keyarg; + HeapTuple tuple; keyarg = mkoidname(relid, attname); ScanKeyEntryInitialize(&skey, @@ -297,10 +297,10 @@ AttributeNumIndexScan(Relation heapRelation, Oid relid, AttrNumber attnum) { - Relation idesc; - ScanKeyData skey; - OidInt2 keyarg; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + OidInt2 keyarg; + HeapTuple tuple; keyarg = mkoidint2(relid, (uint16) attnum); ScanKeyEntryInitialize(&skey, @@ -321,9 +321,9 @@ AttributeNumIndexScan(Relation heapRelation, HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -347,22 +347,21 @@ ProcedureNameIndexScan(Relation heapRelation, int nargs, Oid * argTypes) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; /* tuple being tested */ - HeapTuple return_tuple; /* The tuple pointer we eventually - * return */ - IndexScanDesc sd; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; /* tuple being tested */ + HeapTuple return_tuple; /* The tuple pointer we eventually return */ + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - Form_pg_proc pgProcP; - bool ScanComplete; + Buffer buffer; + Form_pg_proc pgProcP; + bool ScanComplete; /* * The index scan is complete, i.e. we've scanned everything there is * to scan. */ - bool FoundMatch; + bool FoundMatch; /* * In scanning pg_proc, we have found a row that meets our search @@ -392,7 +391,7 @@ ProcedureNameIndexScan(Relation heapRelation, indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -438,12 +437,12 @@ ProcedureNameIndexScan(Relation heapRelation, HeapTuple ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) { - Relation idesc; - IndexScanDesc sd; - ScanKeyData skey; + Relation idesc; + IndexScanDesc sd; + ScanKeyData skey; RetrieveIndexResult indexRes; - HeapTuple tuple; - Buffer buffer; + HeapTuple tuple; + Buffer buffer; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -457,7 +456,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -480,9 +479,9 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -501,9 +500,9 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId) HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -522,9 +521,9 @@ TypeNameIndexScan(Relation heapRelation, char *typeName) HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -543,9 +542,9 @@ ClassNameIndexScan(Relation heapRelation, char *relName) HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 540350bac9..32c89110c0 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.6 1997/09/07 04:40:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.7 1997/09/08 02:21:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,21 +64,21 @@ AggregateCreate(char *aggName, char *agginitval1, char *agginitval2) { - register i; - Relation aggdesc; - HeapTuple tup; - char nulls[Natts_pg_aggregate]; - Datum values[Natts_pg_aggregate]; - Form_pg_proc proc; - Oid xfn1 = InvalidOid; - Oid xfn2 = InvalidOid; - Oid ffn = InvalidOid; - Oid xbase = InvalidOid; - Oid xret1 = InvalidOid; - Oid xret2 = InvalidOid; - Oid fret = InvalidOid; - Oid fnArgs[8]; - TupleDesc tupDesc; + register i; + Relation aggdesc; + HeapTuple tup; + char nulls[Natts_pg_aggregate]; + Datum values[Natts_pg_aggregate]; + Form_pg_proc proc; + Oid xfn1 = InvalidOid; + Oid xfn2 = InvalidOid; + Oid ffn = InvalidOid; + Oid xbase = InvalidOid; + Oid xret1 = InvalidOid; + Oid xret2 = InvalidOid; + Oid fret = InvalidOid; + Oid fnArgs[8]; + TupleDesc tupDesc; memset(fnArgs, 0, 8 * sizeof(Oid)); @@ -267,16 +267,16 @@ AggregateCreate(char *aggName, } -char * +char * AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull) { - HeapTuple tup; - Relation aggRel; - int initValAttno; - Oid transtype; - text *textInitVal; - char *strInitVal, - *initVal; + HeapTuple tup; + Relation aggRel; + int initValAttno; + Oid transtype; + text *textInitVal; + char *strInitVal, + *initVal; Assert(PointerIsValid(aggName)); Assert(PointerIsValid(isNull)); @@ -295,7 +295,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull) initValAttno = Anum_pg_aggregate_agginitval1; } else - /* can only be 1 or 2 */ + /* can only be 1 or 2 */ { transtype = ((Form_pg_aggregate) GETSTRUCT(tup))->aggtranstype2; initValAttno = Anum_pg_aggregate_agginitval2; diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 67a3a2f149..422c212811 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.12 1997/09/07 04:40:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.13 1997/09/08 02:21:48 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -66,7 +66,7 @@ OperatorDef(char *operatorName, bool canHash, char *leftSortName, char *rightSortName); -static void OperatorUpd(Oid baseId, Oid commId, Oid negId); +static void OperatorUpd(Oid baseId, Oid commId, Oid negId); /* ---------------------------------------------------------------- * OperatorGetWithOpenRelation @@ -79,15 +79,15 @@ static void OperatorUpd(Oid baseId, Oid commId, Oid negId); * leftObjectId -- left oid of operator to fetch * rightObjectId -- right oid of operator to fetch */ -static Oid +static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc, const char *operatorName, Oid leftObjectId, Oid rightObjectId) { - HeapScanDesc pg_operator_scan; - Oid operatorObjectId; - HeapTuple tup; + HeapScanDesc pg_operator_scan; + Oid operatorObjectId; + HeapTuple tup; static ScanKeyData opKey[3] = { {0, Anum_pg_operator_oprname, NameEqualRegProcedure}, @@ -145,18 +145,18 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, * and left and right type names. * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorGet(char *operatorName, char *leftTypeName, char *rightTypeName) { - Relation pg_operator_desc; + Relation pg_operator_desc; - Oid operatorObjectId; - Oid leftObjectId = InvalidOid; - Oid rightObjectId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; + Oid operatorObjectId; + Oid leftObjectId = InvalidOid; + Oid rightObjectId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; /* ---------------- * look up the operator types. @@ -216,18 +216,18 @@ OperatorGet(char *operatorName, * * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, char *operatorName, Oid leftObjectId, Oid rightObjectId) { - register int i; - HeapTuple tup; - Datum values[Natts_pg_operator]; - char nulls[Natts_pg_operator]; - Oid operatorObjectId; - TupleDesc tupDesc; + register int i; + HeapTuple tup; + Datum values[Natts_pg_operator]; + char nulls[Natts_pg_operator]; + Oid operatorObjectId; + TupleDesc tupDesc; /* ---------------- * initialize our nulls[] and values[] arrays @@ -300,18 +300,18 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, * to the caller. * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorShellMake(char *operatorName, char *leftTypeName, char *rightTypeName) { - Relation pg_operator_desc; - Oid operatorObjectId; + Relation pg_operator_desc; + Oid operatorObjectId; - Oid leftObjectId = InvalidOid; - Oid rightObjectId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; + Oid leftObjectId = InvalidOid; + Oid rightObjectId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; /* ---------------- * get the left and right type oid's for this operator @@ -450,29 +450,29 @@ OperatorDef(char *operatorName, char *leftSortName, char *rightSortName) { - register i, - j; - Relation pg_operator_desc; + register i, + j; + Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; - Buffer buffer; + HeapScanDesc pg_operator_scan; + HeapTuple tup; + Buffer buffer; ItemPointerData itemPointerData; - char nulls[Natts_pg_operator]; - char replaces[Natts_pg_operator]; - Datum values[Natts_pg_operator]; - Oid other_oid = 0; - Oid operatorObjectId; - Oid leftTypeId = InvalidOid; - Oid rightTypeId = InvalidOid; - Oid commutatorId = InvalidOid; - Oid negatorId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; - char *name[4]; - Oid typeId[8]; - int nargs; - TupleDesc tupDesc; + char nulls[Natts_pg_operator]; + char replaces[Natts_pg_operator]; + Datum values[Natts_pg_operator]; + Oid other_oid = 0; + Oid operatorObjectId; + Oid leftTypeId = InvalidOid; + Oid rightTypeId = InvalidOid; + Oid commutatorId = InvalidOid; + Oid negatorId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; + char *name[4]; + Oid typeId[8]; + int nargs; + TupleDesc tupDesc; static ScanKeyData opKey[3] = { {0, Anum_pg_operator_oprname, NameEqualRegProcedure}, @@ -765,15 +765,15 @@ OperatorDef(char *operatorName, static void OperatorUpd(Oid baseId, Oid commId, Oid negId) { - register i; - Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; - Buffer buffer; + register i; + Relation pg_operator_desc; + HeapScanDesc pg_operator_scan; + HeapTuple tup; + Buffer buffer; ItemPointerData itemPointerData; - char nulls[Natts_pg_operator]; - char replaces[Natts_pg_operator]; - Datum values[Natts_pg_operator]; + char nulls[Natts_pg_operator]; + char replaces[Natts_pg_operator]; + Datum values[Natts_pg_operator]; static ScanKeyData opKey[1] = { {0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure}, @@ -985,11 +985,11 @@ OperatorCreate(char *operatorName, char *leftSortName, char *rightSortName) { - Oid commObjectId, - negObjectId; - Oid leftSortObjectId, - rightSortObjectId; - int definedOK; + Oid commObjectId, + negObjectId; + Oid leftSortObjectId, + rightSortObjectId; + int definedOK; if (!leftTypeName && !rightTypeName) elog(WARN, "OperatorCreate : at least one of leftarg or rightarg must be defined"); diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 1dd1b0867c..e135784ca6 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.6 1997/09/07 04:40:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.7 1997/09/08 02:21:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,23 +55,23 @@ ProcedureCreate(char *procedureName, List * argList, CommandDest dest) { - register i; - Relation rdesc; - HeapTuple tup; - bool defined; - uint16 parameterCount; - char nulls[Natts_pg_proc]; - Datum values[Natts_pg_proc]; - Oid languageObjectId; - Oid typeObjectId; - List *x; - QueryTreeList *querytree_list; - List *plan_list; - Oid typev[8]; - Oid relid; - Oid toid; - text *prosrctext; - TupleDesc tupDesc; + register i; + Relation rdesc; + HeapTuple tup; + bool defined; + uint16 parameterCount; + char nulls[Natts_pg_proc]; + Datum values[Natts_pg_proc]; + Oid languageObjectId; + Oid typeObjectId; + List *x; + QueryTreeList *querytree_list; + List *plan_list; + Oid typev[8]; + Oid relid; + Oid toid; + text *prosrctext; + TupleDesc tupDesc; /* ---------------- * sanity checks @@ -84,7 +84,7 @@ ProcedureCreate(char *procedureName, memset(typev, 0, 8 * sizeof(Oid)); foreach(x, argList) { - Value *t = lfirst(x); + Value *t = lfirst(x); if (parameterCount == 8) elog(WARN, "Procedures cannot take more than 8 arguments"); @@ -270,7 +270,7 @@ ProcedureCreate(char *procedureName, if (RelationGetRelationTupleForm(rdesc)->relhasindex) { - Relation idescs[Num_pg_proc_indices]; + Relation idescs[Num_pg_proc_indices]; CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs); CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup); diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 9a31030421..63bae1ec59 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.8 1997/09/07 04:40:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.9 1997/09/08 02:21:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,13 +44,13 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, * typeName -- name of type to be fetched * defined -- has the type been defined? */ -static Oid +static Oid TypeGetWithOpenRelation(Relation pg_type_desc, char *typeName, bool * defined) { - HeapScanDesc scan; - HeapTuple tup; + HeapScanDesc scan; + HeapTuple tup; static ScanKeyData typeKey[1] = { {0, Anum_pg_type_typname, NameEqualRegProcedure} @@ -118,8 +118,8 @@ Oid TypeGet(char *typeName, /* name of type to be fetched */ bool * defined) /* has the type been defined? */ { - Relation pg_type_desc; - Oid typeoid; + Relation pg_type_desc; + Oid typeoid; /* ---------------- * open the pg_type relation @@ -150,15 +150,15 @@ TypeGet(char *typeName, /* name of type to be fetched */ * * ---------------------------------------------------------------- */ -static Oid +static Oid TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) { - register int i; - HeapTuple tup; - Datum values[Natts_pg_type]; - char nulls[Natts_pg_type]; - Oid typoid; - TupleDesc tupDesc; + register int i; + HeapTuple tup; + Datum values[Natts_pg_type]; + char nulls[Natts_pg_type]; + Oid typoid; + TupleDesc tupDesc; /* ---------------- * initialize our nulls[] and values[] arrays @@ -214,7 +214,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex) { - Relation idescs[Num_pg_type_indices]; + Relation idescs[Num_pg_type_indices]; CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup); @@ -246,8 +246,8 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) Oid TypeShellMake(char *typeName) { - Relation pg_type_desc; - Oid typoid; + Relation pg_type_desc; + Oid typoid; Assert(PointerIsValid(typeName)); @@ -295,27 +295,27 @@ TypeCreate(char *typeName, bool passedByValue, char alignment) { - register i, - j; - Relation pg_type_desc; - HeapScanDesc pg_type_scan; - - Oid typeObjectId; - Oid elementObjectId = InvalidOid; - - HeapTuple tup; - char nulls[Natts_pg_type]; - char replaces[Natts_pg_type]; - Datum values[Natts_pg_type]; - - Buffer buffer; - char *procname; - char *procs[4]; - bool defined; + register i, + j; + Relation pg_type_desc; + HeapScanDesc pg_type_scan; + + Oid typeObjectId; + Oid elementObjectId = InvalidOid; + + HeapTuple tup; + char nulls[Natts_pg_type]; + char replaces[Natts_pg_type]; + Datum values[Natts_pg_type]; + + Buffer buffer; + char *procname; + char *procs[4]; + bool defined; ItemPointerData itemPointerData; - TupleDesc tupDesc; + TupleDesc tupDesc; - Oid argList[8]; + Oid argList[8]; static ScanKeyData typeKey[1] = { @@ -522,7 +522,7 @@ TypeCreate(char *typeName, if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex) { - Relation idescs[Num_pg_type_indices]; + Relation idescs[Num_pg_type_indices]; CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup); @@ -545,11 +545,11 @@ TypeCreate(char *typeName, void TypeRename(char *oldTypeName, char *newTypeName) { - Relation pg_type_desc; - Relation idescs[Num_pg_type_indices]; - Oid type_oid; - HeapTuple tup; - bool defined; + Relation pg_type_desc; + Relation idescs[Num_pg_type_indices]; + Oid type_oid; + HeapTuple tup; + bool defined; ItemPointerData itemPointerData; /* check that that the new type is not already defined */ @@ -603,10 +603,10 @@ TypeRename(char *oldTypeName, char *newTypeName) * the CALLER is responsible for pfreeing the */ -char * +char * makeArrayTypeName(char *typeName) { - char *arr; + char *arr; if (!typeName) return NULL; diff --git a/src/backend/commands/_deadcode/version.c b/src/backend/commands/_deadcode/version.c index c3eb6f4779..0059405767 100644 --- a/src/backend/commands/_deadcode/version.c +++ b/src/backend/commands/_deadcode/version.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.6 1997/09/07 04:41:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.7 1997/09/08 02:22:18 momjian Exp $ * * NOTES * At the point the version is defined, 2 physical relations are created @@ -34,10 +34,10 @@ #define MAX_QUERY_LEN 1024 -char rule_buf[MAX_QUERY_LEN]; +char rule_buf[MAX_QUERY_LEN]; #ifdef NOT_USED -static char attr_list[MAX_QUERY_LEN]; +static char attr_list[MAX_QUERY_LEN]; #endif @@ -105,9 +105,9 @@ eval_as_new_xact(char *query) void DefineVersion(char *name, char *fromRelname, char *date) { - char *bname; - static char saved_basename[512]; - static char saved_snapshot[512]; + char *bname; + static char saved_basename[512]; + static char saved_snapshot[512]; if (date == NULL) { @@ -148,7 +148,7 @@ DefineVersion(char *name, char *fromRelname, char *date) void VersionCreate(char *vname, char *bname) { - static char query_buf[MAX_QUERY_LEN]; + static char query_buf[MAX_QUERY_LEN]; /* * Creating the dummy version relation for triggering rules. @@ -184,12 +184,12 @@ VersionCreate(char *vname, char *bname) static void setAttrList(char *bname) { - Relation rdesc; - int i = 0; - int maxattrs = 0; - char *attrname; - char temp_buf[512]; - int notfirst = 0; + Relation rdesc; + int i = 0; + int maxattrs = 0; + char *attrname; + char temp_buf[512]; + int notfirst = 0; rdesc = heap_openr(bname); if (rdesc == NULL) diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 42d440a867..ee5b9baf55 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.18 1997/09/07 04:40:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.19 1997/09/08 02:21:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,16 +86,16 @@ #include <storage/lmgr.h> -static int notifyFrontEndPending = 0; -static int notifyIssued = 0; -static Dllist *pendingNotifies = NULL; +static int notifyFrontEndPending = 0; +static int notifyIssued = 0; +static Dllist *pendingNotifies = NULL; -static int AsyncExistsPendingNotify(char *); -static void ClearPendingNotify(void); -static void Async_NotifyFrontEnd(void); -static void Async_Unlisten(char *relname, int pid); -static void Async_UnlistenOnExit(int code, char *relname); +static int AsyncExistsPendingNotify(char *); +static void ClearPendingNotify(void); +static void Async_NotifyFrontEnd(void); +static void Async_Unlisten(char *relname, int pid); +static void Async_UnlistenOnExit(int code, char *relname); /* *-------------------------------------------------------------- @@ -169,20 +169,20 @@ void Async_Notify(char *relname) { - HeapTuple lTuple, - rTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key; - Buffer b; - Datum d, - value[3]; - bool isnull; - char repl[3], - nulls[3]; - - char *notifyName; + HeapTuple lTuple, + rTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key; + Buffer b; + Datum d, + value[3]; + bool isnull; + char repl[3], + nulls[3]; + + char *notifyName; #ifdef ASYNC_DEBUG elog(DEBUG, "Async_Notify: %s", relname); @@ -256,15 +256,15 @@ Async_Notify(char *relname) void Async_NotifyAtCommit() { - HeapTuple lTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key; - Datum d; - int ourpid; - bool isnull; - Buffer b; + HeapTuple lTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key; + Datum d; + int ourpid; + bool isnull; + Buffer b; extern TransactionState CurrentTransactionState; if (!pendingNotifies) @@ -406,21 +406,21 @@ Async_NotifyAtAbort() void Async_Listen(char *relname, int pid) { - Datum values[Natts_pg_listener]; - char nulls[Natts_pg_listener]; - TupleDesc tdesc; - HeapScanDesc s; - HeapTuple htup, - tup; - Relation lDesc; - Buffer b; - Datum d; - int i; - bool isnull; - int alreadyListener = 0; - int ourPid = getpid(); - char *relnamei; - TupleDesc tupDesc; + Datum values[Natts_pg_listener]; + char nulls[Natts_pg_listener]; + TupleDesc tdesc; + HeapScanDesc s; + HeapTuple htup, + tup; + Relation lDesc; + Buffer b; + Datum d; + int i; + bool isnull; + int alreadyListener = 0; + int ourPid = getpid(); + char *relnamei; + TupleDesc tupDesc; #ifdef ASYNC_DEBUG elog(DEBUG, "Async_Listen: %s", relname); @@ -513,8 +513,8 @@ Async_Listen(char *relname, int pid) static void Async_Unlisten(char *relname, int pid) { - Relation lDesc; - HeapTuple lTuple; + Relation lDesc; + HeapTuple lTuple; lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname), Int32GetDatum(pid), @@ -560,25 +560,25 @@ Async_UnlistenOnExit(int code, /* from exitpg */ * * -------------------------------------------------------------- */ -GlobalMemory notifyContext = NULL; +GlobalMemory notifyContext = NULL; static void Async_NotifyFrontEnd() { extern CommandDest whereToSendOutput; - HeapTuple lTuple, - rTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key[2]; - Datum d, - value[3]; - char repl[3], - nulls[3]; - Buffer b; - int ourpid; - bool isnull; + HeapTuple lTuple, + rTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key[2]; + Datum d, + value[3]; + char repl[3], + nulls[3]; + Buffer b; + int ourpid; + bool isnull; notifyFrontEndPending = 0; @@ -635,7 +635,7 @@ Async_NotifyFrontEnd() static int AsyncExistsPendingNotify(char *relname) { - Dlelem *p; + Dlelem *p; for (p = DLGetHead(pendingNotifies); p != NULL; @@ -652,7 +652,7 @@ AsyncExistsPendingNotify(char *relname) static void ClearPendingNotify() { - Dlelem *p; + Dlelem *p; while ((p = DLRemHead(pendingNotifies)) != NULL) free(DLE_VAL(p)); diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 2b18cb46df..9e93388f72 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.14 1997/09/07 04:40:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.15 1997/09/08 02:21:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,8 +50,8 @@ #endif /* !NO_SECURITY */ static Relation copy_heap(Oid OIDOldHeap); -static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap); -static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); +static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap); +static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); /* * cluster @@ -82,18 +82,18 @@ static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); void cluster(char oldrelname[], char oldindexname[]) { - Oid OIDOldHeap, - OIDOldIndex, - OIDNewHeap; + Oid OIDOldHeap, + OIDOldIndex, + OIDNewHeap; - Relation OldHeap, - OldIndex; - Relation NewHeap; + Relation OldHeap, + OldIndex; + Relation NewHeap; - char NewIndexName[NAMEDATALEN]; - char NewHeapName[NAMEDATALEN]; - char saveoldrelname[NAMEDATALEN]; - char saveoldindexname[NAMEDATALEN]; + char NewIndexName[NAMEDATALEN]; + char NewHeapName[NAMEDATALEN]; + char saveoldrelname[NAMEDATALEN]; + char saveoldindexname[NAMEDATALEN]; /* @@ -189,15 +189,15 @@ cluster(char oldrelname[], char oldindexname[]) StartTransactionCommand(); } -static Relation +static Relation copy_heap(Oid OIDOldHeap) { - char NewName[NAMEDATALEN]; - TupleDesc OldHeapDesc, - tupdesc; - Oid OIDNewHeap; - Relation NewHeap, - OldHeap; + char NewName[NAMEDATALEN]; + TupleDesc OldHeapDesc, + tupdesc; + Oid OIDNewHeap; + Relation NewHeap, + OldHeap; /* * Create a new heap relation with a temporary name, which has the @@ -235,18 +235,18 @@ copy_heap(Oid OIDOldHeap) static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap) { - Relation OldIndex, - NewHeap; - HeapTuple Old_pg_index_Tuple, - Old_pg_index_relation_Tuple, - pg_proc_Tuple; - IndexTupleForm Old_pg_index_Form; - Form_pg_class Old_pg_index_relation_Form; - Form_pg_proc pg_proc_Form; - char *NewIndexName; - AttrNumber *attnumP; - int natts; - FuncIndexInfo *finfo; + Relation OldIndex, + NewHeap; + HeapTuple Old_pg_index_Tuple, + Old_pg_index_relation_Tuple, + pg_proc_Tuple; + IndexTupleForm Old_pg_index_Form; + Form_pg_class Old_pg_index_relation_Form; + Form_pg_proc pg_proc_Form; + char *NewIndexName; + AttrNumber *attnumP; + int natts; + FuncIndexInfo *finfo; NewHeap = heap_open(OIDNewHeap); OldIndex = index_open(OIDOldIndex); @@ -330,15 +330,15 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) { - Relation LocalNewHeap, - LocalOldHeap, - LocalOldIndex; - IndexScanDesc ScanDesc; + Relation LocalNewHeap, + LocalOldHeap, + LocalOldIndex; + IndexScanDesc ScanDesc; RetrieveIndexResult ScanResult; - ItemPointer HeapTid; - HeapTuple LocalHeapTuple; - Buffer LocalBuffer; - Oid OIDNewHeapInsert; + ItemPointer HeapTid; + HeapTuple LocalHeapTuple; + Buffer LocalBuffer; + Oid OIDNewHeapInsert; /* * Open the relations I need. Scan through the OldHeap on the OldIndex diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 7af9b37c07..0e409396ac 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.14 1997/09/07 04:40:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.15 1997/09/08 02:22:01 momjian Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -46,7 +46,7 @@ * This is where the XXXSuperDuperHacky code was. -cim 3/15/90 * ---------------- */ -MemoryContext PortalExecutorHeapMemory = NULL; +MemoryContext PortalExecutorHeapMemory = NULL; /* -------------------------------- * PortalCleanup @@ -55,7 +55,7 @@ MemoryContext PortalExecutorHeapMemory = NULL; void PortalCleanup(Portal portal) { - MemoryContext context; + MemoryContext context; /* ---------------- * sanity checks @@ -97,10 +97,10 @@ PerformPortalFetch(char *name, char *tag, CommandDest dest) { - Portal portal; - int feature; - QueryDesc *queryDesc; - MemoryContext context; + Portal portal; + int feature; + QueryDesc *queryDesc; + MemoryContext context; /* ---------------- * sanity checks @@ -151,7 +151,7 @@ PerformPortalFetch(char *name, BeginCommand(name, queryDesc->operation, portal->attinfo, /* QueryDescGetTypeInfo(queryDesc), - * */ + * */ false, /* portal fetches don't end up in * relations */ false, /* this is a portal fetch, not a "retrieve @@ -190,7 +190,7 @@ PerformPortalFetch(char *name, void PerformPortalClose(char *name, CommandDest dest) { - Portal portal; + Portal portal; /* ---------------- * sanity checks @@ -257,22 +257,22 @@ PerformAddAttribute(char *relationName, bool inherits, ColumnDef * colDef) { - Relation relrdesc, - attrdesc; - HeapScanDesc attsdesc; - HeapTuple reltup; - HeapTuple attributeTuple; + Relation relrdesc, + attrdesc; + HeapScanDesc attsdesc; + HeapTuple reltup; + HeapTuple attributeTuple; AttributeTupleForm attribute; FormData_pg_attribute attributeD; - int i; - int minattnum, - maxatts; - HeapTuple tup; - ScanKeyData key[2]; + int i; + int minattnum, + maxatts; + HeapTuple tup; + ScanKeyData key[2]; ItemPointerData oldTID; - Relation idescs[Num_pg_attr_indices]; - Relation ridescs[Num_pg_class_indices]; - bool hasindex; + Relation idescs[Num_pg_attr_indices]; + Relation ridescs[Num_pg_class_indices]; + bool hasindex; /* * permissions checking. this would normally be done in utility.c, @@ -310,10 +310,10 @@ PerformAddAttribute(char *relationName, { if (inherits) { - Oid myrelid, - childrelid; - List *child, - *children; + Oid myrelid, + childrelid; + List *child, + *children; relrdesc = heap_openr(relationName); if (!RelationIsValid(relrdesc)) @@ -418,10 +418,10 @@ PerformAddAttribute(char *relationName, i = 1 + minattnum; { - HeapTuple typeTuple; - TypeTupleForm form; - char *p; - int attnelems; + HeapTuple typeTuple; + TypeTupleForm form; + char *p; + int attnelems; /* * XXX use syscache here as an optimization diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 795e9f5584..d1e1db0cd4 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.30 1997/09/07 04:40:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.31 1997/09/08 02:22:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,33 +42,33 @@ /* non-export function prototypes */ -static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim); -static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim); -static Oid GetOutputFunction(Oid type); -static Oid GetTypeElement(Oid type); -static Oid GetInputFunction(Oid type); -static Oid IsTypeByVal(Oid type); +static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim); +static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim); +static Oid GetOutputFunction(Oid type); +static Oid GetTypeElement(Oid type); +static Oid GetInputFunction(Oid type); +static Oid IsTypeByVal(Oid type); static void GetIndexRelations(Oid main_relation_oid, int *n_indices, Relation ** index_rels); #ifdef COPY_PATCH -static void CopyReadNewline(FILE * fp, int *newline); -static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline); +static void CopyReadNewline(FILE * fp, int *newline); +static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline); #else -static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim); +static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim); #endif -static void CopyAttributeOut(FILE * fp, char *string, char *delim); -static int CountTuples(Relation relation); +static void CopyAttributeOut(FILE * fp, char *string, char *delim); +static int CountTuples(Relation relation); -extern FILE *Pfout, - *Pfin; +extern FILE *Pfout, + *Pfin; #ifdef COPY_DEBUG -static int lineno; +static int lineno; #endif @@ -107,11 +107,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, the class. ----------------------------------------------------------------------------*/ - FILE *fp; - Relation rel; - extern char *UserName; /* defined in global.c */ - const AclMode required_access = from ? ACL_WR : ACL_RD; - int result; + FILE *fp; + Relation rel; + extern char *UserName; /* defined in global.c */ + const AclMode required_access = from ? ACL_WR : ACL_RD; + int result; rel = heap_openr(relname); if (rel == NULL) @@ -169,7 +169,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, } else { - mode_t oumask; /* Pre-existing umask value */ + mode_t oumask; /* Pre-existing umask value */ oumask = umask((mode_t) 0); fp = AllocateFile(filename, "w"); @@ -199,19 +199,19 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) { - HeapTuple tuple; - HeapScanDesc scandesc; + HeapTuple tuple; + HeapScanDesc scandesc; - int32 attr_count, - i; + int32 attr_count, + i; AttributeTupleForm *attr; - func_ptr *out_functions; - int dummy; - Oid out_func_oid; - Oid *elements; - Datum value; - bool isnull; /* The attribute we are copying is null */ - char *nulls; + func_ptr *out_functions; + int dummy; + Oid out_func_oid; + Oid *elements; + Datum value; + bool isnull; /* The attribute we are copying is null */ + char *nulls; /* * <nulls> is a (dynamically allocated) array with one character per @@ -220,9 +220,9 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) * * <nulls> is meaningful only if we are doing a binary copy. */ - char *string; - int32 ntuples; - TupleDesc tupDesc; + char *string; + int32 ntuples; + TupleDesc tupDesc; scandesc = heap_beginscan(rel, 0, NULL, 0, NULL); @@ -311,8 +311,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (binary) { - int32 null_ct = 0, - length; + int32 null_ct = 0, + length; for (i = 0; i < attr_count; i++) { @@ -358,54 +358,54 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) { - HeapTuple tuple; - AttrNumber attr_count; + HeapTuple tuple; + AttrNumber attr_count; AttributeTupleForm *attr; - func_ptr *in_functions; - int i, - dummy; - Oid in_func_oid; - Datum *values; - char *nulls, - *index_nulls; - bool *byval; - bool isnull; - bool has_index; - int done = 0; - char *string = NULL, - *ptr; - Relation *index_rels; - int32 len, - null_ct, - null_id; - int32 ntuples, - tuples_read = 0; - bool reading_to_eof = true; - Oid *elements; - FuncIndexInfo *finfo, - **finfoP = NULL; - TupleDesc *itupdescArr; - HeapTuple pgIndexTup; + func_ptr *in_functions; + int i, + dummy; + Oid in_func_oid; + Datum *values; + char *nulls, + *index_nulls; + bool *byval; + bool isnull; + bool has_index; + int done = 0; + char *string = NULL, + *ptr; + Relation *index_rels; + int32 len, + null_ct, + null_id; + int32 ntuples, + tuples_read = 0; + bool reading_to_eof = true; + Oid *elements; + FuncIndexInfo *finfo, + **finfoP = NULL; + TupleDesc *itupdescArr; + HeapTuple pgIndexTup; IndexTupleForm *pgIndexP = NULL; - int *indexNatts = NULL; - char *predString; - Node **indexPred = NULL; - TupleDesc rtupdesc; - ExprContext *econtext = NULL; + int *indexNatts = NULL; + char *predString; + Node **indexPred = NULL; + TupleDesc rtupdesc; + ExprContext *econtext = NULL; #ifndef OMIT_PARTIAL_INDEX - TupleTable tupleTable; + TupleTable tupleTable; TupleTableSlot *slot = NULL; #endif - int natts; - AttrNumber *attnumP; - Datum *idatum; - int n_indices; + int natts; + AttrNumber *attnumP; + Datum *idatum; + int n_indices; InsertIndexResult indexRes; - TupleDesc tupDesc; - Oid loaded_oid; - bool skip_tuple = false; + TupleDesc tupDesc; + Oid loaded_oid; + bool skip_tuple = false; tupDesc = RelationGetTupleDescriptor(rel); attr = tupDesc->attrs; @@ -541,7 +541,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (!binary) { #ifdef COPY_PATCH - int newline = 0; + int newline = 0; #endif #ifdef COPY_DEBUG @@ -647,58 +647,58 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) switch (attr[i]->attlen) { - case sizeof(char): - values[i] = (Datum) * (unsigned char *) ptr; - ptr += sizeof(char); - break; - case sizeof(short): - ptr = (char *) SHORTALIGN(ptr); - values[i] = (Datum) * (unsigned short *) ptr; - ptr += sizeof(short); - break; - case sizeof(int32): - ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) * (uint32 *) ptr; - ptr += sizeof(int32); - break; - default: - elog(WARN, "COPY BINARY: impossible size!"); - break; + case sizeof(char): + values[i] = (Datum) * (unsigned char *) ptr; + ptr += sizeof(char); + break; + case sizeof(short): + ptr = (char *) SHORTALIGN(ptr); + values[i] = (Datum) * (unsigned short *) ptr; + ptr += sizeof(short); + break; + case sizeof(int32): + ptr = (char *) INTALIGN(ptr); + values[i] = (Datum) * (uint32 *) ptr; + ptr += sizeof(int32); + break; + default: + elog(WARN, "COPY BINARY: impossible size!"); + break; } } else if (nulls[i] != 'n') { switch (attr[i]->attlen) { - case -1: - if (attr[i]->attalign == 'd') - ptr = (char *) DOUBLEALIGN(ptr); - else + case -1: + if (attr[i]->attalign == 'd') + ptr = (char *) DOUBLEALIGN(ptr); + else + ptr = (char *) INTALIGN(ptr); + values[i] = (Datum) ptr; + ptr += *(uint32 *) ptr; + break; + case sizeof(char): + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + case sizeof(short): + ptr = (char *) SHORTALIGN(ptr); + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + case sizeof(int32): ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += *(uint32 *) ptr; - break; - case sizeof(char): - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - case sizeof(short): - ptr = (char *) SHORTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - case sizeof(int32): - ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - default: - if (attr[i]->attalign == 'd') - ptr = (char *) DOUBLEALIGN(ptr); - else - ptr = (char *) LONGALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + default: + if (attr[i]->attalign == 'd') + ptr = (char *) DOUBLEALIGN(ptr); + else + ptr = (char *) LONGALIGN(ptr); + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; } } } @@ -721,7 +721,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (rel->trigdesc && rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRInsertTriggers(rel, tuple); @@ -743,7 +743,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (rel->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("CopyFrom", rel, tuple); @@ -826,10 +826,10 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) -static Oid +static Oid GetOutputFunction(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -842,10 +842,10 @@ GetOutputFunction(Oid type) return (InvalidOid); } -static Oid +static Oid GetTypeElement(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -859,10 +859,10 @@ GetTypeElement(Oid type) return (InvalidOid); } -static Oid +static Oid GetInputFunction(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -875,10 +875,10 @@ GetInputFunction(Oid type) return (InvalidOid); } -static Oid +static Oid IsTypeByVal(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -902,24 +902,24 @@ IsTypeByVal(Oid type) typedef struct rel_list { - Oid index_rel_oid; + Oid index_rel_oid; struct rel_list *next; -} RelationList; +} RelationList; static void GetIndexRelations(Oid main_relation_oid, int *n_indices, Relation ** index_rels) { - RelationList *head, - *scan; - Relation pg_index_rel; - HeapScanDesc scandesc; - Oid index_relation_oid; - HeapTuple tuple; - TupleDesc tupDesc; - int i; - bool isnull; + RelationList *head, + *scan; + Relation pg_index_rel; + HeapScanDesc scandesc; + Oid index_relation_oid; + HeapTuple tuple; + TupleDesc tupDesc; + int i; + bool isnull; pg_index_rel = heap_openr(IndexRelationName); scandesc = heap_beginscan(pg_index_rel, 0, NULL, 0, NULL); @@ -978,10 +978,10 @@ GetIndexRelations(Oid main_relation_oid, /* returns 1 is c is in s */ -static bool +static bool inString(char c, char *s) { - int i; + int i; if (s) { @@ -1026,17 +1026,17 @@ CopyReadNewline(FILE * fp, int *newline) * can be used as standard input. */ -static char * +static char * #ifdef COPY_PATCH CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline) #else CopyReadAttribute(FILE * fp, bool * isnull, char *delim) #endif { - static char attribute[EXT_ATTLEN]; - char c; - int done = 0; - int i = 0; + static char attribute[EXT_ATTLEN]; + char c; + int done = 0; + int i = 0; #ifdef COPY_PATCH /* if last delimiter was a newline return a NULL attribute */ @@ -1064,26 +1064,33 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) return (NULL); switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int val; - - val = VALUE(c); - c = getc(fp); - if (ISOCTAL(c)) + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': { - val = (val << 3) + VALUE(c); + int val; + + val = VALUE(c); c = getc(fp); if (ISOCTAL(c)) { val = (val << 3) + VALUE(c); + c = getc(fp); + if (ISOCTAL(c)) + { + val = (val << 3) + VALUE(c); + } + else + { + if (feof(fp)) + return (NULL); + ungetc(c, fp); + } } else { @@ -1091,44 +1098,37 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) return (NULL); ungetc(c, fp); } + c = val & 0377; } - else - { - if (feof(fp)) - return (NULL); - ungetc(c, fp); - } - c = val & 0377; - } - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case 'N': - attribute[0] = '\0'; /* just to be safe */ - *isnull = (bool) true; - break; - case '.': - c = getc(fp); - if (c != '\n') - elog(WARN, "CopyReadAttribute - end of record marker corrupted"); - return (NULL); - break; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case 'N': + attribute[0] = '\0'; /* just to be safe */ + *isnull = (bool) true; + break; + case '.': + c = getc(fp); + if (c != '\n') + elog(WARN, "CopyReadAttribute - end of record marker corrupted"); + return (NULL); + break; } } else if (inString(c, delim) || c == '\n') @@ -1153,9 +1153,9 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) static void CopyAttributeOut(FILE * fp, char *string, char *delim) { - char c; - int is_array = false; - int len = strlen(string); + char c; + int is_array = false; + int len = strlen(string); /* XXX - This is a kludge, we should check the data type */ if (len && (string[0] == '{') && (string[len - 1] == '}')) @@ -1194,10 +1194,10 @@ CopyAttributeOut(FILE * fp, char *string, char *delim) static int CountTuples(Relation relation) { - HeapScanDesc scandesc; - HeapTuple tuple; + HeapScanDesc scandesc; + HeapTuple tuple; - int i; + int i; scandesc = heap_beginscan(relation, 0, NULL, 0, NULL); diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 92641ca70d..e1dac613fe 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.15 1997/09/07 04:40:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.16 1997/09/08 02:22:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,8 +36,8 @@ static int checkAttrExists(char *attributeName, char *attributeType, List * schema); -static List *MergeAttributes(List * schema, List * supers, List ** supconstr); -static void StoreCatalogInheritance(Oid relationId, List * supers); +static List *MergeAttributes(List * schema, List * supers, List ** supconstr); +static void StoreCatalogInheritance(Oid relationId, List * supers); /* ---------------------------------------------------------------- * DefineRelation -- @@ -47,20 +47,20 @@ static void StoreCatalogInheritance(Oid relationId, List * supers); void DefineRelation(CreateStmt * stmt) { - char *relname = palloc(NAMEDATALEN); - List *schema = stmt->tableElts; - int numberOfAttributes; - Oid relationId; - char archChar; - List *inheritList = NULL; - char *archiveName = NULL; - TupleDesc descriptor; - List *constraints; - int heaploc, - archloc; - - char *typename = NULL; /* the typename of this relation. - * not useod for now */ + char *relname = palloc(NAMEDATALEN); + List *schema = stmt->tableElts; + int numberOfAttributes; + Oid relationId; + char archChar; + List *inheritList = NULL; + char *archiveName = NULL; + TupleDesc descriptor; + List *constraints; + int heaploc, + archloc; + + char *typename = NULL;/* the typename of this relation. not + * useod for now */ if (strlen(stmt->relname) >= NAMEDATALEN) elog(WARN, "the relation name %s is >= %d characters long", stmt->relname, @@ -84,19 +84,19 @@ DefineRelation(CreateStmt * stmt) switch (stmt->archiveType) { - case ARCH_NONE: - archChar = 'n'; - break; - case ARCH_LIGHT: - archChar = 'l'; - break; - case ARCH_HEAVY: - archChar = 'h'; - break; - default: - elog(WARN, "Botched archive mode %d, ignoring", - stmt->archiveType); - break; + case ARCH_NONE: + archChar = 'n'; + break; + case ARCH_LIGHT: + archChar = 'l'; + break; + case ARCH_HEAVY: + archChar = 'h'; + break; + default: + elog(WARN, "Botched archive mode %d, ignoring", + stmt->archiveType); + break; } if (stmt->location == -1) @@ -145,15 +145,15 @@ DefineRelation(CreateStmt * stmt) if (constraints != NIL) { - List *entry; - int nconstr = length(constraints); - ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck)); - int ncheck = 0; - int i; + List *entry; + int nconstr = length(constraints); + ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck)); + int ncheck = 0; + int i; foreach(entry, constraints) { - ConstraintDef *cdef = (ConstraintDef *) lfirst(entry); + ConstraintDef *cdef = (ConstraintDef *) lfirst(entry); if (cdef->type == CONSTR_CHECK) { @@ -204,7 +204,7 @@ DefineRelation(CreateStmt * stmt) */ if (archChar != 'n') { - TupleDesc tupdesc; + TupleDesc tupdesc; /* * Need to create an archive relation for this heap relation. We @@ -279,12 +279,12 @@ RemoveRelation(char *name) * \ / * stud_emp {7:percent} */ -static List * +static List * MergeAttributes(List * schema, List * supers, List ** supconstr) { - List *entry; - List *inhSchema = NIL; - List *constraints = NIL; + List *entry; + List *inhSchema = NIL; + List *constraints = NIL; /* * Validates that there are no duplications. Validity checking of @@ -292,8 +292,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) */ foreach(entry, schema) { - List *rest; - ColumnDef *coldef = lfirst(entry); + List *rest; + ColumnDef *coldef = lfirst(entry); foreach(rest, lnext(entry)) { @@ -301,7 +301,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) /* * check for duplicated relation names */ - ColumnDef *restdef = lfirst(rest); + ColumnDef *restdef = lfirst(rest); if (!strcmp(coldef->colname, restdef->colname)) { @@ -312,7 +312,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) } foreach(entry, supers) { - List *rest; + List *rest; foreach(rest, lnext(entry)) { @@ -329,12 +329,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) */ foreach(entry, supers) { - char *name = strVal(lfirst(entry)); - Relation relation; - List *partialResult = NIL; - AttrNumber attrno; - TupleDesc tupleDesc; - TupleConstr *constr; + char *name = strVal(lfirst(entry)); + Relation relation; + List *partialResult = NIL; + AttrNumber attrno; + TupleDesc tupleDesc; + TupleConstr *constr; relation = heap_openr(name); if (relation == NULL) @@ -354,11 +354,11 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--) { AttributeTupleForm attribute = tupleDesc->attrs[attrno]; - char *attributeName; - char *attributeType; - HeapTuple tuple; - ColumnDef *def; - TypeName *typename; + char *attributeName; + char *attributeType; + HeapTuple tuple; + ColumnDef *def; + TypeName *typename; /* * form name, type and constraints @@ -398,8 +398,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) def->defval = NULL; if (attribute->atthasdef) { - AttrDefault *attrdef = constr->defval; - int i; + AttrDefault *attrdef = constr->defval; + int i; Assert(constr != NULL && constr->num_defval > 0); @@ -417,12 +417,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) if (constr && constr->num_check > 0) { - ConstrCheck *check = constr->check; - int i; + ConstrCheck *check = constr->check; + int i; for (i = 0; i < constr->num_check; i++) { - ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef)); + ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef)); cdef->type = CONSTR_CHECK; if (check[i].ccname[0] == '$') @@ -461,12 +461,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) static void StoreCatalogInheritance(Oid relationId, List * supers) { - Relation relation; - TupleDesc desc; - int16 seqNumber; - List *entry; - List *idList; - HeapTuple tuple; + Relation relation; + TupleDesc desc; + int16 seqNumber; + List *entry; + List *idList; + HeapTuple tuple; /* ---------------- * sanity checks @@ -488,8 +488,8 @@ StoreCatalogInheritance(Oid relationId, List * supers) idList = NIL; foreach(entry, supers) { - Datum datum[Natts_pg_inherits]; - char nullarr[Natts_pg_inherits]; + Datum datum[Natts_pg_inherits]; + char nullarr[Natts_pg_inherits]; tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(strVal(lfirst(entry))), @@ -536,11 +536,11 @@ StoreCatalogInheritance(Oid relationId, List * supers) */ foreach(entry, idList) { - HeapTuple tuple; - Oid id; - int16 number; - List *next; - List *current; + HeapTuple tuple; + Oid id; + int16 number; + List *next; + List *current; id = (Oid) lfirsti(entry); current = entry; @@ -572,9 +572,9 @@ StoreCatalogInheritance(Oid relationId, List * supers) */ foreach(entry, idList) { - Oid name; - List *rest; - bool found = false; + Oid name; + List *rest; + bool found = false; again: name = lfirsti(entry); @@ -613,8 +613,8 @@ again: foreach(entry, idList) { - Datum datum[Natts_pg_ipl]; - char nullarr[Natts_pg_ipl]; + Datum datum[Natts_pg_ipl]; + char nullarr[Natts_pg_ipl]; datum[0] = ObjectIdGetDatum(relationId); /* iplrel */ datum[1] = ObjectIdGetDatum(lfirsti(entry)); @@ -642,11 +642,11 @@ again: static int checkAttrExists(char *attributeName, char *attributeType, List * schema) { - List *s; + List *s; foreach(s, schema) { - ColumnDef *def = lfirst(s); + ColumnDef *def = lfirst(s); if (!strcmp(attributeName, def->colname)) { @@ -672,10 +672,10 @@ checkAttrExists(char *attributeName, char *attributeType, List * schema) * the CALLER is responsible for freeing the memory allocated */ -char * +char * MakeArchiveName(Oid relationId) { - char *arch; + char *arch; /* * Archive relations are named a,XXXXX where XXXXX == the OID of the diff --git a/src/backend/commands/defind.c b/src/backend/commands/defind.c index 9b8c5a0218..92bb0e7c09 100644 --- a/src/backend/commands/defind.c +++ b/src/backend/commands/defind.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.13 1997/09/07 04:40:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.14 1997/09/08 02:22:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,19 +39,19 @@ #define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args!=NULL) /* non-export function prototypes */ -static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid); +static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid); static void CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid); static void - CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid); + CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid); static void FuncIndexArgs(IndexElem * funcIndex, AttrNumber * attNumP, Oid * argTypes, Oid * opOidP, Oid relId); static void NormIndexAttrs(List * attList, AttrNumber * attNumP, Oid * opOidP, Oid relId); -static char *GetDefaultOpClass(Oid atttypid); +static char *GetDefaultOpClass(Oid atttypid); /* * DefineIndex -- @@ -76,18 +76,18 @@ DefineIndex(char *heapRelationName, Expr * predicate, List * rangetable) { - Oid *classObjectId; - Oid accessMethodId; - Oid relationId; - int numberOfAttributes; - AttrNumber *attributeNumberA; - HeapTuple tuple; - uint16 parameterCount = 0; - Datum *parameterA = NULL; - FuncIndexInfo fInfo; - List *cnfPred = NULL; - bool lossy = FALSE; - List *pl; + Oid *classObjectId; + Oid accessMethodId; + Oid relationId; + int numberOfAttributes; + AttrNumber *attributeNumberA; + HeapTuple tuple; + uint16 parameterCount = 0; + Datum *parameterA = NULL; + FuncIndexInfo fInfo; + List *cnfPred = NULL; + bool lossy = FALSE; + List *pl; /* * Handle attributes @@ -138,7 +138,7 @@ DefineIndex(char *heapRelationName, */ foreach(pl, parameterList) { - ParamString *param = (ParamString *) lfirst(pl); + ParamString *param = (ParamString *) lfirst(pl); if (!strcasecmp(param->name, "islossy")) lossy = TRUE; @@ -162,8 +162,8 @@ DefineIndex(char *heapRelationName, if (IsFuncIndex(attributeList)) { - IndexElem *funcIndex = lfirst(attributeList); - int nargs; + IndexElem *funcIndex = lfirst(attributeList); + int nargs; nargs = length(funcIndex->args); if (nargs > INDEX_MAX_KEYS) @@ -225,23 +225,23 @@ DefineIndex(char *heapRelationName, void ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) { - Oid *classObjectId; - Oid accessMethodId; - Oid indexId, - relationId; - Oid indproc; - int numberOfAttributes; - AttrNumber *attributeNumberA; - HeapTuple tuple; - FuncIndexInfo fInfo; - FuncIndexInfo *funcInfo = NULL; - IndexTupleForm index; - Node *oldPred = NULL; - List *cnfPred = NULL; - PredInfo *predInfo; - Relation heapRelation; - Relation indexRelation; - int i; + Oid *classObjectId; + Oid accessMethodId; + Oid indexId, + relationId; + Oid indproc; + int numberOfAttributes; + AttrNumber *attributeNumberA; + HeapTuple tuple; + FuncIndexInfo fInfo; + FuncIndexInfo *funcInfo = NULL; + IndexTupleForm index; + Node *oldPred = NULL; + List *cnfPred = NULL; + PredInfo *predInfo; + Relation heapRelation; + Relation indexRelation; + int i; /* * compute index relation id and access method id @@ -283,7 +283,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) if (VARSIZE(&index->indpred) != 0) { - char *predString; + char *predString; predString = fmgr(F_TEXTOUT, &index->indpred); oldPred = stringToNode(predString); @@ -366,7 +366,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid) { - List *item; + List *item; foreach(item, predList) { @@ -377,8 +377,8 @@ CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid) static void CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid) { - List *clauses = NIL, - *clause; + List *clauses = NIL, + *clause; if (is_opclause(predicate)) { @@ -401,8 +401,8 @@ CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid) static void CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid) { - Var *pred_var; - Const *pred_const; + Var *pred_var; + Const *pred_const; pred_var = (Var *) get_leftop(predicate); pred_const = (Const *) get_rightop(predicate); @@ -427,8 +427,8 @@ FuncIndexArgs(IndexElem * funcIndex, Oid * opOidP, Oid relId) { - List *rest; - HeapTuple tuple; + List *rest; + HeapTuple tuple; AttributeTupleForm att; tuple = SearchSysCacheTuple(CLANAME, @@ -449,7 +449,7 @@ FuncIndexArgs(IndexElem * funcIndex, */ for (rest = funcIndex->args; rest != NIL; rest = lnext(rest)) { - char *arg; + char *arg; arg = strVal(lfirst(rest)); @@ -475,8 +475,8 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ Oid * opOidP, Oid relId) { - List *rest; - HeapTuple tuple; + List *rest; + HeapTuple tuple; /* * process attributeList @@ -484,7 +484,7 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ for (rest = attList; rest != NIL; rest = lnext(rest)) { - IndexElem *attribute; + IndexElem *attribute; AttributeTupleForm attform; attribute = lfirst(rest); @@ -531,10 +531,10 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ } } -static char * +static char * GetDefaultOpClass(Oid atttypid) { - HeapTuple tuple; + HeapTuple tuple; tuple = SearchSysCacheTuple(CLADEFTYPE, ObjectIdGetDatum(atttypid), @@ -559,7 +559,7 @@ GetDefaultOpClass(Oid atttypid) void RemoveIndex(char *name) { - HeapTuple tuple; + HeapTuple tuple; tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(name), diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index fb1df213ce..52a0b716f9 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.14 1997/09/07 04:40:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.15 1997/09/08 02:22:09 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -53,8 +53,8 @@ #include <tcop/dest.h> #include <catalog/pg_user.h> -static char *defGetString(DefElem * def); -static int defGetTypeLength(DefElem * def); +static char *defGetString(DefElem * def); +static int defGetTypeLength(DefElem * def); #define DEFAULT_TYPDELIM ',' @@ -66,7 +66,7 @@ case_translate_language_name(const char *input, char *output) Translate the input language name to lower case, except if it's C, translate to upper case. --------------------------------------------------------------------------*/ - int i; + int i; for (i = 0; i < NAMEDATALEN && input[i] != '\0'; ++i) output[i] = tolower(input[i]); @@ -90,7 +90,7 @@ compute_return_type(const Node * returnType, if (nodeTag(returnType) == T_TypeName) { /* a set of values */ - TypeName *setType = (TypeName *) returnType; + TypeName *setType = (TypeName *) returnType; *prorettype_p = setType->name; *returnsSet_p = true; @@ -116,7 +116,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, These are the full parameters of a C or internal function. ---------------------------------------------------------------------------*/ - List *pl; + List *pl; /* the defaults */ *byte_pct_p = BYTE_PCT; @@ -126,7 +126,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, foreach(pl, (List *) parameters) { - ParamString *param = (ParamString *) lfirst(pl); + ParamString *param = (ParamString *) lfirst(pl); if (strcasecmp(param->name, "iscachable") == 0) { @@ -153,8 +153,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, { if (sscanf(param->val, "%d", perbyte_cpu_p) == 0) { - int count; - char *ptr; + int count; + char *ptr; for (count = 0, ptr = param->val; *ptr != '\0'; ptr++) if (*ptr == '!') @@ -166,8 +166,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, { if (sscanf(param->val, "%d", percall_cpu_p) == 0) { - int count; - char *ptr; + int count; + char *ptr; for (count = 0, ptr = param->val; *ptr != '\0'; ptr++) if (*ptr == '!') @@ -212,16 +212,16 @@ interpret_AS_clause(const char languageName[], const char as[], void CreateFunction(ProcedureStmt * stmt, CommandDest dest) { - char *probin_str; + char *probin_str; /* pathname of executable file that executes this function, if any */ - char *prosrc_str; + char *prosrc_str; /* SQL that executes this function, if any */ - char *prorettype; + char *prorettype; /* Type of return value (or member of set of values) from function */ - char languageName[NAMEDATALEN]; + char languageName[NAMEDATALEN]; /* * name of language of function, with case adjusted: "C", "internal", @@ -232,12 +232,12 @@ CreateFunction(ProcedureStmt * stmt, CommandDest dest) * The following are attributes of the function, as expressed in the * CREATE FUNCTION statement, where applicable. */ - int32 byte_pct, - perbyte_cpu, - percall_cpu, - outin_ratio; - bool canCache; - bool returnsSet; + int32 byte_pct, + perbyte_cpu, + percall_cpu, + outin_ratio; + bool canCache; + bool returnsSet; /* The function returns a set of values, as opposed to a singleton. */ @@ -317,30 +317,29 @@ void DefineOperator(char *oprName, List * parameters) { - uint16 precedence = 0; /* operator precedence */ - bool canHash = false; /* operator hashes */ - bool isLeftAssociative = true; /* operator is left + uint16 precedence = 0; /* operator precedence */ + bool canHash = false;/* operator hashes */ + bool isLeftAssociative = true; /* operator is left * associative */ - char *functionName = NULL; /* function for operator */ - char *typeName1 = NULL; /* first type name */ - char *typeName2 = NULL; /* second type name */ - char *commutatorName = NULL; /* optional commutator - * operator name */ - char *negatorName = NULL; /* optional negator operator name */ - char *restrictionName = NULL; /* optional restrict. sel. - * procedure */ - char *joinName = NULL; /* optional join sel. procedure + char *functionName = NULL; /* function for operator */ + char *typeName1 = NULL; /* first type name */ + char *typeName2 = NULL; /* second type name */ + char *commutatorName = NULL; /* optional commutator operator * name */ - char *sortName1 = NULL; /* optional first sort operator */ - char *sortName2 = NULL; /* optional second sort operator */ - List *pl; + char *negatorName = NULL; /* optional negator operator name */ + char *restrictionName = NULL; /* optional restrict. sel. + * procedure */ + char *joinName = NULL;/* optional join sel. procedure name */ + char *sortName1 = NULL; /* optional first sort operator */ + char *sortName2 = NULL; /* optional second sort operator */ + List *pl; /* * loop over the definition list and extract the information we need. */ foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); if (!strcasecmp(defel->defname, "leftarg")) { @@ -465,19 +464,19 @@ void DefineAggregate(char *aggName, List * parameters) { - char *stepfunc1Name = NULL; - char *stepfunc2Name = NULL; - char *finalfuncName = NULL; - char *baseType = NULL; - char *stepfunc1Type = NULL; - char *stepfunc2Type = NULL; - char *init1 = NULL; - char *init2 = NULL; - List *pl; + char *stepfunc1Name = NULL; + char *stepfunc2Name = NULL; + char *finalfuncName = NULL; + char *baseType = NULL; + char *stepfunc1Type = NULL; + char *stepfunc2Type = NULL; + char *init1 = NULL; + char *init2 = NULL; + List *pl; foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); /* * sfunc1 @@ -573,19 +572,19 @@ DefineAggregate(char *aggName, List * parameters) void DefineType(char *typeName, List * parameters) { - int16 internalLength = 0; /* int2 */ - int16 externalLength = 0; /* int2 */ - char *elemName = NULL; - char *inputName = NULL; - char *outputName = NULL; - char *sendName = NULL; - char *receiveName = NULL; - char *defaultValue = NULL; /* Datum */ - bool byValue = false; - char delimiter = DEFAULT_TYPDELIM; - char *shadow_type; - List *pl; - char alignment = 'i'; /* default alignment */ + int16 internalLength = 0; /* int2 */ + int16 externalLength = 0; /* int2 */ + char *elemName = NULL; + char *inputName = NULL; + char *outputName = NULL; + char *sendName = NULL; + char *receiveName = NULL; + char *defaultValue = NULL; /* Datum */ + bool byValue = false; + char delimiter = DEFAULT_TYPDELIM; + char *shadow_type; + List *pl; + char alignment = 'i';/* default alignment */ /* * Type names can only be 15 characters long, so that the shadow type @@ -599,7 +598,7 @@ DefineType(char *typeName, List * parameters) foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); if (!strcasecmp(defel->defname, "internallength")) { @@ -623,7 +622,7 @@ DefineType(char *typeName, List * parameters) } else if (!strcasecmp(defel->defname, "delimiter")) { - char *p = defGetString(defel); + char *p = defGetString(defel); delimiter = p[0]; } @@ -645,7 +644,7 @@ DefineType(char *typeName, List * parameters) } else if (!strcasecmp(defel->defname, "alignment")) { - char *a = defGetString(defel); + char *a = defGetString(defel); if (!strcasecmp(a, "double")) { @@ -720,7 +719,7 @@ DefineType(char *typeName, List * parameters) pfree(shadow_type); } -static char * +static char * defGetString(DefElem * def) { if (nodeTag(def->arg) != T_String) diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 192076e391..c1ad092e92 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.11 1997/09/07 04:40:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.12 1997/09/08 02:22:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ typedef struct ExplainState { /* options */ - bool printCost; /* print cost */ - bool printNodes; /* do nodeToString() instead */ + bool printCost; /* print cost */ + bool printNodes; /* do nodeToString() instead */ /* other states */ - List *rtable; /* range table */ -} ExplainState; + List *rtable; /* range table */ +} ExplainState; -static char *Explain_PlanToString(Plan * plan, ExplainState * es); +static char *Explain_PlanToString(Plan * plan, ExplainState * es); /* * ExplainQuery - @@ -44,15 +44,15 @@ static char *Explain_PlanToString(Plan * plan, ExplainState * es); void ExplainQuery(Query * query, bool verbose, CommandDest dest) { - char *s = NULL, - *s2; - Plan *plan; - ExplainState *es; - int len; + char *s = NULL, + *s2; + Plan *plan; + ExplainState *es; + int len; if (IsAbortedTransactionBlockState()) { - char *tag = "*ABORT STATE*"; + char *tag = "*ABORT STATE*"; EndCommand(tag, dest); @@ -118,9 +118,9 @@ ExplainQuery(Query * query, bool verbose, CommandDest dest) static void explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) { - char *pname; - char buf[1000]; - int i; + char *pname; + char buf[1000]; + int i; if (plan == NULL) { @@ -130,51 +130,51 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) switch (nodeTag(plan)) { - case T_Result: - pname = "Result"; - break; - case T_Append: - pname = "Append"; - break; - case T_NestLoop: - pname = "Nested Loop"; - break; - case T_MergeJoin: - pname = "Merge Join"; - break; - case T_HashJoin: - pname = "Hash Join"; - break; - case T_SeqScan: - pname = "Seq Scan"; - break; - case T_IndexScan: - pname = "Index Scan"; - break; - case T_Temp: - pname = "Temp Scan"; - break; - case T_Sort: - pname = "Sort"; - break; - case T_Group: - pname = "Group"; - break; - case T_Agg: - pname = "Aggregate"; - break; - case T_Unique: - pname = "Unique"; - break; - case T_Hash: - pname = "Hash"; - break; - case T_Tee: - pname = "Tee"; - break; - default: - pname = ""; - break; + case T_Result: + pname = "Result"; + break; + case T_Append: + pname = "Append"; + break; + case T_NestLoop: + pname = "Nested Loop"; + break; + case T_MergeJoin: + pname = "Merge Join"; + break; + case T_HashJoin: + pname = "Hash Join"; + break; + case T_SeqScan: + pname = "Seq Scan"; + break; + case T_IndexScan: + pname = "Index Scan"; + break; + case T_Temp: + pname = "Temp Scan"; + break; + case T_Sort: + pname = "Sort"; + break; + case T_Group: + pname = "Group"; + break; + case T_Agg: + pname = "Aggregate"; + break; + case T_Unique: + pname = "Unique"; + break; + case T_Hash: + pname = "Hash"; + break; + case T_Tee: + pname = "Tee"; + break; + default: + pname = ""; + break; } for (i = 0; i < indent; i++) @@ -183,18 +183,18 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) appendStringInfo(str, pname); switch (nodeTag(plan)) { - case T_SeqScan: - case T_IndexScan: - if (((Scan *) plan)->scanrelid > 0) - { - RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable); - - sprintf(buf, " on %s", rte->refname); - appendStringInfo(str, buf); - } - break; - default: - break; + case T_SeqScan: + case T_IndexScan: + if (((Scan *) plan)->scanrelid > 0) + { + RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable); + + sprintf(buf, " on %s", rte->refname); + appendStringInfo(str, buf); + } + break; + default: + break; } if (es->printCost) { @@ -224,11 +224,11 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) return; } -static char * +static char * Explain_PlanToString(Plan * plan, ExplainState * es) { - StringInfo str; - char *s; + StringInfo str; + char *s; if (plan == NULL) return ""; diff --git a/src/backend/commands/purge.c b/src/backend/commands/purge.c index 8000bbc735..78265c93cc 100644 --- a/src/backend/commands/purge.c +++ b/src/backend/commands/purge.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.7 1997/09/07 04:40:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.8 1997/09/08 02:22:11 momjian Exp $ * * Note: * XXX There are many instances of int32 instead of ...Time. These @@ -28,7 +28,7 @@ #include <commands/purge.h> #include <utils/builtins.h> /* for isreltime() */ -static char cmdname[] = "RelationPurge"; +static char cmdname[] = "RelationPurge"; #define RELATIVE 01 #define ABSOLUTE 02 @@ -38,23 +38,23 @@ RelationPurge(char *relationName, char *absoluteTimeString, char *relativeTimeString) { - register i; - AbsoluteTime absoluteTime = INVALID_ABSTIME; - RelativeTime relativeTime = INVALID_RELTIME; - bits8 dateTag; - Relation relation; - HeapScanDesc scan; + register i; + AbsoluteTime absoluteTime = INVALID_ABSTIME; + RelativeTime relativeTime = INVALID_RELTIME; + bits8 dateTag; + Relation relation; + HeapScanDesc scan; static ScanKeyData key[1] = { {0, Anum_pg_class_relname, F_NAMEEQ} }; - Buffer buffer; - HeapTuple newTuple, - oldTuple; - AbsoluteTime currentTime; - char *values[Natts_pg_class]; - char nulls[Natts_pg_class]; - char replace[Natts_pg_class]; - Relation idescs[Num_pg_class_indices]; + Buffer buffer; + HeapTuple newTuple, + oldTuple; + AbsoluteTime currentTime; + char *values[Natts_pg_class]; + char nulls[Natts_pg_class]; + char replace[Natts_pg_class]; + Relation idescs[Num_pg_class_indices]; /* * XXX for some reason getmyrelids (in inval.c) barfs when you diff --git a/src/backend/commands/recipe.c b/src/backend/commands/recipe.c index bf05c293d1..7796b164c3 100644 --- a/src/backend/commands/recipe.c +++ b/src/backend/commands/recipe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.7 1997/09/07 04:40:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.8 1997/09/08 02:22:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,26 +50,26 @@ beginRecipe(RecipeStmt * stmt) /* structure to keep track of the tee node plans */ typedef struct _teePlanInfo { - char *tpi_relName; - Query *tpi_parsetree; - Plan *tpi_plan; -} TeePlanInfo; + char *tpi_relName; + Query *tpi_parsetree; + Plan *tpi_plan; +} TeePlanInfo; typedef struct _teeInfo { - int num; - TeePlanInfo *val; -} TeeInfo; + int num; + TeePlanInfo *val; +} TeeInfo; -QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2); -void OffsetVarAttno(Node * node, int varno, int offset); +QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2); +void OffsetVarAttno(Node * node, int varno, int offset); static void appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName); -static Plan * +static Plan * replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo); @@ -83,12 +83,12 @@ static void tg_rewriteQuery(TgRecipe * r, TgNode * n, QueryTreeList * q, QueryTreeList * inputQlist); -static Node * +static Node * tg_replaceNumberedParam(Node * expression, int pnum, int rt_ind, char *teeRelName); -static Node * +static Node * tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist); static QueryTreeList * @@ -129,18 +129,18 @@ tg_parseTeeNode(TgRecipe * r, void beginRecipe(RecipeStmt * stmt) { - TgRecipe *r; - int i; - QueryTreeList *qList; - char portalName[1024]; + TgRecipe *r; + int i; + QueryTreeList *qList; + char portalName[1024]; - Plan *plan; - TupleDesc attinfo; - QueryDesc *queryDesc; - Query *parsetree; + Plan *plan; + TupleDesc attinfo; + QueryDesc *queryDesc; + Query *parsetree; - int numTees; - TeeInfo *teeInfo; + int numTees; + TeeInfo *teeInfo; /* * retrieveRecipe() reads the recipe from the database and returns a @@ -177,7 +177,7 @@ beginRecipe(RecipeStmt * stmt) */ for (i = 0; i < r->eyes->num; i++) { - TgNodePtr e; + TgNodePtr e; e = r->eyes->val[i]; if (e->inNodes->num > 1) @@ -231,9 +231,9 @@ beginRecipe(RecipeStmt * stmt) * ---------------------------------------------------------- */ if (teeInfo) { - int t; - Plan *tplan; - Tee *newplan; + int t; + Plan *tplan; + Tee *newplan; for (t = 0; t < teeInfo->num; t++) { @@ -320,12 +320,12 @@ tg_rewriteQuery(TgRecipe * r, QueryTreeList * q, QueryTreeList * inputQlist) { - Query *orig; - Query *inputQ; - int i; - List *rtable; - List *input_rtable; - int rt_length; + Query *orig; + Query *inputQ; + int i; + List *rtable; + List *input_rtable; + int rt_length; /* orig is the original parse tree of the node */ orig = q->qtrees[0]; @@ -380,8 +380,8 @@ tg_rewriteQuery(TgRecipe * r, */ if (orig->targetList != NIL) { - List *tl; - TargetEntry *tle; + List *tl; + TargetEntry *tle; foreach(tl, orig->targetList) { @@ -425,134 +425,134 @@ tg_rewriteQuery(TgRecipe * r, it returns a (possibly modified) Node*. */ -static Node * +static Node * tg_replaceNumberedParam(Node * expression, int pnum, /* the number of the parameter */ int rt_ind, /* the range table index */ char *teeRelName) /* the relname of the tee * table */ { - TargetEntry *param_tle; - Param *p; - Var *newVar, - *oldVar; + TargetEntry *param_tle; + Param *p; + Var *newVar, + *oldVar; if (expression == NULL) return NULL; switch (nodeTag(expression)) { - case T_Param: - { - - /* - * the node is a parameter, substitute the entry from the - * target list of the child that corresponds to the parameter - * number - */ - p = (Param *) expression; - - /* we only deal with the case of numbered parameters */ - if (p->paramkind == PARAM_NUM && p->paramid == pnum) + case T_Param: { - if (p->param_tlist) - { - - /* - * we have a parameter with an attribute like $N.foo - * so replace it with a new var node - */ + /* + * the node is a parameter, substitute the entry from the + * target list of the child that corresponds to the + * parameter number + */ + p = (Param *) expression; - /* param tlist can only have one entry in them! */ - param_tle = (TargetEntry *) (lfirst(p->param_tlist)); - oldVar = (Var *) param_tle->expr; - oldVar->varno = rt_ind; - oldVar->varnoold = rt_ind; - return (Node *) oldVar; - } - else + /* we only deal with the case of numbered parameters */ + if (p->paramkind == PARAM_NUM && p->paramid == pnum) { - /* we have $N without the .foo */ - bool defined; - bool isRel; - - /* - * TODO here, we need to check to see whether the type - * of the tee is a complex type (relation) or a simple - * type - */ - /* - * if it is a simple type, then we need to get the - * "result" attribute from the tee relation - */ - - isRel = (typeid_get_relid(p->paramtype) != 0); - if (isRel) + if (p->param_tlist) { - newVar = makeVar(rt_ind, - 0, /* the whole tuple */ - TypeGet(teeRelName, &defined), - rt_ind, - 0); - return (Node *) newVar; + + /* + * we have a parameter with an attribute like + * $N.foo so replace it with a new var node + */ + + /* param tlist can only have one entry in them! */ + param_tle = (TargetEntry *) (lfirst(p->param_tlist)); + oldVar = (Var *) param_tle->expr; + oldVar->varno = rt_ind; + oldVar->varnoold = rt_ind; + return (Node *) oldVar; } else - newVar = makeVar(rt_ind, - 1, /* just the first field, + { + /* we have $N without the .foo */ + bool defined; + bool isRel; + + /* + * TODO here, we need to check to see whether the + * type of the tee is a complex type (relation) or + * a simple type + */ + + /* + * if it is a simple type, then we need to get the + * "result" attribute from the tee relation + */ + + isRel = (typeid_get_relid(p->paramtype) != 0); + if (isRel) + { + newVar = makeVar(rt_ind, + 0, /* the whole tuple */ + TypeGet(teeRelName, &defined), + rt_ind, + 0); + return (Node *) newVar; + } + else + newVar = makeVar(rt_ind, + 1, /* just the first field, * which is 'result' */ - TypeGet(teeRelName, &defined), - rt_ind, - 0); - return (Node *) newVar; + TypeGet(teeRelName, &defined), + rt_ind, + 0); + return (Node *) newVar; + } + } + else + { + elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind); } } - else + break; + case T_Expr: { - elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind); - } - } - break; - case T_Expr: - { - /* - * the node is an expression, we need to recursively call - * ourselves until we find parameter nodes - */ - List *l; - Expr *expr = (Expr *) expression; - List *newArgs; + /* + * the node is an expression, we need to recursively call + * ourselves until we find parameter nodes + */ + List *l; + Expr *expr = (Expr *) expression; + List *newArgs; - /* - * we have to make a new args lists because Params can be - * replaced by Var nodes in tg_replaceNumberedParam() - */ - newArgs = NIL; + /* + * we have to make a new args lists because Params can be + * replaced by Var nodes in tg_replaceNumberedParam() + */ + newArgs = NIL; - /* - * we only care about argument to expressions, it doesn't - * matter when the opType is - */ - /* recursively rewrite the arguments of this expression */ - foreach(l, expr->args) + /* + * we only care about argument to expressions, it doesn't + * matter when the opType is + */ + /* recursively rewrite the arguments of this expression */ + foreach(l, expr->args) + { + newArgs = lappend(newArgs, + tg_replaceNumberedParam(lfirst(l), + pnum, + rt_ind, + teeRelName)); + } + /* change the arguments of the expression */ + expr->args = newArgs; + } + break; + default: { - newArgs = lappend(newArgs, - tg_replaceNumberedParam(lfirst(l), - pnum, - rt_ind, - teeRelName)); + /* ignore other expr types */ } - /* change the arguments of the expression */ - expr->args = newArgs; - } - break; - default: - { - /* ignore other expr types */ - } } return expression; @@ -572,118 +572,118 @@ tg_replaceNumberedParam(Node * expression, it returns a (possibly modified) Node*. */ -static Node * +static Node * tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist) { - List *tl; - TargetEntry *param_tle, - *tle; - Param *p; - int childno; - char *resname; + List *tl; + TargetEntry *param_tle, + *tle; + Param *p; + int childno; + char *resname; if (expression == NULL) return NULL; switch (nodeTag(expression)) { - case T_Param: - { - - /* - * the node is a parameter, substitute the entry from the - * target list of the child that corresponds to the parameter - * number - */ - p = (Param *) expression; - - /* we only deal with the case of numbered parameters */ - if (p->paramkind == PARAM_NUM) + case T_Param: { - /* paramid's start from 1 */ - childno = p->paramid - 1; - if (p->param_tlist) + /* + * the node is a parameter, substitute the entry from the + * target list of the child that corresponds to the + * parameter number + */ + p = (Param *) expression; + + /* we only deal with the case of numbered parameters */ + if (p->paramkind == PARAM_NUM) { + /* paramid's start from 1 */ + childno = p->paramid - 1; - /* - * we have a parameter with an attribute like $N.foo - * so match the resname "foo" against the target list - * of the (N-1)th inputQlist - */ + if (p->param_tlist) + { - /* param tlist can only have one entry in them! */ - param_tle = (TargetEntry *) (lfirst(p->param_tlist)); - resname = param_tle->resdom->resname; + /* + * we have a parameter with an attribute like + * $N.foo so match the resname "foo" against the + * target list of the (N-1)th inputQlist + */ - if (inputQlist->qtrees[childno]) - { - foreach(tl, inputQlist->qtrees[childno]->targetList) + /* param tlist can only have one entry in them! */ + param_tle = (TargetEntry *) (lfirst(p->param_tlist)); + resname = param_tle->resdom->resname; + + if (inputQlist->qtrees[childno]) { - tle = lfirst(tl); - if (strcmp(resname, tle->resdom->resname) == 0) + foreach(tl, inputQlist->qtrees[childno]->targetList) { - return tle->expr; + tle = lfirst(tl); + if (strcmp(resname, tle->resdom->resname) == 0) + { + return tle->expr; + } } } + else + { + elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid); + } + } else { - elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid); + /* we have $N without the .foo */ + /* use the first resdom in the targetlist of the */ + /* appropriate child query */ + tl = inputQlist->qtrees[childno]->targetList; + tle = lfirst(tl); + return tle->expr; } - } else { - /* we have $N without the .foo */ - /* use the first resdom in the targetlist of the */ - /* appropriate child query */ - tl = inputQlist->qtrees[childno]->targetList; - tle = lfirst(tl); - return tle->expr; + elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind); } } - else + break; + case T_Expr: { - elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind); - } - } - break; - case T_Expr: - { - /* - * the node is an expression, we need to recursively call - * ourselves until we find parameter nodes - */ - List *l; - Expr *expr = (Expr *) expression; - List *newArgs; + /* + * the node is an expression, we need to recursively call + * ourselves until we find parameter nodes + */ + List *l; + Expr *expr = (Expr *) expression; + List *newArgs; - /* - * we have to make a new args lists because Params can be - * replaced by Var nodes in tg_rewriteParamsInExpr() - */ - newArgs = NIL; + /* + * we have to make a new args lists because Params can be + * replaced by Var nodes in tg_rewriteParamsInExpr() + */ + newArgs = NIL; - /* - * we only care about argument to expressions, it doesn't - * matter when the opType is - */ - /* recursively rewrite the arguments of this expression */ - foreach(l, expr->args) - { - newArgs = lappend(newArgs, + /* + * we only care about argument to expressions, it doesn't + * matter when the opType is + */ + /* recursively rewrite the arguments of this expression */ + foreach(l, expr->args) + { + newArgs = lappend(newArgs, tg_rewriteParamsInExpr(lfirst(l), inputQlist)); + } + /* change the arguments of the expression */ + expr->args = newArgs; + } + break; + default: + { + /* ignore other expr types */ } - /* change the arguments of the expression */ - expr->args = newArgs; - } - break; - default: - { - /* ignore other expr types */ - } } return expression; @@ -703,12 +703,12 @@ static int getParamTypes(TgElement * elem, Oid typev[]) { /* this code is similar to ProcedureDefine() */ - int16 parameterCount; - bool defined; - Oid toid; - char *t; - int i, - j; + int16 parameterCount; + bool defined; + Oid toid; + char *t; + int i, + j; parameterCount = 0; for (i = 0; i < 8; i++) @@ -763,10 +763,10 @@ tg_parseTeeNode(TgRecipe * r, TeeInfo * teeInfo) { - QueryTreeList *q; - char *tt; - int rt_ind; - Query *orig; + QueryTreeList *q; + char *tt; + int rt_ind; + Query *orig; /* * the input Node is a tee node, so we need to do the following: we @@ -831,21 +831,21 @@ tg_parseTeeNode(TgRecipe * r, static QueryTreeList * tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) { - TgElement *elem; - char *funcName; - Oid typev[8]; /* eight arguments maximum */ - int i; - int parameterCount; - - QueryTreeList *qList; /* the parse tree of the nodeElement */ - QueryTreeList *inputQlist; /* the list of parse trees for the inputs + TgElement *elem; + char *funcName; + Oid typev[8]; /* eight arguments maximum */ + int i; + int parameterCount; + + QueryTreeList *qList; /* the parse tree of the nodeElement */ + QueryTreeList *inputQlist; /* the list of parse trees for the inputs * to this node */ - QueryTreeList *q; - Oid relid; - TgNode *child; - Relation rel; - unsigned int len; - TupleDesc tupdesc; + QueryTreeList *q; + Oid relid; + TgNode *child; + Relation rel; + unsigned int len; + TupleDesc tupdesc; qList = NULL; @@ -856,79 +856,79 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) elem = n->nodeElem; switch (elem->srcLang) { - case TG_SQL: - { + case TG_SQL: + { - /* - * for SQL ingredients, the SQL query is contained in the - * 'src' field - */ + /* + * for SQL ingredients, the SQL query is contained in + * the 'src' field + */ #ifdef DEBUG_RECIPE - elog(NOTICE, "calling parser with %s", elem->src); + elog(NOTICE, "calling parser with %s", elem->src); #endif /* DEBUG_RECIPE */ - parameterCount = getParamTypes(elem, typev); + parameterCount = getParamTypes(elem, typev); - qList = parser(elem->src, typev, parameterCount); + qList = parser(elem->src, typev, parameterCount); - if (qList->len > 1) - { - elog(NOTICE, - "tg_parseSubQuery: parser produced > 1 query tree"); + if (qList->len > 1) + { + elog(NOTICE, + "tg_parseSubQuery: parser produced > 1 query tree"); + } } - } - break; - case TG_C: - { - /* C ingredients are registered functions in postgres */ - - /* - * we create a new query string by using the function name - * (found in the 'src' field) and adding parameters to it - * so if the function was FOOBAR and took in two - * arguments, we would create a string select - * FOOBAR($1,$2) - */ - char newquery[1000]; + break; + case TG_C: + { + /* C ingredients are registered functions in postgres */ - funcName = elem->src; - parameterCount = getParamTypes(elem, typev); + /* + * we create a new query string by using the function + * name (found in the 'src' field) and adding + * parameters to it so if the function was FOOBAR and + * took in two arguments, we would create a string + * select FOOBAR($1,$2) + */ + char newquery[1000]; - if (parameterCount > 0) - { - int i; + funcName = elem->src; + parameterCount = getParamTypes(elem, typev); - sprintf(newquery, "select %s($1", funcName); - for (i = 1; i < parameterCount; i++) + if (parameterCount > 0) { - sprintf(newquery, "%s,$%d", newquery, i); + int i; + + sprintf(newquery, "select %s($1", funcName); + for (i = 1; i < parameterCount; i++) + { + sprintf(newquery, "%s,$%d", newquery, i); + } + sprintf(newquery, "%s)", newquery); } - sprintf(newquery, "%s)", newquery); - } - else - sprintf(newquery, "select %s()", funcName); + else + sprintf(newquery, "select %s()", funcName); #ifdef DEBUG_RECIPE - elog(NOTICE, "calling parser with %s", newquery); + elog(NOTICE, "calling parser with %s", newquery); #endif /* DEBUG_RECIPE */ - qList = parser(newquery, typev, parameterCount); - if (qList->len > 1) - { - elog(NOTICE, - "tg_parseSubQuery: parser produced > 1 query tree"); + qList = parser(newquery, typev, parameterCount); + if (qList->len > 1) + { + elog(NOTICE, + "tg_parseSubQuery: parser produced > 1 query tree"); + } } - } - break; - case TG_RECIPE_GRAPH: - elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!"); - break; - case TG_COMPILED: - elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!"); - break; - default: - elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang); + break; + case TG_RECIPE_GRAPH: + elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!"); + break; + case TG_COMPILED: + elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!"); + break; + default: + elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang); } /* parse each of the subrecipes that are input to this node */ @@ -1110,41 +1110,41 @@ OffsetVarAttno(Node * node, int varno, int offset) return; switch (nodeTag(node)) { - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; - - OffsetVarAttno(tle->expr, varno, offset); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - OffsetVarAttno((Node *) expr->args, varno, offset); - } - break; - case T_Var: - { - Var *var = (Var *) node; + OffsetVarAttno(tle->expr, varno, offset); + } + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - if (var->varno == varno) - var->varattno += offset; - } - break; - case T_List: - { - List *l; + OffsetVarAttno((Node *) expr->args, varno, offset); + } + break; + case T_Var: + { + Var *var = (Var *) node; - foreach(l, (List *) node) + if (var->varno == varno) + var->varattno += offset; + } + break; + case T_List: { - OffsetVarAttno(lfirst(l), varno, offset); + List *l; + + foreach(l, (List *) node) + { + OffsetVarAttno(lfirst(l), varno, offset); + } } - } - break; - default: - /* ignore the others */ - break; + break; + default: + /* ignore the others */ + break; } } @@ -1156,13 +1156,13 @@ OffsetVarAttno(Node * node, int varno, int offset) * returns a new querytree list */ -QueryTreeList * +QueryTreeList * appendQlist(QueryTreeList * q1, QueryTreeList * q2) { - QueryTreeList *newq; - int i, - j; - int newlen; + QueryTreeList *newq; + int i, + j; + int newlen; if (q1 == NULL) return q2; @@ -1191,7 +1191,7 @@ appendQlist(QueryTreeList * q1, QueryTreeList * q2) static void appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName) { - int i; + int i; Assert(teeInfo); @@ -1223,9 +1223,9 @@ static void replaceSeqScan(Plan * plan, Plan * parent, int rt_ind, Plan * tplan) { - Scan *snode; - Tee *teePlan; - Result *newPlan; + Scan *snode; + Tee *teePlan; + Result *newPlan; if (plan == NULL) { @@ -1306,16 +1306,16 @@ replaceSeqScan(Plan * plan, Plan * parent, * places the sequential scans of the Tee table with * a connection to the actual tee plan node */ -static Plan * +static Plan * replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo) { - int i; - List *rtable; - RangeTblEntry *rte; - char prefix[5]; - int rt_ind; - Plan *tplan; + int i; + List *rtable; + RangeTblEntry *rte; + char prefix[5]; + int rt_ind; + Plan *tplan; rtable = parsetree->rtable; if (rtable == NULL) diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index cafe4d0971..5b31866cf2 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.11 1997/09/07 04:40:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.12 1997/09/08 02:22:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,16 +48,16 @@ RemoveOperator(char *operatorName, /* operator name */ char *typeName1, /* first type name */ char *typeName2) /* optional second type name */ { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Oid typeId1 = InvalidOid; - Oid typeId2 = InvalidOid; - bool defined; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Oid typeId1 = InvalidOid; + Oid typeId2 = InvalidOid; + bool defined; ItemPointerData itemPointerData; - Buffer buffer; - ScanKeyData operatorKey[3]; - char *userName; + Buffer buffer; + ScanKeyData operatorKey[3]; + char *userName; if (typeName1) { @@ -148,14 +148,14 @@ RemoveOperator(char *operatorName, /* operator name */ static void SingleOpOperatorRemove(Oid typeOid) { - Relation rdesc; - ScanKeyData key[3]; - HeapScanDesc sdesc; - HeapTuple tup; + Relation rdesc; + ScanKeyData key[3]; + HeapScanDesc sdesc; + HeapTuple tup; ItemPointerData itemPointerData; - Buffer buffer; - static attnums[3] = {7, 8, 9}; /* left, right, return */ - register i; + Buffer buffer; + static attnums[3] = {7, 8, 9}; /* left, right, return */ + register i; ScanKeyEntryInitialize(&key[0], 0, 0, ObjectIdEqualRegProcedure, (Datum) typeOid); @@ -186,17 +186,17 @@ AttributeAndRelationRemove(Oid typeOid) { struct oidlist { - Oid reloid; + Oid reloid; struct oidlist *next; }; struct oidlist *oidptr, - *optr; - Relation rdesc; - ScanKeyData key[1]; - HeapScanDesc sdesc; - HeapTuple tup; + *optr; + Relation rdesc; + ScanKeyData key[1]; + HeapScanDesc sdesc; + HeapTuple tup; ItemPointerData itemPointerData; - Buffer buffer; + Buffer buffer; /* * Get the oid's of the relations to be removed by scanning the entire @@ -237,7 +237,7 @@ AttributeAndRelationRemove(Oid typeOid) tup = heap_getnext(sdesc, 0, &buffer); if (PointerIsValid(tup)) { - char *name; + char *name; name = (((Form_pg_class) GETSTRUCT(tup))->relname).data; heap_destroy(name); @@ -257,16 +257,16 @@ AttributeAndRelationRemove(Oid typeOid) void RemoveType(char *typeName) /* type name to be removed */ { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Oid typeOid; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Oid typeOid; ItemPointerData itemPointerData; static ScanKeyData typeKey[1] = { {0, Anum_pg_type_typname, NameEqualRegProcedure} }; - char *shadow_type; - char *userName; + char *shadow_type; + char *userName; #ifndef NO_SECURITY userName = GetPgUserName(); @@ -332,20 +332,20 @@ RemoveFunction(char *functionName, /* function name to be removed */ int nargs, List * argNameList /* list of TypeNames */ ) { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Buffer buffer = InvalidBuffer; - bool bufferUsed = FALSE; - Oid argList[8]; - Form_pg_proc the_proc = NULL; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Buffer buffer = InvalidBuffer; + bool bufferUsed = FALSE; + Oid argList[8]; + Form_pg_proc the_proc = NULL; ItemPointerData itemPointerData; static ScanKeyData key[3] = { {0, Anum_pg_proc_proname, NameEqualRegProcedure} }; - char *userName; - char *typename; - int i; + char *userName; + char *typename; + int i; memset(argList, 0, 8 * sizeof(Oid)); for (i = 0; i < nargs; i++) @@ -431,14 +431,14 @@ RemoveFunction(char *functionName, /* function name to be removed */ void RemoveAggregate(char *aggName, char *aggType) { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; ItemPointerData itemPointerData; - char *userName; - Oid basetypeID = InvalidOid; - bool defined; - ScanKeyData aggregateKey[3]; + char *userName; + Oid basetypeID = InvalidOid; + bool defined; + ScanKeyData aggregateKey[3]; /* diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 9b8df69834..d96fb762f2 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.8 1997/09/07 04:40:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.9 1997/09/08 02:22:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,13 +66,13 @@ renameatt(char *relname, char *userName, int recurse) { - Relation relrdesc, - attrdesc; - HeapTuple reltup, - oldatttup, - newatttup; + Relation relrdesc, + attrdesc; + HeapTuple reltup, + oldatttup, + newatttup; ItemPointerData oldTID; - Relation idescs[Num_pg_attr_indices]; + Relation idescs[Num_pg_attr_indices]; /* * permissions checking. this would normally be done in utility.c, @@ -101,10 +101,10 @@ renameatt(char *relname, */ if (recurse) { - Oid myrelid, - childrelid; - List *child, - *children; + Oid myrelid, + childrelid; + List *child, + *children; relrdesc = heap_openr(relname); if (!RelationIsValid(relrdesc)) @@ -126,7 +126,7 @@ renameatt(char *relname, */ foreach(child, children) { - char *childname; + char *childname; childrelid = lfirsti(child); if (childrelid == myrelid) @@ -213,13 +213,13 @@ renameatt(char *relname, void renamerel(char oldrelname[], char newrelname[]) { - Relation relrdesc; /* for RELATION relation */ - HeapTuple oldreltup, - newreltup; + Relation relrdesc; /* for RELATION relation */ + HeapTuple oldreltup, + newreltup; ItemPointerData oldTID; - char oldpath[MAXPGPATH], - newpath[MAXPGPATH]; - Relation idescs[Num_pg_class_indices]; + char oldpath[MAXPGPATH], + newpath[MAXPGPATH]; + Relation idescs[Num_pg_class_indices]; if (IsSystemRelationName(oldrelname)) { diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index c4bd8c40dc..3f5bc37163 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -24,37 +24,37 @@ #define SEQ_MAXVALUE ((int4)0x7FFFFFFF) #define SEQ_MINVALUE -(SEQ_MAXVALUE) -bool ItsSequenceCreation = false; +bool ItsSequenceCreation = false; typedef struct FormData_pg_sequence { - NameData sequence_name; - int4 last_value; - int4 increment_by; - int4 max_value; - int4 min_value; - int4 cache_value; - char is_cycled; - char is_called; -} FormData_pg_sequence; + NameData sequence_name; + int4 last_value; + int4 increment_by; + int4 max_value; + int4 min_value; + int4 cache_value; + char is_cycled; + char is_called; +} FormData_pg_sequence; typedef FormData_pg_sequence *SequenceTupleForm; typedef struct sequence_magic { - uint32 magic; -} sequence_magic; + uint32 magic; +} sequence_magic; typedef struct SeqTableData { - char *name; - Oid relid; - Relation rel; - int4 cached; - int4 last; - int4 increment; + char *name; + Oid relid; + Relation rel; + int4 cached; + int4 last; + int4 increment; struct SeqTableData *next; -} SeqTableData; +} SeqTableData; typedef SeqTableData *SeqTable; @@ -62,8 +62,8 @@ static SeqTable seqtab = NULL; static SeqTable init_sequence(char *caller, char *name); static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf); -static void init_params(CreateSeqStmt * seq, SequenceTupleForm new); -static int get_param(DefElem * def); +static void init_params(CreateSeqStmt * seq, SequenceTupleForm new); +static int get_param(DefElem * def); /* * DefineSequence -- @@ -73,18 +73,18 @@ void DefineSequence(CreateSeqStmt * seq) { FormData_pg_sequence new; - CreateStmt *stmt = makeNode(CreateStmt); - ColumnDef *coldef; - TypeName *typnam; - Relation rel; - Buffer buf; - PageHeader page; + CreateStmt *stmt = makeNode(CreateStmt); + ColumnDef *coldef; + TypeName *typnam; + Relation rel; + Buffer buf; + PageHeader page; sequence_magic *sm; - HeapTuple tuple; - TupleDesc tupDesc; - Datum value[SEQ_COL_LASTCOL]; - char null[SEQ_COL_LASTCOL]; - int i; + HeapTuple tuple; + TupleDesc tupDesc; + Datum value[SEQ_COL_LASTCOL]; + char null[SEQ_COL_LASTCOL]; + int i; /* Check and set values */ init_params(seq, &new); @@ -106,46 +106,46 @@ DefineSequence(CreateSeqStmt * seq) switch (i) { - case SEQ_COL_NAME: - typnam->name = "name"; - coldef->colname = "sequence_name"; - value[i - 1] = PointerGetDatum(seq->seqname); - break; - case SEQ_COL_LASTVAL: - typnam->name = "int4"; - coldef->colname = "last_value"; - value[i - 1] = Int32GetDatum(new.last_value); - break; - case SEQ_COL_INCBY: - typnam->name = "int4"; - coldef->colname = "increment_by"; - value[i - 1] = Int32GetDatum(new.increment_by); - break; - case SEQ_COL_MAXVALUE: - typnam->name = "int4"; - coldef->colname = "max_value"; - value[i - 1] = Int32GetDatum(new.max_value); - break; - case SEQ_COL_MINVALUE: - typnam->name = "int4"; - coldef->colname = "min_value"; - value[i - 1] = Int32GetDatum(new.min_value); - break; - case SEQ_COL_CACHE: - typnam->name = "int4"; - coldef->colname = "cache_value"; - value[i - 1] = Int32GetDatum(new.cache_value); - break; - case SEQ_COL_CYCLE: - typnam->name = "char"; - coldef->colname = "is_cycled"; - value[i - 1] = CharGetDatum(new.is_cycled); - break; - case SEQ_COL_CALLED: - typnam->name = "char"; - coldef->colname = "is_called"; - value[i - 1] = CharGetDatum('f'); - break; + case SEQ_COL_NAME: + typnam->name = "name"; + coldef->colname = "sequence_name"; + value[i - 1] = PointerGetDatum(seq->seqname); + break; + case SEQ_COL_LASTVAL: + typnam->name = "int4"; + coldef->colname = "last_value"; + value[i - 1] = Int32GetDatum(new.last_value); + break; + case SEQ_COL_INCBY: + typnam->name = "int4"; + coldef->colname = "increment_by"; + value[i - 1] = Int32GetDatum(new.increment_by); + break; + case SEQ_COL_MAXVALUE: + typnam->name = "int4"; + coldef->colname = "max_value"; + value[i - 1] = Int32GetDatum(new.max_value); + break; + case SEQ_COL_MINVALUE: + typnam->name = "int4"; + coldef->colname = "min_value"; + value[i - 1] = Int32GetDatum(new.min_value); + break; + case SEQ_COL_CACHE: + typnam->name = "int4"; + coldef->colname = "cache_value"; + value[i - 1] = Int32GetDatum(new.cache_value); + break; + case SEQ_COL_CYCLE: + typnam->name = "char"; + coldef->colname = "is_cycled"; + value[i - 1] = CharGetDatum(new.is_cycled); + break; + case SEQ_COL_CALLED: + typnam->name = "char"; + coldef->colname = "is_called"; + value[i - 1] = CharGetDatum('f'); + break; } stmt->tableElts = lappend(stmt->tableElts, coldef); } @@ -203,18 +203,18 @@ DefineSequence(CreateSeqStmt * seq) int4 nextval(struct varlena * seqin) { - char *seqname = textout(seqin); - SeqTable elm; - Buffer buf; + char *seqname = textout(seqin); + SeqTable elm; + Buffer buf; SequenceTupleForm seq; ItemPointerData iptr; - int4 incby, - maxv, - minv, - cache; - int4 result, - next, - rescnt = 0; + int4 incby, + maxv, + minv, + cache; + int4 result, + next, + rescnt = 0; /* open and WIntentLock sequence */ elm = init_sequence("nextval", seqname); @@ -303,9 +303,9 @@ nextval(struct varlena * seqin) int4 currval(struct varlena * seqin) { - char *seqname = textout(seqin); - SeqTable elm; - int4 result; + char *seqname = textout(seqin); + SeqTable elm; + int4 result; /* open and WIntentLock sequence */ elm = init_sequence("currval", seqname); @@ -322,13 +322,13 @@ currval(struct varlena * seqin) } -static SequenceTupleForm +static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf) { ItemPointerData iptr; - PageHeader page; - ItemId lp; - HeapTuple tuple; + PageHeader page; + ItemId lp; + HeapTuple tuple; sequence_magic *sm; SequenceTupleForm seq; @@ -362,12 +362,12 @@ read_info(char *caller, SeqTable elm, Buffer * buf) } -static SeqTable +static SeqTable init_sequence(char *caller, char *name) { - SeqTable elm, - priv = (SeqTable) NULL; - SeqTable temp; + SeqTable elm, + priv = (SeqTable) NULL; + SeqTable temp; for (elm = seqtab; elm != (SeqTable) NULL;) { @@ -436,8 +436,8 @@ init_sequence(char *caller, char *name) void CloseSequences(void) { - SeqTable elm; - Relation rel; + SeqTable elm; + Relation rel; ItsSequenceCreation = false; @@ -461,17 +461,17 @@ CloseSequences(void) static void init_params(CreateSeqStmt * seq, SequenceTupleForm new) { - DefElem *last_value = NULL; - DefElem *increment_by = NULL; - DefElem *max_value = NULL; - DefElem *min_value = NULL; - DefElem *cache_value = NULL; - List *option; + DefElem *last_value = NULL; + DefElem *increment_by = NULL; + DefElem *max_value = NULL; + DefElem *min_value = NULL; + DefElem *cache_value = NULL; + List *option; new->is_cycled = 'f'; foreach(option, seq->options) { - DefElem *defel = (DefElem *) lfirst(option); + DefElem *defel = (DefElem *) lfirst(option); if (!strcasecmp(defel->defname, "increment")) increment_by = defel; diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 53ab1838cf..e25c955d8d 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -32,36 +32,36 @@ #include "utils/syscache.h" #endif -TriggerData *CurrentTriggerData = NULL; +TriggerData *CurrentTriggerData = NULL; -void RelationBuildTriggers(Relation relation); -void FreeTriggerDesc(Relation relation); +void RelationBuildTriggers(Relation relation); +void FreeTriggerDesc(Relation relation); -static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger); +static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger); -extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs); +extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs); extern GlobalMemory CacheCxt; void CreateTrigger(CreateTrigStmt * stmt) { - int16 tgtype; - int16 tgattr[8] = {0}; - Datum values[Natts_pg_trigger]; - char nulls[Natts_pg_trigger]; - Relation rel; - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - Relation relrdesc; - HeapTuple tuple; + int16 tgtype; + int16 tgattr[8] = {0}; + Datum values[Natts_pg_trigger]; + char nulls[Natts_pg_trigger]; + Relation rel; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + Relation relrdesc; + HeapTuple tuple; ItemPointerData oldTID; - Relation idescs[Num_pg_trigger_indices]; - Relation ridescs[Num_pg_class_indices]; - MemoryContext oldcxt; - Oid fargtypes[8]; - int found = 0; - int i; + Relation idescs[Num_pg_trigger_indices]; + Relation ridescs[Num_pg_class_indices]; + MemoryContext oldcxt; + Oid fargtypes[8]; + int found = 0; + int i; if (IsSystemRelationName(stmt->relname)) elog(WARN, "CreateTrigger: can't create trigger for system relation %s", stmt->relname); @@ -86,24 +86,24 @@ CreateTrigger(CreateTrigStmt * stmt) { switch (stmt->actions[i]) { - case 'i': - if (TRIGGER_FOR_INSERT(tgtype)) - elog(WARN, "CreateTrigger: double INSERT event specified"); - TRIGGER_SETT_INSERT(tgtype); - break; - case 'd': - if (TRIGGER_FOR_DELETE(tgtype)) - elog(WARN, "CreateTrigger: double DELETE event specified"); - TRIGGER_SETT_DELETE(tgtype); - break; - case 'u': - if (TRIGGER_FOR_UPDATE(tgtype)) - elog(WARN, "CreateTrigger: double UPDATE event specified"); - TRIGGER_SETT_UPDATE(tgtype); - break; - default: - elog(WARN, "CreateTrigger: unknown event specified"); - break; + case 'i': + if (TRIGGER_FOR_INSERT(tgtype)) + elog(WARN, "CreateTrigger: double INSERT event specified"); + TRIGGER_SETT_INSERT(tgtype); + break; + case 'd': + if (TRIGGER_FOR_DELETE(tgtype)) + elog(WARN, "CreateTrigger: double DELETE event specified"); + TRIGGER_SETT_DELETE(tgtype); + break; + case 'u': + if (TRIGGER_FOR_UPDATE(tgtype)) + elog(WARN, "CreateTrigger: double UPDATE event specified"); + TRIGGER_SETT_UPDATE(tgtype); + break; + default: + elog(WARN, "CreateTrigger: unknown event specified"); + break; } } @@ -145,14 +145,14 @@ CreateTrigger(CreateTrigStmt * stmt) values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); if (stmt->args) { - List *le; - char *args; - int16 nargs = length(stmt->args); - int len = 0; + List *le; + char *args; + int16 nargs = length(stmt->args); + int len = 0; foreach(le, stmt->args) { - char *ar = (char *) lfirst(le); + char *ar = (char *) lfirst(le); len += strlen(ar) + 4; } @@ -213,17 +213,17 @@ CreateTrigger(CreateTrigStmt * stmt) void DropTrigger(DropTrigStmt * stmt) { - Relation rel; - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - Relation relrdesc; - HeapTuple tuple; + Relation rel; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + Relation relrdesc; + HeapTuple tuple; ItemPointerData oldTID; - Relation ridescs[Num_pg_class_indices]; - MemoryContext oldcxt; - int found = 0; - int tgfound = 0; + Relation ridescs[Num_pg_class_indices]; + MemoryContext oldcxt; + int found = 0; + int tgfound = 0; #ifndef NO_SECURITY if (!pg_ownercheck(GetPgUserName(), stmt->relname, RELNAME)) @@ -295,10 +295,10 @@ DropTrigger(DropTrigStmt * stmt) void RelationRemoveTriggers(Relation rel) { - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - HeapTuple tup; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + HeapTuple tup; tgrel = heap_openr(TriggerRelationName); RelationSetLockForWrite(tgrel); @@ -319,22 +319,22 @@ RelationRemoveTriggers(Relation rel) void RelationBuildTriggers(Relation relation) { - TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc)); - int ntrigs = relation->rd_rel->reltriggers; - Trigger *triggers = NULL; - Trigger *build; - Relation tgrel; + TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc)); + int ntrigs = relation->rd_rel->reltriggers; + Trigger *triggers = NULL; + Trigger *build; + Relation tgrel; Form_pg_trigger pg_trigger; - Relation irel; - ScanKeyData skey; - HeapTuple tuple; - IndexScanDesc sd; + Relation irel; + ScanKeyData skey; + HeapTuple tuple; + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - ItemPointer iptr; + Buffer buffer; + ItemPointer iptr; struct varlena *val; - bool isnull; - int found; + bool isnull; + int found; memset(trigdesc, 0, sizeof(TriggerDesc)); @@ -386,8 +386,8 @@ RelationBuildTriggers(Relation relation) NAMEDATALEN, relation->rd_rel->relname.data); if (build->tgnargs > 0) { - char *p; - int i; + char *p; + int i; val = (struct varlena *) fastgetattr(tuple, Anum_pg_trigger_tgargs, @@ -437,10 +437,10 @@ RelationBuildTriggers(Relation relation) void FreeTriggerDesc(Relation relation) { - TriggerDesc *trigdesc = relation->trigdesc; - Trigger ***t; - Trigger *trigger; - int i; + TriggerDesc *trigdesc = relation->trigdesc; + Trigger ***t; + Trigger *trigger; + int i; if (trigdesc == NULL) return; @@ -483,9 +483,9 @@ FreeTriggerDesc(Relation relation) static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger) { - uint16 *n; - Trigger ***t, - ***tp; + uint16 *n; + Trigger ***t, + ***tp; if (TRIGGER_FOR_ROW(trigger->tgtype)) /* Is ROW/STATEMENT * trigger */ @@ -557,11 +557,11 @@ DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger) HeapTuple ExecBRInsertTriggers(Relation rel, HeapTuple tuple) { - int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT]; - Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT]; - HeapTuple newtuple = tuple; - int nargs; - int i; + int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT]; + Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT]; + HeapTuple newtuple = tuple; + int nargs; + int i; CurrentTriggerData = (TriggerData *) palloc(sizeof(TriggerData)); CurrentTriggerData->tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW; diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 30690f0f32..66fbbd5db2 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.43 1997/09/07 04:41:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.44 1997/09/08 02:22:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,11 +56,11 @@ #include <port-protos.h> -bool VacuumRunning = false; +bool VacuumRunning = false; -static Portal vc_portal; +static Portal vc_portal; -static int MESSAGE_LEVEL; /* message level */ +static int MESSAGE_LEVEL; /* message level */ #define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;} #define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;} @@ -72,46 +72,46 @@ static int MESSAGE_LEVEL; /* message level */ /* non-export function prototypes */ -static void vc_init(void); -static void vc_shutdown(void); -static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols); +static void vc_init(void); +static void vc_shutdown(void); +static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols); static VRelList vc_getrels(NameData * VacRelP); -static void vc_vacone(Oid relid, bool analyze, List * va_cols); -static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl); -static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel); -static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl); -static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel); -static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups); -static void vc_scanoneind(Relation indrel, int nhtups); -static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup); -static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len); -static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats); -static void vc_delhilowstats(Oid relid, int attcnt, int *attnums); -static void vc_setpagelock(Relation rel, BlockNumber blkno); +static void vc_vacone(Oid relid, bool analyze, List * va_cols); +static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl); +static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel); +static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl); +static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel); +static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups); +static void vc_scanoneind(Relation indrel, int nhtups); +static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup); +static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len); +static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats); +static void vc_delhilowstats(Oid relid, int attcnt, int *attnums); +static void vc_setpagelock(Relation rel, BlockNumber blkno); static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl); -static void vc_reappage(VPageList vpl, VPageDescr vpc); -static void vc_vpinsert(VPageList vpl, VPageDescr vpnew); -static void vc_free(VRelList vrl); -static void vc_getindices(Oid relid, int *nindices, Relation ** Irel); -static void vc_clsindices(int nindices, Relation * Irel); +static void vc_reappage(VPageList vpl, VPageDescr vpc); +static void vc_vpinsert(VPageList vpl, VPageDescr vpnew); +static void vc_free(VRelList vrl); +static void vc_getindices(Oid relid, int *nindices, Relation ** Irel); +static void vc_clsindices(int nindices, Relation * Irel); static Relation vc_getarchrel(Relation heaprel); -static void vc_archive(Relation archrel, HeapTuple htup); -static bool vc_isarchrel(char *rname); -static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc); -static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)); -static int vc_cmp_blk(char *left, char *right); -static int vc_cmp_offno(char *left, char *right); -static bool vc_enough_space(VPageDescr vpd, Size len); +static void vc_archive(Relation archrel, HeapTuple htup); +static bool vc_isarchrel(char *rname); +static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc); +static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)); +static int vc_cmp_blk(char *left, char *right); +static int vc_cmp_offno(char *left, char *right); +static bool vc_enough_space(VPageDescr vpd, Size len); void vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) { - char *pname; - MemoryContext old; + char *pname; + MemoryContext old; PortalVariableMemory pmem; - NameData VacRel; - List *le; - List *va_cols = NIL; + NameData VacRel; + List *le; + List *va_cols = NIL; /* * Create a portal for safe memory across transctions. We need to @@ -139,8 +139,8 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) Assert(va_spec == NIL || analyze); foreach(le, va_spec) { - char *col = (char *) lfirst(le); - char *dest; + char *col = (char *) lfirst(le); + char *dest; dest = (char *) palloc(strlen(col) + 1); strcpy(dest, col); @@ -183,7 +183,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) static void vc_init() { - int fd; + int fd; if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0) elog(WARN, "can't create lock file -- another vacuum cleaner running?"); @@ -238,8 +238,8 @@ vc_abort() static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols) { - VRelList vrl, - cur; + VRelList vrl, + cur; /* get list of relations */ vrl = vc_getrels(VacRelP); @@ -254,25 +254,25 @@ vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols) vc_free(vrl); } -static VRelList +static VRelList vc_getrels(NameData * VacRelP) { - Relation pgclass; - TupleDesc pgcdesc; - HeapScanDesc pgcscan; - HeapTuple pgctup; - Buffer buf; + Relation pgclass; + TupleDesc pgcdesc; + HeapScanDesc pgcscan; + HeapTuple pgctup; + Buffer buf; PortalVariableMemory portalmem; - MemoryContext old; - VRelList vrl, - cur; - Datum d; - char *rname; - char rkind; - int16 smgrno; - bool n; - ScanKeyData pgckey; - bool found = false; + MemoryContext old; + VRelList vrl, + cur; + Datum d; + char *rname; + char rkind; + int16 smgrno; + bool n; + ScanKeyData pgckey; + bool found = false; StartTransactionCommand(); @@ -404,23 +404,23 @@ vc_getrels(NameData * VacRelP) static void vc_vacone(Oid relid, bool analyze, List * va_cols) { - Relation pgclass; - TupleDesc pgcdesc; - HeapTuple pgctup, - pgttup; - Buffer pgcbuf; - HeapScanDesc pgcscan; - Relation onerel; - ScanKeyData pgckey; - VPageListData Vvpl; /* List of pages to vacuum and/or clean + Relation pgclass; + TupleDesc pgcdesc; + HeapTuple pgctup, + pgttup; + Buffer pgcbuf; + HeapScanDesc pgcscan; + Relation onerel; + ScanKeyData pgckey; + VPageListData Vvpl; /* List of pages to vacuum and/or clean * indices */ - VPageListData Fvpl; /* List of pages with space enough for + VPageListData Fvpl; /* List of pages with space enough for * re-using */ - VPageDescr *vpp; - Relation *Irel; - int32 nindices, - i; - VRelStats *vacrelstats; + VPageDescr *vpp; + Relation *Irel; + int32 nindices, + i; + VRelStats *vacrelstats; StartTransactionCommand(); @@ -454,8 +454,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) vacrelstats->hasindex = false; if (analyze && !IsSystemRelationName((RelationGetRelationName(onerel))->data)) { - int attr_cnt, - *attnums = NULL; + int attr_cnt, + *attnums = NULL; AttributeTupleForm *attr; attr_cnt = onerel->rd_att->natts; @@ -463,8 +463,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) if (va_cols != NIL) { - int tcnt = 0; - List *le; + int tcnt = 0; + List *le; if (length(va_cols) > attr_cnt) elog(WARN, "vacuum: too many attributes specified for relation %s", @@ -472,7 +472,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) attnums = (int *) palloc(attr_cnt * sizeof(int)); foreach(le, va_cols) { - char *col = (char *) lfirst(le); + char *col = (char *) lfirst(le); for (i = 0; i < attr_cnt; i++) { @@ -495,9 +495,9 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) for (i = 0; i < attr_cnt; i++) { - Operator func_operator; + Operator func_operator; OperatorTupleForm pgopform; - VacAttrStats *stats; + VacAttrStats *stats; stats = &vacrelstats->vacattrstats[i]; stats->attr = palloc(ATTRIBUTE_TUPLE_SIZE); @@ -513,7 +513,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper("=", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmpeq), &nargs); @@ -524,7 +524,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper("<", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmplt), &nargs); @@ -535,7 +535,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper(">", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmpgt), &nargs); @@ -642,39 +642,39 @@ static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl) { - int nblocks, - blkno; - ItemId itemid; - ItemPointer itemptr; - HeapTuple htup; - Buffer buf; - Page page, - tempPage = NULL; - OffsetNumber offnum, - maxoff; - bool pgchanged, - tupgone, - dobufrel, - notup; - char *relname; - VPageDescr vpc, - vp; - uint32 nvac, - ntups, - nunused, - ncrash, - nempg, - nnepg, - nchpg, - nemend; - Size frsize, - frsusf; - Size min_tlen = MAXTUPLEN; - Size max_tlen = 0; - int32 i /* , attr_cnt */ ; - struct rusage ru0, - ru1; - bool do_shrinking = true; + int nblocks, + blkno; + ItemId itemid; + ItemPointer itemptr; + HeapTuple htup; + Buffer buf; + Page page, + tempPage = NULL; + OffsetNumber offnum, + maxoff; + bool pgchanged, + tupgone, + dobufrel, + notup; + char *relname; + VPageDescr vpc, + vp; + uint32 nvac, + ntups, + nunused, + ncrash, + nempg, + nnepg, + nchpg, + nemend; + Size frsize, + frsusf; + Size min_tlen = MAXTUPLEN; + Size max_tlen = 0; + int32 i /* , attr_cnt */ ; + struct rusage ru0, + ru1; + bool do_shrinking = true; getrusage(RUSAGE_SELF, &ru0); @@ -844,11 +844,11 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.", if (tupgone) { - ItemId lpp; + ItemId lpp; if (tempPage == (Page) NULL) { - Size pageSize; + Size pageSize; pageSize = PageGetPageSize(page); tempPage = (Page) palloc(pageSize); @@ -927,7 +927,7 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.", */ if (do_shrinking && Vvpl->vpl_npages - nemend > 0) { - int nusf; /* blocks usefull for re-using */ + int nusf; /* blocks usefull for re-using */ nusf = Vvpl->vpl_npages - nemend; if ((Vvpl->vpl_pgdesc[nusf - 1])->vpd_blkno == nblocks - nemend - 1) @@ -972,50 +972,50 @@ static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel) { - TransactionId myXID; - CommandId myCID; - AbsoluteTime myCTM = 0; - Buffer buf, - ToBuf; - int nblocks, - blkno; - Page page, - ToPage = NULL; - OffsetNumber offnum = 0, - maxoff = 0, - newoff, - moff; - ItemId itemid, - newitemid; - HeapTuple htup, - newtup; - TupleDesc tupdesc = NULL; - Datum *idatum = NULL; - char *inulls = NULL; + TransactionId myXID; + CommandId myCID; + AbsoluteTime myCTM = 0; + Buffer buf, + ToBuf; + int nblocks, + blkno; + Page page, + ToPage = NULL; + OffsetNumber offnum = 0, + maxoff = 0, + newoff, + moff; + ItemId itemid, + newitemid; + HeapTuple htup, + newtup; + TupleDesc tupdesc = NULL; + Datum *idatum = NULL; + char *inulls = NULL; InsertIndexResult iresult; - VPageListData Nvpl; - VPageDescr ToVpd = NULL, - Fvplast, - Vvplast, - vpc, - *vpp; - int ToVpI = 0; - IndDesc *Idesc, - *idcur; - int Fblklast, - Vblklast, - i; - Size tlen; - int nmoved, - Fnpages, - Vnpages; - int nchkmvd, - ntups; - bool isempty, - dowrite; - Relation archrel; - struct rusage ru0, - ru1; + VPageListData Nvpl; + VPageDescr ToVpd = NULL, + Fvplast, + Vvplast, + vpc, + *vpp; + int ToVpI = 0; + IndDesc *Idesc, + *idcur; + int Fblklast, + Vblklast, + i; + Size tlen; + int nmoved, + Fnpages, + Vnpages; + int nchkmvd, + ntups; + bool isempty, + dowrite; + Relation archrel; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1342,9 +1342,9 @@ Elapsed %u/%u sec.", /* vacuum indices again if needed */ if (Irel != (Relation *) NULL) { - VPageDescr *vpleft, - *vpright, - vpsave; + VPageDescr *vpleft, + *vpright, + vpsave; /* re-sort Nvpl.vpl_pgdesc */ for (vpleft = Nvpl.vpl_pgdesc, @@ -1426,12 +1426,12 @@ Elapsed %u/%u sec.", static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl) { - Buffer buf; - Page page; - VPageDescr *vpp; - Relation archrel; - int nblocks; - int i; + Buffer buf; + Page page; + VPageDescr *vpp; + Relation archrel; + int nblocks; + int i; nblocks = Vvpl->vpl_npages; /* if the relation has an archive, open it */ @@ -1486,9 +1486,9 @@ vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl) static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel) { - ItemId itemid; - HeapTuple htup; - int i; + ItemId itemid; + HeapTuple htup; + int i; Assert(vpd->vpd_nusd == 0); for (i = 0; i < vpd->vpd_noff; i++) @@ -1513,11 +1513,11 @@ static void vc_scanoneind(Relation indrel, int nhtups) { RetrieveIndexResult res; - IndexScanDesc iscan; - int nitups; - int nipages; - struct rusage ru0, - ru1; + IndexScanDesc iscan; + int nitups; + int nipages; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1567,14 +1567,14 @@ static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups) { RetrieveIndexResult res; - IndexScanDesc iscan; - ItemPointer heapptr; - int nvac; - int nitups; - int nipages; - VPageDescr vp; - struct rusage ru0, - ru1; + IndexScanDesc iscan; + ItemPointer heapptr; + int nvac; + int nitups; + int nipages; + VPageDescr vp; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1639,14 +1639,14 @@ vc_vaconeind(VPageList vpl, Relation indrel, int nhtups) * * vpl->VPageDescr_array is sorted in right order. */ -static VPageDescr +static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl) { - OffsetNumber ioffno; - OffsetNumber *voff; - VPageDescr vp, - *vpp; - VPageDescrData vpd; + OffsetNumber ioffno; + OffsetNumber *voff; + VPageDescr vp, + *vpp; + VPageDescrData vpd; vpd.vpd_blkno = ItemPointerGetBlockNumber(itemptr); ioffno = ItemPointerGetOffsetNumber(itemptr); @@ -1702,17 +1702,17 @@ vc_tidreapped(ItemPointer itemptr, VPageList vpl) static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup) { - int i, - attr_cnt = vacrelstats->va_natts; - VacAttrStats *vacattrstats = vacrelstats->vacattrstats; - TupleDesc tupDesc = onerel->rd_att; - Datum value; - bool isnull; + int i, + attr_cnt = vacrelstats->va_natts; + VacAttrStats *vacattrstats = vacrelstats->vacattrstats; + TupleDesc tupDesc = onerel->rd_att; + Datum value; + bool isnull; for (i = 0; i < attr_cnt; i++) { - VacAttrStats *stats = &vacattrstats[i]; - bool value_hit = true; + VacAttrStats *stats = &vacattrstats[i]; + bool value_hit = true; value = (Datum) heap_getattr(htup, InvalidBuffer, stats->attr->attnum, tupDesc, &isnull); @@ -1806,7 +1806,7 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke *bucket = value; else { - int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value)); + int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value)); if (len > *bucket_len) { @@ -1833,20 +1833,20 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats) { - Relation rd, - ad, - sd; - HeapScanDesc rsdesc, - asdesc; - TupleDesc sdesc; - HeapTuple rtup, - atup, - stup; - Buffer rbuf, - abuf; - Form_pg_class pgcform; - ScanKeyData rskey, - askey; + Relation rd, + ad, + sd; + HeapScanDesc rsdesc, + asdesc; + TupleDesc sdesc; + HeapTuple rtup, + atup, + stup; + Buffer rbuf, + abuf; + Form_pg_class pgcform; + ScanKeyData rskey, + askey; AttributeTupleForm attp; /* @@ -1872,8 +1872,8 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels if (vacrelstats != NULL && vacrelstats->va_natts > 0) { - VacAttrStats *vacattrstats = vacrelstats->vacattrstats; - int natts = vacrelstats->va_natts; + VacAttrStats *vacattrstats = vacrelstats->vacattrstats; + int natts = vacrelstats->va_natts; ad = heap_openr(AttributeRelationName); sd = heap_openr(StatisticRelationName); @@ -1884,12 +1884,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels while (HeapTupleIsValid(atup = heap_getnext(asdesc, 0, &abuf))) { - int i; - float32data selratio; /* average ratio of rows selected + int i; + float32data selratio; /* average ratio of rows selected * for a random constant */ - VacAttrStats *stats; - Datum values[Natts_pg_statistic]; - char nulls[Natts_pg_statistic]; + VacAttrStats *stats; + Datum values[Natts_pg_statistic]; + char nulls[Natts_pg_statistic]; attp = (AttributeTupleForm) GETSTRUCT(atup); if (attp->attnum <= 0) /* skip system attributes for now, */ @@ -1916,18 +1916,18 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels selratio = 0; else if (VacAttrStatsLtGtValid(stats) && stats->min_cnt + stats->max_cnt == stats->nonnull_cnt) { - double min_cnt_d = stats->min_cnt, - max_cnt_d = stats->max_cnt, - null_cnt_d = stats->null_cnt, - nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */ + double min_cnt_d = stats->min_cnt, + max_cnt_d = stats->max_cnt, + null_cnt_d = stats->null_cnt, + nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */ selratio = (min_cnt_d * min_cnt_d + max_cnt_d * max_cnt_d + null_cnt_d * null_cnt_d) / (nonnullcnt_d + null_cnt_d) / (nonnullcnt_d + null_cnt_d); } else { - double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt); - double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt); + double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt); + double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt); /* * we assume count of other values are 20% of best @@ -1948,12 +1948,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels */ if (VacAttrStatsLtGtValid(stats) && stats->initialized /* && * !IsSystemRelationName( - * pgcform->relname.data) - */ ) + * + pgcform->relname.data) */ ) { - func_ptr out_function; - char *out_string; - int dummy; + func_ptr out_function; + char *out_string; + int dummy; for (i = 0; i < Natts_pg_statistic; ++i) nulls[i] = ' '; @@ -2016,10 +2016,10 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels static void vc_delhilowstats(Oid relid, int attcnt, int *attnums) { - Relation pgstatistic; - HeapScanDesc pgsscan; - HeapTuple pgstup; - ScanKeyData pgskey; + Relation pgstatistic; + HeapScanDesc pgsscan; + HeapTuple pgstup; + ScanKeyData pgskey; pgstatistic = heap_openr(StatisticRelationName); @@ -2038,7 +2038,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums) if (attcnt > 0) { Form_pg_statistic pgs = (Form_pg_statistic) GETSTRUCT(pgstup); - int i; + int i; for (i = 0; i < attcnt; i++) { @@ -2075,7 +2075,7 @@ vc_setpagelock(Relation rel, BlockNumber blkno) static void vc_reappage(VPageList vpl, VPageDescr vpc) { - VPageDescr newvpd; + VPageDescr newvpd; /* allocate a VPageDescrData entry */ newvpd = (VPageDescr) palloc(sizeof(VPageDescrData) + vpc->vpd_noff * sizeof(OffsetNumber)); @@ -2110,8 +2110,8 @@ vc_vpinsert(VPageList vpl, VPageDescr vpnew) static void vc_free(VRelList vrl) { - VRelList p_vrl; - MemoryContext old; + VRelList p_vrl; + MemoryContext old; PortalVariableMemory pmem; pmem = PortalGetVariableMemory(vc_portal); @@ -2138,11 +2138,11 @@ vc_free(VRelList vrl) #define ARCHIVE_PREFIX "a," -static Relation +static Relation vc_getarchrel(Relation heaprel) { - Relation archrel; - char *archrelname; + Relation archrel; + char *archrelname; archrelname = palloc(sizeof(ARCHIVE_PREFIX) + NAMEDATALEN); /* bogus */ sprintf(archrelname, "%s%d", ARCHIVE_PREFIX, heaprel->rd_id); @@ -2165,7 +2165,7 @@ vc_archive(Relation archrel, HeapTuple htup) doinsert(archrel, htup); } -static bool +static bool vc_isarchrel(char *rname) { if (strncmp(ARCHIVE_PREFIX, rname, strlen(ARCHIVE_PREFIX)) == 0) @@ -2174,14 +2174,14 @@ vc_isarchrel(char *rname) return (false); } -static char * +static char * vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)) { - int res; - int last = nelem - 1; - int celm = nelem / 2; - bool last_move, - first_move; + int res; + int last = nelem - 1; + int celm = nelem / 2; + bool last_move, + first_move; last_move = first_move = true; for (;;) @@ -2231,8 +2231,8 @@ vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, cha static int vc_cmp_blk(char *left, char *right) { - BlockNumber lblk, - rblk; + BlockNumber lblk, + rblk; lblk = (*((VPageDescr *) left))->vpd_blkno; rblk = (*((VPageDescr *) right))->vpd_blkno; @@ -2261,17 +2261,17 @@ vc_cmp_offno(char *left, char *right) static void vc_getindices(Oid relid, int *nindices, Relation ** Irel) { - Relation pgindex; - Relation irel; - TupleDesc pgidesc; - HeapTuple pgitup; - HeapScanDesc pgiscan; - Datum d; - int i, - k; - bool n; - ScanKeyData pgikey; - Oid *ioid; + Relation pgindex; + Relation irel; + TupleDesc pgidesc; + HeapTuple pgitup; + HeapScanDesc pgiscan; + Datum d; + int i, + k; + bool n; + ScanKeyData pgikey; + Oid *ioid; *nindices = i = 0; @@ -2354,11 +2354,11 @@ vc_clsindices(int nindices, Relation * Irel) static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc) { - IndDesc *idcur; - HeapTuple pgIndexTup; - AttrNumber *attnumP; - int natts; - int i; + IndDesc *idcur; + HeapTuple pgIndexTup; + AttrNumber *attnumP; + int natts; + int i; *Idesc = (IndDesc *) palloc(nindices * sizeof(IndDesc)); @@ -2390,7 +2390,7 @@ vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc) } /* vc_mkindesc */ -static bool +static bool vc_enough_space(VPageDescr vpd, Size len) { diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 99439de9ce..c4f411021a 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.9 1997/09/07 04:41:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.10 1997/09/08 02:22:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,13 +44,13 @@ static void DefineVirtualRelation(char *relname, List * tlist) { - CreateStmt createStmt; - List *attrList, - *t; - TargetEntry *entry; - Resdom *res; - char *resname; - char *restypename; + CreateStmt createStmt; + List *attrList, + *t; + TargetEntry *entry; + Resdom *res; + char *resname; + char *restypename; /* * create a list with one entry per attribute of this relation. Each @@ -63,8 +63,8 @@ DefineVirtualRelation(char *relname, List * tlist) { foreach(t, tlist) { - ColumnDef *def = makeNode(ColumnDef); - TypeName *typename; + ColumnDef *def = makeNode(ColumnDef); + TypeName *typename; /* * find the names of the attribute & its type @@ -123,7 +123,7 @@ DefineVirtualRelation(char *relname, List * tlist) * XXX it also means viewName cannot be 16 chars long! - ay 11/94 *------------------------------------------------------------------ */ -char * +char * MakeRetrieveViewRuleName(char *viewName) { /* @@ -135,7 +135,7 @@ MakeRetrieveViewRuleName(char *viewName) namestrcpy(rule_name, buf); */ - char *buf; + char *buf; buf = palloc(strlen(viewName) + 5); sprintf(buf, "_RET%s", viewName); @@ -145,9 +145,9 @@ MakeRetrieveViewRuleName(char *viewName) static RuleStmt * FormViewRetrieveRule(char *viewName, Query * viewParse) { - RuleStmt *rule; - char *rname; - Attr *attr; + RuleStmt *rule; + char *rname; + Attr *attr; /* * Create a RuleStmt that corresponds to the suitable rewrite rule @@ -172,12 +172,12 @@ FormViewRetrieveRule(char *viewName, Query * viewParse) static void DefineViewRules(char *viewName, Query * viewParse) { - RuleStmt *retrieve_rule = NULL; + RuleStmt *retrieve_rule = NULL; #ifdef NOTYET - RuleStmt *replace_rule = NULL; - RuleStmt *append_rule = NULL; - RuleStmt *delete_rule = NULL; + RuleStmt *replace_rule = NULL; + RuleStmt *append_rule = NULL; + RuleStmt *delete_rule = NULL; #endif @@ -226,10 +226,10 @@ DefineViewRules(char *viewName, Query * viewParse) static void UpdateRangeTableOfViewParse(char *viewName, Query * viewParse) { - List *old_rt; - List *new_rt; - RangeTblEntry *rt_entry1, - *rt_entry2; + List *old_rt; + List *new_rt; + RangeTblEntry *rt_entry1, + *rt_entry2; /* * first offset all var nodes by 2 @@ -277,7 +277,7 @@ UpdateRangeTableOfViewParse(char *viewName, Query * viewParse) void DefineView(char *viewName, Query * viewParse) { - List *viewTlist; + List *viewTlist; viewTlist = viewParse->targetList; @@ -313,7 +313,7 @@ DefineView(char *viewName, Query * viewParse) void RemoveView(char *viewName) { - char *rname; + char *rname; /* * first remove all the "view" rules... Currently we only have one! diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index 401924485e..3aeb78ed37 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.6 1997/09/07 04:41:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.7 1997/09/08 02:22:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,8 +74,8 @@ ExecOpenScanR(Oid relOid, Relation * returnRelation, /* return */ Pointer * returnScanDesc) /* return */ { - Relation relation; - Pointer scanDesc; + Relation relation; + Pointer scanDesc; /* ---------------- * note: scanDesc returned by ExecBeginScan can be either @@ -104,10 +104,10 @@ ExecOpenScanR(Oid relOid, * returns a relation descriptor given an object id. * ---------------------------------------------------------------- */ -static Relation +static Relation ExecOpenR(Oid relationOid, bool isindex) { - Relation relation; + Relation relation; relation = (Relation) NULL; @@ -141,7 +141,7 @@ ExecOpenR(Oid relationOid, bool isindex) * -cim 9/14/89 * ---------------------------------------------------------------- */ -static Pointer +static Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys, @@ -149,7 +149,7 @@ ExecBeginScan(Relation relation, ScanDirection dir, TimeQual time_range) { - Pointer scanDesc; + Pointer scanDesc; scanDesc = NULL; @@ -198,8 +198,8 @@ void ExecCloseR(Plan * node) { CommonScanState *state; - Relation relation; - HeapScanDesc scanDesc; + Relation relation; + HeapScanDesc scanDesc; /* ---------------- * shut down the heap scan and close the heap relation @@ -208,29 +208,29 @@ ExecCloseR(Plan * node) switch (nodeTag(node)) { - case T_SeqScan: - state = ((SeqScan *) node)->scanstate; - break; + case T_SeqScan: + state = ((SeqScan *) node)->scanstate; + break; - case T_IndexScan: - state = ((IndexScan *) node)->scan.scanstate; - break; + case T_IndexScan: + state = ((IndexScan *) node)->scan.scanstate; + break; - case T_Material: - state = &(((Material *) node)->matstate->csstate); - break; + case T_Material: + state = &(((Material *) node)->matstate->csstate); + break; - case T_Sort: - state = &(((Sort *) node)->sortstate->csstate); - break; + case T_Sort: + state = &(((Sort *) node)->sortstate->csstate); + break; - case T_Agg: - state = &(((Agg *) node)->aggstate->csstate); - break; + case T_Agg: + state = &(((Agg *) node)->aggstate->csstate); + break; - default: - elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!"); - return; + default: + elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!"); + return; } relation = state->css_currentRelation; @@ -249,12 +249,12 @@ ExecCloseR(Plan * node) */ if (nodeTag(node) == T_IndexScan) { - IndexScan *iscan = (IndexScan *) node; + IndexScan *iscan = (IndexScan *) node; IndexScanState *indexstate; - int numIndices; - RelationPtr indexRelationDescs; + int numIndices; + RelationPtr indexRelationDescs; IndexScanDescPtr indexScanDescs; - int i; + int i; indexstate = iscan->indxstate; numIndices = indexstate->iss_NumIndices; @@ -292,32 +292,32 @@ ExecReScan(Plan * node, ExprContext * exprCtxt, Plan * parent) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqReScan((SeqScan *) node, exprCtxt, parent); - return; - - case T_IndexScan: - ExecIndexReScan((IndexScan *) node, exprCtxt, parent); - return; - - case T_Material: - - /* - * the first call to ExecReScan should have no effect because - * everything is initialized properly already. the following - * calls will be handled by ExecSeqReScan() because the nodes - * below the Material node have already been materialized into a - * temp relation. - */ - return; + case T_SeqScan: + ExecSeqReScan((SeqScan *) node, exprCtxt, parent); + return; + + case T_IndexScan: + ExecIndexReScan((IndexScan *) node, exprCtxt, parent); + return; + + case T_Material: + + /* + * the first call to ExecReScan should have no effect because + * everything is initialized properly already. the following + * calls will be handled by ExecSeqReScan() because the nodes + * below the Material node have already been materialized into + * a temp relation. + */ + return; - case T_Tee: - ExecTeeReScan((Tee *) node, exprCtxt, parent); - break; + case T_Tee: + ExecTeeReScan((Tee *) node, exprCtxt, parent); + break; - default: - elog(WARN, "ExecReScan: not a seqscan or indexscan node."); - return; + default: + elog(WARN, "ExecReScan: not a seqscan or indexscan node."); + return; } } @@ -355,21 +355,21 @@ ExecMarkPos(Plan * node) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqMarkPos((SeqScan *) node); - break; + case T_SeqScan: + ExecSeqMarkPos((SeqScan *) node); + break; - case T_IndexScan: - ExecIndexMarkPos((IndexScan *) node); - break; + case T_IndexScan: + ExecIndexMarkPos((IndexScan *) node); + break; - case T_Sort: - ExecSortMarkPos((Sort *) node); - break; + case T_Sort: + ExecSortMarkPos((Sort *) node); + break; - default: - /* elog(DEBUG, "ExecMarkPos: unsupported node type"); */ - break; + default: + /* elog(DEBUG, "ExecMarkPos: unsupported node type"); */ + break; } return; } @@ -385,21 +385,21 @@ ExecRestrPos(Plan * node) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqRestrPos((SeqScan *) node); - return; + case T_SeqScan: + ExecSeqRestrPos((SeqScan *) node); + return; - case T_IndexScan: - ExecIndexRestrPos((IndexScan *) node); - return; + case T_IndexScan: + ExecIndexRestrPos((IndexScan *) node); + return; - case T_Sort: - ExecSortRestrPos((Sort *) node); - return; + case T_Sort: + ExecSortRestrPos((Sort *) node); + return; - default: - /* elog(DEBUG, "ExecRestrPos: node type not supported"); */ - return; + default: + /* elog(DEBUG, "ExecRestrPos: node type not supported"); */ + return; } } @@ -422,7 +422,7 @@ Relation ExecCreatR(TupleDesc tupType, Oid relationOid) { - Relation relDesc; + Relation relDesc; EU3_printf("ExecCreatR: %s type=%d oid=%d\n", "entering: ", tupType, relationOid); diff --git a/src/backend/executor/execFlatten.c b/src/backend/executor/execFlatten.c index 43d616712f..cc98dd6e20 100644 --- a/src/backend/executor/execFlatten.c +++ b/src/backend/executor/execFlatten.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.3 1997/09/07 04:41:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.4 1997/09/08 02:22:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ ExecEvalIter(Iter * iterNode, bool * resultIsNull, bool * iterIsDone) { - Node *expression; + Node *expression; expression = iterNode->iterexpr; @@ -66,13 +66,13 @@ ExecEvalFjoin(TargetEntry * tlist, { #ifdef SETS_FIXED - bool isDone; - int curNode; - List *tlistP; + bool isDone; + int curNode; + List *tlistP; - Fjoin *fjNode = tlist->fjoin; - DatumPtr resVect = fjNode->fj_results; - BoolPtr alwaysDone = fjNode->fj_alwaysDone; + Fjoin *fjNode = tlist->fjoin; + DatumPtr resVect = fjNode->fj_results; + BoolPtr alwaysDone = fjNode->fj_alwaysDone; if (fj_isDone) *fj_isDone = false; @@ -90,7 +90,7 @@ ExecEvalFjoin(TargetEntry * tlist, curNode = 1; foreach(tlistP, lnext(tlist)) { - TargetEntry *tle = lfirst(tlistP); + TargetEntry *tle = lfirst(tlistP); resVect[curNode] = ExecEvalIter((Iter *) tle->expr, econtext, @@ -181,19 +181,19 @@ ExecEvalFjoin(TargetEntry * tlist, } #ifdef SETS_FIXED -static bool +static bool FjoinBumpOuterNodes(TargetEntry * tlist, ExprContext * econtext, DatumPtr results, char *nulls) { - bool funcIsDone = true; - Fjoin *fjNode = tlist->fjoin; - char *alwaysDone = fjNode->fj_alwaysDone; - List *outerList = lnext(tlist); - List *trailers = lnext(tlist); - int trailNode = 1; - int curNode = 1; + bool funcIsDone = true; + Fjoin *fjNode = tlist->fjoin; + char *alwaysDone = fjNode->fj_alwaysDone; + List *outerList = lnext(tlist); + List *trailers = lnext(tlist); + int trailNode = 1; + int curNode = 1; /* * Run through list of functions until we get to one that isn't yet @@ -201,7 +201,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist, */ while ((funcIsDone == true) && (outerList != NIL)) { - TargetEntry *tle = lfirst(outerList); + TargetEntry *tle = lfirst(outerList); if (alwaysDone[curNode] == true) nulls[curNode] = 'n'; @@ -232,7 +232,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist, trailNode = 1; while (trailNode != curNode - 1) { - TargetEntry *tle = lfirst(trailers); + TargetEntry *tle = lfirst(trailers); if (alwaysDone[trailNode] != true) results[trailNode] = ExecEvalIter((Iter) tle->expr, diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index 3ad41bd393..1c9476fc35 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.6 1997/09/07 04:41:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.7 1997/09/08 02:22:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,24 +60,24 @@ * Initialize the Junk filter. *------------------------------------------------------------------------- */ -JunkFilter * +JunkFilter * ExecInitJunkFilter(List * targetList) { - JunkFilter *junkfilter; - List *cleanTargetList; - int len, - cleanLength; - TupleDesc tupType, - cleanTupType; - List *t; - TargetEntry *tle; - Resdom *resdom, - *cleanResdom; - int resjunk; - AttrNumber cleanResno; - AttrNumber *cleanMap; - Size size; - Node *expr; + JunkFilter *junkfilter; + List *cleanTargetList; + int len, + cleanLength; + TupleDesc tupType, + cleanTupType; + List *t; + TargetEntry *tle; + Resdom *resdom, + *cleanResdom; + int resjunk; + AttrNumber cleanResno; + AttrNumber *cleanMap; + Size size; + Node *expr; /* --------------------- * First find the "clean" target list, i.e. all the entries @@ -91,7 +91,7 @@ ExecInitJunkFilter(List * targetList) foreach(t, targetList) { - TargetEntry *rtarget = lfirst(t); + TargetEntry *rtarget = lfirst(t); if (rtarget->resdom != NULL) { @@ -120,11 +120,11 @@ ExecInitJunkFilter(List * targetList) else { #ifdef SETS_FIXED - List *fjListP; - Fjoin *cleanFjoin; - List *cleanFjList; - List *fjList = lfirst(t); - Fjoin *fjNode = (Fjoin *) tl_node(fjList); + List *fjListP; + Fjoin *cleanFjoin; + List *cleanFjList; + List *fjList = lfirst(t); + Fjoin *fjNode = (Fjoin *) tl_node(fjList); cleanFjoin = (Fjoin) copyObject((Node) fjNode); cleanFjList = lcons(cleanFjoin, NIL); @@ -139,7 +139,7 @@ ExecInitJunkFilter(List * targetList) foreach(fjListP, lnext(fjList)) { - TargetEntry *tle = lfirst(fjListP); + TargetEntry *tle = lfirst(fjListP); resdom = tle->resdom; expr = tle->expr; @@ -189,7 +189,7 @@ ExecInitJunkFilter(List * targetList) cleanResno = 1; foreach(t, targetList) { - TargetEntry *tle = lfirst(t); + TargetEntry *tle = lfirst(t); if (tle->resdom != NULL) { @@ -205,9 +205,9 @@ ExecInitJunkFilter(List * targetList) else { #ifdef SETS_FIXED - List fjListP; - List fjList = lfirst(t); - Fjoin fjNode = (Fjoin) lfirst(fjList); + List fjListP; + List fjList = lfirst(t); + Fjoin fjNode = (Fjoin) lfirst(fjList); /* what the hell is this????? */ resdom = (Resdom) lfirst(get_fj_innerNode(fjNode)); @@ -219,7 +219,7 @@ ExecInitJunkFilter(List * targetList) #ifdef SETS_FIXED foreach(fjListP, lnext(fjList)) { - TargetEntry *tle = lfirst(fjListP); + TargetEntry *tle = lfirst(fjListP); resdom = tle->resdom; cleanMap[cleanResno - 1] = resdom->resno; @@ -270,14 +270,14 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, Datum * value, bool * isNull) { - List *targetList; - List *t; - Resdom *resdom; - AttrNumber resno; - char *resname; - int resjunk; - TupleDesc tupType; - HeapTuple tuple; + List *targetList; + List *t; + Resdom *resdom; + AttrNumber resno; + char *resname; + int resjunk; + TupleDesc tupType; + HeapTuple tuple; /* --------------------- * first look in the junkfilter's target list for @@ -289,7 +289,7 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, foreach(t, targetList) { - TargetEntry *tle = lfirst(t); + TargetEntry *tle = lfirst(t); resdom = tle->resdom; resname = resdom->resname; @@ -330,19 +330,19 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, HeapTuple ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot) { - HeapTuple tuple; - HeapTuple cleanTuple; - AttrNumber *cleanMap; - TupleDesc cleanTupType; - TupleDesc tupType; - int cleanLength; - bool isNull; - int i; - Size size; - Datum *values; - char *nulls; - Datum values_array[64]; - char nulls_array[64]; + HeapTuple tuple; + HeapTuple cleanTuple; + AttrNumber *cleanMap; + TupleDesc cleanTupType; + TupleDesc tupType; + int cleanLength; + bool isNull; + int i; + Size size; + Datum *values; + char *nulls; + Datum values_array[64]; + char nulls_array[64]; /* ---------------- * get info from the slot and the junk filter @@ -391,7 +391,7 @@ ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot) */ for (i = 0; i < cleanLength; i++) { - Datum d = (Datum) + Datum d = (Datum) heap_getattr(tuple, InvalidBuffer, cleanMap[i], tupType, &isNull); values[i] = d; diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 2bf0edaf35..c7ff5aa910 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.23 1997/09/07 04:41:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.24 1997/09/08 02:22:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,14 +62,14 @@ ExecCheckPerms(CmdType operation, int resultRelation, List * rangeTable, static TupleDesc InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate); -static void EndPlan(Plan * plan, EState * estate); +static void EndPlan(Plan * plan, EState * estate); static TupleTableSlot * ExecutePlan(EState * estate, Plan * plan, Query * parseTree, CmdType operation, int numberTuples, ScanDirection direction, void (*printfunc) ()); -static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), - EState * estate); +static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), + EState * estate); static void ExecAppend(TupleTableSlot * slot, ItemPointer tupleid, EState * estate); @@ -83,7 +83,7 @@ ExecReplace(TupleTableSlot * slot, ItemPointer tupleid, /* end of local decls */ #ifdef QUERY_LIMIT -static int queryLimit = ALL_TUPLES; +static int queryLimit = ALL_TUPLES; #undef ALL_TUPLES #define ALL_TUPLES queryLimit @@ -112,7 +112,7 @@ ExecutorLimit(int limit) TupleDesc ExecutorStart(QueryDesc * queryDesc, EState * estate) { - TupleDesc result; + TupleDesc result; /* sanity checks */ Assert(queryDesc != NULL); @@ -157,12 +157,12 @@ ExecutorStart(QueryDesc * queryDesc, EState * estate) TupleTableSlot * ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) { - CmdType operation; - Query *parseTree; - Plan *plan; + CmdType operation; + Query *parseTree; + Plan *plan; TupleTableSlot *result; - CommandDest dest; - void (*destination) (); + CommandDest dest; + void (*destination) (); /* ---------------- * sanity checks @@ -200,7 +200,7 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) if ((nodeTag(plan) == T_IndexScan) && (((IndexScan *) plan)->indxstate->iss_RuntimeKeyInfo != NULL)) { - ExprContext *econtext; + ExprContext *econtext; econtext = ((IndexScan *) plan)->scan.scanstate->cstate.cs_ExprContext; ExecIndexReScan((IndexScan *) plan, econtext, plan); @@ -211,57 +211,57 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) switch (feature) { - case EXEC_RUN: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - ALL_TUPLES, - ForwardScanDirection, - destination); - break; - case EXEC_FOR: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - count, - ForwardScanDirection, - destination); - break; + case EXEC_RUN: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + ALL_TUPLES, + ForwardScanDirection, + destination); + break; + case EXEC_FOR: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + count, + ForwardScanDirection, + destination); + break; - /* ---------------- - * retrieve next n "backward" tuples - * ---------------- - */ - case EXEC_BACK: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - count, - BackwardScanDirection, - destination); - break; + /* ---------------- + * retrieve next n "backward" tuples + * ---------------- + */ + case EXEC_BACK: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + count, + BackwardScanDirection, + destination); + break; - /* ---------------- - * return one tuple but don't "retrieve" it. - * (this is used by the rule manager..) -cim 9/14/89 - * ---------------- - */ - case EXEC_RETONE: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - ONE_TUPLE, - ForwardScanDirection, - destination); - break; - default: - result = NULL; - elog(DEBUG, "ExecutorRun: Unknown feature %d", feature); - break; + /* ---------------- + * return one tuple but don't "retrieve" it. + * (this is used by the rule manager..) -cim 9/14/89 + * ---------------- + */ + case EXEC_RETONE: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + ONE_TUPLE, + ForwardScanDirection, + destination); + break; + default: + result = NULL; + elog(DEBUG, "ExecutorRun: Unknown feature %d", feature); + break; } return result; @@ -303,17 +303,17 @@ ExecCheckPerms(CmdType operation, List * rangeTable, Query * parseTree) { - int i = 1; - Oid relid; - HeapTuple htp; - List *lp; - List *qvars, - *tvars; - int32 ok = 1, - aclcheck_result = -1; - char *opstr; - NameData rname; - char *userName; + int i = 1; + Oid relid; + HeapTuple htp; + List *lp; + List *qvars, + *tvars; + int32 ok = 1, + aclcheck_result = -1; + char *opstr; + NameData rname; + char *userName; #define CHECK(MODE) pg_aclcheck(rname.data, userName, MODE) @@ -321,7 +321,7 @@ ExecCheckPerms(CmdType operation, foreach(lp, rangeTable) { - RangeTblEntry *rte = lfirst(lp); + RangeTblEntry *rte = lfirst(lp); relid = rte->relid; htp = SearchSysCacheTuple(RELOID, @@ -348,20 +348,21 @@ ExecCheckPerms(CmdType operation, } switch (operation) { - case CMD_INSERT: - ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) || - ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); - opstr = "append"; - break; - case CMD_NOTIFY: /* what does this mean?? -- jw, 1/6/94 */ - case CMD_DELETE: - case CMD_UPDATE: - ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); - opstr = "write"; - break; - default: - elog(WARN, "ExecCheckPerms: bogus operation %d", - operation); + case CMD_INSERT: + ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) || + ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); + opstr = "append"; + break; + case CMD_NOTIFY: /* what does this mean?? -- jw, + * 1/6/94 */ + case CMD_DELETE: + case CMD_UPDATE: + ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); + opstr = "write"; + break; + default: + elog(WARN, "ExecCheckPerms: bogus operation %d", + operation); } } else @@ -388,16 +389,16 @@ ExecCheckPerms(CmdType operation, * and start up the rule manager * ---------------------------------------------------------------- */ -static TupleDesc +static TupleDesc InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) { - List *rangeTable; - int resultRelation; - Relation intoRelationDesc; + List *rangeTable; + int resultRelation; + Relation intoRelationDesc; - TupleDesc tupType; - List *targetList; - int len; + TupleDesc tupType; + List *targetList; + int len; /* ---------------- * get information from query descriptor @@ -434,11 +435,11 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) * initialize the result relation info stuff. * ---------------- */ - RelationInfo *resultRelationInfo; - Index resultRelationIndex; - RangeTblEntry *rtentry; - Oid resultRelationOid; - Relation resultRelationDesc; + RelationInfo *resultRelationInfo; + Index resultRelationIndex; + RangeTblEntry *rtentry; + Oid resultRelationOid; + Relation resultRelationDesc; resultRelationIndex = resultRelation; rtentry = rt_fetch(resultRelationIndex, rangeTable); @@ -492,8 +493,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) * ---------------- */ { - int nSlots = ExecCountSlotsNode(plan); - TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */ + int nSlots = ExecCountSlotsNode(plan); + TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */ estate->es_tupleTable = tupleTable; } @@ -530,7 +531,7 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) operation == CMD_INSERT) { - JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList); + JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList); estate->es_junkFilter = j; } @@ -545,10 +546,10 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) if (operation == CMD_SELECT) { - char *intoName; - char archiveMode; - Oid intoRelationId; - TupleDesc tupdesc; + char *intoName; + char archiveMode; + Oid intoRelationId; + TupleDesc tupdesc; if (!parseTree->isPortal) { @@ -626,8 +627,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) static void EndPlan(Plan * plan, EState * estate) { - RelationInfo *resultRelationInfo; - Relation intoRelationDesc; + RelationInfo *resultRelationInfo; + Relation intoRelationDesc; /* ---------------- * get information from state @@ -647,7 +648,7 @@ EndPlan(Plan * plan, EState * estate) * ---------------- */ { - TupleTable tupleTable = (TupleTable) estate->es_tupleTable; + TupleTable tupleTable = (TupleTable) estate->es_tupleTable; ExecDestroyTupleTable(tupleTable, true); /* was missing last arg */ estate->es_tupleTable = NULL; @@ -659,7 +660,7 @@ EndPlan(Plan * plan, EState * estate) */ if (resultRelationInfo != NULL) { - Relation resultRelationDesc; + Relation resultRelationDesc; resultRelationDesc = resultRelationInfo->ri_RelationDesc; heap_close(resultRelationDesc); @@ -706,12 +707,12 @@ ExecutePlan(EState * estate, ScanDirection direction, void (*printfunc) ()) { - JunkFilter *junkfilter; + JunkFilter *junkfilter; TupleTableSlot *slot; - ItemPointer tupleid = NULL; + ItemPointer tupleid = NULL; ItemPointerData tuple_ctid; - int current_tuple_count; + int current_tuple_count; TupleTableSlot *result; /* ---------------- @@ -770,11 +771,11 @@ ExecutePlan(EState * estate, */ if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL) { - Datum datum; + Datum datum; /* NameData attrName; */ - HeapTuple newTuple; - bool isNull; + HeapTuple newTuple; + bool isNull; /* --------------- * extract the 'ctid' junk attribute. @@ -822,50 +823,50 @@ ExecutePlan(EState * estate, switch (operation) { - case CMD_SELECT: - ExecRetrieve(slot, /* slot containing tuple */ - printfunc, /* print function */ - estate); /* */ - result = slot; - break; + case CMD_SELECT: + ExecRetrieve(slot, /* slot containing tuple */ + printfunc, /* print function */ + estate); /* */ + result = slot; + break; - case CMD_INSERT: - ExecAppend(slot, tupleid, estate); - result = NULL; - break; + case CMD_INSERT: + ExecAppend(slot, tupleid, estate); + result = NULL; + break; - case CMD_DELETE: - ExecDelete(slot, tupleid, estate); - result = NULL; - break; + case CMD_DELETE: + ExecDelete(slot, tupleid, estate); + result = NULL; + break; - case CMD_UPDATE: - ExecReplace(slot, tupleid, estate, parseTree); - result = NULL; - break; + case CMD_UPDATE: + ExecReplace(slot, tupleid, estate, parseTree); + result = NULL; + break; - /* - * Total hack. I'm ignoring any accessor functions for - * Relation, RelationTupleForm, NameData. Assuming that - * NameData.data has offset 0. - */ - case CMD_NOTIFY: - { - RelationInfo *rInfo = estate->es_result_relation_info; - Relation rDesc = rInfo->ri_RelationDesc; + /* + * Total hack. I'm ignoring any accessor functions for + * Relation, RelationTupleForm, NameData. Assuming that + * NameData.data has offset 0. + */ + case CMD_NOTIFY: + { + RelationInfo *rInfo = estate->es_result_relation_info; + Relation rDesc = rInfo->ri_RelationDesc; + + Async_Notify(rDesc->rd_rel->relname.data); + result = NULL; + current_tuple_count = 0; + numberTuples = 1; + elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname); + } + break; - Async_Notify(rDesc->rd_rel->relname.data); + default: + elog(DEBUG, "ExecutePlan: unknown operation in queryDesc"); result = NULL; - current_tuple_count = 0; - numberTuples = 1; - elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname); - } - break; - - default: - elog(DEBUG, "ExecutePlan: unknown operation in queryDesc"); - result = NULL; - break; + break; } /* ---------------- * check our tuple count.. if we've returned the @@ -901,8 +902,8 @@ ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), EState * estate) { - HeapTuple tuple; - TupleDesc attrtype; + HeapTuple tuple; + TupleDesc attrtype; /* ---------------- * get the heap tuple out of the tuple table slot @@ -944,11 +945,11 @@ ExecAppend(TupleTableSlot * slot, ItemPointer tupleid, EState * estate) { - HeapTuple tuple; - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - int numIndices; - Oid newId; + HeapTuple tuple; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + int numIndices; + Oid newId; /* ---------------- * get the heap tuple out of the tuple table slot @@ -973,7 +974,7 @@ ExecAppend(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRInsertTriggers(resultRelationDesc, tuple); @@ -995,7 +996,7 @@ ExecAppend(TupleTableSlot * slot, if (resultRelationDesc->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("ExecAppend", resultRelationDesc, tuple); @@ -1049,8 +1050,8 @@ ExecDelete(TupleTableSlot * slot, ItemPointer tupleid, EState * estate) { - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; /* ---------------- * get the result relation information @@ -1063,7 +1064,7 @@ ExecDelete(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) { - bool dodelete; + bool dodelete; dodelete = ExecBRDeleteTriggers(resultRelationDesc, tupleid); @@ -1118,10 +1119,10 @@ ExecReplace(TupleTableSlot * slot, EState * estate, Query * parseTree) { - HeapTuple tuple; - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - int numIndices; + HeapTuple tuple; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + int numIndices; /* ---------------- * abort the operation if not running transactions @@ -1158,7 +1159,7 @@ ExecReplace(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRUpdateTriggers(resultRelationDesc, tupleid, tuple); @@ -1180,7 +1181,7 @@ ExecReplace(TupleTableSlot * slot, if (resultRelationDesc->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("ExecReplace", resultRelationDesc, tuple); @@ -1244,21 +1245,21 @@ ExecReplace(TupleTableSlot * slot, ExecARUpdateTriggers(resultRelationDesc, tupleid, tuple); } -static HeapTuple +static HeapTuple ExecAttrDefault(Relation rel, HeapTuple tuple) { - int ndef = rel->rd_att->constr->num_defval; - AttrDefault *attrdef = rel->rd_att->constr->defval; - ExprContext *econtext = makeNode(ExprContext); - HeapTuple newtuple; - Node *expr; - bool isnull; - bool isdone; - Datum val; - Datum *replValue = NULL; - char *replNull = NULL; - char *repl = NULL; - int i; + int ndef = rel->rd_att->constr->num_defval; + AttrDefault *attrdef = rel->rd_att->constr->defval; + ExprContext *econtext = makeNode(ExprContext); + HeapTuple newtuple; + Node *expr; + bool isnull; + bool isdone; + Datum val; + Datum *replValue = NULL; + char *replNull = NULL; + char *repl = NULL; + int i; econtext->ecxt_scantuple = NULL; /* scan tuple slot */ econtext->ecxt_innertuple = NULL; /* inner tuple slot */ @@ -1309,18 +1310,18 @@ ExecAttrDefault(Relation rel, HeapTuple tuple) } -static char * +static char * ExecRelCheck(Relation rel, HeapTuple tuple) { - int ncheck = rel->rd_att->constr->num_check; - ConstrCheck *check = rel->rd_att->constr->check; - ExprContext *econtext = makeNode(ExprContext); + int ncheck = rel->rd_att->constr->num_check; + ConstrCheck *check = rel->rd_att->constr->check; + ExprContext *econtext = makeNode(ExprContext); TupleTableSlot *slot = makeNode(TupleTableSlot); - RangeTblEntry *rte = makeNode(RangeTblEntry); - List *rtlist; - List *qual; - bool res; - int i; + RangeTblEntry *rte = makeNode(RangeTblEntry); + List *rtlist; + List *qual; + bool res; + int i; slot->val = tuple; slot->ttc_shouldFree = false; @@ -1370,7 +1371,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple) HeapTuple ExecConstraints(char *caller, Relation rel, HeapTuple tuple) { - HeapTuple newtuple = tuple; + HeapTuple newtuple = tuple; Assert(rel->rd_att->constr); @@ -1379,7 +1380,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple) if (rel->rd_att->constr->has_not_null) { - int attrChk; + int attrChk; for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++) { @@ -1391,7 +1392,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple) if (rel->rd_att->constr->num_check > 0) { - char *failed; + char *failed; if ((failed = ExecRelCheck(rel, tuple)) != NULL) elog(WARN, "%s: rejected due to CHECK constraint %s", caller, failed); diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index 89caefd162..7e8cce52c7 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.3 1997/09/07 04:41:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.4 1997/09/08 02:22:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -105,7 +105,7 @@ bool ExecInitNode(Plan * node, EState * estate, Plan * parent) { - bool result; + bool result; /* ---------------- * do nothing when we get to the end @@ -117,82 +117,82 @@ ExecInitNode(Plan * node, EState * estate, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - result = ExecInitResult((Result *) node, estate, parent); - break; - - case T_Append: - result = ExecInitAppend((Append *) node, estate, parent); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - result = ExecInitSeqScan((SeqScan *) node, estate, parent); - break; - - case T_IndexScan: - result = ExecInitIndexScan((IndexScan *) node, estate, parent); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - result = ExecInitNestLoop((NestLoop *) node, estate, parent); - break; - - case T_MergeJoin: - result = ExecInitMergeJoin((MergeJoin *) node, estate, parent); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - result = ExecInitMaterial((Material *) node, estate, parent); - break; - - case T_Sort: - result = ExecInitSort((Sort *) node, estate, parent); - break; - - case T_Unique: - result = ExecInitUnique((Unique *) node, estate, parent); - break; - - case T_Group: - result = ExecInitGroup((Group *) node, estate, parent); - break; - - case T_Agg: - result = ExecInitAgg((Agg *) node, estate, parent); - break; - - case T_Hash: - result = ExecInitHash((Hash *) node, estate, parent); - break; - - case T_HashJoin: - result = ExecInitHashJoin((HashJoin *) node, estate, parent); - break; - - case T_Tee: - result = ExecInitTee((Tee *) node, estate, parent); - break; - - default: - elog(DEBUG, "ExecInitNode: node not yet supported: %d", - nodeTag(node)); - result = FALSE; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + result = ExecInitResult((Result *) node, estate, parent); + break; + + case T_Append: + result = ExecInitAppend((Append *) node, estate, parent); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + result = ExecInitSeqScan((SeqScan *) node, estate, parent); + break; + + case T_IndexScan: + result = ExecInitIndexScan((IndexScan *) node, estate, parent); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + result = ExecInitNestLoop((NestLoop *) node, estate, parent); + break; + + case T_MergeJoin: + result = ExecInitMergeJoin((MergeJoin *) node, estate, parent); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + result = ExecInitMaterial((Material *) node, estate, parent); + break; + + case T_Sort: + result = ExecInitSort((Sort *) node, estate, parent); + break; + + case T_Unique: + result = ExecInitUnique((Unique *) node, estate, parent); + break; + + case T_Group: + result = ExecInitGroup((Group *) node, estate, parent); + break; + + case T_Agg: + result = ExecInitAgg((Agg *) node, estate, parent); + break; + + case T_Hash: + result = ExecInitHash((Hash *) node, estate, parent); + break; + + case T_HashJoin: + result = ExecInitHashJoin((HashJoin *) node, estate, parent); + break; + + case T_Tee: + result = ExecInitTee((Tee *) node, estate, parent); + break; + + default: + elog(DEBUG, "ExecInitNode: node not yet supported: %d", + nodeTag(node)); + result = FALSE; } return result; @@ -220,82 +220,82 @@ ExecProcNode(Plan * node, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - result = ExecResult((Result *) node); - break; - - case T_Append: - result = ExecProcAppend((Append *) node); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - result = ExecSeqScan((SeqScan *) node); - break; - - case T_IndexScan: - result = ExecIndexScan((IndexScan *) node); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - result = ExecNestLoop((NestLoop *) node, parent); - break; - - case T_MergeJoin: - result = ExecMergeJoin((MergeJoin *) node); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - result = ExecMaterial((Material *) node); - break; - - case T_Sort: - result = ExecSort((Sort *) node); - break; - - case T_Unique: - result = ExecUnique((Unique *) node); - break; - - case T_Group: - result = ExecGroup((Group *) node); - break; - - case T_Agg: - result = ExecAgg((Agg *) node); - break; - - case T_Hash: - result = ExecHash((Hash *) node); - break; - - case T_HashJoin: - result = ExecHashJoin((HashJoin *) node); - break; - - case T_Tee: - result = ExecTee((Tee *) node, parent); - break; - - default: - elog(DEBUG, "ExecProcNode: node not yet supported: %d", - nodeTag(node)); - result = FALSE; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + result = ExecResult((Result *) node); + break; + + case T_Append: + result = ExecProcAppend((Append *) node); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + result = ExecSeqScan((SeqScan *) node); + break; + + case T_IndexScan: + result = ExecIndexScan((IndexScan *) node); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + result = ExecNestLoop((NestLoop *) node, parent); + break; + + case T_MergeJoin: + result = ExecMergeJoin((MergeJoin *) node); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + result = ExecMaterial((Material *) node); + break; + + case T_Sort: + result = ExecSort((Sort *) node); + break; + + case T_Unique: + result = ExecUnique((Unique *) node); + break; + + case T_Group: + result = ExecGroup((Group *) node); + break; + + case T_Agg: + result = ExecAgg((Agg *) node); + break; + + case T_Hash: + result = ExecHash((Hash *) node); + break; + + case T_HashJoin: + result = ExecHashJoin((HashJoin *) node); + break; + + case T_Tee: + result = ExecTee((Tee *) node, parent); + break; + + default: + elog(DEBUG, "ExecProcNode: node not yet supported: %d", + nodeTag(node)); + result = FALSE; } return result; @@ -309,68 +309,68 @@ ExecCountSlotsNode(Plan * node) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - return ExecCountSlotsResult((Result *) node); - - case T_Append: - return ExecCountSlotsAppend((Append *) node); - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - return ExecCountSlotsSeqScan((SeqScan *) node); - - case T_IndexScan: - return ExecCountSlotsIndexScan((IndexScan *) node); - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - return ExecCountSlotsNestLoop((NestLoop *) node); - - case T_MergeJoin: - return ExecCountSlotsMergeJoin((MergeJoin *) node); - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - return ExecCountSlotsMaterial((Material *) node); - - case T_Sort: - return ExecCountSlotsSort((Sort *) node); - - case T_Unique: - return ExecCountSlotsUnique((Unique *) node); - - case T_Group: - return ExecCountSlotsGroup((Group *) node); - - case T_Agg: - return ExecCountSlotsAgg((Agg *) node); - - case T_Hash: - return ExecCountSlotsHash((Hash *) node); - - case T_HashJoin: - return ExecCountSlotsHashJoin((HashJoin *) node); - - case T_Tee: - return ExecCountSlotsTee((Tee *) node); - - default: - elog(WARN, "ExecCountSlotsNode: node not yet supported: %d", - nodeTag(node)); - break; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + return ExecCountSlotsResult((Result *) node); + + case T_Append: + return ExecCountSlotsAppend((Append *) node); + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + return ExecCountSlotsSeqScan((SeqScan *) node); + + case T_IndexScan: + return ExecCountSlotsIndexScan((IndexScan *) node); + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + return ExecCountSlotsNestLoop((NestLoop *) node); + + case T_MergeJoin: + return ExecCountSlotsMergeJoin((MergeJoin *) node); + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + return ExecCountSlotsMaterial((Material *) node); + + case T_Sort: + return ExecCountSlotsSort((Sort *) node); + + case T_Unique: + return ExecCountSlotsUnique((Unique *) node); + + case T_Group: + return ExecCountSlotsGroup((Group *) node); + + case T_Agg: + return ExecCountSlotsAgg((Agg *) node); + + case T_Hash: + return ExecCountSlotsHash((Hash *) node); + + case T_HashJoin: + return ExecCountSlotsHashJoin((HashJoin *) node); + + case T_Tee: + return ExecCountSlotsTee((Tee *) node); + + default: + elog(WARN, "ExecCountSlotsNode: node not yet supported: %d", + nodeTag(node)); + break; } return 0; } @@ -399,85 +399,85 @@ ExecEndNode(Plan * node, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - ExecEndResult((Result *) node); - break; - - case T_Append: - ExecEndAppend((Append *) node); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - ExecEndSeqScan((SeqScan *) node); - break; - - case T_IndexScan: - ExecEndIndexScan((IndexScan *) node); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - ExecEndNestLoop((NestLoop *) node); - break; - - case T_MergeJoin: - ExecEndMergeJoin((MergeJoin *) node); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - ExecEndMaterial((Material *) node); - break; - - case T_Sort: - ExecEndSort((Sort *) node); - break; - - case T_Unique: - ExecEndUnique((Unique *) node); - break; - - case T_Group: - ExecEndGroup((Group *) node); - break; - - case T_Agg: - ExecEndAgg((Agg *) node); - break; - - /* ---------------- - * XXX add hooks to these - * ---------------- - */ - case T_Hash: - ExecEndHash((Hash *) node); - break; - - case T_HashJoin: - ExecEndHashJoin((HashJoin *) node); - break; - - case T_Tee: - ExecEndTee((Tee *) node, parent); - break; - - default: - elog(DEBUG, "ExecEndNode: node not yet supported", - nodeTag(node)); - break; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + ExecEndResult((Result *) node); + break; + + case T_Append: + ExecEndAppend((Append *) node); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + ExecEndSeqScan((SeqScan *) node); + break; + + case T_IndexScan: + ExecEndIndexScan((IndexScan *) node); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + ExecEndNestLoop((NestLoop *) node); + break; + + case T_MergeJoin: + ExecEndMergeJoin((MergeJoin *) node); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + ExecEndMaterial((Material *) node); + break; + + case T_Sort: + ExecEndSort((Sort *) node); + break; + + case T_Unique: + ExecEndUnique((Unique *) node); + break; + + case T_Group: + ExecEndGroup((Group *) node); + break; + + case T_Agg: + ExecEndAgg((Agg *) node); + break; + + /* ---------------- + * XXX add hooks to these + * ---------------- + */ + case T_Hash: + ExecEndHash((Hash *) node); + break; + + case T_HashJoin: + ExecEndHashJoin((HashJoin *) node); + break; + + case T_Tee: + ExecEndTee((Tee *) node, parent); + break; + + default: + elog(DEBUG, "ExecEndNode: node not yet supported", + nodeTag(node)); + break; } } diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 7b8cb18ef2..a1e0140265 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.13 1997/09/07 04:41:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.14 1997/09/08 02:22:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,31 +65,31 @@ * Currently only used by ExecHashGetBucket and set only by ExecMakeVarConst * and by ExecEvalArrayRef. */ -bool execConstByVal; -int execConstLen; +bool execConstByVal; +int execConstLen; /* static functions decls */ -static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull); +static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull); static Datum ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext, bool * isNull, bool * isDone); -static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull); +static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull); static Datum ExecEvalFunc(Expr * funcClause, ExprContext * econtext, bool * isNull, bool * isDone); static void ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext * econtext, List * argList, Datum argV[], bool * argIsDone); -static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull); +static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull); static Datum ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull); -static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull); -static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull); +static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull); +static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull); static Datum ExecMakeFunctionResult(Node * node, List * arguments, ExprContext * econtext, bool * isNull, bool * isDone); -static bool ExecQualClause(Node * clause, ExprContext * econtext); +static bool ExecQualClause(Node * clause, ExprContext * econtext); /* -------------------------------- * ExecEvalArrayRef @@ -100,24 +100,24 @@ static bool ExecQualClause(Node * clause, ExprContext * econtext); * * -------------------------------- */ -static Datum +static Datum ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext, bool * isNull, bool * isDone) { - bool dummy; - int i = 0, - j = 0; - ArrayType *array_scanner; - List *upperIndexpr, - *lowerIndexpr; - Node *assgnexpr; - List *elt; - IntArray upper, - lower; - int *lIndex; - char *dataPtr; + bool dummy; + int i = 0, + j = 0; + ArrayType *array_scanner; + List *upperIndexpr, + *lowerIndexpr; + Node *assgnexpr; + List *elt; + IntArray upper, + lower; + int *lIndex; + char *dataPtr; *isNull = false; array_scanner = (ArrayType *) ExecEvalExpr(arrayRef->refexpr, @@ -199,7 +199,7 @@ ExecEvalArrayRef(ArrayRef * arrayRef, * aggregate found in the given expression context. * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull) { @@ -230,17 +230,17 @@ ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull) * We have an Assert to make sure this entry condition is met. * * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) { - Datum result; + Datum result; TupleTableSlot *slot; - AttrNumber attnum; - HeapTuple heapTuple; - TupleDesc tuple_type; - Buffer buffer; - bool byval; - int16 len; + AttrNumber attnum; + HeapTuple heapTuple; + TupleDesc tuple_type; + Buffer buffer; + bool byval; + int16 len; /* ---------------- * get the slot we want @@ -248,18 +248,18 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) */ switch (variable->varno) { - case INNER: /* get the tuple from the inner node */ - slot = econtext->ecxt_innertuple; - break; + case INNER: /* get the tuple from the inner node */ + slot = econtext->ecxt_innertuple; + break; - case OUTER: /* get the tuple from the outer node */ - slot = econtext->ecxt_outertuple; - break; + case OUTER: /* get the tuple from the outer node */ + slot = econtext->ecxt_outertuple; + break; - default: /* get the tuple from the relation being + default: /* get the tuple from the relation being * scanned */ - slot = econtext->ecxt_scantuple; - break; + slot = econtext->ecxt_scantuple; + break; } /* ---------------- @@ -286,8 +286,8 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) if (attnum == InvalidAttrNumber) { TupleTableSlot *tempSlot; - TupleDesc td; - HeapTuple tup; + TupleDesc td; + HeapTuple tup; tempSlot = makeNode(TupleTableSlot); tempSlot->ttc_shouldFree = false; @@ -380,11 +380,11 @@ Datum ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) { - char *thisParameterName; - int thisParameterKind; - AttrNumber thisParameterId; - int matchFound; - ParamListInfo paramList; + char *thisParameterName; + int thisParameterKind; + AttrNumber thisParameterId; + int matchFound; + ParamListInfo paramList; thisParameterName = expression->paramname; thisParameterKind = expression->paramkind; @@ -409,44 +409,44 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) { switch (thisParameterKind) { - case PARAM_NAMED: - if (thisParameterKind == paramList->kind && - strcmp(paramList->name, thisParameterName) == 0) - { - matchFound = 1; - } - break; - case PARAM_NUM: - if (thisParameterKind == paramList->kind && - paramList->id == thisParameterId) - { - matchFound = 1; - } - break; - case PARAM_OLD: - case PARAM_NEW: - if (thisParameterKind == paramList->kind && - paramList->id == thisParameterId) - { - matchFound = 1; - - /* - * sanity check - */ - if (strcmp(paramList->name, thisParameterName) != 0) + case PARAM_NAMED: + if (thisParameterKind == paramList->kind && + strcmp(paramList->name, thisParameterName) == 0) { - elog(WARN, - "ExecEvalParam: new/old params with same id & diff names"); + matchFound = 1; } - } - break; - default: + break; + case PARAM_NUM: + if (thisParameterKind == paramList->kind && + paramList->id == thisParameterId) + { + matchFound = 1; + } + break; + case PARAM_OLD: + case PARAM_NEW: + if (thisParameterKind == paramList->kind && + paramList->id == thisParameterId) + { + matchFound = 1; + + /* + * sanity check + */ + if (strcmp(paramList->name, thisParameterName) != 0) + { + elog(WARN, + "ExecEvalParam: new/old params with same id & diff names"); + } + } + break; + default: - /* - * oops! this is not supposed to happen! - */ - elog(WARN, "ExecEvalParam: invalid paramkind %d", - thisParameterKind); + /* + * oops! this is not supposed to happen! + */ + elog(WARN, "ExecEvalParam: invalid paramkind %d", + thisParameterKind); } if (!matchFound) { @@ -477,10 +477,10 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) if (expression->param_tlist != NIL) { - HeapTuple tup; - Datum value; - List *tlist = expression->param_tlist; - TargetEntry *tle = (TargetEntry *) lfirst(tlist); + HeapTuple tup; + Datum value; + List *tlist = expression->param_tlist; + TargetEntry *tle = (TargetEntry *) lfirst(tlist); TupleTableSlot *slot = (TupleTableSlot *) paramList->value; tup = slot->val; @@ -508,12 +508,12 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) * ---------------- */ #ifdef NOT_USED -static char * +static char * GetAttributeByNum(TupleTableSlot * slot, AttrNumber attrno, bool * isNull) { - Datum retval; + Datum retval; if (!AttributeNumberIsValid(attrno)) elog(WARN, "GetAttributeByNum: Invalid attribute number"); @@ -545,7 +545,7 @@ GetAttributeByNum(TupleTableSlot * slot, /* XXX char16 name for catalogs */ #ifdef NOT_USED -char * +char * att_by_num(TupleTableSlot * slot, AttrNumber attrno, bool * isNull) @@ -555,15 +555,15 @@ att_by_num(TupleTableSlot * slot, #endif -char * +char * GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull) { - AttrNumber attrno; - TupleDesc tupdesc; - HeapTuple tuple; - Datum retval; - int natts; - int i; + AttrNumber attrno; + TupleDesc tupdesc; + HeapTuple tuple; + Datum retval; + int natts; + int i; if (attname == NULL) elog(WARN, "GetAttributeByName: Invalid attribute name"); @@ -608,7 +608,7 @@ GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull) /* XXX char16 name for catalogs */ #ifdef NOT_USED -char * +char * att_by_name(TupleTableSlot * slot, char *attname, bool * isNull) { return (GetAttributeByName(slot, attname, isNull)); @@ -623,10 +623,10 @@ ExecEvalFuncArgs(FunctionCachePtr fcache, Datum argV[], bool * argIsDone) { - int i; - bool argIsNull, - *nullVect; - List *arg; + int i; + bool argIsNull, + *nullVect; + List *arg; nullVect = fcache->nullVect; @@ -663,18 +663,18 @@ ExecEvalFuncArgs(FunctionCachePtr fcache, * ExecMakeFunctionResult * ---------------- */ -static Datum +static Datum ExecMakeFunctionResult(Node * node, List * arguments, ExprContext * econtext, bool * isNull, bool * isDone) { - Datum argv[MAXFMGRARGS]; + Datum argv[MAXFMGRARGS]; FunctionCachePtr fcache; - Func *funcNode = NULL; - Oper *operNode = NULL; - bool funcisset = false; + Func *funcNode = NULL; + Oper *operNode = NULL; + bool funcisset = false; /* * This is kind of ugly, Func nodes now have targetlists so that we @@ -703,7 +703,7 @@ ExecMakeFunctionResult(Node * node, */ if (fcache->nargs != 0) { - bool argDone; + bool argDone; if (fcache->nargs > MAXFMGRARGS) elog(WARN, "ExecMakeFunctionResult: too many arguments"); @@ -774,7 +774,7 @@ ExecMakeFunctionResult(Node * node, */ if (fcache->language == SQLlanguageId) { - Datum result; + Datum result; Assert(funcNode); result = postquel_function(funcNode, (char **) argv, isNull, isDone); @@ -788,7 +788,7 @@ ExecMakeFunctionResult(Node * node, */ if ((*isDone) && (fcache->hasSetArg)) { - bool argDone; + bool argDone; ExecEvalFuncArgs(fcache, econtext, arguments, argv, &argDone); @@ -828,7 +828,7 @@ ExecMakeFunctionResult(Node * node, } else { - int i; + int i; if (isDone) *isDone = true; @@ -863,13 +863,13 @@ ExecMakeFunctionResult(Node * node, * ExecEvalOper * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull) { - Oper *op; - List *argList; + Oper *op; + List *argList; FunctionCachePtr fcache; - bool isDone; + bool isDone; /* ---------------- * an opclause is a list (op args). (I think) @@ -908,14 +908,14 @@ ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull) * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalFunc(Expr * funcClause, ExprContext * econtext, bool * isNull, bool * isDone) { - Func *func; - List *argList; + Func *func; + List *argList; FunctionCachePtr fcache; /* ---------------- @@ -963,12 +963,12 @@ ExecEvalFunc(Expr * funcClause, * need to know this, mind you... * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull) { - Datum expr_value; - Node *clause; - bool isDone; + Datum expr_value; + Node *clause; + bool isDone; clause = lfirst(notclause->args); @@ -1002,14 +1002,14 @@ ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull) * ExecEvalOr * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull) { - List *clauses; - List *clause; - bool isDone; - bool IsNull; - Datum const_value = 0; + List *clauses; + List *clause; + bool isDone; + bool IsNull; + Datum const_value = 0; IsNull = false; clauses = orExpr->args; @@ -1066,14 +1066,14 @@ ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull) * ExecEvalAnd * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull) { - List *clauses; - List *clause; - Datum const_value = 0; - bool isDone; - bool IsNull; + List *clauses; + List *clause; + Datum const_value = 0; + bool isDone; + bool IsNull; IsNull = false; @@ -1149,7 +1149,7 @@ ExecEvalExpr(Node * expression, bool * isNull, bool * isDone) { - Datum retDatum = 0; + Datum retDatum = 0; *isNull = false; @@ -1173,68 +1173,68 @@ ExecEvalExpr(Node * expression, switch (nodeTag(expression)) { - case T_Var: - retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull); - break; - case T_Const: - { - Const *con = (Const *) expression; + case T_Var: + retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull); + break; + case T_Const: + { + Const *con = (Const *) expression; - if (con->constisnull) - *isNull = true; - retDatum = con->constvalue; + if (con->constisnull) + *isNull = true; + retDatum = con->constvalue; + break; + } + case T_Param: + retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull); break; - } - case T_Param: - retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull); - break; - case T_Iter: - retDatum = (Datum) ExecEvalIter((Iter *) expression, - econtext, - isNull, - isDone); - break; - case T_Aggreg: - retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression, - econtext, - isNull); - break; - case T_ArrayRef: - retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression, + case T_Iter: + retDatum = (Datum) ExecEvalIter((Iter *) expression, econtext, isNull, isDone); - break; - case T_Expr: - { - Expr *expr = (Expr *) expression; - - switch (expr->opType) + break; + case T_Aggreg: + retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression, + econtext, + isNull); + break; + case T_ArrayRef: + retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression, + econtext, + isNull, + isDone); + break; + case T_Expr: { - case OP_EXPR: - retDatum = (Datum) ExecEvalOper(expr, econtext, isNull); - break; - case FUNC_EXPR: - retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone); - break; - case OR_EXPR: - retDatum = (Datum) ExecEvalOr(expr, econtext, isNull); - break; - case AND_EXPR: - retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull); - break; - case NOT_EXPR: - retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); - break; - default: - elog(WARN, "ExecEvalExpr: unknown expression type"); + Expr *expr = (Expr *) expression; + + switch (expr->opType) + { + case OP_EXPR: + retDatum = (Datum) ExecEvalOper(expr, econtext, isNull); + break; + case FUNC_EXPR: + retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone); + break; + case OR_EXPR: + retDatum = (Datum) ExecEvalOr(expr, econtext, isNull); + break; + case AND_EXPR: + retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull); + break; + case NOT_EXPR: + retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); + break; + default: + elog(WARN, "ExecEvalExpr: unknown expression type"); + break; + } break; } + default: + elog(WARN, "ExecEvalExpr: unknown expression type"); break; - } - default: - elog(WARN, "ExecEvalExpr: unknown expression type"); - break; } return retDatum; @@ -1256,12 +1256,12 @@ ExecEvalExpr(Node * expression, * rest of the qualification) * ---------------------------------------------------------------- */ -static bool +static bool ExecQualClause(Node * clause, ExprContext * econtext) { - Datum expr_value; - bool isNull; - bool isDone; + Datum expr_value; + bool isNull; + bool isDone; /* when there is a null clause, consider the qualification to be true */ if (clause == NULL) @@ -1304,8 +1304,8 @@ ExecQualClause(Node * clause, ExprContext * econtext) bool ExecQual(List * qual, ExprContext * econtext) { - List *clause; - bool result; + List *clause; + bool result; /* ---------------- * debugging stuff @@ -1356,9 +1356,9 @@ ExecQual(List * qual, ExprContext * econtext) int ExecTargetListLength(List * targetlist) { - int len; - List *tl; - TargetEntry *curTle; + int len; + List *tl; + TargetEntry *curTle; len = 0; foreach(tl, targetlist) @@ -1380,7 +1380,7 @@ ExecTargetListLength(List * targetlist) * expression context and return a tuple. * ---------------------------------------------------------------- */ -static HeapTuple +static HeapTuple ExecTargetList(List * targetlist, int nodomains, TupleDesc targettype, @@ -1388,18 +1388,18 @@ ExecTargetList(List * targetlist, ExprContext * econtext, bool * isDone) { - char nulls_array[64]; - bool fjNullArray[64]; - bool *fjIsNull; - char *null_head; - List *tl; - TargetEntry *tle; - Node *expr; - Resdom *resdom; - AttrNumber resind; - Datum constvalue; - HeapTuple newTuple; - bool isNull; + char nulls_array[64]; + bool fjNullArray[64]; + bool *fjIsNull; + char *null_head; + List *tl; + TargetEntry *tle; + Node *expr; + Resdom *resdom; + AttrNumber resind; + Datum constvalue; + HeapTuple newTuple; + bool isNull; /* ---------------- * debugging stuff @@ -1497,12 +1497,12 @@ ExecTargetList(List * targetlist, } else { - int curNode; - Resdom *fjRes; - List *fjTlist = (List *) tle->expr; - Fjoin *fjNode = tle->fjoin; - int nNodes = fjNode->fj_nNodes; - DatumPtr results = fjNode->fj_results; + int curNode; + Resdom *fjRes; + List *fjTlist = (List *) tle->expr; + Fjoin *fjNode = tle->fjoin; + int nNodes = fjNode->fj_nNodes; + DatumPtr results = fjNode->fj_results; ExecEvalFjoin(tle, econtext, fjIsNull, isDone); if (*isDone) @@ -1529,7 +1529,7 @@ ExecTargetList(List * targetlist, curNode++, fjTlist = lnext(fjTlist)) { #if 0 /* what is this?? */ - Node *outernode = lfirst(fjTlist); + Node *outernode = lfirst(fjTlist); fjRes = (Resdom *) outernode->iterexpr; #endif @@ -1582,12 +1582,12 @@ TupleTableSlot * ExecProject(ProjectionInfo * projInfo, bool * isDone) { TupleTableSlot *slot; - List *targetlist; - int len; - TupleDesc tupType; - Datum *tupValue; - ExprContext *econtext; - HeapTuple newTuple; + List *targetlist; + int len; + TupleDesc tupType; + Datum *tupValue; + ExprContext *econtext; + HeapTuple newTuple; /* ---------------- * sanity checks diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 6ea50bb2a9..84dac56a23 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.4 1997/09/07 04:41:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.5 1997/09/08 02:22:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,15 +48,15 @@ ExecScan(Scan * node, * tuple */ { CommonScanState *scanstate; - EState *estate; - List *qual; - bool isDone; + EState *estate; + List *qual; + bool isDone; TupleTableSlot *slot; TupleTableSlot *resultSlot; - HeapTuple newTuple; + HeapTuple newTuple; - ExprContext *econtext; + ExprContext *econtext; ProjectionInfo *projInfo; diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index 287f75699a..373e94ae1a 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.7 1997/09/07 04:41:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.8 1997/09/08 02:22:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,7 @@ TupleTable /* return: address of table */ ExecCreateTupleTable(int initialSize) /* initial number of slots * in table */ { - TupleTable newtable; /* newly allocated table */ + TupleTable newtable; /* newly allocated table */ TupleTableSlot *array; /* newly allocated slot array */ /* ---------------- @@ -200,9 +200,9 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */ bool shouldFree) /* true if we should free slot * contents */ { - int next; /* next avaliable slot */ + int next; /* next avaliable slot */ TupleTableSlot *array; /* start of table array */ - int i; /* counter */ + int i; /* counter */ /* ---------------- * sanity checks @@ -229,8 +229,8 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */ if (shouldFree) for (i = 0; i < next; i++) { - TupleTableSlot slot; - HeapTuple tuple; + TupleTableSlot slot; + HeapTuple tuple; slot = array[i]; tuple = slot.val; @@ -280,7 +280,7 @@ TupleTableSlot * /* return: the slot allocated in the tuple * table */ ExecAllocTableSlot(TupleTable table) { - int slotnum; /* new slot number */ + int slotnum; /* new slot number */ /* ---------------- * sanity checks @@ -383,7 +383,7 @@ ExecStoreTuple(HeapTuple tuple, /* tuple to store */ TupleTableSlot * /* return: slot passed */ ExecClearTuple(TupleTableSlot * slot) /* slot in which to store tuple */ { - HeapTuple oldtuple; /* prior contents of slot */ + HeapTuple oldtuple; /* prior contents of slot */ /* ---------------- * sanity checks @@ -462,7 +462,7 @@ ExecSetSlotPolicy(TupleTableSlot * slot, /* slot to change */ bool shouldFree) /* true if we call pfree() when we * gc. */ { - bool old_shouldFree = slot->ttc_shouldFree; + bool old_shouldFree = slot->ttc_shouldFree; slot->ttc_shouldFree = shouldFree; @@ -490,7 +490,7 @@ TupleDesc /* return: old slot tuple descriptor */ ExecSetSlotDescriptor(TupleTableSlot * slot, /* slot to change */ TupleDesc tupdesc) /* tuple descriptor */ { - TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; + TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; slot->ttc_tupleDescriptor = tupdesc; return old_tupdesc; @@ -521,7 +521,7 @@ TupleDesc /* return: old slot tuple descriptor */ ExecSetNewSlotDescriptor(TupleTableSlot * slot, /* slot to change */ TupleDesc tupdesc) /* tuple descriptor */ { - TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; + TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; slot->ttc_tupleDescriptor = tupdesc; slot->ttc_descIsNew = true; @@ -557,7 +557,7 @@ Buffer /* return: old slot buffer */ ExecSetSlotBuffer(TupleTableSlot * slot, /* slot to change */ Buffer b) /* tuple descriptor */ { - Buffer oldb = slot->ttc_buffer; + Buffer oldb = slot->ttc_buffer; slot->ttc_buffer = b; @@ -578,7 +578,7 @@ void ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */ { /* Buffer b = SlotBuffer((TupleTableSlot*) slot); */ - Buffer b = slot->ttc_buffer; + Buffer b = slot->ttc_buffer; if (BufferIsValid(b)) IncrBufferRefCount(b); @@ -599,7 +599,7 @@ ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */ bool /* return: true if tuple in slot is NULL */ TupIsNull(TupleTableSlot * slot) /* slot to check */ { - HeapTuple tuple; /* contents of slot (returned) */ + HeapTuple tuple; /* contents of slot (returned) */ /* ---------------- * if the slot itself is null then we return true @@ -733,136 +733,136 @@ NodeGetResultTupleSlot(Plan * node) switch (nodeTag(node)) { - case T_Result: - { - ResultState *resstate = ((Result *) node)->resstate; - - slot = resstate->cstate.cs_ResultTupleSlot; - } - break; + case T_Result: + { + ResultState *resstate = ((Result *) node)->resstate; - case T_SeqScan: - { - CommonScanState *scanstate = ((SeqScan *) node)->scanstate; + slot = resstate->cstate.cs_ResultTupleSlot; + } + break; - slot = scanstate->cstate.cs_ResultTupleSlot; - } - break; + case T_SeqScan: + { + CommonScanState *scanstate = ((SeqScan *) node)->scanstate; - case T_NestLoop: - { - NestLoopState *nlstate = ((NestLoop *) node)->nlstate; + slot = scanstate->cstate.cs_ResultTupleSlot; + } + break; - slot = nlstate->jstate.cs_ResultTupleSlot; - } - break; + case T_NestLoop: + { + NestLoopState *nlstate = ((NestLoop *) node)->nlstate; - case T_Append: - { - Append *n = (Append *) node; - AppendState *unionstate; - List *unionplans; - int whichplan; - Plan *subplan; - - unionstate = n->unionstate; - unionplans = n->unionplans; - whichplan = unionstate->as_whichplan; - - subplan = (Plan *) nth(whichplan, unionplans); - slot = NodeGetResultTupleSlot(subplan); + slot = nlstate->jstate.cs_ResultTupleSlot; + } break; - } - case T_IndexScan: - { - CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate; + case T_Append: + { + Append *n = (Append *) node; + AppendState *unionstate; + List *unionplans; + int whichplan; + Plan *subplan; + + unionstate = n->unionstate; + unionplans = n->unionplans; + whichplan = unionstate->as_whichplan; + + subplan = (Plan *) nth(whichplan, unionplans); + slot = NodeGetResultTupleSlot(subplan); + break; + } - slot = scanstate->cstate.cs_ResultTupleSlot; - } - break; + case T_IndexScan: + { + CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate; - case T_Material: - { - MaterialState *matstate = ((Material *) node)->matstate; + slot = scanstate->cstate.cs_ResultTupleSlot; + } + break; - slot = matstate->csstate.css_ScanTupleSlot; - } - break; + case T_Material: + { + MaterialState *matstate = ((Material *) node)->matstate; - case T_Sort: - { - SortState *sortstate = ((Sort *) node)->sortstate; + slot = matstate->csstate.css_ScanTupleSlot; + } + break; - slot = sortstate->csstate.css_ScanTupleSlot; - } - break; + case T_Sort: + { + SortState *sortstate = ((Sort *) node)->sortstate; - case T_Agg: - { - AggState *aggstate = ((Agg *) node)->aggstate; + slot = sortstate->csstate.css_ScanTupleSlot; + } + break; - slot = aggstate->csstate.cstate.cs_ResultTupleSlot; - } - break; + case T_Agg: + { + AggState *aggstate = ((Agg *) node)->aggstate; - case T_Group: - { - GroupState *grpstate = ((Group *) node)->grpstate; + slot = aggstate->csstate.cstate.cs_ResultTupleSlot; + } + break; - slot = grpstate->csstate.cstate.cs_ResultTupleSlot; - } - break; + case T_Group: + { + GroupState *grpstate = ((Group *) node)->grpstate; - case T_Hash: - { - HashState *hashstate = ((Hash *) node)->hashstate; + slot = grpstate->csstate.cstate.cs_ResultTupleSlot; + } + break; - slot = hashstate->cstate.cs_ResultTupleSlot; - } - break; + case T_Hash: + { + HashState *hashstate = ((Hash *) node)->hashstate; - case T_Unique: - { - UniqueState *uniquestate = ((Unique *) node)->uniquestate; + slot = hashstate->cstate.cs_ResultTupleSlot; + } + break; - slot = uniquestate->cs_ResultTupleSlot; - } - break; + case T_Unique: + { + UniqueState *uniquestate = ((Unique *) node)->uniquestate; - case T_MergeJoin: - { - MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate; + slot = uniquestate->cs_ResultTupleSlot; + } + break; - slot = mergestate->jstate.cs_ResultTupleSlot; - } - break; + case T_MergeJoin: + { + MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate; - case T_HashJoin: - { - HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate; + slot = mergestate->jstate.cs_ResultTupleSlot; + } + break; - slot = hashjoinstate->jstate.cs_ResultTupleSlot; - } - break; + case T_HashJoin: + { + HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate; - case T_Tee: - { - TeeState *teestate = ((Tee *) node)->teestate; + slot = hashjoinstate->jstate.cs_ResultTupleSlot; + } + break; - slot = teestate->cstate.cs_ResultTupleSlot; - } - break; + case T_Tee: + { + TeeState *teestate = ((Tee *) node)->teestate; - default: - /* ---------------- - * should never get here - * ---------------- - */ - elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ", - nodeTag(node)); + slot = teestate->cstate.cs_ResultTupleSlot; + } + break; - return NULL; + default: + /* ---------------- + * should never get here + * ---------------- + */ + elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ", + nodeTag(node)); + + return NULL; } return slot; } @@ -897,7 +897,7 @@ TupleDesc ExecGetTupType(Plan * node) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; if (node == NULL) return NULL; @@ -948,11 +948,11 @@ ExecCopyTupType(TupleDesc td, int natts) TupleDesc ExecTypeFromTL(List * targetList) { - List *tlcdr; - TupleDesc typeInfo; - Resdom *resdom; - Oid restype; - int len; + List *tlcdr; + TupleDesc typeInfo; + Resdom *resdom; + Oid restype; + int len; /* ---------------- * examine targetlist - if empty then return NULL @@ -977,7 +977,7 @@ ExecTypeFromTL(List * targetList) tlcdr = targetList; while (tlcdr != NIL) { - TargetEntry *tle = lfirst(tlcdr); + TargetEntry *tle = lfirst(tlcdr); if (tle->resdom != NULL) { @@ -1005,13 +1005,13 @@ ExecTypeFromTL(List * targetList) } else { - Resdom *fjRes; - List *fjTlistP; - List *fjList = lfirst(tlcdr); + Resdom *fjRes; + List *fjTlistP; + List *fjList = lfirst(tlcdr); #ifdef SETS_FIXED - TargetEntry *tle; - Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin; + TargetEntry *tle; + Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin; tle = fjNode->fj_innerNode; /* ??? */ #endif @@ -1037,7 +1037,7 @@ ExecTypeFromTL(List * targetList) foreach(fjTlistP, lnext(fjList)) { - TargetEntry *fjTle = lfirst(fjTlistP); + TargetEntry *fjTle = lfirst(fjTlistP); fjRes = fjTle->resdom; diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 3795c2d101..0f3338d3cb 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.15 1997/09/07 04:41:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.16 1997/09/08 02:22:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,13 +67,13 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple, int *numAttsOutP, * appended, replaced, deleted. * ---------------------------------------------------------------- */ -int NTupleProcessed; -int NTupleRetrieved; -int NTupleReplaced; -int NTupleAppended; -int NTupleDeleted; -int NIndexTupleInserted; -extern int NIndexTupleProcessed; /* have to be defined in the +int NTupleProcessed; +int NTupleRetrieved; +int NTupleReplaced; +int NTupleAppended; +int NTupleDeleted; +int NIndexTupleInserted; +extern int NIndexTupleProcessed; /* have to be defined in the * access method level so that the * cinterface.a will link ok. */ @@ -159,7 +159,7 @@ DisplayTupleCount(FILE * statfp) void ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent) { - int baseId; + int baseId; baseId = estate->es_BaseId; cstate->cs_base_id = baseId; @@ -178,9 +178,9 @@ ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent) void ExecAssignExprContext(EState * estate, CommonState * commonstate) { - ExprContext *econtext; - ParamListInfo paraminfo; - List *rangeTable; + ExprContext *econtext; + ParamListInfo paraminfo; + List *rangeTable; paraminfo = estate->es_param_list_info; rangeTable = estate->es_range_table; @@ -223,8 +223,8 @@ ExecAssignResultType(CommonState * commonstate, void ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate) { - Plan *outerPlan; - TupleDesc tupDesc; + Plan *outerPlan; + TupleDesc tupDesc; outerPlan = outerPlan(node); tupDesc = ExecGetTupType(outerPlan); @@ -239,13 +239,13 @@ ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate) void ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate) { - List *targetList; - int i; - int len; - List *tl; - TargetEntry *tle; - List *fjtl; - TupleDesc origTupDesc; + List *targetList; + int i; + int len; + List *tl; + TargetEntry *tle; + List *fjtl; + TupleDesc origTupDesc; targetList = node->targetlist; origTupDesc = ExecTypeFromTL(targetList); @@ -269,7 +269,7 @@ ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate) #ifdef SETS_FIXED if (!tl_is_resdom(tle)) { - Fjoin *fj = (Fjoin *) lfirst(tle); + Fjoin *fj = (Fjoin *) lfirst(tle); /* it is a FJoin */ fjtl = lnext(tle); @@ -309,7 +309,7 @@ void ExecFreeResultType(CommonState * commonstate) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; slot = commonstate->cs_ResultTupleSlot; tupType = slot->ttc_tupleDescriptor; @@ -329,8 +329,8 @@ void ExecAssignProjectionInfo(Plan * node, CommonState * commonstate) { ProjectionInfo *projInfo; - List *targetList; - int len; + List *targetList; + int len; targetList = node->targetlist; len = ExecTargetListLength(targetList); @@ -407,7 +407,7 @@ void ExecFreeScanType(CommonScanState * csstate) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; slot = csstate->css_ScanTupleSlot; tupType = slot->ttc_tupleDescriptor; @@ -439,8 +439,8 @@ ExecAssignScanType(CommonScanState * csstate, void ExecAssignScanTypeFromOuterPlan(Plan * node, CommonScanState * csstate) { - Plan *outerPlan; - TupleDesc tupDesc; + Plan *outerPlan; + TupleDesc tupDesc; outerPlan = outerPlan(node); tupDesc = ExecGetTupType(outerPlan); @@ -571,10 +571,10 @@ ExecFreeTypeInfo(TupleDesc typeInfo) TupleDesc QueryDescGetTypeInfo(QueryDesc * queryDesc) { - Plan *plan; - TupleDesc tupleType; - List *targetList; - AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo)); + Plan *plan; + TupleDesc tupleType; + List *targetList; + AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo)); plan = queryDesc->plantree; tupleType = (TupleDesc) ExecGetTupType(plan); @@ -611,9 +611,9 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple, AttrNumber ** attsOutP, FuncIndexInfoPtr fInfoP) { - int i; - int numKeys; - AttrNumber *attKeys; + int i; + int numKeys; + AttrNumber *attKeys; /* ---------------- * check parameters @@ -708,32 +708,32 @@ void ExecOpenIndices(Oid resultRelationOid, RelationInfo * resultRelationInfo) { - Relation indexRd; - HeapScanDesc indexSd; - ScanKeyData key; - HeapTuple tuple; - IndexTupleForm indexStruct; - Oid indexOid; - List *oidList; - List *nkeyList; - List *keyList; - List *fiList; - char *predString; - List *predList; - List *indexoid; - List *numkeys; - List *indexkeys; - List *indexfuncs; - List *indexpreds; - int len; - - RelationPtr relationDescs; - IndexInfo **indexInfoArray; + Relation indexRd; + HeapScanDesc indexSd; + ScanKeyData key; + HeapTuple tuple; + IndexTupleForm indexStruct; + Oid indexOid; + List *oidList; + List *nkeyList; + List *keyList; + List *fiList; + char *predString; + List *predList; + List *indexoid; + List *numkeys; + List *indexkeys; + List *indexfuncs; + List *indexpreds; + int len; + + RelationPtr relationDescs; + IndexInfo **indexInfoArray; FuncIndexInfoPtr fInfoP; - int numKeyAtts; - AttrNumber *indexKeyAtts; - PredInfo *predicate; - int i; + int numKeyAtts; + AttrNumber *indexKeyAtts; + PredInfo *predicate; + int i; /* ---------------- * open pg_index @@ -857,7 +857,7 @@ ExecOpenIndices(Oid resultRelationOid, for (i = 0; i < len; i++) { - IndexInfo *ii = makeNode(IndexInfo); + IndexInfo *ii = makeNode(IndexInfo); ii->ii_NumKeyAttributes = 0; ii->ii_KeyAttributeNumbers = (AttrNumber *) NULL; @@ -875,7 +875,7 @@ ExecOpenIndices(Oid resultRelationOid, i = 0; foreach(indexoid, oidList) { - Relation indexDesc; + Relation indexDesc; indexOid = lfirsti(indexoid); indexDesc = index_open(indexOid); @@ -954,9 +954,9 @@ ExecOpenIndices(Oid resultRelationOid, void ExecCloseIndices(RelationInfo * resultRelationInfo) { - int i; - int numIndices; - RelationPtr relationDescs; + int i; + int numIndices; + RelationPtr relationDescs; numIndices = resultRelationInfo->ri_NumIndices; relationDescs = resultRelationInfo->ri_IndexRelationDescs; @@ -986,14 +986,14 @@ ExecFormIndexTuple(HeapTuple heapTuple, Relation indexRelation, IndexInfo * indexInfo) { - IndexTuple indexTuple; - TupleDesc heapDescriptor; - TupleDesc indexDescriptor; - Datum *datum; - char *nulls; - - int numberOfAttributes; - AttrNumber *keyAttributeNumbers; + IndexTuple indexTuple; + TupleDesc heapDescriptor; + TupleDesc indexDescriptor; + Datum *datum; + char *nulls; + + int numberOfAttributes; + AttrNumber *keyAttributeNumbers; FuncIndexInfoPtr fInfoP; /* ---------------- @@ -1075,24 +1075,24 @@ ExecInsertIndexTuples(TupleTableSlot * slot, EState * estate, bool is_update) { - HeapTuple heapTuple; - RelationInfo *resultRelationInfo; - int i; - int numIndices; - RelationPtr relationDescs; - Relation heapRelation; - IndexInfo **indexInfoArray; - IndexInfo *indexInfo; - Node *predicate; - bool satisfied; - ExprContext *econtext; + HeapTuple heapTuple; + RelationInfo *resultRelationInfo; + int i; + int numIndices; + RelationPtr relationDescs; + Relation heapRelation; + IndexInfo **indexInfoArray; + IndexInfo *indexInfo; + Node *predicate; + bool satisfied; + ExprContext *econtext; InsertIndexResult result; - int numberOfAttributes; - AttrNumber *keyAttributeNumbers; + int numberOfAttributes; + AttrNumber *keyAttributeNumbers; FuncIndexInfoPtr fInfoP; - TupleDesc heapDescriptor; - Datum *datum; - char *nulls; + TupleDesc heapDescriptor; + Datum *datum; + char *nulls; heapTuple = slot->val; @@ -1189,10 +1189,10 @@ void setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, List * rangeTable) { - List *tl; - TargetEntry *tle; - Node *expr; - int varno; + List *tl; + TargetEntry *tle; + Node *expr; + int varno; tl = targetList; @@ -1206,9 +1206,9 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, expr = tle->expr; if (expr && IsA(expr, Var)) { - Var *var; - RangeTblEntry *rtentry; - Relation rd; + Var *var; + RangeTblEntry *rtentry; + Relation rd; var = (Var *) expr; rtentry = rt_fetch(var->varnoold, rangeTable); @@ -1238,7 +1238,7 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, void resetVarAttrLenForCreateTable(TupleDesc tupType) { - int varno; + int varno; for (varno = 0; varno < tupType->natts; varno++) { diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 96b9b19dcb..6b10ead651 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.8 1997/09/07 04:41:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.9 1997/09/08 02:22:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,15 +44,15 @@ typedef enum { F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE -} ExecStatus; +} ExecStatus; typedef struct local_es { - QueryDesc *qd; - EState *estate; + QueryDesc *qd; + EState *estate; struct local_es *next; - ExecStatus status; -} execution_state; + ExecStatus status; +} execution_state; #define LAST_POSTQUEL_COMMAND(es) ((es)->next == (execution_state *)NULL) @@ -62,7 +62,7 @@ static execution_state * init_execution_state(FunctionCachePtr fcache, char *args[]); static TupleTableSlot *postquel_getnext(execution_state * es); -static void postquel_end(execution_state * es); +static void postquel_end(execution_state * es); static void postquel_sub_params(execution_state * es, int nargs, char *args[], bool * nullV); @@ -77,10 +77,10 @@ ProjectAttribute(TupleDesc TD, HeapTuple tup, bool * isnullP) { - Datum val, - valueP; - Var *attrVar = (Var *) tlist->expr; - AttrNumber attrno = attrVar->varattno; + Datum val, + valueP; + Var *attrVar = (Var *) tlist->expr; + AttrNumber attrno = attrVar->varattno; val = PointerGetDatum(heap_getattr(tup, @@ -105,10 +105,10 @@ init_execution_state(FunctionCachePtr fcache, execution_state *newes; execution_state *nextes; execution_state *preves; - QueryTreeList *queryTree_list; - int i; - List *planTree_list; - int nargs; + QueryTreeList *queryTree_list; + int i; + List *planTree_list; + int nargs; nargs = fcache->nargs; @@ -122,9 +122,9 @@ init_execution_state(FunctionCachePtr fcache, for (i = 0; i < queryTree_list->len; i++) { - EState *estate; - Query *queryTree = (Query *) (queryTree_list->qtrees[i]); - Plan *planTree = lfirst(planTree_list); + EState *estate; + Query *queryTree = (Query *) (queryTree_list->qtrees[i]); + Plan *planTree = lfirst(planTree_list); if (!nextes) nextes = (execution_state *) palloc(sizeof(execution_state)); @@ -140,8 +140,8 @@ init_execution_state(FunctionCachePtr fcache, if (nargs > 0) { - int i; - ParamListInfo paramLI; + int i; + ParamListInfo paramLI; paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData)); @@ -171,7 +171,7 @@ init_execution_state(FunctionCachePtr fcache, return newes; } -static TupleDesc +static TupleDesc postquel_start(execution_state * es) { #ifdef FUNC_UTIL_PATCH @@ -191,7 +191,7 @@ postquel_start(execution_state * es) static TupleTableSlot * postquel_getnext(execution_state * es) { - int feature; + int feature; #ifdef FUNC_UTIL_PATCH if (es->qd->operation == CMD_UTILITY) @@ -236,8 +236,8 @@ postquel_sub_params(execution_state * es, char *args[], bool * nullV) { - ParamListInfo paramLI; - EState *estate; + ParamListInfo paramLI; + EState *estate; estate = es->estate; paramLI = estate->es_param_list_info; @@ -259,9 +259,9 @@ copy_function_result(FunctionCachePtr fcache, TupleTableSlot * resultSlot) { TupleTableSlot *funcSlot; - TupleDesc resultTd; - HeapTuple newTuple; - HeapTuple oldTuple; + TupleDesc resultTd; + HeapTuple newTuple; + HeapTuple oldTuple; Assert(!TupIsNull(resultSlot)); oldTuple = resultSlot->val; @@ -279,8 +279,8 @@ copy_function_result(FunctionCachePtr fcache, */ if (TupIsNull(funcSlot)) { - int i = 0; - TupleDesc funcTd = funcSlot->ttc_tupleDescriptor; + int i = 0; + TupleDesc funcTd = funcSlot->ttc_tupleDescriptor; while (i < oldTuple->t_natts) { @@ -298,7 +298,7 @@ copy_function_result(FunctionCachePtr fcache, return ExecStoreTuple(newTuple, funcSlot, InvalidBuffer, true); } -static Datum +static Datum postquel_execute(execution_state * es, FunctionCachePtr fcache, List * fTlist, @@ -306,7 +306,7 @@ postquel_execute(execution_state * es, bool * isNull) { TupleTableSlot *slot; - Datum value; + Datum value; #ifdef INDEXSCAN_PATCH @@ -360,8 +360,8 @@ postquel_execute(execution_state * es, resSlot = copy_function_result(fcache, slot); if (fTlist != NIL) { - HeapTuple tup; - TargetEntry *tle = lfirst(fTlist); + HeapTuple tup; + TargetEntry *tle = lfirst(fTlist); tup = resSlot->val; value = ProjectAttribute(resSlot->ttc_tupleDescriptor, @@ -401,9 +401,9 @@ Datum postquel_function(Func * funcNode, char **args, bool * isNull, bool * isDone) { execution_state *es; - Datum result = 0; + Datum result = 0; FunctionCachePtr fcache = funcNode->func_fcache; - CommandId savedId; + CommandId savedId; /* * Before we start do anything we must save CurrentScanCommandId to diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index ee03f6854d..92fa9bbe1e 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -36,18 +36,18 @@ */ typedef struct AggFuncInfo { - Oid xfn1_oid; - Oid xfn2_oid; - Oid finalfn_oid; - func_ptr xfn1; - func_ptr xfn2; - func_ptr finalfn; - int xfn1_nargs; - int xfn2_nargs; - int finalfn_nargs; -} AggFuncInfo; + Oid xfn1_oid; + Oid xfn2_oid; + Oid finalfn_oid; + func_ptr xfn1; + func_ptr xfn2; + func_ptr finalfn; + int xfn1_nargs; + int xfn2_nargs; + int finalfn_nargs; +} AggFuncInfo; -static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); +static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); /* --------------------------------------- @@ -90,26 +90,26 @@ static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); TupleTableSlot * ExecAgg(Agg * node) { - AggState *aggstate; - EState *estate; - Aggreg **aggregates; - Plan *outerPlan; - int i, - nagg; - Datum *value1, - *value2; - int *noInitValue; - AggFuncInfo *aggFuncInfo; - long nTuplesAgged = 0; - ExprContext *econtext; + AggState *aggstate; + EState *estate; + Aggreg **aggregates; + Plan *outerPlan; + int i, + nagg; + Datum *value1, + *value2; + int *noInitValue; + AggFuncInfo *aggFuncInfo; + long nTuplesAgged = 0; + ExprContext *econtext; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - HeapTuple oneTuple; - char *nulls; - bool isDone; - bool isNull = FALSE, - isNull1 = FALSE, - isNull2 = FALSE; + HeapTuple oneTuple; + char *nulls; + bool isDone; + bool isNull = FALSE, + isNull1 = FALSE, + isNull2 = FALSE; /* --------------------- * get state info from node @@ -143,19 +143,19 @@ ExecAgg(Agg * node) for (i = 0; i < nagg; i++) { - Aggreg *agg; - char *aggname; - HeapTuple aggTuple; + Aggreg *agg; + char *aggname; + HeapTuple aggTuple; Form_pg_aggregate aggp; - Oid xfn1_oid, - xfn2_oid, - finalfn_oid; - func_ptr xfn1_ptr, - xfn2_ptr, - finalfn_ptr; - int xfn1_nargs, - xfn2_nargs, - finalfn_nargs; + Oid xfn1_oid, + xfn2_oid, + finalfn_oid; + func_ptr xfn1_ptr, + xfn2_ptr, + finalfn_ptr; + int xfn1_nargs, + xfn2_nargs, + finalfn_nargs; agg = aggregates[i]; @@ -240,7 +240,7 @@ ExecAgg(Agg * node) */ for (;;) { - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot; isNull = isNull1 = isNull2 = 0; @@ -258,9 +258,9 @@ ExecAgg(Agg * node) */ if (nTuplesAgged == 0) { - TupleDesc tupType; - Datum *tupValue; - char *null_array; + TupleDesc tupType; + Datum *tupValue; + char *null_array; tupType = aggstate->csstate.css_ScanTupleSlot->ttc_tupleDescriptor; tupValue = projInfo->pi_tupValue; @@ -277,29 +277,29 @@ ExecAgg(Agg * node) for (i = 0; i < nagg; i++) { - AttrNumber attnum; - int2 attlen; - Datum newVal = (Datum) NULL; - AggFuncInfo *aggfns = &aggFuncInfo[i]; - Datum args[2]; - Node *tagnode = NULL; + AttrNumber attnum; + int2 attlen; + Datum newVal = (Datum) NULL; + AggFuncInfo *aggfns = &aggFuncInfo[i]; + Datum args[2]; + Node *tagnode = NULL; switch (nodeTag(aggregates[i]->target)) { - case T_Var: - tagnode = NULL; - newVal = aggGetAttr(outerslot, - aggregates[i], - &isNull); - break; - case T_Expr: - tagnode = ((Expr *) aggregates[i]->target)->oper; - econtext->ecxt_scantuple = outerslot; - newVal = ExecEvalExpr(aggregates[i]->target, econtext, - &isNull, NULL); - break; - default: - elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i); + case T_Var: + tagnode = NULL; + newVal = aggGetAttr(outerslot, + aggregates[i], + &isNull); + break; + case T_Expr: + tagnode = ((Expr *) aggregates[i]->target)->oper; + econtext->ecxt_scantuple = outerslot; + newVal = ExecEvalExpr(aggregates[i]->target, econtext, + &isNull, NULL); + break; + default: + elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i); } if (isNull) @@ -309,7 +309,7 @@ ExecAgg(Agg * node) { if (noInitValue[i]) { - int byVal; + int byVal; /* * value1 and value2 has not been initialized. This is @@ -371,7 +371,7 @@ ExecAgg(Agg * node) if (aggfns->xfn2) { - Datum xfn2_val = value2[i]; + Datum xfn2_val = value2[i]; value2[i] = (Datum) fmgr_c(aggfns->xfn2, aggfns->xfn2_oid, @@ -399,8 +399,8 @@ ExecAgg(Agg * node) */ for (i = 0; i < nagg; i++) { - char *args[2]; - AggFuncInfo *aggfns = &aggFuncInfo[i]; + char *args[2]; + AggFuncInfo *aggfns = &aggFuncInfo[i]; if (noInitValue[i]) { @@ -490,9 +490,9 @@ ExecAgg(Agg * node) bool ExecInitAgg(Agg * node, EState * estate, Plan * parent) { - AggState *aggstate; - Plan *outerPlan; - ExprContext *econtext; + AggState *aggstate; + Plan *outerPlan; + ExprContext *econtext; /* * assign the node's execution state @@ -566,8 +566,8 @@ ExecCountSlotsAgg(Agg * node) void ExecEndAgg(Agg * node) { - AggState *aggstate; - Plan *outerPlan; + AggState *aggstate; + Plan *outerPlan; aggstate = node->aggstate; @@ -590,16 +590,16 @@ ExecEndAgg(Agg * node) * get the attribute (specified in the Var node in agg) to aggregate * over from the tuple */ -static Datum +static Datum aggGetAttr(TupleTableSlot * slot, Aggreg * agg, bool * isNull) { - Datum result; - AttrNumber attnum; - HeapTuple heapTuple; - TupleDesc tuple_type; - Buffer buffer; + Datum result; + AttrNumber attnum; + HeapTuple heapTuple; + TupleDesc tuple_type; + Buffer buffer; /* ---------------- * extract tuple information from the slot @@ -619,8 +619,8 @@ aggGetAttr(TupleTableSlot * slot, if (attnum == InvalidAttrNumber) { TupleTableSlot *tempSlot; - TupleDesc td; - HeapTuple tup; + TupleDesc td; + HeapTuple tup; tempSlot = makeNode(TupleTableSlot); tempSlot->ttc_shouldFree = false; diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index 043ad5d974..da43dc8ee3 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.6 1997/09/07 04:41:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.7 1997/09/08 02:22:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ #include "utils/mcxt.h" #include "parser/parsetree.h" /* for rt_store() macro */ -static bool exec_append_initialize_next(Append * node); +static bool exec_append_initialize_next(Append * node); /* ---------------------------------------------------------------- * exec-append-initialize-next @@ -75,20 +75,20 @@ static bool exec_append_initialize_next(Append * node); * Returns t iff there is a "next" scan to process. * ---------------------------------------------------------------- */ -static bool +static bool exec_append_initialize_next(Append * node) { - EState *estate; - AppendState *unionstate; + EState *estate; + AppendState *unionstate; TupleTableSlot *result_slot; - List *rangeTable; + List *rangeTable; - int whichplan; - int nplans; - List *rtentries; - ResTarget *rtentry; + int whichplan; + int nplans; + List *rtentries; + ResTarget *rtentry; - Index unionrelid; + Index unionrelid; /* ---------------- * get information from the append node @@ -184,16 +184,16 @@ exec_append_initialize_next(Append * node) bool ExecInitAppend(Append * node, EState * estate, Plan * parent) { - AppendState *unionstate; - int nplans; - List *resultList = NULL; - List *rtentries; - List *unionplans; - bool *initialized; - int i; - Plan *initNode; - List *junkList; - RelationInfo *es_rri = estate->es_result_relation_info; + AppendState *unionstate; + int nplans; + List *resultList = NULL; + List *rtentries; + List *unionplans; + bool *initialized; + int i; + Plan *initNode; + List *junkList; + RelationInfo *es_rri = estate->es_result_relation_info; /* ---------------- * assign execution state to node and get information @@ -251,13 +251,13 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) if ((es_rri != (RelationInfo *) NULL) && (node->unionrelid == es_rri->ri_RangeTableIndex)) { - RelationInfo *rri; - List *rtentryP; + RelationInfo *rri; + List *rtentryP; foreach(rtentryP, rtentries) { - Oid reloid; - RangeTblEntry *rtentry = lfirst(rtentryP); + Oid reloid; + RangeTblEntry *rtentry = lfirst(rtentryP); reloid = rtentry->relid; rri = makeNode(RelationInfo); @@ -281,8 +281,8 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) for (i = 0; i < nplans; i++) { - JunkFilter *j; - List *targetList; + JunkFilter *j; + List *targetList; /* ---------------- * NOTE: we first modify range table in @@ -343,9 +343,9 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) int ExecCountSlotsAppend(Append * node) { - List *plan; - List *unionplans = node->unionplans; - int nSlots = 0; + List *plan; + List *unionplans = node->unionplans; + int nSlots = 0; foreach(plan, unionplans) { @@ -365,15 +365,15 @@ ExecCountSlotsAppend(Append * node) TupleTableSlot * ExecProcAppend(Append * node) { - EState *estate; - AppendState *unionstate; + EState *estate; + AppendState *unionstate; - int whichplan; - List *unionplans; - Plan *subnode; + int whichplan; + List *unionplans; + Plan *subnode; TupleTableSlot *result; TupleTableSlot *result_slot; - ScanDirection direction; + ScanDirection direction; /* ---------------- * get information from the node @@ -458,13 +458,13 @@ ExecProcAppend(Append * node) void ExecEndAppend(Append * node) { - AppendState *unionstate; - int nplans; - List *unionplans; - bool *initialized; - int i; - List *resultRelationInfoList; - RelationInfo *resultRelationInfo; + AppendState *unionstate; + int nplans; + List *unionplans; + bool *initialized; + int i; + List *resultRelationInfoList; + RelationInfo *resultRelationInfo; /* ---------------- * get information from the node @@ -494,7 +494,7 @@ ExecEndAppend(Append * node) resultRelationInfoList = unionstate->as_result_relation_info_list; while (resultRelationInfoList != NIL) { - Relation resultRelationDesc; + Relation resultRelationDesc; resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList); resultRelationDesc = resultRelationInfo->ri_RelationDesc; diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index 1a96a1ee91..c7e63696c0 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -13,7 +13,7 @@ * columns. (ie. tuples from the same group are consecutive) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.6 1997/09/07 04:41:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.7 1997/09/08 02:22:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,17 +66,17 @@ ExecGroup(Group * node) static TupleTableSlot * ExecGroupEveryTuple(Group * node) { - GroupState *grpstate; - EState *estate; - ExprContext *econtext; + GroupState *grpstate; + EState *estate; + ExprContext *econtext; - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot, - *lastslot; + *lastslot; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - bool isDone; + bool isDone; /* --------------------- * get state info from node @@ -167,17 +167,17 @@ ExecGroupEveryTuple(Group * node) static TupleTableSlot * ExecGroupOneTuple(Group * node) { - GroupState *grpstate; - EState *estate; - ExprContext *econtext; + GroupState *grpstate; + EState *estate; + ExprContext *econtext; - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot, - *lastslot; + *lastslot; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - bool isDone; + bool isDone; /* --------------------- * get state info from node @@ -291,8 +291,8 @@ ExecGroupOneTuple(Group * node) bool ExecInitGroup(Group * node, EState * estate, Plan * parent) { - GroupState *grpstate; - Plan *outerPlan; + GroupState *grpstate; + Plan *outerPlan; /* * assign the node's execution state @@ -358,8 +358,8 @@ ExecCountSlotsGroup(Group * node) void ExecEndGroup(Group * node) { - GroupState *grpstate; - Plan *outerPlan; + GroupState *grpstate; + Plan *outerPlan; grpstate = node->grpstate; @@ -379,22 +379,22 @@ ExecEndGroup(Group * node) /* * code swiped from nodeUnique.c */ -static bool +static bool sameGroup(TupleTableSlot * oldslot, TupleTableSlot * newslot, int numCols, AttrNumber * grpColIdx, TupleDesc tupdesc) { - bool isNull1, - isNull2; - char *attr1, - *attr2; - char *val1, - *val2; - int i; - AttrNumber att; - Oid typoutput; + bool isNull1, + isNull2; + char *attr1, + *attr2; + char *val1, + *val2; + int i; + AttrNumber att; + Oid typoutput; for (i = 0; i < numCols; i++) { diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index b25939fa83..b0e7ca4dd5 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.11 1997/09/07 04:41:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.12 1997/09/08 02:22:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,12 +42,12 @@ #include "utils/palloc.h" #include "utils/hsearch.h" -extern int NBuffers; -static int HashTBSize; +extern int NBuffers; +static int HashTBSize; -static void mk_hj_temp(char *tempname); -static int hashFunc(char *key, int len); -static int ExecHashPartition(Hash * node); +static void mk_hj_temp(char *tempname); +static int hashFunc(char *key, int len); +static int ExecHashPartition(Hash * node); static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable); static void ExecHashOverflowInsert(HashJoinTable hashtable, @@ -64,20 +64,20 @@ ExecHashOverflowInsert(HashJoinTable hashtable, TupleTableSlot * ExecHash(Hash * node) { - EState *estate; - HashState *hashstate; - Plan *outerNode; - Var *hashkey; - HashJoinTable hashtable; + EState *estate; + HashState *hashstate; + Plan *outerNode; + Var *hashkey; + HashJoinTable hashtable; TupleTableSlot *slot; - ExprContext *econtext; + ExprContext *econtext; - int nbatch; - File *batches = NULL; - RelativeAddr *batchPos; - int *batchSizes; - int i; - RelativeAddr *innerbatchNames; + int nbatch; + File *batches = NULL; + RelativeAddr *batchPos; + int *batchSizes; + int i; + RelativeAddr *innerbatchNames; /* ---------------- * get state info from node @@ -167,8 +167,8 @@ ExecHash(Hash * node) bool ExecInitHash(Hash * node, EState * estate, Plan * parent) { - HashState *hashstate; - Plan *outerPlan; + HashState *hashstate; + Plan *outerPlan; SO1_printf("ExecInitHash: %s\n", "initializing hash node"); @@ -240,9 +240,9 @@ ExecCountSlotsHash(Hash * node) void ExecEndHash(Hash * node) { - HashState *hashstate; - Plan *outerPlan; - File *batches; + HashState *hashstate; + Plan *outerPlan; + File *batches; /* ---------------- * get info from the hash state @@ -268,10 +268,10 @@ ExecEndHash(Hash * node) ExecEndNode(outerPlan, (Plan *) node); } -static RelativeAddr +static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable) { - RelativeAddr p; + RelativeAddr p; p = hashtable->top; hashtable->top += size; @@ -290,23 +290,23 @@ hashTableAlloc(int size, HashJoinTable hashtable) HashJoinTable ExecHashTableCreate(Hash * node) { - Plan *outerNode; - int nbatch; - int ntuples; - int tupsize; - IpcMemoryId shmid; - HashJoinTable hashtable; - HashBucket bucket; - int nbuckets; - int totalbuckets; - int bucketsize; - int i; - RelativeAddr *outerbatchNames; - RelativeAddr *outerbatchPos; - RelativeAddr *innerbatchNames; - RelativeAddr *innerbatchPos; - int *innerbatchSizes; - RelativeAddr tempname; + Plan *outerNode; + int nbatch; + int ntuples; + int tupsize; + IpcMemoryId shmid; + HashJoinTable hashtable; + HashBucket bucket; + int nbuckets; + int totalbuckets; + int bucketsize; + int i; + RelativeAddr *outerbatchNames; + RelativeAddr *outerbatchPos; + RelativeAddr *innerbatchNames; + RelativeAddr *innerbatchPos; + int *innerbatchSizes; + RelativeAddr tempname; nbatch = -1; HashTBSize = NBuffers / 2; @@ -461,15 +461,15 @@ ExecHashTableInsert(HashJoinTable hashtable, File * batches) { TupleTableSlot *slot; - HeapTuple heapTuple; - HashBucket bucket; - int bucketno; - int nbatch; - int batchno; - char *buffer; - RelativeAddr *batchPos; - int *batchSizes; - char *pos; + HeapTuple heapTuple; + HashBucket bucket; + int bucketno; + int nbatch; + int batchno; + char *buffer; + RelativeAddr *batchPos; + int *batchSizes; + char *pos; nbatch = hashtable->nbatch; batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos); @@ -551,9 +551,9 @@ ExecHashGetBucket(HashJoinTable hashtable, ExprContext * econtext, Var * hashkey) { - int bucketno; - Datum keyval; - bool isNull; + int bucketno; + Datum keyval; + bool isNull; /* ---------------- @@ -606,10 +606,10 @@ ExecHashOverflowInsert(HashJoinTable hashtable, HashBucket bucket, HeapTuple heapTuple) { - OverflowTuple otuple; - RelativeAddr newend; - OverflowTuple firstotuple; - OverflowTuple lastotuple; + OverflowTuple otuple; + RelativeAddr newend; + OverflowTuple firstotuple; + OverflowTuple lastotuple; firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple); lastotuple = (OverflowTuple) ABSADDR(bucket->lastotuple); @@ -687,14 +687,14 @@ ExecScanHashBucket(HashJoinState * hjstate, List * hjclauses, ExprContext * econtext) { - HeapTuple heapTuple; - bool qualResult; - OverflowTuple otuple = NULL; - OverflowTuple curotuple; + HeapTuple heapTuple; + bool qualResult; + OverflowTuple otuple = NULL; + OverflowTuple curotuple; TupleTableSlot *inntuple; - OverflowTuple firstotuple; - OverflowTuple lastotuple; - HashJoinTable hashtable; + OverflowTuple firstotuple; + OverflowTuple lastotuple; + HashJoinTable hashtable; hashtable = hjstate->hj_HashTable; firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple); @@ -785,7 +785,7 @@ static int hashFunc(char *key, int len) { register unsigned int h; - register int l; + register int l; register unsigned char *k; /* @@ -828,11 +828,11 @@ hashFunc(char *key, int len) static int ExecHashPartition(Hash * node) { - Plan *outerNode; - int b; - int pages; - int ntuples; - int tupsize; + Plan *outerNode; + int b; + int pages; + int ntuples; + int tupsize; /* * get size information for plan node @@ -866,8 +866,8 @@ ExecHashPartition(Hash * node) void ExecHashTableReset(HashJoinTable hashtable, int ntuples) { - int i; - HashBucket bucket; + int i; + HashBucket bucket; hashtable->nbuckets = hashtable->totalbuckets = ceil((double) ntuples / NTUP_PER_BUCKET); @@ -886,7 +886,7 @@ ExecHashTableReset(HashJoinTable hashtable, int ntuples) hashtable->pcount = hashtable->nprocess; } -static int hjtmpcnt = 0; +static int hjtmpcnt = 0; static void mk_hj_temp(char *tempname) diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 3548e38cc8..b0c6eec3c0 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.6 1997/09/07 04:41:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.7 1997/09/08 02:22:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ #include "utils/palloc.h" static TupleTableSlot * - ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate); + ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate); static TupleTableSlot * ExecHashJoinGetSavedTuple(HashJoinState * hjstate, char *buffer, @@ -43,7 +43,7 @@ static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch); -static int ExecHashJoinNewBatch(HashJoinState * hjstate); +static int ExecHashJoinNewBatch(HashJoinState * hjstate); @@ -59,39 +59,39 @@ static int ExecHashJoinNewBatch(HashJoinState * hjstate); TupleTableSlot * /* return: a tuple or NULL */ ExecHashJoin(HashJoin * node) { - HashJoinState *hjstate; - EState *estate; - Plan *outerNode; - Hash *hashNode; - List *hjclauses; - Expr *clause; - List *qual; - ScanDirection dir; + HashJoinState *hjstate; + EState *estate; + Plan *outerNode; + Hash *hashNode; + List *hjclauses; + Expr *clause; + List *qual; + ScanDirection dir; TupleTableSlot *inntuple; - Var *outerVar; - ExprContext *econtext; + Var *outerVar; + ExprContext *econtext; - HashJoinTable hashtable; - int bucketno; - HashBucket bucket; - HeapTuple curtuple; + HashJoinTable hashtable; + int bucketno; + HashBucket bucket; + HeapTuple curtuple; - bool qualResult; + bool qualResult; TupleTableSlot *outerTupleSlot; TupleTableSlot *innerTupleSlot; - int nbatch; - int curbatch; - File *outerbatches; - RelativeAddr *outerbatchNames; - RelativeAddr *outerbatchPos; - Var *innerhashkey; - int batch; - int batchno; - char *buffer; - int i; - bool hashPhaseDone; - char *pos; + int nbatch; + int curbatch; + File *outerbatches; + RelativeAddr *outerbatchNames; + RelativeAddr *outerbatchPos; + Var *innerhashkey; + int batch; + int batchno; + char *buffer; + int i; + bool hashPhaseDone; + char *pos; /* ---------------- * get information from HashJoin node @@ -125,7 +125,7 @@ ExecHashJoin(HashJoin * node) if (hjstate->jstate.cs_TupFromTlist) { TupleTableSlot *result; - bool isDone; + bool isDone; result = ExecProject(hjstate->jstate.cs_ProjInfo, &isDone); if (!isDone) @@ -322,7 +322,7 @@ ExecHashJoin(HashJoin * node) { ProjectionInfo *projInfo; TupleTableSlot *result; - bool isDone; + bool isDone; hjstate->hj_CurBucket = bucket; hjstate->hj_CurTuple = curtuple; @@ -394,9 +394,9 @@ ExecHashJoin(HashJoin * node) bool /* return: initialization status */ ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent) { - HashJoinState *hjstate; - Plan *outerNode; - Hash *hashNode; + HashJoinState *hjstate; + Plan *outerNode; + Hash *hashNode; /* ---------------- * assign the node's execution state @@ -451,7 +451,7 @@ ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent) * ---------------- */ { - HashState *hashstate = hashNode->hashstate; + HashState *hashstate = hashNode->hashstate; TupleTableSlot *slot = hashstate->cstate.cs_ResultTupleSlot; @@ -513,7 +513,7 @@ ExecCountSlotsHashJoin(HashJoin * node) void ExecEndHashJoin(HashJoin * node) { - HashJoinState *hjstate; + HashJoinState *hjstate; /* ---------------- * get info from the HashJoin state @@ -572,13 +572,13 @@ static TupleTableSlot * ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate) { TupleTableSlot *slot; - HashJoinTable hashtable; - int curbatch; - File *outerbatches; - char *outerreadPos; - int batchno; - char *outerreadBuf; - int outerreadBlk; + HashJoinTable hashtable; + int curbatch; + File *outerbatches; + char *outerreadPos; + int batchno; + char *outerreadBuf; + int outerreadBlk; hashtable = hjstate->hj_HashTable; curbatch = hashtable->curbatch; @@ -626,11 +626,11 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate, int *block, /* return parameter */ char **position) /* return parameter */ { - char *bufstart; - char *bufend; - int cc; - HeapTuple heapTuple; - HashJoinTable hashtable; + char *bufstart; + char *bufend; + int cc; + HeapTuple heapTuple; + HashJoinTable hashtable; hashtable = hjstate->hj_HashTable; bufend = buffer + *(long *) buffer; @@ -666,20 +666,20 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate, static int ExecHashJoinNewBatch(HashJoinState * hjstate) { - File *innerBatches; - File *outerBatches; - int *innerBatchSizes; - Var *innerhashkey; - HashJoinTable hashtable; - int nbatch; - char *readPos; - int readBlk; - char *readBuf; + File *innerBatches; + File *outerBatches; + int *innerBatchSizes; + Var *innerhashkey; + HashJoinTable hashtable; + int nbatch; + char *readPos; + int readBlk; + char *readBuf; TupleTableSlot *slot; - ExprContext *econtext; - int i; - int cc; - int newbatch; + ExprContext *econtext; + int i; + int cc; + int newbatch; hashtable = hjstate->hj_HashTable; outerBatches = hjstate->hj_OuterBatches; @@ -793,7 +793,7 @@ ExecHashJoinNewBatch(HashJoinState * hjstate) static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch) { - int b; + int b; if (bucketno < hashtable->nbuckets || nbatch == 0) return 0; @@ -813,16 +813,16 @@ ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch) * ---------------------------------------------------------------- */ -char * +char * ExecHashJoinSaveTuple(HeapTuple heapTuple, char *buffer, File file, char *position) { - long *pageend; - char *pagestart; - char *pagebound; - int cc; + long *pageend; + char *pagestart; + char *pagebound; + int cc; pageend = (long *) buffer; pagestart = (char *) (buffer + sizeof(long)); diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index c89a4fcb08..61fca80a0c 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.8 1997/09/07 04:41:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.9 1997/09/08 02:22:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,19 +82,19 @@ static TupleTableSlot *IndexNext(IndexScan * node); static TupleTableSlot * IndexNext(IndexScan * node) { - EState *estate; + EState *estate; CommonScanState *scanstate; IndexScanState *indexstate; - ScanDirection direction; - int indexPtr; + ScanDirection direction; + int indexPtr; IndexScanDescPtr scanDescs; - IndexScanDesc scandesc; - Relation heapRelation; + IndexScanDesc scandesc; + Relation heapRelation; RetrieveIndexResult result; - ItemPointer iptr; - HeapTuple tuple; + ItemPointer iptr; + HeapTuple tuple; TupleTableSlot *slot; - Buffer buffer = InvalidBuffer; + Buffer buffer = InvalidBuffer; /* ---------------- * extract necessary information from index scan node @@ -219,30 +219,30 @@ ExecIndexScan(IndexScan * node) void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent) { - EState *estate; + EState *estate; IndexScanState *indexstate; - ScanDirection direction; + ScanDirection direction; IndexScanDescPtr scanDescs; - ScanKey *scanKeys; - IndexScanDesc sdesc; - ScanKey skey; - int numIndices; - int i; - - Pointer *runtimeKeyInfo; - int indexPtr; - int *numScanKeys; - List *indxqual; - List *qual; - int n_keys; - ScanKey scan_keys; - int *run_keys; - int j; - Expr *clause; - Node *scanexpr; - Datum scanvalue; - bool isNull; - bool isDone; + ScanKey *scanKeys; + IndexScanDesc sdesc; + ScanKey skey; + int numIndices; + int i; + + Pointer *runtimeKeyInfo; + int indexPtr; + int *numScanKeys; + List *indxqual; + List *qual; + int n_keys; + ScanKey scan_keys; + int *run_keys; + int j; + Expr *clause; + Node *scanexpr; + Datum scanvalue; + bool isNull; + bool isDone; indexstate = node->indxstate; estate = node->scan.plan.state; @@ -335,9 +335,9 @@ ExecEndIndexScan(IndexScan * node) { CommonScanState *scanstate; IndexScanState *indexstate; - ScanKey *scanKeys; - int numIndices; - int i; + ScanKey *scanKeys; + int numIndices; + int i; scanstate = node->scan.scanstate; indexstate = node->indxstate; @@ -399,8 +399,8 @@ ExecIndexMarkPos(IndexScan * node) { IndexScanState *indexstate; IndexScanDescPtr indexScanDescs; - IndexScanDesc scanDesc; - int indexPtr; + IndexScanDesc scanDesc; + int indexPtr; indexstate = node->indxstate; indexPtr = indexstate->iss_IndexPtr; @@ -430,8 +430,8 @@ ExecIndexRestrPos(IndexScan * node) { IndexScanState *indexstate; IndexScanDescPtr indexScanDescs; - IndexScanDesc scanDesc; - int indexPtr; + IndexScanDesc scanDesc; + int indexPtr; indexstate = node->indxstate; indexPtr = indexstate->iss_IndexPtr; @@ -465,27 +465,27 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) { IndexScanState *indexstate; CommonScanState *scanstate; - List *indxqual; - List *indxid; - int i; - int numIndices; - int indexPtr; - ScanKey *scanKeys; - int *numScanKeys; - RelationPtr relationDescs; + List *indxqual; + List *indxid; + int i; + int numIndices; + int indexPtr; + ScanKey *scanKeys; + int *numScanKeys; + RelationPtr relationDescs; IndexScanDescPtr scanDescs; - Pointer *runtimeKeyInfo; - bool have_runtime_keys; - List *rangeTable; - RangeTblEntry *rtentry; - Index relid; - Oid reloid; - TimeQual timeQual; - - Relation currentRelation; - HeapScanDesc currentScanDesc; - ScanDirection direction; - int baseid; + Pointer *runtimeKeyInfo; + bool have_runtime_keys; + List *rangeTable; + RangeTblEntry *rtentry; + Index relid; + Oid reloid; + TimeQual timeQual; + + Relation currentRelation; + HeapScanDesc currentScanDesc; + ScanDirection direction; + int baseid; /* ---------------- * assign execution state to node @@ -600,11 +600,11 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (i = 0; i < numIndices; i++) { - int j; - List *qual; - int n_keys; - ScanKey scan_keys; - int *run_keys; + int j; + List *qual; + int n_keys; + ScanKey scan_keys; + int *run_keys; qual = nth(i, indxqual); n_keys = length(qual); @@ -623,17 +623,16 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (j = 0; j < n_keys; j++) { - Expr *clause; /* one part of index qual */ - Oper *op; /* operator used in scan.. */ - Node *leftop; /* expr on lhs of operator */ - Node *rightop; /* expr on rhs ... */ - bits16 flags = 0; - - int scanvar; /* which var identifies varattno */ - AttrNumber varattno = 0; /* att number used in scan */ - Oid opid; /* operator id used in scan */ - Datum scanvalue = 0; /* value used in scan (if - * const) */ + Expr *clause; /* one part of index qual */ + Oper *op; /* operator used in scan.. */ + Node *leftop; /* expr on lhs of operator */ + Node *rightop;/* expr on rhs ... */ + bits16 flags = 0; + + int scanvar;/* which var identifies varattno */ + AttrNumber varattno = 0; /* att number used in scan */ + Oid opid; /* operator id used in scan */ + Datum scanvalue = 0; /* value used in scan (if const) */ /* ---------------- * extract clause information from the qualification @@ -702,7 +701,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) } else if (IsA(leftop, Param)) { - bool isnull; + bool isnull; /* ---------------- * if the leftop is a Param node then it means @@ -785,7 +784,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) } else if (IsA(rightop, Param)) { - bool isnull; + bool isnull; /* ---------------- * if the rightop is a Param node then it means @@ -885,8 +884,8 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) indexstate->iss_RuntimeKeyInfo = NULL; for (i = 0; i < numIndices; i++) { - List *qual; - int n_keys; + List *qual; + int n_keys; qual = nth(i, indxqual); n_keys = length(qual); @@ -947,7 +946,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (i = 0; i < numIndices; i++) { - Oid indexOid; + Oid indexOid; indexOid = (Oid) nthi(i, indxid); diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index 49ba73d3bf..6ff8598901 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.7 1997/09/07 04:41:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.8 1997/09/08 02:22:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,16 +50,16 @@ TupleTableSlot * /* result tuple from subplan */ ExecMaterial(Material * node) { - EState *estate; - MaterialState *matstate; - Plan *outerNode; - ScanDirection dir; - Relation tempRelation; - Relation currentRelation; - HeapScanDesc currentScanDesc; - HeapTuple heapTuple; + EState *estate; + MaterialState *matstate; + Plan *outerNode; + ScanDirection dir; + Relation tempRelation; + Relation currentRelation; + HeapScanDesc currentScanDesc; + HeapTuple heapTuple; TupleTableSlot *slot; - Buffer buffer; + Buffer buffer; /* ---------------- * get state info from node @@ -190,10 +190,10 @@ ExecMaterial(Material * node) bool /* initialization status */ ExecInitMaterial(Material * node, EState * estate, Plan * parent) { - MaterialState *matstate; - Plan *outerPlan; - TupleDesc tupType; - Relation tempDesc; + MaterialState *matstate; + Plan *outerPlan; + TupleDesc tupType; + Relation tempDesc; /* int len; */ @@ -308,9 +308,9 @@ ExecCountSlotsMaterial(Material * node) void ExecEndMaterial(Material * node) { - MaterialState *matstate; - Relation tempRelation; - Plan *outerPlan; + MaterialState *matstate; + Relation tempRelation; + Plan *outerPlan; /* ---------------- * get info from the material state @@ -349,8 +349,8 @@ ExecEndMaterial(Material * node) List /* nothing of interest */ ExecMaterialMarkPos(Material node) { - MaterialState matstate; - HeapScanDesc sdesc; + MaterialState matstate; + HeapScanDesc sdesc; /* ---------------- * if we haven't materialized yet, just return NIL. @@ -379,8 +379,8 @@ ExecMaterialMarkPos(Material node) void ExecMaterialRestrPos(Material node) { - MaterialState matstate; - HeapScanDesc sdesc; + MaterialState matstate; + HeapScanDesc sdesc; /* ---------------- * if we haven't materialized yet, just return. diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 348d3fa1e0..621cfcea90 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.9 1997/09/07 04:41:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.10 1997/09/08 02:22:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ #include "utils/lsyscache.h" #include "utils/psort.h" -static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext); +static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext); /* ---------------------------------------------------------------- * MarkInnerTuple and RestoreInnerTuple macros @@ -142,13 +142,13 @@ static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econt * by "sortOp". * ---------------------------------------------------------------- */ -static List * +static List * MJFormOSortopI(List * qualList, Oid sortOp) { - List *qualCopy; - List *qualcdr; - Expr *qual; - Oper *op; + List *qualCopy; + List *qualcdr; + Expr *qual; + Oper *op; /* ---------------- * qualList is a list: ((op .. ..) ...) @@ -206,11 +206,11 @@ MJFormOSortopI(List * qualList, Oid sortOp) * by "sortOp" and reversing the positions of the keys. * ---------------------------------------------------------------- */ -static List * +static List * MJFormISortopO(List * qualList, Oid sortOp) { - List *ISortopO; - List *qualcdr; + List *ISortopO; + List *qualcdr; /* ---------------- * first generate OSortopI, a list of the form @@ -226,9 +226,9 @@ MJFormISortopO(List * qualList, Oid sortOp) */ foreach(qualcdr, ISortopO) { - Expr *qual; - List *inner; - List *outer; + Expr *qual; + List *inner; + List *outer; qual = lfirst(qualcdr); @@ -257,14 +257,14 @@ MJFormISortopO(List * qualList, Oid sortOp) * if (key1i > key2i) is true and (key1j = key2j) for 0 < j < i. * ---------------------------------------------------------------- */ -static bool +static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext) { - List *clause; - List *eqclause; - Datum const_value; - bool isNull; - bool isDone; + List *clause; + List *eqclause; + Datum const_value; + bool isNull; + bool isDone; /* ---------------- * if we have no compare qualification, return nil @@ -394,7 +394,7 @@ CleanUpSort(Plan * plan) if (plan->type == T_Sort) { - Sort *sort = (Sort *) plan; + Sort *sort = (Sort *) plan; psort_end(sort); } @@ -451,25 +451,25 @@ CleanUpSort(Plan * plan) TupleTableSlot * ExecMergeJoin(MergeJoin * node) { - EState *estate; + EState *estate; MergeJoinState *mergestate; - ScanDirection direction; - List *innerSkipQual; - List *outerSkipQual; - List *mergeclauses; - List *qual; - bool qualResult; - bool compareResult; - - Plan *innerPlan; + ScanDirection direction; + List *innerSkipQual; + List *outerSkipQual; + List *mergeclauses; + List *qual; + bool qualResult; + bool compareResult; + + Plan *innerPlan; TupleTableSlot *innerTupleSlot; - Plan *outerPlan; + Plan *outerPlan; TupleTableSlot *outerTupleSlot; TupleTableSlot *markedTupleSlot; - ExprContext *econtext; + ExprContext *econtext; /* ---------------- * get information from node @@ -503,7 +503,7 @@ ExecMergeJoin(MergeJoin * node) { TupleTableSlot *result; ProjectionInfo *projInfo; - bool isDone; + bool isDone; projInfo = mergestate->jstate.cs_ProjInfo; result = ExecProject(projInfo, &isDone); @@ -523,349 +523,185 @@ ExecMergeJoin(MergeJoin * node) switch (mergestate->mj_JoinState) { - /* - * ******************************** EXEC_MJ_INITIALIZE means - * that this is the first time ExecMergeJoin() has been called - * and so we have to initialize the inner, outer and marked - * tuples as well as various stuff in the expression context. ******************************** - * - */ - case EXEC_MJ_INITIALIZE: - MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n"); - /* ---------------- - * Note: at this point, if either of our inner or outer - * tuples are nil, then the join ends immediately because - * we know one of the subplans is empty. - * ---------------- - */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - if (TupIsNull(innerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** inner tuple is nil ****\n"); - return NULL; - } + /* + * ******************************** EXEC_MJ_INITIALIZE + * means that this is the first time ExecMergeJoin() has + * been called and so we have to initialize the inner, + * outer and marked tuples as well as various stuff in the + * expression context. ******************************** + * + */ + case EXEC_MJ_INITIALIZE: + MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n"); + /* ---------------- + * Note: at this point, if either of our inner or outer + * tuples are nil, then the join ends immediately because + * we know one of the subplans is empty. + * ---------------- + */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + if (TupIsNull(innerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** inner tuple is nil ****\n"); + return NULL; + } - outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); - if (TupIsNull(outerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); - return NULL; - } - - /* ---------------- - * store the inner and outer tuple in the merge state - * ---------------- - */ - econtext->ecxt_innertuple = innerTupleSlot; - econtext->ecxt_outertuple = outerTupleSlot; - - /* ---------------- - * set the marked tuple to nil - * and initialize its tuple descriptor atttributes. - * -jeff 10 july 1991 - * ---------------- - */ - ExecClearTuple(mergestate->mj_MarkedTupleSlot); - mergestate->mj_MarkedTupleSlot->ttc_tupleDescriptor = - innerTupleSlot->ttc_tupleDescriptor; + outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); + if (TupIsNull(outerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); + return NULL; + } + + /* ---------------- + * store the inner and outer tuple in the merge state + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + econtext->ecxt_outertuple = outerTupleSlot; + + /* ---------------- + * set the marked tuple to nil + * and initialize its tuple descriptor atttributes. + * -jeff 10 july 1991 + * ---------------- + */ + ExecClearTuple(mergestate->mj_MarkedTupleSlot); + mergestate->mj_MarkedTupleSlot->ttc_tupleDescriptor = + innerTupleSlot->ttc_tupleDescriptor; /* mergestate->mj_MarkedTupleSlot->ttc_execTupDescriptor = innerTupleSlot->ttc_execTupDescriptor; */ - /* ---------------- - * initialize merge join state to skip inner tuples. - * ---------------- - */ - mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; - break; - - /* - * ******************************** EXEC_MJ_JOINMARK means we - * have just found a new outer tuple and a possible matching - * inner tuple. This is the case after the INITIALIZE, - * SKIPOUTER or SKIPINNER states. ******************************** - * - */ - case EXEC_MJ_JOINMARK: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n"); - ExecMarkPos(innerPlan); - - innerTupleSlot = econtext->ecxt_innertuple; - MarkInnerTuple(innerTupleSlot, mergestate); - - mergestate->mj_JoinState = EXEC_MJ_JOINTEST; - break; - - /* - * ******************************** EXEC_MJ_JOINTEST means we - * have two tuples which might satisify the merge clause, so - * we test them. - * - * If they do satisify, then we join them and move on to the next - * inner tuple (EXEC_MJ_JOINTUPLES). - * - * If they do not satisify then advance to next outer tuple. ******************************** - * - */ - case EXEC_MJ_JOINTEST: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n"); - - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; - } - break; - - /* - * ******************************** EXEC_MJ_JOINTUPLES means - * we have two tuples which satisified the merge clause so we - * join them and then proceed to get the next inner tuple - * (EXEC_NEXT_INNER). ******************************** - * - */ - case EXEC_MJ_JOINTUPLES: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); - mergestate->mj_JoinState = EXEC_MJ_NEXTINNER; - - qualResult = ExecQual((List *) qual, econtext); - MJ_DEBUG_QUAL(qual, qualResult); - - if (qualResult) - { /* ---------------- - * qualification succeeded. now form the desired - * projection tuple and return the slot containing it. + * initialize merge join state to skip inner tuples. * ---------------- */ - ProjectionInfo *projInfo; - TupleTableSlot *result; - bool isDone; - - MJ_printf("ExecMergeJoin: **** returning tuple ****\n"); - - projInfo = mergestate->jstate.cs_ProjInfo; - - result = ExecProject(projInfo, &isDone); - mergestate->jstate.cs_TupFromTlist = !isDone; - return result; - } - break; - - /* - * ******************************** EXEC_MJ_NEXTINNER means - * advance the inner scan to the next tuple. If the tuple is - * not nil, we then proceed to test it against the join - * qualification. ******************************** - * - */ - case EXEC_MJ_NEXTINNER: - MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n"); - - /* ---------------- - * now we get the next inner tuple, if any - * ---------------- - */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(innerTupleSlot); - econtext->ecxt_innertuple = innerTupleSlot; - - if (TupIsNull(innerTupleSlot)) - { - mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINTEST; - } - break; - - /* - * ******************************** EXEC_MJ_NEXTOUTER means - * - * outer inner outer tuple - 5 5 - marked tuple 5 5 6 - * 6 - inner tuple 7 7 - * - * we know we just bumped into the first inner tuple > current - * outer tuple so get a new outer tuple and then proceed to - * test it against the marked tuple (EXEC_MJ_TESTOUTER) ******************************** - * - */ - case EXEC_MJ_NEXTOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n"); - - outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(outerTupleSlot); - econtext->ecxt_outertuple = outerTupleSlot; - - /* ---------------- - * if the outer tuple is null then we know - * we are done with the join - * ---------------- - */ - if (TupIsNull(outerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); - CleanUpSort(node->join.lefttree->lefttree); - CleanUpSort(node->join.righttree->lefttree); - return NULL; - } - - mergestate->mj_JoinState = EXEC_MJ_TESTOUTER; - break; - - /* - * ******************************** EXEC_MJ_TESTOUTER If the - * new outer tuple and the marked tuple satisify the merge - * clause then we know we have duplicates in the outer scan so - * we have to restore the inner scan to the marked tuple and - * proceed to join the new outer tuples with the inner tuples - * (EXEC_MJ_JOINTEST) - * - * This is the case when - * - * outer inner 4 5 - marked tuple outer tuple - 5 5 new - * outer tuple - 5 5 6 8 - inner tuple 7 12 - * - * new outer tuple = marked tuple - * - * If the outer tuple fails the test, then we know we have to - * proceed to skip outer tuples until outer >= inner - * (EXEC_MJ_SKIPOUTER). - * - * This is the case when - * - * outer inner 5 5 - marked tuple outer tuple - 5 5 new - * outer tuple - 6 8 - inner tuple 7 12 - * - * new outer tuple > marked tuple - * - ******************************** - * - */ - case EXEC_MJ_TESTOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n"); - - /* ---------------- - * here we compare the outer tuple with the marked inner tuple - * by using the marked tuple in place of the inner tuple. - * ---------------- - */ - innerTupleSlot = econtext->ecxt_innertuple; - markedTupleSlot = mergestate->mj_MarkedTupleSlot; - econtext->ecxt_innertuple = markedTupleSlot; - - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - /* ---------------- - * the merge clause matched so now we juggle the slots - * back the way they were and proceed to JOINTEST. - * ---------------- + mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; + break; + + /* + * ******************************** EXEC_MJ_JOINMARK means + * we have just found a new outer tuple and a possible + * matching inner tuple. This is the case after the + * INITIALIZE, SKIPOUTER or SKIPINNER states. ******************************** + * */ - econtext->ecxt_innertuple = innerTupleSlot; + case EXEC_MJ_JOINMARK: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n"); + ExecMarkPos(innerPlan); - RestoreInnerTuple(innerTupleSlot, markedTupleSlot); + innerTupleSlot = econtext->ecxt_innertuple; + MarkInnerTuple(innerTupleSlot, mergestate); - ExecRestrPos(innerPlan); mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + break; - } - else - { - /* ---------------- - * if the inner tuple was nil and the new outer - * tuple didn't match the marked outer tuple then - * we may have the case: + /* + * ******************************** EXEC_MJ_JOINTEST means + * we have two tuples which might satisify the merge + * clause, so we test them. * - * outer inner - * 4 4 - marked tuple - * new outer - 5 4 - * 6 nil - inner tuple - * 7 + * If they do satisify, then we join them and move on to the + * next inner tuple (EXEC_MJ_JOINTUPLES). + * + * If they do not satisify then advance to next outer tuple. ******************************** * - * which means that all subsequent outer tuples will be - * larger than our inner tuples. - * ---------------- */ - if (TupIsNull(innerTupleSlot)) + case EXEC_MJ_JOINTEST: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n"); + + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) { - MJ_printf("ExecMergeJoin: **** wierd case 1 ****\n"); - return NULL; + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; + } + break; + + /* + * ******************************** EXEC_MJ_JOINTUPLES + * means we have two tuples which satisified the merge + * clause so we join them and then proceed to get the next + * inner tuple (EXEC_NEXT_INNER). ******************************** + * + */ + case EXEC_MJ_JOINTUPLES: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); + mergestate->mj_JoinState = EXEC_MJ_NEXTINNER; + + qualResult = ExecQual((List *) qual, econtext); + MJ_DEBUG_QUAL(qual, qualResult); + + if (qualResult) + { + /* ---------------- + * qualification succeeded. now form the desired + * projection tuple and return the slot containing it. + * ---------------- + */ + ProjectionInfo *projInfo; + TupleTableSlot *result; + bool isDone; + + MJ_printf("ExecMergeJoin: **** returning tuple ****\n"); + + projInfo = mergestate->jstate.cs_ProjInfo; + + result = ExecProject(projInfo, &isDone); + mergestate->jstate.cs_TupFromTlist = !isDone; + return result; } + break; + + /* + * ******************************** EXEC_MJ_NEXTINNER + * means advance the inner scan to the next tuple. If the + * tuple is not nil, we then proceed to test it against + * the join qualification. ******************************** + * + */ + case EXEC_MJ_NEXTINNER: + MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n"); /* ---------------- - * restore the inner tuple and continue on to - * skip outer tuples. + * now we get the next inner tuple, if any * ---------------- */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(innerTupleSlot); econtext->ecxt_innertuple = innerTupleSlot; - mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; - } - break; - - /* - * ******************************** EXEC_MJ_SKIPOUTER means - * skip over tuples in the outer plan until we find an outer - * tuple > current inner tuple. - * - * For example: - * - * outer inner 5 5 5 5 outer tuple - 6 8 - inner - * tuple 7 12 8 14 - * - * we have to advance the outer scan until we find the outer 8. - * - ******************************** - * - */ - case EXEC_MJ_SKIPOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n"); - /* ---------------- - * before we advance, make sure the current tuples - * do not satisify the mergeclauses. If they do, then - * we update the marked tuple and go join them. - * ---------------- - */ - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - ExecMarkPos(innerPlan); - innerTupleSlot = econtext->ecxt_innertuple; - MarkInnerTuple(innerTupleSlot, mergestate); - - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + if (TupIsNull(innerTupleSlot)) + { + mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + } break; - } - - /* ---------------- - * ok, now test the skip qualification - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - outerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); - - /* ---------------- - * compareResult is true as long as we should - * continue skipping tuples. - * ---------------- - */ - if (compareResult) - { + + /* + * ******************************** EXEC_MJ_NEXTOUTER + * means + * + * outer inner outer tuple - 5 5 - marked tuple 5 5 + * 6 6 - inner tuple 7 7 + * + * we know we just bumped into the first inner tuple > + * current outer tuple so get a new outer tuple and then + * proceed to test it against the marked tuple + * (EXEC_MJ_TESTOUTER) ******************************** + * + */ + case EXEC_MJ_NEXTOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n"); outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); MJ_DEBUG_PROC_NODE(outerTupleSlot); @@ -878,169 +714,342 @@ ExecMergeJoin(MergeJoin * node) */ if (TupIsNull(outerTupleSlot)) { - MJ_printf("ExecMergeJoin: **** outerTuple is nil ****\n"); + MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); + CleanUpSort(node->join.lefttree->lefttree); + CleanUpSort(node->join.righttree->lefttree); return NULL; } + + mergestate->mj_JoinState = EXEC_MJ_TESTOUTER; + break; + + /* + * ******************************** EXEC_MJ_TESTOUTER If + * the new outer tuple and the marked tuple satisify the + * merge clause then we know we have duplicates in the + * outer scan so we have to restore the inner scan to the + * marked tuple and proceed to join the new outer tuples + * with the inner tuples (EXEC_MJ_JOINTEST) + * + * This is the case when + * + * outer inner 4 5 - marked tuple outer tuple - 5 5 + * new outer tuple - 5 5 6 8 - inner tuple 7 + * 12 + * + * new outer tuple = marked tuple + * + * If the outer tuple fails the test, then we know we have to + * proceed to skip outer tuples until outer >= inner + * (EXEC_MJ_SKIPOUTER). + * + * This is the case when + * + * outer inner 5 5 - marked tuple outer tuple - 5 5 + * new outer tuple - 6 8 - inner tuple 7 12 + * + * new outer tuple > marked tuple + * + ******************************* + * + * + */ + case EXEC_MJ_TESTOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n"); + /* ---------------- - * otherwise test the new tuple against the skip qual. - * (we remain in the EXEC_MJ_SKIPOUTER state) + * here we compare the outer tuple with the marked inner tuple + * by using the marked tuple in place of the inner tuple. * ---------------- */ - break; - } - - /* ---------------- - * now check the inner skip qual to see if we - * should now skip inner tuples... if we fail the - * inner skip qual, then we know we have a new pair - * of matching tuples. - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - innerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); - - if (compareResult) - { - mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINMARK; - } - break; - - /* - * ******************************** EXEC_MJ_SKIPINNER means - * skip over tuples in the inner plan until we find an inner - * tuple > current outer tuple. - * - * For example: - * - * outer inner 5 5 5 5 outer tuple - 12 8 - inner - * tuple 14 10 17 12 - * - * we have to advance the inner scan until we find the inner 12. - * - ******************************** - * - */ - case EXEC_MJ_SKIPINNER: - MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n"); - /* ---------------- - * before we advance, make sure the current tuples - * do not satisify the mergeclauses. If they do, then - * we update the marked tuple and go join them. - * ---------------- - */ - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - ExecMarkPos(innerPlan); innerTupleSlot = econtext->ecxt_innertuple; + markedTupleSlot = mergestate->mj_MarkedTupleSlot; + econtext->ecxt_innertuple = markedTupleSlot; - MarkInnerTuple(innerTupleSlot, mergestate); + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + /* ---------------- + * the merge clause matched so now we juggle the slots + * back the way they were and proceed to JOINTEST. + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + + RestoreInnerTuple(innerTupleSlot, markedTupleSlot); - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + ExecRestrPos(innerPlan); + mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + + } + else + { + /* ---------------- + * if the inner tuple was nil and the new outer + * tuple didn't match the marked outer tuple then + * we may have the case: + * + * outer inner + * 4 4 - marked tuple + * new outer - 5 4 + * 6 nil - inner tuple + * 7 + * + * which means that all subsequent outer tuples will be + * larger than our inner tuples. + * ---------------- + */ + if (TupIsNull(innerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** wierd case 1 ****\n"); + return NULL; + } + + /* ---------------- + * restore the inner tuple and continue on to + * skip outer tuples. + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; + } break; - } - - /* ---------------- - * ok, now test the skip qualification - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - innerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); - - /* ---------------- - * compareResult is true as long as we should - * continue skipping tuples. - * ---------------- - */ - if (compareResult) - { + + /* + * ******************************** EXEC_MJ_SKIPOUTER + * means skip over tuples in the outer plan until we find + * an outer tuple > current inner tuple. + * + * For example: + * + * outer inner 5 5 5 5 outer tuple - 6 8 - + * inner tuple 7 12 8 14 + * + * we have to advance the outer scan until we find the outer + * 8. + * + ******************************* + * + * + */ + case EXEC_MJ_SKIPOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n"); /* ---------------- - * now try and get a new inner tuple + * before we advance, make sure the current tuples + * do not satisify the mergeclauses. If they do, then + * we update the marked tuple and go join them. * ---------------- */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(innerTupleSlot); - econtext->ecxt_innertuple = innerTupleSlot; + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + ExecMarkPos(innerPlan); + innerTupleSlot = econtext->ecxt_innertuple; + + MarkInnerTuple(innerTupleSlot, mergestate); + + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + break; + } /* ---------------- - * if the inner tuple is null then we know - * we have to restore the inner scan - * and advance to the next outer tuple + * ok, now test the skip qualification * ---------------- */ - if (TupIsNull(innerTupleSlot)) + compareResult = MergeCompare(mergeclauses, + outerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); + + /* ---------------- + * compareResult is true as long as we should + * continue skipping tuples. + * ---------------- + */ + if (compareResult) { + + outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(outerTupleSlot); + econtext->ecxt_outertuple = outerTupleSlot; + /* ---------------- - * this is an interesting case.. all our - * inner tuples are smaller then our outer - * tuples so we never found an inner tuple - * to mark. - * - * outer inner - * outer tuple - 5 4 - * 5 4 - * 6 nil - inner tuple - * 7 - * - * This means the join should end. + * if the outer tuple is null then we know + * we are done with the join * ---------------- */ - MJ_printf("ExecMergeJoin: **** wierd case 2 ****\n"); - return NULL; + if (TupIsNull(outerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** outerTuple is nil ****\n"); + return NULL; + } + /* ---------------- + * otherwise test the new tuple against the skip qual. + * (we remain in the EXEC_MJ_SKIPOUTER state) + * ---------------- + */ + break; } /* ---------------- - * otherwise test the new tuple against the skip qual. - * (we remain in the EXEC_MJ_SKIPINNER state) + * now check the inner skip qual to see if we + * should now skip inner tuples... if we fail the + * inner skip qual, then we know we have a new pair + * of matching tuples. * ---------------- */ + compareResult = MergeCompare(mergeclauses, + innerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); + + if (compareResult) + { + mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINMARK; + } break; - } - - /* ---------------- - * compare finally failed and we have stopped skipping - * inner tuples so now check the outer skip qual - * to see if we should now skip outer tuples... - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - outerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); - - if (compareResult) - { - mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINMARK; - } - - break; - - /* - * ******************************** if we get here it means - * our code is fucked up and so we just end the join - * prematurely. ******************************** - * - */ - default: - elog(NOTICE, "ExecMergeJoin: invalid join state. aborting"); - return NULL; + + /* + * ******************************** EXEC_MJ_SKIPINNER + * means skip over tuples in the inner plan until we find + * an inner tuple > current outer tuple. + * + * For example: + * + * outer inner 5 5 5 5 outer tuple - 12 8 - inner + * tuple 14 10 17 12 + * + * we have to advance the inner scan until we find the inner + * 12. + * + ******************************* + * + * + */ + case EXEC_MJ_SKIPINNER: + MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n"); + /* ---------------- + * before we advance, make sure the current tuples + * do not satisify the mergeclauses. If they do, then + * we update the marked tuple and go join them. + * ---------------- + */ + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + ExecMarkPos(innerPlan); + innerTupleSlot = econtext->ecxt_innertuple; + + MarkInnerTuple(innerTupleSlot, mergestate); + + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + break; + } + + /* ---------------- + * ok, now test the skip qualification + * ---------------- + */ + compareResult = MergeCompare(mergeclauses, + innerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); + + /* ---------------- + * compareResult is true as long as we should + * continue skipping tuples. + * ---------------- + */ + if (compareResult) + { + /* ---------------- + * now try and get a new inner tuple + * ---------------- + */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(innerTupleSlot); + econtext->ecxt_innertuple = innerTupleSlot; + + /* ---------------- + * if the inner tuple is null then we know + * we have to restore the inner scan + * and advance to the next outer tuple + * ---------------- + */ + if (TupIsNull(innerTupleSlot)) + { + /* ---------------- + * this is an interesting case.. all our + * inner tuples are smaller then our outer + * tuples so we never found an inner tuple + * to mark. + * + * outer inner + * outer tuple - 5 4 + * 5 4 + * 6 nil - inner tuple + * 7 + * + * This means the join should end. + * ---------------- + */ + MJ_printf("ExecMergeJoin: **** wierd case 2 ****\n"); + return NULL; + } + + /* ---------------- + * otherwise test the new tuple against the skip qual. + * (we remain in the EXEC_MJ_SKIPINNER state) + * ---------------- + */ + break; + } + + /* ---------------- + * compare finally failed and we have stopped skipping + * inner tuples so now check the outer skip qual + * to see if we should now skip outer tuples... + * ---------------- + */ + compareResult = MergeCompare(mergeclauses, + outerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); + + if (compareResult) + { + mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINMARK; + } + + break; + + /* + * ******************************** if we get here it + * means our code is fucked up and so we just end the join + * prematurely. ******************************** + * + */ + default: + elog(NOTICE, "ExecMergeJoin: invalid join state. aborting"); + return NULL; } } } @@ -1057,13 +1066,13 @@ bool ExecInitMergeJoin(MergeJoin * node, EState * estate, Plan * parent) { MergeJoinState *mergestate; - List *joinclauses; - RegProcedure rightsortop; - RegProcedure leftsortop; - RegProcedure sortop; + List *joinclauses; + RegProcedure rightsortop; + RegProcedure leftsortop; + RegProcedure sortop; - List *OSortopI; - List *ISortopO; + List *OSortopI; + List *ISortopO; MJ1_printf("ExecInitMergeJoin: %s\n", "initializing node"); diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index e7cba2e756..d8d5f38d6d 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.4 1997/09/07 04:41:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.5 1997/09/08 02:22:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,17 +57,17 @@ TupleTableSlot * ExecNestLoop(NestLoop * node, Plan * parent) { - NestLoopState *nlstate; - Plan *innerPlan; - Plan *outerPlan; - bool needNewOuterTuple; + NestLoopState *nlstate; + Plan *innerPlan; + Plan *outerPlan; + bool needNewOuterTuple; TupleTableSlot *outerTupleSlot; TupleTableSlot *innerTupleSlot; - List *qual; - bool qualResult; - ExprContext *econtext; + List *qual; + bool qualResult; + ExprContext *econtext; /* ---------------- * get information from the node @@ -86,7 +86,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) */ econtext = nlstate->jstate.cs_ExprContext; - /* ---------------- * get the current outer tuple + /* ---------------- * get the current outer tuple * ---------------- */ outerTupleSlot = nlstate->jstate.cs_OuterTupleSlot; @@ -101,7 +101,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) if (nlstate->jstate.cs_TupFromTlist) { TupleTableSlot *result; - bool isDone; + bool isDone; result = ExecProject(nlstate->jstate.cs_ProjInfo, &isDone); if (!isDone) @@ -238,7 +238,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) */ ProjectionInfo *projInfo; TupleTableSlot *result; - bool isDone; + bool isDone; ENL1_printf("qualification succeeded, projecting tuple"); @@ -267,7 +267,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) bool ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent) { - NestLoopState *nlstate; + NestLoopState *nlstate; NL1_printf("ExecInitNestLoop: %s\n", "initializing node"); @@ -347,7 +347,7 @@ ExecCountSlotsNestLoop(NestLoop * node) void ExecEndNestLoop(NestLoop * node) { - NestLoopState *nlstate; + NestLoopState *nlstate; NL1_printf("ExecEndNestLoop: %s\n", "ending node processing"); diff --git a/src/backend/executor/nodeResult.c b/src/backend/executor/nodeResult.c index 743bd73f2b..4e0e62ddfe 100644 --- a/src/backend/executor/nodeResult.c +++ b/src/backend/executor/nodeResult.c @@ -27,7 +27,7 @@ * SeqScan (emp.all) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.3 1997/09/07 04:41:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.4 1997/09/08 02:22:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,14 +53,14 @@ TupleTableSlot * ExecResult(Result * node) { - ResultState *resstate; + ResultState *resstate; TupleTableSlot *outerTupleSlot; TupleTableSlot *resultSlot; - Plan *outerPlan; - ExprContext *econtext; - Node *qual; - bool qualResult; - bool isDone; + Plan *outerPlan; + ExprContext *econtext; + Node *qual; + bool qualResult; + bool isDone; ProjectionInfo *projInfo; /* ---------------- @@ -191,7 +191,7 @@ ExecResult(Result * node) bool ExecInitResult(Result * node, EState * estate, Plan * parent) { - ResultState *resstate; + ResultState *resstate; /* ---------------- * assign execution state to node @@ -267,7 +267,7 @@ ExecCountSlotsResult(Result * node) void ExecEndResult(Result * node) { - ResultState *resstate; + ResultState *resstate; resstate = node->resstate; diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index d3451f8026..1d04360c9d 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.5 1997/09/07 04:41:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.6 1997/09/08 02:22:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,13 +49,13 @@ static TupleTableSlot *SeqNext(SeqScan * node); static TupleTableSlot * SeqNext(SeqScan * node) { - HeapTuple tuple; - HeapScanDesc scandesc; + HeapTuple tuple; + HeapScanDesc scandesc; CommonScanState *scanstate; - EState *estate; - ScanDirection direction; + EState *estate; + ScanDirection direction; TupleTableSlot *slot; - Buffer buffer; + Buffer buffer; /* ---------------- * get information from the estate and scan state @@ -118,7 +118,7 @@ TupleTableSlot * ExecSeqScan(SeqScan * node) { TupleTableSlot *slot; - Plan *outerPlan; + Plan *outerPlan; S_printf("ExecSeqScan: scanning node: "); S_nodeDisplay(node); @@ -150,19 +150,19 @@ ExecSeqScan(SeqScan * node) * subplans of scans. * ---------------------------------------------------------------- */ -static Oid +static Oid InitScanRelation(SeqScan * node, EState * estate, CommonScanState * scanstate, Plan * outerPlan) { - Index relid; - List *rangeTable; - RangeTblEntry *rtentry; - Oid reloid; - TimeQual timeQual; - ScanDirection direction; - Relation currentRelation; - HeapScanDesc currentScanDesc; - RelationInfo *resultRelationInfo; + Index relid; + List *rangeTable; + RangeTblEntry *rtentry; + Oid reloid; + TimeQual timeQual; + ScanDirection direction; + Relation currentRelation; + HeapScanDesc currentScanDesc; + RelationInfo *resultRelationInfo; if (outerPlan == NULL) { @@ -239,9 +239,9 @@ bool ExecInitSeqScan(SeqScan * node, EState * estate, Plan * parent) { CommonScanState *scanstate; - Plan *outerPlan; - Oid reloid; - HeapScanDesc scandesc; + Plan *outerPlan; + Oid reloid; + HeapScanDesc scandesc; /* ---------------- * assign the node's execution state @@ -315,7 +315,7 @@ void ExecEndSeqScan(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; + Plan *outerPlan; /* ---------------- * get information from node @@ -369,11 +369,11 @@ void ExecSeqReScan(SeqScan * node, ExprContext * exprCtxt, Plan * parent) { CommonScanState *scanstate; - EState *estate; - Plan *outerPlan; - Relation rdesc; - HeapScanDesc sdesc; - ScanDirection direction; + EState *estate; + Plan *outerPlan; + Relation rdesc; + HeapScanDesc sdesc; + ScanDirection direction; scanstate = node->scanstate; estate = node->plan.state; @@ -406,8 +406,8 @@ void ExecSeqMarkPos(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; - HeapScanDesc sdesc; + Plan *outerPlan; + HeapScanDesc sdesc; scanstate = node->scanstate; @@ -445,8 +445,8 @@ void ExecSeqRestrPos(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; - HeapScanDesc sdesc; + Plan *outerPlan; + HeapScanDesc sdesc; scanstate = node->scanstate; diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index eb2e2e7b18..64f56bc99a 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.7 1997/09/07 04:41:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.8 1997/09/08 02:22:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,17 +32,17 @@ * Returns an array of ScanKeyData. * ---------------------------------------------------------------- */ -static ScanKey +static ScanKey FormSortKeys(Sort * sortnode) { - ScanKey sortkeys; - List *targetList; - List *tl; - int keycount; - Resdom *resdom; - AttrNumber resno; - Index reskey; - Oid reskeyop; + ScanKey sortkeys; + List *targetList; + List *tl; + int keycount; + Resdom *resdom; + AttrNumber resno; + Index reskey; + Oid reskeyop; /* ---------------- * get information from the node @@ -65,7 +65,7 @@ FormSortKeys(Sort * sortnode) */ foreach(tl, targetList) { - TargetEntry *target = (TargetEntry *) lfirst(tl); + TargetEntry *target = (TargetEntry *) lfirst(tl); resdom = target->resdom; resno = resdom->resno; @@ -104,13 +104,13 @@ FormSortKeys(Sort * sortnode) TupleTableSlot * ExecSort(Sort * node) { - EState *estate; - SortState *sortstate; - Plan *outerNode; - ScanDirection dir; - int keycount; - ScanKey sortkeys; - HeapTuple heapTuple; + EState *estate; + SortState *sortstate; + Plan *outerNode; + ScanDirection dir; + int keycount; + ScanKey sortkeys; + HeapTuple heapTuple; TupleTableSlot *slot; /* ---------------- @@ -231,9 +231,9 @@ ExecSort(Sort * node) bool ExecInitSort(Sort * node, EState * estate, Plan * parent) { - SortState *sortstate; - Plan *outerPlan; - ScanKey sortkeys; + SortState *sortstate; + Plan *outerPlan; + ScanKey sortkeys; SO1_printf("ExecInitSort: %s\n", "initializing sort node"); @@ -330,8 +330,8 @@ ExecCountSlotsSort(Sort * node) void ExecEndSort(Sort * node) { - SortState *sortstate; - Plan *outerPlan; + SortState *sortstate; + Plan *outerPlan; /* ---------------- * get info from the sort state @@ -371,7 +371,7 @@ ExecEndSort(Sort * node) void ExecSortMarkPos(Sort * node) { - SortState *sortstate; + SortState *sortstate; /* ---------------- * if we haven't sorted yet, just return @@ -395,7 +395,7 @@ ExecSortMarkPos(Sort * node) void ExecSortRestrPos(Sort * node) { - SortState *sortstate; + SortState *sortstate; /* ---------------- * if we haven't sorted yet, just return. diff --git a/src/backend/executor/nodeTee.c b/src/backend/executor/nodeTee.c index 8a1e233125..e3ddfe39d6 100644 --- a/src/backend/executor/nodeTee.c +++ b/src/backend/executor/nodeTee.c @@ -15,7 +15,7 @@ * ExecEndTee * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.7 1997/09/07 04:41:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.8 1997/09/08 02:22:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,12 +47,12 @@ bool ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) { - TeeState *teeState; - Plan *outerPlan; - int len; - Relation bufferRel; - TupleDesc tupType; - EState *estate; + TeeState *teeState; + Plan *outerPlan; + int len; + Relation bufferRel; + TupleDesc tupType; + EState *estate; /* * it is possible that the Tee has already been initialized since it @@ -154,7 +154,7 @@ ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) if (node->teeTableName[0] != '\0') { - Relation r; + Relation r; teeState->tee_bufferRelname = pstrdup(node->teeTableName); @@ -168,7 +168,7 @@ ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) bufferRel = heap_openr(teeState->tee_bufferRelname); else bufferRel = heap_open(heap_create(teeState->tee_bufferRelname, - /*FIX */ NULL, + /* FIX */ NULL, 'n', DEFAULT_SMGR, tupType)); @@ -232,10 +232,10 @@ ExecCountSlotsTee(Tee * node) static void initTeeScanDescs(Tee * node) { - TeeState *teeState; - Relation bufferRel; - ScanDirection dir; - MemoryContext orig; + TeeState *teeState; + Relation bufferRel; + ScanDirection dir; + MemoryContext orig; teeState = node->teestate; if (teeState->tee_leftScanDesc && teeState->tee_rightScanDesc) @@ -292,20 +292,20 @@ initTeeScanDescs(Tee * node) TupleTableSlot * ExecTee(Tee * node, Plan * parent) { - EState *estate; - TeeState *teeState; - int leftPlace, - rightPlace, - lastPlace; - int branch; + EState *estate; + TeeState *teeState; + int leftPlace, + rightPlace, + lastPlace; + int branch; TupleTableSlot *result; TupleTableSlot *slot; - Plan *childNode; - ScanDirection dir; - HeapTuple heapTuple; - Relation bufferRel; - HeapScanDesc scanDesc; - Buffer buffer; + Plan *childNode; + ScanDirection dir; + HeapTuple heapTuple; + Relation bufferRel; + HeapScanDesc scanDesc; + Buffer buffer; estate = ((Plan *) node)->state; teeState = node->teestate; @@ -369,7 +369,7 @@ ExecTee(Tee * node, Plan * parent) * move the scandesc forward so we don't re-read this * tuple later */ - HeapTuple throwAway; + HeapTuple throwAway; /* Buffer buffer; */ throwAway = heap_getnext(scanDesc, @@ -446,9 +446,9 @@ void ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent) { - EState *estate; - TeeState *teeState; - ScanDirection dir; + EState *estate; + TeeState *teeState; + ScanDirection dir; estate = ((Plan *) node)->state; teeState = node->teestate; @@ -492,13 +492,13 @@ ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent) void ExecEndTee(Tee * node, Plan * parent) { - EState *estate; - TeeState *teeState; - int leftPlace, - rightPlace, - lastPlace; - Relation bufferRel; - MemoryContext orig; + EState *estate; + TeeState *teeState; + int leftPlace, + rightPlace, + lastPlace; + Relation bufferRel; + MemoryContext orig; estate = ((Plan *) node)->state; teeState = node->teestate; diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c index 75e40ccad9..5a340b8cf5 100644 --- a/src/backend/executor/nodeUnique.c +++ b/src/backend/executor/nodeUnique.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.8 1997/09/07 04:41:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.9 1997/09/08 02:22:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,15 +47,15 @@ * same ADT value. -cim * ---------------------------------------------------------------- */ -static bool /* true if tuples are identical, false +static bool /* true if tuples are identical, false * otherwise */ ExecIdenticalTuples(TupleTableSlot * t1, TupleTableSlot * t2) { - HeapTuple h1; - HeapTuple h2; - char *d1; - char *d2; - int len; + HeapTuple h1; + HeapTuple h2; + char *d1; + char *d2; + int len; h1 = t1->val; h2 = t2->val; @@ -110,14 +110,14 @@ ExecIdenticalTuples(TupleTableSlot * t1, TupleTableSlot * t2) TupleTableSlot * /* return: a tuple or NULL */ ExecUnique(Unique * node) { - UniqueState *uniquestate; + UniqueState *uniquestate; TupleTableSlot *resultTupleSlot; TupleTableSlot *slot; - Plan *outerPlan; - char *uniqueAttr; - AttrNumber uniqueAttrNum; - TupleDesc tupDesc; - Oid typoutput; + Plan *outerPlan; + char *uniqueAttr; + AttrNumber uniqueAttrNum; + TupleDesc tupDesc; + Oid typoutput; /* ---------------- * get information from the node @@ -180,12 +180,12 @@ ExecUnique(Unique * node) * to check equality, we check to see if the typoutput of the * attributes are equal */ - bool isNull1, - isNull2; - char *attr1, - *attr2; - char *val1, - *val2; + bool isNull1, + isNull2; + char *attr1, + *attr2; + char *val1, + *val2; attr1 = heap_getattr(slot->val, InvalidBuffer, uniqueAttrNum, tupDesc, &isNull1); @@ -245,9 +245,9 @@ ExecUnique(Unique * node) bool /* return: initialization status */ ExecInitUnique(Unique * node, EState * estate, Plan * parent) { - UniqueState *uniquestate; - Plan *outerPlan; - char *uniqueAttr; + UniqueState *uniquestate; + Plan *outerPlan; + char *uniqueAttr; /* ---------------- * assign execution state to node @@ -299,8 +299,8 @@ ExecInitUnique(Unique * node, EState * estate, Plan * parent) if (uniqueAttr) { - TupleDesc tupDesc; - int i = 0; + TupleDesc tupDesc; + int i = 0; tupDesc = ExecGetResultType(uniquestate); @@ -340,7 +340,7 @@ ExecCountSlotsUnique(Unique * node) void ExecEndUnique(Unique * node) { - UniqueState *uniquestate; + UniqueState *uniquestate; uniquestate = node->uniquestate; ExecEndNode(outerPlan((Plan *) node), (Plan *) node); diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 1d05a752d2..de4915785d 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -11,39 +11,39 @@ typedef struct { - QueryTreeList *qtlist; /* malloced */ - uint32 processed; /* by Executor */ - SPITupleTable *tuptable; - Portal portal; /* portal per procedure */ - MemoryContext savedcxt; - CommandId savedId; -} _SPI_connection; - -static Portal _SPI_portal = (Portal) NULL; + QueryTreeList *qtlist; /* malloced */ + uint32 processed; /* by Executor */ + SPITupleTable *tuptable; + Portal portal; /* portal per procedure */ + MemoryContext savedcxt; + CommandId savedId; +} _SPI_connection; + +static Portal _SPI_portal = (Portal) NULL; static _SPI_connection *_SPI_stack = NULL; static _SPI_connection *_SPI_current = NULL; -static int _SPI_connected = -1; -static int _SPI_curid = -1; +static int _SPI_connected = -1; +static int _SPI_curid = -1; -uint32 SPI_processed = 0; -SPITupleTable *SPI_tuptable; -int SPI_result; +uint32 SPI_processed = 0; +SPITupleTable *SPI_tuptable; +int SPI_result; -void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); +void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); typedef struct { - QueryTreeList *qtlist; - List *ptlist; - int nargs; - Oid *argtypes; -} _SPI_plan; + QueryTreeList *qtlist; + List *ptlist; + int nargs; + Oid *argtypes; +} _SPI_plan; -static int _SPI_execute(char *src, int tcount, _SPI_plan * plan); -static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount); +static int _SPI_execute(char *src, int tcount, _SPI_plan * plan); +static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount); #if 0 -static void _SPI_fetch(FetchStmt * stmt); +static void _SPI_fetch(FetchStmt * stmt); #endif static int @@ -52,23 +52,23 @@ _SPI_execute_plan(_SPI_plan * plan, static _SPI_plan *_SPI_copy_plan(_SPI_plan * plan, bool local); -static int _SPI_begin_call(bool execmem); -static int _SPI_end_call(bool procmem); +static int _SPI_begin_call(bool execmem); +static int _SPI_end_call(bool procmem); static MemoryContext _SPI_execmem(void); static MemoryContext _SPI_procmem(void); -static bool _SPI_checktuples(bool isRetrieveIntoRelation); +static bool _SPI_checktuples(bool isRetrieveIntoRelation); #ifdef SPI_EXECUTOR_STATS -extern int ShowExecutorStats; -extern void ResetUsage(void); -extern void ShowUsage(void); +extern int ShowExecutorStats; +extern void ResetUsage(void); +extern void ShowUsage(void); #endif int SPI_connect() { - char pname[64]; + char pname[64]; PortalVariableMemory pvmem; /* @@ -141,7 +141,7 @@ SPI_connect() int SPI_finish() { - int res; + int res; res = _SPI_begin_call(false); /* live in procedure memory */ if (res < 0) @@ -179,7 +179,7 @@ SPI_finish() int SPI_exec(char *src, int tcount) { - int res; + int res; if (src == NULL || tcount < 0) return (SPI_ERROR_ARGUMENT); @@ -197,7 +197,7 @@ SPI_exec(char *src, int tcount) int SPI_execp(void *plan, char **Values, char *Nulls, int tcount) { - int res; + int res; if (plan == NULL || tcount < 0) return (SPI_ERROR_ARGUMENT); @@ -216,10 +216,10 @@ SPI_execp(void *plan, char **Values, char *Nulls, int tcount) return (res); } -void * +void * SPI_prepare(char *src, int nargs, Oid * argtypes) { - _SPI_plan *plan; + _SPI_plan *plan; if (nargs < 0 || (nargs > 0 && argtypes == NULL)) { @@ -248,10 +248,10 @@ SPI_prepare(char *src, int nargs, Oid * argtypes) } -void * +void * SPI_saveplan(void *plan) { - _SPI_plan *newplan; + _SPI_plan *newplan; if (plan == NULL) { @@ -275,7 +275,7 @@ SPI_saveplan(void *plan) int SPI_fnumber(TupleDesc tupdesc, char *fname) { - int res; + int res; if (_SPI_curid + 1 != _SPI_connected) return (SPI_ERROR_UNCONNECTED); @@ -289,12 +289,12 @@ SPI_fnumber(TupleDesc tupdesc, char *fname) return (SPI_ERROR_NOATTRIBUTE); } -char * +char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) { - char *val; - bool isnull; - Oid foutoid; + char *val; + bool isnull; + Oid foutoid; SPI_result = 0; if (_SPI_curid + 1 != _SPI_connected) @@ -319,10 +319,10 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) return (fmgr(foutoid, val, gettypelem(tupdesc->attrs[fnumber - 1]->atttypid))); } -char * +char * SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull) { - char *val; + char *val; *isnull = true; SPI_result = 0; @@ -340,10 +340,10 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull) return (val); } -char * +char * SPI_gettype(TupleDesc tupdesc, int fnumber) { - HeapTuple typeTuple; + HeapTuple typeTuple; SPI_result = 0; if (_SPI_curid + 1 != _SPI_connected) @@ -391,7 +391,7 @@ SPI_gettypeid(TupleDesc tupdesc, int fnumber) return (tupdesc->attrs[fnumber - 1]->atttypid); } -char * +char * SPI_getrelname(Relation rel) { @@ -414,8 +414,8 @@ SPI_getrelname(Relation rel) void spi_printtup(HeapTuple tuple, TupleDesc tupdesc) { - SPITupleTable *tuptable; - MemoryContext oldcxt; + SPITupleTable *tuptable; + MemoryContext oldcxt; /* * When called by Executor _SPI_curid expected to be equal to @@ -459,18 +459,18 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc) static int _SPI_execute(char *src, int tcount, _SPI_plan * plan) { - QueryTreeList *queryTree_list; - List *planTree_list; - List *ptlist; - QueryDesc *qdesc; - Query *queryTree; - Plan *planTree; - EState *state; - int qlen; - int nargs = 0; - Oid *argtypes = NULL; - int res; - int i; + QueryTreeList *queryTree_list; + List *planTree_list; + List *ptlist; + QueryDesc *qdesc; + Query *queryTree; + Plan *planTree; + EState *state; + int qlen; + int nargs = 0; + Oid *argtypes = NULL; + int res; + int i; /* Increment CommandCounter to see changes made by now */ CommandCounterIncrement(); @@ -502,7 +502,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan) { if (nodeTag(queryTree->utilityStmt) == T_CopyStmt) { - CopyStmt *stmt = (CopyStmt *) (queryTree->utilityStmt); + CopyStmt *stmt = (CopyStmt *) (queryTree->utilityStmt); if (stmt->filename == NULL) return (SPI_ERROR_COPY); @@ -556,17 +556,17 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan) static int _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) { - QueryTreeList *queryTree_list = plan->qtlist; - List *planTree_list = plan->ptlist; - QueryDesc *qdesc; - Query *queryTree; - Plan *planTree; - EState *state; - int nargs = plan->nargs; - int qlen = queryTree_list->len; - int res; - int i, - k; + QueryTreeList *queryTree_list = plan->qtlist; + List *planTree_list = plan->ptlist; + QueryDesc *qdesc; + Query *queryTree; + Plan *planTree; + EState *state; + int nargs = plan->nargs; + int qlen = queryTree_list->len; + int res; + int i, + k; /* Increment CommandCounter to see changes made by now */ CommandCounterIncrement(); @@ -598,7 +598,7 @@ _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) state = CreateExecutorState(); if (nargs > 0) { - ParamListInfo paramLI = (ParamListInfo) palloc((nargs + 1) * + ParamListInfo paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData)); state->es_param_list_info = paramLI; @@ -627,14 +627,14 @@ _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) { - Query *parseTree; - Plan *plan; - int operation; - TupleDesc tupdesc; - bool isRetrieveIntoPortal = false; - bool isRetrieveIntoRelation = false; - char *intoName = NULL; - int res; + Query *parseTree; + Plan *plan; + int operation; + TupleDesc tupdesc; + bool isRetrieveIntoPortal = false; + bool isRetrieveIntoRelation = false; + char *intoName = NULL; + int res; parseTree = queryDesc->parsetree; plan = queryDesc->plantree; @@ -642,34 +642,34 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) switch (operation) { - case CMD_SELECT: - res = SPI_OK_SELECT; - if (parseTree->isPortal) - { - isRetrieveIntoPortal = true; - intoName = parseTree->into; - parseTree->isBinary = false; /* */ + case CMD_SELECT: + res = SPI_OK_SELECT; + if (parseTree->isPortal) + { + isRetrieveIntoPortal = true; + intoName = parseTree->into; + parseTree->isBinary = false; /* */ - return (SPI_ERROR_CURSOR); + return (SPI_ERROR_CURSOR); - } - else if (parseTree->into != NULL) /* select into table */ - { - res = SPI_OK_SELINTO; - isRetrieveIntoRelation = true; - } - break; - case CMD_INSERT: - res = SPI_OK_INSERT; - break; - case CMD_DELETE: - res = SPI_OK_DELETE; - break; - case CMD_UPDATE: - res = SPI_OK_UPDATE; - break; - default: - return (SPI_ERROR_OPUNKNOWN); + } + else if (parseTree->into != NULL) /* select into table */ + { + res = SPI_OK_SELINTO; + isRetrieveIntoRelation = true; + } + break; + case CMD_INSERT: + res = SPI_OK_INSERT; + break; + case CMD_DELETE: + res = SPI_OK_DELETE; + break; + case CMD_UPDATE: + res = SPI_OK_UPDATE; + break; + default: + return (SPI_ERROR_OPUNKNOWN); } if (state == NULL) /* plan preparation */ @@ -725,13 +725,13 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) static void _SPI_fetch(FetchStmt * stmt) { - char *name = stmt->portalname; - int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK; - int count = stmt->howMany; - Portal portal; - QueryDesc *queryDesc; - EState *state; - MemoryContext context; + char *name = stmt->portalname; + int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK; + int count = stmt->howMany; + Portal portal; + QueryDesc *queryDesc; + EState *state; + MemoryContext context; if (name == NULL) elog(FATAL, "SPI_fetch from blank portal unsupported"); @@ -761,10 +761,10 @@ _SPI_fetch(FetchStmt * stmt) #endif -static MemoryContext +static MemoryContext _SPI_execmem() { - MemoryContext oldcxt; + MemoryContext oldcxt; PortalHeapMemory phmem; phmem = PortalGetHeapMemory(_SPI_current->portal); @@ -774,10 +774,10 @@ _SPI_execmem() } -static MemoryContext +static MemoryContext _SPI_procmem() { - MemoryContext oldcxt; + MemoryContext oldcxt; PortalVariableMemory pvmem; pvmem = PortalGetVariableMemory(_SPI_current->portal); @@ -834,12 +834,12 @@ _SPI_end_call(bool procmem) return (0); } -static bool +static bool _SPI_checktuples(bool isRetrieveIntoRelation) { - uint32 processed = _SPI_current->processed; - SPITupleTable *tuptable = _SPI_current->tuptable; - bool failed = false; + uint32 processed = _SPI_current->processed; + SPITupleTable *tuptable = _SPI_current->tuptable; + bool failed = false; if (processed == 0) { @@ -866,9 +866,9 @@ _SPI_checktuples(bool isRetrieveIntoRelation) static _SPI_plan * _SPI_copy_plan(_SPI_plan * plan, bool local) { - _SPI_plan *newplan; - MemoryContext oldcxt; - int i; + _SPI_plan *newplan; + MemoryContext oldcxt; + int i; if (local) oldcxt = MemoryContextSwitchTo((MemoryContext) diff --git a/src/backend/lib/dllist.c b/src/backend/lib/dllist.c index 70feee02bb..8790a84440 100644 --- a/src/backend/lib/dllist.c +++ b/src/backend/lib/dllist.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.6 1997/09/07 04:41:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.7 1997/09/08 02:22:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,10 +18,10 @@ #include <lib/dllist.h> -Dllist * +Dllist * DLNewList(void) { - Dllist *l; + Dllist *l; l = malloc(sizeof(Dllist)); l->dll_head = 0; @@ -34,7 +34,7 @@ DLNewList(void) void DLFreeList(Dllist * l) { - Dlelem *curr; + Dlelem *curr; while ((curr = DLRemHead(l)) != 0) free(curr); @@ -42,10 +42,10 @@ DLFreeList(Dllist * l) free(l); } -Dlelem * +Dlelem * DLNewElem(void *val) { - Dlelem *e; + Dlelem *e; e = malloc(sizeof(Dlelem)); e->dle_next = 0; @@ -61,7 +61,7 @@ DLFreeElem(Dlelem * e) free(e); } -Dlelem * +Dlelem * DLGetHead(Dllist * l) { return (l ? l->dll_head : 0); @@ -69,17 +69,17 @@ DLGetHead(Dllist * l) /* get the value stored in the first element */ #ifdef NOT_USED -void * +void * DLGetHeadVal(Dllist * l) { - Dlelem *e = DLGetHead(l); + Dlelem *e = DLGetHead(l); return (e ? e->dle_val : 0); } #endif -Dlelem * +Dlelem * DLGetTail(Dllist * l) { return (l ? l->dll_tail : 0); @@ -87,23 +87,23 @@ DLGetTail(Dllist * l) /* get the value stored in the first element */ #ifdef NOT_USED -void * +void * DLGetTailVal(Dllist * l) { - Dlelem *e = DLGetTail(l); + Dlelem *e = DLGetTail(l); return (e ? e->dle_val : 0); } #endif -Dlelem * +Dlelem * DLGetPred(Dlelem * e) /* get predecessor */ { return (e ? e->dle_prev : 0); } -Dlelem * +Dlelem * DLGetSucc(Dlelem * e) /* get successor */ { return (e ? e->dle_next : 0); @@ -112,7 +112,7 @@ DLGetSucc(Dlelem * e) /* get successor */ void DLRemove(Dlelem * e) { - Dllist *l; + Dllist *l; if (e->dle_prev) e->dle_prev->dle_next = e->dle_next; @@ -162,11 +162,11 @@ DLAddTail(Dllist * l, Dlelem * e) l->dll_head = l->dll_tail; } -Dlelem * +Dlelem * DLRemHead(Dllist * l) { /* remove and return the head */ - Dlelem *result; + Dlelem *result; if (l->dll_head == 0) return 0; @@ -188,11 +188,11 @@ DLRemHead(Dllist * l) return result; } -Dlelem * +Dlelem * DLRemTail(Dllist * l) { /* remove and return the tail */ - Dlelem *result; + Dlelem *result; if (l->dll_tail == 0) return 0; diff --git a/src/backend/lib/fstack.c b/src/backend/lib/fstack.c index f97d467fe9..f28f24ae14 100644 --- a/src/backend/lib/fstack.c +++ b/src/backend/lib/fstack.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.5 1997/09/07 04:42:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.6 1997/09/08 02:22:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ FixedStackInit(FixedStack stack, Offset offset) Pointer FixedStackPop(FixedStack stack) { - Pointer pointer; + Pointer pointer; AssertArg(FixedStackIsValid(stack)); @@ -75,7 +75,7 @@ FixedStackPop(FixedStack stack) void FixedStackPush(FixedStack stack, Pointer pointer) { - FixedItem item = FixedStackGetItem(stack, pointer); + FixedItem item = FixedStackGetItem(stack, pointer); AssertArg(FixedStackIsValid(stack)); AssertArg(PointerIsValid(pointer)); @@ -96,11 +96,11 @@ FixedStackPush(FixedStack stack, Pointer pointer) * BadArg if stack is invalid. * BadArg if pointer is invalid. */ -static bool +static bool FixedStackContains(FixedStack stack, Pointer pointer) { - FixedItem next; - FixedItem item; + FixedItem next; + FixedItem item; AssertArg(FixedStackIsValid(stack)); AssertArg(PointerIsValid(pointer)); @@ -135,7 +135,7 @@ FixedStackGetTop(FixedStack stack) Pointer FixedStackGetNext(FixedStack stack, Pointer pointer) { - FixedItem item; + FixedItem item; /* AssertArg(FixedStackIsValid(stack)); */ /* AssertArg(PointerIsValid(pointer)); */ diff --git a/src/backend/lib/hasht.c b/src/backend/lib/hasht.c index 4e12dcf30e..3ad58e4e0e 100644 --- a/src/backend/lib/hasht.c +++ b/src/backend/lib/hasht.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.5 1997/09/07 04:42:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.6 1997/09/08 02:22:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,9 +28,9 @@ void HashTableWalk(HTAB * hashtable, HashtFunc function, int arg) { - long *hashent; - long *data; - int keysize; + long *hashent; + long *data; + int keysize; keysize = hashtable->hctl->keysize; hash_seq((HTAB *) NULL); diff --git a/src/backend/lib/lispsort.c b/src/backend/lib/lispsort.c index bf346ecc1a..41c0e934e7 100644 --- a/src/backend/lib/lispsort.c +++ b/src/backend/lib/lispsort.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.5 1997/09/07 04:42:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.6 1997/09/08 02:23:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,15 +29,15 @@ ** as passed into lisp_qsort(), and returns a new list with ** the nodes sorted. The old list is *not* freed or modified (?) */ -List * +List * lisp_qsort(List * the_list, /* the list to be sorted */ int (*compare) ()) /* function to compare two nodes */ { - int i; - size_t num; - List **nodearray; - List *tmp, - *output; + int i; + size_t num; + List **nodearray; + List *tmp, + *output; /* find size of list */ num = length(the_list); diff --git a/src/backend/lib/qsort.c b/src/backend/lib/qsort.c index ff2bbfa16d..14ac14c39d 100644 --- a/src/backend/lib/qsort.c +++ b/src/backend/lib/qsort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.3 1997/09/07 04:42:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.4 1997/09/08 02:23:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; +static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ @@ -67,8 +67,8 @@ static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; */ #define THRESH 4 -static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()); -static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()); +static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()); +static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()); void pg_qsort(void *bot, @@ -129,15 +129,15 @@ pg_qsort(void *bot, static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()) { - register int cnt; + register int cnt; register u_char ch; - register char *top, - *mid, - *t1, - *t2; - register int n1, - n2; - char *bsv; + register char *top, + *mid, + *t1, + *t2; + register int n1, + n2; + char *bsv; /* bot and nmemb must already be set. */ partition: @@ -277,13 +277,13 @@ swap: SWAP(bot, replace); static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()) { - register int cnt; + register int cnt; register u_char ch; - register char *s1, - *s2, - *t1, - *t2, - *top; + register char *s1, + *s2, + *t1, + *t2, + *top; /* * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm S). diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 34108c04c7..639af1854f 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.4 1997/09/07 04:42:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.5 1997/09/08 02:23:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,8 +30,8 @@ StringInfo makeStringInfo() { - StringInfo res; - long size; + StringInfo res; + long size; res = (StringInfo) palloc(sizeof(StringInfoData)); if (res == NULL) @@ -72,9 +72,9 @@ makeStringInfo() void appendStringInfo(StringInfo str, char *buffer) { - int buflen, - newlen; - char *s; + int buflen, + newlen; + char *s; Assert((str != NULL)); diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index ff6711d3b5..f3af7c52cc 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.15 1997/09/07 04:42:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.16 1997/09/08 02:23:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ #include <libpq/hba.h> #include <libpq/password.h> -static int be_getauthsvc(MsgType msgtype); +static int be_getauthsvc(MsgType msgtype); /*---------------------------------------------------------------- * common definitions for generic fe/be routines @@ -81,9 +81,9 @@ static int be_getauthsvc(MsgType msgtype); struct authsvc { - char name[16]; /* service nickname (for command line) */ - MsgType msgtype; /* startup packet header type */ - int allowed; /* initially allowed (before command line + char name[16]; /* service nickname (for command line) */ + MsgType msgtype; /* startup packet header type */ + int allowed; /* initially allowed (before command line * option parsing)? */ }; @@ -99,10 +99,10 @@ struct authsvc */ #if defined(HBA) -static int useHostBasedAuth = 1; +static int useHostBasedAuth = 1; #else -static int useHostBasedAuth = 0; +static int useHostBasedAuth = 0; #endif @@ -125,7 +125,7 @@ static struct authsvc authsvcs[] = { {"password", STARTUP_PASSWORD_MSG, 1} }; -static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); +static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); #ifdef KRB4 /* This has to be ifdef'd out because krb.h does exist. This needs @@ -157,13 +157,13 @@ pg_krb4_recvauth(int sock, struct sockaddr_in * raddr, char *username) { - long krbopts = 0;/* one-way authentication */ - KTEXT_ST clttkt; - char instance[INST_SZ]; - AUTH_DAT auth_data; - Key_schedule key_sched; - char version[KRB_SENDAUTH_VLEN]; - int status; + long krbopts = 0; /* one-way authentication */ + KTEXT_ST clttkt; + char instance[INST_SZ]; + AUTH_DAT auth_data; + Key_schedule key_sched; + char version[KRB_SENDAUTH_VLEN]; + int status; strcpy(instance, "*"); /* don't care, but arg gets expanded * anyway */ @@ -255,10 +255,10 @@ pg_krb4_recvauth(int sock, * krb5_an_to_ln, except that it punts if multiple components are found, * and we can't afford to punt. */ -static char * +static char * pg_an_to_ln(char *aname) { - char *p; + char *p; if ((p = strchr(aname, '/')) || (p = strchr(aname, '@'))) *p = '\0'; @@ -297,16 +297,16 @@ pg_krb5_recvauth(int sock, struct sockaddr_in * raddr, char *username) { - char servbuf[MAXHOSTNAMELEN + 1 + - sizeof(PG_KRB_SRVNAM)]; - char *hostp, - *kusername = (char *) NULL; + char servbuf[MAXHOSTNAMELEN + 1 + + sizeof(PG_KRB_SRVNAM)]; + char *hostp, + *kusername = (char *) NULL; krb5_error_code code; - krb5_principal client, - server; - krb5_address sender_addr; + krb5_principal client, + server; + krb5_address sender_addr; krb5_rdreq_key_proc keyproc = (krb5_rdreq_key_proc) NULL; - krb5_pointer keyprocarg = (krb5_pointer) NULL; + krb5_pointer keyprocarg = (krb5_pointer) NULL; /* |