1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

pgindent run before 6.3 release, with Thomas' requested changes.

This commit is contained in:
Bruce Momjian
1998-02-26 04:46:47 +00:00
parent 757bf69a2e
commit a32450a585
430 changed files with 12390 additions and 10292 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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() */

View File

@@ -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() */

View File

@@ -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);

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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 */

File diff suppressed because it is too large Load Diff

View File

@@ -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;

View File

@@ -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);

File diff suppressed because it is too large Load Diff

View File

@@ -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() */
/*

View File

@@ -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++)
{

View File

@@ -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() */

View File

@@ -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)

View File

@@ -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;

View File

@@ -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() */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 +

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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}},

View File

@@ -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;

View File

@@ -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() */

View File

@@ -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

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
/*

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
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;
}
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);
}
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;

View File

@@ -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();

View File

@@ -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);
memcpy(dbpath, VARDATA(dbtext), (VARSIZE(dbtext)-VARHDRSZ));
*(dbpath+(VARSIZE(dbtext)-VARHDRSZ)) = '\0';
dbtext = (text *) heap_getattr(dbtup,
Anum_pg_database_datpath,
RelationGetTupleDescriptor(dbrel),
(char *) NULL);
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() */

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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++;

View File

@@ -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);
}

View File

@@ -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))