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

Ye-old pgindent run. Same 4-space tabs.

This commit is contained in:
Bruce Momjian
2000-04-12 17:17:23 +00:00
parent db4518729d
commit 52f77df613
434 changed files with 24799 additions and 21246 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.44 2000/01/26 05:57:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.45 2000/04/12 17:15:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -681,8 +681,8 @@ ChangeACLStmt *
makeAclStmt(char *privileges, List *rel_list, char *grantee,
char grant_or_revoke)
{
ChangeACLStmt *n = makeNode(ChangeACLStmt);
StringInfoData str;
ChangeACLStmt *n = makeNode(ChangeACLStmt);
StringInfoData str;
initStringInfo(&str);

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.34 2000/03/19 22:10:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.35 2000/04/12 17:15:48 momjian Exp $
*/
#include <limits.h>
@@ -32,6 +32,7 @@ static const char *num_word(Cash value);
#ifdef USE_LOCALE
static struct lconv *lconvert = NULL;
#endif
/* cash_in()

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.43 2000/03/14 23:06:35 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.44 2000/04/12 17:15:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,7 +22,7 @@
#include "utils/builtins.h"
static int
date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn);
date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn);
/*****************************************************************************
@@ -188,10 +188,10 @@ date_mii(DateADT dateVal, int4 days)
/* date_timestamp()
* Convert date to timestamp data type.
*/
Timestamp *
Timestamp *
date_timestamp(DateADT dateVal)
{
Timestamp *result;
Timestamp *result;
struct tm tt,
*tm = &tt;
int tz;
@@ -392,7 +392,7 @@ time_in(char *str)
elog(ERROR, "Bad (null) time external representation");
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0))
elog(ERROR, "Bad time external representation '%s'", str);
time = palloc(sizeof(*time));
@@ -492,16 +492,16 @@ time_cmp(TimeADT *time1, TimeADT *time2)
return (*time1 < *time2) ? -1 : (((*time1 > *time2) ? 1 : 0));
} /* time_cmp() */
TimeADT *
TimeADT *
time_larger(TimeADT *time1, TimeADT *time2)
{
return time_gt(time1, time2)? time1: time2;
return time_gt(time1, time2) ? time1 : time2;
} /* time_larger() */
TimeADT *
TimeADT *
time_smaller(TimeADT *time1, TimeADT *time2)
{
return time_lt(time1, time2)? time1: time2;
return time_lt(time1, time2) ? time1 : time2;
} /* time_smaller() */
/* overlaps_time()
@@ -514,19 +514,21 @@ overlaps_time(TimeADT *ts1, TimeADT *te1, TimeADT *ts2, TimeADT *te2)
/* Make sure we have ordered pairs... */
if (time_gt(ts1, te1))
{
TimeADT *tt = ts1;
TimeADT *tt = ts1;
ts1 = te1;
te1 = tt;
}
if (time_gt(ts2, te2))
{
TimeADT *tt = ts2;
TimeADT *tt = ts2;
ts2 = te2;
te2 = tt;
}
return ((time_gt(ts1, ts2) && (time_lt(ts1, te2) || time_lt(te1, te2)))
|| (time_gt(ts2, ts1) && (time_lt(ts2, te1) || time_lt(te2, te1)))
|| (time_gt(ts2, ts1) && (time_lt(ts2, te1) || time_lt(te2, te1)))
|| time_eq(ts1, ts2));
}
@@ -550,13 +552,9 @@ timestamp_time(Timestamp *timestamp)
elog(ERROR, "Unable to convert timestamp to date");
if (TIMESTAMP_IS_EPOCH(*timestamp))
{
timestamp2tm(SetTimestamp(*timestamp), NULL, tm, &fsec, NULL);
}
else if (TIMESTAMP_IS_CURRENT(*timestamp))
{
timestamp2tm(SetTimestamp(*timestamp), &tz, tm, &fsec, &tzn);
}
else
{
if (timestamp2tm(*timestamp, &tz, tm, &fsec, &tzn) != 0)
@@ -574,10 +572,10 @@ timestamp_time(Timestamp *timestamp)
/* datetime_timestamp()
* Convert date and time to timestamp data type.
*/
Timestamp *
Timestamp *
datetime_timestamp(DateADT date, TimeADT *time)
{
Timestamp *result;
Timestamp *result;
if (!PointerIsValid(time))
{
@@ -618,7 +616,7 @@ time_interval(TimeADT *time)
*****************************************************************************/
TimeTzADT *
TimeTzADT *
timetz_in(char *str)
{
TimeTzADT *time;
@@ -638,7 +636,7 @@ timetz_in(char *str)
elog(ERROR, "Bad (null) time external representation");
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
elog(ERROR, "Bad time external representation '%s'", str);
time = palloc(sizeof(*time));
@@ -738,19 +736,19 @@ timetz_ge(TimeTzADT *time1, TimeTzADT *time2)
int
timetz_cmp(TimeTzADT *time1, TimeTzADT *time2)
{
return (timetz_lt(time1, time2) ? -1 : (timetz_gt(time1, time2)? 1: 0));
return (timetz_lt(time1, time2) ? -1 : (timetz_gt(time1, time2) ? 1 : 0));
} /* timetz_cmp() */
TimeTzADT *
TimeTzADT *
timetz_larger(TimeTzADT *time1, TimeTzADT *time2)
{
return timetz_gt(time1, time2)? time1: time2;
return timetz_gt(time1, time2) ? time1 : time2;
} /* timetz_larger() */
TimeTzADT *
TimeTzADT *
timetz_smaller(TimeTzADT *time1, TimeTzADT *time2)
{
return timetz_lt(time1, time2)? time1: time2;
return timetz_lt(time1, time2) ? time1 : time2;
} /* timetz_smaller() */
/* overlaps_timetz()
@@ -763,13 +761,15 @@ overlaps_timetz(TimeTzADT *ts1, TimeTzADT *te1, TimeTzADT *ts2, TimeTzADT *te2)
/* Make sure we have ordered pairs... */
if (timetz_gt(ts1, te1))
{
TimeTzADT *tt = ts1;
TimeTzADT *tt = ts1;
ts1 = te1;
te1 = tt;
}
if (timetz_gt(ts2, te2))
{
TimeTzADT *tt = ts2;
TimeTzADT *tt = ts2;
ts2 = te2;
te2 = tt;
}
@@ -782,10 +782,10 @@ overlaps_timetz(TimeTzADT *ts1, TimeTzADT *te1, TimeTzADT *ts2, TimeTzADT *te2)
/* timestamp_timetz()
* Convert timestamp to timetz data type.
*/
TimeTzADT *
TimeTzADT *
timestamp_timetz(Timestamp *timestamp)
{
TimeTzADT *result;
TimeTzADT *result;
struct tm tt,
*tm = &tt;
int tz;
@@ -804,9 +804,7 @@ timestamp_timetz(Timestamp *timestamp)
tz = 0;
}
else if (TIMESTAMP_IS_CURRENT(*timestamp))
{
timestamp2tm(SetTimestamp(*timestamp), &tz, tm, &fsec, &tzn);
}
else
{
if (timestamp2tm(*timestamp, &tz, tm, &fsec, &tzn) != 0)
@@ -828,7 +826,7 @@ timestamp_timetz(Timestamp *timestamp)
* stored with the timetz to the result.
* - thomas 2000-03-10
*/
Timestamp *
Timestamp *
datetimetz_timestamp(DateADT date, TimeTzADT *time)
{
Timestamp *result;
@@ -841,9 +839,7 @@ datetimetz_timestamp(DateADT date, TimeTzADT *time)
result = palloc(sizeof(*result));
if (!PointerIsValid(date) || !PointerIsValid(time))
{
TIMESTAMP_INVALID(*result);
}
else
{
if (date2tm(date, &tz, tm, &fsec, &tzn) != 0)
@@ -857,5 +853,3 @@ datetimetz_timestamp(DateADT date, TimeTzADT *time)
return result;
} /* datetimetz_timestamp() */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.45 2000/03/29 03:57:18 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.46 2000/04/12 17:15:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,7 +35,7 @@
#define USE_DATE_CACHE 1
#define ROUND_ALL 0
static int DecodePosixTimezone(char *str, int *val);
static int DecodePosixTimezone(char *str, int *val);
int day_tab[2][13] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
@@ -457,23 +457,24 @@ ParseDateTime(char *timestr, char *lowstr,
while (isalpha(*cp))
*lp++ = tolower(*cp++);
/* Full date string with leading text month?
* Could also be a POSIX time zone...
/*
* Full date string with leading text month? Could also be a
* POSIX time zone...
*/
if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
{
#if 0
/*
* special case of Posix timezone "GMT-0800"
* Note that other sign (e.g. "GMT+0800"
* is recognized as two separate fields and handled later.
* XXX There is no room for a delimiter between
* the "GMT" and the "-0800", so we are going to just swallow the "GMT".
* But this leads to other troubles with the definition of signs,
* so we have to flip
* - thomas 2000-02-06
* special case of Posix timezone "GMT-0800" Note that
* other sign (e.g. "GMT+0800" is recognized as two
* separate fields and handled later. XXX There is no room
* for a delimiter between the "GMT" and the "-0800", so
* we are going to just swallow the "GMT". But this leads
* to other troubles with the definition of signs, so we
* have to flip - thomas 2000-02-06
*/
if ((*cp == '-') && isdigit(*(cp+1))
if ((*cp == '-') && isdigit(*(cp + 1))
&& (strncmp(field[nf], "gmt", 3) == 0))
{
*cp = '+';
@@ -586,7 +587,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm->tm_min = 0;
tm->tm_sec = 0;
*fsec = 0;
tm->tm_isdst = -1; /* don't know daylight savings time status apriori */
tm->tm_isdst = -1; /* don't know daylight savings time status
* apriori */
if (tzp != NULL)
*tzp = 0;
@@ -595,10 +597,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
switch (ftype[i])
{
case DTK_DATE:
/* Already have a date?
* Then this might be a POSIX time zone
* with an embedded dash (e.g. "PST-3" == "EST")
* - thomas 2000-03-15
/*
* Already have a date? Then this might be a POSIX time
* zone with an embedded dash (e.g. "PST-3" == "EST") -
* thomas 2000-03-15
*/
if ((fmask & DTK_DATE_M) == DTK_DATE_M)
{
@@ -630,17 +633,18 @@ DecodeDateTime(char **field, int *ftype, int nf,
return -1;
{
int tz;
int tz;
if (DecodeTimezone(field[i], &tz) != 0)
return -1;
/* Already have a time zone?
* Then maybe this is the second field of a POSIX time:
* EST+3 (equivalent to PST)
/*
* Already have a time zone? Then maybe this is the
* second field of a POSIX time: EST+3 (equivalent to
* PST)
*/
if ((i > 0) && ((fmask & DTK_M(TZ)) != 0)
&& (ftype[i-1] == DTK_TZ) && (isalpha(*field[i-1])))
&& (ftype[i - 1] == DTK_TZ) && (isalpha(*field[i - 1])))
{
*tzp -= tz;
tmask = 0;
@@ -742,6 +746,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
break;
case MONTH:
/*
* already have a (numeric) month? then see if we
* can substitute...
@@ -881,7 +886,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm->tm_mon += 1;
#if defined(HAVE_TM_ZONE)
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
*tzp = -(tm->tm_gmtoff); /* tm_gmtoff is
* Sun/DEC-ism */
#elif defined(HAVE_INT_TIMEZONE)
#ifdef __CYGWIN__
*tzp = ((tm->tm_isdst > 0) ? (_timezone - 3600) : _timezone);
@@ -937,7 +943,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm->tm_min = 0;
tm->tm_sec = 0;
*fsec = 0;
tm->tm_isdst = -1; /* don't know daylight savings time status apriori */
tm->tm_isdst = -1; /* don't know daylight savings time status
* apriori */
if (tzp != NULL)
*tzp = 0;
@@ -948,9 +955,10 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
switch (ftype[i])
{
case DTK_DATE:
/* This might be a POSIX time zone
* with an embedded dash (e.g. "PST-3" == "EST")
* - thomas 2000-03-15
/*
* This might be a POSIX time zone with an embedded dash
* (e.g. "PST-3" == "EST") - thomas 2000-03-15
*/
if ((tzp == NULL)
|| (DecodePosixTimezone(field[i], tzp) != 0))
@@ -970,17 +978,18 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
return -1;
{
int tz;
int tz;
if (DecodeTimezone(field[i], &tz) != 0)
return -1;
/* Already have a time zone?
* Then maybe this is the second field of a POSIX time:
* EST+3 (equivalent to PST)
/*
* Already have a time zone? Then maybe this is the
* second field of a POSIX time: EST+3 (equivalent to
* PST)
*/
if ((i > 0) && ((fmask & DTK_M(TZ)) != 0)
&& (ftype[i-1] == DTK_TZ) && (isalpha(*field[i-1])))
&& (ftype[i - 1] == DTK_TZ) && (isalpha(*field[i - 1])))
{
*tzp -= tz;
tmask = 0;
@@ -1107,11 +1116,12 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
/* timezone not specified? then find local timezone if possible */
if ((tzp != NULL) && (!(fmask & DTK_M(TZ))))
{
struct tm tt, *tmp = &tt;
struct tm tt,
*tmp = &tt;
/*
* daylight savings time modifier but no standard timezone?
* then error
* daylight savings time modifier but no standard timezone? then
* error
*/
if (fmask & DTK_M(DTZMOD))
return -1;
@@ -1127,7 +1137,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm->tm_isdst = tmp->tm_isdst;
#if defined(HAVE_TM_ZONE)
*tzp = -(tmp->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
*tzp = -(tmp->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */
#elif defined(HAVE_INT_TIMEZONE)
#ifdef __CYGWIN__
*tzp = ((tmp->tm_isdst > 0) ? (_timezone - 3600) : _timezone);
@@ -1366,10 +1376,8 @@ DecodeNumber(int flen, char *str, int fmask,
* Enough digits to be unequivocal year? Used to test for 4 digits or
* more, but we now test first for a three-digit doy so anything
* bigger than two digits had better be an explicit year. - thomas
* 1999-01-09
* Back to requiring a 4 digit year.
* We accept a two digit year farther down.
* - thomas 2000-03-28
* 1999-01-09 Back to requiring a 4 digit year. We accept a two digit
* year farther down. - thomas 2000-03-28
*/
else if (flen >= 4)
{
@@ -1414,8 +1422,10 @@ DecodeNumber(int flen, char *str, int fmask,
*tmask = DTK_M(DAY);
tm->tm_mday = val;
}
/* Check for 2 or 4 or more digits, but currently we reach here
* only if two digits. - thomas 2000-03-28
/*
* Check for 2 or 4 or more digits, but currently we reach here only
* if two digits. - thomas 2000-03-28
*/
else if (!(fmask & DTK_M(YEAR))
&& ((flen >= 4) || (flen == 2)))
@@ -1550,14 +1560,15 @@ DecodeTimezone(char *str, int *tzp)
/* DecodePosixTimezone()
* Interpret string as a POSIX-compatible timezone:
* PST-hh:mm
* PST+h
* PST-hh:mm
* PST+h
* - thomas 2000-03-15
*/
static int
DecodePosixTimezone(char *str, int *tzp)
{
int val, tz;
int val,
tz;
int type;
char *cp;
char delim;
@@ -1571,10 +1582,10 @@ DecodePosixTimezone(char *str, int *tzp)
delim = *cp;
*cp = '\0';
type = DecodeSpecial(MAXDATEFIELDS-1, str, &val);
type = DecodeSpecial(MAXDATEFIELDS - 1, str, &val);
*cp = delim;
switch(type)
switch (type)
{
case DTZ:
case TZ:
@@ -1898,7 +1909,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
* Binary search -- from Knuth (6.2.1) Algorithm B. Special case like this
* is WAY faster than the generic bsearch().
*/
datetkn *
datetkn *
datebsearch(char *key, datetkn *base, unsigned int nel)
{
datetkn *last = base + nel - 1,
@@ -2002,7 +2013,8 @@ EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str)
if (tzp != NULL)
{
int hour, min;
int hour,
min;
hour = -(*tzp / 3600);
min = ((abs(*tzp) / 60) % 60);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.56 2000/04/07 13:39:40 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.57 2000/04/12 17:15:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1159,8 +1159,9 @@ dpow(float64 arg1, float64 arg2)
tmp1 = *arg1;
tmp2 = *arg2;
/* We must check both for errno getting set and for a NaN result,
* in order to deal with the vagaries of different platforms...
/*
* We must check both for errno getting set and for a NaN result, in
* order to deal with the vagaries of different platforms...
*/
errno = 0;
*result = (float64data) pow(tmp1, tmp2);
@@ -1192,9 +1193,10 @@ dexp(float64 arg1)
tmp = *arg1;
/* We must check both for errno getting set and for a NaN result,
* in order to deal with the vagaries of different platforms.
* Also, a zero result implies unreported underflow.
/*
* We must check both for errno getting set and for a NaN result, in
* order to deal with the vagaries of different platforms. Also, a
* zero result implies unreported underflow.
*/
errno = 0;
*result = (float64data) exp(tmp);
@@ -1234,7 +1236,7 @@ dlog1(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dlog1() */
} /* dlog1() */
/*
@@ -1260,7 +1262,7 @@ dlog10(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dlog10() */
} /* dlog10() */
/*
@@ -1289,7 +1291,7 @@ dacos(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dacos() */
} /* dacos() */
/*
@@ -1318,7 +1320,7 @@ dasin(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dasin() */
} /* dasin() */
/*
@@ -1347,7 +1349,7 @@ datan(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* datan() */
} /* datan() */
/*
@@ -1374,7 +1376,7 @@ datan2(float64 arg1, float64 arg2)
CheckFloat8Val(*result);
return result;
} /* datan2() */
} /* datan2() */
/*
@@ -1403,7 +1405,7 @@ dcos(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dcos() */
} /* dcos() */
/*
@@ -1430,10 +1432,10 @@ dcot(float64 arg1)
)
elog(ERROR, "dcot(%f) input is out of range", *arg1);
*result = 1.0/(*result);
*result = 1.0 / (*result);
CheckFloat8Val(*result);
return result;
} /* dcot() */
} /* dcot() */
/*
@@ -1462,7 +1464,7 @@ dsin(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dsin() */
} /* dsin() */
/*
@@ -1491,7 +1493,7 @@ dtan(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* dtan() */
} /* dtan() */
#ifndef M_PI
@@ -1517,7 +1519,7 @@ degrees(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* degrees() */
} /* degrees() */
/*
@@ -1533,7 +1535,7 @@ dpi(void)
*result = (M_PI);
return result;
} /* dpi() */
} /* dpi() */
/*
@@ -1553,11 +1555,11 @@ radians(float64 arg1)
CheckFloat8Val(*result);
return result;
} /* radians() */
} /* radians() */
/*
* drandom - returns a random number
* drandom - returns a random number
*/
float64
drandom(void)
@@ -1571,7 +1573,7 @@ drandom(void)
CheckFloat8Val(*result);
return result;
} /* drandom() */
} /* drandom() */
/*
@@ -1580,12 +1582,12 @@ drandom(void)
int32
setseed(float64 seed)
{
int iseed = ((*seed) * RAND_MAX);
int iseed = ((*seed) * RAND_MAX);
srandom((unsigned int) ((*seed) * RAND_MAX));
return iseed;
} /* setseed() */
} /* setseed() */
/*

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.49 2000/03/14 23:06:36 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.50 2000/04/12 17:15:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -877,7 +877,7 @@ line_construct_pm(Point *pt, double m)
/* use "mx - y + yinter = 0" */
result->A = m;
result->B = -1.0;
if (m==DBL_MAX)
if (m == DBL_MAX)
result->C = pt->y;
else
result->C = pt->y - m * pt->x;

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.13 2000/02/17 03:39:42 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.14 2000/04/12 17:15:50 momjian Exp $
*
* XXX These are totally bogus. Perhaps someone will make them do
* something reasonable, someday.
@@ -34,7 +34,7 @@
* In general, rtrees need to search multiple subtrees in order to guarantee
* that all occurrences of the same key have been found. Because of this,
* the estimated cost for scanning the index ought to be higher than the
* output selectivity would indicate. rtcostestimate(), over in selfuncs.c,
* output selectivity would indicate. rtcostestimate(), over in selfuncs.c,
* ought to be adjusted accordingly --- but until we can generate somewhat
* realistic numbers here, it hardly matters...
*/

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.35 2000/03/14 23:06:36 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.36 2000/04/12 17:15:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -88,7 +88,7 @@ int2vectorin(char *intString)
result = (int16 *) palloc(sizeof(int16[INDEX_MAX_KEYS]));
for (slot=0; *intString && slot < INDEX_MAX_KEYS; slot++)
for (slot = 0; *intString && slot < INDEX_MAX_KEYS; slot++)
{
if (sscanf(intString, "%hd", &result[slot]) != 1)
break;
@@ -100,7 +100,7 @@ int2vectorin(char *intString)
while (*intString && isspace(*intString))
intString++;
if (*intString)
elog(ERROR,"int2vector value has too many values");
elog(ERROR, "int2vector value has too many values");
while (slot < INDEX_MAX_KEYS)
result[slot++] = 0;
@@ -113,7 +113,8 @@ int2vectorin(char *intString)
char *
int2vectorout(int16 *int2Array)
{
int num, maxnum;
int num,
maxnum;
char *rp;
char *result;
@@ -126,12 +127,12 @@ int2vectorout(int16 *int2Array)
}
/* find last non-zero value in vector */
for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
for (maxnum = INDEX_MAX_KEYS - 1; maxnum >= 0; maxnum--)
if (int2Array[maxnum] != 0)
break;
/* assumes sign, 5 digits, ' ' */
rp = result = (char *) palloc((maxnum+1) * 7 + 1);
rp = result = (char *) palloc((maxnum + 1) * 7 + 1);
for (num = 0; num <= maxnum; num++)
{
if (num != 0)
@@ -694,13 +695,13 @@ int2fac(int16 arg1)
int32
int4abs(int32 arg1)
{
return ((arg1 < 0)? -arg1: arg1);
return ((arg1 < 0) ? -arg1 : arg1);
}
int16
int2abs(int16 arg1)
{
return ((arg1 < 0)? -arg1: arg1);
return ((arg1 < 0) ? -arg1 : arg1);
}
int16

View File

@@ -71,10 +71,10 @@ int8in(char *str)
elog(ERROR, "Bad int8 external representation \"%s\"", str);
while (*ptr && isdigit(*ptr)) /* process digits */
{
int64 newtmp = tmp * 10 + (*ptr++ - '0');
int64 newtmp = tmp * 10 + (*ptr++ - '0');
if ((newtmp / 10) != tmp) /* overflow? */
elog(ERROR,"int8 value out of range: \"%s\"", str);
elog(ERROR, "int8 value out of range: \"%s\"", str);
tmp = newtmp;
}
if (*ptr) /* trailing junk? */
@@ -372,7 +372,7 @@ int8abs(int64 *arg1)
result = palloc(sizeof(*result));
*result = ((*arg1 < 0)? -*arg1: *arg1);
*result = ((*arg1 < 0) ? -*arg1 : *arg1);
return result;
}
@@ -400,7 +400,7 @@ int64 *
int8fac(int64 *arg1)
{
int64 *result;
int64 i;
int64 i;
if (!PointerIsValid(arg1))
return NULL;
@@ -581,7 +581,7 @@ int84(int64 *val)
#if NOT_USED
int64 *
int2vector (int16 val)
int2vector (int16 val)
{
int64 *result;

View File

@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.33 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.34 2000/04/12 17:15:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -149,7 +149,7 @@ textnlike(struct varlena * s, struct varlena * p)
static int
DoMatch(pg_wchar * text, pg_wchar * p)
{
for (; *p && *text; text++, p++)
for (; *p && *text; text ++, p++)
{
switch (*p)
{
@@ -158,7 +158,7 @@ DoMatch(pg_wchar * text, pg_wchar * p)
p++;
/* FALLTHROUGH */
default:
if (*text != *p)
if (*text !=*p)
return LIKE_FALSE;
break;
case '_':
@@ -172,29 +172,37 @@ DoMatch(pg_wchar * text, pg_wchar * p)
/* Trailing percent matches everything. */
if (*p == '\0')
return LIKE_TRUE;
/* Otherwise, scan for a text position at which we
* can match the rest of the pattern.
/*
* Otherwise, scan for a text position at which we can
* match the rest of the pattern.
*/
for (; *text; text++)
for (; *text; text ++)
{
/* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
/*
* Optimization to prevent most recursion: don't
* recurse unless first pattern char might match this
* text char.
*/
if (*text == *p || *p == '\\' || *p == '_')
{
int matched = DoMatch(text, p);
int matched = DoMatch(text, p);
if (matched != LIKE_FALSE)
return matched; /* TRUE or ABORT */
return matched; /* TRUE or ABORT */
}
}
/* End of text with no match, so no point in trying later
/*
* End of text with no match, so no point in trying later
* places to start matching this pattern.
*/
return LIKE_ABORT;
}
}
if (*text != '\0')
if (*text !='\0')
return LIKE_FALSE; /* end of pattern, but not of text */
/* End of input string. Do we have matching pattern remaining? */
@@ -202,8 +210,10 @@ DoMatch(pg_wchar * text, pg_wchar * p)
p++;
if (*p == '\0')
return LIKE_TRUE;
/* End of text with no match, so no point in trying later
* places to start matching this pattern.
/*
* End of text with no match, so no point in trying later places to
* start matching this pattern.
*/
return LIKE_ABORT;
}

View File

@@ -1,7 +1,7 @@
/* ----------
* lztext.c -
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.5 1999/12/28 13:40:48 wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.6 2000/04/12 17:15:50 momjian Exp $
*
* Text type with internal LZ compressed representation. Uses the
* standard PostgreSQL compression method.
@@ -34,10 +34,10 @@
lztext *
lztextin(char *str)
{
lztext *result;
int32 rawsize;
lztext *tmp;
int tmp_size;
lztext *result;
int32 rawsize;
lztext *tmp;
int tmp_size;
/* ----------
* Handle NULL
@@ -66,11 +66,11 @@ lztextin(char *str)
* sequence.
* ----------
*/
if (tmp_size - tmp->varsize < 256 ||
tmp_size - tmp->varsize < tmp_size / 4)
{
if (tmp_size - tmp->varsize < 256 ||
tmp_size - tmp->varsize < tmp_size / 4)
result = tmp;
} else {
else
{
result = (lztext *) palloc(tmp->varsize);
memcpy(result, tmp, tmp->varsize);
pfree(tmp);
@@ -89,7 +89,7 @@ lztextin(char *str)
char *
lztextout(lztext *lz)
{
char *result;
char *result;
/* ----------
* Handle NULL
@@ -137,10 +137,12 @@ int32
lztextlen(lztext *lz)
{
#ifdef MULTIBYTE
unsigned char *s1,*s2;
int len;
int l;
int wl;
unsigned char *s1,
*s2;
int len;
int l;
int wl;
#endif
/* ----------
* Handle NULL
@@ -151,7 +153,7 @@ lztextlen(lztext *lz)
#ifdef MULTIBYTE
len = 0;
s1 = s2 = (unsigned char *)lztextout(lz);
s1 = s2 = (unsigned char *) lztextout(lz);
l = PGLZ_RAW_SIZE(lz);
while (l > 0)
{
@@ -160,7 +162,7 @@ lztextlen(lztext *lz)
s1 += wl;
len++;
}
pfree((char *)s2);
pfree((char *) s2);
return (len);
#else
/* ----------
@@ -206,11 +208,11 @@ lztextoctetlen(lztext *lz)
lztext *
text_lztext(text *txt)
{
lztext *result;
int32 rawsize;
lztext *tmp;
int tmp_size;
char *str;
lztext *result;
int32 rawsize;
lztext *tmp;
int tmp_size;
char *str;
/* ----------
* Handle NULL
@@ -223,8 +225,8 @@ text_lztext(text *txt)
* Determine input size and eventually tuple size
* ----------
*/
rawsize = VARSIZE(txt) - VARHDRSZ;
str = VARDATA(txt);
rawsize = VARSIZE(txt) - VARHDRSZ;
str = VARDATA(txt);
tmp_size = PGLZ_MAX_OUTPUT(rawsize);
/* ----------
@@ -240,11 +242,11 @@ text_lztext(text *txt)
* sequence.
* ----------
*/
if (tmp_size - tmp->varsize < 256 ||
tmp_size - tmp->varsize < tmp_size / 4)
{
if (tmp_size - tmp->varsize < 256 ||
tmp_size - tmp->varsize < tmp_size / 4)
result = tmp;
} else {
else
{
result = (lztext *) palloc(tmp->varsize);
memcpy(result, tmp, tmp->varsize);
pfree(tmp);
@@ -303,12 +305,12 @@ lztext_cmp(lztext *lz1, lztext *lz2)
{
#ifdef USE_LOCALE
char *cp1;
char *cp2;
int result;
char *cp1;
char *cp2;
int result;
if (lz1 == NULL || lz2 == NULL)
return (int32)0;
return (int32) 0;
cp1 = lztextout(lz1);
cp2 = lztextout(lz2);
@@ -320,21 +322,21 @@ lztext_cmp(lztext *lz1, lztext *lz2)
return result;
#else /* !USE_LOCALE */
#else /* !USE_LOCALE */
PGLZ_DecompState ds1;
PGLZ_DecompState ds2;
int c1;
int c2;
int32 result = (int32)0;
PGLZ_DecompState ds1;
PGLZ_DecompState ds2;
int c1;
int c2;
int32 result = (int32) 0;
if (lz1 == NULL || lz2 == NULL)
return (int32)0;
return (int32) 0;
pglz_decomp_init(&ds1, lz1);
pglz_decomp_init(&ds2, lz2);
for(;;)
for (;;)
{
c1 = pglz_decomp_getchar(&ds1);
c2 = pglz_decomp_getchar(&ds2);
@@ -342,17 +344,17 @@ lztext_cmp(lztext *lz1, lztext *lz2)
if (c1 == EOF)
{
if (c2 != EOF)
result = (int32)-1;
result = (int32) -1;
break;
} else {
}
else
{
if (c2 == EOF)
{
result = (int32)1;
}
result = (int32) 1;
}
if (c1 != c2)
{
result = (int32)(c1 - c2);
result = (int32) (c1 - c2);
break;
}
}
@@ -362,7 +364,7 @@ lztext_cmp(lztext *lz1, lztext *lz2)
return result;
#endif /* USE_LOCALE */
#endif /* USE_LOCALE */
}
@@ -379,7 +381,7 @@ lztext_eq(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) == 0);
return (bool) (lztext_cmp(lz1, lz2) == 0);
}
@@ -389,7 +391,7 @@ lztext_ne(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) != 0);
return (bool) (lztext_cmp(lz1, lz2) != 0);
}
@@ -399,7 +401,7 @@ lztext_gt(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) > 0);
return (bool) (lztext_cmp(lz1, lz2) > 0);
}
@@ -409,7 +411,7 @@ lztext_ge(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) >= 0);
return (bool) (lztext_cmp(lz1, lz2) >= 0);
}
@@ -419,7 +421,7 @@ lztext_lt(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) < 0);
return (bool) (lztext_cmp(lz1, lz2) < 0);
}
@@ -429,7 +431,5 @@ lztext_le(lztext *lz1, lztext *lz2)
if (lz1 == NULL || lz2 == NULL)
return false;
return (bool)(lztext_cmp(lz1, lz2) <= 0);
return (bool) (lztext_cmp(lz1, lz2) <= 0);
}

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.66 2000/02/16 17:24:48 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.67 2000/04/12 17:15:50 momjian Exp $
*
* NOTES
*
@@ -47,6 +47,7 @@
#if 0
static AbsoluteTime tm2abstime(struct tm * tm, int tz);
#endif
@@ -101,6 +102,7 @@ static int sec_tab[] = {
1, 1, 60, 60,
3600, 3600, 86400, 86400, 604800, 604800,
2592000, 2592000, 31536000, 31536000};
#endif
/*
@@ -246,8 +248,11 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
/* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
if (tzn != NULL)
{
/* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
contains an error message, which doesn't fit in the buffer */
/*
* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
* contains an error message, which doesn't fit in the buffer
*/
strncpy(tzn, tm->tm_zone, MAXTZLEN);
if (strlen(tm->tm_zone) > MAXTZLEN)
{
@@ -264,8 +269,11 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn)
#endif
if (tzn != NULL)
{
/* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
contains an error message, which doesn't fit in the buffer */
/*
* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
* contains an error message, which doesn't fit in the buffer
*/
strncpy(tzn, tzname[tm->tm_isdst], MAXTZLEN);
if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
{
@@ -634,10 +642,10 @@ timestamp_abstime(Timestamp *timestamp)
/* abstime_timestamp()
* Convert abstime to timestamp.
*/
Timestamp *
Timestamp *
abstime_timestamp(AbsoluteTime abstime)
{
Timestamp *result;
Timestamp *result;
if (!PointerIsValid(result = palloc(sizeof(Timestamp))))
elog(ERROR, "Unable to allocate space to convert abstime to timestamp");

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.27 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.28 2000/04/12 17:15:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -149,7 +149,8 @@ namecpy(Name n1, Name n2)
int
namecat(Name n1, Name n2)
{
return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer than n1 */
return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer
* than n1 */
}
#endif

View File

@@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
* $Id: network.c,v 1.20 2000/03/08 01:44:37 momjian Exp $
* $Id: network.c,v 1.21 2000/04/12 17:15:50 momjian Exp $
* Jon Postel RIP 16 Oct 1998
*/
@@ -448,8 +448,8 @@ network_netmask(inet *ip)
if (ip_family(ip) == AF_INET)
{
/* It's an IP V4 address: */
int addr = htonl(ip_bits(ip) ?
(-1 << (32 - ip_bits(ip))) & 0xffffffff : 0x00000000);
int addr = htonl(ip_bits(ip) ?
(-1 << (32 - ip_bits(ip))) & 0xffffffff : 0x00000000);
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
elog(ERROR, "unable to print netmask (%s)", strerror(errno));

View File

@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.26 2000/03/13 02:31:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.27 2000/04/12 17:15:50 momjian Exp $
*
* ----------
*/
@@ -59,8 +59,8 @@
* *after* the decimal point. Scales are always >= 0.)
*
* buf points at the physical start of the palloc'd digit buffer for the
* NumericVar. digits points at the first digit in actual use (the one
* with the specified weight). We normally leave an unused byte or two
* NumericVar. digits points at the first digit in actual use (the one
* with the specified weight). We normally leave an unused byte or two
* (preset to zeroes) between buf and digits, so that there is room to store
* a carry out of the top digit without special pushups. We just need to
* decrement digits (and increment weight) to make room for the carry digit.
@@ -77,11 +77,13 @@ typedef unsigned char NumericDigit;
typedef struct NumericVar
{
int ndigits; /* number of digits in digits[] - can be 0! */
int ndigits; /* number of digits in digits[] - can be
* 0! */
int weight; /* weight of first digit */
int rscale; /* result scale */
int dscale; /* display scale */
int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
int sign; /* NUMERIC_POS, NUMERIC_NEG, or
* NUMERIC_NAN */
NumericDigit *buf; /* start of palloc'd space for digits[] */
NumericDigit *digits; /* decimal digits */
} NumericVar;
@@ -122,13 +124,14 @@ static NumericVar const_nan =
#ifdef NUMERIC_DEBUG
static void dump_numeric(char *str, Numeric num);
static void dump_var(char *str, NumericVar *var);
#else
#define dump_numeric(s,n)
#define dump_var(s,v)
#endif
#define digitbuf_alloc(size) ((NumericDigit *) palloc(size))
#define digitbuf_free(buf) \
#define digitbuf_free(buf) \
do { \
if ((buf) != NULL) \
pfree(buf); \
@@ -535,16 +538,16 @@ numeric_round(Numeric num, int32 scale)
if (i < arg.ndigits)
{
/* If i = 0, the value loses all digits, but could round up if its
* first digit is more than 4. If i < 0 the result must be 0.
/*
* If i = 0, the value loses all digits, but could round up if its
* first digit is more than 4. If i < 0 the result must be 0.
*/
if (i < 0)
{
arg.ndigits = 0;
}
else
{
int carry = (arg.digits[i] > 4) ? 1 : 0;
int carry = (arg.digits[i] > 4) ? 1 : 0;
arg.ndigits = i;
@@ -557,7 +560,7 @@ numeric_round(Numeric num, int32 scale)
if (i < 0)
{
Assert(i == -1); /* better not have added more than 1 digit */
Assert(i == -1);/* better not have added more than 1 digit */
Assert(arg.digits > arg.buf);
arg.digits--;
arg.ndigits++;
@@ -728,10 +731,10 @@ numeric_cmp(Numeric num1, Numeric num2)
NumericVar arg2;
if (num1 == NULL || num2 == NULL)
return (int32)0;
return (int32) 0;
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
return (int32)0;
return (int32) 0;
init_var(&arg1);
init_var(&arg2);
@@ -744,7 +747,7 @@ numeric_cmp(Numeric num1, Numeric num2)
free_var(&arg1);
free_var(&arg2);
return (int32)((result == 0) ? 0 : ((result < 0) ? -1 : 1));
return (int32) ((result == 0) ? 0 : ((result < 0) ? -1 : 1));
}
@@ -1742,7 +1745,7 @@ numeric_int4(Numeric num)
init_var(&x);
set_var_from_num(num, &x);
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
free_var(&x);
@@ -1793,7 +1796,7 @@ numeric_int8(Numeric num)
init_var(&x);
set_var_from_num(num, &x);
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
free_var(&x);
@@ -1844,7 +1847,7 @@ numeric_int2(Numeric num)
init_var(&x);
set_var_from_num(num, &x);
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
str = get_str_from_var(&x, 0); /* dscale = 0 produces rounding */
free_var(&x);
@@ -2130,7 +2133,7 @@ set_var_from_str(char *str, NumericVar *dest)
cp++;
}
if (! isdigit(*cp))
if (!isdigit(*cp))
elog(ERROR, "Bad numeric input format '%s'", str);
while (*cp)
@@ -2158,8 +2161,8 @@ set_var_from_str(char *str, NumericVar *dest)
/* Handle exponent, if any */
if (*cp == 'e' || *cp == 'E')
{
long exponent;
char *endptr;
long exponent;
char *endptr;
cp++;
exponent = strtol(cp, &endptr, 10);
@@ -2210,7 +2213,8 @@ set_var_from_num(Numeric num, NumericVar *dest)
int i;
int n;
n = num->varlen - NUMERIC_HDRSZ; /* number of digit-pairs in packed fmt */
n = num->varlen - NUMERIC_HDRSZ; /* number of digit-pairs in packed
* fmt */
alloc_var(dest, n * 2);
@@ -2224,6 +2228,7 @@ set_var_from_num(Numeric num, NumericVar *dest)
for (i = 0; i < n; i++)
{
unsigned char digitpair = num->n_data[i];
*digit++ = (digitpair >> 4) & 0x0f;
*digit++ = digitpair & 0x0f;
}
@@ -2278,7 +2283,7 @@ get_str_from_var(NumericVar *var, int dscale)
i = dscale + var->weight + 1;
if (i >= 0 && var->ndigits > i)
{
int carry = (var->digits[i] > 4) ? 1 : 0;
int carry = (var->digits[i] > 4) ? 1 : 0;
var->ndigits = i;
@@ -2421,6 +2426,7 @@ make_result(NumericVar *var)
while (j < n)
{
unsigned char digitpair = digit[j++] << 4;
if (j < n)
digitpair |= digit[j++];
result->n_data[i++] = digitpair;
@@ -2459,7 +2465,7 @@ apply_typmod(NumericVar *var, int32 typmod)
i = scale + var->weight + 1;
if (i >= 0 && var->ndigits > i)
{
int carry = (var->digits[i] > 4) ? 1 : 0;
int carry = (var->digits[i] > 4) ? 1 : 0;
var->ndigits = i;
@@ -2494,7 +2500,7 @@ apply_typmod(NumericVar *var, int32 typmod)
if (var->weight >= maxweight)
{
/* Determine true weight; and check for all-zero result */
int tweight = var->weight;
int tweight = var->weight;
for (i = 0; i < var->ndigits; i++)
{
@@ -2502,10 +2508,10 @@ apply_typmod(NumericVar *var, int32 typmod)
break;
tweight--;
}
if (tweight >= maxweight && i < var->ndigits)
elog(ERROR, "overflow on numeric "
"ABS(value) >= 10^%d for field with precision %d scale %d",
"ABS(value) >= 10^%d for field with precision %d scale %d",
tweight, precision, scale);
}
@@ -2588,20 +2594,20 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
switch (cmp_abs(var1, var2))
{
case 0: /* ----------
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
zero_var(result);
result->rscale = MAX(var1->rscale, var2->rscale);
result->dscale = MAX(var1->dscale, var2->dscale);
break;
case 1: /* ----------
* ABS(var1) > ABS(var2)
* result = +(ABS(var1) - ABS(var2))
* ----------
*/
* ABS(var1) > ABS(var2)
* result = +(ABS(var1) - ABS(var2))
* ----------
*/
sub_abs(var1, var2, result);
result->sign = NUMERIC_POS;
break;
@@ -2629,20 +2635,20 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
switch (cmp_abs(var1, var2))
{
case 0: /* ----------
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
zero_var(result);
result->rscale = MAX(var1->rscale, var2->rscale);
result->dscale = MAX(var1->dscale, var2->dscale);
break;
case 1: /* ----------
* ABS(var1) > ABS(var2)
* result = -(ABS(var1) - ABS(var2))
* ----------
*/
* ABS(var1) > ABS(var2)
* result = -(ABS(var1) - ABS(var2))
* ----------
*/
sub_abs(var1, var2, result);
result->sign = NUMERIC_NEG;
break;
@@ -2707,20 +2713,20 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
switch (cmp_abs(var1, var2))
{
case 0: /* ----------
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
zero_var(result);
result->rscale = MAX(var1->rscale, var2->rscale);
result->dscale = MAX(var1->dscale, var2->dscale);
break;
case 1: /* ----------
* ABS(var1) > ABS(var2)
* result = +(ABS(var1) - ABS(var2))
* ----------
*/
* ABS(var1) > ABS(var2)
* result = +(ABS(var1) - ABS(var2))
* ----------
*/
sub_abs(var1, var2, result);
result->sign = NUMERIC_POS;
break;
@@ -2748,20 +2754,20 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
switch (cmp_abs(var1, var2))
{
case 0: /* ----------
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
* ABS(var1) == ABS(var2)
* result = ZERO
* ----------
*/
zero_var(result);
result->rscale = MAX(var1->rscale, var2->rscale);
result->dscale = MAX(var1->dscale, var2->dscale);
break;
case 1: /* ----------
* ABS(var1) > ABS(var2)
* result = -(ABS(var1) - ABS(var2))
* ----------
*/
* ABS(var1) > ABS(var2)
* result = -(ABS(var1) - ABS(var2))
* ----------
*/
sub_abs(var1, var2, result);
result->sign = NUMERIC_NEG;
break;
@@ -3054,7 +3060,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
result->ndigits = ri + 1;
if (ri == res_ndigits + 1)
{
int carry = (res_digits[ri] > 4) ? 1 : 0;
int carry = (res_digits[ri] > 4) ? 1 : 0;
result->ndigits = ri;
res_digits[ri] = 0;

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.39 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.40 2000/04/12 17:15:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -84,7 +84,7 @@ pg_atoi(char *s, int size, int c)
errno = ERANGE;
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
}
#endif /* HAVE_LONG_INT_64 */
#endif /* HAVE_LONG_INT_64 */
break;
case sizeof(int16):
if (l < SHRT_MIN)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.33 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.34 2000/04/12 17:15:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,7 +39,7 @@ oidvectorin(char *oidString)
result = (Oid *) palloc(sizeof(Oid[INDEX_MAX_KEYS]));
for (slot=0; *oidString && slot < INDEX_MAX_KEYS; slot++)
for (slot = 0; *oidString && slot < INDEX_MAX_KEYS; slot++)
{
if (sscanf(oidString, "%u", &result[slot]) != 1)
break;
@@ -51,7 +51,7 @@ oidvectorin(char *oidString)
while (*oidString && isspace(*oidString))
oidString++;
if (*oidString)
elog(ERROR,"oidvector value has too many values");
elog(ERROR, "oidvector value has too many values");
while (slot < INDEX_MAX_KEYS)
result[slot++] = 0;
@@ -64,7 +64,8 @@ oidvectorin(char *oidString)
char *
oidvectorout(Oid *oidArray)
{
int num, maxnum;
int num,
maxnum;
char *rp;
char *result;
@@ -77,12 +78,12 @@ oidvectorout(Oid *oidArray)
}
/* find last non-zero value in vector */
for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
for (maxnum = INDEX_MAX_KEYS - 1; maxnum >= 0; maxnum--)
if (oidArray[maxnum] != 0)
break;
/* assumes sign, 10 digits, ' ' */
rp = result = (char *) palloc((maxnum+1) * 12 + 1);
rp = result = (char *) palloc((maxnum + 1) * 12 + 1);
for (num = 0; num <= maxnum; num++)
{
if (num != 0)

View File

@@ -1,7 +1,7 @@
/*
* Edmund Mergl <E.Mergl@bawue.de>
*
* $Id: oracle_compat.c,v 1.23 2000/04/07 13:39:41 thomas Exp $
* $Id: oracle_compat.c,v 1.24 2000/04/12 17:15:51 momjian Exp $
*
*/
@@ -466,10 +466,16 @@ rtrim(text *string, text *set)
text *
translate(text *string, text *from, text *to)
{
text *result;
char *from_ptr, *to_ptr;
char *source, *target;
int m, fromlen, tolen, retlen, i;
text *result;
char *from_ptr,
*to_ptr;
char *source,
*target;
int m,
fromlen,
tolen,
retlen,
i;
if (string == (text *) NULL ||
from == (text *) NULL ||
@@ -492,11 +498,11 @@ translate(text *string, text *from, text *to)
while (m-- > 0)
{
char rep = *source++;
char rep = *source++;
for (i = 0; i < fromlen; i++)
{
if (from_ptr[i] == rep)
if (from_ptr[i] == rep)
break;
}
if (i < fromlen)
@@ -521,6 +527,7 @@ translate(text *string, text *from, text *to)
}
VARSIZE(result) = retlen + VARHDRSZ;
/*
* There may be some wasted space in the result if deletions occurred,
* but it's not worth reallocating it; the function result probably
@@ -541,34 +548,35 @@ ascii(text *string)
return 0;
return ((int) *(VARDATA(string)));
} /* ascii() */
} /* ascii() */
text *
ichar(int4 cvalue)
{
text *result;
text *result;
result = (text *) palloc(VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ + 1;
*VARDATA(result) = (char) cvalue;
return result;
} /* ichar() */
} /* ichar() */
text *
repeat(text *string, int4 count)
{
text *result;
int slen, tlen;
int i;
char *cp;
text *result;
int slen,
tlen;
int i;
char *cp;
if (count < 0)
count = 0;
slen = (VARSIZE(string)-VARHDRSZ);
slen = (VARSIZE(string) - VARHDRSZ);
tlen = (VARHDRSZ + (count * slen));
result = (text *) palloc(tlen);
@@ -582,5 +590,4 @@ repeat(text *string, int4 count)
}
return result;
} /* repeat() */
} /* repeat() */

View File

@@ -2,22 +2,22 @@
/* -----------------------------------------------------------------------
* pg_locale.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.3 2000/03/18 18:57:14 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.4 2000/04/12 17:15:51 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
*
* The PostgreSQL locale utils.
* The PostgreSQL locale utils.
*
* Karel Zak - Zakkr
*
* -----------------------------------------------------------------------
*/
#include <stdio.h>
#include "postgres.h"
#ifdef USE_LOCALE
#include <locale.h>
@@ -27,72 +27,72 @@
/*------
* Return in PG_LocaleCategories current locale setting
* Return in PG_LocaleCategories current locale setting
*------
*/
*/
PG_LocaleCategories *
PGLC_current( PG_LocaleCategories *lc )
PGLC_current(PG_LocaleCategories * lc)
{
lc->lang = getenv("LANG");
lc->lc_ctype = setlocale(LC_CTYPE, NULL);
lc->lc_numeric = setlocale(LC_NUMERIC, NULL);
lc->lc_time = setlocale(LC_TIME, NULL);
lc->lc_collate = setlocale(LC_COLLATE, NULL);
lc->lc_monetary = setlocale(LC_MONETARY, NULL);
lc->lc_messages = setlocale(LC_MESSAGES, NULL);
lc->lang = getenv("LANG");
lc->lc_ctype = setlocale(LC_CTYPE, NULL);
lc->lc_numeric = setlocale(LC_NUMERIC, NULL);
lc->lc_time = setlocale(LC_TIME, NULL);
lc->lc_collate = setlocale(LC_COLLATE, NULL);
lc->lc_monetary = setlocale(LC_MONETARY, NULL);
lc->lc_messages = setlocale(LC_MESSAGES, NULL);
return lc;
}
}
#ifdef DEBUG_LOCALE_UTILS
#ifdef DEBUG_LOCALE_UTILS
/*------
* Print a PG_LocaleCategories struct as DEBUG
*------
*/
PG_LocaleCategories *
PGLC_debug_lc( PG_LocaleCategories *lc )
PGLC_debug_lc(PG_LocaleCategories * lc)
{
elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n",
lc->lang,
lc->lc_ctype,
lc->lc_numeric,
lc->lc_time,
lc->lc_collate,
lc->lc_monetary,
lc->lc_messages
lc->lang,
lc->lc_ctype,
lc->lc_numeric,
lc->lc_time,
lc->lc_collate,
lc->lc_monetary,
lc->lc_messages
);
return lc;
return lc;
}
#endif
/*------
* Set locales via a PG_LocaleCategories struct
* Set locales via a PG_LocaleCategories struct
*------
*/
PG_LocaleCategories *
PGLC_setlocale( PG_LocaleCategories *lc )
PGLC_setlocale(PG_LocaleCategories * lc)
{
if (!setlocale(LC_CTYPE, lc->lc_ctype ))
elog(NOTICE, "pg_setlocale(): 'LC_CTYPE=%s' cannot be honored.", lc->lc_ctype);
if (!setlocale(LC_NUMERIC, lc->lc_numeric ))
if (!setlocale(LC_CTYPE, lc->lc_ctype))
elog(NOTICE, "pg_setlocale(): 'LC_CTYPE=%s' cannot be honored.", lc->lc_ctype);
if (!setlocale(LC_NUMERIC, lc->lc_numeric))
elog(NOTICE, "pg_setlocale(): 'LC_NUMERIC=%s' cannot be honored.", lc->lc_numeric);
if (!setlocale(LC_TIME, lc->lc_time ))
elog(NOTICE, "pg_setlocale(): 'LC_TIME=%s' cannot be honored.", lc->lc_time);
if (!setlocale(LC_COLLATE, lc->lc_collate ))
if (!setlocale(LC_TIME, lc->lc_time))
elog(NOTICE, "pg_setlocale(): 'LC_TIME=%s' cannot be honored.", lc->lc_time);
if (!setlocale(LC_COLLATE, lc->lc_collate))
elog(NOTICE, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.", lc->lc_collate);
if (!setlocale(LC_MONETARY, lc->lc_monetary ))
elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);
if (!setlocale(LC_MESSAGES, lc->lc_messages ))
if (!setlocale(LC_MONETARY, lc->lc_monetary))
elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);
if (!setlocale(LC_MESSAGES, lc->lc_messages))
elog(NOTICE, "pg_setlocale(): 'LC_MESSAGE=%s' cannot be honored.", lc->lc_messages);
return lc;
@@ -101,28 +101,28 @@ PGLC_setlocale( PG_LocaleCategories *lc )
/*------
* Return the POSIX lconv struct (contains number/money formatting information)
* with locale information for *all* categories.
* => Returned lconv is *independent* on current locale catogories setting - in
* => Returned lconv is *independent* on current locale catogories setting - in
* contrast to standard localeconv().
*
* ! libc prepare memory space for lconv itself and all returned strings in
* lconv are *static strings*.
* ! libc prepare memory space for lconv itself and all returned strings in
* lconv are *static strings*.
*------
*/
struct lconv *
PGLC_localeconv(void)
{
PG_LocaleCategories lc;
struct lconv *lconv;
PG_LocaleCategories lc;
struct lconv *lconv;
/* Save current locale setting to lc */
PGLC_current(&lc);
PGLC_current(&lc);
/* Set all locale category for current lang */
setlocale(LC_ALL, "");
/* Get numeric formatting information */
lconv = localeconv();
/* Get numeric formatting information */
lconv = localeconv();
/* Set previous original locale */
PGLC_setlocale(&lc);
@@ -130,4 +130,4 @@ PGLC_localeconv(void)
}
#endif /* USE_LOCALE */
#endif /* USE_LOCALE */

View File

@@ -1,7 +1,7 @@
/* ----------
* pg_lzcompress.c -
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.3 1999/11/25 01:28:04 wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.4 2000/04/12 17:15:51 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
@@ -83,7 +83,7 @@
*
* So the 16 bits of a 2 byte tag are coded as
*
* 7---T1--0 7---T2--0
* 7---T1--0 7---T2--0
* OOOO LLLL OOOO OOOO
*
* This limits the offset to 1-4095 (12 bits) and the length
@@ -144,9 +144,10 @@
* Linked list for the backward history lookup
* ----------
*/
typedef struct PGLZ_HistEntry {
struct PGLZ_HistEntry *next;
char *pos;
typedef struct PGLZ_HistEntry
{
struct PGLZ_HistEntry *next;
char *pos;
} PGLZ_HistEntry;
@@ -155,35 +156,43 @@ typedef struct PGLZ_HistEntry {
* ----------
*/
static PGLZ_Strategy strategy_default_data = {
256, /* Data chunks smaller 256 bytes are nott compressed */
6144, /* Data chunks greater equal 6K force compression */
/* except compressed result is greater uncompressed data */
20, /* Compression rates below 20% mean fallback to uncompressed */
/* storage except compression is forced by previous parameter */
128, /* Stop history lookup if a match of 128 bytes is found */
10 /* Lower good match size by 10% at every lookup loop iteration. */
256, /* Data chunks smaller 256 bytes are nott
* compressed */
6144, /* Data chunks greater equal 6K force
* compression */
/* except compressed result is greater uncompressed data */
20, /* Compression rates below 20% mean
* fallback to uncompressed */
/* storage except compression is forced by previous parameter */
128, /* Stop history lookup if a match of 128
* bytes is found */
10 /* Lower good match size by 10% at every
* lookup loop iteration. */
};
PGLZ_Strategy *PGLZ_strategy_default = &strategy_default_data;
PGLZ_Strategy *PGLZ_strategy_default = &strategy_default_data;
static PGLZ_Strategy strategy_allways_data = {
0, /* Chunks of any size are compressed */
0, /* */
0, /* We want to save at least one single byte */
128, /* Stop history lookup if a match of 128 bytes is found */
6 /* Look harder for a good match. */
0, /* Chunks of any size are compressed */
0, /* */
0, /* We want to save at least one single
* byte */
128, /* Stop history lookup if a match of 128
* bytes is found */
6 /* Look harder for a good match. */
};
PGLZ_Strategy *PGLZ_strategy_allways = &strategy_allways_data;
PGLZ_Strategy *PGLZ_strategy_allways = &strategy_allways_data;
static PGLZ_Strategy strategy_never_data = {
0, /* */
0, /* */
0, /* */
0, /* Zero indicates "store uncompressed allways" */
0 /* */
0, /* */
0, /* */
0, /* */
0, /* Zero indicates "store uncompressed
* allways" */
0 /* */
};
PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
@@ -197,7 +206,7 @@ PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
#if 1
#define pglz_hist_idx(_s,_e) ( \
(((_e) - (_s)) < 4) ? 0 : \
((((_s)[0] << 9) ^ ((_s)[1] << 6) ^ \
((((_s)[0] << 9) ^ ((_s)[1] << 6) ^ \
((_s)[2] << 3) ^ (_s)[3]) & (PGLZ_HISTORY_MASK)) \
)
#else
@@ -217,7 +226,7 @@ PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
#define pglz_hist_add(_hs,_hn,_s,_e) { \
int __hindex = pglz_hist_idx((_s),(_e)); \
(_hn)->next = (_hs)[__hindex]; \
(_hn)->pos = (_s); \
(_hn)->pos = (_s); \
(_hs)[__hindex] = (_hn)++; \
}
@@ -288,16 +297,16 @@ PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data;
* ----------
*/
static inline int
pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
int *lenp, int *offp, int good_match, int good_drop)
pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
int *lenp, int *offp, int good_match, int good_drop)
{
PGLZ_HistEntry *hent;
int32 len = 0;
int32 off = 0;
int32 thislen;
int32 thisoff;
char *ip;
char *hp;
PGLZ_HistEntry *hent;
int32 len = 0;
int32 off = 0;
int32 thislen;
int32 thisoff;
char *ip;
char *hp;
/* ----------
* Traverse the linked history list until a good enough
@@ -311,7 +320,7 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
* Be happy with lesser good matches the more entries we visited.
* ----------
*/
good_match -= (good_match * good_drop) /100;
good_match -= (good_match * good_drop) / 100;
/* ----------
* Stop if the offset does not fit into our tag anymore.
@@ -340,9 +349,9 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
thislen = len;
ip += len;
hp += len;
} else {
thislen = 0;
}
else
thislen = 0;
while (ip < end && *ip == *hp && thislen < PGLZ_MAX_MATCH)
{
thislen++;
@@ -390,29 +399,29 @@ pglz_find_match (PGLZ_HistEntry **hstart, char *input, char *end,
* ----------
*/
int
pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
pglz_compress(char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy)
{
PGLZ_HistEntry *hist_start[PGLZ_HISTORY_SIZE];
PGLZ_HistEntry *hist_alloc;
PGLZ_HistEntry hist_prealloc[PGLZ_HISTORY_PREALLOC];
PGLZ_HistEntry *hist_next;
PGLZ_HistEntry *hist_start[PGLZ_HISTORY_SIZE];
PGLZ_HistEntry *hist_alloc;
PGLZ_HistEntry hist_prealloc[PGLZ_HISTORY_PREALLOC];
PGLZ_HistEntry *hist_next;
unsigned char *bp = ((unsigned char *)dest) + sizeof(PGLZ_Header);
unsigned char *bstart = bp;
char *dp = source;
char *dend = source + slen;
unsigned char ctrl_dummy = 0;
unsigned char *ctrlp = &ctrl_dummy;
unsigned char ctrlb = 0;
unsigned char ctrl = 0;
int32 match_len;
int32 match_off;
int32 good_match;
int32 good_drop;
int32 do_compress = 1;
int32 result_size = -1;
int32 result_max;
int32 need_rate;
unsigned char *bp = ((unsigned char *) dest) + sizeof(PGLZ_Header);
unsigned char *bstart = bp;
char *dp = source;
char *dend = source + slen;
unsigned char ctrl_dummy = 0;
unsigned char *ctrlp = &ctrl_dummy;
unsigned char ctrlb = 0;
unsigned char ctrl = 0;
int32 match_len;
int32 match_off;
int32 good_match;
int32 good_drop;
int32 do_compress = 1;
int32 result_size = -1;
int32 result_max;
int32 need_rate;
/* ----------
* Our fallback strategy is the default.
@@ -436,7 +445,9 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
{
memcpy(bstart, source, slen);
return (dest->varsize = slen + sizeof(PGLZ_Header));
} else {
}
else
{
if (slen < strategy->min_input_size)
{
memcpy(bstart, source, slen);
@@ -464,12 +475,12 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* table on the stack frame.
* ----------
*/
memset((void *)hist_start, 0, sizeof(hist_start));
memset((void *) hist_start, 0, sizeof(hist_start));
if (slen + 1 <= PGLZ_HISTORY_PREALLOC)
hist_alloc = hist_prealloc;
else
hist_alloc = (PGLZ_HistEntry *)
palloc(sizeof(PGLZ_HistEntry) * (slen + 1));
palloc(sizeof(PGLZ_HistEntry) * (slen + 1));
hist_next = hist_alloc;
/* ----------
@@ -481,9 +492,9 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* ----------
*/
if (slen >= strategy->force_input_size)
{
result_max = slen;
} else {
else
{
need_rate = strategy->min_comp_rate;
if (need_rate < 0)
need_rate = 0;
@@ -513,8 +524,8 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* Try to find a match in the history
* ----------
*/
if (pglz_find_match(hist_start, dp, dend, &match_len,
&match_off, good_match, good_drop))
if (pglz_find_match(hist_start, dp, dend, &match_len,
&match_off, good_match, good_drop))
{
/* ----------
* Create the tag and add history entries for
@@ -522,21 +533,23 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* ----------
*/
pglz_out_tag(ctrlp, ctrlb, ctrl, bp, match_len, match_off);
while(match_len--)
while (match_len--)
{
pglz_hist_add(hist_start, hist_next, dp, dend);
dp++; /* Do not do this ++ in the line above! */
/* The macro would do it four times - Jan. */
dp++; /* Do not do this ++ in the line above! */
/* The macro would do it four times - Jan. */
}
} else {
}
else
{
/* ----------
* No match found. Copy one literal byte.
* ----------
*/
pglz_out_literal(ctrlp, ctrlb, ctrl, bp, *dp);
pglz_hist_add(hist_start, hist_next, dp, dend);
dp++; /* Do not do this ++ in the line above! */
/* The macro would do it four times - Jan. */
dp++; /* Do not do this ++ in the line above! */
/* The macro would do it four times - Jan. */
}
}
@@ -545,7 +558,7 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* ----------
*/
if (hist_alloc != hist_prealloc)
pfree((void *)hist_alloc);
pfree((void *) hist_alloc);
/* ----------
* If we are still in compressing mode, write out the last
@@ -558,9 +571,8 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
*ctrlp = ctrlb;
result_size = bp - bstart;
if (result_size >= result_max) {
if (result_size >= result_max)
do_compress = 0;
}
}
/* ----------
@@ -571,10 +583,10 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* ----------
*/
if (do_compress)
{
return (dest->varsize = result_size + sizeof(PGLZ_Header));
} else {
memcpy(((char *)dest) + sizeof(PGLZ_Header), source, slen);
else
{
memcpy(((char *) dest) + sizeof(PGLZ_Header), source, slen);
return (dest->varsize = slen + sizeof(PGLZ_Header));
}
}
@@ -587,19 +599,19 @@ pglz_compress (char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strateg
* ----------
*/
int
pglz_decompress (PGLZ_Header *source, char *dest)
pglz_decompress(PGLZ_Header *source, char *dest)
{
unsigned char *dp;
unsigned char *dend;
unsigned char *bp;
unsigned char ctrl;
int32 ctrlc;
int32 len;
int32 off;
unsigned char *dp;
unsigned char *dend;
unsigned char *bp;
unsigned char ctrl;
int32 ctrlc;
int32 len;
int32 off;
dp = ((unsigned char *)source) + sizeof(PGLZ_Header);
dend = ((unsigned char *)source) + source->varsize;
bp = (unsigned char *)dest;
dp = ((unsigned char *) source) + sizeof(PGLZ_Header);
dend = ((unsigned char *) source) + source->varsize;
bp = (unsigned char *) dest;
if (source->varsize == source->rawsize + sizeof(PGLZ_Header))
{
@@ -630,9 +642,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
off = ((dp[0] & 0xf0) << 4) | dp[1];
dp += 2;
if (len == 18)
{
len += *dp++;
}
/* ----------
* Now we copy the bytes specified by the tag from
@@ -646,7 +656,9 @@ pglz_decompress (PGLZ_Header *source, char *dest)
*bp = bp[-off];
bp++;
}
} else {
}
else
{
/* ----------
* An unset control bit means LITERAL BYTE. So we
* just copy one from INPUT to OUTPUT.
@@ -667,7 +679,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
* That's it.
* ----------
*/
return (char *)bp - dest;
return (char *) bp - dest;
}
@@ -681,7 +693,7 @@ pglz_decompress (PGLZ_Header *source, char *dest)
int
pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
{
unsigned char retval;
unsigned char retval;
if (dstate->tocopy > 0)
{
@@ -703,9 +715,7 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
* ----------
*/
if (dstate->cp_in == dstate->cp_end)
{
return EOF;
}
/* ----------
* This decompression method saves time only, if we stop near
@@ -721,14 +731,14 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
*/
if (dstate->cp_out - dstate->temp_buf >= 256)
{
unsigned char *cp_in = dstate->cp_in;
unsigned char *cp_out = dstate->cp_out;
unsigned char *cp_end = dstate->cp_end;
unsigned char *cp_copy;
unsigned char ctrl;
int off;
int len;
int i;
unsigned char *cp_in = dstate->cp_in;
unsigned char *cp_out = dstate->cp_out;
unsigned char *cp_end = dstate->cp_end;
unsigned char *cp_copy;
unsigned char ctrl;
int off;
int len;
int i;
while (cp_in < cp_end)
{
@@ -748,27 +758,27 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
len += *cp_in++;
cp_copy = cp_out - off;
while(len--)
while (len--)
*cp_out++ = *cp_copy++;
} else {
*cp_out++ = *cp_in++;
}
else
*cp_out++ = *cp_in++;
ctrl >>= 1;
}
}
dstate->cp_in = dstate->cp_out;
dstate->cp_end = cp_out;
dstate->next_char = pglz_get_next_decomp_char_from_plain;
dstate->cp_in = dstate->cp_out;
dstate->cp_end = cp_out;
dstate->next_char = pglz_get_next_decomp_char_from_plain;
return (int)(*(dstate->cp_in++));
return (int) (*(dstate->cp_in++));
}
/* ----------
* Not yet, get next control byte into decomp state.
* ----------
*/
dstate->ctrl = (unsigned char)(*(dstate->cp_in++));
dstate->ctrl = (unsigned char) (*(dstate->cp_in++));
dstate->ctrl_count = 8;
}
@@ -777,9 +787,7 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
* ----------
*/
if (dstate->cp_in == dstate->cp_end)
{
return EOF;
}
/* ----------
* Handle next control bit.
@@ -793,27 +801,29 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
* and do the copy for the first byte as above.
* ----------
*/
int off;
int off;
dstate->tocopy = (dstate->cp_in[0] & 0x0f) + 3;
off = ((dstate->cp_in[0] & 0xf0) << 4) | dstate->cp_in[1];
dstate->cp_in += 2;
dstate->tocopy = (dstate->cp_in[0] & 0x0f) + 3;
off = ((dstate->cp_in[0] & 0xf0) << 4) | dstate->cp_in[1];
dstate->cp_in += 2;
if (dstate->tocopy == 18)
dstate->tocopy += *(dstate->cp_in++);
dstate->cp_copy = dstate->cp_out - off;
dstate->tocopy--;
retval = (*(dstate->cp_out++) = *(dstate->cp_copy++));
} else {
}
else
{
/* ----------
* Bit is unset, so literal byte follows.
* ----------
*/
retval = (int)(*(dstate->cp_out++) = *(dstate->cp_in++));
retval = (int) (*(dstate->cp_out++) = *(dstate->cp_in++));
}
dstate->ctrl >>= 1;
return (int)retval;
return (int) retval;
}
@@ -831,7 +841,5 @@ pglz_get_next_decomp_char_from_plain(PGLZ_DecompState *dstate)
if (dstate->cp_in >= dstate->cp_end)
return EOF;
return (int)(*(dstate->cp_in++));
return (int) (*(dstate->cp_in++));
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.53 2000/02/27 03:30:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.54 2000/04/12 17:15:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -264,7 +264,7 @@ oidvectortypes(Oid *oidArray)
for (num = 0; num < FUNC_MAX_ARGS; num++)
{
if (oidArray[num] != InvalidOid)
numargs = num+1;
numargs = num + 1;
}
result = (text *) palloc((NAMEDATALEN + 1) * numargs + VARHDRSZ + 1);

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
* out of its tuple
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.47 2000/03/17 02:36:23 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.48 2000/04/12 17:15:51 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -66,7 +66,8 @@ typedef struct
bool varprefix; /* TRUE to print prefixes on Vars */
} deparse_context;
typedef struct {
typedef struct
{
Index rt_index;
int levelsup;
} check_if_rte_used_context;
@@ -113,7 +114,7 @@ static char *get_relation_name(Oid relid);
static char *get_attribute_name(Oid relid, int2 attnum);
static bool check_if_rte_used(Node *node, Index rt_index, int levelsup);
static bool check_if_rte_used_walker(Node *node,
check_if_rte_used_context *context);
check_if_rte_used_context *context);
#define inherit_marker(rte) ((rte)->inh ? "*" : "")
@@ -133,7 +134,7 @@ pg_get_ruledef(NameData *rname)
int spirc;
HeapTuple ruletup;
TupleDesc rulettc;
StringInfoData buf;
StringInfoData buf;
int len;
/* ----------
@@ -231,7 +232,7 @@ pg_get_viewdef(NameData *rname)
int spirc;
HeapTuple ruletup;
TupleDesc rulettc;
StringInfoData buf;
StringInfoData buf;
int len;
char name1[NAMEDATALEN + 5];
char name2[NAMEDATALEN + 5];
@@ -338,8 +339,8 @@ pg_get_indexdef(Oid indexrelid)
int spirc;
int len;
int keyno;
StringInfoData buf;
StringInfoData keybuf;
StringInfoData buf;
StringInfoData keybuf;
char *sep;
/* ----------
@@ -427,8 +428,8 @@ pg_get_indexdef(Oid indexrelid)
initStringInfo(&buf);
appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
idxrec->indisunique ? "UNIQUE " : "",
quote_identifier(pstrdup(NameStr(idxrelrec->relname))),
quote_identifier(pstrdup(NameStr(indrelrec->relname))),
quote_identifier(pstrdup(NameStr(idxrelrec->relname))),
quote_identifier(pstrdup(NameStr(indrelrec->relname))),
quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
spi_fno)));
@@ -451,8 +452,8 @@ pg_get_indexdef(Oid indexrelid)
* ----------
*/
appendStringInfo(&keybuf, "%s",
quote_identifier(get_attribute_name(idxrec->indrelid,
idxrec->indkey[keyno])));
quote_identifier(get_attribute_name(idxrec->indrelid,
idxrec->indkey[keyno])));
/* ----------
* If not a functional index, add the operator class name
@@ -472,8 +473,8 @@ pg_get_indexdef(Oid indexrelid)
spi_ttc = SPI_tuptable->tupdesc;
spi_fno = SPI_fnumber(spi_ttc, "opcname");
appendStringInfo(&keybuf, " %s",
quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
spi_fno)));
quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
spi_fno)));
}
}
@@ -493,7 +494,7 @@ pg_get_indexdef(Oid indexrelid)
procStruct = (Form_pg_proc) GETSTRUCT(proctup);
appendStringInfo(&buf, "%s(%s) ",
quote_identifier(pstrdup(NameStr(procStruct->proname))),
quote_identifier(pstrdup(NameStr(procStruct->proname))),
keybuf.data);
spi_args[0] = ObjectIdGetDatum(idxrec->indclass[0]);
@@ -589,8 +590,8 @@ pg_get_userbyid(int32 uid)
* tree (ie, not the raw output of gram.y).
*
* rangetables is a List of Lists of RangeTblEntry nodes: first sublist is for
* varlevelsup = 0, next for varlevelsup = 1, etc. In each sublist the first
* item is for varno = 1, next varno = 2, etc. (Each sublist has the same
* varlevelsup = 0, next for varlevelsup = 1, etc. In each sublist the first
* item is for varno = 1, next varno = 2, etc. (Each sublist has the same
* format as the rtable list of a parsetree or query.)
*
* forceprefix is TRUE to force all Vars to be prefixed with their table names.
@@ -603,8 +604,8 @@ pg_get_userbyid(int32 uid)
char *
deparse_expression(Node *expr, List *rangetables, bool forceprefix)
{
StringInfoData buf;
deparse_context context;
StringInfoData buf;
deparse_context context;
initStringInfo(&buf);
context.buf = &buf;
@@ -710,7 +711,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
{
Node *qual;
Query *query;
deparse_context context;
deparse_context context;
appendStringInfo(buf, " WHERE ");
@@ -834,7 +835,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
static void
get_query_def(Query *query, StringInfo buf, List *parentrtables)
{
deparse_context context;
deparse_context context;
context.buf = buf;
context.rangetables = lcons(query->rtable, parentrtables);
@@ -954,7 +955,7 @@ get_select_query_def(Query *query, deparse_context *context)
get_rule_expr(tle->expr, context);
/* Check if we must say AS ... */
if (! IsA(tle->expr, Var))
if (!IsA(tle->expr, Var))
tell_as = strcmp(tle->resdom->resname, "?column?");
else
{
@@ -996,11 +997,12 @@ get_select_query_def(Query *query, deparse_context *context)
appendStringInfo(buf, "%s%s",
quote_identifier(rte->relname),
inherit_marker(rte));
/*
* NOTE: SQL92 says you can't write column aliases unless
* you write a table alias --- so, if there's an alias list,
* make sure we emit a table alias even if it's the same as
* the table's real name.
* you write a table alias --- so, if there's an alias
* list, make sure we emit a table alias even if it's the
* same as the table's real name.
*/
if ((rte->ref != NULL)
&& ((strcmp(rte->relname, rte->ref->relname) != 0)
@@ -1010,7 +1012,7 @@ get_select_query_def(Query *query, deparse_context *context)
quote_identifier(rte->ref->relname));
if (rte->ref->attrs != NIL)
{
List *col;
List *col;
appendStringInfo(buf, " (");
foreach(col, rte->ref->attrs)
@@ -1018,7 +1020,7 @@ get_select_query_def(Query *query, deparse_context *context)
if (col != rte->ref->attrs)
appendStringInfo(buf, ", ");
appendStringInfo(buf, "%s",
quote_identifier(strVal(lfirst(col))));
quote_identifier(strVal(lfirst(col))));
}
appendStringInfoChar(buf, ')');
}
@@ -1042,7 +1044,7 @@ get_select_query_def(Query *query, deparse_context *context)
foreach(l, query->groupClause)
{
GroupClause *grp = (GroupClause *) lfirst(l);
Node *groupexpr;
Node *groupexpr;
groupexpr = get_sortgroupclause_expr(grp,
query->targetList);
@@ -1228,8 +1230,8 @@ get_delete_query_def(Query *query, deparse_context *context)
static RangeTblEntry *
get_rte_for_var(Var *var, deparse_context *context)
{
List *rtlist = context->rangetables;
int sup = var->varlevelsup;
List *rtlist = context->rangetables;
int sup = var->varlevelsup;
while (sup-- > 0)
rtlist = lnext(rtlist);
@@ -1281,11 +1283,11 @@ get_rule_expr(Node *node, deparse_context *context)
appendStringInfo(buf, "old.");
else
appendStringInfo(buf, "%s.",
quote_identifier(rte->ref->relname));
quote_identifier(rte->ref->relname));
}
appendStringInfo(buf, "%s",
quote_identifier(get_attribute_name(rte->relid,
var->varattno)));
quote_identifier(get_attribute_name(rte->relid,
var->varattno)));
}
break;
@@ -1307,7 +1309,7 @@ get_rule_expr(Node *node, deparse_context *context)
/* binary operator */
get_rule_expr((Node *) lfirst(args), context);
appendStringInfo(buf, " %s ",
get_opname(((Oper *) expr->oper)->opno));
get_opname(((Oper *) expr->oper)->opno));
get_rule_expr((Node *) lsecond(args), context);
}
else
@@ -1318,7 +1320,7 @@ get_rule_expr(Node *node, deparse_context *context)
Form_pg_operator optup;
tp = SearchSysCacheTuple(OPEROID,
ObjectIdGetDatum(opno),
ObjectIdGetDatum(opno),
0, 0, 0);
Assert(HeapTupleIsValid(tp));
optup = (Form_pg_operator) GETSTRUCT(tp);
@@ -1435,7 +1437,7 @@ get_rule_expr(Node *node, deparse_context *context)
appendStringInfoChar(buf, '(');
get_rule_expr(relabel->arg, context);
typetup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(relabel->resulttype),
ObjectIdGetDatum(relabel->resulttype),
0, 0, 0);
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup of type %u failed",
@@ -1510,7 +1512,8 @@ get_func_expr(Expr *expr, deparse_context *context)
proname = pstrdup(NameStr(procStruct->proname));
/*
* nullvalue() and nonnullvalue() should get turned into special syntax
* nullvalue() and nonnullvalue() should get turned into special
* syntax
*/
if (procStruct->pronargs == 1 && procStruct->proargtypes[0] == InvalidOid)
{
@@ -1540,18 +1543,19 @@ get_func_expr(Expr *expr, deparse_context *context)
/*
* Strip off any RelabelType on the input, so we don't print
* redundancies like x::bpchar::char(8).
* XXX Are there any cases where this is a bad idea?
* redundancies like x::bpchar::char(8). XXX Are there any cases
* where this is a bad idea?
*/
if (IsA(arg, RelabelType))
arg = ((RelabelType *) arg)->arg;
appendStringInfoChar(buf, '(');
get_rule_expr(arg, context);
appendStringInfo(buf, ")::");
/*
* Show typename with appropriate length decoration.
* Note that since exprIsLengthCoercion succeeded, the function
* name is the same as its output type name.
* Show typename with appropriate length decoration. Note that
* since exprIsLengthCoercion succeeded, the function name is the
* same as its output type name.
*/
if (strcmp(proname, "bpchar") == 0)
{
@@ -1571,7 +1575,7 @@ get_func_expr(Expr *expr, deparse_context *context)
{
if (coercedTypmod >= (int32) VARHDRSZ)
appendStringInfo(buf, "numeric(%d,%d)",
((coercedTypmod - VARHDRSZ) >> 16) & 0xffff,
((coercedTypmod - VARHDRSZ) >> 16) & 0xffff,
(coercedTypmod - VARHDRSZ) & 0xffff);
else
appendStringInfo(buf, "numeric");
@@ -1621,8 +1625,8 @@ get_tle_expr(TargetEntry *tle, deparse_context *context)
int32 coercedTypmod;
/*
* If top level is a length coercion to the correct length, suppress it;
* else dump the expression normally.
* If top level is a length coercion to the correct length, suppress
* it; else dump the expression normally.
*/
if (tle->resdom->restypmod >= 0 &&
exprIsLengthCoercion((Node *) expr, &coercedTypmod) &&
@@ -1659,10 +1663,11 @@ get_const_expr(Const *constval, deparse_context *context)
if (constval->constisnull)
{
/*
* Always label the type of a NULL constant. This not only
* prevents misdecisions about the type, but it ensures that
* our output is a valid b_expr.
* prevents misdecisions about the type, but it ensures that our
* output is a valid b_expr.
*/
extval = pstrdup(NameStr(typeStruct->typname));
appendStringInfo(buf, "NULL::%s", quote_identifier(extval));
@@ -1681,20 +1686,21 @@ get_const_expr(Const *constval, deparse_context *context)
case INT4OID:
case OIDOID: /* int types */
case FLOAT4OID:
case FLOAT8OID: /* float types */
case FLOAT8OID: /* float types */
/* These types are printed without quotes */
appendStringInfo(buf, extval);
break;
default:
/*
* We must quote any funny characters in the constant's
* representation.
* XXX Any MULTIBYTE considerations here?
* representation. XXX Any MULTIBYTE considerations here?
*/
appendStringInfoChar(buf, '\'');
for (valptr = extval; *valptr; valptr++)
{
char ch = *valptr;
char ch = *valptr;
if (ch == '\'' || ch == '\\')
{
appendStringInfoChar(buf, '\\');
@@ -1818,10 +1824,11 @@ get_sublink_expr(Node *node, deparse_context *context)
static char *
quote_identifier(char *ident)
{
/*
* Can avoid quoting if ident starts with a lowercase letter and
* contains only lowercase letters, digits, and underscores,
* *and* is not any SQL keyword. Otherwise, supply quotes.
* contains only lowercase letters, digits, and underscores, *and* is
* not any SQL keyword. Otherwise, supply quotes.
*/
bool safe;
char *result;
@@ -1835,20 +1842,21 @@ quote_identifier(char *ident)
{
char *ptr;
for (ptr = ident+1; *ptr; ptr++)
for (ptr = ident + 1; *ptr; ptr++)
{
char ch = *ptr;
char ch = *ptr;
safe = ((ch >= 'a' && ch <= 'z') ||
(ch >= '0' && ch <= '9') ||
(ch == '_'));
if (! safe)
if (!safe)
break;
}
}
if (safe)
{
/*
* Check for keyword. This test is overly strong, since many of
* the "keywords" known to the parser are usable as column names,
@@ -1955,7 +1963,11 @@ check_if_rte_used_walker(Node *node,
check_if_rte_used(query->havingQual,
context->rt_index, context->levelsup + 1))
return true;
/* fall through to let expression_tree_walker examine lefthand args */
/*
* fall through to let expression_tree_walker examine lefthand
* args
*/
}
return expression_tree_walker(node, check_if_rte_used_walker,
(void *) context);

View File

@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.63 2000/04/09 04:31:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.64 2000/04/12 17:15:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,25 +45,25 @@
#define FunctionalSelectivity(nIndKeys,attNum) ((attNum)==InvalidAttrNumber)
/* default selectivity estimate for equalities such as "A = b" */
#define DEFAULT_EQ_SEL 0.01
#define DEFAULT_EQ_SEL 0.01
/* default selectivity estimate for inequalities such as "A < b" */
#define DEFAULT_INEQ_SEL (1.0 / 3.0)
static bool convert_string_to_scalar(char *str, int strlength,
double *scaleval);
double *scaleval);
static void getattproperties(Oid relid, AttrNumber attnum,
Oid *typid,
int *typlen,
bool *typbyval,
int32 *typmod);
Oid *typid,
int *typlen,
bool *typbyval,
int32 *typmod);
static bool getattstatistics(Oid relid, AttrNumber attnum,
Oid typid, int32 typmod,
double *nullfrac,
double *commonfrac,
Datum *commonval,
Datum *loval,
Datum *hival);
Oid typid, int32 typmod,
double *nullfrac,
double *commonfrac,
Datum *commonval,
Datum *loval,
Datum *hival);
/*
@@ -109,15 +109,17 @@ eqsel(Oid opid,
{
if (flag & SEL_CONSTANT)
{
/* Is the constant "=" to the column's most common value?
* (Although the operator may not really be "=",
* we will assume that seeing whether it returns TRUE
* for the most common value is useful information.
* If you don't like it, maybe you shouldn't be using
* eqsel for your operator...)
/*
* Is the constant "=" to the column's most common value?
* (Although the operator may not really be "=", we will
* assume that seeing whether it returns TRUE for the most
* common value is useful information. If you don't like
* it, maybe you shouldn't be using eqsel for your
* operator...)
*/
RegProcedure eqproc = get_opcode(opid);
bool mostcommon;
RegProcedure eqproc = get_opcode(opid);
bool mostcommon;
if (eqproc == (RegProcedure) NULL)
elog(ERROR, "eqsel: no procedure for operator %u",
@@ -133,7 +135,9 @@ eqsel(Oid opid,
if (mostcommon)
{
/* Constant is "=" to the most common value. We know
/*
* Constant is "=" to the most common value. We know
* selectivity exactly (or as exactly as VACUUM could
* calculate it, anyway).
*/
@@ -141,17 +145,22 @@ eqsel(Oid opid,
}
else
{
/* Comparison is against a constant that is neither the
* most common value nor null. Its selectivity cannot
* be more than this:
/*
* Comparison is against a constant that is neither
* the most common value nor null. Its selectivity
* cannot be more than this:
*/
selec = 1.0 - commonfrac - nullfrac;
if (selec > commonfrac)
selec = commonfrac;
/* and in fact it's probably less, so we should apply
* a fudge factor. The only case where we don't is
* for a boolean column, where indeed we have estimated
* the less-common value's frequency exactly!
/*
* and in fact it's probably less, so we should apply
* a fudge factor. The only case where we don't is
* for a boolean column, where indeed we have
* estimated the less-common value's frequency
* exactly!
*/
if (typid != BOOLOID)
selec *= 0.5;
@@ -159,14 +168,18 @@ eqsel(Oid opid,
}
else
{
/* Search is for a value that we do not know a priori,
* but we will assume it is not NULL. Selectivity
* cannot be more than this:
/*
* Search is for a value that we do not know a priori, but
* we will assume it is not NULL. Selectivity cannot be
* more than this:
*/
selec = 1.0 - nullfrac;
if (selec > commonfrac)
selec = commonfrac;
/* and in fact it's probably less, so apply a fudge
/*
* and in fact it's probably less, so apply a fudge
* factor.
*/
selec *= 0.5;
@@ -178,15 +191,17 @@ eqsel(Oid opid,
else if (selec > 1.0)
selec = 1.0;
if (! typbyval)
if (!typbyval)
pfree(DatumGetPointer(commonval));
}
else
{
/* No VACUUM ANALYZE stats available, so make a guess using
* the disbursion stat (if we have that, which is unlikely
* for a normal attribute; but for a system attribute we may
* be able to estimate it).
/*
* No VACUUM ANALYZE stats available, so make a guess using
* the disbursion stat (if we have that, which is unlikely for
* a normal attribute; but for a system attribute we may be
* able to estimate it).
*/
selec = get_attdisbursion(relid, attno, 0.01);
}
@@ -234,7 +249,7 @@ scalarltsel(Oid opid,
float64 result;
result = (float64) palloc(sizeof(float64data));
if (! (flag & SEL_CONSTANT) || NONVALUE(attno) || NONVALUE(relid))
if (!(flag & SEL_CONSTANT) || NONVALUE(attno) || NONVALUE(relid))
*result = DEFAULT_INEQ_SEL;
else
{
@@ -253,21 +268,24 @@ scalarltsel(Oid opid,
numerator,
denominator;
/* Get left and right datatypes of the operator so we know
* what type the constant is.
/*
* Get left and right datatypes of the operator so we know what
* type the constant is.
*/
oprtuple = get_operator_tuple(opid);
if (! HeapTupleIsValid(oprtuple))
if (!HeapTupleIsValid(oprtuple))
elog(ERROR, "scalarltsel: no tuple for operator %u", opid);
ltype = ((Form_pg_operator) GETSTRUCT(oprtuple))->oprleft;
rtype = ((Form_pg_operator) GETSTRUCT(oprtuple))->oprright;
/* Convert the constant to a uniform comparison scale. */
if (! convert_to_scalar(value,
((flag & SEL_RIGHT) ? rtype : ltype),
&val))
if (!convert_to_scalar(value,
((flag & SEL_RIGHT) ? rtype : ltype),
&val))
{
/* Ideally we'd produce an error here, on the grounds that the
/*
* Ideally we'd produce an error here, on the grounds that the
* given operator shouldn't have scalarltsel registered as its
* selectivity func unless we can deal with its operand types.
* But currently, all manner of stuff is invoking scalarltsel,
@@ -281,9 +299,9 @@ scalarltsel(Oid opid,
getattproperties(relid, attno,
&typid, &typlen, &typbyval, &typmod);
if (! getattstatistics(relid, attno, typid, typmod,
NULL, NULL, NULL,
&loval, &hival))
if (!getattstatistics(relid, attno, typid, typmod,
NULL, NULL, NULL,
&loval, &hival))
{
/* no stats available, so default result */
*result = DEFAULT_INEQ_SEL;
@@ -291,11 +309,11 @@ scalarltsel(Oid opid,
}
/* Convert the attribute's loval/hival to common scale. */
if (! convert_to_scalar(loval, typid, &low) ||
! convert_to_scalar(hival, typid, &high))
if (!convert_to_scalar(loval, typid, &low) ||
!convert_to_scalar(hival, typid, &high))
{
/* See above comments... */
if (! typbyval)
if (!typbyval)
{
pfree(DatumGetPointer(hival));
pfree(DatumGetPointer(loval));
@@ -306,7 +324,7 @@ scalarltsel(Oid opid,
}
/* release temp storage if needed */
if (! typbyval)
if (!typbyval)
{
pfree(DatumGetPointer(hival));
pfree(DatumGetPointer(loval));
@@ -314,18 +332,22 @@ scalarltsel(Oid opid,
if (high <= low)
{
/* If we trusted the stats fully, we could return a small or
* large selec depending on which side of the single data point
* the constant is on. But it seems better to assume that the
* stats are wrong and return a default...
/*
* If we trusted the stats fully, we could return a small or
* large selec depending on which side of the single data
* point the constant is on. But it seems better to assume
* that the stats are wrong and return a default...
*/
*result = DEFAULT_INEQ_SEL;
}
else if (val < low || val > high)
{
/* If given value is outside the statistical range, return a
* small or large value; but not 0.0/1.0 since there is a chance
* the stats are out of date.
/*
* If given value is outside the statistical range, return a
* small or large value; but not 0.0/1.0 since there is a
* chance the stats are out of date.
*/
if (flag & SEL_RIGHT)
*result = (val < low) ? 0.001 : 0.999;
@@ -359,8 +381,9 @@ scalargtsel(Oid opid,
{
float64 result;
/* Compute selectivity of "<", then invert --- but only if we
* were able to produce a non-default estimate.
/*
* Compute selectivity of "<", then invert --- but only if we were
* able to produce a non-default estimate.
*/
result = scalarltsel(opid, relid, attno, value, flag);
if (*result != DEFAULT_INEQ_SEL)
@@ -392,23 +415,24 @@ eqjoinsel(Oid opid,
{
num1 = unknown1 ? 1.0 : get_attdisbursion(relid1, attno1, 0.01);
num2 = unknown2 ? 1.0 : get_attdisbursion(relid2, attno2, 0.01);
/*
* The join selectivity cannot be more than num2, since each
* tuple in table 1 could match no more than num2 fraction of
* tuples in table 2 (and that's only if the table-1 tuple
* matches the most common value in table 2, so probably it's
* less). By the same reasoning it is not more than num1.
* The min is therefore an upper bound.
* The join selectivity cannot be more than num2, since each tuple
* in table 1 could match no more than num2 fraction of tuples in
* table 2 (and that's only if the table-1 tuple matches the most
* common value in table 2, so probably it's less). By the same
* reasoning it is not more than num1. The min is therefore an
* upper bound.
*
* If we know the disbursion of only one side, use it; the reasoning
* above still works.
*
* XXX can we make a better estimate here? Using the nullfrac
* XXX can we make a better estimate here? Using the nullfrac
* statistic might be helpful, for example. Assuming the operator
* is strict (does not succeed for null inputs) then the selectivity
* couldn't be more than (1-nullfrac1)*(1-nullfrac2), which might
* be usefully small if there are many nulls. How about applying
* the operator to the most common values?
* is strict (does not succeed for null inputs) then the
* selectivity couldn't be more than (1-nullfrac1)*(1-nullfrac2),
* which might be usefully small if there are many nulls. How
* about applying the operator to the most common values?
*/
min = (num1 < num2) ? num1 : num2;
*result = min;
@@ -434,7 +458,7 @@ neqjoinsel(Oid opid,
}
/*
* scalarltjoinsel - Join selectivity of "<" and "<=" for scalars
* scalarltjoinsel - Join selectivity of "<" and "<=" for scalars
*/
float64
scalarltjoinsel(Oid opid,
@@ -451,7 +475,7 @@ scalarltjoinsel(Oid opid,
}
/*
* scalargtjoinsel - Join selectivity of ">" and ">=" for scalars
* scalargtjoinsel - Join selectivity of ">" and ">=" for scalars
*/
float64
scalargtjoinsel(Oid opid,
@@ -493,10 +517,11 @@ convert_to_scalar(Datum value, Oid typid,
{
switch (typid)
{
/*
* Built-in numeric types
*/
case BOOLOID:
/*
* Built-in numeric types
*/
case BOOLOID:
*scaleval = (double) DatumGetUInt8(value);
return true;
case INT2OID:
@@ -506,16 +531,16 @@ convert_to_scalar(Datum value, Oid typid,
*scaleval = (double) DatumGetInt32(value);
return true;
case INT8OID:
*scaleval = (double) (* i8tod((int64 *) DatumGetPointer(value)));
*scaleval = (double) (*i8tod((int64 *) DatumGetPointer(value)));
return true;
case FLOAT4OID:
*scaleval = (double) (* DatumGetFloat32(value));
*scaleval = (double) (*DatumGetFloat32(value));
return true;
case FLOAT8OID:
*scaleval = (double) (* DatumGetFloat64(value));
*scaleval = (double) (*DatumGetFloat64(value));
return true;
case NUMERICOID:
*scaleval = (double) (* numeric_float8((Numeric) DatumGetPointer(value)));
*scaleval = (double) (*numeric_float8((Numeric) DatumGetPointer(value)));
return true;
case OIDOID:
case REGPROCOID:
@@ -523,110 +548,114 @@ convert_to_scalar(Datum value, Oid typid,
*scaleval = (double) DatumGetObjectId(value);
return true;
/*
* Built-in string types
*/
/*
* Built-in string types
*/
case CHAROID:
{
char ch = DatumGetChar(value);
{
char ch = DatumGetChar(value);
return convert_string_to_scalar(&ch, 1, scaleval);
}
return convert_string_to_scalar(&ch, 1, scaleval);
}
case BPCHAROID:
case VARCHAROID:
case TEXTOID:
{
char *str = (char *) VARDATA(DatumGetPointer(value));
int strlength = VARSIZE(DatumGetPointer(value)) - VARHDRSZ;
{
char *str = (char *) VARDATA(DatumGetPointer(value));
int strlength = VARSIZE(DatumGetPointer(value)) - VARHDRSZ;
return convert_string_to_scalar(str, strlength, scaleval);
}
return convert_string_to_scalar(str, strlength, scaleval);
}
case NAMEOID:
{
NameData *nm = (NameData *) DatumGetPointer(value);
{
NameData *nm = (NameData *) DatumGetPointer(value);
return convert_string_to_scalar(NameStr(*nm), strlen(NameStr(*nm)),
scaleval);
}
/*
* Built-in absolute-time types
*/
case TIMESTAMPOID:
*scaleval = * ((Timestamp *) DatumGetPointer(value));
return true;
case ABSTIMEOID:
*scaleval = * abstime_timestamp(value);
return true;
case DATEOID:
*scaleval = * date_timestamp(value);
return true;
/*
* Built-in relative-time types
*/
case INTERVALOID:
{
Interval *interval = (Interval *) DatumGetPointer(value);
return convert_string_to_scalar(NameStr(*nm), strlen(NameStr(*nm)),
scaleval);
}
/*
* Convert the month part of Interval to days using assumed
* average month length of 365.25/12.0 days. Not too accurate,
* but plenty good enough for our purposes.
* Built-in absolute-time types
*/
*scaleval = interval->time +
interval->month * (365.25/12.0 * 24.0 * 60.0 * 60.0);
case TIMESTAMPOID:
*scaleval = *((Timestamp *) DatumGetPointer(value));
return true;
}
case ABSTIMEOID:
*scaleval = *abstime_timestamp(value);
return true;
case DATEOID:
*scaleval = *date_timestamp(value);
return true;
/*
* Built-in relative-time types
*/
case INTERVALOID:
{
Interval *interval = (Interval *) DatumGetPointer(value);
/*
* Convert the month part of Interval to days using
* assumed average month length of 365.25/12.0 days. Not
* too accurate, but plenty good enough for our purposes.
*/
*scaleval = interval->time +
interval->month * (365.25 / 12.0 * 24.0 * 60.0 * 60.0);
return true;
}
case RELTIMEOID:
*scaleval = (RelativeTime) DatumGetInt32(value);
return true;
case TINTERVALOID:
{
TimeInterval interval = (TimeInterval) DatumGetPointer(value);
if (interval->status != 0)
{
*scaleval = interval->data[1] - interval->data[0];
return true;
TimeInterval interval = (TimeInterval) DatumGetPointer(value);
if (interval->status != 0)
{
*scaleval = interval->data[1] - interval->data[0];
return true;
}
break;
}
break;
}
case TIMEOID:
*scaleval = * ((TimeADT *) DatumGetPointer(value));
*scaleval = *((TimeADT *) DatumGetPointer(value));
return true;
default:
{
/*
* See whether there is a registered type-conversion function,
* namely a procedure named "float8" with the right signature.
* If so, assume we can convert the value to the numeric scale.
*
* NOTE: there are no such procedures in the standard distribution,
* except with argument types that we already dealt with above.
* This code is just here as an escape for user-defined types.
*/
Oid oid_array[FUNC_MAX_ARGS];
HeapTuple ftup;
MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
oid_array[0] = typid;
ftup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum("float8"),
Int32GetDatum(1),
PointerGetDatum(oid_array),
0);
if (HeapTupleIsValid(ftup) &&
((Form_pg_proc) GETSTRUCT(ftup))->prorettype == FLOAT8OID)
{
RegProcedure convertproc = (RegProcedure) ftup->t_data->t_oid;
Datum converted = (Datum) fmgr(convertproc, value);
*scaleval = (double) (* DatumGetFloat64(converted));
return true;
/*
* See whether there is a registered type-conversion
* function, namely a procedure named "float8" with the
* right signature. If so, assume we can convert the value
* to the numeric scale.
*
* NOTE: there are no such procedures in the standard
* distribution, except with argument types that we
* already dealt with above. This code is just here as an
* escape for user-defined types.
*/
Oid oid_array[FUNC_MAX_ARGS];
HeapTuple ftup;
MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
oid_array[0] = typid;
ftup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum("float8"),
Int32GetDatum(1),
PointerGetDatum(oid_array),
0);
if (HeapTupleIsValid(ftup) &&
((Form_pg_proc) GETSTRUCT(ftup))->prorettype == FLOAT8OID)
{
RegProcedure convertproc = (RegProcedure) ftup->t_data->t_oid;
Datum converted = (Datum) fmgr(convertproc, value);
*scaleval = (double) (*DatumGetFloat64(converted));
return true;
}
break;
}
break;
}
}
/* Don't know how to convert */
return false;
@@ -649,16 +678,18 @@ static bool
convert_string_to_scalar(char *str, int strlength,
double *scaleval)
{
unsigned char *sptr;
int slen;
unsigned char *sptr;
int slen;
#ifdef USE_LOCALE
char *rawstr;
char *xfrmstr;
size_t xfrmsize;
size_t xfrmlen;
char *rawstr;
char *xfrmstr;
size_t xfrmsize;
size_t xfrmlen;
#endif
double num,
denom;
double num,
denom;
if (strlength <= 0)
{
@@ -680,8 +711,8 @@ convert_string_to_scalar(char *str, int strlength,
{
/* Oops, didn't make it */
pfree(xfrmstr);
xfrmstr = (char *) palloc(xfrmlen+1);
xfrmlen = strxfrm(xfrmstr, rawstr, xfrmlen+1);
xfrmstr = (char *) palloc(xfrmlen + 1);
xfrmlen = strxfrm(xfrmstr, rawstr, xfrmlen + 1);
}
pfree(rawstr);
@@ -730,7 +761,7 @@ getattproperties(Oid relid, AttrNumber attnum,
ObjectIdGetDatum(relid),
Int16GetDatum(attnum),
0, 0);
if (! HeapTupleIsValid(atp))
if (!HeapTupleIsValid(atp))
elog(ERROR, "getattproperties: no attribute tuple %u %d",
relid, (int) attnum);
att_tup = (Form_pg_attribute) GETSTRUCT(atp);
@@ -778,14 +809,14 @@ getattstatistics(Oid relid,
bool isnull;
/*
* We assume that there will only be one entry in pg_statistic for
* the given rel/att, so we search WITHOUT considering the staop
* column. Someday, VACUUM might store more than one entry per rel/att,
* We assume that there will only be one entry in pg_statistic for the
* given rel/att, so we search WITHOUT considering the staop column.
* Someday, VACUUM might store more than one entry per rel/att,
* corresponding to more than one possible sort ordering defined for
* the column type. However, to make that work we will need to figure
* out which staop to search for --- it's not necessarily the one we
* have at hand! (For example, we might have a '>' operator rather than
* the '<' operator that will appear in staop.)
* have at hand! (For example, we might have a '>' operator rather
* than the '<' operator that will appear in staop.)
*/
tuple = SearchSysCacheTuple(STATRELID,
ObjectIdGetDatum(relid),
@@ -807,20 +838,22 @@ getattstatistics(Oid relid,
typeTuple = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(typid),
0, 0, 0);
if (! HeapTupleIsValid(typeTuple))
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "getattstatistics: Cache lookup failed for type %u",
typid);
fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc);
typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem;
/* Values are variable-length fields, so cannot access as struct fields.
* Must do it the hard way with SysCacheGetAttr.
/*
* Values are variable-length fields, so cannot access as struct
* fields. Must do it the hard way with SysCacheGetAttr.
*/
if (commonval)
{
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_stacommonval,
&isnull);
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_stacommonval,
&isnull);
if (isnull)
{
elog(DEBUG, "getattstatistics: stacommonval is null");
@@ -828,7 +861,8 @@ getattstatistics(Oid relid,
}
else
{
char *strval = textout(val);
char *strval = textout(val);
*commonval = (Datum)
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
@@ -837,9 +871,10 @@ getattstatistics(Oid relid,
if (loval)
{
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_staloval,
&isnull);
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_staloval,
&isnull);
if (isnull)
{
elog(DEBUG, "getattstatistics: staloval is null");
@@ -847,7 +882,8 @@ getattstatistics(Oid relid,
}
else
{
char *strval = textout(val);
char *strval = textout(val);
*loval = (Datum)
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
@@ -856,9 +892,10 @@ getattstatistics(Oid relid,
if (hival)
{
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_stahival,
&isnull);
text *val = (text *) SysCacheGetAttr(STATRELID, tuple,
Anum_pg_statistic_stahival,
&isnull);
if (isnull)
{
elog(DEBUG, "getattstatistics: stahival is null");
@@ -866,7 +903,8 @@ getattstatistics(Oid relid,
}
else
{
char *strval = textout(val);
char *strval = textout(val);
*hival = (Datum)
(*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
@@ -894,11 +932,11 @@ genericcostestimate(Query *root, RelOptInfo *rel,
Cost *indexTotalCost,
Selectivity *indexSelectivity)
{
double numIndexTuples;
double numIndexPages;
double numIndexTuples;
double numIndexPages;
/* Estimate the fraction of main-table tuples that will be visited */
*indexSelectivity = clauselist_selectivity(root, indexQuals,
*indexSelectivity = clauselist_selectivity(root, indexQuals,
lfirsti(rel->relids));
/* Estimate the number of index tuples that will be visited */
@@ -908,8 +946,8 @@ genericcostestimate(Query *root, RelOptInfo *rel,
numIndexPages = *indexSelectivity * index->pages;
/*
* Always estimate at least one tuple and page are touched,
* even when indexSelectivity estimate is tiny.
* Always estimate at least one tuple and page are touched, even when
* indexSelectivity estimate is tiny.
*/
if (numIndexTuples < 1.0)
numIndexTuples = 1.0;
@@ -921,11 +959,12 @@ genericcostestimate(Query *root, RelOptInfo *rel,
*
* Our generic assumption is that the index pages will be read
* sequentially, so they have cost 1.0 each, not random_page_cost.
* Also, we charge for evaluation of the indexquals at each index tuple.
* All the costs are assumed to be paid incrementally during the scan.
*/
*indexStartupCost = 0;
*indexTotalCost = numIndexPages +
* Also, we charge for evaluation of the indexquals at each index
* tuple. All the costs are assumed to be paid incrementally during
* the scan.
*/
*indexStartupCost = 0;
*indexTotalCost = numIndexPages +
(cpu_index_tuple_cost + cost_qual_eval(indexQuals)) * numIndexTuples;
}
@@ -941,7 +980,7 @@ btcostestimate(Query *root, RelOptInfo *rel,
Selectivity *indexSelectivity)
{
genericcostestimate(root, rel, index, indexQuals,
indexStartupCost, indexTotalCost, indexSelectivity);
indexStartupCost, indexTotalCost, indexSelectivity);
}
void
@@ -952,7 +991,7 @@ rtcostestimate(Query *root, RelOptInfo *rel,
Selectivity *indexSelectivity)
{
genericcostestimate(root, rel, index, indexQuals,
indexStartupCost, indexTotalCost, indexSelectivity);
indexStartupCost, indexTotalCost, indexSelectivity);
}
void
@@ -963,7 +1002,7 @@ hashcostestimate(Query *root, RelOptInfo *rel,
Selectivity *indexSelectivity)
{
genericcostestimate(root, rel, index, indexQuals,
indexStartupCost, indexTotalCost, indexSelectivity);
indexStartupCost, indexTotalCost, indexSelectivity);
}
void
@@ -974,5 +1013,5 @@ gistcostestimate(Query *root, RelOptInfo *rel,
Selectivity *indexSelectivity)
{
genericcostestimate(root, rel, index, indexQuals,
indexStartupCost, indexTotalCost, indexSelectivity);
indexStartupCost, indexTotalCost, indexSelectivity);
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.15 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.16 2000/04/12 17:15:51 momjian Exp $
*
* NOTES
* input routine largely stolen from boxin().
@@ -31,7 +31,7 @@
ItemPointer
tidin(const char *str)
{
const char *p,
const char *p,
*coord[NTIDARGS];
int i;
ItemPointer result;
@@ -105,25 +105,21 @@ bool
tideq(ItemPointer arg1, ItemPointer arg2)
{
if ((!arg1) || (!arg2))
{
return false;
}
return ( BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
arg1->ip_posid == arg2->ip_posid );
return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
arg1->ip_posid == arg2->ip_posid);
}
bool
tidne(ItemPointer arg1, ItemPointer arg2)
{
if ((!arg1) || (!arg2))
{
return false;
}
return ( BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
arg1->ip_posid != arg2->ip_posid );
return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
arg1->ip_posid != arg2->ip_posid);
}
text *
@@ -131,7 +127,8 @@ tid_text(ItemPointer tid)
{
char *str;
if (!tid) return (text *)NULL;
if (!tid)
return (text *) NULL;
str = tidout(tid);
return textin(str);
@@ -140,10 +137,11 @@ tid_text(ItemPointer tid)
ItemPointer
text_tid(const text *string)
{
ItemPointer result;
char *str;
ItemPointer result;
char *str;
if (!string) return (ItemPointer)0;
if (!string)
return (ItemPointer) 0;
str = textout((text *) string);
result = tidin(str);
@@ -162,7 +160,8 @@ text_tid(const text *string)
ItemPointer
currtid_byreloid(Oid reloid, ItemPointer tid)
{
ItemPointer result = NULL, ret;
ItemPointer result = NULL,
ret;
Relation rel;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
@@ -183,11 +182,13 @@ currtid_byreloid(Oid reloid, ItemPointer tid)
ItemPointer
currtid_byrelname(const text *relname, ItemPointer tid)
{
ItemPointer result = NULL, ret;
char *str;
ItemPointer result = NULL,
ret;
char *str;
Relation rel;
if (!relname) return result;
if (!relname)
return result;
str = textout((text *) relname);
@@ -201,7 +202,7 @@ currtid_byrelname(const text *relname, ItemPointer tid)
heap_close(rel, AccessShareLock);
}
else
elog(ERROR, "Relation %s not found", textout((text *)relname));
elog(ERROR, "Relation %s not found", textout((text *) relname));
pfree(str);
return result;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.24 2000/04/07 13:39:41 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.25 2000/04/12 17:15:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,10 +42,10 @@ static double time2t(const int hour, const int min, const double sec);
/* timestamp_in()
* Convert a string to internal form.
*/
Timestamp *
Timestamp *
timestamp_in(char *str)
{
Timestamp *result;
Timestamp *result;
double fsec;
struct tm tt,
@@ -249,10 +249,10 @@ EncodeSpecialTimestamp(Timestamp dt, char *str)
return FALSE;
} /* EncodeSpecialTimestamp() */
Timestamp *
Timestamp *
now(void)
{
Timestamp *result;
Timestamp *result;
AbsoluteTime sec;
result = palloc(sizeof(Timestamp));
@@ -469,9 +469,9 @@ tm2interval(struct tm * tm, double fsec, Interval *span)
{
span->month = ((tm->tm_year * 12) + tm->tm_mon);
span->time = ((((((tm->tm_mday * 24.0)
+ tm->tm_hour) * 60.0)
+ tm->tm_min) * 60.0)
+ tm->tm_sec);
+ tm->tm_hour) * 60.0)
+ tm->tm_min) * 60.0)
+ tm->tm_sec);
span->time = JROUND(span->time + fsec);
return 0;
@@ -562,7 +562,7 @@ SetTimestamp(Timestamp dt)
return dt;
} /* SetTimestamp() */
/* timestamp_relop - is timestamp1 relop timestamp2
/* timestamp_relop - is timestamp1 relop timestamp2
*/
bool
timestamp_eq(Timestamp *timestamp1, Timestamp *timestamp2)
@@ -896,13 +896,15 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
/* Make sure we have ordered pairs... */
if (timestamp_gt(ts1, te1))
{
Timestamp *tt = ts1;
Timestamp *tt = ts1;
ts1 = te1;
te1 = tt;
}
if (timestamp_gt(ts2, te2))
{
Timestamp *tt = ts2;
Timestamp *tt = ts2;
ts2 = te2;
te2 = tt;
}
@@ -910,7 +912,7 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
return ((timestamp_gt(ts1, ts2) && (timestamp_lt(ts1, te2) || timestamp_lt(te1, te2)))
|| (timestamp_gt(ts2, ts1) && (timestamp_lt(ts2, te1) || timestamp_lt(te2, te1)))
|| timestamp_eq(ts1, ts2));
} /* overlaps_timestamp() */
} /* overlaps_timestamp() */
/*----------------------------------------------------------
@@ -921,10 +923,10 @@ overlaps_timestamp(Timestamp *ts1, Timestamp *te1, Timestamp *ts2, Timestamp *te
* actual value.
*---------------------------------------------------------*/
Timestamp *
Timestamp *
timestamp_smaller(Timestamp *timestamp1, Timestamp *timestamp2)
{
Timestamp *result;
Timestamp *result;
Timestamp dt1,
dt2;
@@ -952,10 +954,10 @@ timestamp_smaller(Timestamp *timestamp1, Timestamp *timestamp2)
return result;
} /* timestamp_smaller() */
Timestamp *
Timestamp *
timestamp_larger(Timestamp *timestamp1, Timestamp *timestamp2)
{
Timestamp *result;
Timestamp *result;
Timestamp dt1,
dt2;
@@ -1028,10 +1030,10 @@ timestamp_mi(Timestamp *timestamp1, Timestamp *timestamp2)
* to the last day of month.
* Lastly, add in the "quantitative time".
*/
Timestamp *
Timestamp *
timestamp_pl_span(Timestamp *timestamp, Interval *span)
{
Timestamp *result;
Timestamp *result;
Timestamp dt;
int tz;
char *tzn;
@@ -1099,10 +1101,10 @@ timestamp_pl_span(Timestamp *timestamp, Interval *span)
return result;
} /* timestamp_pl_span() */
Timestamp *
Timestamp *
timestamp_mi_span(Timestamp *timestamp, Interval *span)
{
Timestamp *result;
Timestamp *result;
Interval tspan;
if (!PointerIsValid(timestamp) || !PointerIsValid(span))
@@ -1485,10 +1487,10 @@ timestamp_text(Timestamp *timestamp)
* Text type is not null terminated, so use temporary string
* then call the standard input routine.
*/
Timestamp *
Timestamp *
text_timestamp(text *str)
{
Timestamp *result;
Timestamp *result;
int i;
char *sp,
*dp,
@@ -1571,10 +1573,10 @@ text_interval(text *str)
/* timestamp_trunc()
* Extract specified field from timestamp.
*/
Timestamp *
Timestamp *
timestamp_trunc(text *units, Timestamp *timestamp)
{
Timestamp *result;
Timestamp *result;
Timestamp dt;
int tz;

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.59 2000/03/13 01:54:07 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.60 2000/04/12 17:15:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,6 +24,7 @@
#ifdef CYR_RECODE
char *convertstr(char *, int, int);
#endif

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.57 2000/03/24 02:41:46 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.58 2000/04/12 17:15:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -682,9 +682,9 @@ byteaGetBit(bytea *v, int32 n)
len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len*8)
if (n < 0 || n >= len * 8)
elog(ERROR, "byteaGetBit: index %d out of range [0..%d]",
n, len*8 - 1);
n, len * 8 - 1);
byteNo = n / 8;
bitNo = n % 8;
@@ -757,9 +757,9 @@ byteaSetBit(bytea *v, int32 n, int32 newBit)
len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len*8)
if (n < 0 || n >= len * 8)
elog(ERROR, "byteaSetBit: index %d out of range [0..%d]",
n, len*8 - 1);
n, len * 8 - 1);
byteNo = n / 8;
bitNo = n % 8;