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

OK, folks, here is the pgindent output.

This commit is contained in:
Bruce Momjian
1998-09-01 04:40:42 +00:00
parent af74855a60
commit fa1a8d6a97
574 changed files with 26509 additions and 24033 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.30 1998/09/01 03:25:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.31 1998/09/01 04:32:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,8 +151,8 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(USENAME,
PointerGetDatum(name),
0, 0, 0);
PointerGetDatum(name),
0, 0, 0);
if (!HeapTupleIsValid(htup))
elog(ERROR, "aclparse: non-existent user \"%s\"", name);
aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htup))->usesysid;
@@ -262,8 +262,8 @@ aclitemout(AclItem *aip)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(USESYSID,
ObjectIdGetDatum(aip->ai_id),
0, 0, 0);
ObjectIdGetDatum(aip->ai_id),
0, 0, 0);
if (!HeapTupleIsValid(htup))
{
char *tmp = int2out(aip->ai_id);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.33 1998/09/01 03:25:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.34 1998/09/01 04:32:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,23 +43,19 @@
/*-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-*/
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, int32 typmod,
char typdelim, int typlen, bool typbyval,
char typalign, int *nbytes);
#ifdef LOARRAY
static char *
_ReadLOArray(char *str, int *nbytes, int *fd, bool *chunkFlag,
static char *_ReadLOArray(char *str, int *nbytes, int *fd, bool *chunkFlag,
int ndim, int *dim, int baseSize);
#endif
static void
_CopyArrayEls(char **values, char *p, int nitems, int typlen,
static void _CopyArrayEls(char **values, char *p, int nitems, int typlen,
char typalign, bool typbyval);
static void
system_cache_lookup(Oid element_type, bool input, int *typlen,
static void system_cache_lookup(Oid element_type, bool input, int *typlen,
bool *typbyval, char *typdelim, Oid *typelem, Oid *proc,
char *typalign);
static Datum _ArrayCast(char *value, bool byval, int len);
@@ -68,18 +64,15 @@ static Datum _ArrayCast(char *value, bool byval, int len);
static char *_AdvanceBy1word(char *str, char **word);
#endif
static void
_ArrayRange(int *st, int *endp, int bsize, char *destPtr,
static void _ArrayRange(int *st, int *endp, int bsize, char *destPtr,
ArrayType *array, int from);
static int _ArrayClipCount(int *stI, int *endpI, ArrayType *array);
static void
_LOArrayRange(int *st, int *endp, int bsize, int srcfd,
static void _LOArrayRange(int *st, int *endp, int bsize, int srcfd,
int destfd, ArrayType *array, int isSrcLO, bool *isNull);
static void
_ReadArray(int *st, int *endp, int bsize, int srcfd, int destfd,
static void _ReadArray(int *st, int *endp, int bsize, int srcfd, int destfd,
ArrayType *array, int isDestLO, bool *isNull);
static int ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest);
static int SanityCheckInput(int ndim, int n, int *dim, int *lb, int *indx);
static int ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest);
static int SanityCheckInput(int ndim, int n, int *dim, int *lb, int *indx);
static int array_read(char *destptr, int eltsize, int nitems, char *srcptr);
static char *array_seek(char *ptr, int eltsize, int nitems);
@@ -608,7 +601,8 @@ array_out(ArrayType *v, Oid element_type)
FmgrInfo outputproc;
char typalign;
char *p, *tmp,
char *p,
*tmp,
*retval,
**values,
delim[2];
@@ -698,9 +692,11 @@ array_out(ArrayType *v, Oid element_type)
*/
overall_length += 2;
}
for (tmp=values[i];*tmp;tmp++) {
for (tmp = values[i]; *tmp; tmp++)
{
overall_length += 1;
if (*tmp=='"') overall_length += 1;
if (*tmp == '"')
overall_length += 1;
}
overall_length += 1;
}
@@ -729,12 +725,14 @@ array_out(ArrayType *v, Oid element_type)
if (!typbyval)
{
strcat(p, "\"");
l=strlen(p);
for (tmp=values[k];*tmp;tmp++) {
if (*tmp=='"') p[l++]='\\';
p[l++]=*tmp;
}
p[l]='\0';
l = strlen(p);
for (tmp = values[k]; *tmp; tmp++)
{
if (*tmp == '"')
p[l++] = '\\';
p[l++] = *tmp;
}
p[l] = '\0';
strcat(p, "\"");
}
else

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.25 1998/09/01 03:25:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.26 1998/09/01 04:32:26 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
* XXX UNHACK Allow the currency symbol to be multi-byte.
* - thomas 1998-03-01
* - thomas 1998-03-01
*/
Cash *
cash_in(const char *str)
@@ -77,11 +78,11 @@ cash_in(const char *str)
/* best guess is 2 in this case I think */
fpoint = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */
dsymbol = ((*lconvert->mon_decimal_point != '\0')? *lconvert->mon_decimal_point: '.');
ssymbol = ((*lconvert->mon_thousands_sep != '\0')? *lconvert->mon_thousands_sep: ',');
csymbol = ((*lconvert->currency_symbol != '\0')? lconvert->currency_symbol: "$");
psymbol = ((*lconvert->positive_sign != '\0')? *lconvert->positive_sign: '+');
nsymbol = ((*lconvert->negative_sign != '\0')? lconvert->negative_sign: "-");
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
ssymbol = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
psymbol = ((*lconvert->positive_sign != '\0') ? *lconvert->positive_sign : '+');
nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");
#else
fpoint = 2;
dsymbol = '.';
@@ -92,27 +93,29 @@ cash_in(const char *str)
#endif
#ifdef CASHDEBUG
printf( "cashin- precision '%d'; decimal '%c'; thousands '%c'; currency '%s'; positive '%c'; negative '%s'\n",
fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol);
printf("cashin- precision '%d'; decimal '%c'; thousands '%c'; currency '%s'; positive '%c'; negative '%s'\n",
fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol);
#endif
/* we need to add all sorts of checking here. For now just */
/* strip all leading whitespace and any leading currency symbol */
while (isspace(*s)) s++;
if (strncmp(s,csymbol,strlen(csymbol)) == 0) s += strlen(csymbol);
while (isspace(*s))
s++;
if (strncmp(s, csymbol, strlen(csymbol)) == 0)
s += strlen(csymbol);
#ifdef CASHDEBUG
printf( "cashin- string is '%s'\n", s);
printf("cashin- string is '%s'\n", s);
#endif
/* a leading minus or paren signifies a negative number */
/* again, better heuristics needed */
if (strncmp(s,nsymbol,strlen(nsymbol)) == 0)
if (strncmp(s, nsymbol, strlen(nsymbol)) == 0)
{
sgn = -1;
s += strlen(nsymbol);
#ifdef CASHDEBUG
printf( "cashin- negative symbol; string is '%s'\n", s);
printf("cashin- negative symbol; string is '%s'\n", s);
#endif
}
else if (*s == '(')
@@ -125,14 +128,16 @@ printf( "cashin- negative symbol; string is '%s'\n", s);
s++;
#ifdef CASHDEBUG
printf( "cashin- string is '%s'\n", s);
printf("cashin- string is '%s'\n", s);
#endif
while (isspace(*s)) s++;
if (strncmp(s,csymbol,strlen(csymbol)) == 0) s += strlen(csymbol);
while (isspace(*s))
s++;
if (strncmp(s, csymbol, strlen(csymbol)) == 0)
s += strlen(csymbol);
#ifdef CASHDEBUG
printf( "cashin- string is '%s'\n", s);
printf("cashin- string is '%s'\n", s);
#endif
for (;; s++)
@@ -184,7 +189,7 @@ printf( "cashin- string is '%s'\n", s);
*result = (value * sgn);
#ifdef CASHDEBUG
printf( "cashin- result is %d\n", *result);
printf("cashin- result is %d\n", *result);
#endif
return result;
@@ -219,14 +224,14 @@ cash_out(Cash *in_value)
lconvert = localeconv();
mon_group = *lconvert->mon_grouping;
comma = ((*lconvert->mon_thousands_sep != '\0')? *lconvert->mon_thousands_sep: ',');
comma = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
/* 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? */
convention = lconvert->n_sign_posn;
dsymbol = ((*lconvert->mon_decimal_point != '\0')? *lconvert->mon_decimal_point: '.');
csymbol = ((*lconvert->currency_symbol != '\0')? lconvert->currency_symbol: "$");
nsymbol = ((*lconvert->negative_sign != '\0')? lconvert->negative_sign: "-");
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");
#else
mon_group = 3;
comma = ',';
@@ -273,8 +278,8 @@ cash_out(Cash *in_value)
value /= 10;
}
strncpy((buf+count-strlen(csymbol)+1),csymbol,strlen(csymbol));
count -= strlen(csymbol)-1;
strncpy((buf + count - strlen(csymbol) + 1), csymbol, strlen(csymbol));
count -= strlen(csymbol) - 1;
if (buf[LAST_DIGIT] == ',')
buf[LAST_DIGIT] = buf[LAST_PAREN];

View File

@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.17 1998/09/01 03:25:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.18 1998/09/01 04:32:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,25 +40,21 @@
static CHUNK_INFO cInfo;
/* non-export function prototypes */
static int
_FindBestChunk(int size, int *dmax, int *dbest, int dim,
static int _FindBestChunk(int size, int *dmax, int *dbest, int dim,
int A[MAXPAT][MAXDIM + 1], int N);
static int get_next(int *d, int k, int C, int *dmax);
static void initialize_info(CHUNK_INFO *A, int ndim, int *dim, int *chunk);
#ifdef LOARRAY
static void
_ConvertToChunkFile(int n, int baseSize, int *dim, int *C,
static void _ConvertToChunkFile(int n, int baseSize, int *dim, int *C,
int srcfd, int destfd);
static void
read_chunk(int *chunk_no, int *C, char *a_chunk, int srcfd,
static void read_chunk(int *chunk_no, int *C, char *a_chunk, int srcfd,
int n, int baseSize, int *PX, int *dist);
static int write_chunk(struct varlena * a_chunk, int ofile);
static int seek_and_read(int pos, int size, char *buff, int fp, int from);
#endif
static int
GetChunkSize(FILE *fd, int ndim, int dim[MAXDIM], int baseSize,
static int GetChunkSize(FILE *fd, int ndim, int dim[MAXDIM], int baseSize,
int d[MAXDIM]);
/*------------------------------------------------------------------------
@@ -421,7 +417,7 @@ seek_and_read(int pos, int size, char *buff, int fp, int from)
}
#endif /* LOARRAY */
#endif /* LOARRAY */
/*----------------------------------------------------------------------------
* _ReadChunkArray --

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.26 1998/09/01 03:25:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.27 1998/09/01 04:32:29 momjian Exp $
*
* NOTES
* This code is actually (almost) unused.
@@ -102,8 +102,7 @@ static int correct_dir(char *direction, int *signptr);
#endif
static int
istinterval(char *i_string,
static int istinterval(char *i_string,
AbsoluteTime *i_start,
AbsoluteTime *i_end);
@@ -207,36 +206,39 @@ reltime2tm(int32 time, struct tm * tm)
} /* reltime2tm() */
#if FALSE
char *timestring;
long quantity;
int i;
int unitnr;
timestring = (char *) palloc(Max(strlen(INVALID_RELTIME_STR),
UNITMAXLEN) + 1);
if (timevalue == INVALID_RELTIME)
int
dummyfunc()
{
strcpy(timestring, INVALID_RELTIME_STR);
return timestring;
}
char *timestring;
long quantity;
int i;
int unitnr;
if (timevalue == 0)
i = 1; /* unit = 'seconds' */
else
for (i = 12; i >= 0; i = i - 2)
if ((timevalue % sec_tab[i]) == 0)
break; /* appropriate unit found */
unitnr = i;
quantity = (timevalue / sec_tab[unitnr]);
if (quantity > 1 || quantity < -1)
unitnr++; /* adjust index for PLURAL of unit */
if (quantity >= 0)
sprintf(timestring, "%c %lu %s", RELTIME_LABEL,
quantity, unit_tab[unitnr]);
else
sprintf(timestring, "%c %lu %s %s", RELTIME_LABEL,
(quantity * -1), unit_tab[unitnr], RELTIME_PAST);
return timestring;
timestring = (char *) palloc(Max(strlen(INVALID_RELTIME_STR),
UNITMAXLEN) + 1);
if (timevalue == INVALID_RELTIME)
{
strcpy(timestring, INVALID_RELTIME_STR);
return timestring;
}
if (timevalue == 0)
i = 1; /* unit = 'seconds' */
else
for (i = 12; i >= 0; i = i - 2)
if ((timevalue % sec_tab[i]) == 0)
break; /* appropriate unit found */
unitnr = i;
quantity = (timevalue / sec_tab[unitnr]);
if (quantity > 1 || quantity < -1)
unitnr++; /* adjust index for PLURAL of unit */
if (quantity >= 0)
sprintf(timestring, "%c %lu %s", RELTIME_LABEL,
quantity, unit_tab[unitnr]);
else
sprintf(timestring, "%c %lu %s %s", RELTIME_LABEL,
(quantity * -1), unit_tab[unitnr], RELTIME_PAST);
return timestring;
}
#endif
@@ -987,126 +989,123 @@ isreltime(char *str)
} /* isreltime() */
#if FALSE
char *p;
char c;
int i;
char unit[UNITMAXLEN];
char direction[DIRMAXLEN];
int localSign;
int localUnitNumber;
long localQuantity;
if (!PointerIsValid(sign))
int
dummyfunc()
{
sign = &localSign;
}
char *p;
char c;
int i;
char unit[UNITMAXLEN];
char direction[DIRMAXLEN];
int localSign;
int localUnitNumber;
long localQuantity;
if (!PointerIsValid(unitnr))
{
unitnr = &localUnitNumber;
}
if (!PointerIsValid(sign))
sign = &localSign;
if (!PointerIsValid(quantity))
{
quantity = &localQuantity;
}
if (!PointerIsValid(unitnr))
unitnr = &localUnitNumber;
unit[0] = '\0';
direction[0] = '\0';
p = timestring;
/* skip leading blanks */
while ((c = *p) != '\0')
{
if (!PointerIsValid(quantity))
quantity = &localQuantity;
unit[0] = '\0';
direction[0] = '\0';
p = timestring;
/* skip leading blanks */
while ((c = *p) != '\0')
{
if (c != ' ')
break;
p++;
}
/* Test whether 'invalid time' identifier or not */
if (!strncmp(INVALID_RELTIME_STR, p, strlen(INVALID_RELTIME_STR) + 1))
return 2; /* correct 'invalid time' identifier found */
/* handle label of relative time */
if (c != RELTIME_LABEL)
return 0; /* syntax error */
c = *++p;
if (c != ' ')
break;
return 0; /* syntax error */
p++;
}
/* Test whether 'invalid time' identifier or not */
if (!strncmp(INVALID_RELTIME_STR, p, strlen(INVALID_RELTIME_STR) + 1))
return 2; /* correct 'invalid time' identifier found */
/* handle label of relative time */
if (c != RELTIME_LABEL)
return 0; /* syntax error */
c = *++p;
if (c != ' ')
return 0; /* syntax error */
p++;
/* handle the quantity */
*quantity = 0;
for (;;)
{
c = *p;
if (isdigit(c))
/* handle the quantity */
*quantity = 0;
for (;;)
{
*quantity = *quantity * 10 + (c - '0');
p++;
}
else
{
if (c == ' ')
break; /* correct quantity found */
else
return 0; /* syntax error */
}
}
/* handle unit */
p++;
i = 0;
for (;;)
{
c = *p;
if (c >= 'a' && c <= 'z' && i <= (UNITMAXLEN - 1))
{
unit[i] = c;
p++;
i++;
}
else
{
if ((c == ' ' || c == '\0')
&& correct_unit(unit, unitnr))
break; /* correct unit found */
else
return 0; /* syntax error */
}
}
/* handle optional direction */
if (c == ' ')
p++;
i = 0;
*sign = 1;
for (;;)
{
c = *p;
if (c >= 'a' && c <= 'z' && i <= (DIRMAXLEN - 1))
{
direction[i] = c;
p++;
i++;
}
else
{
if ((c == ' ' || c == '\0') && i == 0)
c = *p;
if (isdigit(c))
{
*sign = 1;
break; /* no direction specified */
}
if ((c == ' ' || c == '\0') && i != 0)
{
direction[i] = '\0';
correct_dir(direction, sign);
break; /* correct direction found */
*quantity = *quantity * 10 + (c - '0');
p++;
}
else
return 0; /* syntax error */
{
if (c == ' ')
break; /* correct quantity found */
else
return 0; /* syntax error */
}
}
}
return 1;
/* handle unit */
p++;
i = 0;
for (;;)
{
c = *p;
if (c >= 'a' && c <= 'z' && i <= (UNITMAXLEN - 1))
{
unit[i] = c;
p++;
i++;
}
else
{
if ((c == ' ' || c == '\0')
&& correct_unit(unit, unitnr))
break; /* correct unit found */
else
return 0; /* syntax error */
}
}
/* handle optional direction */
if (c == ' ')
p++;
i = 0;
*sign = 1;
for (;;)
{
c = *p;
if (c >= 'a' && c <= 'z' && i <= (DIRMAXLEN - 1))
{
direction[i] = c;
p++;
i++;
}
else
{
if ((c == ' ' || c == '\0') && i == 0)
{
*sign = 1;
break; /* no direction specified */
}
if ((c == ' ' || c == '\0') && i != 0)
{
direction[i] = '\0';
correct_dir(direction, sign);
break; /* correct direction found */
}
else
return 0; /* syntax error */
}
}
return 1;
}
/*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.56 1998/09/01 03:25:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.57 1998/09/01 04:32:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,15 +32,12 @@
#include "utils/builtins.h"
static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
static int
DecodeNumber(int flen, char *field,
static int DecodeNumber(int flen, char *field,
int fmask, int *tmask, struct tm * tm, double *fsec);
static int
DecodeNumberField(int len, char *str,
static int DecodeNumberField(int len, char *str,
int fmask, int *tmask, struct tm * tm, double *fsec);
static int DecodeSpecial(int field, char *lowtoken, int *val);
static int
DecodeTime(char *str, int fmask, int *tmask,
static int DecodeTime(char *str, int fmask, int *tmask,
struct tm * tm, double *fsec);
static int DecodeTimezone(char *str, int *tzp);
static int DecodeUnits(int field, char *lowtoken, int *val);
@@ -2208,7 +2205,7 @@ static datetkn deltatktbl[] = {
{"mils", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */
{"millenia", UNITS, DTK_MILLENIUM}, /* "millenia" relative time units */
{DMILLENIUM, UNITS, DTK_MILLENIUM}, /* "millenium" relative time units */
{"millisecon", UNITS, DTK_MILLISEC}, /* relative time units */
{"millisecon", UNITS, DTK_MILLISEC}, /* relative time units */
{"min", UNITS, DTK_MINUTE}, /* "minute" relative time units */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative time units */
@@ -2223,18 +2220,18 @@ static datetkn deltatktbl[] = {
{DMILLISEC, UNITS, DTK_MILLISEC},
{"mseconds", UNITS, DTK_MILLISEC},
{"msecs", UNITS, DTK_MILLISEC},
{"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative time */
{"qtr", UNITS, DTK_QUARTER},/* "quarter" relative time */
{DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative time */
{"reltime", IGNORE, 0}, /* for pre-v6.1 "Undefined Reltime" */
{"reltime", IGNORE, 0}, /* for pre-v6.1 "Undefined Reltime" */
{"s", UNITS, DTK_SECOND},
{"sec", UNITS, DTK_SECOND},
{DSECOND, UNITS, DTK_SECOND},
{"seconds", UNITS, DTK_SECOND},
{"secs", UNITS, DTK_SECOND},
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"tz", UNITS, DTK_TZ}, /* "timezone" time offset */
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"tz", UNITS, DTK_TZ}, /* "timezone" time offset */
{"tz_hour", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
{"tz_minute", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"tz_minute", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"us", UNITS, DTK_MICROSEC},/* "microsecond" relative time units */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative time
@@ -3645,7 +3642,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
* an unsigned floating point number. - thomas 1997-11-16
*
* Allow ISO-style time span, with implicit units on number of days
* preceeding an hh:mm:ss field. - thomas 1998-04-30
* preceeding an hh:mm:ss field. - thomas 1998-04-30
*/
int
DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, double *fsec)
@@ -3688,8 +3685,10 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do
break;
case DTK_TZ:
/* Timezone is a token with a leading sign character
* and otherwise the same as a non-signed numeric field
/*
* Timezone is a token with a leading sign character and
* otherwise the same as a non-signed numeric field
*/
case DTK_DATE:
case DTK_NUMBER:
@@ -4258,7 +4257,7 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
*
* Support "traditional Postgres" and ISO-8601 styles.
* Actually, afaik ISO does not address time interval formatting,
* but this looks similar to the spec for absolute date/time.
* but this looks similar to the spec for absolute date/time.
* - thomas 1998-04-30
*/
int
@@ -4270,7 +4269,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
switch (style)
{
/* compatible with ISO date formats */
/* compatible with ISO date formats */
case USE_ISO_DATES:
break;
@@ -4284,7 +4283,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
{
is_before |= (tm->tm_year < 0);
sprintf(cp, "%d year%s",
abs(tm->tm_year), ((abs(tm->tm_year) != 1) ? "s" : ""));
abs(tm->tm_year), ((abs(tm->tm_year) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
}
@@ -4292,26 +4291,26 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
if (tm->tm_mon != 0)
{
is_before |= (tm->tm_mon < 0);
sprintf(cp, "%s%d mon%s", (is_nonzero? " ": ""),
abs(tm->tm_mon), ((abs(tm->tm_mon) != 1) ? "s" : ""));
sprintf(cp, "%s%d mon%s", (is_nonzero ? " " : ""),
abs(tm->tm_mon), ((abs(tm->tm_mon) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
}
switch (style)
{
/* compatible with ISO date formats */
/* compatible with ISO date formats */
case USE_ISO_DATES:
if (tm->tm_mday != 0)
{
is_before |= (tm->tm_mday < 0);
sprintf(cp, "%s%d", (is_nonzero? " ": ""), abs(tm->tm_mday));
sprintf(cp, "%s%d", (is_nonzero ? " " : ""), abs(tm->tm_mday));
cp += strlen(cp);
is_nonzero = TRUE;
}
is_before |= ((tm->tm_hour < 0) || (tm->tm_min < 0));
sprintf(cp, "%s%02d:%02d", (is_nonzero? " ": ""),
abs(tm->tm_hour), abs(tm->tm_min));
sprintf(cp, "%s%02d:%02d", (is_nonzero ? " " : ""),
abs(tm->tm_hour), abs(tm->tm_min));
cp += strlen(cp);
if ((tm->tm_hour != 0) || (tm->tm_min != 0))
is_nonzero = TRUE;
@@ -4341,7 +4340,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
if (tm->tm_mday != 0)
{
is_before |= (tm->tm_mday < 0);
sprintf(cp, "%s%d day%s", (is_nonzero? " ": ""),
sprintf(cp, "%s%d day%s", (is_nonzero ? " " : ""),
abs(tm->tm_mday), ((abs(tm->tm_mday) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
@@ -4349,7 +4348,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
if (tm->tm_hour != 0)
{
is_before |= (tm->tm_hour < 0);
sprintf(cp, "%s%d hour%s", (is_nonzero? " ": ""),
sprintf(cp, "%s%d hour%s", (is_nonzero ? " " : ""),
abs(tm->tm_hour), ((abs(tm->tm_hour) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
@@ -4358,8 +4357,8 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
if (tm->tm_min != 0)
{
is_before |= (tm->tm_min < 0);
sprintf(cp, "%s%d min%s", (is_nonzero? " ": ""),
abs(tm->tm_min), ((abs(tm->tm_min) != 1) ? "s" : ""));
sprintf(cp, "%s%d min%s", (is_nonzero ? " " : ""),
abs(tm->tm_min), ((abs(tm->tm_min) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
}
@@ -4369,7 +4368,7 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
{
fsec += tm->tm_sec;
is_before |= (fsec < 0);
sprintf(cp, "%s%.2f secs", (is_nonzero? " ": ""), fabs(fsec));
sprintf(cp, "%s%.2f secs", (is_nonzero ? " " : ""), fabs(fsec));
cp += strlen(cp);
is_nonzero = TRUE;
@@ -4378,8 +4377,8 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
else if (tm->tm_sec != 0)
{
is_before |= (tm->tm_sec < 0);
sprintf(cp, "%s%d sec%s", (is_nonzero? " ": ""),
abs(tm->tm_sec), ((abs(tm->tm_sec) != 1) ? "s" : ""));
sprintf(cp, "%s%d sec%s", (is_nonzero ? " " : ""),
abs(tm->tm_sec), ((abs(tm->tm_sec) != 1) ? "s" : ""));
cp += strlen(cp);
is_nonzero = TRUE;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.32 1998/09/01 03:25:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.33 1998/09/01 04:32:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -158,7 +158,7 @@ CheckFloat4Val(double val)
if (val != 0.0 && fabs(val) < FLOAT4_MIN)
elog(ERROR, "Bad float4 input format -- underflow");
return;
#endif /* UNSAFE_FLOATS */
#endif /* UNSAFE_FLOATS */
}
/*
@@ -183,7 +183,7 @@ CheckFloat8Val(double val)
if (val != 0.0 && fabs(val) < FLOAT8_MIN)
elog(ERROR, "Bad float8 input format -- underflow");
return;
#endif /* UNSAFE_FLOATS */
#endif /* UNSAFE_FLOATS */
}
/*
@@ -1491,7 +1491,7 @@ double x;
return w - TWO52[sx];
}
#endif /* !HAVE_RINT */
#endif /* !HAVE_RINT */
#ifndef HAVE_CBRT
@@ -1506,4 +1506,4 @@ double x;
return isneg ? -tmpres : tmpres;
}
#endif /* !HAVE_CBRT */
#endif /* !HAVE_CBRT */

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.36 1998/09/01 03:26:01 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.37 1998/09/01 04:32:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -777,6 +777,7 @@ line_in(char *str)
LSEG lseg;
int isopen;
char *s;
#endif
if (!PointerIsValid(str))
@@ -800,9 +801,11 @@ line_in(char *str)
char *
line_out(LINE *line)
{
char *result;
char *result;
#ifdef ENABLE_LINE_TYPE
LSEG lseg;
LSEG lseg;
#endif
if (!PointerIsValid(line))
@@ -2343,7 +2346,7 @@ close_pl(Point *pt, LINE *line)
*
* Some tricky code here, relying on boolean expressions
* evaluating to only zero or one to use as an array index.
* bug fixes by gthaker@atl.lmco.com; May 1, 1998
* bug fixes by gthaker@atl.lmco.com; May 1, 1998
*/
Point *
close_ps(Point *pt, LSEG *lseg)
@@ -2356,7 +2359,7 @@ close_ps(Point *pt, LSEG *lseg)
#ifdef GEODEBUG
printf("close_sp:pt->x %f pt->y %f\nlseg(0).x %f lseg(0).y %f lseg(1).x %f lseg(1).y %f\n",
pt->x, pt->y, lseg->p[0].x, lseg->p[0].y, lseg->p[1].x, lseg->p[1].y);
pt->x, pt->y, lseg->p[0].x, lseg->p[0].y, lseg->p[1].x, lseg->p[1].y);
#endif
result = NULL;
@@ -2372,14 +2375,14 @@ close_ps(Point *pt, LSEG *lseg)
#endif
/* first check if point is below or above the entire lseg. */
if (pt->y < lseg->p[!yh].y)
result = point_copy(&lseg->p[!yh]); /* below the lseg */
result = point_copy(&lseg->p[!yh]); /* below the lseg */
else if (pt->y > lseg->p[yh].y)
result = point_copy(&lseg->p[yh]); /* above the lseg */
result = point_copy(&lseg->p[yh]); /* above the lseg */
if (result != NULL)
return result;
return result;
/* point lines along (to left or right) of the vertical lseg. */
result = palloc(sizeof(*result));
result->x = lseg->p[0].x;
result->y = pt->y;
@@ -2392,11 +2395,11 @@ close_ps(Point *pt, LSEG *lseg)
#endif
/* first check if point is left or right of the entire lseg. */
if (pt->x < lseg->p[!xh].x)
result = point_copy(&lseg->p[!xh]); /* left of the lseg */
result = point_copy(&lseg->p[!xh]); /* left of the lseg */
else if (pt->x > lseg->p[xh].x)
result = point_copy(&lseg->p[xh]); /* right of the lseg */
result = point_copy(&lseg->p[xh]); /* right of the lseg */
if (result != NULL)
return result;
return result;
/* point lines along (at top or below) the horiz. lseg. */
result = palloc(sizeof(*result));
@@ -2405,31 +2408,41 @@ close_ps(Point *pt, LSEG *lseg)
return result;
}
/* vert. and horiz. cases are down, now check if the closest
* point is one of the end points or someplace on the lseg. */
/*
* vert. and horiz. cases are down, now check if the closest point is
* one of the end points or someplace on the lseg.
*/
/* TODO: Ask if "tmp" should be freed to prevent memory leak */
invm = -1.0 / point_sl(&(lseg->p[0]), &(lseg->p[1]));
tmp = line_construct_pm(&lseg->p[!yh], invm); /* lower edge of the "band" */
if (pt->y < (tmp->A*pt->x + tmp->C)) { /* we are below the lower edge */
result = point_copy(&lseg->p[!yh]); /* below the lseg, take lower end pt */
/* fprintf(stderr,"below: tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
return result;
tmp = line_construct_pm(&lseg->p[!yh], invm); /* lower edge of the
* "band" */
if (pt->y < (tmp->A * pt->x + tmp->C))
{ /* we are below the lower edge */
result = point_copy(&lseg->p[!yh]); /* below the lseg, take
* lower end pt */
/* fprintf(stderr,"below: tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
return result;
}
tmp = line_construct_pm(&lseg->p[yh], invm); /* upper edge of the "band" */
if (pt->y > (tmp->A*pt->x + tmp->C)) { /* we are below the lower edge */
result = point_copy(&lseg->p[yh]); /* above the lseg, take higher end pt */
/* fprintf(stderr,"above: tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
return result;
tmp = line_construct_pm(&lseg->p[yh], invm); /* upper edge of the
* "band" */
if (pt->y > (tmp->A * pt->x + tmp->C))
{ /* we are below the lower edge */
result = point_copy(&lseg->p[yh]); /* above the lseg, take
* higher end pt */
/* fprintf(stderr,"above: tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
return result;
}
/* at this point the "normal" from point will hit lseg. The closet point
* will be somewhere on the lseg */
/*
* at this point the "normal" from point will hit lseg. The closet
* point will be somewhere on the lseg
*/
tmp = line_construct_pm(pt, invm);
/* fprintf(stderr,"tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
/* fprintf(stderr,"tmp A %f B %f C %f m %f\n",tmp->A,tmp->B,tmp->C, tmp->m); */
result = interpt_sl(lseg, tmp);
/* fprintf(stderr,"result.x %f result.y %f\n", result->x, result->y); */
/* fprintf(stderr,"result.x %f result.y %f\n", result->x, result->y); */
return result;
} /* close_ps() */
@@ -4428,7 +4441,7 @@ box_circle(BOX *box)
} /* box_circle() */
POLYGON *
POLYGON *
circle_poly(int npts, CIRCLE *circle)
{
POLYGON *poly;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.16 1998/09/01 03:26:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.17 1998/09/01 04:32:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -80,7 +80,7 @@ int2out(int16 sh)
int16 *
int28in(char *shs)
{
int16 **result;
int16 **result;
int nums;
if (shs == NULL)

View File

@@ -208,7 +208,7 @@ int48ge(int32 val1, int64 * val2)
int64 *
int8um(int64 * val)
{
int64 temp = 0;
int64 temp = 0;
int64 *result = palloc(sizeof(int64));
if (!PointerIsValid(val))
@@ -217,7 +217,7 @@ int8um(int64 * val)
#if FALSE
*result = temp - (*val);
#else
result = int8mi(&temp, val);
result = int8mi(&temp, val);
#endif
return result;
@@ -281,17 +281,18 @@ int8larger(int64 * val1, int64 * val2)
{
#if FALSE
int64 *result = palloc(sizeof(int64));
#endif
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
#if FALSE
*result = ((*val1 > *val2)? *val1: *val2);
*result = ((*val1 > *val2) ? *val1 : *val2);
return result;
#endif
return (*val1 > *val2)? val1: val2;
return (*val1 > *val2) ? val1 : val2;
} /* int8larger() */
int64 *
@@ -299,17 +300,18 @@ int8smaller(int64 * val1, int64 * val2)
{
#if FALSE
int64 *result = palloc(sizeof(int64));
#endif
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
#if FALSE
*result = ((*val1 < *val2)? *val1: *val2);
*result = ((*val1 < *val2) ? *val1 : *val2);
return result;
#endif
return (*val1 < *val2)? val1: val2;
return (*val1 < *val2) ? val1 : val2;
} /* int8smaller() */
@@ -400,7 +402,7 @@ int48mul(int32 val1, int64 * val2)
if (!PointerIsValid(val2))
return NULL;
*result = (int64) val1 * *val2;
*result = (int64) val1 **val2;
return result;
} /* int48mul() */
@@ -442,14 +444,16 @@ int84(int64 * val)
elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL);
#if FALSE
/* Hmm. This conditional always tests true on my i686/linux box.
* It's a gcc compiler bug, or I'm missing something obvious, which is more likely...
* - thomas 1998-06-09
/*
* Hmm. This conditional always tests true on my i686/linux box. It's
* a gcc compiler bug, or I'm missing something obvious, which is more
* likely... - thomas 1998-06-09
*/
if ((*val < INT_MIN) || (*val > INT_MAX))
#endif
if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
elog(ERROR, "int8 conversion to int4 is out of range", NULL);
if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1)))
elog(ERROR, "int8 conversion to int4 is out of range", NULL);
result = *val;
@@ -501,10 +505,10 @@ i8tod(int64 * val)
* Convert double float to 8-byte integer.
* Do a range check before the conversion.
* Note that the comparison probably isn't quite right
* since we only have ~52 bits of precision in a double float
* and so subtracting one from a large number gives the large
* number exactly. However, for some reason the comparison below
* does the right thing on my i686/linux-rh4.2 box.
* since we only have ~52 bits of precision in a double float
* and so subtracting one from a large number gives the large
* number exactly. However, for some reason the comparison below
* does the right thing on my i686/linux-rh4.2 box.
* - thomas 1998-06-16
*/
int64 *

View File

@@ -23,7 +23,7 @@
#include "utils/builtins.h" /* where the function declarations go */
#include "mb/pg_wchar.h"
static int like(pg_wchar *text, pg_wchar *p);
static int like(pg_wchar * text, pg_wchar * p);
/*
* interface routines called by the function manager
@@ -40,18 +40,18 @@ static int like(pg_wchar *text, pg_wchar *p);
static bool
fixedlen_like(char *s, struct varlena * p, int charlen)
{
pg_wchar *sterm,
pg_wchar *sterm,
*pterm;
int result;
int len;
int len;
if (!s || !p)
return FALSE;
/* be sure sterm is null-terminated */
#ifdef MULTIBYTE
sterm = (pg_wchar *) palloc((charlen + 1)*sizeof(pg_wchar));
(void)pg_mb2wchar_with_len((unsigned char *)s,sterm,charlen);
sterm = (pg_wchar *) palloc((charlen + 1) * sizeof(pg_wchar));
(void) pg_mb2wchar_with_len((unsigned char *) s, sterm, charlen);
#else
sterm = (char *) palloc(charlen + 1);
StrNCpy(sterm, s, charlen + 1);
@@ -65,8 +65,8 @@ fixedlen_like(char *s, struct varlena * p, int charlen)
/* palloc the length of the text + the null character */
len = VARSIZE(p) - VARHDRSZ;
#ifdef MULTIBYTE
pterm = (pg_wchar *) palloc((len + 1)*sizeof(pg_wchar));
(void)pg_mb2wchar_with_len((unsigned char *)VARDATA(p),pterm,len);
pterm = (pg_wchar *) palloc((len + 1) * sizeof(pg_wchar));
(void) pg_mb2wchar_with_len((unsigned char *) VARDATA(p), pterm, len);
#else
pterm = (char *) palloc(len + 1);
memmove(pterm, VARDATA(p), len);
@@ -111,7 +111,7 @@ textnlike(struct varlena * s, struct varlena * p)
}
/* $Revision: 1.19 $
/* $Revision: 1.20 $
** "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.
@@ -146,7 +146,7 @@ textnlike(struct varlena * s, struct varlena * p)
** Match text and p, return LIKE_TRUE, LIKE_FALSE, or LIKE_ABORT.
*/
static int
DoMatch(pg_wchar *text, pg_wchar *p)
DoMatch(pg_wchar * text, pg_wchar * p)
{
int matched;
@@ -189,7 +189,7 @@ DoMatch(pg_wchar *text, pg_wchar *p)
** User-level routine. Returns TRUE or FALSE.
*/
static int
like(pg_wchar *text, pg_wchar *p)
like(pg_wchar * text, pg_wchar * p)
{
if (p[0] == '%' && p[1] == '\0')
return TRUE;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.14 1998/09/01 03:26:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.15 1998/09/01 04:32:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -73,13 +73,13 @@ oidrand(Oid o, int32 X)
return true;
/*
* We do this because the cancel key is actually a random, so we don't
* want them to be able to request random numbers using our postmaster
* seeded value.
* We do this because the cancel key is actually a random, so we don't
* want them to be able to request random numbers using our postmaster
* seeded value.
*/
if (!random_initialized)
{
srandom((unsigned int)time(NULL));
srandom((unsigned int) time(NULL));
random_initialized = true;
}

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.14 1998/09/01 03:26:10 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.15 1998/09/01 04:32:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -199,7 +199,7 @@ namestrcmp(Name name, char *str)
if (!name && !str)
return 0;
if (!name)
return -1; /* NULL < anything */
return -1; /* NULL < anything */
if (!str)
return 1; /* NULL < anything */
return strncmp(name->data, str, NAMEDATALEN);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.12 1998/09/01 03:26:11 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.13 1998/09/01 04:32:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,14 +72,14 @@ int4notin(int16 not_in_arg, char *relation_and_attr)
/* the last argument should be a ScanKey, not an integer! - jolly */
/* it looks like the arguments are out of order, too */
/* but skeyData is never initialized! does this work?? - ay 2/95 */
scan_descriptor = heap_beginscan(relation_to_scan, false, SnapshotNow,
scan_descriptor = heap_beginscan(relation_to_scan, false, SnapshotNow,
0, &skeyData);
retval = true;
/* do a scan of the relation, and do the check */
while (HeapTupleIsValid(current_tuple = heap_getnext(scan_descriptor, 0)) &&
retval)
retval)
{
value = heap_getattr(current_tuple,
(AttrNumber) attrid,

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.25 1998/09/01 03:26:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.26 1998/09/01 04:32:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,7 +77,7 @@ pg_atoi(char *s, int size, int c)
errno = ERANGE;
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
}
#endif /* HAS_LONG_LONG */
#endif /* HAS_LONG_LONG */
break;
case sizeof(int16):
if (l < SHRT_MIN)

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.17 1998/09/01 03:26:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.18 1998/09/01 04:32:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,7 +31,7 @@
Oid *
oid8in(char *oidString)
{
Oid **result;
Oid **result;
int nums;
if (oidString == NULL)
@@ -128,8 +128,9 @@ oid8eq(Oid *arg1, Oid *arg2)
bool
oid8lt(Oid *arg1, Oid *arg2)
{
int i;
for (i=0; i < 8; i++)
int i;
for (i = 0; i < 8; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4lt(arg1[i], arg2[i]);
return false;
@@ -138,8 +139,9 @@ oid8lt(Oid *arg1, Oid *arg2)
bool
oid8le(Oid *arg1, Oid *arg2)
{
int i;
for (i=0; i < 8; i++)
int i;
for (i = 0; i < 8; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4le(arg1[i], arg2[i]);
return true;
@@ -148,8 +150,9 @@ oid8le(Oid *arg1, Oid *arg2)
bool
oid8ge(Oid *arg1, Oid *arg2)
{
int i;
for (i=0; i < 8; i++)
int i;
for (i = 0; i < 8; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4ge(arg1[i], arg2[i]);
return true;
@@ -158,8 +161,9 @@ oid8ge(Oid *arg1, Oid *arg2)
bool
oid8gt(Oid *arg1, Oid *arg2)
{
int i;
for (i=0; i < 8; i++)
int i;
for (i = 0; i < 8; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4gt(arg1[i], arg2[i]);
return false;

View File

@@ -1,7 +1,7 @@
/*
* Edmund Mergl <E.Mergl@bawue.de>
*
* $Id: oracle_compat.c,v 1.15 1998/08/11 18:38:07 momjian Exp $
* $Id: oracle_compat.c,v 1.16 1998/09/01 04:32:45 momjian Exp $
*
*/
@@ -54,7 +54,7 @@ lower(text *string)
ptr_ret = VARDATA(ret);
while (m--)
*ptr_ret++ = tolower((unsigned char)*ptr++);
*ptr_ret++ = tolower((unsigned char) *ptr++);
return ret;
}
@@ -92,7 +92,7 @@ upper(text *string)
ptr_ret = VARDATA(ret);
while (m--)
*ptr_ret++ = toupper((unsigned char)*ptr++);
*ptr_ret++ = toupper((unsigned char) *ptr++);
return ret;
}
@@ -131,15 +131,15 @@ initcap(text *string)
ptr = VARDATA(string);
ptr_ret = VARDATA(ret);
*ptr_ret++ = toupper((unsigned char)*ptr++);
*ptr_ret++ = toupper((unsigned char) *ptr++);
--m;
while (m--)
{
if (*(ptr_ret - 1) == ' ' || *(ptr_ret - 1) == ' ')
*ptr_ret++ = toupper((unsigned char)*ptr++);
*ptr_ret++ = toupper((unsigned char) *ptr++);
else
*ptr_ret++ = tolower((unsigned char)*ptr++);
*ptr_ret++ = tolower((unsigned char) *ptr++);
}
return ret;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.19 1998/09/01 03:26:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.20 1998/09/01 04:32:46 momjian Exp $
*
* Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance
@@ -36,7 +36,7 @@
#if defined(DISABLE_XOPEN_NLS)
#undef _XOPEN_SOURCE
#endif /* DISABLE_XOPEN_NLS */
#endif /* DISABLE_XOPEN_NLS */
/* this is the number of cached regular expressions held. */
#ifndef MAX_CACHED_RES

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.25 1998/09/01 03:26:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.26 1998/09/01 04:32:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,7 +28,7 @@
/*****************************************************************************
* USER I/O ROUTINES *
*****************************************************************************/
/*
* regprocin - converts "proname" to proid
*
@@ -46,27 +46,29 @@ regprocin(char *pro_name_and_oid)
if (!IsBootstrapProcessingMode())
{
/*
* we need to use the oid because there can be multiple entries
* with the same name. We accept 1323_int4eq and 1323.
* we need to use the oid because there can be multiple entries
* with the same name. We accept 1323_int4eq and 1323.
*/
if (strrchr(pro_name_and_oid,'_') != NULL)
if (strrchr(pro_name_and_oid, '_') != NULL)
{
proctup = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(atoi(strrchr(pro_name_and_oid,'_')+1)),
0, 0, 0);
ObjectIdGetDatum(atoi(strrchr(pro_name_and_oid, '_') + 1)),
0, 0, 0);
}
else if (atoi(pro_name_and_oid) != InvalidOid)
{
proctup = SearchSysCacheTuple(PROOID,
/* atoi stops at the _ */
ObjectIdGetDatum(atoi(pro_name_and_oid)),
0, 0, 0);
/* atoi stops at the _ */
ObjectIdGetDatum(atoi(pro_name_and_oid)),
0, 0, 0);
}
if (HeapTupleIsValid(proctup))
result = (RegProcedure) proctup->t_oid;
else elog(ERROR, "regprocin: no such procedure %s", pro_name_and_oid);
result = (RegProcedure) proctup->t_oid;
else
elog(ERROR, "regprocin: no such procedure %s", pro_name_and_oid);
}
else
{
@@ -74,7 +76,7 @@ regprocin(char *pro_name_and_oid)
HeapScanDesc procscan;
ScanKeyData key;
bool isnull;
proc = heap_openr(ProcedureRelationName);
if (!RelationIsValid(proc))
{
@@ -87,7 +89,7 @@ regprocin(char *pro_name_and_oid)
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
(Datum) pro_name_and_oid);
procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
if (!HeapScanIsValid(procscan))
{
@@ -99,23 +101,23 @@ regprocin(char *pro_name_and_oid)
proctup = heap_getnext(procscan, 0);
if (HeapTupleIsValid(proctup))
{
result = (RegProcedure) heap_getattr(proctup,
ObjectIdAttributeNumber,
RelationGetDescr(proc),
&isnull);
if (isnull)
elog(FATAL, "regprocin: null procedure %s", pro_name_and_oid);
result = (RegProcedure) heap_getattr(proctup,
ObjectIdAttributeNumber,
RelationGetDescr(proc),
&isnull);
if (isnull)
elog(FATAL, "regprocin: null procedure %s", pro_name_and_oid);
}
else
result = (RegProcedure) 0;
result = (RegProcedure) 0;
heap_endscan(procscan);
heap_close(proc);
}
}
#ifdef EBUG
elog(DEBUG, "regprocin: no such procedure %s", pro_name_and_oid);
#endif /* defined(EBUG) */
#endif /* defined(EBUG) */
return (int32) result;
}
@@ -133,15 +135,15 @@ regprocout(RegProcedure proid)
if (!IsBootstrapProcessingMode())
{
proctup = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(proid),
0, 0, 0);
ObjectIdGetDatum(proid),
0, 0, 0);
if (HeapTupleIsValid(proctup))
{
char *s;
s = ((Form_pg_proc) GETSTRUCT(proctup))->proname.data;
snprintf(result, NAMEDATALEN, "%s_%d", s, proid);
char *s;
s = ((Form_pg_proc) GETSTRUCT(proctup))->proname.data;
snprintf(result, NAMEDATALEN, "%s_%d", s, proid);
}
else
{
@@ -154,7 +156,7 @@ regprocout(RegProcedure proid)
Relation proc;
HeapScanDesc procscan;
ScanKeyData key;
proc = heap_openr(ProcedureRelationName);
if (!RelationIsValid(proc))
{
@@ -167,7 +169,7 @@ regprocout(RegProcedure proid)
(AttrNumber) ObjectIdAttributeNumber,
(RegProcedure) F_INT4EQ,
(Datum) proid);
procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
if (!HeapScanIsValid(procscan))
{
@@ -183,7 +185,7 @@ regprocout(RegProcedure proid)
bool isnull;
s = (char *) heap_getattr(proctup, 1,
RelationGetDescr(proc), &isnull);
RelationGetDescr(proc), &isnull);
if (!isnull)
StrNCpy(result, s, NAMEDATALEN);
else
@@ -191,8 +193,8 @@ regprocout(RegProcedure proid)
}
else
{
result[0] = '-';
result[1] = '\0';
result[0] = '-';
result[1] = '\0';
}
heap_endscan(procscan);
heap_close(proc);
@@ -200,8 +202,8 @@ regprocout(RegProcedure proid)
}
#ifdef EBUG
elog(DEBUG, "regprocout: no such procedure %d", proid);
#endif /* defined(EBUG) */
elog(DEBUG, "regprocout: no such procedure %d", proid);
#endif /* defined(EBUG) */
return result;
}
@@ -232,15 +234,15 @@ oid8types(Oid **oidArray)
if (*sp != InvalidOid)
{
typetup = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(*sp),
0, 0, 0);
ObjectIdGetDatum(*sp),
0, 0, 0);
if (HeapTupleIsValid(typetup))
{
char *s;
s = ((Form_pg_type) GETSTRUCT(typetup))->typname.data;
StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s,
NAMEDATALEN);
NAMEDATALEN);
strcat(VARDATA(result), " ");
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.22 1998/09/01 03:26:18 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.23 1998/09/01 04:32:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -41,8 +41,7 @@
#define FunctionalSelectivity(nIndKeys,attNum) (attNum==InvalidAttrNumber)
static float32data getattdisbursion(Oid relid, AttrNumber attnum);
static void
gethilokey(Oid relid, AttrNumber attnum, Oid opid,
static void gethilokey(Oid relid, AttrNumber attnum, Oid opid,
char **high, char **low);

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.17 1998/09/01 03:26:19 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.18 1998/09/01 04:32:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -112,8 +112,8 @@ SetDefine(char *querystr, char *typename)
RelationSetLockForWrite(procrel);
tup = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(setoid),
0, 0, 0);
ObjectIdGetDatum(setoid),
0, 0, 0);
if (HeapTupleIsValid(tup))
{
newtup = heap_modifytuple(tup,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.38 1998/09/01 03:26:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.39 1998/09/01 04:32:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -137,7 +137,8 @@ bpchar(char *s, int32 len)
{
char *result,
*r;
int rlen, slen;
int rlen,
slen;
int i;
if (s == NULL)
@@ -152,8 +153,8 @@ bpchar(char *s, int32 len)
elog(ERROR, "bpchar: length of char() must be less than 4096");
#ifdef STRINGDEBUG
printf("bpchar- convert string length %d (%d) ->%d (%d)\n",
VARSIZE(s)-VARHDRSZ, VARSIZE(s), rlen, len);
printf("bpchar- convert string length %d (%d) ->%d (%d)\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), rlen, len);
#endif
result = (char *) palloc(len);
@@ -163,7 +164,7 @@ printf("bpchar- convert string length %d (%d) ->%d (%d)\n",
s = VARDATA(s);
#ifdef STRINGDEBUG
printf("bpchar- string is '");
printf("bpchar- string is '");
#endif
for (i = 0; (i < rlen) && (i < slen); i++)
@@ -172,14 +173,14 @@ printf("bpchar- string is '");
break;
#ifdef STRINGDEBUG
printf("%c", *s);
printf("%c", *s);
#endif
*r++ = *s++;
}
#ifdef STRINGDEBUG
printf("'\n");
printf("'\n");
#endif
/* blank pad the string if necessary */
@@ -187,7 +188,7 @@ printf("'\n");
*r++ = ' ';
return result;
} /* bpchar() */
} /* bpchar() */
/* bpchar_char()
@@ -197,7 +198,7 @@ int32
bpchar_char(char *s)
{
return (int32) *VARDATA(s);
} /* bpchar_char() */
} /* bpchar_char() */
/* char_bpchar()
* Convert char to bpchar(1).
@@ -205,21 +206,21 @@ bpchar_char(char *s)
char *
char_bpchar(int32 c)
{
char *result;
char *result;
result = palloc(VARHDRSZ+1);
result = palloc(VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ+1;
VARSIZE(result) = VARHDRSZ + 1;
*(VARDATA(result)) = (char) c;
return result;
} /* char_bpchar() */
} /* char_bpchar() */
/* bpchar_name()
* Converts a bpchar() type to a NameData type.
*/
NameData *
NameData *
bpchar_name(char *s)
{
NameData *result;
@@ -229,29 +230,33 @@ bpchar_name(char *s)
return NULL;
len = VARSIZE(s) - VARHDRSZ;
if (len > NAMEDATALEN) len = NAMEDATALEN;
if (len > NAMEDATALEN)
len = NAMEDATALEN;
while (len > 0) {
if (*(VARDATA(s)+len-1) != ' ') break;
while (len > 0)
{
if (*(VARDATA(s) + len - 1) != ' ')
break;
len--;
}
#ifdef STRINGDEBUG
printf("bpchar- convert string length %d (%d) ->%d\n",
VARSIZE(s)-VARHDRSZ, VARSIZE(s), len);
printf("bpchar- convert string length %d (%d) ->%d\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), len);
#endif
result = (NameData *) palloc(NAMEDATALEN);
StrNCpy(result->data, VARDATA(s), NAMEDATALEN);
/* now null pad to full length... */
while (len < NAMEDATALEN) {
while (len < NAMEDATALEN)
{
*(result->data + len) = '\0';
len++;
}
return result;
} /* bpchar_name() */
} /* bpchar_name() */
/* name_bpchar()
* Converts a NameData type to a bpchar type.
@@ -268,8 +273,8 @@ name_bpchar(NameData *s)
len = strlen(s->data);
#ifdef STRINGDEBUG
printf("bpchar- convert string length %d (%d) ->%d\n",
VARSIZE(s)-VARHDRSZ, VARSIZE(s), len);
printf("bpchar- convert string length %d (%d) ->%d\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), len);
#endif
result = (char *) palloc(VARHDRSZ + len);
@@ -277,7 +282,7 @@ printf("bpchar- convert string length %d (%d) ->%d\n",
VARSIZE(result) = len + VARHDRSZ;
return result;
} /* name_bpchar() */
} /* name_bpchar() */
/*****************************************************************************
@@ -372,7 +377,7 @@ varchar(char *s, int32 slen)
strncpy(VARDATA(result), VARDATA(s), len);
return result;
} /* varchar() */
} /* varchar() */
/*****************************************************************************
@@ -400,7 +405,10 @@ bpcharlen(char *arg)
{
#ifdef MULTIBYTE
unsigned char *s;
int len, l, wl;
int len,
l,
wl;
#endif
if (!PointerIsValid(arg))
elog(ERROR, "Bad (null) char() external representation", NULL);
@@ -408,13 +416,14 @@ bpcharlen(char *arg)
l = bcTruelen(arg);
len = 0;
s = VARDATA(arg);
while (l > 0) {
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
while (l > 0)
{
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
}
return(len);
return (len);
#else
return bcTruelen(arg);
#endif
@@ -565,7 +574,10 @@ varcharlen(char *arg)
{
#ifdef MULTIBYTE
unsigned char *s;
int len, l, wl;
int len,
l,
wl;
#endif
if (!PointerIsValid(arg))
elog(ERROR, "Bad (null) varchar() external representation", NULL);
@@ -574,13 +586,14 @@ varcharlen(char *arg)
len = 0;
s = VARDATA(arg);
l = VARSIZE(arg) - VARHDRSZ;
while (l > 0) {
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
while (l > 0)
{
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
}
return(len);
return (len);
#else
return VARSIZE(arg) - VARHDRSZ;
#endif

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.41 1998/09/01 03:26:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.42 1998/09/01 04:32:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -208,9 +208,12 @@ textlen(text *t)
{
#ifdef MULTIBYTE
unsigned char *s;
int len, l, wl;
int len,
l,
wl;
#endif
if (!PointerIsValid(t))
elog(ERROR, "Null input to textlen");
@@ -218,17 +221,18 @@ textlen(text *t)
len = 0;
s = VARDATA(t);
l = VARSIZE(t) - VARHDRSZ;
while (l > 0) {
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
while (l > 0)
{
wl = pg_mblen(s);
l -= wl;
s += wl;
len++;
}
return(len);
return (len);
#else
return VARSIZE(t) - VARHDRSZ;
#endif
} /* textlen() */
/*
@@ -322,9 +326,11 @@ text_substr(text *string, int32 m, int32 n)
{
text *ret;
int len;
#ifdef MULTIBYTE
int i;
char *p;
int i;
char *p;
#endif
if ((string == (text *) NULL) || (m <= 0))
@@ -332,7 +338,7 @@ text_substr(text *string, int32 m, int32 n)
len = VARSIZE(string) - VARHDRSZ;
#ifdef MULTIBYTE
len = pg_mbstrlen_with_len(VARDATA(string),len);
len = pg_mbstrlen_with_len(VARDATA(string), len);
#endif
/* m will now become a zero-based starting position */
@@ -350,13 +356,11 @@ text_substr(text *string, int32 m, int32 n)
#ifdef MULTIBYTE
p = VARDATA(string);
for (i=0;i<m;i++) {
p += pg_mblen(p);
}
for (i = 0; i < m; i++)
p += pg_mblen(p);
m = p - VARDATA(string);
for (i=0;i<n;i++) {
p += pg_mblen(p);
}
for (i = 0; i < n; i++)
p += pg_mblen(p);
n = p - (VARDATA(string) + m);
#endif
ret = (text *) palloc(VARHDRSZ + n);
@@ -385,10 +389,13 @@ textpos(text *t1, text *t2)
p;
int len1,
len2;
pg_wchar *p1,
pg_wchar *p1,
*p2;
#ifdef MULTIBYTE
pg_wchar *ps1, *ps2;
pg_wchar *ps1,
*ps2;
#endif
if (!PointerIsValid(t1) || !PointerIsValid(t2))
@@ -400,11 +407,11 @@ textpos(text *t1, text *t2)
len1 = (VARSIZE(t1) - VARHDRSZ);
len2 = (VARSIZE(t2) - VARHDRSZ);
#ifdef MULTIBYTE
ps1 = p1 = (pg_wchar *) palloc((len1 + 1)*sizeof(pg_wchar));
(void)pg_mb2wchar_with_len((unsigned char *)VARDATA(t1),p1,len1);
ps1 = p1 = (pg_wchar *) palloc((len1 + 1) * sizeof(pg_wchar));
(void) pg_mb2wchar_with_len((unsigned char *) VARDATA(t1), p1, len1);
len1 = pg_wchar_strlen(p1);
ps2 = p2 = (pg_wchar *) palloc((len2 + 1)*sizeof(pg_wchar));
(void)pg_mb2wchar_with_len((unsigned char *)VARDATA(t2),p2,len2);
ps2 = p2 = (pg_wchar *) palloc((len2 + 1) * sizeof(pg_wchar));
(void) pg_mb2wchar_with_len((unsigned char *) VARDATA(t2), p2, len2);
len2 = pg_wchar_strlen(p2);
#else
p1 = VARDATA(t1);
@@ -477,8 +484,9 @@ textne(text *arg1, text *arg2)
int
varstr_cmp(char *arg1, int len1, char *arg2, int len2)
{
int result;
char *a1p, *a2p;
int result;
char *a1p,
*a2p;
#ifdef USE_LOCALE
a1p = (unsigned char *) palloc(len1 + 1);
@@ -518,8 +526,10 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
int
text_cmp(text *arg1, text *arg2)
{
char *a1p, *a2p;
int len1, len2;
char *a1p,
*a2p;
int len1,
len2;
if (arg1 == NULL || arg2 == NULL)
return (bool) FALSE;
@@ -539,7 +549,7 @@ text_cmp(text *arg1, text *arg2)
bool
text_lt(text *arg1, text *arg2)
{
return (bool)(text_cmp(arg1, arg2) < 0);
return (bool) (text_cmp(arg1, arg2) < 0);
} /* text_lt() */
/* text_le()
@@ -548,7 +558,7 @@ text_lt(text *arg1, text *arg2)
bool
text_le(text *arg1, text *arg2)
{
return (bool)(text_cmp(arg1, arg2) <= 0);
return (bool) (text_cmp(arg1, arg2) <= 0);
} /* text_le() */
bool
@@ -725,7 +735,7 @@ byteaSetBit(text *v, int32 n, int32 newBit)
/* text_name()
* Converts a text() type to a NameData type.
*/
NameData *
NameData *
text_name(text *s)
{
NameData *result;
@@ -735,24 +745,26 @@ text_name(text *s)
return NULL;
len = VARSIZE(s) - VARHDRSZ;
if (len > NAMEDATALEN) len = NAMEDATALEN;
if (len > NAMEDATALEN)
len = NAMEDATALEN;
#ifdef STRINGDEBUG
printf("text- convert string length %d (%d) ->%d\n",
VARSIZE(s)-VARHDRSZ, VARSIZE(s), len);
printf("text- convert string length %d (%d) ->%d\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), len);
#endif
result = palloc(NAMEDATALEN);
StrNCpy(result->data, VARDATA(s), NAMEDATALEN);
/* now null pad to full length... */
while (len < NAMEDATALEN) {
while (len < NAMEDATALEN)
{
*(result->data + len) = '\0';
len++;
}
return result;
} /* text_name() */
} /* text_name() */
/* name_text()
* Converts a NameData type to a text type.
@@ -769,8 +781,8 @@ name_text(NameData *s)
len = strlen(s->data);
#ifdef STRINGDEBUG
printf("text- convert string length %d (%d) ->%d\n",
VARSIZE(s)-VARHDRSZ, VARSIZE(s), len);
printf("text- convert string length %d (%d) ->%d\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), len);
#endif
result = palloc(VARHDRSZ + len);
@@ -778,4 +790,4 @@ printf("text- convert string length %d (%d) ->%d\n",
VARSIZE(result) = len + VARHDRSZ;
return result;
} /* name_text() */
} /* name_text() */

View File

@@ -1,11 +1,11 @@
/*-------------------------------------------------------------------------
*
* version.c--
* Returns the version string
* Returns the version string
*
* IDENTIFICATION
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/version.c,v 1.1 1998/04/29 12:38:05 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/version.c,v 1.2 1998/09/01 04:32:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,12 +14,13 @@
#include "version.h"
text* version(void);
text *version(void);
text* version(void)
text *
version(void)
{
int n = strlen(PG_VERSION_STR) + VARHDRSZ;
text *ret = (text *) palloc(n);
int n = strlen(PG_VERSION_STR) + VARHDRSZ;
text *ret = (text *) palloc(n);
VARSIZE(ret) = n;
strcpy(VARDATA(ret), PG_VERSION_STR);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.33 1998/09/01 03:26:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.34 1998/09/01 04:32:57 momjian Exp $
*
* Notes:
* XXX This needs to use exception.h to handle recovery when
@@ -102,7 +102,7 @@ do { \
elog(DEBUG, "CatalogCacheInitializeCache: called w/relname %s", \
cache->cc_relname) \
} while(0)
#define CatalogCacheInitializeCache_DEBUG2 \
do { \
if (cache->cc_key[i] > 0) { \
@@ -665,7 +665,7 @@ do { \
cp->cc_skey[i].sk_argument); \
} \
} while(0)
#else
#define InitSysCache_DEBUG1
#endif
@@ -894,7 +894,7 @@ SearchSysCache(struct catcache * cache,
CACHE3_elog(DEBUG, "SearchSysCache(%s): found in bucket %d",
RelationGetRelationName(relation), hash);
heap_close(relation);
#endif /* CACHEDEBUG */
#endif /* CACHEDEBUG */
return ct->ct_tup;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.17 1998/09/01 03:26:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.18 1998/09/01 04:32:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,8 +36,7 @@
#endif
static Oid GetDynamicFuncArgType(Var *arg, ExprContext *econtext);
static FunctionCachePtr
init_fcache(Oid foid,
static FunctionCachePtr init_fcache(Oid foid,
bool use_syscache,
List *argList,
ExprContext *econtext);
@@ -126,7 +125,7 @@ init_fcache(Oid foid,
* ----------------
*/
typeTuple = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(procedureStruct->prorettype),
ObjectIdGetDatum(procedureStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.15 1998/09/01 03:26:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.16 1998/09/01 04:33:00 momjian Exp $
*
* Note - this code is real crufty...
*
@@ -33,8 +33,7 @@
static InvalidationEntry InvalidationEntryAllocate(uint16 size);
static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ());
static LocalInvalid
LocalInvalidRegister(LocalInvalid invalid,
static LocalInvalid LocalInvalidRegister(LocalInvalid invalid,
InvalidationEntry entry);
static void getmyrelids(void);
@@ -166,7 +165,7 @@ elog(DEBUG, "CacheIdRegisterLocalInvalid(%d, %d, [%d, %d])", \
ItemPointerGetOffsetNumber(pointer))
#else
#define CacheIdRegisterLocalInvalid_DEBUG1
#endif /* INVALIDDEBUG */
#endif /* INVALIDDEBUG */
static void
CacheIdRegisterLocalInvalid(Index cacheId,
@@ -218,7 +217,7 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
#ifdef INVALIDDEBUG
elog(DEBUG, "RelationRegisterLocalInvalid(%d, %d)", relationId,
objectId);
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
/* ----------------
* create a message describing the relation descriptor
@@ -267,7 +266,7 @@ getmyrelids()
MyAMRelationId = tuple->t_oid;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(AccessMethodOperatorRelationName),
PointerGetDatum(AccessMethodOperatorRelationName),
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyAMOPRelationId = tuple->t_oid;
@@ -287,7 +286,7 @@ elog(DEBUG, "CacheIdInvalidate(%d, %d, 0x%x[%d])", cacheId, hashIndex,\
pointer, ItemPointerIsValid(pointer))
#else
#define CacheIdInvalidate_DEBUG1
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
static void
CacheIdInvalidate(Index cacheId,
@@ -380,7 +379,7 @@ elog(DEBUG,\
#else
#define InvalidationMessageRegisterSharedInvalid_DEBUG1
#define InvalidationMessageRegisterSharedInvalid_DEBUG2
#endif /* INVALIDDEBUG */
#endif /* INVALIDDEBUG */
static void
InvalidationMessageRegisterSharedInvalid(InvalidationMessage message)
@@ -430,7 +429,7 @@ elog(DEBUG, "InvalidationMessageCacheInvalidate(c, %d, %d, [%d, %d])",\
#else
#define InvalidationMessageCacheInvalidate_DEBUG1
#define InvalidationMessageCacheInvalidate_DEBUG2
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
static void
InvalidationMessageCacheInvalidate(InvalidationMessage message)
@@ -536,7 +535,7 @@ DiscardInvalid()
*/
#ifdef INVALIDDEBUG
elog(DEBUG, "DiscardInvalid called");
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
InvalidateSharedInvalid(CacheIdInvalidate, ResetSystemCaches);
}
@@ -557,7 +556,7 @@ RegisterInvalid(bool send)
*/
#ifdef INVALIDDEBUG
elog(DEBUG, "RegisterInvalid(%d) called", send);
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
/* ----------------
* Note: Invalid is a global variable
@@ -582,7 +581,7 @@ SetRefreshWhenInvalidate(bool on)
{
#ifdef INVALIDDEBUG
elog(DEBUG, "RefreshWhenInvalidate(%d) called", on);
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
RefreshWhenInvalidate = on;
}
@@ -603,7 +602,7 @@ elog(DEBUG, "RelationInvalidateHeapTuple(%s, [%d,%d])", \
ItemPointerGetOffsetNumber(&tuple->t_ctid))
#else
#define RelationInvalidateHeapTuple_DEBUG1
#endif /* defined(INVALIDDEBUG) */
#endif /* defined(INVALIDDEBUG) */
void
RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.21 1998/09/01 03:26:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.22 1998/09/01 04:33:01 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -136,9 +136,9 @@ get_attisset(Oid relid, char *attname)
attno = get_attnum(relid, attname);
tuple = SearchSysCacheTuple(ATTNAME,
ObjectIdGetDatum(relid),
PointerGetDatum(attname),
0, 0);
ObjectIdGetDatum(relid),
PointerGetDatum(attname),
0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "get_attisset: no attribute %s in relation %d",
attname, relid);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.49 1998/09/01 03:26:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.50 1998/09/01 04:33:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -81,8 +81,7 @@
#include "utils/syscache.h"
static void
RelationFlushRelation(Relation *relationPtr,
static void RelationFlushRelation(Relation *relationPtr,
bool onlyFlushReferenceCountZero);
static Relation RelationNameCacheGetRelation(char *relationName);
static void init_irels(void);
@@ -195,7 +194,7 @@ do { \
RELATION = NULL; \
} while(0)
#define RelationIdCacheLookup(ID, RELATION) \
#define RelationIdCacheLookup(ID, RELATION) \
do { \
RelIdCacheEnt *hentry; \
bool found; \
@@ -233,8 +232,7 @@ do { \
} while(0)
/* non-export function prototypes */
static void
formrdesc(char *relationName, u_int natts,
static void formrdesc(char *relationName, u_int natts,
FormData_pg_attribute *att);
#if 0 /* See comments at line 1304 */
@@ -246,14 +244,11 @@ 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);
@@ -596,11 +591,11 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
for (i = 1; i <= relation->rd_rel->relnatts; i++)
{
atttup = (HeapTuple) AttributeNumIndexScan(attrel,
RelationGetRelid(relation), i);
RelationGetRelid(relation), i);
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cannot find attribute %d of relation %s", i,
relation->rd_rel->relname.data);
relation->rd_rel->relname.data);
attp = (Form_pg_attribute) GETSTRUCT(atttup);
relation->rd_att->attrs[i - 1] =
@@ -714,7 +709,7 @@ RelationBuildRuleLock(Relation relation)
* add attribute data to relation->rd_att
* ----------------
*/
while (HeapTupleIsValid(pg_rewrite_tuple=heap_getnext(pg_rewrite_scan, 0)))
while (HeapTupleIsValid(pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0)))
{
bool isnull;
Datum ruleaction;
@@ -1094,7 +1089,7 @@ formrdesc(char *relationName,
RelationCacheInsert(relation);
RelationInitLockInfo(relation);
/*
* Determining this requires a scan on pg_class, but to do the scan
* the rdesc for pg_class must already exist. Therefore we must do
@@ -1689,8 +1684,8 @@ AttrDefaultFetch(Relation relation)
for (found = 0;;)
{
Buffer buffer;
Buffer buffer;
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
@@ -1708,29 +1703,29 @@ AttrDefaultFetch(Relation relation)
continue;
if (attrdef[i].adsrc != NULL)
elog(ERROR, "AttrDefaultFetch: second record found for attr %s in rel %s",
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
val = (struct varlena *) fastgetattr(tuple,
Anum_pg_attrdef_adbin,
adrel->rd_att, &isnull);
if (isnull)
elog(ERROR, "AttrDefaultFetch: adbin IS NULL for attr %s in rel %s",
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
attrdef[i].adbin = textout(val);
val = (struct varlena *) fastgetattr(tuple,
Anum_pg_attrdef_adsrc,
adrel->rd_att, &isnull);
if (isnull)
elog(ERROR, "AttrDefaultFetch: adsrc IS NULL for attr %s in rel %s",
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
relation->rd_att->attrs[adform->adnum - 1]->attname.data,
relation->rd_rel->relname.data);
attrdef[i].adsrc = textout(val);
break;
}
ReleaseBuffer(buffer);
if (i >= ndef)
elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
adform->adnum,
@@ -1777,8 +1772,8 @@ RelCheckFetch(Relation relation)
for (found = 0;;)
{
Buffer buffer;
Buffer buffer;
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
@@ -1790,7 +1785,7 @@ RelCheckFetch(Relation relation)
continue;
if (found == ncheck)
elog(ERROR, "RelCheckFetch: unexpected record found for rel %s",
relation->rd_rel->relname.data);
relation->rd_rel->relname.data);
rcname = (Name) fastgetattr(tuple,
Anum_pg_relcheck_rcname,
@@ -1982,7 +1977,8 @@ init_irels(void)
#define SMD(i) strat[0].strategyMapData[i].entry[0]
/* have to reinit the function pointers in the strategy maps */
for (i = 0; i < am->amstrategies * relform->relnatts; i++) {
for (i = 0; i < am->amstrategies * relform->relnatts; i++)
{
fmgr_info(SMD(i).sk_procedure,
&(SMD(i).sk_func));
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.21 1998/09/01 03:26:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.22 1998/09/01 04:33:03 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@@ -205,7 +205,7 @@ static struct cachedesc cacheinfo[] = {
0,
0
},
offsetof(FormData_pg_type, typalign) +sizeof(char),
offsetof(FormData_pg_type, typalign) + sizeof(char),
TypeNameIndex,
TypeNameIndexScan},
{TypeRelationName, /* TYPOID */
@@ -241,7 +241,7 @@ static struct cachedesc cacheinfo[] = {
sizeof(FormData_pg_opclass),
NULL,
NULL},
{IndexRelationName, /* INDRELIDKEY */ /* never used */
{IndexRelationName, /* INDRELIDKEY *//* never used */
2,
{
Anum_pg_index_indrelid,
@@ -438,6 +438,7 @@ InitCatalogCache()
}
}
}
/*
* SearchSysCacheTupleCopy--
*
@@ -445,11 +446,11 @@ InitCatalogCache()
* that the user is required to pfree().
*/
HeapTuple
SearchSysCacheTupleCopy(int cacheId,/* cache selection code */
Datum key1,
Datum key2,
Datum key3,
Datum key4)
SearchSysCacheTupleCopy(int cacheId, /* cache selection code */
Datum key1,
Datum key2,
Datum key3,
Datum key4)
{
HeapTuple cachetup;
@@ -457,9 +458,9 @@ SearchSysCacheTupleCopy(int cacheId,/* cache selection code */
if (PointerIsValid(cachetup))
return heap_copytuple(cachetup);
else
return cachetup; /* NULL */
return cachetup; /* NULL */
}
/*
* SearchSysCacheTuple--
@@ -588,7 +589,7 @@ SearchSysCacheGetAttribute(int cacheId,
elog(DEBUG,
"SearchSysCacheGetAttribute: Lookup in %s(%d) failed",
cacheName, cacheId);
#endif /* defined(CACHEDEBUG) */
#endif /* defined(CACHEDEBUG) */
return NULL;
}
@@ -623,6 +624,7 @@ SearchSysCacheGetAttribute(int cacheId,
if (isNull)
{
/*
* Used to be an elog(DEBUG, ...) here and a claim that it should
* be a FATAL error, I don't think either is warranted -mer 6/9/92
@@ -681,7 +683,7 @@ TypeDefaultRetrieve(Oid typId)
#ifdef CACHEDEBUG
elog(DEBUG, "TypeDefaultRetrieve: Lookup in %s(%d) failed",
cacheinfo[TYPOID].name, TYPOID);
#endif /* defined(CACHEDEBUG) */
#endif /* defined(CACHEDEBUG) */
return NULL;
}
@@ -700,7 +702,7 @@ TypeDefaultRetrieve(Oid typId)
#ifdef CACHEDEBUG
elog(DEBUG, "TypeDefaultRetrieve: No extractable typdefault in %s(%d)",
cacheinfo[TYPOID].name, TYPOID);
#endif /* defined(CACHEDEBUG) */
#endif /* defined(CACHEDEBUG) */
return NULL;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.11 1998/09/01 03:26:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.12 1998/09/01 04:33:05 momjian Exp $
*
* NOTE
* This should eventually work with elog(), dlog(), etc.
@@ -50,7 +50,7 @@ ExceptionalCondition(char *conditionName,
else
{
EPRINTF("TRAP: %s(\"%s:%s\", File: \"%s\", Line: %d)\n",
exceptionP->message, conditionName,
exceptionP->message, conditionName,
(detail == NULL ? "" : detail),
fileName, lineNumber);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.34 1998/09/01 03:26:37 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.35 1998/09/01 04:33:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,7 +17,7 @@
#include <fcntl.h>
#ifndef O_RDONLY
#include <sys/file.h>
#endif /* O_RDONLY */
#endif /* O_RDONLY */
#include <sys/types.h>
#include <stdarg.h>
#include <errno.h>
@@ -38,12 +38,12 @@
/*
* Global option to control the use of syslog(3) for logging:
*
* 0 stdout/stderr only
* 1 stdout/stderr + syslog
* 2 syslog only
* 0 stdout/stderr only
* 1 stdout/stderr + syslog
* 2 syslog only
*/
#define UseSyslog pg_options[OPT_SYSLOG]
#define PG_LOG_FACILITY LOG_LOCAL0
#define PG_LOG_FACILITY LOG_LOCAL0
#else
#define UseSyslog 0
#endif
@@ -69,10 +69,12 @@ elog(int lev, const char *fmt,...)
#ifndef PG_STANDALONE
extern FILE *Pfout;
#endif
#ifdef USE_SYSLOG
int log_level;
#endif
int len;
@@ -135,25 +137,26 @@ elog(int lev, const char *fmt,...)
va_end(ap);
#ifdef USE_SYSLOG
switch (lev) {
case NOIND:
log_level = LOG_DEBUG;
break;
case DEBUG:
log_level = LOG_DEBUG;
break;
case NOTICE:
log_level = LOG_NOTICE;
break;
case ERROR:
log_level = LOG_WARNING;
break;
case FATAL:
default:
log_level = LOG_ERR;
break;
switch (lev)
{
case NOIND:
log_level = LOG_DEBUG;
break;
case DEBUG:
log_level = LOG_DEBUG;
break;
case NOTICE:
log_level = LOG_NOTICE;
break;
case ERROR:
log_level = LOG_WARNING;
break;
case FATAL:
default:
log_level = LOG_ERR;
break;
}
write_syslog(log_level, line+TIMESTAMP_SIZE);
write_syslog(log_level, line + TIMESTAMP_SIZE);
#endif
len = strlen(strcat(line, "\n"));
@@ -195,7 +198,7 @@ elog(int lev, const char *fmt,...)
else
pq_putnchar("E", 1);
/* pq_putint(-101, 4); *//* should be query id */
pq_putstr(line+TIMESTAMP_SIZE); /* don't show timestamps */
pq_putstr(line + TIMESTAMP_SIZE); /* don't show timestamps */
pq_flush();
}
if (Pfout == NULL)
@@ -207,16 +210,16 @@ elog(int lev, const char *fmt,...)
*/
fputs(line, stderr);
}
#endif /* !PG_STANDALONE */
#endif /* !PG_STANDALONE */
if (lev == ERROR)
{
extern bool InError;
extern bool InError;
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
if (!InError)
{
kill(MyProcPid, SIGQUIT); /* abort to traffic cop */
kill(MyProcPid, SIGQUIT); /* abort to traffic cop */
pause();
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.22 1998/09/01 03:26:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.23 1998/09/01 04:33:08 momjian Exp $
*
* NOTE
* XXX this code needs improvement--check for state violations and
@@ -24,11 +24,9 @@
#include "utils/exc.h"
#include "storage/ipc.h"
static void
ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
static void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
ExcMessage message);
static void
ExcPrint(Exception *excP, ExcDetail detail, ExcData data,
static void ExcPrint(Exception *excP, ExcDetail detail, ExcData data,
ExcMessage message);
/*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.19 1998/09/01 03:26:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.20 1998/09/01 04:33:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,7 +172,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
if (!(fcp = fmgr_isbuiltin(procedureId)))
{
procedureTuple = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(procedureId),
ObjectIdGetDatum(procedureId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.15 1998/09/01 03:26:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.16 1998/09/01 04:33:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,7 @@
#include "utils/hsearch.h"
#ifndef FRONTEND
#include "utils/mcxt.h"
#endif /* !FRONTEND */
#endif /* !FRONTEND */
#include "utils/palloc.h"
/*
@@ -115,7 +115,7 @@ DynaHashFree(Pointer ptr)
#define MEM_ALLOC palloc
#define MEM_FREE pfree
#endif /* FRONTEND */
#endif /* FRONTEND */
/* ----------------
* Internal routines

View File

@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.11 1998/09/01 03:26:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.12 1998/09/01 04:33:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -160,8 +160,8 @@ FindExec(char *full_path, char *argv0, char *binary_name)
int pathlen;
/*
* for the postmaster: First try: use the binary that's located in
* the same directory as the postmaster, if it was invoked with an
* for the postmaster: First try: use the binary that's located in the
* same directory as the postmaster, if it was invoked with an
* explicit path. Presumably the user used an explicit path because it
* wasn't in PATH, and we don't want to use incompatible executables.
*
@@ -170,9 +170,9 @@ FindExec(char *full_path, char *argv0, char *binary_name)
* trees (obj/post{master,gres}) because they all put the two binaries
* in the same place.
*
* for the binary: First try: if we're given some kind of path,
* use it (making sure that a relative path is made absolute before
* returning it).
* for the binary: First try: if we're given some kind of path, use it
* (making sure that a relative path is made absolute before returning
* it).
*/
if (argv0 && (p = strrchr(argv0, '/')) && *++p)
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.21 1998/09/01 03:26:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.22 1998/09/01 04:33:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -241,9 +241,10 @@ SetDatabaseName(char *name)
const char *
getdatabaseencoding()
{
elog(ERROR, "you need to enable MB to use this function");
return("");
elog(ERROR, "you need to enable MB to use this function");
return ("");
}
#endif
#ifdef CYR_RECODE
@@ -433,7 +434,7 @@ SetPgUserName()
free(UserName);
UserName = malloc(strlen(p) + 1);
strcpy(UserName, p);
#endif /* NO_SECURITY */
#endif /* NO_SECURITY */
}
/* ----------------------------------------------------------------
@@ -469,8 +470,8 @@ SetUserId()
userName = GetPgUserName();
userTup = SearchSysCacheTuple(USENAME,
PointerGetDatum(userName),
0, 0, 0);
PointerGetDatum(userName),
0, 0, 0);
if (!HeapTupleIsValid(userTup))
elog(FATAL, "SetUserId: user \"%s\" is not in \"%s\"",
userName,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.34 1998/08/24 01:13:56 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.35 1998/09/01 04:33:17 momjian Exp $
*
* NOTES
* InitPostgres() is the function called from PostgresMain
@@ -121,7 +121,7 @@ InitMyDatabaseInfo(char *name)
int4 owner;
char *path,
myPath[MAXPGPATH + 1];
int encoding;
int encoding;
SetDatabaseName(name);
GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath, &encoding);
@@ -201,8 +201,8 @@ VerifySystemDatabase()
static void
VerifyMyDatabase()
{
const char *name;
const char *myPath;
const char *name;
const char *myPath;
/* Failure reason returned by some function. NULL if no failure */
char *reason;
@@ -384,7 +384,7 @@ forcesharedmemory:
#endif
if (!IsUnderPostmaster) /* postmaster already did this */
if (!IsUnderPostmaster) /* postmaster already did this */
{
PostgresIpcKey = key;
AttachSharedMemoryAndSemaphores(key);
@@ -509,6 +509,8 @@ 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

View File

@@ -2,7 +2,7 @@
* This file contains some public functions
* usable for both the backend and the frontend.
* Tatsuo Ishii
* $Id: common.c,v 1.1 1998/07/24 03:31:56 scrappy Exp $ */
* $Id: common.c,v 1.2 1998/09/01 04:33:19 momjian Exp $ */
#include <stdio.h>
#include <string.h>
@@ -14,54 +14,61 @@
* case is ignored.
* if there's no valid encoding, returns -1
*/
int pg_char_to_encoding(const char *s)
int
pg_char_to_encoding(const char *s)
{
pg_encoding_conv_tbl *p = pg_conv_tbl;
pg_encoding_conv_tbl *p = pg_conv_tbl;
for(;p->encoding >= 0;p++) {
if (!strcasecmp(s, p->name)) {
break;
}
}
return(p->encoding);
for (; p->encoding >= 0; p++)
{
if (!strcasecmp(s, p->name))
break;
}
return (p->encoding);
}
/*
* check to see if encoding name is valid
*/
int pg_valid_client_encoding(const char *name)
int
pg_valid_client_encoding(const char *name)
{
return(pg_char_to_encoding(name));
return (pg_char_to_encoding(name));
}
/*
* find encoding table entry by encoding
*/
pg_encoding_conv_tbl *pg_get_encent_by_encoding(int encoding)
pg_encoding_conv_tbl *
pg_get_encent_by_encoding(int encoding)
{
pg_encoding_conv_tbl *p = pg_conv_tbl;
for(;p->encoding >= 0;p++) {
if (p->encoding == encoding) {
return(p);
}
}
return(0);
pg_encoding_conv_tbl *p = pg_conv_tbl;
for (; p->encoding >= 0; p++)
{
if (p->encoding == encoding)
return (p);
}
return (0);
}
/*
* convert encoding symbol to encoding char.
* if there's no valid encoding symbol, returns ""
*/
const char *pg_encoding_to_char(int encoding)
const char *
pg_encoding_to_char(int encoding)
{
pg_encoding_conv_tbl *p = pg_get_encent_by_encoding(encoding);
pg_encoding_conv_tbl *p = pg_get_encent_by_encoding(encoding);
if (!p) return("");
return(p->name);
if (!p)
return ("");
return (p->name);
}
/* returns the byte length of a multi-byte word for an encoding */
int pg_encoding_mblen(int encoding, const unsigned char *mbstr)
int
pg_encoding_mblen(int encoding, const unsigned char *mbstr)
{
return((*pg_wchar_table[encoding].mblen)(mbstr));
return ((*pg_wchar_table[encoding].mblen) (mbstr));
}

View File

@@ -2,7 +2,7 @@
* conversion between client encoding and server internal encoding
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
* $Id: conv.c,v 1.2 1998/08/24 01:13:59 momjian Exp $
* $Id: conv.c,v 1.3 1998/09/01 04:33:21 momjian Exp $
*/
#include <stdio.h>
#include <string.h>
@@ -13,405 +13,505 @@
* convert bogus chars that cannot be represented in the current encoding
* system.
*/
static void printBogusChar(unsigned char **mic, unsigned char **p)
static void
printBogusChar(unsigned char **mic, unsigned char **p)
{
char strbuf[16];
int l = pg_mic_mblen(*mic);
char strbuf[16];
int l = pg_mic_mblen(*mic);
*(*p)++ = '(';
while (l--) {
sprintf(strbuf,"%02x",*(*mic)++);
*(*p)++ = strbuf[0];
*(*p)++ = strbuf[1];
}
*(*p)++ = ')';
*(*p)++ = '(';
while (l--)
{
sprintf(strbuf, "%02x", *(*mic)++);
*(*p)++ = strbuf[0];
*(*p)++ = strbuf[1];
}
*(*p)++ = ')';
}
/*
* SJIS ---> MIC
*/
static void sjis2mic(unsigned char *sjis, unsigned char *p, int len)
static void
sjis2mic(unsigned char *sjis, unsigned char *p, int len)
{
int c1,c2;
int c1,
c2;
while (len > 0 && (c1 = *sjis++)) {
if (c1 >= 0xa1 && c1 <= 0xdf) { /* 1 byte kana? */
len--;
*p++ = LC_JISX0201K;
*p++ = c1;
} else if (c1 > 0x7f) { /* kanji? */
c2 = *sjis++;
len -= 2;
*p++ = LC_JISX0208;
*p++ = ((c1 & 0x3f)<<1) + 0x9f + (c2 > 0x9e);
*p++ = c2 + ((c2 > 0x9e)? 2 : 0x60) + (c2 < 0x80);
} else { /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *sjis++))
{
if (c1 >= 0xa1 && c1 <= 0xdf)
{ /* 1 byte kana? */
len--;
*p++ = LC_JISX0201K;
*p++ = c1;
}
else if (c1 > 0x7f)
{ /* kanji? */
c2 = *sjis++;
len -= 2;
*p++ = LC_JISX0208;
*p++ = ((c1 & 0x3f) << 1) + 0x9f + (c2 > 0x9e);
*p++ = c2 + ((c2 > 0x9e) ? 2 : 0x60) + (c2 < 0x80);
}
else
{ /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
}
/*
* MIC ---> SJIS
*/
static void mic2sjis(unsigned char *mic, unsigned char *p, int len)
static void
mic2sjis(unsigned char *mic, unsigned char *p, int len)
{
int c1,c2;
int c1,
c2;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == LC_JISX0201K) {
*p++ = *mic++;
} else if (c1 == LC_JISX0208) {
c1 = *mic++;
c2 = *mic++;
*p++ = ((c1 - 0xa1)>>1) + ((c1 < 0xdf)? 0x81 : 0xc1);
*p++ = c2 - ((c1 & 1)? ((c2 < 0xe0)? 0x61 : 0x60) : 2);
} else if (c1 > 0x7f) { /* cannot convert to SJIS! */
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == LC_JISX0201K)
*p++ = *mic++;
else if (c1 == LC_JISX0208)
{
c1 = *mic++;
c2 = *mic++;
*p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1);
*p++ = c2 - ((c1 & 1) ? ((c2 < 0xe0) ? 0x61 : 0x60) : 2);
}
else if (c1 > 0x7f)
{ /* cannot convert to SJIS! */
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
/*
* EUC_JP ---> MIC
*/
static void euc_jp2mic(unsigned char *euc, unsigned char *p, int len)
static void
euc_jp2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *euc++)) {
if (c1 == SS2) { /* 1 byte kana? */
len -= 2;
*p++ = LC_JISX0201K;
*p++ = *euc++;
} else if (c1 == SS3) { /* JIS X0212 kanji? */
len -= 3;
*p++ = LC_JISX0212;
*p++ = *euc++;
*p++ = *euc++;
} else if (c1 & 0x80) { /* kanji? */
len -= 2;
*p++ = LC_JISX0208;
*p++ = c1;
*p++ = *euc++;
} else { /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *euc++))
{
if (c1 == SS2)
{ /* 1 byte kana? */
len -= 2;
*p++ = LC_JISX0201K;
*p++ = *euc++;
}
else if (c1 == SS3)
{ /* JIS X0212 kanji? */
len -= 3;
*p++ = LC_JISX0212;
*p++ = *euc++;
*p++ = *euc++;
}
else if (c1 & 0x80)
{ /* kanji? */
len -= 2;
*p++ = LC_JISX0208;
*p++ = c1;
*p++ = *euc++;
}
else
{ /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
}
/*
* MIC ---> EUC_JP
*/
static void mic2euc_jp(unsigned char *mic, unsigned char *p, int len)
static void
mic2euc_jp(unsigned char *mic, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == LC_JISX0201K) {
*p++ = SS2;
*p++ = *mic++;
} else if (c1 == LC_JISX0212) {
*p++ = SS3;
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 == LC_JISX0208) {
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 > 0x7f) { /* cannot convert to EUC_JP! */
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == LC_JISX0201K)
{
*p++ = SS2;
*p++ = *mic++;
}
else if (c1 == LC_JISX0212)
{
*p++ = SS3;
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 == LC_JISX0208)
{
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 > 0x7f)
{ /* cannot convert to EUC_JP! */
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
/*
* EUC_KR ---> MIC
*/
static void euc_kr2mic(unsigned char *euc, unsigned char *p, int len)
static void
euc_kr2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *euc++)) {
if (c1 & 0x80) {
len -= 2;
*p++ = LC_KS5601;
*p++ = c1;
*p++ = *euc++;
} else { /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *euc++))
{
if (c1 & 0x80)
{
len -= 2;
*p++ = LC_KS5601;
*p++ = c1;
*p++ = *euc++;
}
else
{ /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
}
/*
* MIC ---> EUC_KR
*/
static void mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
static void
mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == LC_KS5601) {
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 > 0x7f) { /* cannot convert to EUC_KR! */
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == LC_KS5601)
{
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 > 0x7f)
{ /* cannot convert to EUC_KR! */
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
/*
* EUC_CN ---> MIC
*/
static void euc_cn2mic(unsigned char *euc, unsigned char *p, int len)
static void
euc_cn2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *euc++)) {
if (c1 & 0x80) {
len -= 2;
*p++ = LC_GB2312_80;
*p++ = c1;
*p++ = *euc++;
} else { /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *euc++))
{
if (c1 & 0x80)
{
len -= 2;
*p++ = LC_GB2312_80;
*p++ = c1;
*p++ = *euc++;
}
else
{ /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
}
/*
* MIC ---> EUC_CN
*/
static void mic2euc_cn(unsigned char *mic, unsigned char *p, int len)
static void
mic2euc_cn(unsigned char *mic, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == LC_GB2312_80) {
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 > 0x7f) { /* cannot convert to EUC_CN! */
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == LC_GB2312_80)
{
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 > 0x7f)
{ /* cannot convert to EUC_CN! */
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
/*
* EUC_TW ---> MIC
*/
static void euc_tw2mic(unsigned char *euc, unsigned char *p, int len)
static void
euc_tw2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *euc++)) {
if (c1 == SS2) {
len -= 4;
c1 = *euc++; /* plane No. */
if (c1 == 0xa1) {
*p++ = LC_CNS11643_1;
} else if (c1 == 0xa2) {
*p++ = LC_CNS11643_2;
} else {
*p++ = 0x9d; /* LCPRV2 */
*p++ = 0xa3 - c1 + LC_CNS11643_3;
}
*p++ = *euc++;
*p++ = *euc++;
} else if (c1 & 0x80) { /* CNS11643-1 */
len -= 2;
*p++ = LC_CNS11643_1;
*p++ = c1;
*p++ = *euc++;
} else { /* should be ASCII */
len --;
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *euc++))
{
if (c1 == SS2)
{
len -= 4;
c1 = *euc++; /* plane No. */
if (c1 == 0xa1)
*p++ = LC_CNS11643_1;
else if (c1 == 0xa2)
*p++ = LC_CNS11643_2;
else
{
*p++ = 0x9d; /* LCPRV2 */
*p++ = 0xa3 - c1 + LC_CNS11643_3;
}
*p++ = *euc++;
*p++ = *euc++;
}
else if (c1 & 0x80)
{ /* CNS11643-1 */
len -= 2;
*p++ = LC_CNS11643_1;
*p++ = c1;
*p++ = *euc++;
}
else
{ /* should be ASCII */
len--;
*p++ = c1;
}
}
*p = '\0';
}
/*
* MIC ---> EUC_TW
*/
static void mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
static void
mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2) {
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 == 0x9d) { /* LCPRV2? */
*p++ = SS2;
*p++ = c1 - LC_CNS11643_3 + 0xa3;
*p++ = *mic++;
*p++ = *mic++;
} else if (c1 > 0x7f) { /* cannot convert to EUC_TW! */
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2)
{
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 == 0x9d)
{ /* LCPRV2? */
*p++ = SS2;
*p++ = c1 - LC_CNS11643_3 + 0xa3;
*p++ = *mic++;
*p++ = *mic++;
}
else if (c1 > 0x7f)
{ /* cannot convert to EUC_TW! */
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
/*
* LATINn ---> MIC
*/
static void latin2mic(unsigned char *l, unsigned char *p, int len, int lc)
static void
latin2mic(unsigned char *l, unsigned char *p, int len, int lc)
{
int c1;
int c1;
while (len-- > 0 && (c1 = *l++)) {
if (c1 > 0x7f) { /* Latin1? */
*p++ = lc;
}
*p++ = c1;
}
*p = '\0';
while (len-- > 0 && (c1 = *l++))
{
if (c1 > 0x7f)
{ /* Latin1? */
*p++ = lc;
}
*p++ = c1;
}
*p = '\0';
}
/*
* MIC ---> LATINn
*/
static void mic2latin(unsigned char *mic, unsigned char *p, int len, int lc)
static void
mic2latin(unsigned char *mic, unsigned char *p, int len, int lc)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
len -= pg_mic_mblen(mic++);
while (len > 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
if (c1 == lc) {
*p++ = *mic++;
} else if (c1 > 0x7f) {
mic--;
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
if (c1 == lc)
*p++ = *mic++;
else if (c1 > 0x7f)
{
mic--;
printBogusChar(&mic, &p);
}
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
static void latin12mic(unsigned char *l, unsigned char *p, int len)
static void
latin12mic(unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_ISO8859_1);
latin2mic(l, p, len, LC_ISO8859_1);
}
static void mic2latin1(unsigned char *mic, unsigned char *p, int len)
static void
mic2latin1(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_1);
mic2latin(mic, p, len, LC_ISO8859_1);
}
static void latin22mic(unsigned char *l, unsigned char *p, int len)
static void
latin22mic(unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_ISO8859_2);
latin2mic(l, p, len, LC_ISO8859_2);
}
static void mic2latin2(unsigned char *mic, unsigned char *p, int len)
static void
mic2latin2(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_2);
mic2latin(mic, p, len, LC_ISO8859_2);
}
static void latin32mic(unsigned char *l, unsigned char *p, int len)
static void
latin32mic(unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_ISO8859_3);
latin2mic(l, p, len, LC_ISO8859_3);
}
static void mic2latin3(unsigned char *mic, unsigned char *p, int len)
static void
mic2latin3(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_3);
mic2latin(mic, p, len, LC_ISO8859_3);
}
static void latin42mic(unsigned char *l, unsigned char *p, int len)
static void
latin42mic(unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_ISO8859_4);
latin2mic(l, p, len, LC_ISO8859_4);
}
static void mic2latin4(unsigned char *mic, unsigned char *p, int len)
static void
mic2latin4(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_4);
mic2latin(mic, p, len, LC_ISO8859_4);
}
static void latin52mic(unsigned char *l, unsigned char *p, int len)
static void
latin52mic(unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_ISO8859_5);
latin2mic(l, p, len, LC_ISO8859_5);
}
static void mic2latin5(unsigned char *mic, unsigned char *p, int len)
static void
mic2latin5(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_5);
mic2latin(mic, p, len, LC_ISO8859_5);
}
/*
* ASCII ---> MIC
*/
static void ascii2mic(unsigned char *l, unsigned char *p, int len)
static void
ascii2mic(unsigned char *l, unsigned char *p, int len)
{
int c1;
int c1;
while (len-- > 0 && (c1 = *l++)) {
*p++ = (c1 & 0x7f);
}
*p = '\0';
while (len-- > 0 && (c1 = *l++))
*p++ = (c1 & 0x7f);
*p = '\0';
}
/*
* MIC ---> ASCII
*/
static void mic2ascii(unsigned char *mic, unsigned char *p, int len)
static void
mic2ascii(unsigned char *mic, unsigned char *p, int len)
{
int c1;
int c1;
while (len > 0 && (c1 = *mic)) {
if (c1 > 0x7f) {
printBogusChar(&mic, &p);
} else { /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
while (len > 0 && (c1 = *mic))
{
if (c1 > 0x7f)
printBogusChar(&mic, &p);
else
{ /* should be ASCII */
*p++ = c1;
}
}
*p = '\0';
}
pg_encoding_conv_tbl pg_conv_tbl[] = {
{SQL_ASCII, "SQL_ASCII", 0, ascii2mic, mic2ascii}, /* SQL/ACII */
{EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp}, /* EUC_JP */
{EUC_CN, "EUC_CN", 0, euc_cn2mic, mic2euc_cn}, /* EUC_CN */
{EUC_KR, "EUC_KR", 0, euc_kr2mic, mic2euc_kr}, /* EUC_KR */
{EUC_TW, "EUC_TW", 0, euc_tw2mic, mic2euc_tw}, /* EUC_TW */
{UNICODE, "UNICODE", 0, 0, 0}, /* UNICODE */
{MULE_INTERNAL, "MULE_INTERNAL", 0, 0, 0}, /* MULE_INTERNAL */
{LATIN1, "LATIN1", 0, latin12mic, mic2latin1}, /* ISO 8859 Latin 1 */
{LATIN2, "LATIN2", 0, latin22mic, mic2latin2}, /* ISO 8859 Latin 2 */
{LATIN3, "LATIN3", 0, latin32mic, mic2latin3}, /* ISO 8859 Latin 3 */
{LATIN4, "LATIN4", 0, latin42mic, mic2latin4}, /* ISO 8859 Latin 4 */
{LATIN5, "LATIN5", 0, latin52mic, mic2latin5}, /* ISO 8859 Latin 5 */
{SJIS, "SJIS", 1, sjis2mic, mic2sjis}, /* SJIS */
{-1, "", 0, 0, 0} /* end mark */
{SQL_ASCII, "SQL_ASCII", 0, ascii2mic, mic2ascii}, /* SQL/ACII */
{EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp}, /* EUC_JP */
{EUC_CN, "EUC_CN", 0, euc_cn2mic, mic2euc_cn}, /* EUC_CN */
{EUC_KR, "EUC_KR", 0, euc_kr2mic, mic2euc_kr}, /* EUC_KR */
{EUC_TW, "EUC_TW", 0, euc_tw2mic, mic2euc_tw}, /* EUC_TW */
{UNICODE, "UNICODE", 0, 0, 0}, /* UNICODE */
{MULE_INTERNAL, "MULE_INTERNAL", 0, 0, 0}, /* MULE_INTERNAL */
{LATIN1, "LATIN1", 0, latin12mic, mic2latin1}, /* ISO 8859 Latin 1 */
{LATIN2, "LATIN2", 0, latin22mic, mic2latin2}, /* ISO 8859 Latin 2 */
{LATIN3, "LATIN3", 0, latin32mic, mic2latin3}, /* ISO 8859 Latin 3 */
{LATIN4, "LATIN4", 0, latin42mic, mic2latin4}, /* ISO 8859 Latin 4 */
{LATIN5, "LATIN5", 0, latin52mic, mic2latin5}, /* ISO 8859 Latin 5 */
{SJIS, "SJIS", 1, sjis2mic, mic2sjis}, /* SJIS */
{-1, "", 0, 0, 0} /* end mark */
};

View File

@@ -3,7 +3,7 @@
* client encoding and server internal encoding.
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
* $Id: mbutils.c,v 1.2 1998/07/26 04:31:04 scrappy Exp $ */
* $Id: mbutils.c,v 1.3 1998/09/01 04:33:22 momjian Exp $ */
#include <stdio.h>
#include <string.h>
@@ -11,77 +11,85 @@
#include "mb/pg_wchar.h"
static client_encoding = -1;
static void (*client_to_mic)(); /* something to MIC */
static void (*client_from_mic)(); /* MIC to something */
static void (*server_to_mic)(); /* something to MIC */
static void (*server_from_mic)(); /* MIC to something */
static void (*client_to_mic) ();/* something to MIC */
static void (*client_from_mic) (); /* MIC to something */
static void (*server_to_mic) ();/* something to MIC */
static void (*server_from_mic) (); /* MIC to something */
/*
* find encoding table entry by encoding
*/
static pg_encoding_conv_tbl *get_enc_ent(int encoding)
static pg_encoding_conv_tbl *
get_enc_ent(int encoding)
{
pg_encoding_conv_tbl *p = pg_conv_tbl;
for(;p->encoding >= 0;p++) {
if (p->encoding == encoding) {
return(p);
}
}
return(0);
pg_encoding_conv_tbl *p = pg_conv_tbl;
for (; p->encoding >= 0; p++)
{
if (p->encoding == encoding)
return (p);
}
return (0);
}
/*
* set the client encoding. if client/server encoding is
* not supported, returns -1
*/
int pg_set_client_encoding(int encoding)
int
pg_set_client_encoding(int encoding)
{
int current_server_encoding = GetDatabaseEncoding();
int current_server_encoding = GetDatabaseEncoding();
client_encoding = encoding;
client_encoding = encoding;
if (client_encoding == current_server_encoding) { /* server == client? */
client_to_mic = client_from_mic = 0;
server_to_mic = server_from_mic = 0;
} else if (current_server_encoding == MULE_INTERNAL) { /* server == MULE_INETRNAL? */
client_to_mic = get_enc_ent(encoding)->to_mic;
client_from_mic = get_enc_ent(encoding)->from_mic;
server_to_mic = server_from_mic = 0;
if (client_to_mic == 0 || client_from_mic == 0) {
return(-1);
}
} else if (encoding == MULE_INTERNAL) { /* client == MULE_INETRNAL? */
client_to_mic = client_from_mic = 0;
server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
if (server_to_mic == 0 || server_from_mic == 0) {
return(-1);
}
} else {
client_to_mic = get_enc_ent(encoding)->to_mic;
client_from_mic = get_enc_ent(encoding)->from_mic;
server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
if (client_to_mic == 0 || client_from_mic == 0) {
return(-1);
}
if (server_to_mic == 0 || server_from_mic == 0) {
return(-1);
}
}
return(0);
if (client_encoding == current_server_encoding)
{ /* server == client? */
client_to_mic = client_from_mic = 0;
server_to_mic = server_from_mic = 0;
}
else if (current_server_encoding == MULE_INTERNAL)
{ /* server == MULE_INETRNAL? */
client_to_mic = get_enc_ent(encoding)->to_mic;
client_from_mic = get_enc_ent(encoding)->from_mic;
server_to_mic = server_from_mic = 0;
if (client_to_mic == 0 || client_from_mic == 0)
return (-1);
}
else if (encoding == MULE_INTERNAL)
{ /* client == MULE_INETRNAL? */
client_to_mic = client_from_mic = 0;
server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
if (server_to_mic == 0 || server_from_mic == 0)
return (-1);
}
else
{
client_to_mic = get_enc_ent(encoding)->to_mic;
client_from_mic = get_enc_ent(encoding)->from_mic;
server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
if (client_to_mic == 0 || client_from_mic == 0)
return (-1);
if (server_to_mic == 0 || server_from_mic == 0)
return (-1);
}
return (0);
}
/*
* returns the current client encoding
*/
int pg_get_client_encoding()
int
pg_get_client_encoding()
{
if (client_encoding == -1) {
/* this is the first time */
client_encoding = GetDatabaseEncoding();
}
return(client_encoding);
if (client_encoding == -1)
{
/* this is the first time */
client_encoding = GetDatabaseEncoding();
}
return (client_encoding);
}
/*
@@ -89,25 +97,27 @@ int pg_get_client_encoding()
* client_encoding or no conversion function exists,
* returns s. So be careful.
*/
unsigned char *pg_client_to_server(unsigned char *s, int len)
unsigned char *
pg_client_to_server(unsigned char *s, int len)
{
static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
unsigned char *p = s;
static unsigned char b1[MAX_PARSE_BUFFER * 4]; /* is this enough? */
static unsigned char b2[MAX_PARSE_BUFFER * 4]; /* is this enough? */
unsigned char *p = s;
if (client_encoding == GetDatabaseEncoding()) {
return(p);
}
if (client_to_mic) {
(*client_to_mic)(s, b1, len);
len = strlen(b1);
p = b1;
}
if (server_from_mic) {
(*server_from_mic)(p, b2, len);
p = b2;
}
return(p);
if (client_encoding == GetDatabaseEncoding())
return (p);
if (client_to_mic)
{
(*client_to_mic) (s, b1, len);
len = strlen(b1);
p = b1;
}
if (server_from_mic)
{
(*server_from_mic) (p, b2, len);
p = b2;
}
return (p);
}
/*
@@ -115,102 +125,115 @@ unsigned char *pg_client_to_server(unsigned char *s, int len)
* client_encoding or no conversion function exists,
* returns s. So be careful.
*/
unsigned char *pg_server_to_client(unsigned char *s, int len)
unsigned char *
pg_server_to_client(unsigned char *s, int len)
{
static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
unsigned char *p = s;
static unsigned char b1[MAX_PARSE_BUFFER * 4]; /* is this enough? */
static unsigned char b2[MAX_PARSE_BUFFER * 4]; /* is this enough? */
unsigned char *p = s;
if (client_encoding == GetDatabaseEncoding()) {
return(p);
}
if (server_to_mic) {
(*server_to_mic)(s, b1, len);
len = strlen(b1);
p = b1;
}
if (client_from_mic) {
(*client_from_mic)(p, b2, len);
p = b2;
}
return(p);
if (client_encoding == GetDatabaseEncoding())
return (p);
if (server_to_mic)
{
(*server_to_mic) (s, b1, len);
len = strlen(b1);
p = b1;
}
if (client_from_mic)
{
(*client_from_mic) (p, b2, len);
p = b2;
}
return (p);
}
/* convert a multi-byte string to a wchar */
void pg_mb2wchar(const unsigned char *from, pg_wchar *to)
void
pg_mb2wchar(const unsigned char *from, pg_wchar * to)
{
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len)(from,to,strlen(from));
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
}
/* convert a multi-byte string to a wchar with a limited length */
void pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
void
pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len)(from,to,len);
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
}
/* returns the byte length of a multi-byte word */
int pg_mblen(const unsigned char *mbstr)
int
pg_mblen(const unsigned char *mbstr)
{
return((*pg_wchar_table[GetDatabaseEncoding()].mblen)(mbstr));
return ((*pg_wchar_table[GetDatabaseEncoding()].mblen) (mbstr));
}
/* returns the length (counted as a wchar) of a multi-byte string */
int pg_mbstrlen(const unsigned char *mbstr)
int
pg_mbstrlen(const unsigned char *mbstr)
{
int len = 0;
while (*mbstr) {
mbstr += pg_mblen(mbstr);
len++;
}
return(len);
int len = 0;
while (*mbstr)
{
mbstr += pg_mblen(mbstr);
len++;
}
return (len);
}
/* returns the length (counted as a wchar) of a multi-byte string
/* returns the length (counted as a wchar) of a multi-byte string
(not necessarily NULL terminated) */
int pg_mbstrlen_with_len(const unsigned char *mbstr, int limit)
int
pg_mbstrlen_with_len(const unsigned char *mbstr, int limit)
{
int len = 0;
int l;
while (*mbstr && limit > 0) {
l = pg_mblen(mbstr);
limit -= l;
mbstr += l;
len++;
}
return(len);
int len = 0;
int l;
while (*mbstr && limit > 0)
{
l = pg_mblen(mbstr);
limit -= l;
mbstr += l;
len++;
}
return (len);
}
/*
* fuctions for utils/init
*/
static int DatabaseEncoding = MULTIBYTE;
static int DatabaseEncoding = MULTIBYTE;
void
SetDatabaseEncoding(int encoding)
{
DatabaseEncoding = encoding;
DatabaseEncoding = encoding;
}
int
GetDatabaseEncoding()
{
return(DatabaseEncoding);
return (DatabaseEncoding);
}
/* for builtin-function */
const char *
getdatabaseencoding()
{
return(pg_encoding_to_char(DatabaseEncoding));
return (pg_encoding_to_char(DatabaseEncoding));
}
/* set and get template1 database encoding */
static int templateEncoding;
void SetTemplateEncoding(int encoding)
static int templateEncoding;
void
SetTemplateEncoding(int encoding)
{
templateEncoding = encoding;
templateEncoding = encoding;
}
int GetTemplateEncoding()
int
GetTemplateEncoding()
{
return(templateEncoding);
return (templateEncoding);
}

View File

@@ -1,6 +1,6 @@
/*
* testing of utf2wchar()
* $Id: utftest.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
* $Id: utftest.c,v 1.2 1998/09/01 04:33:23 momjian Exp $
*/
#include <regex/regex.h>
#include <regex/utils.h>
@@ -10,24 +10,28 @@
main()
{
/* Example 1 from RFC2044 */
char utf1[] = {0x41,0xe2,0x89,0xa2,0xce,0x91,0x2e,0};
/* Example 2 from RFC2044 */
char utf2[] = {0x48,0x69,0x20,0x4d,0x6f,0x6d,0x20,0xe2,0x98,0xba,0x21,0};
/* Example 3 from RFC2044 */
char utf3[] = {0xe6,0x97,0xa5,0xe6,0x9c,0xac,0xe8,0xaa,0x9e,0};
char *utf[] = {utf1,utf2,utf3};
pg_wchar ucs[128];
pg_wchar *p;
int i;
/* Example 1 from RFC2044 */
char utf1[] = {0x41, 0xe2, 0x89, 0xa2, 0xce, 0x91, 0x2e, 0};
for (i=0;i<sizeof(utf)/sizeof(char *);i++) {
pg_utf2wchar(utf[i],ucs);
p = ucs;
while(*p) {
printf("%04x ",*p);
p++;
}
printf("\n");
}
/* Example 2 from RFC2044 */
char utf2[] = {0x48, 0x69, 0x20, 0x4d, 0x6f, 0x6d, 0x20, 0xe2, 0x98, 0xba, 0x21, 0};
/* Example 3 from RFC2044 */
char utf3[] = {0xe6, 0x97, 0xa5, 0xe6, 0x9c, 0xac, 0xe8, 0xaa, 0x9e, 0};
char *utf[] = {utf1, utf2, utf3};
pg_wchar ucs[128];
pg_wchar *p;
int i;
for (i = 0; i < sizeof(utf) / sizeof(char *); i++)
{
pg_utf2wchar(utf[i], ucs);
p = ucs;
while (*p)
{
printf("%04x ", *p);
p++;
}
printf("\n");
}
}

View File

@@ -2,7 +2,7 @@
* This file contains some public functions
* related to show/set/reset variable commands.
* Tatsuo Ishii
* $Id: variable.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
* $Id: variable.c,v 1.2 1998/09/01 04:33:24 momjian Exp $
*/
#include "mb/pg_wchar.h"
@@ -10,64 +10,66 @@
bool
parse_client_encoding(const char *value)
{
int encoding;
int encoding;
encoding = pg_valid_client_encoding(value);
if (encoding < 0) {
elog(ERROR, "Client encoding %s is not supported", value);
} else {
if (pg_set_client_encoding(encoding)) {
elog(ERROR, "Conversion between %s and %s is not supported",
value, pg_encoding_to_char(GetDatabaseEncoding()));
}
}
return TRUE;
encoding = pg_valid_client_encoding(value);
if (encoding < 0)
elog(ERROR, "Client encoding %s is not supported", value);
else
{
if (pg_set_client_encoding(encoding))
{
elog(ERROR, "Conversion between %s and %s is not supported",
value, pg_encoding_to_char(GetDatabaseEncoding()));
}
}
return TRUE;
}
bool
show_client_encoding()
{
elog(NOTICE, "Current client encoding is %s",
pg_encoding_to_char(pg_get_client_encoding()));
return TRUE;
elog(NOTICE, "Current client encoding is %s",
pg_encoding_to_char(pg_get_client_encoding()));
return TRUE;
}
bool
reset_client_encoding()
{
int encoding;
char *env = getenv("PGCLIENTENCODING");
int encoding;
char *env = getenv("PGCLIENTENCODING");
if (env) {
encoding = pg_char_to_encoding(env);
if (encoding < 0) {
encoding = GetDatabaseEncoding();
}
} else {
encoding = GetDatabaseEncoding();
}
pg_set_client_encoding(encoding);
return TRUE;
if (env)
{
encoding = pg_char_to_encoding(env);
if (encoding < 0)
encoding = GetDatabaseEncoding();
}
else
encoding = GetDatabaseEncoding();
pg_set_client_encoding(encoding);
return TRUE;
}
bool
parse_server_encoding(const char *value)
{
elog(NOTICE, "SET SERVER_ENCODING is not supported");
return TRUE;
elog(NOTICE, "SET SERVER_ENCODING is not supported");
return TRUE;
}
bool
show_server_encoding()
{
elog(NOTICE, "Current server encoding is %s",
pg_encoding_to_char(GetDatabaseEncoding()));
return TRUE;
elog(NOTICE, "Current server encoding is %s",
pg_encoding_to_char(GetDatabaseEncoding()));
return TRUE;
}
bool
reset_server_encoding()
{
elog(NOTICE, "RESET SERVER_ENCODING is not supported");
return TRUE;
elog(NOTICE, "RESET SERVER_ENCODING is not supported");
return TRUE;
}

View File

@@ -1,7 +1,7 @@
/*
* conversion functions between pg_wchar and multi-byte streams.
* Tatsuo Ishii
* $Id: wchar.c,v 1.3 1998/08/25 04:19:16 momjian Exp $
* $Id: wchar.c,v 1.4 1998/09/01 04:33:26 momjian Exp $
*/
#include "mb/pg_wchar.h"
@@ -10,7 +10,7 @@
* conversion to pg_wchar is done by "table driven."
* to add an encoding support, define mb2wchar_with_len(), mblen()
* for the particular encoding. Note that if the encoding is only
* supported in the client, you don't need to define
* supported in the client, you don't need to define
* mb2wchar_with_len() function (SJIS is the case).
*/
@@ -18,18 +18,20 @@
* SQL/ASCII
*/
static void pg_ascii2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len > 0) {
*to++ = *from++;
len--;
}
*to = 0;
while (*from && len > 0)
{
*to++ = *from++;
len--;
}
*to = 0;
}
static int pg_ascii_mblen(const unsigned char *s)
static int
pg_ascii_mblen(const unsigned char *s)
{
return(1);
return (1);
}
/*
@@ -37,169 +39,195 @@ static int pg_ascii_mblen(const unsigned char *s)
*/
static void pg_euc2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len > 0) {
if (*from == SS2) {
from++;
len--;
*to = 0xff & *from++;
len--;
} else if (*from == SS3) {
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
} else if (*from & 0x80) {
*to = *from++ << 8;
*to |= *from++;
len -= 2;
} else {
*to = *from++;
len--;
}
to++;
}
*to = 0;
while (*from && len > 0)
{
if (*from == SS2)
{
from++;
len--;
*to = 0xff & *from++;
len--;
}
else if (*from == SS3)
{
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
}
else if (*from & 0x80)
{
*to = *from++ << 8;
*to |= *from++;
len -= 2;
}
else
{
*to = *from++;
len--;
}
to++;
}
*to = 0;
}
static int pg_euc_mblen(const unsigned char *s)
static int
pg_euc_mblen(const unsigned char *s)
{
int len;
int len;
if (*s == SS2) {
len = 2;
} else if (*s == SS3) {
len = 3;
} else if (*s & 0x80) {
len = 2;
} else {
len = 1;
}
return(len);
if (*s == SS2)
len = 2;
else if (*s == SS3)
len = 3;
else if (*s & 0x80)
len = 2;
else
len = 1;
return (len);
}
/*
* EUC_JP
*/
static void pg_eucjp2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
pg_euc2wchar_with_len(from,to,len);
pg_euc2wchar_with_len(from, to, len);
}
static int pg_eucjp_mblen(const unsigned char *s)
static int
pg_eucjp_mblen(const unsigned char *s)
{
return(pg_euc_mblen(s));
return (pg_euc_mblen(s));
}
/*
* EUC_KR
*/
static void pg_euckr2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
pg_euc2wchar_with_len(from,to,len);
pg_euc2wchar_with_len(from, to, len);
}
static int pg_euckr_mblen(const unsigned char *s)
static int
pg_euckr_mblen(const unsigned char *s)
{
return(pg_euc_mblen(s));
return (pg_euc_mblen(s));
}
/*
* EUC_CN
*/
static void pg_euccn2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len > 0) {
if (*from == SS2) {
from++;
len--;
*to = 0x3f00 & (*from++ << 8);
*to = *from++;
len -= 2;
} else if (*from == SS3) {
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
} else if (*from & 0x80) {
*to = *from++ << 8;
*to |= *from++;
len -= 2;
} else {
*to = *from++;
len--;
}
to++;
}
*to = 0;
while (*from && len > 0)
{
if (*from == SS2)
{
from++;
len--;
*to = 0x3f00 & (*from++ << 8);
*to = *from++;
len -= 2;
}
else if (*from == SS3)
{
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
}
else if (*from & 0x80)
{
*to = *from++ << 8;
*to |= *from++;
len -= 2;
}
else
{
*to = *from++;
len--;
}
to++;
}
*to = 0;
}
static int pg_euccn_mblen(const unsigned char *s)
static int
pg_euccn_mblen(const unsigned char *s)
{
int len;
int len;
if (*s == SS2) {
len = 3;
} else if (*s == SS3) {
len = 3;
} else if (*s & 0x80) {
len = 2;
} else {
len = 1;
}
return(len);
if (*s == SS2)
len = 3;
else if (*s == SS3)
len = 3;
else if (*s & 0x80)
len = 2;
else
len = 1;
return (len);
}
/*
* EUC_TW
*/
static void pg_euctw2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len > 0) {
if (*from == SS2) {
from++;
len--;
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 3;
} else if (*from == SS3) {
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
} else if (*from & 0x80) {
*to = *from++ << 8;
*to |= *from++;
len -= 2;
} else {
*to = *from++;
len--;
}
to++;
}
*to = 0;
while (*from && len > 0)
{
if (*from == SS2)
{
from++;
len--;
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 3;
}
else if (*from == SS3)
{
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
len -= 3;
}
else if (*from & 0x80)
{
*to = *from++ << 8;
*to |= *from++;
len -= 2;
}
else
{
*to = *from++;
len--;
}
to++;
}
*to = 0;
}
static int pg_euctw_mblen(const unsigned char *s)
static int
pg_euctw_mblen(const unsigned char *s)
{
int len;
int len;
if (*s == SS2) {
len = 4;
} else if (*s == SS3) {
len = 3;
} else if (*s & 0x80) {
len = 2;
} else {
len = 1;
}
return(len);
if (*s == SS2)
len = 4;
else if (*s == SS3)
len = 3;
else if (*s & 0x80)
len = 2;
else
len = 1;
return (len);
}
/*
@@ -208,45 +236,55 @@ static int pg_euctw_mblen(const unsigned char *s)
* len: length of from.
* "from" not necessarily null terminated.
*/
static void pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static void
pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
unsigned char c1,c2,c3;
while (*from && len > 0) {
if ((*from & 0x80) == 0) {
*to = *from++;
len--;
} else if ((*from & 0xe0) == 0xc0) {
c1 = *from++ & 0x1f;
c2 = *from++ & 0x3f;
len -= 2;
*to = c1 << 6;
*to |= c2;
} else if ((*from & 0xe0) == 0xe0) {
c1 = *from++ & 0x0f;
c2 = *from++ & 0x3f;
c3 = *from++ & 0x3f;
len -= 3;
*to = c1 << 12;
*to |= c2 << 6;
*to |= c3;
}
to++;
}
*to = 0;
unsigned char c1,
c2,
c3;
while (*from && len > 0)
{
if ((*from & 0x80) == 0)
{
*to = *from++;
len--;
}
else if ((*from & 0xe0) == 0xc0)
{
c1 = *from++ & 0x1f;
c2 = *from++ & 0x3f;
len -= 2;
*to = c1 << 6;
*to |= c2;
}
else if ((*from & 0xe0) == 0xe0)
{
c1 = *from++ & 0x0f;
c2 = *from++ & 0x3f;
c3 = *from++ & 0x3f;
len -= 3;
*to = c1 << 12;
*to |= c2 << 6;
*to |= c3;
}
to++;
}
*to = 0;
}
static int pg_utf_mblen(const unsigned char *s)
static int
pg_utf_mblen(const unsigned char *s)
{
int len = 1;
int len = 1;
if ((*s & 0x80) == 0) {
len = 1;
} else if ((*s & 0xe0) == 0xc0) {
len = 2;
} else if ((*s & 0xe0) == 0xe0) {
len = 3;
}
return(len);
if ((*s & 0x80) == 0)
len = 1;
else if ((*s & 0xe0) == 0xc0)
len = 2;
else if ((*s & 0xe0) == 0xe0)
len = 3;
return (len);
}
/*
@@ -255,127 +293,148 @@ static int pg_utf_mblen(const unsigned char *s)
* len: length of from.
* "from" not necessarily null terminated.
*/
static void pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static void
pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len > 0) {
if (IS_LC1(*from)) {
*to = *from++ << 16;
*to |= *from++;
len -= 2;
} else if (IS_LCPRV1(*from)) {
from++;
*to = *from++ << 16;
*to |= *from++;
len -= 3;
} else if (IS_LC2(*from)) {
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 3;
} else if (IS_LCPRV2(*from)) {
from++;
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 4;
} else { /* assume ASCII */
*to = (unsigned char)*from++;
len--;
}
to++;
}
*to = 0;
while (*from && len > 0)
{
if (IS_LC1(*from))
{
*to = *from++ << 16;
*to |= *from++;
len -= 2;
}
else if (IS_LCPRV1(*from))
{
from++;
*to = *from++ << 16;
*to |= *from++;
len -= 3;
}
else if (IS_LC2(*from))
{
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 3;
}
else if (IS_LCPRV2(*from))
{
from++;
*to = *from++ << 16;
*to |= *from++ << 8;
*to |= *from++;
len -= 4;
}
else
{ /* assume ASCII */
*to = (unsigned char) *from++;
len--;
}
to++;
}
*to = 0;
}
int pg_mule_mblen(const unsigned char *s)
int
pg_mule_mblen(const unsigned char *s)
{
int len;
int len;
if (IS_LC1(*s)) {
len = 2;
} else if (IS_LCPRV1(*s)) {
len = 3;
} else if (IS_LC2(*s)) {
len = 3;
} else if (IS_LCPRV2(*s)) {
len = 4;
} else { /* assume ASCII */
len = 1;
}
return(len);
if (IS_LC1(*s))
len = 2;
else if (IS_LCPRV1(*s))
len = 3;
else if (IS_LC2(*s))
len = 3;
else if (IS_LCPRV2(*s))
len = 4;
else
{ /* assume ASCII */
len = 1;
}
return (len);
}
/*
* ISO8859-1
*/
static void pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
static void
pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
while (*from && len-- > 0) {
*to++ = *from++;
}
*to = 0;
while (*from && len-- > 0)
*to++ = *from++;
*to = 0;
}
static int pg_latin1_mblen(const unsigned char *s)
static int
pg_latin1_mblen(const unsigned char *s)
{
return(1);
return (1);
}
/*
* SJIS
*/
static int pg_sjis_mblen(const unsigned char *s)
static int
pg_sjis_mblen(const unsigned char *s)
{
int len;
int len;
if (*s >= 0xa1 && *s <= 0xdf) { /* 1 byte kana? */
len = 1;
} else if (*s > 0x7f) { /* kanji? */
len = 2;
} else { /* should be ASCII */
len = 1;
}
return(len);
if (*s >= 0xa1 && *s <= 0xdf)
{ /* 1 byte kana? */
len = 1;
}
else if (*s > 0x7f)
{ /* kanji? */
len = 2;
}
else
{ /* should be ASCII */
len = 1;
}
return (len);
}
pg_wchar_tbl pg_wchar_table[] = {
{pg_ascii2wchar_with_len, pg_ascii_mblen},
{pg_eucjp2wchar_with_len, pg_eucjp_mblen},
{pg_euccn2wchar_with_len, pg_euccn_mblen},
{pg_euckr2wchar_with_len, pg_euckr_mblen},
{pg_euctw2wchar_with_len, pg_euctw_mblen},
{pg_utf2wchar_with_len, pg_utf_mblen},
{pg_mule2wchar_with_len, pg_mule_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, pg_sjis_mblen}
{pg_ascii2wchar_with_len, pg_ascii_mblen},
{pg_eucjp2wchar_with_len, pg_eucjp_mblen},
{pg_euccn2wchar_with_len, pg_euccn_mblen},
{pg_euckr2wchar_with_len, pg_euckr_mblen},
{pg_euctw2wchar_with_len, pg_euctw_mblen},
{pg_utf2wchar_with_len, pg_utf_mblen},
{pg_mule2wchar_with_len, pg_mule_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{pg_latin12wchar_with_len, pg_latin1_mblen},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, pg_sjis_mblen}
};
/* returns the byte length of a word for mule internal code */
int pg_mic_mblen(const unsigned char *mbstr)
int
pg_mic_mblen(const unsigned char *mbstr)
{
return(pg_mule_mblen(mbstr));
return (pg_mule_mblen(mbstr));
}

View File

@@ -9,22 +9,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -38,11 +38,11 @@
int
pg_char_and_wchar_strcmp(s1, s2)
register const char *s1;
register const pg_wchar *s2;
register const char *s1;
register const pg_wchar *s2;
{
while ((pg_wchar)*s1 == *s2++)
while ((pg_wchar) * s1 == *s2++)
if (*s1++ == 0)
return 0;
return *(const unsigned char *)s1 - *(const pg_wchar *)(s2 - 1);
return *(const unsigned char *) s1 - *(const pg_wchar *) (s2 - 1);
}

View File

@@ -8,22 +8,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -37,16 +37,18 @@
int
pg_wchar_strncmp(s1, s2, n)
register const pg_wchar *s1, *s2;
register size_t n;
register const pg_wchar *s1,
*s2;
register size_t n;
{
if (n == 0)
return 0;
do {
do
{
if (*s1 != *s2++)
return (*(const pg_wchar *)s1 -
*(const pg_wchar *)(s2 - 1));
return (*(const pg_wchar *) s1 -
*(const pg_wchar *) (s2 - 1));
if (*s1++ == 0)
break;
} while (--n != 0);
@@ -55,17 +57,18 @@ pg_wchar_strncmp(s1, s2, n)
int
pg_char_and_wchar_strncmp(s1, s2, n)
register const char *s1;
register const pg_wchar *s2;
register size_t n;
register const char *s1;
register const pg_wchar *s2;
register size_t n;
{
if (n == 0)
return 0;
do {
if ((pg_wchar )*s1 != *s2++)
return (*(const pg_wchar *)s1 -
*(const pg_wchar *)(s2 - 1));
do
{
if ((pg_wchar) * s1 != *s2++)
return (*(const pg_wchar *) s1 -
*(const pg_wchar *) (s2 - 1));
if (*s1++ == 0)
break;
} while (--n != 0);
@@ -74,10 +77,10 @@ pg_char_and_wchar_strncmp(s1, s2, n)
size_t
pg_wchar_strlen(str)
const pg_wchar *str;
const pg_wchar *str;
{
register const pg_wchar *s;
for (s = str; *s; ++s);
return(s - str);
return (s - str);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.18 1998/09/01 03:26:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.19 1998/09/01 04:33:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,6 +106,7 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
return FALSE;
} /* GetDatabaseInfo() */
#endif
char *
@@ -268,14 +269,13 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
*/
tup_db = (Form_pg_database) GETSTRUCT(tup);
#ifdef MULTIBYTE
/* get encoding from template database.
This is the "default for default" for
create database command.
*/
if (strcmp("template1",tup_db->datname.data) == 0)
{
/*
* get encoding from template database. This is the "default
* for default" for create database command.
*/
if (strcmp("template1", tup_db->datname.data) == 0)
SetTemplateEncoding(tup_db->encoding);
}
#endif
if (strcmp(name, tup_db->datname.data) == 0)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.6 1998/08/19 02:03:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.7 1998/09/01 04:33:32 momjian Exp $
*
* DESCRIPTION
* See superuser().
@@ -31,8 +31,8 @@ superuser(void)
HeapTuple utup;
utup = SearchSysCacheTuple(USENAME,
PointerGetDatum(UserName),
0, 0, 0);
PointerGetDatum(UserName),
0, 0, 0);
Assert(utup != NULL);
return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
}

View File

@@ -4,7 +4,7 @@
*
* Conditional trace ans logging functions.
*
* Massimo Dal Zotto <dz@cs.unitn.it>
* Massimo Dal Zotto <dz@cs.unitn.it>
*
*-------------------------------------------------------------------------
*/
@@ -32,12 +32,12 @@
/*
* Global option to control the use of syslog(3) for logging:
*
* 0 stdout/stderr only
* 1 stdout/stderr + syslog
* 2 syslog only
* 0 stdout/stderr only
* 1 stdout/stderr + syslog
* 2 syslog only
*/
#define UseSyslog pg_options[OPT_SYSLOG]
#define PG_LOG_FACILITY LOG_LOCAL0
#define UseSyslog pg_options[OPT_SYSLOG]
#define PG_LOG_FACILITY LOG_LOCAL0
#define PG_LOG_IDENT "postgres"
#else
#define UseSyslog 0
@@ -56,7 +56,7 @@ static char *opt_names[] = {
"parserstats",
"plannerstats",
"executorstats",
"shortlocks", /* currently unused but needed, see lock.c */
"shortlocks", /* currently unused but needed, see lock.c */
"locks",
"userlocks",
"spinlocks",
@@ -65,59 +65,65 @@ static char *opt_names[] = {
"palloc",
"lock_debug_oidmin",
"lock_debug_relid",
"lock_read_priority", /* lock priority, see lock.c */
"deadlock_timeout", /* deadlock timeout, see proc.c */
"syslog", /* use syslog for error messages */
"hostlookup", /* enable hostname lookup in ps_status */
"showportnumber", /* show port number in ps_status */
"notifyunlock", /* enable unlock of pg_listener after notify */
"notifyhack" /* enable notify hack to remove duplicate tuples */
"lock_read_priority", /* lock priority, see lock.c */
"deadlock_timeout", /* deadlock timeout, see proc.c */
"syslog", /* use syslog for error messages */
"hostlookup", /* enable hostname lookup in ps_status */
"showportnumber", /* show port number in ps_status */
"notifyunlock", /* enable unlock of pg_listener after
* notify */
"notifyhack" /* enable notify hack to remove duplicate
* tuples */
};
/*
* Array of trace flags which can be set or reset independently.
*/
int pg_options[NUM_PG_OPTIONS] = { 0 };
int pg_options[NUM_PG_OPTIONS] = {0};
static int openlog_done = 0;
static int openlog_done = 0;
/*
* Print a timestamp and a message to stdout if the trace flag
* indexed by the flag value is set.
*/
int
tprintf(int flag, const char *fmt, ... )
tprintf(int flag, const char *fmt,...)
{
va_list ap;
char line[ELOG_MAXLEN+TIMESTAMP_SIZE+1];
char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
#ifdef USE_SYSLOG
int log_level;
int log_level;
#endif
if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0)) {
if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0))
{
/* uconditional trace or trace all option set */
} else if (pg_options[TRACE_ALL] == 0) {
if ((flag < 0) || (flag >= NUM_PG_OPTIONS) || (!pg_options[flag])) {
return 0;
}
} else if (pg_options[TRACE_ALL] < 0) {
return 0;
}
else if (pg_options[TRACE_ALL] == 0)
{
if ((flag < 0) || (flag >= NUM_PG_OPTIONS) || (!pg_options[flag]))
return 0;
}
else if (pg_options[TRACE_ALL] < 0)
return 0;
va_start(ap, fmt);
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
vsprintf(line + TIMESTAMP_SIZE, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG
log_level = ((flag == TRACE_ALL) ? LOG_INFO : LOG_DEBUG);
write_syslog(log_level, line+TIMESTAMP_SIZE);
write_syslog(log_level, line + TIMESTAMP_SIZE);
#endif
if (UseSyslog <= 1) {
if (UseSyslog <= 1)
{
puts(line);
fflush(stdout);
}
@@ -129,23 +135,24 @@ tprintf(int flag, const char *fmt, ... )
* Print a timestamp and a message to stderr.
*/
int
eprintf(const char *fmt, ... )
eprintf(const char *fmt,...)
{
va_list ap;
char line[ELOG_MAXLEN+TIMESTAMP_SIZE+1];
char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
va_start(ap, fmt);
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
vsprintf(line + TIMESTAMP_SIZE, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG
write_syslog(LOG_ERR, line+TIMESTAMP_SIZE);
write_syslog(LOG_ERR, line + TIMESTAMP_SIZE);
#endif
if (UseSyslog <= 1) {
if (UseSyslog <= 1)
{
fputs(line, stderr);
fputc('\n', stderr);
fflush(stderr);
@@ -161,14 +168,17 @@ eprintf(const char *fmt, ... )
void
write_syslog(int level, char *line)
{
if (UseSyslog >= 1) {
if (!openlog_done) {
if (UseSyslog >= 1)
{
if (!openlog_done)
{
openlog_done = 1;
openlog(PG_LOG_IDENT, LOG_PID|LOG_NDELAY, PG_LOG_FACILITY);
openlog(PG_LOG_IDENT, LOG_PID | LOG_NDELAY, PG_LOG_FACILITY);
}
syslog(level, "%s", line);
}
}
#endif
#ifdef ELOG_TIMESTAMPS
@@ -178,10 +188,11 @@ write_syslog(int level, char *line)
char *
tprintf_timestamp()
{
struct timeval tv;
struct tm *time;
time_t tm;
static char timestamp[32], pid[8];
struct timeval tv;
struct tm *time;
time_t tm;
static char timestamp[32],
pid[8];
gettimeofday(&tv, DST_NONE);
tm = tv.tv_sec;
@@ -189,29 +200,28 @@ tprintf_timestamp()
sprintf(pid, "[%d]", MyProcPid);
sprintf(timestamp, "%02d%02d%02d.%02d:%02d:%02d.%03d %7s ",
time->tm_year, time->tm_mon+1, time->tm_mday,
time->tm_year, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec,
tv.tv_usec/1000, pid);
tv.tv_usec / 1000, pid);
return timestamp;
}
#endif
int
option_flag(int flag)
{
if ((flag < 0) || (flag >= NUM_PG_OPTIONS)) {
if ((flag < 0) || (flag >= NUM_PG_OPTIONS))
return 0;
}
return pg_options[flag];
}
int
set_option_flag(int flag, int value)
{
if ((flag < 0) || (flag >= NUM_PG_OPTIONS)) {
if ((flag < 0) || (flag >= NUM_PG_OPTIONS))
return -1;
}
pg_options[flag] = value;
return value;
@@ -220,26 +230,29 @@ set_option_flag(int flag, int value)
/*
* Parse an option string like "name,name+,name-,name=value".
* Single options are delimited by ',',space,tab,newline or cr.
*/
*/
void
parse_options(char *str)
{
char *s,
*name;
int i,
len,
val,
is_comment;
char *s,
*name;
int i,
len,
val,
is_comment;
Assert((sizeof(opt_names) / sizeof(char *)) == NUM_PG_OPTIONS);
Assert((sizeof(opt_names)/sizeof(char*)) == NUM_PG_OPTIONS);
str = strdup(str);
for (s=str; *s;) {
for (s = str; *s;)
{
is_comment = 0;
name = s;
val = 1;
for (; *s; s++) {
switch (*s) {
for (; *s; s++)
{
switch (*s)
{
case '#':
is_comment = 1;
break;
@@ -265,26 +278,28 @@ parse_options(char *str)
goto setval;
}
}
setval:
for (; *s; s++) {
if (*s == ',') {
setval:
for (; *s; s++)
{
if (*s == ',')
{
*s++ = '\0';
break;
}
}
len = strlen(name);
if (len == 0) {
if (len == 0)
continue;
}
for (i=0; i<NUM_PG_OPTIONS; i++) {
if (strncmp(name, opt_names[i], len) == 0) {
for (i = 0; i < NUM_PG_OPTIONS; i++)
{
if (strncmp(name, opt_names[i], len) == 0)
{
pg_options[i] = val;
break;
}
}
if (!is_comment && (i >= NUM_PG_OPTIONS)) {
if (!is_comment && (i >= NUM_PG_OPTIONS))
fprintf(stderr, "invalid option: %s\n", name);
}
}
free(str);
}
@@ -299,20 +314,22 @@ read_pg_options(SIGNAL_ARGS)
int verbose;
char buffer[BUF_SIZE];
char c;
char *s,
*p;
char *s,
*p;
sprintf(buffer, "%s/%s", DataDir, "pg_options");
if ((fd = open(buffer, O_RDONLY)) < 0) {
if ((fd = open(buffer, O_RDONLY)) < 0)
return;
}
if ((n = read(fd, buffer, BUF_SIZE-1)) > 0) {
if ((n = read(fd, buffer, BUF_SIZE - 1)) > 0)
{
/* collpse buffer in place removing comments and spaces */
for (s=buffer,p=buffer,c='\0'; s<(buffer+n); ) {
switch (*s) {
for (s = buffer, p = buffer, c = '\0'; s < (buffer + n);)
{
switch (*s)
{
case '#':
while ((s < (buffer+n)) && (*s++ != '\n'));
while ((s < (buffer + n)) && (*s++ != '\n'));
break;
case ' ':
case '\t':
@@ -333,9 +350,8 @@ read_pg_options(SIGNAL_ARGS)
verbose = pg_options[TRACE_VERBOSE];
parse_options(buffer);
verbose |= pg_options[TRACE_VERBOSE];
if (verbose || postgres_signal_arg == SIGHUP) {
if (verbose || postgres_signal_arg == SIGHUP)
tprintf(TRACE_ALL, "read_pg_options: %s", buffer);
}
}
close(fd);
@@ -343,8 +359,8 @@ read_pg_options(SIGNAL_ARGS)
/*
* Local variables:
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.10 1998/09/01 03:27:02 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.11 1998/09/01 04:33:34 momjian Exp $
*
* NOTE
* XXX This is a preliminary implementation which lacks fail-fast
@@ -26,8 +26,7 @@
#endif
static void AllocPointerDump(AllocPointer pointer);
static int
AllocSetIterate(AllocSet set,
static int AllocSetIterate(AllocSet set,
void (*function) (AllocPointer pointer));
#undef AllocSetReset

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.9 1998/09/01 03:27:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.10 1998/09/01 04:33:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,8 +75,7 @@ MemoryContext CurrentMemoryContext = NULL;
static Pointer GlobalMemoryAlloc(GlobalMemory this, Size size);
static void GlobalMemoryFree(GlobalMemory this, Pointer pointer);
static Pointer
GlobalMemoryRealloc(GlobalMemory this, Pointer pointer,
static Pointer GlobalMemoryRealloc(GlobalMemory this, Pointer pointer,
Size size);
static char *GlobalMemoryGetName(GlobalMemory this);
static void GlobalMemoryDump(GlobalMemory this);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.7 1998/09/01 03:27:06 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.8 1998/09/01 04:33:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,7 +67,7 @@ palloc(Size size)
return malloc(size);
#else
return MemoryContextAlloc(CurrentMemoryContext, size);
#endif /* PALLOC_IS_MALLOC */
#endif /* PALLOC_IS_MALLOC */
}
void
@@ -77,7 +77,7 @@ pfree(void *pointer)
free(pointer);
#else
MemoryContextFree(CurrentMemoryContext, pointer);
#endif /* PALLOC_IS_MALLOC */
#endif /* PALLOC_IS_MALLOC */
}
/*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.13 1998/09/01 03:27:08 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.14 1998/09/01 04:33:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -285,7 +285,7 @@ PortalHeapMemoryFree(PortalHeapMemory this,
pointer);
#ifdef ALLOCFREE_ERROR_ABORT
Assert(AllocSetContains(&block->setData, pointer));
#endif /* ALLOCFREE_ERROR_ABORT */
#endif /* ALLOCFREE_ERROR_ABORT */
}
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.18 1998/09/01 03:27:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.19 1998/09/01 04:33:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,7 +32,7 @@ extern bool PostgresIsInitialized;
#ifndef GOODAMI
TransactionId HeapSpecialTransactionId = InvalidTransactionId;
CommandId HeapSpecialCommandId = FirstCommandId;
CommandId HeapSpecialCommandId = FirstCommandId;
void
setheapoverride(bool on)
@@ -40,14 +40,14 @@ setheapoverride(bool on)
if (on)
{
TransactionIdStore(GetCurrentTransactionId(),
&HeapSpecialTransactionId);
&HeapSpecialTransactionId);
HeapSpecialCommandId = GetCurrentCommandId();
}
else
HeapSpecialTransactionId = InvalidTransactionId;
}
#endif /* !defined(GOODAMI) */
#endif /* !defined(GOODAMI) */
/*
* XXX Transaction system override hacks end here
*/
@@ -196,7 +196,7 @@ HeapTupleSatisfiesNow(HeapTuple tuple)
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;
@@ -206,7 +206,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 */
}
/*