mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
OK, folks, here is the pgindent output.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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 --
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 *
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user