diff options
Diffstat (limited to 'src/backend/utils')
50 files changed, 1359 insertions, 1257 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 62a977b3fe5..aff5abb5045 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.26 1998/02/25 13:07:43 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.27 1998/02/26 04:36:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -182,7 +182,7 @@ aclparse(char *s, AclItem *aip, unsigned *modechg) * RETURNS: * the new Acl */ -Acl * +Acl * makeacl(int n) { Acl *new_acl; @@ -240,10 +240,10 @@ aclitemin(char *s) * RETURNS: * the new string */ -char * +char * aclitemout(AclItem *aip) { - char *p; + char *p; char *out; HeapTuple htp; unsigned i; @@ -272,12 +272,13 @@ aclitemout(AclItem *aip) #ifdef NOT_USED - When this elog(NOTICE) goes to the libpq client, it crashes the - client because the NOTICE protocol is coming right in the middle - of a request for a field value. We skip the NOTICE for now. + When this elog(NOTICE) goes to the libpq client, + it crashes the + client because the NOTICE protocol is coming right in the middle + of a request for a field value.We skip the NOTICE for now. - elog(NOTICE, "aclitemout: usesysid %d not found", - aip->ai_id); + elog(NOTICE, "aclitemout: usesysid %d not found", + aip->ai_id); #endif @@ -342,7 +343,7 @@ aclitemgt(AclItem *a1, AclItem *a2) (a1->ai_idtype == a2->ai_idtype && a1->ai_id > a2->ai_id)); } -Acl * +Acl * aclownerdefault(char *relname, AclId ownerid) { Acl *acl; @@ -359,7 +360,7 @@ aclownerdefault(char *relname, AclId ownerid) return (acl); } -Acl * +Acl * acldefault(char *relname) { Acl *acl; @@ -373,7 +374,7 @@ acldefault(char *relname) return (acl); } -Acl * +Acl * aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg) { Acl *new_acl; @@ -490,13 +491,13 @@ aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg) * aclinsert * */ -Acl * +Acl * aclinsert(Acl *old_acl, AclItem *mod_aip) { return (aclinsert3(old_acl, mod_aip, ACL_MODECHG_EQL)); } -Acl * +Acl * aclremove(Acl *old_acl, AclItem *mod_aip) { Acl *new_acl; @@ -583,7 +584,7 @@ aclcontains(Acl *acl, AclItem *aip) * */ -char * +char * aclmakepriv(char *old_privlist, char new_priv) { char *priv; @@ -636,7 +637,7 @@ aclmakepriv(char *old_privlist, char new_priv) * */ -char * +char * aclmakeuser(char *user_type, char *user) { char *user_list; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index a04a3b6174a..50c42c11207 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.26 1998/02/14 18:00:37 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.27 1998/02/26 04:36:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,8 @@ /*-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-*/ static int _ArrayCount(char *str, int dim[], int typdelim); -static char *_ReadArrayStr(char *arrayStr, int nitems, int ndim, int dim[], +static char * +_ReadArrayStr(char *arrayStr, int nitems, int ndim, int dim[], FmgrInfo *inputproc, Oid typelem, int16 typmod, char typdelim, int typlen, bool typbyval, char typalign, int *nbytes); @@ -90,7 +91,7 @@ static char *array_seek(char *ptr, int eltsize, int nitems); * the internal representation of the input array *-------------------------------------------------------------------- */ -char * +char * array_in(char *string, /* input array in external form */ Oid element_type, /* type OID of an array element */ int16 typmod) @@ -208,7 +209,7 @@ array_in(char *string, /* input array in external form */ /* array not a large object */ dataPtr = (char *) _ReadArrayStr(p, nitems, ndim, dim, &inputproc, typelem, - typmod, typdelim, typlen, typbyval, typalign, + typmod, typdelim, typlen, typbyval, typalign, &nbytes); nbytes += ARR_OVERHEAD(ndim); retval = (ArrayType *) palloc(nbytes); @@ -612,7 +613,7 @@ _CopyArrayEls(char **values, * containing the array in its external format. *------------------------------------------------------------------------- */ -char * +char * array_out(ArrayType *v, Oid element_type) { int typlen; @@ -769,7 +770,7 @@ array_out(ArrayType *v, Oid element_type) * returns the dimension of the array pointed to by "v" *---------------------------------------------------------------------------- */ -char * +char * array_dims(ArrayType *v, bool *isNull) { char *p, @@ -1071,7 +1072,7 @@ array_clip(ArrayType *array, * returns a pointer to the modified array. *----------------------------------------------------------------------------- */ -char * +char * array_set(ArrayType *array, int n, int indx[], @@ -1206,7 +1207,7 @@ array_set(ArrayType *array, * returns a pointer to the modified array. *---------------------------------------------------------------------------- */ -char * +char * array_assgn(ArrayType *array, int n, int upperIndx[], @@ -1722,7 +1723,7 @@ _LOtransfer(char **destfd, #undef MAX_READ } -char * +char * _array_newLO(int *fd, int flag) { char *p; diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c index fbfaa6973d4..e781dbe59f1 100644 --- a/src/backend/utils/adt/bool.c +++ b/src/backend/utils/adt/bool.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.13 1998/01/05 16:39:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.14 1998/02/26 04:36:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,9 +33,10 @@ bool boolin(char *b) { - switch(*b) { - case 't': - case 'T': + switch (*b) + { + case 't': + case 'T': if (strncasecmp(b, "true", strlen(b)) == 0) return (TRUE); break; @@ -72,10 +73,10 @@ boolin(char *b) break; } - elog(ERROR,"Bad boolean external representation '%s'", b); + elog(ERROR, "Bad boolean external representation '%s'", b); /* not reached */ return (FALSE); -} /* boolin() */ +} /* boolin() */ /* * boolout - converts 1 or 0 to "t" or "f" @@ -88,7 +89,7 @@ boolout(bool b) *result = (b) ? 't' : 'f'; result[1] = '\0'; return (result); -} /* boolout() */ +} /* boolout() */ /***************************************************************************** @@ -122,11 +123,11 @@ boolgt(bool arg1, bool arg2) bool istrue(bool arg1) { - return(arg1 == TRUE); -} /* istrue() */ + return (arg1 == TRUE); +} /* istrue() */ bool isfalse(bool arg1) { - return(arg1 != TRUE); -} /* isfalse() */ + return (arg1 != TRUE); +} /* isfalse() */ diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 7d2f7b937cf..e9e3a971b49 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.21 1998/01/07 18:46:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.22 1998/02/26 04:36:53 momjian Exp $ */ #include <stdio.h> @@ -34,6 +34,7 @@ static const char *num_word(Cash value); #ifdef USE_LOCALE static struct lconv *lconvert = NULL; + #endif /* cash_in() @@ -46,7 +47,7 @@ static struct lconv *lconvert = NULL; * monetary values returned by localeconv() can be multiple * bytes/characters. This code assumes one byte only. - tgl 97/04/14 */ -Cash * +Cash * cash_in(const char *str) { Cash *result; @@ -73,7 +74,7 @@ cash_in(const char *str) /* frac_digits in the C locale seems to return CHAR_MAX */ /* best guess is 2 in this case I think */ - fpoint = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */ + fpoint = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */ dsymbol = *lconvert->mon_decimal_point; ssymbol = *lconvert->mon_thousands_sep; @@ -90,8 +91,8 @@ cash_in(const char *str) #endif #ifdef CASHDEBUG -printf( "cashin- precision %d; decimal %c; thousands %c; currency %c; positive %c; negative %c\n", - fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol); + printf("cashin- precision %d; decimal %c; thousands %c; currency %c; positive %c; negative %c\n", + fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol); #endif /* we need to add all sorts of checking here. For now just */ @@ -164,7 +165,7 @@ printf( "cashin- precision %d; decimal %c; thousands %c; currency %c; positive % *result = (value * sgn); return (result); -} /* cash_in() */ +} /* cash_in() */ /* cash_out() @@ -201,7 +202,7 @@ cash_out(Cash *in_value) nsymbol = lconvert->negative_sign; /* frac_digits in the C locale seems to return CHAR_MAX */ /* best guess is 2 in this case I think */ - points = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */ + points = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */ convention = lconvert->n_sign_posn; #else mon_group = 3; @@ -276,7 +277,7 @@ cash_out(Cash *in_value) } return (result); -} /* cash_out() */ +} /* cash_out() */ bool @@ -286,7 +287,7 @@ cash_eq(Cash *c1, Cash *c2) return (FALSE); return (*c1 == *c2); -} /* cash_eq() */ +} /* cash_eq() */ bool cash_ne(Cash *c1, Cash *c2) @@ -295,7 +296,7 @@ cash_ne(Cash *c1, Cash *c2) return (FALSE); return (*c1 != *c2); -} /* cash_ne() */ +} /* cash_ne() */ bool cash_lt(Cash *c1, Cash *c2) @@ -304,7 +305,7 @@ cash_lt(Cash *c1, Cash *c2) return (FALSE); return (*c1 < *c2); -} /* cash_lt() */ +} /* cash_lt() */ bool cash_le(Cash *c1, Cash *c2) @@ -313,7 +314,7 @@ cash_le(Cash *c1, Cash *c2) return (FALSE); return (*c1 <= *c2); -} /* cash_le() */ +} /* cash_le() */ bool cash_gt(Cash *c1, Cash *c2) @@ -322,7 +323,7 @@ cash_gt(Cash *c1, Cash *c2) return (FALSE); return (*c1 > *c2); -} /* cash_gt() */ +} /* cash_gt() */ bool cash_ge(Cash *c1, Cash *c2) @@ -331,13 +332,13 @@ cash_ge(Cash *c1, Cash *c2) return (FALSE); return (*c1 >= *c2); -} /* cash_ge() */ +} /* cash_ge() */ /* cash_pl() * Add two cash values. */ -Cash * +Cash * cash_pl(Cash *c1, Cash *c2) { Cash *result; @@ -351,13 +352,13 @@ cash_pl(Cash *c1, Cash *c2) *result = (*c1 + *c2); return (result); -} /* cash_pl() */ +} /* cash_pl() */ /* cash_mi() * Subtract two cash values. */ -Cash * +Cash * cash_mi(Cash *c1, Cash *c2) { Cash *result; @@ -371,13 +372,13 @@ cash_mi(Cash *c1, Cash *c2) *result = (*c1 - *c2); return (result); -} /* cash_mi() */ +} /* cash_mi() */ /* cash_mul_flt8() * Multiply cash by float8. */ -Cash * +Cash * cash_mul_flt8(Cash *c, float8 *f) { Cash *result; @@ -391,17 +392,17 @@ cash_mul_flt8(Cash *c, float8 *f) *result = ((*f) * (*c)); return (result); -} /* cash_mul_flt8() */ +} /* cash_mul_flt8() */ /* flt8_mul_cash() * Multiply float8 by cash. */ -Cash * +Cash * flt8_mul_cash(float8 *f, Cash *c) { return (cash_mul_flt8(c, f)); -} /* flt8_mul_cash() */ +} /* flt8_mul_cash() */ /* cash_div_flt8() @@ -410,7 +411,7 @@ flt8_mul_cash(float8 *f, Cash *c) * XXX Don't know if rounding or truncating is correct behavior. * Round for now. - tgl 97/04/15 */ -Cash * +Cash * cash_div_flt8(Cash *c, float8 *f) { Cash *result; @@ -427,12 +428,12 @@ cash_div_flt8(Cash *c, float8 *f) *result = rint(*c / *f); return (result); -} /* cash_div_flt8() */ +} /* cash_div_flt8() */ /* cash_mul_flt4() * Multiply cash by float4. */ -Cash * +Cash * cash_mul_flt4(Cash *c, float4 *f) { Cash *result; @@ -446,17 +447,17 @@ cash_mul_flt4(Cash *c, float4 *f) *result = ((*f) * (*c)); return (result); -} /* cash_mul_flt4() */ +} /* cash_mul_flt4() */ /* flt4_mul_cash() * Multiply float4 by float4. */ -Cash * +Cash * flt4_mul_cash(float4 *f, Cash *c) { return (cash_mul_flt4(c, f)); -} /* flt4_mul_cash() */ +} /* flt4_mul_cash() */ /* cash_div_flt4() @@ -465,7 +466,7 @@ flt4_mul_cash(float4 *f, Cash *c) * XXX Don't know if rounding or truncating is correct behavior. * Round for now. - tgl 97/04/15 */ -Cash * +Cash * cash_div_flt4(Cash *c, float4 *f) { Cash *result; @@ -482,13 +483,13 @@ cash_div_flt4(Cash *c, float4 *f) *result = rint(*c / *f); return (result); -} /* cash_div_flt4() */ +} /* cash_div_flt4() */ /* cash_mul_int4() * Multiply cash by int4. */ -Cash * +Cash * cash_mul_int4(Cash *c, int4 i) { Cash *result; @@ -502,17 +503,17 @@ cash_mul_int4(Cash *c, int4 i) *result = ((i) * (*c)); return (result); -} /* cash_mul_int4() */ +} /* cash_mul_int4() */ /* int4_mul_cash() * Multiply int4 by cash. */ -Cash * +Cash * int4_mul_cash(int4 i, Cash *c) { return (cash_mul_int4(c, i)); -} /* int4_mul_cash() */ +} /* int4_mul_cash() */ /* cash_div_int4() @@ -521,7 +522,7 @@ int4_mul_cash(int4 i, Cash *c) * XXX Don't know if rounding or truncating is correct behavior. * Round for now. - tgl 97/04/15 */ -Cash * +Cash * cash_div_int4(Cash *c, int4 i) { Cash *result; @@ -538,13 +539,13 @@ cash_div_int4(Cash *c, int4 i) *result = rint(*c / i); return (result); -} /* cash_div_int4() */ +} /* cash_div_int4() */ /* cash_mul_int2() * Multiply cash by int2. */ -Cash * +Cash * cash_mul_int2(Cash *c, int2 s) { Cash *result; @@ -558,17 +559,17 @@ cash_mul_int2(Cash *c, int2 s) *result = ((s) * (*c)); return (result); -} /* cash_mul_int2() */ +} /* cash_mul_int2() */ /* int2_mul_cash() * Multiply int2 by cash. */ -Cash * +Cash * int2_mul_cash(int2 s, Cash *c) { return (cash_mul_int2(c, s)); -} /* int2_mul_cash() */ +} /* int2_mul_cash() */ /* cash_div_int2() @@ -577,7 +578,7 @@ int2_mul_cash(int2 s, Cash *c) * XXX Don't know if rounding or truncating is correct behavior. * Round for now. - tgl 97/04/15 */ -Cash * +Cash * cash_div_int2(Cash *c, int2 s) { Cash *result; @@ -594,13 +595,13 @@ cash_div_int2(Cash *c, int2 s) *result = rint(*c / s); return (result); -} /* cash_div_int2() */ +} /* cash_div_int2() */ /* cashlarger() * Return larger of two cash values. */ -Cash * +Cash * cashlarger(Cash *c1, Cash *c2) { Cash *result; @@ -614,13 +615,13 @@ cashlarger(Cash *c1, Cash *c2) *result = ((*c1 > *c2) ? *c1 : *c2); return (result); -} /* cashlarger() */ +} /* cashlarger() */ /* cashsmaller() * Return smaller of two cash values. */ -Cash * +Cash * cashsmaller(Cash *c1, Cash *c2) { Cash *result; @@ -634,7 +635,7 @@ cashsmaller(Cash *c1, Cash *c2) *result = ((*c1 < *c2) ? *c1 : *c2); return (result); -} /* cashsmaller() */ +} /* cashsmaller() */ /* cash_words_out() @@ -691,7 +692,7 @@ cash_words_out(Cash *value) strcat(buf, m0 == 1 ? " cent" : " cents"); *buf = toupper(*buf); return (buf); -} /* cash_words_out() */ +} /* cash_words_out() */ /************************************************************************* @@ -749,4 +750,4 @@ num_word(Cash value) } return (buf); -} /* num_word() */ +} /* num_word() */ diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index cb715cd7c7f..23bfd4c20b0 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.14 1997/11/02 15:25:57 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.15 1998/02/26 04:36:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ charin(char *ch) /* * charout - converts 'x' to "x" */ -char * +char * charout(int32 ch) { char *result = (char *) palloc(2); @@ -75,7 +75,7 @@ cidin(char *s) * NOTE: we must no use 'charout' because cid might be a non * printable character... */ -char * +char * cidout(int32 c) { char *result; @@ -93,7 +93,7 @@ cidout(int32 c) * Note: * Currently if strlen(s) < 14, the extra chars are nulls */ -char * +char * char16in(char *s) { char *result; @@ -108,7 +108,7 @@ char16in(char *s) /* * char16out - converts internal reprsentation to "..." */ -char * +char * char16out(char *s) { char *result = (char *) palloc(17); @@ -272,7 +272,7 @@ char2in(char *s) return (res); } -char * +char * char2out(uint16 s) { char *result = (char *) palloc(3); @@ -338,7 +338,7 @@ char4in(char *s) return (res); } -char * +char * char4out(s) uint32 s; { @@ -392,7 +392,7 @@ char4cmp(uint32 a, uint32 b) } /* ============================== char8 ============================== */ -char * +char * char8in(char *s) { char *result; @@ -405,7 +405,7 @@ char8in(char *s) return (result); } -char * +char * char8out(char *s) { char *result = (char *) palloc(9); diff --git a/src/backend/utils/adt/chunk.c b/src/backend/utils/adt/chunk.c index 9f38f5caadb..2eeebfb12d7 100644 --- a/src/backend/utils/adt/chunk.c +++ b/src/backend/utils/adt/chunk.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.15 1998/02/11 19:12:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.16 1998/02/26 04:36:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,7 +70,7 @@ GetChunkSize(FILE *fd, int ndim, int dim[MAXDIM], int baseSize, * information about the chunked file *----------------------------------------------------------------------- */ -char * +char * _ChunkArray(int fd, FILE *afd, int ndim, @@ -191,7 +191,7 @@ _FindBestChunk(int size, * compute the number of page fetches for a given chunk size (d[]) * and access pattern (A[][]) */ - int i, + int i, j, nc; @@ -224,7 +224,7 @@ _FindBestChunk(int size, static int get_next(int d[], int k, int C, int dmax[]) { - int i, + int i, j, temp; @@ -266,7 +266,8 @@ get_next(int d[], int k, int C, int dmax[]) } #ifdef LOARRAY -static char a_chunk[BLCKSZ + VARHDRSZ];/* VARHDRSZ since a_chunk is in varlena format */ +static char a_chunk[BLCKSZ + VARHDRSZ]; /* VARHDRSZ since a_chunk is in + * varlena format */ #endif diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index e3dadad0f94..6b7c24c5488 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.23 1998/02/11 19:12:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.24 1998/02/26 04:36:57 momjian Exp $ * * NOTES * This code is actually (almost) unused. @@ -155,13 +155,13 @@ reltimein(char *str) elog(ERROR, "Bad reltime (internal coding error) '%s'", str); return (INVALID_RELTIME); -} /* reltimein() */ +} /* reltimein() */ /* * reltimeout - converts the internal format to a reltime string */ -char * +char * reltimeout(int32 time) { char *result; @@ -184,7 +184,7 @@ reltimeout(int32 time) strcpy(result, buf); return (result); -} /* reltimeout() */ +} /* reltimeout() */ #define TMODULO(t,q,u) {q = (t / u); \ @@ -201,12 +201,12 @@ reltime2tm(int32 time, struct tm * tm) TMODULO(time, tm->tm_sec, 1); return; -} /* reltime2tm() */ +} /* reltime2tm() */ #if FALSE char *timestring; long quantity; -int i; +int i; int unitnr; timestring = (char *) palloc(Max(strlen(INVALID_RELTIME_STR), @@ -274,7 +274,7 @@ tintervalin(char *intervalstr) * tintervalout - converts an internal interval format to a string * */ -char * +char * tintervalout(TimeInterval interval) { char *i_str, @@ -350,7 +350,7 @@ timespan_reltime(TimeSpan *timespan) } return (time); -} /* timespan_reltime() */ +} /* timespan_reltime() */ TimeSpan * @@ -378,7 +378,7 @@ reltime_timespan(RelativeTime reltime) } return (result); -} /* reltime_timespan() */ +} /* reltime_timespan() */ /* @@ -575,7 +575,7 @@ intervalsame(TimeInterval i1, TimeInterval i2) return (FALSE); /* invalid interval */ return (abstimeeq(i1->data[0], i2->data[0]) && abstimeeq(i1->data[1], i2->data[1])); -} /* intervalsame() */ +} /* intervalsame() */ /* @@ -585,7 +585,10 @@ intervalsame(TimeInterval i1, TimeInterval i2) bool intervaleq(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -596,7 +599,7 @@ intervaleq(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -608,8 +611,8 @@ intervaleq(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) == (t21-t20)); -} /* intervaleq() */ + return ((t11 - t10) == (t21 - t20)); +} /* intervaleq() */ /* * intervalne - returns 1, iff interval i1 is not equal to interval i2 @@ -618,7 +621,10 @@ intervaleq(TimeInterval i1, TimeInterval i2) bool intervalne(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -629,7 +635,7 @@ intervalne(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -641,8 +647,8 @@ intervalne(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) != (t21-t20)); -} /* intervalne() */ + return ((t11 - t10) != (t21 - t20)); +} /* intervalne() */ /* * intervallt - returns TRUE, iff interval i1 is less than interval i2 @@ -651,7 +657,10 @@ intervalne(TimeInterval i1, TimeInterval i2) bool intervallt(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -662,7 +671,7 @@ intervallt(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -674,8 +683,8 @@ intervallt(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) < (t21-t20)); -} /* intervallt() */ + return ((t11 - t10) < (t21 - t20)); +} /* intervallt() */ /* * intervalle - returns TRUE, iff interval i1 is less than or equal to interval i2 @@ -684,7 +693,10 @@ intervallt(TimeInterval i1, TimeInterval i2) bool intervalle(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -695,7 +707,7 @@ intervalle(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -707,8 +719,8 @@ intervalle(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) <= (t21-t20)); -} /* intervalle() */ + return ((t11 - t10) <= (t21 - t20)); +} /* intervalle() */ /* * intervalgt - returns TRUE, iff interval i1 is less than interval i2 @@ -717,7 +729,10 @@ intervalle(TimeInterval i1, TimeInterval i2) bool intervalgt(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -728,7 +743,7 @@ intervalgt(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -740,8 +755,8 @@ intervalgt(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) > (t21-t20)); -} /* intervalgt() */ + return ((t11 - t10) > (t21 - t20)); +} /* intervalgt() */ /* * intervalge - returns TRUE, iff interval i1 is less than or equal to interval i2 @@ -750,7 +765,10 @@ intervalgt(TimeInterval i1, TimeInterval i2) bool intervalge(TimeInterval i1, TimeInterval i2) { - AbsoluteTime t10, t11, t20, t21; + AbsoluteTime t10, + t11, + t20, + t21; if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) return (FALSE); /* invalid interval */ @@ -761,7 +779,7 @@ intervalge(TimeInterval i1, TimeInterval i2) t21 = i2->data[1]; if ((t10 == INVALID_ABSTIME) || (t20 == INVALID_ABSTIME) - || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) + || (t20 == INVALID_ABSTIME) || (t21 == INVALID_ABSTIME)) return (FALSE); if (t10 == CURRENT_ABSTIME) @@ -773,8 +791,8 @@ intervalge(TimeInterval i1, TimeInterval i2) if (t21 == CURRENT_ABSTIME) t21 = GetCurrentTransactionStartTime(); - return ((t11-t10) >= (t21-t20)); -} /* intervalge() */ + return ((t11 - t10) >= (t21 - t20)); +} /* intervalge() */ /* @@ -963,11 +981,11 @@ isreltime(char *str) } return 0; -} /* isreltime() */ +} /* isreltime() */ #if FALSE -char *p; -char c; +char *p; +char c; int i; char unit[UNITMAXLEN]; char direction[DIRMAXLEN]; @@ -1156,9 +1174,9 @@ istinterval(char *i_string, AbsoluteTime *i_start, AbsoluteTime *i_end) { - char *p, + char *p, *p1; - char c; + char c; p = i_string; /* skip leading blanks up to '[' */ @@ -1259,7 +1277,7 @@ istinterval(char *i_string, * the Wisconsin benchmark with Illustra whose TimeNow() shows current * time with precision up to microsecs.) - ay 3/95 */ -text * +text * timeofday(void) { diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 4e6cea8db5c..2acf11e50bc 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.21 1998/01/07 18:46:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.22 1998/02/26 04:36:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,7 +110,7 @@ date_in(char *str) date = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1)); return (date); -} /* date_in() */ +} /* date_in() */ /* date_out() * Given internal format date, convert to text string. @@ -133,7 +133,7 @@ date_out(DateADT date) strcpy(result, buf); return (result); -} /* date_out() */ +} /* date_out() */ bool date_eq(DateADT dateVal1, DateADT dateVal2) @@ -151,25 +151,25 @@ bool date_lt(DateADT dateVal1, DateADT dateVal2) { return (dateVal1 < dateVal2); -} /* date_lt() */ +} /* date_lt() */ bool date_le(DateADT dateVal1, DateADT dateVal2) { return (dateVal1 <= dateVal2); -} /* date_le() */ +} /* date_le() */ bool date_gt(DateADT dateVal1, DateADT dateVal2) { return (dateVal1 > dateVal2); -} /* date_gt() */ +} /* date_gt() */ bool date_ge(DateADT dateVal1, DateADT dateVal2) { return (dateVal1 >= dateVal2); -} /* date_ge() */ +} /* date_ge() */ int date_cmp(DateADT dateVal1, DateADT dateVal2) @@ -183,19 +183,19 @@ date_cmp(DateADT dateVal1, DateADT dateVal2) return 1; } return 0; -} /* date_cmp() */ +} /* date_cmp() */ DateADT date_larger(DateADT dateVal1, DateADT dateVal2) { return (date_gt(dateVal1, dateVal2) ? dateVal1 : dateVal2); -} /* date_larger() */ +} /* date_larger() */ DateADT date_smaller(DateADT dateVal1, DateADT dateVal2) { return (date_lt(dateVal1, dateVal2) ? dateVal1 : dateVal2); -} /* date_smaller() */ +} /* date_smaller() */ /* Compute difference between two dates in days. */ @@ -203,7 +203,7 @@ int4 date_mi(DateADT dateVal1, DateADT dateVal2) { return (dateVal1 - dateVal2); -} /* date_mi() */ +} /* date_mi() */ /* Add a number of days to a date, giving a new date. * Must handle both positive and negative numbers of days. @@ -212,7 +212,7 @@ DateADT date_pli(DateADT dateVal, int4 days) { return (dateVal + days); -} /* date_pli() */ +} /* date_pli() */ /* Subtract a number of days from a date, giving a new date. */ @@ -220,13 +220,13 @@ DateADT date_mii(DateADT dateVal, int4 days) { return (date_pli(dateVal, -days)); -} /* date_mii() */ +} /* date_mii() */ /* date_datetime() * Convert date to datetime data type. */ -DateTime * +DateTime * date_datetime(DateADT dateVal) { DateTime *result; @@ -250,7 +250,7 @@ date_datetime(DateADT dateVal) elog(ERROR, "Datetime out of range", NULL); return (result); -} /* date_datetime() */ +} /* date_datetime() */ /* datetime_date() @@ -291,7 +291,7 @@ datetime_date(DateTime *datetime) result = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1)); return (result); -} /* datetime_date() */ +} /* datetime_date() */ /* abstime_date() @@ -333,7 +333,7 @@ abstime_date(AbsoluteTime abstime) } return (result); -} /* abstime_date() */ +} /* abstime_date() */ /* date2tm() @@ -416,7 +416,7 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn) } return 0; -} /* date2tm() */ +} /* date2tm() */ /***************************************************************************** @@ -424,7 +424,7 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn) *****************************************************************************/ -TimeADT * +TimeADT * time_in(char *str) { TimeADT *time; @@ -458,7 +458,7 @@ time_in(char *str) *time = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec); return (time); -} /* time_in() */ +} /* time_in() */ char * @@ -487,7 +487,7 @@ time_out(TimeADT *time) strcpy(result, buf); return (result); -} /* time_out() */ +} /* time_out() */ bool @@ -497,7 +497,7 @@ time_eq(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 == *time2); -} /* time_eq() */ +} /* time_eq() */ bool time_ne(TimeADT *time1, TimeADT *time2) @@ -506,7 +506,7 @@ time_ne(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 != *time2); -} /* time_eq() */ +} /* time_eq() */ bool time_lt(TimeADT *time1, TimeADT *time2) @@ -515,7 +515,7 @@ time_lt(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 < *time2); -} /* time_eq() */ +} /* time_eq() */ bool time_le(TimeADT *time1, TimeADT *time2) @@ -524,7 +524,7 @@ time_le(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 <= *time2); -} /* time_eq() */ +} /* time_eq() */ bool time_gt(TimeADT *time1, TimeADT *time2) @@ -533,7 +533,7 @@ time_gt(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 > *time2); -} /* time_eq() */ +} /* time_eq() */ bool time_ge(TimeADT *time1, TimeADT *time2) @@ -542,22 +542,22 @@ time_ge(TimeADT *time1, TimeADT *time2) return (FALSE); return (*time1 >= *time2); -} /* time_eq() */ +} /* time_eq() */ int time_cmp(TimeADT *time1, TimeADT *time2) { return ((*time1 < *time2) ? -1 : (((*time1 > *time2) ? 1 : 0))); -} /* time_cmp() */ +} /* time_cmp() */ /* datetime_time() * Convert datetime to time data type. */ -TimeADT * +TimeADT * datetime_time(DateTime *datetime) { - TimeADT *result; + TimeADT *result; struct tm tt, *tm = &tt; int tz; @@ -591,13 +591,13 @@ datetime_time(DateTime *datetime) *result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec); return (result); -} /* datetime_time() */ +} /* datetime_time() */ /* datetime_datetime() * Convert date and time to datetime data type. */ -DateTime * +DateTime * datetime_datetime(DateADT date, TimeADT *time) { DateTime *result; @@ -606,13 +606,15 @@ datetime_datetime(DateADT date, TimeADT *time) { result = palloc(sizeof(DateTime)); DATETIME_INVALID(*result); - } else { + } + else + { result = date_datetime(date); *result += *time; } return (result); -} /* datetime_datetime() */ +} /* datetime_datetime() */ int32 /* RelativeTime */ diff --git a/src/backend/utils/adt/dt.c b/src/backend/utils/adt/dt.c index b80d08ea9a7..9e30ca5bd09 100644 --- a/src/backend/utils/adt/dt.c +++ b/src/backend/utils/adt/dt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.51 1998/02/11 19:12:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.52 1998/02/26 04:37:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,24 +31,24 @@ #endif #include "utils/builtins.h" -static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); +static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); static int DecodeNumber(int flen, char *field, int fmask, int *tmask, struct tm * tm, double *fsec); static int DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, double *fsec); -static int DecodeSpecial(int field, char *lowtoken, int *val); +static int DecodeSpecial(int field, char *lowtoken, int *val); static int DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec); -static int DecodeTimezone(char *str, int *tzp); -static int DecodeUnits(int field, char *lowtoken, int *val); -static int EncodeSpecialDateTime(DateTime dt, char *str); +static int DecodeTimezone(char *str, int *tzp); +static int DecodeUnits(int field, char *lowtoken, int *val); +static int EncodeSpecialDateTime(DateTime dt, char *str); static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel); static DateTime dt2local(DateTime dt, int timezone); static void dt2time(DateTime dt, int *hour, int *min, double *sec); -static int j2day(int jd); +static int j2day(int jd); #define USE_DATE_CACHE 1 #define ROUND_ALL 0 @@ -154,12 +154,12 @@ datetime_in(char *str) } return (result); -} /* datetime_in() */ +} /* datetime_in() */ /* datetime_out() * Convert a datetime to external form. */ -char * +char * datetime_out(DateTime *dt) { char *result; @@ -193,7 +193,7 @@ datetime_out(DateTime *dt) strcpy(result, buf); return (result); -} /* datetime_out() */ +} /* datetime_out() */ /* timespan_in() @@ -250,12 +250,12 @@ timespan_in(char *str) } return (span); -} /* timespan_in() */ +} /* timespan_in() */ /* timespan_out() * Convert a time span to external form. */ -char * +char * timespan_out(TimeSpan *span) { char *result; @@ -278,7 +278,7 @@ timespan_out(TimeSpan *span) strcpy(result, buf); return (result); -} /* timespan_out() */ +} /* timespan_out() */ /***************************************************************************** @@ -293,7 +293,7 @@ datetime_finite(DateTime *datetime) return FALSE; return (!DATETIME_NOT_FINITE(*datetime)); -} /* datetime_finite() */ +} /* datetime_finite() */ bool timespan_finite(TimeSpan *timespan) @@ -302,7 +302,7 @@ timespan_finite(TimeSpan *timespan) return FALSE; return (!TIMESPAN_NOT_FINITE(*timespan)); -} /* timespan_finite() */ +} /* timespan_finite() */ /*---------------------------------------------------------- @@ -334,7 +334,7 @@ GetEpochTime(struct tm * tm) #endif return; -} /* GetEpochTime() */ +} /* GetEpochTime() */ DateTime SetDateTime(DateTime dt) @@ -361,7 +361,7 @@ SetDateTime(DateTime dt) } return (dt); -} /* SetDateTime() */ +} /* SetDateTime() */ /* datetime_relop - is datetime1 relop datetime2 */ @@ -386,7 +386,7 @@ datetime_eq(DateTime *datetime1, DateTime *datetime2) dt2 = SetDateTime(dt2); return (dt1 == dt2); -} /* datetime_eq() */ +} /* datetime_eq() */ bool datetime_ne(DateTime *datetime1, DateTime *datetime2) @@ -409,7 +409,7 @@ datetime_ne(DateTime *datetime1, DateTime *datetime2) dt2 = SetDateTime(dt2); return (dt1 != dt2); -} /* datetime_ne() */ +} /* datetime_ne() */ bool datetime_lt(DateTime *datetime1, DateTime *datetime2) @@ -432,7 +432,7 @@ datetime_lt(DateTime *datetime1, DateTime *datetime2) dt2 = SetDateTime(dt2); return (dt1 < dt2); -} /* datetime_lt() */ +} /* datetime_lt() */ bool datetime_gt(DateTime *datetime1, DateTime *datetime2) @@ -458,7 +458,7 @@ datetime_gt(DateTime *datetime1, DateTime *datetime2) printf("datetime_gt- %f %s greater than %f\n", dt1, ((dt1 > dt2) ? "is" : "is not"), dt2); #endif return (dt1 > dt2); -} /* datetime_gt() */ +} /* datetime_gt() */ bool datetime_le(DateTime *datetime1, DateTime *datetime2) @@ -481,7 +481,7 @@ datetime_le(DateTime *datetime1, DateTime *datetime2) dt2 = SetDateTime(dt2); return (dt1 <= dt2); -} /* datetime_le() */ +} /* datetime_le() */ bool datetime_ge(DateTime *datetime1, DateTime *datetime2) @@ -504,7 +504,7 @@ datetime_ge(DateTime *datetime1, DateTime *datetime2) dt2 = SetDateTime(dt2); return (dt1 >= dt2); -} /* datetime_ge() */ +} /* datetime_ge() */ /* datetime_cmp - 3-state comparison for datetime @@ -541,7 +541,7 @@ datetime_cmp(DateTime *datetime1, DateTime *datetime2) } return (((dt1 < dt2) ? -1 : ((dt1 > dt2) ? 1 : 0))); -} /* datetime_cmp() */ +} /* datetime_cmp() */ /* timespan_relop - is timespan1 relop timespan2 @@ -557,7 +557,7 @@ timespan_eq(TimeSpan *timespan1, TimeSpan *timespan2) return ((timespan1->time == timespan2->time) && (timespan1->month == timespan2->month)); -} /* timespan_eq() */ +} /* timespan_eq() */ bool timespan_ne(TimeSpan *timespan1, TimeSpan *timespan2) @@ -570,7 +570,7 @@ timespan_ne(TimeSpan *timespan1, TimeSpan *timespan2) return ((timespan1->time != timespan2->time) || (timespan1->month != timespan2->month)); -} /* timespan_ne() */ +} /* timespan_ne() */ bool timespan_lt(TimeSpan *timespan1, TimeSpan *timespan2) @@ -592,7 +592,7 @@ timespan_lt(TimeSpan *timespan1, TimeSpan *timespan2) span2 += (timespan2->month * (30.0 * 86400)); return (span1 < span2); -} /* timespan_lt() */ +} /* timespan_lt() */ bool timespan_gt(TimeSpan *timespan1, TimeSpan *timespan2) @@ -614,7 +614,7 @@ timespan_gt(TimeSpan *timespan1, TimeSpan *timespan2) span2 += (timespan2->month * (30.0 * 86400)); return (span1 > span2); -} /* timespan_gt() */ +} /* timespan_gt() */ bool timespan_le(TimeSpan *timespan1, TimeSpan *timespan2) @@ -636,7 +636,7 @@ timespan_le(TimeSpan *timespan1, TimeSpan *timespan2) span2 += (timespan2->month * (30.0 * 86400)); return (span1 <= span2); -} /* timespan_le() */ +} /* timespan_le() */ bool timespan_ge(TimeSpan *timespan1, TimeSpan *timespan2) @@ -658,7 +658,7 @@ timespan_ge(TimeSpan *timespan1, TimeSpan *timespan2) span2 += (timespan2->month * (30.0 * 86400)); return (span1 >= span2); -} /* timespan_ge() */ +} /* timespan_ge() */ /* timespan_cmp - 3-state comparison for timespan @@ -690,7 +690,7 @@ timespan_cmp(TimeSpan *timespan1, TimeSpan *timespan2) span2 += (timespan2->month * (30.0 * 86400)); return ((span1 < span2) ? -1 : (span1 > span2) ? 1 : 0); -} /* timespan_cmp() */ +} /* timespan_cmp() */ /*---------------------------------------------------------- @@ -736,7 +736,7 @@ datetime_smaller(DateTime *datetime1, DateTime *datetime2) } return (result); -} /* datetime_smaller() */ +} /* datetime_smaller() */ DateTime * datetime_larger(DateTime *datetime1, DateTime *datetime2) @@ -773,7 +773,7 @@ datetime_larger(DateTime *datetime1, DateTime *datetime2) } return (result); -} /* datetime_larger() */ +} /* datetime_larger() */ TimeSpan * @@ -814,7 +814,7 @@ datetime_mi(DateTime *datetime1, DateTime *datetime2) result->month = 0; return (result); -} /* datetime_mi() */ +} /* datetime_mi() */ /* datetime_pl_span() @@ -917,7 +917,7 @@ datetime_pl_span(DateTime *datetime, TimeSpan *span) } return (result); -} /* datetime_pl_span() */ +} /* datetime_pl_span() */ DateTime * datetime_mi_span(DateTime *datetime, TimeSpan *span) @@ -934,7 +934,7 @@ datetime_mi_span(DateTime *datetime, TimeSpan *span) result = datetime_pl_span(datetime, &tspan); return (result); -} /* datetime_mi_span() */ +} /* datetime_mi_span() */ TimeSpan * @@ -951,7 +951,7 @@ timespan_um(TimeSpan *timespan) result->month = -(timespan->month); return (result); -} /* timespan_um() */ +} /* timespan_um() */ TimeSpan * @@ -1007,7 +1007,7 @@ timespan_smaller(TimeSpan *timespan1, TimeSpan *timespan2) } return (result); -} /* timespan_smaller() */ +} /* timespan_smaller() */ TimeSpan * timespan_larger(TimeSpan *timespan1, TimeSpan *timespan2) @@ -1062,7 +1062,7 @@ timespan_larger(TimeSpan *timespan1, TimeSpan *timespan2) } return (result); -} /* timespan_larger() */ +} /* timespan_larger() */ TimeSpan * @@ -1079,7 +1079,7 @@ timespan_pl(TimeSpan *span1, TimeSpan *span2) result->time = JROUND(span1->time + span2->time); return (result); -} /* timespan_pl() */ +} /* timespan_pl() */ TimeSpan * timespan_mi(TimeSpan *span1, TimeSpan *span2) @@ -1095,7 +1095,7 @@ timespan_mi(TimeSpan *span1, TimeSpan *span2) result->time = JROUND(span1->time - span2->time); return (result); -} /* timespan_mi() */ +} /* timespan_mi() */ TimeSpan * timespan_div(TimeSpan *span1, float8 *arg2) @@ -1115,7 +1115,7 @@ timespan_div(TimeSpan *span1, float8 *arg2) result->time = JROUND(span1->time / *arg2); return (result); -} /* timespan_div() */ +} /* timespan_div() */ /* datetime_age() * Calculate time difference while retaining year/month fields. @@ -1259,7 +1259,7 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) } return (result); -} /* datetime_age() */ +} /* datetime_age() */ /*---------------------------------------------------------- @@ -1270,7 +1270,7 @@ datetime_age(DateTime *datetime1, DateTime *datetime2) /* datetime_text() * Convert datetime to text data type. */ -text * +text * datetime_text(DateTime *datetime) { text *result; @@ -1295,7 +1295,7 @@ datetime_text(DateTime *datetime) pfree(str); return (result); -} /* datetime_text() */ +} /* datetime_text() */ /* text_datetime() @@ -1324,13 +1324,13 @@ text_datetime(text *str) result = datetime_in(dstr); return (result); -} /* text_datetime() */ +} /* text_datetime() */ /* timespan_text() * Convert timespan to text data type. */ -text * +text * timespan_text(TimeSpan *timespan) { text *result; @@ -1355,7 +1355,7 @@ timespan_text(TimeSpan *timespan) pfree(str); return (result); -} /* timespan_text() */ +} /* timespan_text() */ /* text_timespan() @@ -1363,7 +1363,7 @@ timespan_text(TimeSpan *timespan) * Text type may not be null terminated, so copy to temporary string * then call the standard input routine. */ -TimeSpan * +TimeSpan * text_timespan(text *str) { TimeSpan *result; @@ -1384,7 +1384,7 @@ text_timespan(text *str) result = timespan_in(dstr); return (result); -} /* text_timespan() */ +} /* text_timespan() */ /* datetime_trunc() * Extract specified field from datetime. @@ -1532,7 +1532,7 @@ datetime_trunc(text *units, DateTime *datetime) } return (result); -} /* datetime_trunc() */ +} /* datetime_trunc() */ /* timespan_trunc() * Extract specified field from timespan. @@ -1657,7 +1657,7 @@ timespan_trunc(text *units, TimeSpan *timespan) } return (result); -} /* timespan_trunc() */ +} /* timespan_trunc() */ /* datetime_part() @@ -1800,7 +1800,7 @@ datetime_part(text *units, DateTime *datetime) elog(ERROR, "Unable to encode datetime", NULL); *result = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - - date2j(tm->tm_year, 1, 1) + 1); + - date2j(tm->tm_year, 1, 1) + 1); break; default: @@ -1817,7 +1817,7 @@ datetime_part(text *units, DateTime *datetime) } return (result); -} /* datetime_part() */ +} /* datetime_part() */ /* timespan_part() @@ -1954,13 +1954,13 @@ timespan_part(text *units, TimeSpan *timespan) } return (result); -} /* timespan_part() */ +} /* timespan_part() */ /* datetime_zone() * Encode datetime type with specified time zone. */ -text * +text * datetime_zone(text *zone, DateTime *datetime) { text *result; @@ -2044,7 +2044,7 @@ datetime_zone(text *zone, DateTime *datetime) } return (result); -} /* datetime_zone() */ +} /* datetime_zone() */ /***************************************************************************** @@ -2066,222 +2066,238 @@ datetime_zone(text *zone, DateTime *datetime) */ static datetkn datetktbl[] = { /* text token lexval */ - {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */ - {"acsst", DTZ, 63}, /* Cent. Australia */ - {"acst", TZ, 57}, /* Cent. Australia */ - {DA_D, ADBC, AD}, /* "ad" for years >= 0 */ - {"abstime", IGNORE, 0}, /* "abstime" for pre-v6.1 "Invalid Abstime" */ - {"adt", DTZ, NEG(18)}, /* Atlantic Daylight Time */ - {"aesst", DTZ, 66}, /* E. Australia */ - {"aest", TZ, 60}, /* Australia Eastern Std Time */ - {"ahst", TZ, 60}, /* Alaska-Hawaii Std Time */ - {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */ - {"am", AMPM, AM}, - {"apr", MONTH, 4}, - {"april", MONTH, 4}, - {"ast", TZ, NEG(24)}, /* Atlantic Std Time (Canada) */ - {"at", IGNORE, 0}, /* "at" (throwaway) */ - {"aug", MONTH, 8}, - {"august", MONTH, 8}, - {"awsst", DTZ, 54}, /* W. Australia */ - {"awst", TZ, 48}, /* W. Australia */ - {DB_C, ADBC, BC}, /* "bc" for years < 0 */ - {"bst", TZ, 6}, /* British Summer Time */ - {"bt", TZ, 18}, /* Baghdad Time */ - {"cadt", DTZ, 63}, /* Central Australian DST */ - {"cast", TZ, 57}, /* Central Australian ST */ - {"cat", TZ, NEG(60)}, /* Central Alaska Time */ - {"cct", TZ, 48}, /* China Coast */ - {"cdt", DTZ, NEG(30)}, /* Central Daylight Time */ - {"cet", TZ, 6}, /* Central European Time */ - {"cetdst", DTZ, 12}, /* Central European Dayl.Time */ - {"cst", TZ, NEG(36)}, /* Central Standard Time */ - {DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */ - {"dec", MONTH, 12}, - {"december", MONTH, 12}, - {"dnt", TZ, 6}, /* Dansk Normal Tid */ - {"dow", RESERV, DTK_DOW}, /* day of week */ - {"doy", RESERV, DTK_DOY}, /* day of year */ - {"dst", DTZMOD, 6}, - {"east", TZ, NEG(60)}, /* East Australian Std Time */ - {"edt", DTZ, NEG(24)}, /* Eastern Daylight Time */ - {"eet", TZ, 12}, /* East. Europe, USSR Zone 1 */ - {"eetdst", DTZ, 18}, /* Eastern Europe */ - {EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */ + {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */ + {"acsst", DTZ, 63}, /* Cent. Australia */ + {"acst", TZ, 57}, /* Cent. Australia */ + {DA_D, ADBC, AD}, /* "ad" for years >= 0 */ + {"abstime", IGNORE, 0}, /* "abstime" for pre-v6.1 "Invalid + * Abstime" */ + {"adt", DTZ, NEG(18)}, /* Atlantic Daylight Time */ + {"aesst", DTZ, 66}, /* E. Australia */ + {"aest", TZ, 60}, /* Australia Eastern Std Time */ + {"ahst", TZ, 60}, /* Alaska-Hawaii Std Time */ + {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */ + {"am", AMPM, AM}, + {"apr", MONTH, 4}, + {"april", MONTH, 4}, + {"ast", TZ, NEG(24)}, /* Atlantic Std Time (Canada) */ + {"at", IGNORE, 0}, /* "at" (throwaway) */ + {"aug", MONTH, 8}, + {"august", MONTH, 8}, + {"awsst", DTZ, 54}, /* W. Australia */ + {"awst", TZ, 48}, /* W. Australia */ + {DB_C, ADBC, BC}, /* "bc" for years < 0 */ + {"bst", TZ, 6}, /* British Summer Time */ + {"bt", TZ, 18}, /* Baghdad Time */ + {"cadt", DTZ, 63}, /* Central Australian DST */ + {"cast", TZ, 57}, /* Central Australian ST */ + {"cat", TZ, NEG(60)}, /* Central Alaska Time */ + {"cct", TZ, 48}, /* China Coast */ + {"cdt", DTZ, NEG(30)}, /* Central Daylight Time */ + {"cet", TZ, 6}, /* Central European Time */ + {"cetdst", DTZ, 12}, /* Central European Dayl.Time */ + {"cst", TZ, NEG(36)}, /* Central Standard Time */ + {DCURRENT, RESERV, DTK_CURRENT}, /* "current" is always now */ + {"dec", MONTH, 12}, + {"december", MONTH, 12}, + {"dnt", TZ, 6}, /* Dansk Normal Tid */ + {"dow", RESERV, DTK_DOW}, /* day of week */ + {"doy", RESERV, DTK_DOY}, /* day of year */ + {"dst", DTZMOD, 6}, + {"east", TZ, NEG(60)}, /* East Australian Std Time */ + {"edt", DTZ, NEG(24)}, /* Eastern Daylight Time */ + {"eet", TZ, 12}, /* East. Europe, USSR Zone 1 */ + {"eetdst", DTZ, 18}, /* Eastern Europe */ + {EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */ #if USE_AUSTRALIAN_RULES - {"est", TZ, 60}, /* Australia Eastern Std Time */ + {"est", TZ, 60}, /* Australia Eastern Std Time */ #else - {"est", TZ, NEG(30)}, /* Eastern Standard Time */ + {"est", TZ, NEG(30)}, /* Eastern Standard Time */ #endif - {"feb", MONTH, 2}, - {"february", MONTH, 2}, - {"fri", DOW, 5}, - {"friday", DOW, 5}, - {"fst", TZ, 6}, /* French Summer Time */ - {"fwt", DTZ, 12}, /* French Winter Time */ - {"gmt", TZ, 0}, /* Greenwish Mean Time */ - {"gst", TZ, 60}, /* Guam Std Time, USSR Zone 9 */ - {"hdt", DTZ, NEG(54)}, /* Hawaii/Alaska */ - {"hmt", DTZ, 18}, /* Hellas ? ? */ - {"hst", TZ, NEG(60)}, /* Hawaii Std Time */ - {"idle", TZ, 72}, /* Intl. Date Line, East */ - {"idlw", TZ, NEG(72)}, /* Intl. Date Line,, est */ - {LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */ - {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid time */ - {"ist", TZ, 12}, /* Israel */ - {"it", TZ, 22}, /* Iran Time */ - {"jan", MONTH, 1}, - {"january", MONTH, 1}, - {"jst", TZ, 54}, /* Japan Std Time,USSR Zone 8 */ - {"jt", TZ, 45}, /* Java Time */ - {"jul", MONTH, 7}, - {"july", MONTH, 7}, - {"jun", MONTH, 6}, - {"june", MONTH, 6}, - {"kst", TZ, 54}, /* Korea Standard Time */ - {"ligt", TZ, 60}, /* From Melbourne, Australia */ - {"mar", MONTH, 3}, - {"march", MONTH, 3}, - {"may", MONTH, 5}, - {"mdt", DTZ, NEG(36)}, /* Mountain Daylight Time */ - {"mest", DTZ, 12}, /* Middle Europe Summer Time */ - {"met", TZ, 6}, /* Middle Europe Time */ - {"metdst", DTZ, 12}, /* Middle Europe Daylight Time */ - {"mewt", TZ, 6}, /* Middle Europe Winter Time */ - {"mez", TZ, 6}, /* Middle Europe Zone */ - {"mon", DOW, 1}, - {"monday", DOW, 1}, - {"mst", TZ, NEG(42)}, /* Mountain Standard Time */ - {"mt", TZ, 51}, /* Moluccas Time */ - {"ndt", DTZ, NEG(15)}, /* Nfld. Daylight Time */ - {"nft", TZ, NEG(21)}, /* Newfoundland Standard Time */ - {"nor", TZ, 6}, /* Norway Standard Time */ - {"nov", MONTH, 11}, - {"november", MONTH, 11}, - {NOW, RESERV, DTK_NOW}, /* current transaction time */ - {"nst", TZ, NEG(21)}, /* Nfld. Standard Time */ - {"nt", TZ, NEG(66)}, /* Nome Time */ - {"nzdt", DTZ, 78}, /* New Zealand Daylight Time */ - {"nzst", TZ, 72}, /* New Zealand Standard Time */ - {"nzt", TZ, 72}, /* New Zealand Time */ - {"oct", MONTH, 10}, - {"october", MONTH, 10}, - {"on", IGNORE, 0}, /* "on" (throwaway) */ - {"pdt", DTZ, NEG(42)}, /* Pacific Daylight Time */ - {"pm", AMPM, PM}, - {"pst", TZ, NEG(48)}, /* Pacific Standard Time */ - {"sadt", DTZ, 63}, /* S. Australian Dayl. Time */ - {"sast", TZ, 57}, /* South Australian Std Time */ - {"sat", DOW, 6}, - {"saturday", DOW, 6}, - {"sep", MONTH, 9}, - {"sept", MONTH, 9}, - {"september", MONTH, 9}, - {"set", TZ, NEG(6)}, /* Seychelles Time ?? */ - {"sst", DTZ, 12}, /* Swedish Summer Time */ - {"sun", DOW, 0}, - {"sunday", DOW, 0}, - {"swt", TZ, 6}, /* Swedish Winter Time */ - {"thu", DOW, 4}, - {"thur", DOW, 4}, - {"thurs", DOW, 4}, - {"thursday", DOW, 4}, - {TODAY, RESERV, DTK_TODAY}, /* midnight */ - {TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */ - {"tue", DOW, 2}, - {"tues", DOW, 2}, - {"tuesday", DOW, 2}, - {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid time */ - {"ut", TZ, 0}, - {"utc", TZ, 0}, - {"wadt", DTZ, 48}, /* West Australian DST */ - {"wast", TZ, 42}, /* West Australian Std Time */ - {"wat", TZ, NEG(6)}, /* West Africa Time */ - {"wdt", DTZ, 54}, /* West Australian DST */ - {"wed", DOW, 3}, - {"wednesday", DOW, 3}, - {"weds", DOW, 3}, - {"wet", TZ, 0}, /* Western Europe */ - {"wetdst", DTZ, 6}, /* Western Europe */ - {"wst", TZ, 48}, /* West Australian Std Time */ - {"ydt", DTZ, NEG(48)}, /* Yukon Daylight Time */ - {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */ - {"yst", TZ, NEG(54)}, /* Yukon Standard Time */ - {"zp4", TZ, NEG(24)}, /* GMT +4 hours. */ - {"zp5", TZ, NEG(30)}, /* GMT +5 hours. */ - {"zp6", TZ, NEG(36)}, /* GMT +6 hours. */ - {"z", RESERV, DTK_ZULU}, /* 00:00:00 */ - {ZULU, RESERV, DTK_ZULU}, /* 00:00:00 */ + {"feb", MONTH, 2}, + {"february", MONTH, 2}, + {"fri", DOW, 5}, + {"friday", DOW, 5}, + {"fst", TZ, 6}, /* French Summer Time */ + {"fwt", DTZ, 12}, /* French Winter Time */ + {"gmt", TZ, 0}, /* Greenwish Mean Time */ + {"gst", TZ, 60}, /* Guam Std Time, USSR Zone 9 */ + {"hdt", DTZ, NEG(54)}, /* Hawaii/Alaska */ + {"hmt", DTZ, 18}, /* Hellas ? ? */ + {"hst", TZ, NEG(60)}, /* Hawaii Std Time */ + {"idle", TZ, 72}, /* Intl. Date Line, East */ + {"idlw", TZ, NEG(72)}, /* Intl. Date Line,, est */ + {LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */ + {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid + * time */ + {"ist", TZ, 12}, /* Israel */ + {"it", TZ, 22}, /* Iran Time */ + {"jan", MONTH, 1}, + {"january", MONTH, 1}, + {"jst", TZ, 54}, /* Japan Std Time,USSR Zone 8 */ + {"jt", TZ, 45}, /* Java Time */ + {"jul", MONTH, 7}, + {"july", MONTH, 7}, + {"jun", MONTH, 6}, + {"june", MONTH, 6}, + {"kst", TZ, 54}, /* Korea Standard Time */ + {"ligt", TZ, 60}, /* From Melbourne, Australia */ + {"mar", MONTH, 3}, + {"march", MONTH, 3}, + {"may", MONTH, 5}, + {"mdt", DTZ, NEG(36)}, /* Mountain Daylight Time */ + {"mest", DTZ, 12}, /* Middle Europe Summer Time */ + {"met", TZ, 6}, /* Middle Europe Time */ + {"metdst", DTZ, 12}, /* Middle Europe Daylight Time */ + {"mewt", TZ, 6}, /* Middle Europe Winter Time */ + {"mez", TZ, 6}, /* Middle Europe Zone */ + {"mon", DOW, 1}, + {"monday", DOW, 1}, + {"mst", TZ, NEG(42)}, /* Mountain Standard Time */ + {"mt", TZ, 51}, /* Moluccas Time */ + {"ndt", DTZ, NEG(15)}, /* Nfld. Daylight Time */ + {"nft", TZ, NEG(21)}, /* Newfoundland Standard Time */ + {"nor", TZ, 6}, /* Norway Standard Time */ + {"nov", MONTH, 11}, + {"november", MONTH, 11}, + {NOW, RESERV, DTK_NOW}, /* current transaction time */ + {"nst", TZ, NEG(21)}, /* Nfld. Standard Time */ + {"nt", TZ, NEG(66)}, /* Nome Time */ + {"nzdt", DTZ, 78}, /* New Zealand Daylight Time */ + {"nzst", TZ, 72}, /* New Zealand Standard Time */ + {"nzt", TZ, 72}, /* New Zealand Time */ + {"oct", MONTH, 10}, + {"october", MONTH, 10}, + {"on", IGNORE, 0}, /* "on" (throwaway) */ + {"pdt", DTZ, NEG(42)}, /* Pacific Daylight Time */ + {"pm", AMPM, PM}, + {"pst", TZ, NEG(48)}, /* Pacific Standard Time */ + {"sadt", DTZ, 63}, /* S. Australian Dayl. Time */ + {"sast", TZ, 57}, /* South Australian Std Time */ + {"sat", DOW, 6}, + {"saturday", DOW, 6}, + {"sep", MONTH, 9}, + {"sept", MONTH, 9}, + {"september", MONTH, 9}, + {"set", TZ, NEG(6)}, /* Seychelles Time ?? */ + {"sst", DTZ, 12}, /* Swedish Summer Time */ + {"sun", DOW, 0}, + {"sunday", DOW, 0}, + {"swt", TZ, 6}, /* Swedish Winter Time */ + {"thu", DOW, 4}, + {"thur", DOW, 4}, + {"thurs", DOW, 4}, + {"thursday", DOW, 4}, + {TODAY, RESERV, DTK_TODAY}, /* midnight */ + {TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */ + {"tue", DOW, 2}, + {"tues", DOW, 2}, + {"tuesday", DOW, 2}, + {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid + * time */ + {"ut", TZ, 0}, + {"utc", TZ, 0}, + {"wadt", DTZ, 48}, /* West Australian DST */ + {"wast", TZ, 42}, /* West Australian Std Time */ + {"wat", TZ, NEG(6)}, /* West Africa Time */ + {"wdt", DTZ, 54}, /* West Australian DST */ + {"wed", DOW, 3}, + {"wednesday", DOW, 3}, + {"weds", DOW, 3}, + {"wet", TZ, 0}, /* Western Europe */ + {"wetdst", DTZ, 6}, /* Western Europe */ + {"wst", TZ, 48}, /* West Australian Std Time */ + {"ydt", DTZ, NEG(48)}, /* Yukon Daylight Time */ + {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */ + {"yst", TZ, NEG(54)}, /* Yukon Standard Time */ + {"zp4", TZ, NEG(24)}, /* GMT +4 hours. */ + {"zp5", TZ, NEG(30)}, /* GMT +5 hours. */ + {"zp6", TZ, NEG(36)}, /* GMT +6 hours. */ + {"z", RESERV, DTK_ZULU}, /* 00:00:00 */ + {ZULU, RESERV, DTK_ZULU}, /* 00:00:00 */ }; static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; static datetkn deltatktbl[] = { /* text token lexval */ - {"@", IGNORE, 0}, /* postgres relative time prefix */ - {DAGO, AGO, 0}, /* "ago" indicates negative time offset */ - {"c", UNITS, DTK_CENTURY}, /* "century" relative time units */ - {"cent", UNITS, DTK_CENTURY}, /* "century" relative time units */ - {"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative time units */ - {DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative time units */ - {"d", UNITS, DTK_DAY}, /* "day" relative time units */ - {DDAY, UNITS, DTK_DAY}, /* "day" relative time units */ - {"days", UNITS, DTK_DAY}, /* "days" relative time units */ - {"dec", UNITS, DTK_DECADE}, /* "decade" relative time units */ - {"decs", UNITS, DTK_DECADE}, /* "decades" relative time units */ - {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative time units */ - {"decades", UNITS, DTK_DECADE}, /* "decades" relative time units */ - {"h", UNITS, DTK_HOUR}, /* "hour" relative time units */ - {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative time units */ - {"hours", UNITS, DTK_HOUR}, /* "hours" relative time units */ - {"hr", UNITS, DTK_HOUR}, /* "hour" relative time units */ - {"hrs", UNITS, DTK_HOUR}, /* "hours" relative time units */ - {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid time */ - {"m", UNITS, DTK_MINUTE}, /* "minute" relative time units */ - {"microsecon", UNITS, DTK_MILLISEC}, /* "microsecond" relative time units */ - {"mil", UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ - {"mils", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ - {"millenia", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ - {DMILLENIUM, UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ - {"millisecon", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */ - {"min", UNITS, DTK_MINUTE}, /* "minute" relative time units */ - {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative time units */ - {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative time units */ - {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative time units */ - {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative time units */ - {"mon", UNITS, DTK_MONTH}, /* "months" relative time units */ - {"mons", UNITS, DTK_MONTH}, /* "months" relative time units */ - {DMONTH, UNITS, DTK_MONTH}, /* "month" relative time units */ - {"months", UNITS, DTK_MONTH}, /* "months" relative time units */ - {"ms", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */ - {"msec", UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */ - {DMILLISEC, UNITS, DTK_MILLISEC}, /* "millisecond" relative time units */ - {"mseconds", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time units */ - {"msecs", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time units */ - {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative time units */ - {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative time units */ - {"reltime", IGNORE, 0}, /* "reltime" for pre-v6.1 "Undefined Reltime" */ - {"s", UNITS, DTK_SECOND}, /* "second" relative time units */ - {"sec", UNITS, DTK_SECOND}, /* "second" relative time units */ - {DSECOND, UNITS, DTK_SECOND}, /* "second" relative time units */ - {"seconds", UNITS, DTK_SECOND}, /* "seconds" relative time units */ - {"secs", UNITS, DTK_SECOND}, /* "seconds" relative time units */ - {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ - {"tz", UNITS, DTK_TZ}, /* "timezone" time offset */ - {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid time */ - {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */ - {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */ - {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative time units */ - {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative time units */ - {"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative time units */ - {"w", UNITS, DTK_WEEK}, /* "week" relative time units */ - {DWEEK, UNITS, DTK_WEEK}, /* "week" relative time units */ - {"weeks", UNITS, DTK_WEEK}, /* "weeks" relative time units */ - {"y", UNITS, DTK_YEAR}, /* "year" relative time units */ - {DYEAR, UNITS, DTK_YEAR}, /* "year" relative time units */ - {"years", UNITS, DTK_YEAR}, /* "years" relative time units */ - {"yr", UNITS, DTK_YEAR}, /* "year" relative time units */ - {"yrs", UNITS, DTK_YEAR}, /* "years" relative time units */ + {"@", IGNORE, 0}, /* postgres relative time prefix */ + {DAGO, AGO, 0}, /* "ago" indicates negative time offset */ + {"c", UNITS, DTK_CENTURY}, /* "century" relative time units */ + {"cent", UNITS, DTK_CENTURY}, /* "century" relative time units */ + {"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative time units */ + {DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative time units */ + {"d", UNITS, DTK_DAY}, /* "day" relative time units */ + {DDAY, UNITS, DTK_DAY}, /* "day" relative time units */ + {"days", UNITS, DTK_DAY}, /* "days" relative time units */ + {"dec", UNITS, DTK_DECADE}, /* "decade" relative time units */ + {"decs", UNITS, DTK_DECADE},/* "decades" relative time units */ + {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative time units */ + {"decades", UNITS, DTK_DECADE}, /* "decades" relative time units */ + {"h", UNITS, DTK_HOUR}, /* "hour" relative time units */ + {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative time units */ + {"hours", UNITS, DTK_HOUR}, /* "hours" relative time units */ + {"hr", UNITS, DTK_HOUR}, /* "hour" relative time units */ + {"hrs", UNITS, DTK_HOUR}, /* "hours" relative time units */ + {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for invalid + * time */ + {"m", UNITS, DTK_MINUTE}, /* "minute" relative time units */ + {"microsecon", UNITS, DTK_MILLISEC}, /* "microsecond" relative + * time units */ + {"mil", UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ + {"mils", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ + {"millenia", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */ + {DMILLENIUM, UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */ + {"millisecon", UNITS, DTK_MILLISEC}, /* "millisecond" relative + * time units */ + {"min", UNITS, DTK_MINUTE}, /* "minute" relative time units */ + {"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */ + {"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */ + {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative time units */ + {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative time units */ + {"mon", UNITS, DTK_MONTH}, /* "months" relative time units */ + {"mons", UNITS, DTK_MONTH}, /* "months" relative time units */ + {DMONTH, UNITS, DTK_MONTH}, /* "month" relative time units */ + {"months", UNITS, DTK_MONTH}, /* "months" relative time units */ + {"ms", UNITS, DTK_MILLISEC},/* "millisecond" relative time units */ + {"msec", UNITS, DTK_MILLISEC}, /* "millisecond" relative time + * units */ + {DMILLISEC, UNITS, DTK_MILLISEC}, /* "millisecond" relative time + * units */ + {"mseconds", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time + * units */ + {"msecs", UNITS, DTK_MILLISEC}, /* "milliseconds" relative time + * units */ + {"qtr", UNITS, DTK_QUARTER},/* "quarter" relative time units */ + {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative time units */ + {"reltime", IGNORE, 0}, /* "reltime" for pre-v6.1 "Undefined + * Reltime" */ + {"s", UNITS, DTK_SECOND}, /* "second" relative time units */ + {"sec", UNITS, DTK_SECOND}, /* "second" relative time units */ + {DSECOND, UNITS, DTK_SECOND}, /* "second" relative time units */ + {"seconds", UNITS, DTK_SECOND}, /* "seconds" relative time units */ + {"secs", UNITS, DTK_SECOND},/* "seconds" relative time units */ + {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ + {"tz", UNITS, DTK_TZ}, /* "timezone" time offset */ + {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid + * time */ + {"us", UNITS, DTK_MICROSEC},/* "microsecond" relative time units */ + {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative time + * units */ + {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative time + * units */ + {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative time + * units */ + {"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative time + * units */ + {"w", UNITS, DTK_WEEK}, /* "week" relative time units */ + {DWEEK, UNITS, DTK_WEEK}, /* "week" relative time units */ + {"weeks", UNITS, DTK_WEEK}, /* "weeks" relative time units */ + {"y", UNITS, DTK_YEAR}, /* "year" relative time units */ + {DYEAR, UNITS, DTK_YEAR}, /* "year" relative time units */ + {"years", UNITS, DTK_YEAR}, /* "years" relative time units */ + {"yr", UNITS, DTK_YEAR}, /* "year" relative time units */ + {"yrs", UNITS, DTK_YEAR}, /* "years" relative time units */ }; static unsigned int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; @@ -2330,7 +2346,7 @@ date2j(int y, int m, int d) return ((1461 * (y + 4800 + m12)) / 4 + (367 * (m - 2 - 12 * (m12))) / 12 - (3 * ((y + 4900 + m12) / 100)) / 4 + d - 32075); -} /* date2j() */ +} /* date2j() */ void j2date(int jd, int *year, int *month, int *day) @@ -2359,7 +2375,7 @@ j2date(int jd, int *year, int *month, int *day) *month = m; *day = d; return; -} /* j2date() */ +} /* j2date() */ static int j2day(int date) @@ -2369,7 +2385,7 @@ j2day(int date) day = (date + 1) % 7; return (day); -} /* j2day() */ +} /* j2day() */ /* datetime2tm() @@ -2529,7 +2545,7 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn) #endif return 0; -} /* datetime2tm() */ +} /* datetime2tm() */ /* tm2datetime() @@ -2559,7 +2575,7 @@ tm2datetime(struct tm * tm, double fsec, int *tzp, DateTime *result) *result = dt2local(*result, -(*tzp)); return 0; -} /* tm2datetime() */ +} /* tm2datetime() */ /* timespan2tm() @@ -2600,7 +2616,7 @@ timespan2tm(TimeSpan span, struct tm * tm, float8 *fsec) #endif return 0; -} /* timespan2tm() */ +} /* timespan2tm() */ int tm2timespan(struct tm * tm, double fsec, TimeSpan *span) @@ -2615,7 +2631,7 @@ tm2timespan(struct tm * tm, double fsec, TimeSpan *span) #endif return 0; -} /* tm2timespan() */ +} /* tm2timespan() */ static DateTime @@ -2624,13 +2640,13 @@ dt2local(DateTime dt, int tz) dt -= tz; dt = JROUND(dt); return (dt); -} /* dt2local() */ +} /* dt2local() */ double time2t(const int hour, const int min, const double sec) { return ((((hour * 60) + min) * 60) + sec); -} /* time2t() */ +} /* time2t() */ static void dt2time(DateTime jd, int *hour, int *min, double *sec) @@ -2646,7 +2662,7 @@ dt2time(DateTime jd, int *hour, int *min, double *sec) *sec = JROUND(time); return; -} /* dt2time() */ +} /* dt2time() */ /* @@ -2696,14 +2712,22 @@ ParseDateTime(char *timestr, char *lowstr, *lp++ = tolower(*cp++); } - /* otherwise, number only and will determine year, month, or day later */ + + /* + * otherwise, number only and will determine year, month, or + * day later + */ else { ftype[nf] = DTK_NUMBER; } } - /* text? then date string, month, day of week, special, or timezone */ + + /* + * text? then date string, month, day of week, special, or + * timezone + */ else if (isalpha(*cp)) { ftype[nf] = DTK_STRING; @@ -2786,7 +2810,7 @@ ParseDateTime(char *timestr, char *lowstr, *numfields = nf; return 0; -} /* ParseDateTime() */ +} /* ParseDateTime() */ /* DecodeDateTime() @@ -3086,7 +3110,7 @@ DecodeDateTime(char *field[], int ftype[], int nf, } return 0; -} /* DecodeDateTime() */ +} /* DecodeDateTime() */ /* DecodeTimeOnly() @@ -3107,7 +3131,8 @@ DecodeTimeOnly(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, d tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; - tm->tm_isdst = -1; /* don't know daylight savings time status apriori */ + tm->tm_isdst = -1; /* don't know daylight savings time status + * apriori */ *fsec = 0; fmask = DTK_DATE_M; @@ -3211,7 +3236,7 @@ DecodeTimeOnly(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, d return -1; return 0; -} /* DecodeTimeOnly() */ +} /* DecodeTimeOnly() */ /* DecodeDate() @@ -3317,7 +3342,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) } return 0; -} /* DecodeDate() */ +} /* DecodeDate() */ /* DecodeTime() @@ -3376,7 +3401,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec) return -1; return 0; -} /* DecodeTime() */ +} /* DecodeTime() */ /* DecodeNumber() @@ -3505,7 +3530,7 @@ DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double } return 0; -} /* DecodeNumber() */ +} /* DecodeNumber() */ /* DecodeNumberField() @@ -3590,7 +3615,7 @@ DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, dou } return 0; -} /* DecodeNumberField() */ +} /* DecodeNumberField() */ /* DecodeTimezone() @@ -3633,7 +3658,7 @@ DecodeTimezone(char *str, int *tzp) *tzp = -tz; return (*cp != '\0'); -} /* DecodeTimezone() */ +} /* DecodeTimezone() */ /* DecodeSpecial() @@ -3684,7 +3709,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) } return (type); -} /* DecodeSpecial() */ +} /* DecodeSpecial() */ /* DecodeDateDelta() @@ -3692,7 +3717,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) * Return 0 if decoded and -1 if problems. * * Allow "date" field DTK_DATE since this could be just - * an unsigned floating point number. - thomas 1997-11-16 + * an unsigned floating point number. - thomas 1997-11-16 * * If code is changed to read fields from first to last, * then use READ_FORWARD-bracketed code to allow sign @@ -3705,6 +3730,7 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, #if READ_FORWARD int is_neg = FALSE; + #endif char *cp; @@ -3749,7 +3775,8 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, } /* - * read through remaining list backwards to pick up units before values + * read through remaining list backwards to pick up units before + * values */ for (i = nf - 1; i >= ii; i--) { @@ -3809,7 +3836,7 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, break; case DTK_MILLISEC: - *fsec += ((val +fval) * 1e-3); + *fsec += ((val + fval) * 1e-3); break; case DTK_SECOND: @@ -3842,14 +3869,14 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, case DTK_WEEK: tm->tm_mday += val * 7; if (fval != 0) - tm->tm_sec += (fval * (7*86400)); + tm->tm_sec += (fval * (7 * 86400)); tmask = ((fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY)); break; case DTK_MONTH: tm->tm_mon += val; if (fval != 0) - tm->tm_sec += (fval * (30*86400)); + tm->tm_sec += (fval * (30 * 86400)); tmask = DTK_M(MONTH); break; @@ -3959,7 +3986,7 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, /* ensure that at least one time field has been found */ return ((fmask != 0) ? 0 : -1); -} /* DecodeDateDelta() */ +} /* DecodeDateDelta() */ /* DecodeUnits() @@ -4005,7 +4032,7 @@ DecodeUnits(int field, char *lowtoken, int *val) } return (type); -} /* DecodeUnits() */ +} /* DecodeUnits() */ /* datebsearch() @@ -4015,9 +4042,9 @@ DecodeUnits(int field, char *lowtoken, int *val) static datetkn * datebsearch(char *key, datetkn *base, unsigned int nel) { - datetkn *last = base + nel - 1, + datetkn *last = base + nel - 1, *position; - int result; + int result; while (last >= base) { @@ -4082,7 +4109,7 @@ EncodeSpecialDateTime(DateTime dt, char *str) } return (FALSE); -} /* EncodeSpecialDateTime() */ +} /* EncodeSpecialDateTime() */ /* EncodeDateOnly() @@ -4096,17 +4123,17 @@ EncodeDateOnly(struct tm * tm, int style, char *str) switch (style) { - /* compatible with ISO date formats */ + /* compatible with ISO date formats */ case USE_ISO_DATES: if (tm->tm_year > 0) sprintf(str, "%04d-%02d-%02d", - tm->tm_year, tm->tm_mon, tm->tm_mday); + tm->tm_year, tm->tm_mon, tm->tm_mday); else sprintf(str, "%04d-%02d-%02d %s", - -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); + -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); break; - /* compatible with Oracle/Ingres date formats */ + /* compatible with Oracle/Ingres date formats */ case USE_SQL_DATES: if (EuroDates) sprintf(str, "%02d/%02d", tm->tm_mday, tm->tm_mon); @@ -4118,7 +4145,7 @@ EncodeDateOnly(struct tm * tm, int style, char *str) sprintf((str + 5), "/%04d %s", -(tm->tm_year - 1), "BC"); break; - /* German-style date format */ + /* German-style date format */ case USE_GERMAN_DATES: sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon); if (tm->tm_year > 0) @@ -4127,7 +4154,7 @@ EncodeDateOnly(struct tm * tm, int style, char *str) sprintf((str + 5), ".%04d %s", -(tm->tm_year - 1), "BC"); break; - /* traditional date-only style for Postgres */ + /* traditional date-only style for Postgres */ case USE_POSTGRES_DATES: default: if (EuroDates) @@ -4146,7 +4173,7 @@ EncodeDateOnly(struct tm * tm, int style, char *str) #endif return (TRUE); -} /* EncodeDateOnly() */ +} /* EncodeDateOnly() */ /* EncodeTimeOnly() @@ -4170,19 +4197,19 @@ EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str) #endif return (TRUE); -} /* EncodeTimeOnly() */ +} /* EncodeTimeOnly() */ /* EncodeDateTime() * Encode date and time interpreted as local time. * Support several date styles: - * Postgres - day mon hh:mm:ss yyyy tz - * SQL - mm/dd/yyyy hh:mm:ss.ss tz - * ISO - yyyy-mm-dd hh:mm:ss+/-tz - * German - dd.mm/yyyy hh:mm:ss tz + * Postgres - day mon hh:mm:ss yyyy tz + * SQL - mm/dd/yyyy hh:mm:ss.ss tz + * ISO - yyyy-mm-dd hh:mm:ss+/-tz + * German - dd.mm/yyyy hh:mm:ss tz * Variants (affects order of month and day for Postgres and SQL styles): - * US - mm/dd/yyyy - * European - dd/mm/yyyy + * US - mm/dd/yyyy + * European - dd/mm/yyyy */ int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str) @@ -4214,13 +4241,13 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha switch (style) { - /* compatible with ISO date formats */ + /* compatible with ISO date formats */ case USE_ISO_DATES: if (tm->tm_year > 0) { sprintf(str, "%04d-%02d-%02d %02d:%02d:", - tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min); + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min); sprintf((str + 17), ((fsec != 0) ? "%05.2f" : "%02.0f"), sec); if ((*tzn != NULL) && (tm->tm_isdst >= 0)) @@ -4243,14 +4270,14 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha { if (tm->tm_hour || tm->tm_min) sprintf(str, "%04d-%02d-%02d %02d:%02d %s", - -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, "BC"); + -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, "BC"); else sprintf(str, "%04d-%02d-%02d %s", - -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); + -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); } break; - /* compatible with Oracle/Ingres date formats */ + /* compatible with Oracle/Ingres date formats */ case USE_SQL_DATES: if (EuroDates) sprintf(str, "%02d/%02d", tm->tm_mday, tm->tm_mon); @@ -4260,7 +4287,7 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha if (tm->tm_year > 0) { sprintf((str + 5), "/%04d %02d:%02d:%05.2f", - tm->tm_year, tm->tm_hour, tm->tm_min, sec); + tm->tm_year, tm->tm_hour, tm->tm_min, sec); if ((*tzn != NULL) && (tm->tm_isdst >= 0)) { @@ -4271,16 +4298,16 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha } else sprintf((str + 5), "/%04d %02d:%02d %s", - -(tm->tm_year - 1), tm->tm_hour, tm->tm_min, "BC"); + -(tm->tm_year - 1), tm->tm_hour, tm->tm_min, "BC"); break; - /* German variant on European style */ + /* German variant on European style */ case USE_GERMAN_DATES: sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon); if (tm->tm_year > 0) { sprintf((str + 5), ".%04d %02d:%02d:%05.2f", - tm->tm_year, tm->tm_hour, tm->tm_min, sec); + tm->tm_year, tm->tm_hour, tm->tm_min, sec); if ((*tzn != NULL) && (tm->tm_isdst >= 0)) { @@ -4291,10 +4318,10 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha } else sprintf((str + 5), ".%04d %02d:%02d %s", - -(tm->tm_year - 1), tm->tm_hour, tm->tm_min, "BC"); + -(tm->tm_year - 1), tm->tm_hour, tm->tm_min, "BC"); break; - /* backward-compatible with traditional Postgres abstime dates */ + /* backward-compatible with traditional Postgres abstime dates */ case USE_POSTGRES_DATES: default: day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); @@ -4337,7 +4364,7 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha else { sprintf((str + 10), " %02d:%02d %04d %s", - tm->tm_hour, tm->tm_min, -(tm->tm_year - 1), "BC"); + tm->tm_hour, tm->tm_min, -(tm->tm_year - 1), "BC"); } break; } @@ -4347,7 +4374,7 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha #endif return (TRUE); -} /* EncodeDateTime() */ +} /* EncodeDateTime() */ /* EncodeTimeSpan() @@ -4365,9 +4392,9 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str) switch (style) { - /* compatible with ISO date formats */ + /* compatible with ISO date formats */ case USE_ISO_DATES: - break; + break; default: strcpy(cp, "@"); @@ -4401,7 +4428,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str) switch (style) { - /* compatible with ISO date formats */ + /* compatible with ISO date formats */ case USE_ISO_DATES: if ((tm->tm_hour != 0) || (tm->tm_min != 0)) is_nonzero = TRUE; @@ -4486,7 +4513,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str) #endif return 0; -} /* EncodeTimeSpan() */ +} /* EncodeTimeSpan() */ #if defined(linux) && defined(PPC) diff --git a/src/backend/utils/adt/filename.c b/src/backend/utils/adt/filename.c index 1039de0b3c7..77bfa4df4e1 100644 --- a/src/backend/utils/adt/filename.c +++ b/src/backend/utils/adt/filename.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.13 1998/01/05 16:39:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.14 1998/02/26 04:37:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ #include <miscadmin.h> #include "utils/builtins.h" /* where function declarations go */ -char * +char * filename_in(char *file) { char *str; @@ -72,7 +72,7 @@ filename_in(char *file) else { len = (p - file) - 1; - StrNCpy(name, file + 1, len+1); + StrNCpy(name, file + 1, len + 1); } /* printf("name: %s\n"); */ if ((pw = getpwnam(name)) == NULL) @@ -102,7 +102,7 @@ filename_in(char *file) else { len = (p - file) - 1; - StrNCpy(environment, file + 1, len+1); + StrNCpy(environment, file + 1, len + 1); } envirp = getenv(environment); if (envirp) @@ -123,7 +123,7 @@ filename_in(char *file) return (str); } -char * +char * filename_out(char *s) { char *ret; diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 71b324a5c37..532e0dc30b9 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.28 1998/02/02 00:03:54 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.29 1998/02/26 04:37:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -220,7 +220,7 @@ float4in(char *num) * float4out - converts a float4 number to a string * using a standard output format */ -char * +char * float4out(float32 num) { char *ascii = (char *) palloc(MAXFLOATWIDTH + 1); @@ -262,7 +262,7 @@ float8in(char *num) * float8out - converts float8 number to a string * using a standard output format */ -char * +char * float8out(float64 num) { char *ascii = (char *) palloc(MAXDOUBLEWIDTH + 1); diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index c3845fdcc4f..83d3ce90b8f 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.30 1998/02/03 15:55:58 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.31 1998/02/26 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,14 +135,14 @@ single_decode(char *str, float8 *x, char **s) *s = cp; return (TRUE); -} /* single_decode() */ +} /* single_decode() */ static int single_encode(float8 x, char *str) { sprintf(str, "%.*g", digits8, x); return (TRUE); -} /* single_encode() */ +} /* single_encode() */ static int pair_decode(char *str, float8 *x, float8 *y, char **s) @@ -267,7 +267,7 @@ path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point *p) *ss = s; return (TRUE); -} /* path_decode() */ +} /* path_decode() */ static char * path_encode(bool closed, int npts, Point *pt) @@ -315,7 +315,7 @@ path_encode(bool closed, int npts, Point *pt) *cp = '\0'; return (result); -} /* path_encode() */ +} /* path_encode() */ /*------------------------------------------------------------- * pair_count - count the number of points @@ -385,7 +385,7 @@ box_in(char *str) } return (box); -} /* box_in() */ +} /* box_in() */ /* box_out - convert a box to external form. */ @@ -396,7 +396,7 @@ box_out(BOX *box) return (NULL); return (path_encode(-1, 2, (Point *) &(box->high))); -} /* box_out() */ +} /* box_out() */ /* box_construct - fill in a new box. @@ -620,7 +620,7 @@ box_width(BOX *box) *result = box->high.x - box->low.x; return (result); -} /* box_width() */ +} /* box_width() */ /* box_height - returns the height of the box @@ -796,7 +796,7 @@ line_construct_pm(Point *pt, double m) #endif return (result); -} /* line_construct_pm() */ +} /* line_construct_pm() */ static LINE * /* two points */ @@ -850,7 +850,7 @@ line_construct_pp(Point *pt1, Point *pt2) #endif } return (result); -} /* line_construct_pp() */ +} /* line_construct_pp() */ /*---------------------------------------------------------- @@ -875,7 +875,7 @@ line_parallel(LINE *l1, LINE *l2) } return (FPeq(l2->A, l1->A * (l2->B / l1->B))); -} /* line_parallel() */ +} /* line_parallel() */ #ifdef NOT_USED bool @@ -897,7 +897,7 @@ line_perp(LINE *l1, LINE *l2) } return (FPeq(((l1->A * l2->B) / (l1->B * l2->A)), -1.0)); -} /* line_perp() */ +} /* line_perp() */ #endif @@ -908,7 +908,7 @@ line_vertical(LINE *line) return (FPeq(line->A, -1.0) && FPzero(line->B)); #endif return (FPzero(line->B)); -} /* line_vertical() */ +} /* line_vertical() */ static bool line_horizontal(LINE *line) @@ -917,7 +917,7 @@ line_horizontal(LINE *line) return (FPzero(line->m)); #endif return (FPzero(line->A)); -} /* line_horizontal() */ +} /* line_horizontal() */ #ifdef NOT_USED bool @@ -1028,7 +1028,7 @@ line_interpt(LINE *l1, LINE *l2) printf("line_interpt- lines intersect at (%.*g,%.*g)\n", digits8, x, digits8, y); #endif return (result); -} /* line_interpt() */ +} /* line_interpt() */ /*********************************************************************** @@ -1094,7 +1094,7 @@ path_in(char *str) path->closed = (!isopen); return (path); -} /* path_in() */ +} /* path_in() */ char * @@ -1104,7 +1104,7 @@ path_out(PATH *path) return NULL; return (path_encode(path->closed, path->npts, (Point *) &(path->p[0]))); -} /* path_out() */ +} /* path_out() */ /*---------------------------------------------------------- @@ -1157,7 +1157,7 @@ path_isclosed(PATH *path) return FALSE; return (path->closed); -} /* path_isclosed() */ +} /* path_isclosed() */ bool path_isopen(PATH *path) @@ -1166,7 +1166,7 @@ path_isopen(PATH *path) return FALSE; return (!path->closed); -} /* path_isopen() */ +} /* path_isopen() */ int4 @@ -1176,7 +1176,7 @@ path_npoints(PATH *path) return 0; return (path->npts); -} /* path_npoints() */ +} /* path_npoints() */ PATH * path_close(PATH *path) @@ -1190,7 +1190,7 @@ path_close(PATH *path) result->closed = TRUE; return (result); -} /* path_close() */ +} /* path_close() */ PATH * @@ -1205,7 +1205,7 @@ path_open(PATH *path) result->closed = FALSE; return (result); -} /* path_open() */ +} /* path_open() */ PATH * @@ -1219,7 +1219,7 @@ path_copy(PATH *path) memmove((char *) result, (char *) path, size); return (result); -} /* path_copy() */ +} /* path_copy() */ /* path_inter - @@ -1272,11 +1272,11 @@ path_inter(PATH *p1, PATH *p2) /* if we dropped through, no two segs intersected */ return (FALSE); -} /* path_inter() */ +} /* path_inter() */ /* path_distance() * This essentially does a cartesian product of the lsegs in the - * two paths, and finds the min distance between any two lsegs + * two paths, and finds the min distance between any two lsegs */ double * path_distance(PATH *p1, PATH *p2) @@ -1314,7 +1314,7 @@ path_distance(PATH *p1, PATH *p2) } return (min); -} /* path_distance() */ +} /* path_distance() */ /*---------------------------------------------------------- @@ -1334,7 +1334,7 @@ path_length(PATH *path) *result += point_dt(&path->p[i], &path->p[i + 1]); return (result); -} /* path_length() */ +} /* path_length() */ #ifdef NOT_USED @@ -1349,7 +1349,7 @@ path_ln(PATH *path) result += point_dt(&path->p[i], &path->p[i + 1]); return (result); -} /* path_ln() */ +} /* path_ln() */ #endif @@ -1387,7 +1387,7 @@ point_in(char *str) point->y = y; return (point); -} /* point_in() */ +} /* point_in() */ char * point_out(Point *pt) @@ -1396,7 +1396,7 @@ point_out(Point *pt) return (NULL); return (path_encode(-1, 1, pt)); -} /* point_out() */ +} /* point_out() */ static Point * @@ -1480,7 +1480,7 @@ point_eq(Point *pt1, Point *pt2) bool point_ne(Point *pt1, Point *pt2) { - return (! point_eq(pt1, pt2)); + return (!point_eq(pt1, pt2)); } /*---------------------------------------------------------- @@ -1510,8 +1510,8 @@ double point_dt(Point *pt1, Point *pt2) { #ifdef GEODEBUG -printf("point_dt- segment (%f,%f),(%f,%f) length is %f\n", - pt1->x, pt1->y, pt2->x, pt2->y, HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); + printf("point_dt- segment (%f,%f),(%f,%f) length is %f\n", + pt1->x, pt1->y, pt2->x, pt2->y, HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); #endif return (HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); } @@ -1575,7 +1575,7 @@ lseg_in(char *str) #endif return (lseg); -} /* lseg_in() */ +} /* lseg_in() */ char * @@ -1585,7 +1585,7 @@ lseg_out(LSEG *ls) return (NULL); return (path_encode(FALSE, 2, (Point *) &(ls->p[0]))); -} /* lseg_out() */ +} /* lseg_out() */ /* lseg_construct - @@ -1633,7 +1633,7 @@ lseg_length(LSEG *lseg) result = point_distance(&lseg->p[0], &lseg->p[1]); return (result); -} /* lseg_length() */ +} /* lseg_length() */ /*---------------------------------------------------------- * Relative position routines. @@ -1671,15 +1671,15 @@ lseg_parallel(LSEG *l1, LSEG *l2) #endif return (FPeq(point_sl(&(l1->p[0]), &(l1->p[1])), point_sl(&(l2->p[0]), &(l2->p[1])))); -} /* lseg_parallel() */ +} /* lseg_parallel() */ /* lseg_perp() * Determine if two line segments are perpendicular. * * This code did not get the correct answer for - * '((0,0),(0,1))'::lseg ?-| '((0,0),(1,0))'::lseg + * '((0,0),(0,1))'::lseg ?-| '((0,0),(1,0))'::lseg * So, modified it to check explicitly for slope of vertical line - * returned by point_sl() and the results seem better. + * returned by point_sl() and the results seem better. * - thomas 1998-01-31 */ bool @@ -1692,15 +1692,15 @@ lseg_perp(LSEG *l1, LSEG *l2) m2 = point_sl(&(l2->p[0]), &(l2->p[1])); #ifdef GEODEBUG -printf("lseg_perp- slopes are %g and %g\n", m1, m2); + printf("lseg_perp- slopes are %g and %g\n", m1, m2); #endif if (FPzero(m1)) - return(FPeq(m2, DBL_MAX)); + return (FPeq(m2, DBL_MAX)); else if (FPzero(m2)) - return(FPeq(m1, DBL_MAX)); + return (FPeq(m1, DBL_MAX)); return (FPeq(m1 / m2, -1.0)); -} /* lseg_perp() */ +} /* lseg_perp() */ bool lseg_vertical(LSEG *lseg) @@ -1722,7 +1722,7 @@ lseg_eq(LSEG *l1, LSEG *l2) FPeq(l1->p[1].y, l2->p[1].y) && FPeq(l1->p[0].x, l2->p[0].x) && FPeq(l1->p[1].y, l2->p[1].y)); -} /* lseg_eq() */ +} /* lseg_eq() */ bool lseg_ne(LSEG *l1, LSEG *l2) @@ -1731,31 +1731,31 @@ lseg_ne(LSEG *l1, LSEG *l2) !FPeq(l1->p[1].y, l2->p[1].y) || !FPeq(l1->p[0].x, l2->p[0].x) || !FPeq(l1->p[1].y, l2->p[1].y)); -} /* lseg_ne() */ +} /* lseg_ne() */ bool lseg_lt(LSEG *l1, LSEG *l2) { return (FPlt(point_dt(&l1->p[0], &l1->p[1]), point_dt(&l2->p[0], &l2->p[1]))); -} /* lseg_lt() */ +} /* lseg_lt() */ bool lseg_le(LSEG *l1, LSEG *l2) { return (FPle(point_dt(&l1->p[0], &l1->p[1]), point_dt(&l2->p[0], &l2->p[1]))); -} /* lseg_le() */ +} /* lseg_le() */ bool lseg_gt(LSEG *l1, LSEG *l2) { return (FPgt(point_dt(&l1->p[0], &l1->p[1]), point_dt(&l2->p[0], &l2->p[1]))); -} /* lseg_gt() */ +} /* lseg_gt() */ bool lseg_ge(LSEG *l1, LSEG *l2) { return (FPge(point_dt(&l1->p[0], &l1->p[1]), point_dt(&l2->p[0], &l2->p[1]))); -} /* lseg_ge() */ +} /* lseg_ge() */ /*---------------------------------------------------------- @@ -1805,7 +1805,7 @@ lseg_dt(LSEG *l1, LSEG *l2) pfree(d); return (result); -} /* lseg_dt() */ +} /* lseg_dt() */ Point * @@ -1822,7 +1822,7 @@ lseg_center(LSEG *lseg) result->y = (lseg->p[0].y - lseg->p[1].y) / 2; return (result); -} /* lseg_center() */ +} /* lseg_center() */ /* lseg_interpt - @@ -1875,7 +1875,7 @@ lseg_interpt(LSEG *l1, LSEG *l2) pfree(tmp2); return (result); -} /* lseg_interpt() */ +} /* lseg_interpt() */ /*********************************************************************** ** @@ -2158,7 +2158,7 @@ dist_cpoly(CIRCLE *circle, POLYGON *poly) *result = 0; return (result); -} /* dist_cpoly() */ +} /* dist_cpoly() */ /*--------------------------------------------------------------------- @@ -2255,17 +2255,17 @@ close_pl(Point *pt, LINE *line) tmp = line_construct_pm(pt, invm); result = line_interpt(tmp, line); return (result); -} /* close_pl() */ +} /* close_pl() */ /* close_ps() * Closest point on line segment to specified point. * Take the closest endpoint if the point is left, right, - * above, or below the segment, otherwise find the intersection - * point of the segment and its perpendicular through the point. + * above, or below the segment, otherwise find the intersection + * point of the segment and its perpendicular through the point. * * Some tricky code here, relying on boolean expressions - * evaluating to only zero or one to use as an array index. + * evaluating to only zero or one to use as an array index. */ Point * close_ps(Point *pt, LSEG *lseg) @@ -2294,7 +2294,7 @@ close_ps(Point *pt, LSEG *lseg) if (lseg_vertical(lseg)) { #ifdef GEODEBUG -printf("close_ps- segment is vertical\n"); + printf("close_ps- segment is vertical\n"); #endif result = palloc(sizeof(*result)); result->x = lseg->p[0].x; @@ -2304,7 +2304,7 @@ printf("close_ps- segment is vertical\n"); else if (lseg_horizontal(lseg)) { #ifdef GEODEBUG -printf("close_ps- segment is horizontal\n"); + printf("close_ps- segment is horizontal\n"); #endif result = palloc(sizeof(*result)); result->x = pt->x; @@ -2316,7 +2316,7 @@ printf("close_ps- segment is horizontal\n"); tmp = line_construct_pm(pt, invm); result = interpt_sl(lseg, tmp); return (result); -} /* close_ps() */ +} /* close_ps() */ /* close_lseg() * Closest point to l1 on l2. @@ -2352,7 +2352,8 @@ close_lseg(LSEG *l1, LSEG *l2) if (*(d = dist_ps(&l2->p[1], l1)) < dist) { - if (result != NULL) pfree(result); + if (result != NULL) + pfree(result); result = close_ps(&l2->p[1], l1); memcpy(&point, result, sizeof(point)); @@ -2368,7 +2369,7 @@ close_lseg(LSEG *l1, LSEG *l2) } return (result); -} /* close_lseg() */ +} /* close_lseg() */ /* close_pb() * Closest point on or in box to specified point. @@ -2396,7 +2397,7 @@ close_pb(Point *pt, BOX *box) if (*(d = dist_ps(pt, &seg)) < dist) { dist = *d; - memcpy(&lseg,&seg,sizeof(lseg)); + memcpy(&lseg, &seg, sizeof(lseg)); } pfree(d); @@ -2406,7 +2407,7 @@ close_pb(Point *pt, BOX *box) if (*(d = dist_ps(pt, &seg)) < dist) { dist = *d; - memcpy(&lseg,&seg,sizeof(lseg)); + memcpy(&lseg, &seg, sizeof(lseg)); } pfree(d); @@ -2414,19 +2415,19 @@ close_pb(Point *pt, BOX *box) if (*(d = dist_ps(pt, &seg)) < dist) { dist = *d; - memcpy(&lseg,&seg,sizeof(lseg)); + memcpy(&lseg, &seg, sizeof(lseg)); } pfree(d); return (close_ps(pt, &lseg)); -} /* close_pb() */ +} /* close_pb() */ /* close_sl() * Closest point on line to line segment. * * XXX THIS CODE IS WRONG * The code is actually calculating the point on the line segment - * which is backwards from the routine naming convention. + * which is backwards from the routine naming convention. * Copied code to new routine close_ls() but haven't fixed this one yet. * - thomas 1998-01-31 */ @@ -2477,7 +2478,7 @@ close_ls(LINE *line, LSEG *lseg) pfree(d1); pfree(d2); return (result); -} /* close_ls() */ +} /* close_ls() */ /* close_sb() * Closest point on or in box to line segment. @@ -2534,7 +2535,7 @@ close_sb(LSEG *lseg, BOX *box) /* OK, we now have the closest line segment on the box boundary */ return (close_lseg(lseg, &bseg)); -} /* close_sb() */ +} /* close_sb() */ Point * close_lb(LINE *line, BOX *box) @@ -2662,7 +2663,7 @@ on_ppath(Point *pt, PATH *path) if (FPeq(yh, yl)) /* horizontal seg? */ if (FPge(pt->x, xl) && FPle(pt->x, xh) && FPeq(pt->y, yh)) - return (TRUE); /* pt lies on seg */ + return (TRUE); /* pt lies on seg */ else continue; /* skip other hz segs */ if (FPlt(yh, pt->y) || /* pt is strictly below seg */ @@ -2690,7 +2691,7 @@ on_ppath(Point *pt, PATH *path) return (above == UNDEF || /* path is horizontal */ inter % 2); /* odd # of intersections */ #endif -} /* on_ppath() */ +} /* on_ppath() */ bool @@ -2700,7 +2701,7 @@ on_sl(LSEG *lseg, LINE *line) return (FALSE); return (on_pl(&lseg->p[0], line) && on_pl(&lseg->p[1], line)); -} /* on_sl() */ +} /* on_sl() */ bool on_sb(LSEG *lseg, BOX *box) @@ -2709,7 +2710,7 @@ on_sb(LSEG *lseg, BOX *box) return (FALSE); return (on_pb(&lseg->p[0], box) && on_pb(&lseg->p[1], box)); -} /* on_sb() */ +} /* on_sb() */ /*--------------------------------------------------------------------- * inter_ @@ -2738,7 +2739,7 @@ inter_sl(LSEG *lseg, LINE *line) * * Segment completely inside box counts as intersection. * If you want only segments crossing box boundaries, - * try converting box to path first. + * try converting box to path first. * * Optimize for non-intersection by checking for box intersection first. * - thomas 1998-01-30 @@ -2789,7 +2790,7 @@ inter_sb(LSEG *lseg, BOX *box) /* if we dropped through, no two segs intersected */ return (FALSE); -} /* inter_sb() */ +} /* inter_sb() */ /* inter_lb() * Do line and box intersect? @@ -2884,7 +2885,7 @@ make_bound_box(POLYGON *poly) * "x0,y0,...,xn,yn" * also supports the older style "(x1,...,xn,y1,...yn)" *------------------------------------------------------------------*/ -POLYGON * +POLYGON * poly_in(char *str) { POLYGON *poly; @@ -2913,7 +2914,7 @@ poly_in(char *str) make_bound_box(poly); return (poly); -} /* poly_in() */ +} /* poly_in() */ /*--------------------------------------------------------------- * poly_out - convert internal POLYGON representation to the @@ -2927,7 +2928,7 @@ poly_out(POLYGON *poly) return NULL; return (path_encode(TRUE, poly->npts, &(poly->p[0]))); -} /* poly_out() */ +} /* poly_out() */ /*------------------------------------------------------- @@ -3001,7 +3002,7 @@ poly_same(POLYGON *polya, POLYGON *polyb) } return TRUE; #endif -} /* poly_same() */ +} /* poly_same() */ /*----------------------------------------------------------------- * Determine if polygon A overlaps polygon B by determining if @@ -3065,7 +3066,7 @@ poly_contain(POLYGON *polya, POLYGON *polyb) polya->boundbox.low.x, polya->boundbox.low.y, polya->boundbox.high.x, polya->boundbox.high.y); #endif return (FALSE); -} /* poly_contain() */ +} /* poly_contain() */ /*----------------------------------------------------------------- @@ -3085,7 +3086,7 @@ bool poly_contained(POLYGON *polya, POLYGON *polyb) { return (poly_contain(polyb, polya)); -} /* poly_contained() */ +} /* poly_contained() */ /* poly_contain_pt() @@ -3105,7 +3106,7 @@ poly_contain_pt(POLYGON *poly, Point *p) return (FALSE); return (point_inside(p, poly->npts, &(poly->p[0])) != 0); -} /* poly_contain_pt() */ +} /* poly_contain_pt() */ bool pt_contained_poly(Point *p, POLYGON *poly) @@ -3114,7 +3115,7 @@ pt_contained_poly(Point *p, POLYGON *poly) return (FALSE); return (poly_contain_pt(poly, p)); -} /* pt_contained_poly() */ +} /* pt_contained_poly() */ double * @@ -3130,7 +3131,7 @@ poly_distance(POLYGON *polya, POLYGON *polyb) *result = 0; return (result); -} /* poly_distance() */ +} /* poly_distance() */ /*********************************************************************** @@ -3146,7 +3147,7 @@ point(float8 *x, float8 *y) return (NULL); return (point_construct(*x, *y)); -} /* point() */ +} /* point() */ Point * @@ -3163,7 +3164,7 @@ point_add(Point *p1, Point *p2) result->y = (p1->y + p2->y); return (result); -} /* point_add() */ +} /* point_add() */ Point * point_sub(Point *p1, Point *p2) @@ -3179,7 +3180,7 @@ point_sub(Point *p1, Point *p2) result->y = (p1->y - p2->y); return (result); -} /* point_sub() */ +} /* point_sub() */ Point * point_mul(Point *p1, Point *p2) @@ -3195,7 +3196,7 @@ point_mul(Point *p1, Point *p2) result->y = (p1->x * p2->y) + (p1->y * p2->x); return (result); -} /* point_mul() */ +} /* point_mul() */ Point * point_div(Point *p1, Point *p2) @@ -3217,7 +3218,7 @@ point_div(Point *p1, Point *p2) result->y = ((p2->x * p1->y) - (p2->y * p1->x)) / div; return (result); -} /* point_div() */ +} /* point_div() */ /*********************************************************************** @@ -3237,7 +3238,7 @@ box(Point *p1, Point *p2) result = box_construct(p1->x, p2->x, p1->y, p2->y); return (result); -} /* box() */ +} /* box() */ BOX * box_add(BOX *box, Point *p) @@ -3251,7 +3252,7 @@ box_add(BOX *box, Point *p) (box->high.y + p->y), (box->low.y + p->y)); return (result); -} /* box_add() */ +} /* box_add() */ BOX * box_sub(BOX *box, Point *p) @@ -3265,7 +3266,7 @@ box_sub(BOX *box, Point *p) (box->high.y - p->y), (box->low.y - p->y)); return (result); -} /* box_sub() */ +} /* box_sub() */ BOX * box_mul(BOX *box, Point *p) @@ -3285,7 +3286,7 @@ box_mul(BOX *box, Point *p) pfree(low); return (result); -} /* box_mul() */ +} /* box_mul() */ BOX * box_div(BOX *box, Point *p) @@ -3305,7 +3306,7 @@ box_div(BOX *box, Point *p) pfree(low); return (result); -} /* box_div() */ +} /* box_div() */ /*********************************************************************** @@ -3357,7 +3358,7 @@ path_add(PATH *p1, PATH *p2) } return (result); -} /* path_add() */ +} /* path_add() */ /* path_add_pt() * Translation operator. @@ -3380,7 +3381,7 @@ path_add_pt(PATH *path, Point *point) } return (result); -} /* path_add_pt() */ +} /* path_add_pt() */ PATH * path_sub_pt(PATH *path, Point *point) @@ -3400,7 +3401,7 @@ path_sub_pt(PATH *path, Point *point) } return (result); -} /* path_sub_pt() */ +} /* path_sub_pt() */ /* path_mul_pt() @@ -3427,7 +3428,7 @@ path_mul_pt(PATH *path, Point *point) } return (result); -} /* path_mul_pt() */ +} /* path_mul_pt() */ PATH * path_div_pt(PATH *path, Point *point) @@ -3450,7 +3451,7 @@ path_div_pt(PATH *path, Point *point) } return (result); -} /* path_div_pt() */ +} /* path_div_pt() */ bool @@ -3460,7 +3461,7 @@ path_contain_pt(PATH *path, Point *p) return (FALSE); return ((path->closed ? (point_inside(p, path->npts, &(path->p[0])) != 0) : FALSE)); -} /* path_contain_pt() */ +} /* path_contain_pt() */ bool pt_contained_path(Point *p, PATH *path) @@ -3469,7 +3470,7 @@ pt_contained_path(Point *p, PATH *path) return (FALSE); return (path_contain_pt(path, p)); -} /* pt_contained_path() */ +} /* pt_contained_path() */ Point * @@ -3486,9 +3487,9 @@ path_center(PATH *path) result = NULL; return (result); -} /* path_center() */ +} /* path_center() */ -POLYGON * +POLYGON * path_poly(PATH *path) { POLYGON *poly; @@ -3516,7 +3517,7 @@ path_poly(PATH *path) make_bound_box(poly); return (poly); -} /* path_polygon() */ +} /* path_polygon() */ /* upgradepath() @@ -3556,7 +3557,7 @@ upgradepath(PATH *path) } return (result); -} /* upgradepath() */ +} /* upgradepath() */ bool isoldpath(PATH *path) @@ -3565,7 +3566,7 @@ isoldpath(PATH *path) return (FALSE); return (path->npts == (path->p[0].y + 1)); -} /* isoldpath() */ +} /* isoldpath() */ /*********************************************************************** @@ -3581,7 +3582,7 @@ poly_npoints(POLYGON *poly) return (FALSE); return (poly->npts); -} /* poly_npoints() */ +} /* poly_npoints() */ Point * @@ -3605,7 +3606,7 @@ poly_center(POLYGON *poly) } return (result); -} /* poly_center() */ +} /* poly_center() */ BOX * @@ -3619,13 +3620,13 @@ poly_box(POLYGON *poly) box = box_copy(&poly->boundbox); return (box); -} /* poly_box() */ +} /* poly_box() */ /* box_poly() * Convert a box to a polygon. */ -POLYGON * +POLYGON * box_poly(BOX *box) { POLYGON *poly; @@ -3653,7 +3654,7 @@ box_poly(BOX *box) box_fill(&poly->boundbox, box->high.x, box->low.x, box->high.y, box->low.y); return (poly); -} /* box_poly() */ +} /* box_poly() */ PATH * @@ -3680,7 +3681,7 @@ poly_path(POLYGON *poly) } return (path); -} /* poly_path() */ +} /* poly_path() */ /* upgradepoly() @@ -3688,7 +3689,7 @@ poly_path(POLYGON *poly) * Old-style: '(x1,x2,...,y1,y2,...)' * New-style: '(x1,y1,x2,y2,...)' */ -POLYGON * +POLYGON * upgradepoly(POLYGON *poly) { POLYGON *result; @@ -3729,12 +3730,12 @@ upgradepoly(POLYGON *poly) } return (result); -} /* upgradepoly() */ +} /* upgradepoly() */ /* revertpoly() * Reverse effect of upgradepoly(). */ -POLYGON * +POLYGON * revertpoly(POLYGON *poly) { POLYGON *result; @@ -3775,7 +3776,7 @@ revertpoly(POLYGON *poly) } return (result); -} /* revertpoly() */ +} /* revertpoly() */ /*********************************************************************** @@ -3854,7 +3855,7 @@ circle_in(char *str) elog(ERROR, "Bad circle external representation '%s'", str); return (circle); -} /* circle_in() */ +} /* circle_in() */ /* circle_out - convert a circle to external form. */ @@ -3886,7 +3887,7 @@ circle_out(CIRCLE *circle) *cp = '\0'; return (result); -} /* circle_out() */ +} /* circle_out() */ /*---------------------------------------------------------- @@ -3902,7 +3903,7 @@ circle_same(CIRCLE *circle1, CIRCLE *circle2) return (FPeq(circle1->radius, circle2->radius) && FPeq(circle1->center.x, circle2->center.x) && FPeq(circle1->center.y, circle2->center.y)); -} /* circle_same() */ +} /* circle_same() */ /* circle_overlap - does circle1 overlap circle2? */ @@ -3986,37 +3987,37 @@ bool circle_eq(CIRCLE *circle1, CIRCLE *circle2) { return (FPeq(circle_ar(circle1), circle_ar(circle2))); -} /* circle_eq() */ +} /* circle_eq() */ bool circle_ne(CIRCLE *circle1, CIRCLE *circle2) { return (!circle_eq(circle1, circle2)); -} /* circle_ne() */ +} /* circle_ne() */ bool circle_lt(CIRCLE *circle1, CIRCLE *circle2) { return (FPlt(circle_ar(circle1), circle_ar(circle2))); -} /* circle_lt() */ +} /* circle_lt() */ bool circle_gt(CIRCLE *circle1, CIRCLE *circle2) { return (FPgt(circle_ar(circle1), circle_ar(circle2))); -} /* circle_gt() */ +} /* circle_gt() */ bool circle_le(CIRCLE *circle1, CIRCLE *circle2) { return (FPle(circle_ar(circle1), circle_ar(circle2))); -} /* circle_le() */ +} /* circle_le() */ bool circle_ge(CIRCLE *circle1, CIRCLE *circle2) { return (FPge(circle_ar(circle1), circle_ar(circle2))); -} /* circle_ge() */ +} /* circle_ge() */ /*---------------------------------------------------------- @@ -4039,7 +4040,7 @@ circle_copy(CIRCLE *circle) memmove((char *) result, (char *) circle, sizeof(CIRCLE)); return (result); -} /* circle_copy() */ +} /* circle_copy() */ /* circle_add_pt() @@ -4059,7 +4060,7 @@ circle_add_pt(CIRCLE *circle, Point *point) result->center.y += point->y; return (result); -} /* circle_add_pt() */ +} /* circle_add_pt() */ CIRCLE * circle_sub_pt(CIRCLE *circle, Point *point) @@ -4075,7 +4076,7 @@ circle_sub_pt(CIRCLE *circle, Point *point) result->center.y -= point->y; return (result); -} /* circle_sub_pt() */ +} /* circle_sub_pt() */ /* circle_mul_pt() @@ -4099,7 +4100,7 @@ circle_mul_pt(CIRCLE *circle, Point *point) result->radius *= HYPOT(point->x, point->y); return (result); -} /* circle_mul_pt() */ +} /* circle_mul_pt() */ CIRCLE * circle_div_pt(CIRCLE *circle, Point *point) @@ -4119,7 +4120,7 @@ circle_div_pt(CIRCLE *circle, Point *point) result->radius /= HYPOT(point->x, point->y); return (result); -} /* circle_div_pt() */ +} /* circle_div_pt() */ /* circle_area - returns the area of the circle. @@ -4179,7 +4180,7 @@ circle_distance(CIRCLE *circle1, CIRCLE *circle2) *result = 0; return (result); -} /* circle_distance() */ +} /* circle_distance() */ bool @@ -4196,14 +4197,14 @@ circle_contain_pt(CIRCLE *circle, Point *point) pfree(d); return (within); -} /* circle_contain_pt() */ +} /* circle_contain_pt() */ bool pt_contained_circle(Point *point, CIRCLE *circle) { return (circle_contain_pt(circle, point)); -} /* circle_contain_pt() */ +} /* circle_contain_pt() */ /* dist_pc - returns the distance between @@ -4221,7 +4222,7 @@ dist_pc(Point *point, CIRCLE *circle) *result = 0; return (result); -} /* dist_pc() */ +} /* dist_pc() */ /* circle_center - returns the center point of the circle. @@ -4286,7 +4287,7 @@ circle(Point *center, float8 *radius) } -BOX * +BOX * circle_box(CIRCLE *circle) { BOX *box; @@ -4305,7 +4306,7 @@ circle_box(CIRCLE *circle) box->low.y = circle->center.y - delta; return (box); -} /* circle_box() */ +} /* circle_box() */ /* box_circle() * Convert a box to a circle. @@ -4326,10 +4327,10 @@ box_circle(BOX *box) circle->radius = point_dt(&circle->center, &box->high); return (circle); -} /* box_circle() */ +} /* box_circle() */ -POLYGON * +POLYGON * circle_poly(int npts, CIRCLE *circle) { POLYGON *poly; @@ -4403,7 +4404,7 @@ poly_circle(POLYGON *poly) elog(ERROR, "Unable to convert polygon to circle", NULL); return (circle); -} /* poly_circle() */ +} /* poly_circle() */ /*********************************************************************** @@ -4471,7 +4472,7 @@ point_inside(Point *p, int npts, Point plist[]) return 1; } return 0; -} /* point_inside() */ +} /* point_inside() */ /* lseg_crossing() @@ -4534,7 +4535,7 @@ lseg_crossing(double x, double y, double px, double py) return (HIT_IT); return (FPgt((sgn * z), 0) ? 0 : 2 * sgn); } -} /* lseg_crossing() */ +} /* lseg_crossing() */ static bool @@ -4594,4 +4595,4 @@ plist_same(int npts, Point p1[], Point p2[]) } return (FALSE); -} /* plist_same() */ +} /* plist_same() */ diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index e7767e4cdbd..2bf1fdf80f3 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.14 1998/02/11 19:12:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.15 1998/02/26 04:37:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,7 +80,7 @@ int2out(int16 sh) int16 * int28in(char *shs) { - int16 (*result)[]; + int16 (*result)[]; int nums; if (shs == NULL) @@ -109,9 +109,9 @@ int28in(char *shs) char * int28out(int16 (*shs)[]) { - int num; - int16 *sp; - char *rp; + int num; + int16 *sp; + char *rp; char *result; if (shs == NULL) @@ -145,7 +145,7 @@ int32 * int44in(char *input_string) { int32 *foo = (int32 *) palloc(4 * sizeof(int32)); - int i = 0; + int i = 0; i = sscanf(input_string, "%d, %d, %d, %d", @@ -242,10 +242,10 @@ i4toi2(int32 arg1) text * int2_text(int16 arg1) { - text *result; + text *result; - int len; - char *str; + int len; + char *str; str = int2out(arg1); len = (strlen(str) + VARHDRSZ); @@ -257,36 +257,36 @@ int2_text(int16 arg1) pfree(str); - return(result); -} /* int2_text() */ + return (result); +} /* int2_text() */ int16 text_int2(text *string) { - int16 result; + int16 result; - int len; - char *str; + int len; + char *str; len = (VARSIZE(string) - VARHDRSZ); - str = palloc(len+1); + str = palloc(len + 1); memmove(str, VARDATA(string), len); - *(str+len) = '\0'; + *(str + len) = '\0'; result = int2in(str); pfree(str); - - return(result); -} /* text_int2() */ + + return (result); +} /* text_int2() */ text * int4_text(int32 arg1) { - text *result; + text *result; - int len; - char *str; + int len; + char *str; str = int4out(arg1); len = (strlen(str) + VARHDRSZ); @@ -298,28 +298,28 @@ int4_text(int32 arg1) pfree(str); - return(result); -} /* int4_text() */ + return (result); +} /* int4_text() */ int32 text_int4(text *string) { - int32 result; + int32 result; - int len; - char *str; + int len; + char *str; len = (VARSIZE(string) - VARHDRSZ); - str = palloc(len+1); + str = palloc(len + 1); memmove(str, VARDATA(string), len); - *(str+len) = '\0'; + *(str + len) = '\0'; result = int4in(str); pfree(str); - - return(result); -} /* text_int4() */ + + return (result); +} /* text_int4() */ /* diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index 35446cd7da7..7d4681262d5 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -48,7 +48,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen) /* be sure sterm is null-terminated */ sterm = (char *) palloc(charlen + 1); - StrNCpy(sterm, s, charlen+1); + StrNCpy(sterm, s, charlen + 1); /* * p is a text = varlena, not a string so we have to make a string @@ -150,7 +150,7 @@ textnlike(struct varlena * s, struct varlena * p) } -/* $Revision: 1.11 $ +/* $Revision: 1.12 $ ** "like.c" A first attempt at a LIKE operator for Postgres95. ** ** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. @@ -187,7 +187,7 @@ textnlike(struct varlena * s, struct varlena * p) static int DoMatch(char *text, char *p) { - int matched; + int matched; for (; *p; text ++, p++) { diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 7c4d1364a76..c186ea15908 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.41 1998/02/02 01:28:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.42 1998/02/26 04:37:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,7 +103,7 @@ GetCurrentAbsoluteTime(void) #endif return ((AbsoluteTime) now); -} /* GetCurrentAbsoluteTime() */ +} /* GetCurrentAbsoluteTime() */ void @@ -114,7 +114,7 @@ GetCurrentTime(struct tm * tm) abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL); return; -} /* GetCurrentTime() */ +} /* GetCurrentTime() */ void @@ -190,7 +190,7 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn) #endif return; -} /* abstime2tm() */ +} /* abstime2tm() */ /* tm2abstime() @@ -231,7 +231,7 @@ tm2abstime(struct tm * tm, int tz) return (INVALID_ABSTIME); return (sec); -} /* tm2abstime() */ +} /* tm2abstime() */ /* nabstimein() @@ -300,13 +300,13 @@ nabstimein(char *str) }; return result; -} /* nabstimein() */ +} /* nabstimein() */ /* nabstimeout() * Given an AbsoluteTime return the English text version of the date */ -char * +char * nabstimeout(AbsoluteTime time) { char *result; @@ -347,7 +347,7 @@ nabstimeout(AbsoluteTime time) strcpy(result, buf); return (result); -} /* nabstimeout() */ +} /* nabstimeout() */ /* @@ -392,7 +392,7 @@ abstime_finite(AbsoluteTime abstime) { return ((abstime != INVALID_ABSTIME) && (abstime != NOSTART_ABSTIME) && (abstime != NOEND_ABSTIME)); -} /* abstime_finite() */ +} /* abstime_finite() */ /* @@ -534,7 +534,7 @@ datetime_abstime(DateTime *datetime) }; return (result); -} /* datetime_abstime() */ +} /* datetime_abstime() */ /* abstime_datetime() * Convert abstime to datetime. @@ -575,4 +575,4 @@ abstime_datetime(AbsoluteTime abstime) }; return (result); -} /* abstime_datetime() */ +} /* abstime_datetime() */ diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index fb281a3e4e3..3cabfaf8b42 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.10 1997/10/25 01:10:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.11 1998/02/26 04:37:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ namein(char *s) /* * nameout - converts internal reprsentation to "..." */ -char * +char * nameout(NameData *s) { if (s == NULL) diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index f3c9fb07adc..6797253b9b0 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.22 1998/02/11 19:12:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.23 1998/02/26 04:37:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -184,9 +184,9 @@ ftoa(double value, char *ascii, int width, int prec1, char format) #else auto int expon; auto int sign; - int avail = 0; - char *a = NULL; - char *p = NULL; + int avail = 0; + char *a = NULL; + char *p = NULL; char mode; int lowercase; int prec; @@ -333,7 +333,7 @@ frac_out: *a = 0; avail = a - ascii; return (avail); -#endif +#endif } #endif @@ -370,13 +370,13 @@ frac_out: int atof1(char *str, double *val) { - char *p; + char *p; double v; double fact; int minus; - char c; + char c; int expon; - int gotmant; + int gotmant; v = 0.0; p = str; diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index c7224a04e18..e6d66d126ed 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.14 1998/02/11 19:12:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.15 1998/02/26 04:37:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,10 +28,10 @@ * Note: * Fills any nonexistent digits with NULL oids. */ -Oid * +Oid * oid8in(char *oidString) { - Oid (*result)[]; + Oid (*result)[]; int nums; if (oidString == NULL) @@ -60,9 +60,9 @@ oid8in(char *oidString) char * oid8out(Oid (*oidArray)[]) { - int num; - Oid *sp; - char *rp; + int num; + Oid *sp; + char *rp; char *result; if (oidArray == NULL) @@ -142,10 +142,10 @@ int4eqoid(int32 arg1, Oid arg2) text * oid_text(Oid oid) { - text *result; + text *result; - int len; - char *str; + int len; + char *str; str = oidout(oid); len = (strlen(str) + VARHDRSZ); @@ -153,28 +153,28 @@ oid_text(Oid oid) result = palloc(len); VARSIZE(result) = len; - memmove(VARDATA(result), str, (len-VARHDRSZ)); + memmove(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); - return(result); -} /* oid_text() */ + return (result); +} /* oid_text() */ Oid text_oid(text *string) { - Oid result; + Oid result; - int len; - char *str; + int len; + char *str; - len = (VARSIZE(string) - VARHDRSZ); + len = (VARSIZE(string) - VARHDRSZ); - str = palloc(len+1); + str = palloc(len + 1); memmove(str, VARDATA(string), len); - *(str+len) = '\0'; + *(str + len) = '\0'; result = oidin(str); pfree(str); - return(result); -} /* oid_text() */ + return (result); +} /* oid_text() */ diff --git a/src/backend/utils/adt/oidint2.c b/src/backend/utils/adt/oidint2.c index 25e034aaecb..38dcfe7f9fc 100644 --- a/src/backend/utils/adt/oidint2.c +++ b/src/backend/utils/adt/oidint2.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.4 1997/09/08 21:48:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.5 1998/02/26 04:37:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ oidint2in(char *o) return (oi); } -char * +char * oidint2out(OidInt2 o) { char *r; diff --git a/src/backend/utils/adt/oidint4.c b/src/backend/utils/adt/oidint4.c index c8c7c3de4bd..2c45edb1ec8 100644 --- a/src/backend/utils/adt/oidint4.c +++ b/src/backend/utils/adt/oidint4.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.4 1997/09/08 21:48:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.5 1998/02/26 04:37:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ oidint4in(char *o) return (oi); } -char * +char * oidint4out(OidInt4 o) { char *r; diff --git a/src/backend/utils/adt/oidname.c b/src/backend/utils/adt/oidname.c index 6cfa44e36a3..ff61681984a 100644 --- a/src/backend/utils/adt/oidname.c +++ b/src/backend/utils/adt/oidname.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.11 1998/01/05 16:40:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.12 1998/02/26 04:37:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ oidnamein(char *inStr) return oc; } -char * +char * oidnameout(OidName oidname) { char buf[30 + NAMEDATALEN]; /* oidname length + oid length + diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index e39c83aa26f..3680b1e2194 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -1,7 +1,7 @@ /* * Edmund Mergl <E.Mergl@bawue.de> * - * $Id: oracle_compat.c,v 1.11 1998/01/13 03:49:51 scrappy Exp $ + * $Id: oracle_compat.c,v 1.12 1998/02/26 04:37:19 momjian Exp $ * */ @@ -36,7 +36,7 @@ text *translate(text *string, char from, char to); * ********************************************************************/ -text * +text * lower(text *string) { text *ret; @@ -76,7 +76,7 @@ lower(text *string) * ********************************************************************/ -text * +text * upper(text *string) { text *ret; @@ -118,7 +118,7 @@ upper(text *string) * ********************************************************************/ -text * +text * initcap(text *string) { text *ret; @@ -169,7 +169,7 @@ initcap(text *string) * ********************************************************************/ -text * +text * lpad(text *string1, int4 len, text *string2) { text *ret; @@ -225,7 +225,7 @@ lpad(text *string1, int4 len, text *string2) * ********************************************************************/ -text * +text * rpad(text *string1, int4 len, text *string2) { text *ret; @@ -281,7 +281,7 @@ rpad(text *string1, int4 len, text *string2) * ********************************************************************/ -text * +text * btrim(text *string, text *set) { text *ret; @@ -349,7 +349,7 @@ btrim(text *string, text *set) memcpy(VARDATA(ret), ptr, m); return ret; -} /* btrim() */ +} /* btrim() */ /******************************************************************** @@ -367,7 +367,7 @@ btrim(text *string, text *set) * ********************************************************************/ -text * +text * ltrim(text *string, text *set) { text *ret; @@ -430,7 +430,7 @@ ltrim(text *string, text *set) * ********************************************************************/ -text * +text * rtrim(text *string, text *set) { text *ret; @@ -502,7 +502,7 @@ rtrim(text *string, text *set) * ********************************************************************/ -text * +text * substr(text *string, int4 m, int4 n) { text *ret; @@ -548,7 +548,7 @@ substr(text *string, int4 m, int4 n) * ********************************************************************/ -text * +text * translate(text *string, char from, char to) { text *ret; diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 024e46b5cac..7efc0e47e6b 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.13 1998/01/05 16:40:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.14 1998/02/26 04:37:20 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -189,7 +189,7 @@ fixedlen_regexeq(char *s, struct varlena * p, int charlen, int cflags) /* be sure sterm is null-terminated */ sterm = (char *) palloc(charlen + 1); - StrNCpy(sterm, s, charlen+1); + StrNCpy(sterm, s, charlen + 1); result = RE_compile_and_execute(p, sterm, cflags); diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 10b64a16b19..30c9b682602 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.14 1998/02/11 19:12:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.15 1998/02/26 04:37:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -90,7 +90,7 @@ regprocin(char *proname) /* * regprocout - converts proid to "proname" */ -char * +char * regprocout(RegProcedure proid) { Relation proc; @@ -152,7 +152,7 @@ regprocout(RegProcedure proid) /* * int8typeout - converts int8 type oids to "typname" list */ -text * +text * oid8types(Oid (*oidArray)[]) { Relation type; @@ -160,18 +160,18 @@ oid8types(Oid (*oidArray)[]) HeapTuple typetup; text *result; ScanKeyData key; - int num; - Oid *sp; + int num; + Oid *sp; if (oidArray == NULL) { - result = (text *) palloc(VARHDRSZ); + result = (text *) palloc(VARHDRSZ); VARSIZE(result) = 0; return (result); } - result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ); - *VARDATA(result) = '\0'; + result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ); + *VARDATA(result) = '\0'; type = heap_openr(TypeRelationName); if (!RelationIsValid(type)) { @@ -190,7 +190,7 @@ oid8types(Oid (*oidArray)[]) (AttrNumber) ObjectIdAttributeNumber, (RegProcedure) F_INT4EQ, (Datum) *sp); - + typescan = heap_beginscan(type, 0, false, 1, &key); if (!HeapScanIsValid(typescan)) { @@ -204,17 +204,17 @@ oid8types(Oid (*oidArray)[]) { char *s; bool isnull; - + s = (char *) heap_getattr(typetup, 1, - RelationGetTupleDescriptor(type), &isnull); + RelationGetTupleDescriptor(type), &isnull); if (!isnull) { - StrNCpy(VARDATA(result)+strlen(VARDATA(result)),s,16); - strcat(VARDATA(result)," "); + StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s, 16); + strcat(VARDATA(result), " "); } else elog(FATAL, "int8typeout: null procedure %d", *sp); - /* FALLTHROUGH */ + /* FALLTHROUGH */ } heap_endscan(typescan); } diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 94d31aa95a6..695d4b1d525 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.17 1998/02/11 19:12:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.18 1998/02/26 04:37:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -334,7 +334,7 @@ gethilokey(Oid relid, char **high, char **low) { - Relation rdesc; + Relation rdesc; HeapScanDesc sdesc; static ScanKeyData key[3] = { {0, Anum_pg_statistic_starelid, F_OIDEQ, {0, 0, F_OIDEQ}}, diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index f394f081622..82a192db8e5 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.4 1997/09/08 02:31:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.5 1998/02/26 04:37:22 momjian Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -67,7 +67,7 @@ tidin(char *str) * tidout * ---------------------------------------------------------------- */ -char * +char * tidout(ItemPointer itemPtr) { BlockNumber blockNumber; diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index f7ddf6199d2..8d468765866 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -51,11 +51,11 @@ timestamp_out(time_t timestamp) EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf); break; } - + result = palloc(strlen(buf) + 1); strcpy(result, buf); return result; -} /* timestamp_out() */ +} /* timestamp_out() */ time_t now(void) @@ -69,47 +69,47 @@ now(void) bool timestampeq(time_t t1, time_t t2) { - return(abstimeeq(t1,t2)); + return (abstimeeq(t1, t2)); } bool timestampne(time_t t1, time_t t2) { - return(abstimene(t1,t2)); + return (abstimene(t1, t2)); } bool timestamplt(time_t t1, time_t t2) { - return(abstimelt(t1,t2)); + return (abstimelt(t1, t2)); } bool timestampgt(time_t t1, time_t t2) { - return(abstimegt(t1,t2)); + return (abstimegt(t1, t2)); } bool timestample(time_t t1, time_t t2) { - return(abstimele(t1,t2)); + return (abstimele(t1, t2)); } bool timestampge(time_t t1, time_t t2) { - return(abstimege(t1,t2)); + return (abstimege(t1, t2)); } -DateTime * +DateTime * timestamp_datetime(time_t timestamp) { - return(abstime_datetime((AbsoluteTime) timestamp)); -} /* timestamp_datetime() */ + return (abstime_datetime((AbsoluteTime) timestamp)); +} /* timestamp_datetime() */ time_t datetime_timestamp(DateTime *datetime) { - return((AbsoluteTime) datetime_abstime(datetime)); -} /* datetime_timestamp() */ + return ((AbsoluteTime) datetime_abstime(datetime)); +} /* datetime_timestamp() */ diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index f3a2df7b94d..796cc3099ac 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.28 1998/02/24 15:19:44 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.29 1998/02/26 04:37:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,8 @@ #include "utils/builtins.h" #ifdef CYR_RECODE -char *convertstr(char *,int,int); +char *convertstr(char *, int, int); + #endif /* @@ -90,7 +91,7 @@ bpcharin(char *s, int dummy, int16 atttypmod) } #ifdef CYR_RECODE - convertstr(result + VARHDRSZ,len,0); + convertstr(result + VARHDRSZ, len, 0); #endif /* blank pad the string if necessary */ @@ -117,11 +118,11 @@ bpcharout(char *s) { len = VARSIZE(s) - VARHDRSZ; result = (char *) palloc(len + 1); - StrNCpy(result, VARDATA(s), len+1); /* these are blank-padded */ + StrNCpy(result, VARDATA(s), len + 1); /* these are blank-padded */ } #ifdef CYR_RECODE - convertstr(result,len,1); + convertstr(result, len, 1); #endif return (result); @@ -148,7 +149,7 @@ varcharin(char *s, int dummy, int16 atttypmod) len = strlen(s) + VARHDRSZ; if (atttypmod != -1 && len > atttypmod) - len = atttypmod; /* clip the string at max length */ + len = atttypmod; /* clip the string at max length */ if (len > 4096) elog(ERROR, "varcharin: length of char() must be less than 4096"); @@ -158,7 +159,7 @@ varcharin(char *s, int dummy, int16 atttypmod) strncpy(VARDATA(result), s, len - VARHDRSZ); #ifdef CYR_RECODE - convertstr(result + VARHDRSZ,len,0); + convertstr(result + VARHDRSZ, len, 0); #endif return (result); @@ -180,11 +181,11 @@ varcharout(char *s) { len = VARSIZE(s) - VARHDRSZ; result = (char *) palloc(len + 1); - StrNCpy(result, VARDATA(s), len+1); + StrNCpy(result, VARDATA(s), len + 1); } #ifdef CYR_RECODE - convertstr(result,len,1); + convertstr(result, len, 1); #endif return (result); @@ -216,7 +217,7 @@ bpcharlen(char *arg) if (!PointerIsValid(arg)) elog(ERROR, "Bad (null) char() external representation", NULL); - return(bcTruelen(arg)); + return (bcTruelen(arg)); } bool @@ -356,7 +357,7 @@ varcharlen(char *arg) if (!PointerIsValid(arg)) elog(ERROR, "Bad (null) varchar() external representation", NULL); - return(VARSIZE(arg) - VARHDRSZ); + return (VARSIZE(arg) - VARHDRSZ); } bool diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 8d334a2ffd9..a6b45d20938 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.30 1998/02/24 15:19:45 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.31 1998/02/26 04:37:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -159,7 +159,7 @@ textin(char *inputText) memmove(VARDATA(result), inputText, len - VARHDRSZ); #ifdef CYR_RECODE - convertstr(VARDATA(result),len-VARHDRSZ,0); + convertstr(VARDATA(result), len - VARHDRSZ, 0); #endif return (result); @@ -187,7 +187,7 @@ textout(text *vlena) result[len] = '\0'; #ifdef CYR_RECODE - convertstr(result,len,1); + convertstr(result, len, 1); #endif return (result); @@ -199,16 +199,16 @@ textout(text *vlena) /* * textlen - * returns the actual length of a text* - * (which is less than the VARSIZE of the text*) + * (which is less than the VARSIZE of the text*) */ int32 textlen(text *t) { if (!PointerIsValid(t)) - elog(ERROR,"Null input to textlen"); + elog(ERROR, "Null input to textlen"); return (VARSIZE(t) - VARHDRSZ); -} /* textlen() */ +} /* textlen() */ /* * textcat - @@ -259,7 +259,7 @@ textcat(text *t1, text *t2) VARSIZE(result) = len; return (result); -} /* textcat() */ +} /* textcat() */ /* * text_substr() @@ -267,17 +267,17 @@ textcat(text *t1, text *t2) * - thomas 1997-12-31 * * Input: - * - string - * - starting position (is one-based) - * - string length + * - string + * - starting position (is one-based) + * - string length * * If the starting position is zero or less, then return the entire string. * XXX Note that this may not be the right behavior: - * if we are calculating the starting position we might want it to start at one. + * if we are calculating the starting position we might want it to start at one. * If the length is less than zero, return the remaining string. * * Note that the arguments operate on octet length, - * so not aware of multi-byte character sets. + * so not aware of multi-byte character sets. */ text * text_substr(text *string, int32 m, int32 n) @@ -299,17 +299,17 @@ text_substr(text *string, int32 m, int32 n) else { m--; - if (((m+n) > len) || (n < 0)) - n = (len-m); + if (((m + n) > len) || (n < 0)) + n = (len - m); } ret = (text *) palloc(VARHDRSZ + n); VARSIZE(ret) = VARHDRSZ + n; - memcpy(VARDATA(ret), VARDATA(string)+m, n); + memcpy(VARDATA(ret), VARDATA(string) + m, n); return ret; -} /* text_substr() */ +} /* text_substr() */ /* * textpos - @@ -351,7 +351,7 @@ textpos(text *t1, text *t2) p1++; }; return (pos); -} /* textpos() */ +} /* textpos() */ /* * texteq - returns 1 iff arguments are equal @@ -381,7 +381,7 @@ texteq(text *arg1, text *arg2) if (*a1p++ != *a2p++) return ((bool) 0); return ((bool) 1); -} /* texteq() */ +} /* texteq() */ bool textne(text *arg1, text *arg2) @@ -443,7 +443,7 @@ text_lt(text *arg1, text *arg2) #endif return (result); -} /* text_lt() */ +} /* text_lt() */ /* text_le() * Comparison function for text strings. @@ -499,7 +499,7 @@ text_le(text *arg1, text *arg2) #endif return (result); -} /* text_le() */ +} /* text_le() */ bool text_gt(text *arg1, text *arg2) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 36a617d8ae0..ef9593b2b13 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.23 1998/02/23 17:43:19 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.24 1998/02/26 04:37:27 momjian Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -677,7 +677,7 @@ InitSysCache(char *relname, HeapTuple (*iScanfuncP) ()) { CatCache *cp; - int i; + int i; MemoryContext oldcxt; char *indname; @@ -862,8 +862,8 @@ SearchSysCache(struct catcache * cache, elt; elt = DLGetSucc(elt)) { - bool res; - + bool res; + ct = (CatCTup *) DLE_VAL(elt); /* ---------------- * see if the cached tuple matches our key. @@ -871,10 +871,10 @@ SearchSysCache(struct catcache * cache, * ---------------- */ HeapKeyTest(ct->ct_tup, - cache->cc_tupdesc, - cache->cc_nkeys, - cache->cc_skey, - res); + cache->cc_tupdesc, + cache->cc_nkeys, + cache->cc_skey, + res); if (res) break; } diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c index 485a1d01bae..2a8df51c6a1 100644 --- a/src/backend/utils/cache/fcache.c +++ b/src/backend/utils/cache/fcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.10 1998/01/15 19:45:29 pgsql Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.11 1998/02/26 04:37:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -282,10 +282,13 @@ init_fcache(Oid foid, - if (retval->language != SQLlanguageId) { + if (retval->language != SQLlanguageId) + { fmgr_info(foid, &(retval->func)); retval->nargs = retval->func.fn_nargs; - } else { + } + else + { retval->func.fn_addr = (func_ptr) NULL; } diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index c5f325a2fdb..b56c25e94de 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.12 1998/02/10 16:03:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.13 1998/02/26 04:37:30 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -67,7 +67,7 @@ op_class(Oid opno, int32 opclass, Oid amopid) * return the "attname" field from the attribute relation. * */ -char * +char * get_attname(Oid relid, AttrNumber attnum) { FormData_pg_attribute att_tup; @@ -161,7 +161,7 @@ get_attisset(Oid relid, char *attname) * return the "atttypmod" field from the attribute relation. * */ -int16 +int16 get_atttypmod(Oid relid, AttrNumber attnum) { FormData_pg_attribute att_tup; @@ -209,7 +209,7 @@ get_opcode(Oid opno) * * Note: return the struct so that it gets copied. */ -char * +char * get_opname(Oid opno) { FormData_pg_operator optup; @@ -395,7 +395,7 @@ get_relnatts(Oid relid) * Returns the name of a given relation. * */ -char * +char * get_rel_name(Oid relid) { FormData_pg_class reltup; diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index f40d5a3fdbc..79056f34d46 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.36 1998/02/23 17:43:25 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.37 1998/02/26 04:37:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -258,11 +258,14 @@ static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo); static HeapTuple scan_pg_rel_seq(RelationBuildDescInfo buildinfo); static HeapTuple scan_pg_rel_ind(RelationBuildDescInfo buildinfo); static Relation AllocateRelationDesc(u_int natts, Form_pg_class relp); -static void RelationBuildTupleDesc(RelationBuildDescInfo buildinfo, +static void +RelationBuildTupleDesc(RelationBuildDescInfo buildinfo, Relation relation, u_int natts); -static void build_tupdesc_seq(RelationBuildDescInfo buildinfo, +static void +build_tupdesc_seq(RelationBuildDescInfo buildinfo, Relation relation, u_int natts); -static void build_tupdesc_ind(RelationBuildDescInfo buildinfo, +static void +build_tupdesc_ind(RelationBuildDescInfo buildinfo, Relation relation, u_int natts); static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo); static void IndexedAccessMethodInitialize(Relation relation); @@ -766,11 +769,11 @@ RelationBuildRuleLock(Relation relation) Anum_pg_rewrite_ev_qual, pg_rewrite_tupdesc, &isnull); - ruleaction = PointerGetDatum (textout((struct varlena *) DatumGetPointer (ruleaction))); - rule_evqual_string = PointerGetDatum (textout((struct varlena *) DatumGetPointer (rule_evqual_string))); + ruleaction = PointerGetDatum(textout((struct varlena *) DatumGetPointer(ruleaction))); + rule_evqual_string = PointerGetDatum(textout((struct varlena *) DatumGetPointer(rule_evqual_string))); - rule->actions = (List *) stringToNode(DatumGetPointer (ruleaction)); - rule->qual = (Node *) stringToNode(DatumGetPointer (rule_evqual_string)); + rule->actions = (List *) stringToNode(DatumGetPointer(ruleaction)); + rule->qual = (Node *) stringToNode(DatumGetPointer(rule_evqual_string)); rules[numlocks++] = rule; if (numlocks == maxlocks) @@ -2017,7 +2020,7 @@ init_irels(void) for (i = 0; i < am->amstrategies; i++) fmgr_info(SMD(i).sk_procedure, &(SMD(i).sk_func)); - SMD(i).sk_nargs = SMD(i).sk_func.fn_nargs; + SMD(i).sk_nargs = SMD(i).sk_func.fn_nargs; /* diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 6f028de93ac..490a6417c9f 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.15 1998/02/25 13:07:50 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.16 1998/02/26 04:37:33 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -57,7 +57,7 @@ extern bool AMI_OVERRIDE; /* XXX style */ #include "utils/syscache.h" #include "catalog/indexing.h" -typedef HeapTuple(*ScanFunc) (); +typedef HeapTuple (*ScanFunc) (); /* ---------------- * Warning: cacheinfo[] below is changed, then be sure and @@ -179,7 +179,7 @@ static struct cachedesc cacheinfo[] = { 0, 0, 0}, - offsetof(TypeTupleFormData, typalign) + sizeof(char), + offsetof(TypeTupleFormData, typalign) +sizeof(char), TypeNameIndex, TypeNameIndexScan}, {TypeRelationName, /* TYPOID */ @@ -254,7 +254,7 @@ static struct cachedesc cacheinfo[] = { sizeof(FormData_pg_listener), NULL, (ScanFunc) NULL}, - {ShadowRelationName, /* USENAME */ + {ShadowRelationName, /* USENAME */ 1, {Anum_pg_shadow_usename, 0, @@ -263,7 +263,7 @@ static struct cachedesc cacheinfo[] = { sizeof(FormData_pg_shadow), NULL, (ScanFunc) NULL}, - {ShadowRelationName, /* USESYSID */ + {ShadowRelationName, /* USESYSID */ 1, {Anum_pg_shadow_usesysid, 0, @@ -392,13 +392,13 @@ InitCatalogCache() * XXX The tuple that is returned is NOT supposed to be pfree'd! */ HeapTuple -SearchSysCacheTuple(int cacheId, /* cache selection code */ +SearchSysCacheTuple(int cacheId,/* cache selection code */ Datum key1, Datum key2, Datum key3, Datum key4) { - HeapTuple tp; + HeapTuple tp; if (cacheId < 0 || cacheId >= SysCacheSize) { @@ -489,7 +489,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */ * * [callers all assume this returns a (struct varlena *). -ay 10/94] */ -void * +void * SearchSysCacheGetAttribute(int cacheId, AttrNumber attributeNumber, Datum key1, @@ -591,7 +591,7 @@ SearchSysCacheGetAttribute(int cacheId, * [identical to get_typdefault, expecting a (struct varlena *) as ret val. * some day, either of the functions should be removed -ay 10/94] */ -void * +void * TypeDefaultRetrieve(Oid typId) { HeapTuple typeTuple; diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 36855ce6eb6..63fd69b10af 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.26 1998/02/11 19:12:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.27 1998/02/26 04:37:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ elog(int lev, const char *fmt,...) va_list ap; char buf[ELOG_MAXLEN], line[ELOG_MAXLEN]; - char *bp; + char *bp; const char *cp; extern int errno, sys_nerr; @@ -162,10 +162,13 @@ elog(int lev, const char *fmt,...) pq_putstr(line); pq_flush(); } - if (Pfout == NULL) { - /* There is no socket. One explanation for this is we are running - as the Postmaster. So we'll write the message to stderr. - */ + if (Pfout == NULL) + { + + /* + * There is no socket. One explanation for this is we are running + * as the Postmaster. So we'll write the message to stderr. + */ fputs(line, stderr); } #endif /* !PG_STANDALONE */ @@ -177,7 +180,7 @@ elog(int lev, const char *fmt,...) ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */ if (!InError) { - kill(MyProcPid, 1); /* abort to traffic cop */ + kill(MyProcPid, 1); /* abort to traffic cop */ pause(); } diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c index 0851a92a5d7..ee79fa98142 100644 --- a/src/backend/utils/error/exc.c +++ b/src/backend/utils/error/exc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.19 1998/02/11 19:12:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.20 1998/02/26 04:37:35 momjian Exp $ * * NOTE * XXX this code needs improvement--check for state violations and @@ -179,7 +179,7 @@ ExcRaise(Exception *excP, ExcData data, ExcMessage message) { - ExcFrame *efp; + ExcFrame *efp; efp = ExcCurFrameP; if (efp == NULL) diff --git a/src/backend/utils/error/format.c b/src/backend/utils/error/format.c index 384da49a6f5..e76f78cbca9 100644 --- a/src/backend/utils/error/format.c +++ b/src/backend/utils/error/format.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.5 1997/09/08 02:31:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.6 1998/02/26 04:37:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ static char FormBuf[FormMaxSize]; * form * ---------------- */ -char * +char * form(const char *fmt,...) { va_list args; diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 0eb45503bb9..de248c02058 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.14 1998/02/11 19:12:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.15 1998/02/26 04:37:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,21 +33,24 @@ #include "commands/trigger.h" -static char * -fmgr_pl(char *arg0, ...) +static char * +fmgr_pl(char *arg0,...) { - va_list pvar; - FmgrValues values; - bool isNull = false; - int i; + va_list pvar; + FmgrValues values; + bool isNull = false; + int i; memset(&values, 0, sizeof(values)); - if (fmgr_pl_finfo->fn_nargs > 0) { + if (fmgr_pl_finfo->fn_nargs > 0) + { values.data[0] = arg0; - if (fmgr_pl_finfo->fn_nargs > 1) { + if (fmgr_pl_finfo->fn_nargs > 1) + { va_start(pvar, arg0); - for (i = 1; i < fmgr_pl_finfo->fn_nargs; i++) { + for (i = 1; i < fmgr_pl_finfo->fn_nargs; i++) + { values.data[i] = va_arg(pvar, char *); } va_end(pvar); @@ -57,21 +60,21 @@ fmgr_pl(char *arg0, ...) /* Call the PL handler */ CurrentTriggerData = NULL; return (*(fmgr_pl_finfo->fn_plhandler)) (fmgr_pl_finfo, - &values, - &isNull); -} + &values, + &isNull); +} -char * +char * fmgr_c(FmgrInfo *finfo, - FmgrValues * values, - bool * isNull) -{ - char *returnValue = (char *) NULL; - int n_arguments = finfo->fn_nargs; - func_ptr user_fn = fmgr_faddr(finfo); - - + FmgrValues *values, + bool *isNull) +{ + char *returnValue = (char *) NULL; + int n_arguments = finfo->fn_nargs; + func_ptr user_fn = fmgr_faddr(finfo); + + if (user_fn == (func_ptr) NULL) { @@ -84,11 +87,12 @@ fmgr_c(FmgrInfo *finfo, } /* - * If finfo contains a PL handler for this function, - * call that instead. + * If finfo contains a PL handler for this function, call that + * instead. */ - if (finfo->fn_plhandler != NULL) { - return (*(finfo->fn_plhandler))(finfo, values, isNull); + if (finfo->fn_plhandler != NULL) + { + return (*(finfo->fn_plhandler)) (finfo, values, isNull); } switch (n_arguments) @@ -190,11 +194,11 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) switch (language) { case INTERNALlanguageId: - finfo->fn_addr = - fmgr_lookupByName(procedureStruct->proname.data); + finfo->fn_addr = + fmgr_lookupByName(procedureStruct->proname.data); if (!finfo->fn_addr) elog(ERROR, "fmgr_info: function %s: not in internal table", - procedureStruct->proname.data); + procedureStruct->proname.data); break; case ClanguageId: finfo->fn_addr = fmgr_dynamic(procedureId, &(finfo->fn_nargs)); @@ -226,7 +230,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) { FmgrInfo plfinfo; - fmgr_info(((Form_pg_language)GETSTRUCT(languageTuple))->lanplcallfoid, &plfinfo); + fmgr_info(((Form_pg_language) GETSTRUCT(languageTuple))->lanplcallfoid, &plfinfo); finfo->fn_addr = (func_ptr) fmgr_pl; finfo->fn_plhandler = plfinfo.fn_addr; finfo->fn_nargs = procedureStruct->pronargs; @@ -257,7 +261,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) * Returns the return value of the invoked function if succesful, * 0 if unsuccessful. */ -char * +char * fmgr(Oid procedureId,...) { va_list pvar; @@ -295,8 +299,8 @@ fmgr(Oid procedureId,...) * funcinfo, n_arguments, args... */ #ifdef NOT_USED -char * -fmgr_ptr(FmgrInfo *finfo, ...) +char * +fmgr_ptr(FmgrInfo *finfo,...) { va_list pvar; int i; @@ -305,7 +309,7 @@ fmgr_ptr(FmgrInfo *finfo, ...) FmgrValues values; bool isNull = false; - local_finfo->fn_addr = finfo->fn_addr; + local_finfo->fn_addr = finfo->fn_addr; local_finfo->fn_plhandler = finfo->fn_plhandler; local_finfo->fn_oid = finfo->fn_oid; @@ -332,8 +336,8 @@ fmgr_ptr(FmgrInfo *finfo, ...) * function pointer field to FuncIndexInfo, it will be replace by calls * to fmgr_c(). */ -char * -fmgr_array_args(Oid procedureId, int nargs, char *args[], bool * isNull) +char * +fmgr_array_args(Oid procedureId, int nargs, char *args[], bool *isNull) { FmgrInfo finfo; diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 9a722a004c4..23f4f43d9bd 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.12 1998/02/11 19:13:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.13 1998/02/26 04:37:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -154,10 +154,10 @@ static long hash_accesses, /************************** CREATE ROUTINES **********************/ -HTAB * +HTAB * hash_create(int nelem, HASHCTL *info, int flags) { - HHDR *hctl; + HHDR *hctl; HTAB *hashp; @@ -303,8 +303,8 @@ static int init_htab(HTAB *hashp, int nelem) { SEG_OFFSET *segp; - int nbuckets; - int nsegs; + int nbuckets; + int nsegs; int l2; HHDR *hctl; @@ -387,7 +387,7 @@ hash_destroy(HTAB *hashp) if (hashp != NULL) { - SEG_OFFSET segNum; + SEG_OFFSET segNum; SEGMENT segp; int nsegs = hashp->hctl->nsegs; int j; @@ -469,7 +469,7 @@ call_hash(HTAB *hashp, char *k, int len) * foundPtr is TRUE if we found an element in the table * (FALSE if we entered one). */ -long * +long * hash_search(HTAB *hashp, char *keyPtr, HASHACTION action, /* HASH_FIND / HASH_ENTER / HASH_REMOVE @@ -480,7 +480,7 @@ hash_search(HTAB *hashp, long segment_num; long segment_ndx; SEGMENT segp; - ELEMENT *curr; + ELEMENT *curr; HHDR *hctl; BUCKET_INDEX currIndex; BUCKET_INDEX *prevIndexPtr; @@ -653,7 +653,7 @@ hash_search(HTAB *hashp, * return TRUE in the end. * */ -long * +long * hash_seq(HTAB *hashp) { static uint32 curBucket = 0; @@ -811,7 +811,7 @@ expand_table(HTAB *hashp) static int dir_realloc(HTAB *hashp) { - char *p; + char *p; char **p_ptr; long old_dirsize; long new_dirsize; diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c index 609ca80d813..6cf11d22bf6 100644 --- a/src/backend/utils/hash/hashfn.c +++ b/src/backend/utils/hash/hashfn.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.6 1998/02/11 19:13:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.7 1998/02/26 04:37:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ string_hash(char *key, int keysize) long tag_hash(int *key, int keysize) { - long h = 0; + long h = 0; /* * Convert tag to integer; Use four byte chunks in a "jump table" to @@ -130,10 +130,10 @@ tag_hash(int *key, int keysize) long disk_hash(char *key) { - int n = 0; - char *str = key; - int len = strlen(key); - int loop; + int n = 0; + char *str = key; + int len = strlen(key); + int loop; #define HASHC n = *str++ + 65599 * n diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 7d118676887..55ec93cc75d 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.20 1998/02/25 13:08:00 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.21 1998/02/26 04:37:56 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -35,7 +35,7 @@ #include "libpq/pqcomm.h" #include "catalog/catname.h" -ProtocolVersion FrontendProtocol = PG_PROTOCOL_LATEST; +ProtocolVersion FrontendProtocol = PG_PROTOCOL_LATEST; int Portfd = -1; int Noversion = 0; int Quiet = 1; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 359adfb25b6..abd6aa8b2a2 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.11 1998/02/25 13:08:09 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.12 1998/02/26 04:38:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,6 +54,7 @@ extern char *DatabasePath; #ifdef CYR_RECODE unsigned char RecodeForwTable[128]; unsigned char RecodeBackTable[128]; + #endif @@ -228,7 +229,7 @@ GetProcessingMode() * Returns path to database. * */ -char * +char * GetDatabasePath() { return strdup(DatabasePath); @@ -238,7 +239,7 @@ GetDatabasePath() * GetDatabaseName -- * Returns name of database. */ -char * +char * GetDatabaseName() { return strdup(DatabaseName); @@ -264,7 +265,7 @@ SetDatabaseName(char *name) } #ifdef CYR_RECODE -#define MAX_TOKEN 80 +#define MAX_TOKEN 80 /* Some standard C libraries, including GNU, have an isblank() function. Others, including Solaris, do not. So we have our own. @@ -326,80 +327,87 @@ read_through_eol(FILE *file) while (c != '\n' && c != EOF); } -void SetCharSet() +void +SetCharSet() { - FILE *file; - char *p,c,eof=false; - char *map_file; - char buf[MAX_TOKEN]; - int i; - unsigned char FromChar,ToChar; - - for(i=0; i<128; i++) - { - RecodeForwTable[i] = i+128; - RecodeBackTable[i] = i+128; - } - - p = getenv("PG_RECODETABLE"); - if (p && *p != '\0') - { - map_file = (char *) malloc((strlen(DataDir) + - strlen(p)+2)*sizeof(char)); - sprintf(map_file, "%s/%s", DataDir, p); - file = fopen(map_file, "r"); - if (file == NULL) - return; - eof=false; - while (!eof) - { - c = getc(file); - ungetc(c, file); - if (c == EOF) - eof = true; - else - { - if (c == '#') - read_through_eol(file); - else - { - /* Read the FromChar */ - next_token(file, buf, sizeof(buf)); - if (buf[0] != '\0') - { - FromChar = strtoul(buf,0,0); - /* Read the ToChar */ - next_token(file, buf, sizeof(buf)); - if (buf[0] != '\0') - { - ToChar = strtoul(buf,0,0); - RecodeForwTable[FromChar-128] = ToChar; - RecodeBackTable[ToChar-128] = FromChar; - } - read_through_eol(file); - } - } - } - } - fclose(file); - free(map_file); - } + FILE *file; + char *p, + c, + eof = false; + char *map_file; + char buf[MAX_TOKEN]; + int i; + unsigned char FromChar, + ToChar; + + for (i = 0; i < 128; i++) + { + RecodeForwTable[i] = i + 128; + RecodeBackTable[i] = i + 128; + } + + p = getenv("PG_RECODETABLE"); + if (p && *p != '\0') + { + map_file = (char *) malloc((strlen(DataDir) + + strlen(p) + 2) * sizeof(char)); + sprintf(map_file, "%s/%s", DataDir, p); + file = fopen(map_file, "r"); + if (file == NULL) + return; + eof = false; + while (!eof) + { + c = getc(file); + ungetc(c, file); + if (c == EOF) + eof = true; + else + { + if (c == '#') + read_through_eol(file); + else + { + /* Read the FromChar */ + next_token(file, buf, sizeof(buf)); + if (buf[0] != '\0') + { + FromChar = strtoul(buf, 0, 0); + /* Read the ToChar */ + next_token(file, buf, sizeof(buf)); + if (buf[0] != '\0') + { + ToChar = strtoul(buf, 0, 0); + RecodeForwTable[FromChar - 128] = ToChar; + RecodeBackTable[ToChar - 128] = FromChar; + } + read_through_eol(file); + } + } + } + } + fclose(file); + free(map_file); + } } -char* convertstr(unsigned char *buff,int len,int dest) +char * +convertstr(unsigned char *buff, int len, int dest) { - int i; - char *ch=buff; - for (i = 0; i < len; i++,buff++) - { - if (*buff >127) - if (dest) - *buff = RecodeForwTable[*buff-128]; - else - *buff = RecodeBackTable[*buff-128]; - } - return ch; + int i; + char *ch = buff; + + for (i = 0; i < len; i++, buff++) + { + if (*buff > 127) + if (dest) + *buff = RecodeForwTable[*buff - 128]; + else + *buff = RecodeBackTable[*buff - 128]; + } + return ch; } + #endif /* ---------------- @@ -413,7 +421,7 @@ char* convertstr(unsigned char *buff,int len,int dest) * in pg_proc.h). Define GetPgUserName() as a macro - tgl 97/04/26 * ---------------- */ -char * +char * getpgusername() { return UserName; diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 5c367013858..baac25cfbee 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.24 1998/02/23 18:43:06 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.25 1998/02/26 04:38:12 momjian Exp $ * * NOTES * InitPostgres() is the function called from PostgresMain @@ -49,7 +49,8 @@ #include "storage/bufmgr.h" #include "access/transam.h" /* XXX dependency problem */ #include "utils/syscache.h" -#include "storage/bufpage.h" /* for page layout, for InitMyDatabaseInfo() */ +#include "storage/bufpage.h" /* for page layout, for + * InitMyDatabaseInfo() */ #include "storage/sinval.h" #include "storage/sinvaladt.h" #include "storage/lmgr.h" @@ -117,7 +118,7 @@ InitMyDatabaseInfo(char *name) { Oid owner; char *path, - myPath[MAXPGPATH+1]; + myPath[MAXPGPATH + 1]; SetDatabaseName(name); GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath); @@ -132,7 +133,7 @@ InitMyDatabaseInfo(char *name) SetDatabasePath(path); return; -} /* InitMyDatabaseInfo() */ +} /* InitMyDatabaseInfo() */ /* @@ -180,15 +181,15 @@ VerifySystemDatabase() ValidatePgVersion(DataDir, &reason); if (reason != NULL) sprintf(errormsg, - "InitPostgres could not validate that the database" - " system version is compatible with this level of" - " Postgres.\n\tYou may need to run initdb to create" - " a new database system.\n\t%s", reason); + "InitPostgres could not validate that the database" + " system version is compatible with this level of" + " Postgres.\n\tYou may need to run initdb to create" + " a new database system.\n\t%s", reason); } if (errormsg[0] != '\0') elog(FATAL, errormsg); /* Above does not return */ -} /* VerifySystemDatabase() */ +} /* VerifySystemDatabase() */ static void @@ -207,42 +208,43 @@ VerifyMyDatabase() if ((fd = open(myPath, O_RDONLY, 0)) == -1) sprintf(errormsg, - "Database '%s' does not exist." + "Database '%s' does not exist." "\n\tWe know this because the directory '%s' does not exist." - "\n\tYou can create a database with the SQL command" - " CREATE DATABASE.\n\tTo see what databases exist," - " look at the subdirectories of '%s/base/'.", - name, myPath, DataDir); + "\n\tYou can create a database with the SQL command" + " CREATE DATABASE.\n\tTo see what databases exist," + " look at the subdirectories of '%s/base/'.", + name, myPath, DataDir); else { close(fd); ValidatePgVersion(myPath, &reason); if (reason != NULL) sprintf(errormsg, - "InitPostgres could not validate that the database" - " version is compatible with this level of Postgres" - "\n\teven though the database system as a whole" - " appears to be at a compatible level." - "\n\tYou may need to recreate the database with SQL" - " commands DROP DATABASE and CREATE DATABASE." - "\n\t%s", reason); + "InitPostgres could not validate that the database" + " version is compatible with this level of Postgres" + "\n\teven though the database system as a whole" + " appears to be at a compatible level." + "\n\tYou may need to recreate the database with SQL" + " commands DROP DATABASE and CREATE DATABASE." + "\n\t%s", reason); else { + /* * The directories and PG_VERSION files are in order. */ - int rc; /* return code from some function we call */ + int rc; /* return code from some function we call */ #ifdef FILEDEBUG -printf("Try changing directory for database %s to %s\n", name, myPath); + printf("Try changing directory for database %s to %s\n", name, myPath); #endif rc = chdir(myPath); if (rc < 0) sprintf(errormsg, - "InitPostgres unable to change " - "current directory to '%s', errno = %s (%d).", - myPath, strerror(errno), errno); + "InitPostgres unable to change " + "current directory to '%s', errno = %s (%d).", + myPath, strerror(errno), errno); else errormsg[0] = '\0'; } @@ -251,7 +253,7 @@ printf("Try changing directory for database %s to %s\n", name, myPath); if (errormsg[0] != '\0') elog(FATAL, errormsg); /* Above does not return */ -} /* VerifyMyDatabase() */ +} /* VerifyMyDatabase() */ /* -------------------------------- @@ -280,9 +282,9 @@ InitUserid() static void InitCommunication() { - char *postid; /* value of environment variable */ - char *postport; /* value of environment variable */ - char *ipc_key; /* value of environemnt variable */ + char *postid; /* value of environment variable */ + char *postport; /* value of environment variable */ + char *ipc_key; /* value of environemnt variable */ IPCKey key = 0; /* ---------------- @@ -303,14 +305,17 @@ InitCommunication() } - ipc_key = getenv("IPC_KEY"); - if (!PointerIsValid(ipc_key)) { - key = -1; - } else { - key = atoi(ipc_key); - Assert(MyBackendTag >= 0); - } - + ipc_key = getenv("IPC_KEY"); + if (!PointerIsValid(ipc_key)) + { + key = -1; + } + else + { + key = atoi(ipc_key); + Assert(MyBackendTag >= 0); + } + postport = getenv("POSTPORT"); if (PointerIsValid(postport)) @@ -329,11 +334,8 @@ InitCommunication() * To enable emulation, run the following shell commands (in addition * to enabling this goto) * - * % setenv POSTID 1 - * % setenv POSTPORT 4321 - * % setenv IPC_KEY 4321000 - * % postmaster & - * % kill -9 %1 + * % setenv POSTID 1 % setenv POSTPORT 4321 % setenv IPC_KEY 4321000 + * % postmaster & % kill -9 %1 * * Upon doing this, Postmaster will have allocated the shared memory * resources that Postgres will attach to if you enable @@ -503,19 +505,19 @@ InitPostgres(char *name) /* database name */ /* * ******************************** + * * code after this point assumes we are in the proper directory! * - * So, how do we implement alternate locations for databases? - * There are two possible locations for tables and we need to look - * in DataDir/pg_database to find the true location of an - * individual database. We can brute-force it as done in - * InitMyDatabaseInfo(), or we can be patient and wait until we - * open pg_database gracefully. Will try that, but may not work... - * - thomas 1997-11-01 - * ******************************** + * So, how do we implement alternate locations for databases? There are + * two possible locations for tables and we need to look in + * DataDir/pg_database to find the true location of an individual + * database. We can brute-force it as done in InitMyDatabaseInfo(), or + * we can be patient and wait until we open pg_database gracefully. + * Will try that, but may not work... - thomas 1997-11-01 ******************************** + * */ - /* Does not touch files (?) - thomas 1997-11-01 */ + /* Does not touch files (?) - thomas 1997-11-01 */ smgrinit(); /* ---------------- @@ -534,7 +536,8 @@ InitPostgres(char *name) /* database name */ * after initdb is done. -mer 15 June 1992 */ RelationInitialize(); /* pre-allocated reldescs created here */ - InitializeTransactionSystem(); /* pg_log,etc init/crash recovery here */ + InitializeTransactionSystem(); /* pg_log,etc init/crash recovery + * here */ LockDisable(false); @@ -564,7 +567,7 @@ InitPostgres(char *name) /* database name */ /* ---------------- * initialize the access methods. - * Does not touch files (?) - thomas 1997-11-01 + * Does not touch files (?) - thomas 1997-11-01 * ---------------- */ initam(); @@ -574,8 +577,10 @@ InitPostgres(char *name) /* database name */ * ---------------- */ zerocaches(); - /* Does not touch files since all routines are builtins (?) - * - thomas 1997-11-01 + + /* + * Does not touch files since all routines are builtins (?) - thomas + * 1997-11-01 */ InitCatalogCache(); diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index 24087cdafa6..cec5b306671 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.6 1998/01/31 04:39:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.7 1998/02/26 04:38:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,23 +41,23 @@ GetDatabaseInfo(char *name, Oid *owner, char *path) { Oid dbowner, dbid; - char dbpath[MAXPGPATH+1]; + char dbpath[MAXPGPATH + 1]; text *dbtext; Relation dbrel; - HeapTuple dbtup; - HeapTuple tup; - Buffer buf; + HeapTuple dbtup; + HeapTuple tup; + Buffer buf; HeapScanDesc scan; ScanKeyData scanKey; dbrel = heap_openr(DatabaseRelationName); if (!RelationIsValid(dbrel)) - elog(FATAL,"GetDatabaseInfo: cannot open relation \"%-.*s\"", - DatabaseRelationName); + elog(FATAL, "GetDatabaseInfo: cannot open relation \"%-.*s\"", + DatabaseRelationName); ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname, - NameEqualRegProcedure, NameGetDatum(name)); + NameEqualRegProcedure, NameGetDatum(name)); scan = heap_beginscan(dbrel, 0, false, 1, &scanKey); if (!HeapScanIsValid(scan)) @@ -80,61 +80,65 @@ GetDatabaseInfo(char *name, Oid *owner, char *path) if (!HeapTupleIsValid(dbtup)) { - elog(NOTICE,"GetDatabaseInfo: %s entry not found %s", - DatabaseRelationName,name); + elog(NOTICE, "GetDatabaseInfo: %s entry not found %s", + DatabaseRelationName, name); return TRUE; } dbowner = (Oid) heap_getattr(dbtup, - Anum_pg_database_datdba, - RelationGetTupleDescriptor(dbrel), - (char *) NULL); + Anum_pg_database_datdba, + RelationGetTupleDescriptor(dbrel), + (char *) NULL); dbid = dbtup->t_oid; - + dbtext = (text *) heap_getattr(dbtup, - Anum_pg_database_datpath, - RelationGetTupleDescriptor(dbrel), - (char *) NULL); + Anum_pg_database_datpath, + RelationGetTupleDescriptor(dbrel), + (char *) NULL); - memcpy(dbpath, VARDATA(dbtext), (VARSIZE(dbtext)-VARHDRSZ)); - *(dbpath+(VARSIZE(dbtext)-VARHDRSZ)) = '\0'; + memcpy(dbpath, VARDATA(dbtext), (VARSIZE(dbtext) - VARHDRSZ)); + *(dbpath + (VARSIZE(dbtext) - VARHDRSZ)) = '\0'; heap_close(dbrel); owner = palloc(sizeof(Oid)); *owner = dbowner; - path = palloc(strlen(dbpath)+1); + path = palloc(strlen(dbpath) + 1); strcpy(path, dbpath); return FALSE; -} /* GetDatabaseInfo() */ +} /* GetDatabaseInfo() */ char * ExpandDatabasePath(char *dbpath) { char *path; char *cp; - char buf[MAXPGPATH+1]; + char buf[MAXPGPATH + 1]; /* leading path delimiter? then already absolute path */ if (*dbpath == SEP_CHAR) { cp = strrchr(dbpath, SEP_CHAR); - strncpy(buf,dbpath,(cp-dbpath)); - sprintf(&buf[cp-dbpath], "%cbase%c%s", SEP_CHAR, SEP_CHAR, (cp+1)); + strncpy(buf, dbpath, (cp - dbpath)); + sprintf(&buf[cp - dbpath], "%cbase%c%s", SEP_CHAR, SEP_CHAR, (cp + 1)); } /* path delimiter somewhere? then has leading environment variable */ else if (strchr(dbpath, SEP_CHAR) != NULL) { cp = strchr(dbpath, SEP_CHAR); - strncpy(buf,dbpath,(cp-dbpath)); - buf[cp-dbpath] = '\0'; + strncpy(buf, dbpath, (cp - dbpath)); + buf[cp - dbpath] = '\0'; path = getenv(buf); - /* problem getting environment variable? let calling routine handle it */ + + /* + * problem getting environment variable? let calling routine + * handle it + */ if (path == NULL) return path; - sprintf(buf, "%s%cbase%c%s", path, SEP_CHAR, SEP_CHAR, (cp+1)); + sprintf(buf, "%s%cbase%c%s", path, SEP_CHAR, SEP_CHAR, (cp + 1)); } /* no path delimiter? then add the default path prefixes */ else @@ -142,11 +146,11 @@ ExpandDatabasePath(char *dbpath) sprintf(buf, "%s%cbase%c%s", DataDir, SEP_CHAR, SEP_CHAR, dbpath); } - path = palloc(strlen(buf)+1); - strcpy(path,buf); + path = palloc(strlen(buf) + 1); + strcpy(path, buf); return path; -} /* ExpandDatabasePath() */ +} /* ExpandDatabasePath() */ /* -------------------------------- @@ -269,8 +273,8 @@ GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path) { *db_id = tup->t_oid; strncpy(path, VARDATA(&(tup_db->datpath)), - (VARSIZE(&(tup_db->datpath))-VARHDRSZ)); - *(path+VARSIZE(&(tup_db->datpath))-VARHDRSZ) = '\0'; + (VARSIZE(&(tup_db->datpath)) - VARHDRSZ)); + *(path + VARSIZE(&(tup_db->datpath)) - VARHDRSZ) = '\0'; goto done; } @@ -280,4 +284,4 @@ GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path) done: close(dbfd); pfree(pg); -} /* GetRawDatabaseInfo() */ +} /* GetRawDatabaseInfo() */ diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index b2fc83e5f71..880b8cddc72 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.6 1997/09/08 21:49:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.7 1998/02/26 04:38:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -293,7 +293,7 @@ MemoryContextRealloc(MemoryContext context, * BadArgumentsErr if firstTime is true for subsequent calls. */ #ifdef NOT_USED -char * +char * MemoryContextGetName(MemoryContext context) { AssertState(MemoryContextEnabled); diff --git a/src/backend/utils/mmgr/palloc.c b/src/backend/utils/mmgr/palloc.c index bd680464b93..e4d822156f2 100644 --- a/src/backend/utils/mmgr/palloc.c +++ b/src/backend/utils/mmgr/palloc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.5 1997/09/08 02:32:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.6 1998/02/26 04:38:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ * NonallocatedPointer if pointer was not returned by palloc or repalloc * or may have been subsequently freed. */ -void * +void * palloc(Size size) { #ifdef PALLOC_IS_MALLOC @@ -94,7 +94,7 @@ pfree(void *pointer) * NonallocatedPointer if pointer was not returned by palloc or repalloc * or may have been freed already. */ -void * +void * repalloc(void *pointer, Size size) { #ifdef PALLOC_IS_MALLOC @@ -107,7 +107,7 @@ repalloc(void *pointer, Size size) /* pstrdup allocates space for and copies a string just like strdup except it uses palloc instead of malloc */ -char * +char * pstrdup(char *string) { char *nstr; diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 10f619e5ce0..f56bc4cf0ae 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.9 1997/09/18 20:22:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.10 1998/02/26 04:38:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -704,7 +704,7 @@ PortalGetQueryDesc(Portal portal) * BadState if called when disabled. * BadArg if portal is invalid. */ -EState * +EState * PortalGetState(Portal portal) { AssertState(PortalManagerEnabled); diff --git a/src/backend/utils/sort/lselect.c b/src/backend/utils/sort/lselect.c index 80b9fce42a5..527ecd198f9 100644 --- a/src/backend/utils/sort/lselect.c +++ b/src/backend/utils/sort/lselect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.12 1998/02/11 19:13:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.13 1998/02/26 04:38:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -140,7 +140,7 @@ gettuple(struct leftist ** treep, else *treep = lmerge(tp->lt_left, tp->lt_right, context); - pfree (tp); + pfree(tp); return (tup); } @@ -186,7 +186,7 @@ puttuple(struct leftist ** treep, int tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context) { - Datum lattr, + Datum lattr, rattr; int nkey = 0; int result = 0; @@ -212,12 +212,12 @@ tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context) if (context->scanKeys[nkey].sk_flags & SK_COMMUTE) { if (!(result = - (long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (rattr, lattr))) + (long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (rattr, lattr))) result = -(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (lattr, rattr); } else if (!(result = - (long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (lattr, rattr))) + (long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (lattr, rattr))) result = -(long) (*fmgr_faddr(&context->scanKeys[nkey].sk_func)) (rattr, lattr); nkey++; diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index 9bb7de5b68b..fa439f520ed 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.38 1998/02/23 06:27:39 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.39 1998/02/26 04:38:29 momjian Exp $ * * NOTES * Sorts the first relation into the second relation. @@ -57,32 +57,32 @@ #include "utils/psort.h" #include "utils/rel.h" -static bool createfirstrun(Sort * node); -static bool createrun(Sort * node, FILE * file); -static void destroytape(FILE * file); -static void dumptuples(FILE * file, Sort * node); +static bool createfirstrun(Sort *node); +static bool createrun(Sort *node, FILE *file); +static void destroytape(FILE *file); +static void dumptuples(FILE *file, Sort *node); static FILE *gettape(void); -static void initialrun(Sort * node); -static void inittapes(Sort * node); -static void merge(Sort * node, struct tape * dest); -static FILE *mergeruns(Sort * node); +static void initialrun(Sort *node); +static void inittapes(Sort *node); +static void merge(Sort *node, struct tape * dest); +static FILE *mergeruns(Sort *node); static HeapTuple tuplecopy(HeapTuple tup); -static int _psort_cmp (HeapTuple *ltup, HeapTuple *rtup); +static int _psort_cmp(HeapTuple *ltup, HeapTuple *rtup); #define TEMPDIR "./" -/* +/* * tlenzero used to delimit runs; both vars below must have * the same size as HeapTuple->t_len */ static unsigned int tlenzero = 0; static unsigned int tlendummy; -static TupleDesc PsortTupDesc; -static ScanKey PsortKeys; /* used by _psort_cmp */ -static int PsortNkeys; +static TupleDesc PsortTupDesc; +static ScanKey PsortKeys; /* used by _psort_cmp */ +static int PsortNkeys; /* * old psort global variables @@ -127,7 +127,7 @@ static int PsortNkeys; * Allocates and initializes sort node's psort state. */ bool -psort_begin(Sort * node, int nkeys, ScanKey key) +psort_begin(Sort *node, int nkeys, ScanKey key) { node->psortstate = (struct Psortstate *) palloc(sizeof(struct Psortstate)); @@ -173,9 +173,9 @@ psort_begin(Sort * node, int nkeys, ScanKey key) * number of allocated tapes */ static void -inittapes(Sort * node) +inittapes(Sort *node) { - int i; + int i; struct tape *tp; Assert(node != (Sort *) NULL); @@ -245,7 +245,7 @@ inittapes(Sort * node) #define USEMEM(NODE,AMT) PS(node)->treeContext.sortMem -= (AMT) #define FREEMEM(NODE,AMT) PS(node)->treeContext.sortMem += (AMT) -#define LACKMEM(NODE) (PS(node)->treeContext.sortMem <= BLCKSZ) /* not accurate */ +#define LACKMEM(NODE) (PS(node)->treeContext.sortMem <= BLCKSZ) /* not accurate */ #define TRACEMEM(FUNC) #define TRACEOUT(FUNC, TUP) @@ -274,7 +274,7 @@ inittapes(Sort * node) * Also, perhaps allocate tapes when needed. Split into 2 funcs. */ static void -initialrun(Sort * node) +initialrun(Sort *node) { /* struct tuple *tup; */ struct tape *tp; @@ -288,22 +288,25 @@ initialrun(Sort * node) if (createfirstrun(node)) { - Assert (PS(node)->using_tape_files); + Assert(PS(node)->using_tape_files); extrapasses = 0; } - else /* all tuples fetched */ + else +/* all tuples fetched */ { - if ( !PS(node)->using_tape_files ) /* empty or sorted in memory */ + if (!PS(node)->using_tape_files) /* empty or sorted in + * memory */ return; - /* + + /* * if PS(node)->Tuples == NULL then we have single (sorted) run - * which can be used as result grab file! So, we may avoid + * which can be used as result grab file! So, we may avoid * mergeruns - it will just copy this run to new file. */ - if ( PS(node)->Tuples == NULL ) + if (PS(node)->Tuples == NULL) { PS(node)->psort_grab_file = PS(node)->Tape->tp_file; - rewind (PS(node)->psort_grab_file); + rewind(PS(node)->psort_grab_file); return; } extrapasses = 2; @@ -352,7 +355,7 @@ initialrun(Sort * node) } /* - * createfirstrun - tries to sort tuples in memory using qsort + * createfirstrun - tries to sort tuples in memory using qsort * until LACKMEM; if not enough memory then switches * to tape method * @@ -363,12 +366,12 @@ initialrun(Sort * node) static bool createfirstrun(Sort *node) { - HeapTuple tup; - bool foundeor = false; - HeapTuple *memtuples; - int t_last = -1; - int t_free = 1000; - TupleTableSlot *cr_slot; + HeapTuple tup; + bool foundeor = false; + HeapTuple *memtuples; + int t_last = -1; + int t_free = 1000; + TupleTableSlot *cr_slot; Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -376,15 +379,15 @@ createfirstrun(Sort *node) Assert(PS(node)->memtuples == NULL); Assert(PS(node)->tupcount == 0); if (LACKMEM(node)) - elog (FATAL, "psort: LACKMEM in createfirstrun"); - + elog(FATAL, "psort: LACKMEM in createfirstrun"); + memtuples = palloc(t_free * sizeof(HeapTuple)); - + for (;;) { - if ( LACKMEM (node) ) + if (LACKMEM(node)) break; - + /* * About to call ExecProcNode, it can mess up the state if it * eventually calls another Sort node. So must stow it away here @@ -399,28 +402,28 @@ createfirstrun(Sort *node) foundeor = true; break; } - + tup = tuplecopy(cr_slot->val); ExecClearTuple(cr_slot); IncrProcessed(); USEMEM(node, tup->t_len); TRACEMEM(createfirstrun); - if ( t_free <= 0 ) + if (t_free <= 0) { - t_free = 1000; - memtuples = repalloc (memtuples, - (t_last + t_free + 1) * sizeof (HeapTuple)); + t_free = 1000; + memtuples = repalloc(memtuples, + (t_last + t_free + 1) * sizeof(HeapTuple)); } t_last++; t_free--; memtuples[t_last] = tup; } - - if ( t_last < 0 ) /* empty */ + + if (t_last < 0) /* empty */ { - Assert (foundeor); - pfree (memtuples); + Assert(foundeor); + pfree(memtuples); return (false); } t_last++; @@ -428,27 +431,27 @@ createfirstrun(Sort *node) PsortTupDesc = PS(node)->treeContext.tupDesc; PsortKeys = PS(node)->treeContext.scanKeys; PsortNkeys = PS(node)->treeContext.nKeys; - qsort (memtuples, t_last, sizeof (HeapTuple), - (int (*)(const void *,const void *))_psort_cmp); - - if ( LACKMEM (node) ) /* in-memory sort is impossible */ + qsort(memtuples, t_last, sizeof(HeapTuple), + (int (*) (const void *, const void *)) _psort_cmp); + + if (LACKMEM(node)) /* in-memory sort is impossible */ { - int t; - - Assert (!foundeor); + int t; + + Assert(!foundeor); inittapes(node); /* put tuples into leftist tree for createrun */ - for (t = t_last - 1 ; t >= 0; t--) + for (t = t_last - 1; t >= 0; t--) puttuple(&PS(node)->Tuples, memtuples[t], 0, &PS(node)->treeContext); - pfree (memtuples); - foundeor = !createrun (node, PS(node)->Tape->tp_file); + pfree(memtuples); + foundeor = !createrun(node, PS(node)->Tape->tp_file); } else { - Assert (foundeor); + Assert(foundeor); PS(node)->memtuples = memtuples; } - + return (!foundeor); } @@ -464,24 +467,24 @@ createfirstrun(Sort *node) * Tuples contains the tuples for the following run upon exit */ static bool -createrun(Sort * node, FILE * file) +createrun(Sort *node, FILE *file) { HeapTuple lasttuple; HeapTuple tup; - TupleTableSlot *cr_slot; - HeapTuple *memtuples; - int t_last = -1; - int t_free = 1000; - bool foundeor = false; - short junk; + TupleTableSlot *cr_slot; + HeapTuple *memtuples; + int t_last = -1; + int t_free = 1000; + bool foundeor = false; + short junk; Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); - Assert (PS(node)->using_tape_files); + Assert(PS(node)->using_tape_files); lasttuple = NULL; memtuples = palloc(t_free * sizeof(HeapTuple)); - + for (;;) { while (LACKMEM(node) && PS(node)->Tuples != NULL) @@ -493,14 +496,14 @@ createrun(Sort * node, FILE * file) TRACEMEM(createrun); } lasttuple = gettuple(&PS(node)->Tuples, &junk, - &PS(node)->treeContext); + &PS(node)->treeContext); PUTTUP(node, lasttuple, file); TRACEOUT(createrun, lasttuple); } - + if (LACKMEM(node)) break; - + /* * About to call ExecProcNode, it can mess up the state if it * eventually calls another Sort node. So must stow it away here @@ -528,11 +531,11 @@ createrun(Sort * node, FILE * file) if (lasttuple != NULL && tuplecmp(tup, lasttuple, &PS(node)->treeContext)) { - if ( t_free <= 0 ) + if (t_free <= 0) { - t_free = 1000; - memtuples = repalloc (memtuples, - (t_last + t_free + 1) * sizeof (HeapTuple)); + t_free = 1000; + memtuples = repalloc(memtuples, + (t_last + t_free + 1) * sizeof(HeapTuple)); } t_last++; t_free--; @@ -549,23 +552,23 @@ createrun(Sort * node, FILE * file) } dumptuples(file, node); ENDRUN(file); /* delimit the end of the run */ - + t_last++; /* put tuples for the next run into leftist tree */ - if ( t_last >= 1 ) + if (t_last >= 1) { - int t; - + int t; + PsortTupDesc = PS(node)->treeContext.tupDesc; PsortKeys = PS(node)->treeContext.scanKeys; PsortNkeys = PS(node)->treeContext.nKeys; - qsort (memtuples, t_last, sizeof (HeapTuple), - (int (*)(const void *,const void *))_psort_cmp); - for (t = t_last - 1 ; t >= 0; t--) + qsort(memtuples, t_last, sizeof(HeapTuple), + (int (*) (const void *, const void *)) _psort_cmp); + for (t = t_last - 1; t >= 0; t--) puttuple(&PS(node)->Tuples, memtuples[t], 0, &PS(node)->treeContext); } - - pfree (memtuples); + + pfree(memtuples); return (!foundeor); } @@ -598,7 +601,7 @@ tuplecopy(HeapTuple tup) * file of tuples in order */ static FILE * -mergeruns(Sort * node) +mergeruns(Sort *node) { struct tape *tp; @@ -625,17 +628,17 @@ mergeruns(Sort * node) * (polyphase merge Alg.D(D5)--Knuth, Vol.3, p271) */ static void -merge(Sort * node, struct tape * dest) +merge(Sort *node, struct tape * dest) { - HeapTuple tup; + HeapTuple tup; struct tape *lasttp; /* (TAPE[P]) */ struct tape *tp; struct leftist *tuples; - FILE *destfile; - int times; /* runs left to merge */ - int outdummy; /* complete dummy runs */ - short fromtape; - unsigned int tuplen; + FILE *destfile; + int times; /* runs left to merge */ + int outdummy; /* complete dummy runs */ + short fromtape; + unsigned int tuplen; Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -732,7 +735,7 @@ merge(Sort * node, struct tape * dest) * dumptuples - stores all the tuples in tree into file */ static void -dumptuples(FILE * file, Sort * node) +dumptuples(FILE *file, Sort *node) { struct leftist *tp; struct leftist *newp; @@ -740,7 +743,7 @@ dumptuples(FILE * file, Sort * node) LeftistContext context = &PS(node)->treeContext; HeapTuple tup; - Assert (PS(node)->using_tape_files); + Assert(PS(node)->using_tape_files); tp = *treep; while (tp != NULL) @@ -767,7 +770,7 @@ dumptuples(FILE * file, Sort * node) * a NULL indicating the last tuple has been processed. */ HeapTuple -psort_grabtuple(Sort * node, bool * should_free) +psort_grabtuple(Sort *node, bool *should_free) { HeapTuple tup; @@ -776,10 +779,10 @@ psort_grabtuple(Sort * node, bool * should_free) if (PS(node)->using_tape_files == true) { - unsigned int tuplen; - + unsigned int tuplen; + *should_free = true; - if (ScanDirectionIsForward (node->plan.state->es_direction)) + if (ScanDirectionIsForward(node->plan.state->es_direction)) { if (PS(node)->all_fetched) return NULL; @@ -790,7 +793,7 @@ psort_grabtuple(Sort * node, bool * should_free) GETTUP(node, tup, tuplen, PS(node)->psort_grab_file); /* Update current merged sort file position */ - PS(node)->psort_current += tuplen + sizeof (tlendummy); + PS(node)->psort_current += tuplen + sizeof(tlendummy); return tup; } else @@ -800,64 +803,72 @@ psort_grabtuple(Sort * node, bool * should_free) } } /* Backward */ - if (PS(node)->psort_current <= sizeof (tlendummy)) + if (PS(node)->psort_current <= sizeof(tlendummy)) return NULL; - /* - * if all tuples are fetched already then we return last tuple, + + /* + * if all tuples are fetched already then we return last tuple, * else - tuple before last returned. */ if (PS(node)->all_fetched) { - /* psort_current is pointing to the zero tuplen at the end of file */ - fseek(PS(node)->psort_grab_file, - PS(node)->psort_current - sizeof (tlendummy), SEEK_SET); + + /* + * psort_current is pointing to the zero tuplen at the end of + * file + */ + fseek(PS(node)->psort_grab_file, + PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); GETLEN(tuplen, PS(node)->psort_grab_file); if (PS(node)->psort_current < tuplen) - elog (FATAL, "psort_grabtuple: too big last tuple len in backward scan"); + elog(FATAL, "psort_grabtuple: too big last tuple len in backward scan"); PS(node)->all_fetched = false; } else { /* move to position of end tlen of prev tuple */ - PS(node)->psort_current -= sizeof (tlendummy); + PS(node)->psort_current -= sizeof(tlendummy); fseek(PS(node)->psort_grab_file, PS(node)->psort_current, SEEK_SET); - GETLEN(tuplen, PS(node)->psort_grab_file); /* get tlen of prev tuple */ + GETLEN(tuplen, PS(node)->psort_grab_file); /* get tlen of prev + * tuple */ if (tuplen == 0) - elog (FATAL, "psort_grabtuple: tuplen is 0 in backward scan"); - if (PS(node)->psort_current <= tuplen + sizeof (tlendummy)) - { /* prev tuple should be first one */ + elog(FATAL, "psort_grabtuple: tuplen is 0 in backward scan"); + if (PS(node)->psort_current <= tuplen + sizeof(tlendummy)) + { /* prev tuple should be first one */ if (PS(node)->psort_current != tuplen) - elog (FATAL, "psort_grabtuple: first tuple expected in backward scan"); + elog(FATAL, "psort_grabtuple: first tuple expected in backward scan"); PS(node)->psort_current = 0; fseek(PS(node)->psort_grab_file, PS(node)->psort_current, SEEK_SET); return NULL; } - /* - * Get position of prev tuple. This tuple becomes current tuple - * now and we have to return previous one. + + /* + * Get position of prev tuple. This tuple becomes current + * tuple now and we have to return previous one. */ PS(node)->psort_current -= tuplen; /* move to position of end tlen of prev tuple */ - fseek(PS(node)->psort_grab_file, - PS(node)->psort_current - sizeof (tlendummy), SEEK_SET); + fseek(PS(node)->psort_grab_file, + PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); GETLEN(tuplen, PS(node)->psort_grab_file); - if (PS(node)->psort_current < tuplen + sizeof (tlendummy)) - elog (FATAL, "psort_grabtuple: too big tuple len in backward scan"); + if (PS(node)->psort_current < tuplen + sizeof(tlendummy)) + elog(FATAL, "psort_grabtuple: too big tuple len in backward scan"); } - /* - * move to prev (or last) tuple start position + sizeof(t_len) + + /* + * move to prev (or last) tuple start position + sizeof(t_len) */ fseek(PS(node)->psort_grab_file, - PS(node)->psort_current - tuplen, SEEK_SET); + PS(node)->psort_current - tuplen, SEEK_SET); tup = (HeapTuple) palloc((unsigned) tuplen); SETTUPLEN(tup, tuplen); GETTUP(node, tup, tuplen, PS(node)->psort_grab_file); - return tup; /* file position is equal to psort_current */ + return tup; /* file position is equal to psort_current */ } else { *should_free = false; - if (ScanDirectionIsForward (node->plan.state->es_direction)) + if (ScanDirectionIsForward(node->plan.state->es_direction)) { if (PS(node)->psort_current < PS(node)->tupcount) return (PS(node)->memtuples[PS(node)->psort_current++]); @@ -870,15 +881,16 @@ psort_grabtuple(Sort * node, bool * should_free) /* Backward */ if (PS(node)->psort_current <= 0) return NULL; - /* - * if all tuples are fetched already then we return last tuple, + + /* + * if all tuples are fetched already then we return last tuple, * else - tuple before last returned. */ - if (PS(node)->all_fetched) + if (PS(node)->all_fetched) PS(node)->all_fetched = false; else { - PS(node)->psort_current--; /* last returned tuple */ + PS(node)->psort_current--; /* last returned tuple */ if (PS(node)->psort_current <= 0) return NULL; } @@ -890,7 +902,7 @@ psort_grabtuple(Sort * node, bool * should_free) * psort_markpos - saves current position in the merged sort file */ void -psort_markpos(Sort * node) +psort_markpos(Sort *node) { Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -903,7 +915,7 @@ psort_markpos(Sort * node) * last saved position */ void -psort_restorepos(Sort * node) +psort_restorepos(Sort *node) { Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -918,12 +930,13 @@ psort_restorepos(Sort * node) * called unless psort_grabtuple has returned a NULL. */ void -psort_end(Sort * node) +psort_end(Sort *node) { struct tape *tp; if (!node->cleaned) { + /* * I'm changing this because if we are sorting a relation with no * tuples, psortstate is NULL. @@ -950,14 +963,15 @@ psort_end(Sort * node) } void -psort_rescan (Sort *node) +psort_rescan(Sort *node) { + /* * If subnode is to be rescanned then free our previous results */ - if (((Plan*) node)->lefttree->chgParam != NULL) + if (((Plan *) node)->lefttree->chgParam != NULL) { - psort_end (node); + psort_end(node); node->cleaned = false; } else if (PS(node) != (Psortstate *) NULL) @@ -966,7 +980,7 @@ psort_rescan (Sort *node) PS(node)->psort_current = 0; PS(node)->psort_saved = 0; if (PS(node)->using_tape_files == true) - rewind (PS(node)->psort_grab_file); + rewind(PS(node)->psort_grab_file); } } @@ -1039,10 +1053,10 @@ gettape() */ #ifdef NOT_USED static void -resettape(FILE * file) +resettape(FILE *file) { struct tapelst *tp; - int fd; + int fd; Assert(PointerIsValid(file)); @@ -1071,11 +1085,11 @@ resettape(FILE * file) * Exits instead of returning status, if given invalid tape. */ static void -destroytape(FILE * file) +destroytape(FILE *file) { struct tapelst *tp, *tq; - int fd; + int fd; if ((tp = Tapes) == NULL) elog(FATAL, "destroytape: tape not found"); @@ -1108,38 +1122,40 @@ destroytape(FILE * file) } static int -_psort_cmp (HeapTuple *ltup, HeapTuple *rtup) +_psort_cmp(HeapTuple *ltup, HeapTuple *rtup) { - Datum lattr, rattr; - int nkey; - int result = 0; - bool isnull1, isnull2; - - for (nkey = 0; nkey < PsortNkeys && !result; nkey++ ) - { + Datum lattr, + rattr; + int nkey; + int result = 0; + bool isnull1, + isnull2; + + for (nkey = 0; nkey < PsortNkeys && !result; nkey++) + { lattr = heap_getattr(*ltup, - PsortKeys[nkey].sk_attno, - PsortTupDesc, - &isnull1); + PsortKeys[nkey].sk_attno, + PsortTupDesc, + &isnull1); rattr = heap_getattr(*rtup, - PsortKeys[nkey].sk_attno, - PsortTupDesc, - &isnull2); - if ( isnull1 ) + PsortKeys[nkey].sk_attno, + PsortTupDesc, + &isnull2); + if (isnull1) { - if ( !isnull2 ) + if (!isnull2) result = 1; } - else if ( isnull2 ) - result = -1; - + else if (isnull2) + result = -1; + else if (PsortKeys[nkey].sk_flags & SK_COMMUTE) { - if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr))) - result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr); + if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr))) + result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr); } else if (!(result = -(long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (lattr, rattr))) - result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr); - } - return (result); + result = (long) (*fmgr_faddr(&PsortKeys[nkey].sk_func)) (rattr, lattr); + } + return (result); } diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index dea288da584..bb0538eb79a 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.13 1997/11/26 03:54:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.14 1998/02/26 04:38:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,9 +125,10 @@ HeapTupleSatisfiesItself(HeapTuple tuple) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { - if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */ + if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or + * aborted */ return (false); - + if (TransactionIdIsCurrentTransactionId(tuple->t_xmin)) { if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ @@ -139,7 +140,7 @@ HeapTupleSatisfiesItself(HeapTuple tuple) if (!TransactionIdDidCommit(tuple->t_xmin)) { if (TransactionIdDidAbort(tuple->t_xmin)) - tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ + tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ return (false); } @@ -229,17 +230,18 @@ HeapTupleSatisfiesNow(HeapTuple tuple) if (!PostgresIsInitialized) return ((bool) (TransactionIdIsValid(tuple->t_xmin) && - !TransactionIdIsValid(tuple->t_xmax))); + !TransactionIdIsValid(tuple->t_xmax))); if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { - if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */ + if (tuple->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or + * aborted */ return (false); if (TransactionIdIsCurrentTransactionId(tuple->t_xmin)) { if (CommandIdGEScanCommandId(tuple->t_cmin)) - return (false); /* inserted after scan started */ + return (false); /* inserted after scan started */ if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ return (true); @@ -249,7 +251,7 @@ HeapTupleSatisfiesNow(HeapTuple tuple) if (CommandIdGEScanCommandId(tuple->t_cmax)) return (true); /* deleted after scan started */ else - return (false); /* deleted before scan started */ + return (false); /* deleted before scan started */ } /* @@ -259,7 +261,7 @@ HeapTupleSatisfiesNow(HeapTuple tuple) if (!TransactionIdDidCommit(tuple->t_xmin)) { if (TransactionIdDidAbort(tuple->t_xmin)) - tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ + tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ return (false); } @@ -277,9 +279,9 @@ HeapTupleSatisfiesNow(HeapTuple tuple) if (TransactionIdIsCurrentTransactionId(tuple->t_xmax)) { if (CommandIdGEScanCommandId(tuple->t_cmax)) - return (true); /* deleted after scan started */ + return (true); /* deleted after scan started */ else - return (false); /* deleted before scan started */ + return (false); /* deleted before scan started */ } if (!TransactionIdDidCommit(tuple->t_xmax)) |