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

pgindent run on all C files. Java run to follow. initdb/regression

tests pass.
This commit is contained in:
Bruce Momjian
2001-10-25 05:50:21 +00:00
parent 59da2105d8
commit b81844b173
818 changed files with 21684 additions and 20491 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.64 2001/06/14 01:09:22 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.65 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,11 +38,11 @@ static bool aclitemgt(const AclItem *a1, const AclItem *a2);
static AclMode convert_priv_string(text *priv_type_text);
static bool has_table_privilege_cname_cname(char *username, char *relname,
text *priv_type_text);
text *priv_type_text);
static bool has_table_privilege_cname_id(char *username, Oid reloid,
text *priv_type_text);
text *priv_type_text);
static bool has_table_privilege_id_cname(int32 usesysid, char *relname,
text *priv_type_text);
text *priv_type_text);
/*
@@ -394,7 +394,7 @@ acldefault(const char *relname, AclId ownerid)
/*
* Add or replace an item in an ACL array. The result is a modified copy;
* Add or replace an item in an ACL array. The result is a modified copy;
* the input object is not changed.
*
* NB: caller is responsible for having detoasted the input ACL, if needed.
@@ -622,7 +622,7 @@ aclmakepriv(const char *old_privlist, char new_priv)
int l;
Assert(strlen(old_privlist) <= strlen(ACL_MODE_STR));
priv = palloc(strlen(ACL_MODE_STR)+1);
priv = palloc(strlen(ACL_MODE_STR) + 1);
if (old_privlist == NULL || old_privlist[0] == '\0')
{
@@ -687,7 +687,7 @@ char *
makeAclString(const char *privileges, const char *grantee, char grant_or_revoke)
{
StringInfoData str;
char *ret;
char *ret;
initStringInfo(&str);
@@ -731,7 +731,7 @@ has_table_privilege_name_name(PG_FUNCTION_ARGS)
{
Name username = PG_GETARG_NAME(0);
Name relname = PG_GETARG_NAME(1);
text *priv_type_text = PG_GETARG_TEXT_P(2);
text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_cname_cname(NameStr(*username),
@@ -757,7 +757,7 @@ Datum
has_table_privilege_name(PG_FUNCTION_ARGS)
{
Name relname = PG_GETARG_NAME(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
text *priv_type_text = PG_GETARG_TEXT_P(1);
int32 usesysid;
bool result;
@@ -786,7 +786,7 @@ has_table_privilege_name_id(PG_FUNCTION_ARGS)
{
Name username = PG_GETARG_NAME(0);
Oid reloid = PG_GETARG_OID(1);
text *priv_type_text = PG_GETARG_TEXT_P(2);
text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_cname_id(NameStr(*username),
@@ -812,7 +812,7 @@ Datum
has_table_privilege_id(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
text *priv_type_text = PG_GETARG_TEXT_P(1);
char *relname;
int32 usesysid;
AclMode mode;
@@ -828,12 +828,12 @@ has_table_privilege_id(PG_FUNCTION_ARGS)
elog(ERROR, "has_table_privilege: invalid relation oid %u",
reloid);
/*
/*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
/*
/*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);
@@ -860,7 +860,7 @@ has_table_privilege_id_name(PG_FUNCTION_ARGS)
{
int32 usesysid = PG_GETARG_INT32(0);
Name relname = PG_GETARG_NAME(1);
text *priv_type_text = PG_GETARG_TEXT_P(2);
text *priv_type_text = PG_GETARG_TEXT_P(2);
bool result;
result = has_table_privilege_id_cname(usesysid,
@@ -886,8 +886,8 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS)
{
int32 usesysid = PG_GETARG_INT32(0);
Oid reloid = PG_GETARG_OID(1);
text *priv_type_text = PG_GETARG_TEXT_P(2);
char *relname;
text *priv_type_text = PG_GETARG_TEXT_P(2);
char *relname;
AclMode mode;
int32 result;
@@ -899,12 +899,12 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS)
elog(ERROR, "has_table_privilege: invalid relation oid %u",
reloid);
/*
/*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
/*
/*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);
@@ -931,7 +931,7 @@ has_table_privilege_id_id(PG_FUNCTION_ARGS)
static AclMode
convert_priv_string(text *priv_type_text)
{
char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text)));
char *priv_type = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
@@ -958,6 +958,7 @@ convert_priv_string(text *priv_type_text)
return ACL_TRIGGER;
elog(ERROR, "has_table_privilege: invalid privilege type %s", priv_type);
/*
* We should never get here, but stop the compiler from complaining
*/
@@ -986,8 +987,8 @@ has_table_privilege_cname_cname(char *username, char *relname,
usesysid = get_usesysid(username);
/*
* Make use of has_table_privilege_id_cname.
* It accepts the arguments we now have.
* Make use of has_table_privilege_id_cname. It accepts the arguments
* we now have.
*/
return has_table_privilege_id_cname(usesysid, relname, priv_type_text);
}
@@ -1008,7 +1009,7 @@ has_table_privilege_cname_id(char *username, Oid reloid,
text *priv_type_text)
{
int32 usesysid;
char *relname;
char *relname;
/*
* Lookup userid based on username
@@ -1024,8 +1025,8 @@ has_table_privilege_cname_id(char *username, Oid reloid,
reloid);
/*
* Make use of has_table_privilege_id_cname.
* It accepts the arguments we now have.
* Make use of has_table_privilege_id_cname. It accepts the arguments
* we now have.
*/
return has_table_privilege_id_cname(usesysid, relname, priv_type_text);
}
@@ -1050,10 +1051,9 @@ has_table_privilege_id_cname(int32 usesysid, char *relname,
int32 result;
/*
* Check relname is valid.
* This is needed to deal with the case when usename is a superuser
* in which case pg_aclcheck simply returns ACLCHECK_OK
* without validating relname
* Check relname is valid. This is needed to deal with the case when
* usename is a superuser in which case pg_aclcheck simply returns
* ACLCHECK_OK without validating relname
*/
tuple = SearchSysCache(RELNAME,
PointerGetDatum(relname),
@@ -1063,12 +1063,12 @@ has_table_privilege_id_cname(int32 usesysid, char *relname,
relname);
ReleaseSysCache(tuple);
/*
/*
* Convert priv_type_text to an AclMode
*/
mode = convert_priv_string(priv_type_text);
/*
/*
* Finally, check for the privilege
*/
result = pg_aclcheck(relname, usesysid, mode);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.70 2001/03/22 03:59:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.71 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -764,7 +764,6 @@ array_ref(ArrayType *array,
if (arraylen > 0)
{
/*
* fixed-length arrays -- these are assumed to be 1-d, 0-based
*/
@@ -815,7 +814,7 @@ array_ref(ArrayType *array,
* lowerIndx[] and upperIndx[]. These are generally just temporaries.
*-----------------------------------------------------------------------------
*/
ArrayType *
ArrayType *
array_get_slice(ArrayType *array,
int nSubscripts,
int *upperIndx,
@@ -841,7 +840,6 @@ array_get_slice(ArrayType *array,
if (arraylen > 0)
{
/*
* fixed-length arrays -- currently, cannot slice these because
* parser labels output as being of the fixed-length array type!
@@ -926,7 +924,7 @@ array_get_slice(ArrayType *array,
* with NULL, which will probably not make him happy.
*-----------------------------------------------------------------------------
*/
ArrayType *
ArrayType *
array_set(ArrayType *array,
int nSubscripts,
int *indx,
@@ -958,7 +956,6 @@ array_set(ArrayType *array,
if (arraylen > 0)
{
/*
* fixed-length arrays -- these are assumed to be 1-d, 0-based. We
* cannot extend them, either.
@@ -1090,7 +1087,7 @@ array_set(ArrayType *array,
* with NULL, which will probably not make him happy.
*----------------------------------------------------------------------------
*/
ArrayType *
ArrayType *
array_set_slice(ArrayType *array,
int nSubscripts,
int *upperIndx,
@@ -1123,7 +1120,6 @@ array_set_slice(ArrayType *array,
if (arraylen > 0)
{
/*
* fixed-length arrays -- not got round to doing this...
*/
@@ -1192,7 +1188,6 @@ array_set_slice(ArrayType *array,
olddatasize = ARR_SIZE(array) - overheadlen;
if (ndim > 1)
{
/*
* here we do not need to cope with extension of the array; it
* would be a lot more complicated if we had to do so...
@@ -1203,7 +1198,6 @@ array_set_slice(ArrayType *array,
}
else
{
/*
* here we must allow for possibility of slice larger than orig
* array
@@ -1237,7 +1231,6 @@ array_set_slice(ArrayType *array,
if (ndim > 1)
{
/*
* here we do not need to cope with extension of the array; it
* would be a lot more complicated if we had to do so...
@@ -1401,7 +1394,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
* NULL element values are not supported.
*----------
*/
ArrayType *
ArrayType *
construct_array(Datum *elems, int nelems,
bool elmbyval, int elmlen, char elmalign)
{

View File

@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* ascii.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.9 2001/09/06 04:57:29 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.10 2001/10/25 05:49:43 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
@@ -80,7 +80,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
if (enc == PG_LATIN1)
{
/*
* ISO-8859-1 <range: 160 -- 255>
*/
@@ -89,7 +88,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
}
else if (enc == PG_LATIN2)
{
/*
* ISO-8859-2 <range: 160 -- 255>
*/
@@ -98,7 +96,6 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
}
else if (enc == PG_WIN1250)
{
/*
* Window CP1250 <range: 128 -- 255>
*/
@@ -151,13 +148,13 @@ Datum
to_ascii_encname(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1)))
)
);
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
pg_char_to_encoding(NameStr(*PG_GETARG_NAME(1)))
)
);
}
/* ----------
@@ -168,13 +165,13 @@ Datum
to_ascii_enc(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
PG_GETARG_INT32(1)
)
);
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
PG_GETARG_INT32(1)
)
);
}
/* ----------
@@ -185,13 +182,12 @@ Datum
to_ascii_default(PG_FUNCTION_ARGS)
{
PG_RETURN_TEXT_P
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
GetDatabaseEncoding()
)
);
(
encode_to_ascii
(
PG_GETARG_TEXT_P_COPY(0),
GetDatabaseEncoding()
)
);
}
#endif /* MULTIBYTE */

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.50 2001/03/22 03:59:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.51 2001/10/25 05:49:43 momjian Exp $
*/
#include "postgres.h"
@@ -85,7 +85,6 @@ cash_in(PG_FUNCTION_ARGS)
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
#endif
#ifdef USE_LOCALE
@@ -244,7 +243,6 @@ cash_out(PG_FUNCTION_ARGS)
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
#endif
#ifdef USE_LOCALE

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.31 2001/05/28 21:58:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.32 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -161,9 +161,9 @@ text_char(PG_FUNCTION_ARGS)
char result;
/*
* An empty input string is converted to \0 (for consistency with charin).
* If the input is longer than one character, the excess data is silently
* discarded.
* An empty input string is converted to \0 (for consistency with
* charin). If the input is longer than one character, the excess data
* is silently discarded.
*/
if (VARSIZE(arg1) > VARHDRSZ)
result = *(VARDATA(arg1));
@@ -189,9 +189,7 @@ char_text(PG_FUNCTION_ARGS)
*(VARDATA(result)) = arg1;
}
else
{
VARATT_SIZEP(result) = VARHDRSZ;
}
PG_RETURN_TEXT_P(result);
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.62 2001/10/18 17:30:15 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.63 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -268,7 +268,7 @@ Datum
date_timestamptz(PG_FUNCTION_ARGS)
{
DateADT dateVal = PG_GETARG_DATEADT(0);
TimestampTz result;
TimestampTz result;
struct tm tt,
*tm = &tt;
time_t utime;
@@ -310,7 +310,7 @@ date_timestamptz(PG_FUNCTION_ARGS)
Datum
timestamptz_date(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
DateADT result;
struct tm tt,
*tm = &tt;
@@ -427,6 +427,7 @@ Datum
time_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -506,7 +507,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
TimeTypmod = typmod;
}
*time = (rint(((double) *time)*TimeScale)/TimeScale);
*time = (rint(((double) *time) * TimeScale) / TimeScale);
if (*time >= 86400)
*time -= 86400;
@@ -610,7 +611,6 @@ time_smaller(PG_FUNCTION_ARGS)
Datum
overlaps_time(PG_FUNCTION_ARGS)
{
/*
* The arguments are TimeADT, but we leave them as generic Datums to
* avoid dereferencing nulls (TimeADT is pass-by-reference!)
@@ -679,7 +679,6 @@ overlaps_time(PG_FUNCTION_ARGS)
*/
if (TIMEADT_GT(ts1, ts2))
{
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
@@ -715,7 +714,6 @@ overlaps_time(PG_FUNCTION_ARGS)
}
else
{
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
@@ -937,6 +935,7 @@ Datum
timetz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -1199,7 +1198,6 @@ timetz_mi_interval(PG_FUNCTION_ARGS)
Datum
overlaps_timetz(PG_FUNCTION_ARGS)
{
/*
* The arguments are TimeTzADT *, but we leave them as generic Datums
* for convenience of notation --- and to avoid dereferencing nulls.
@@ -1268,7 +1266,6 @@ overlaps_timetz(PG_FUNCTION_ARGS)
*/
if (TIMETZ_GT(ts1, ts2))
{
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
@@ -1304,7 +1301,6 @@ overlaps_timetz(PG_FUNCTION_ARGS)
}
else
{
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
@@ -1360,7 +1356,7 @@ time_timetz(PG_FUNCTION_ARGS)
Datum
timestamptz_timetz(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimeTzADT *result;
struct tm tt,
*tm = &tt;
@@ -1394,7 +1390,7 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS)
{
DateADT date = PG_GETARG_DATEADT(0);
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
TimestampTz result;
TimestampTz result;
result = date * 86400.0 + time->time + time->zone;
@@ -1477,7 +1473,7 @@ timetz_part(PG_FUNCTION_ARGS)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMETZ units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
@@ -1550,19 +1546,17 @@ timetz_part(PG_FUNCTION_ARGS)
default:
elog(ERROR, "TIMETZ units '%s' not supported",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
result = 0;
}
}
else if ((type == RESERV) && (val == DTK_EPOCH))
{
result = time->time - time->zone;
}
else
{
elog(ERROR, "TIMETZ units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
result = 0;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.74 2001/10/20 01:02:18 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.75 2001/10/25 05:49:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,29 +27,29 @@
static int DecodeNumber(int flen, char *field,
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
static int DecodeNumberField(int len, char *str,
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
int fmask, int *tmask,
struct tm * tm, double *fsec, int *is2digits);
static int DecodeTime(char *str, int fmask, int *tmask,
struct tm * tm, double *fsec);
struct tm * tm, double *fsec);
static int DecodeTimezone(char *str, int *tzp);
static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
static int DecodePosixTimezone(char *str, int *val);
void TrimTrailingZeros(char *str);
void TrimTrailingZeros(char *str);
int day_tab[2][13] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", NULL};
"Thursday", "Friday", "Saturday", NULL};
/*****************************************************************************
@@ -237,7 +237,7 @@ static datetkn australian_datetktbl[] = {
};
static unsigned int australian_szdatetktbl = sizeof australian_datetktbl /
sizeof australian_datetktbl[0];
sizeof australian_datetktbl[0];
static datetkn deltatktbl[] = {
/* text, token, lexval */
@@ -247,41 +247,41 @@ static datetkn deltatktbl[] = {
{"cent", UNITS, DTK_CENTURY}, /* "century" relative */
{"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative */
{DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative */
{"d", UNITS, DTK_DAY}, /* "day" relative */
{DDAY, UNITS, DTK_DAY}, /* "day" relative */
{"days", UNITS, DTK_DAY}, /* "days" relative */
{"dec", UNITS, DTK_DECADE}, /* "decade" relative */
{"decs", UNITS, DTK_DECADE}, /* "decades" relative */
{"d", UNITS, DTK_DAY}, /* "day" relative */
{DDAY, UNITS, DTK_DAY}, /* "day" relative */
{"days", UNITS, DTK_DAY}, /* "days" relative */
{"dec", UNITS, DTK_DECADE}, /* "decade" relative */
{"decs", UNITS, DTK_DECADE},/* "decades" relative */
{DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */
{"decades", UNITS, DTK_DECADE}, /* "decades" relative */
{"h", UNITS, DTK_HOUR}, /* "hour" relative */
{DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
{"hours", UNITS, DTK_HOUR}, /* "hours" relative */
{"hr", UNITS, DTK_HOUR}, /* "hour" relative */
{"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
{"h", UNITS, DTK_HOUR}, /* "hour" relative */
{DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
{"hours", UNITS, DTK_HOUR}, /* "hours" relative */
{"hr", UNITS, DTK_HOUR}, /* "hour" relative */
{"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
{INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
{"m", UNITS, DTK_MINUTE}, /* "minute" relative */
{"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
{"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
{DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
{"millisecon", UNITS, DTK_MILLISEC}, /* relative */
{"m", UNITS, DTK_MINUTE}, /* "minute" relative */
{"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
{"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
{DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
{"millisecon", UNITS, DTK_MILLISEC}, /* relative */
{"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
{"min", UNITS, DTK_MINUTE}, /* "minute" relative */
{"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
{"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
{"min", UNITS, DTK_MINUTE}, /* "minute" relative */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative */
{"mins", UNITS, DTK_MINUTE},/* "minutes" relative */
{DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */
{"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative */
{"mon", UNITS, DTK_MONTH}, /* "months" relative */
{"mons", UNITS, DTK_MONTH}, /* "months" relative */
{DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
{"mon", UNITS, DTK_MONTH}, /* "months" relative */
{"mons", UNITS, DTK_MONTH}, /* "months" relative */
{DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
{"months", UNITS, DTK_MONTH},
{"ms", UNITS, DTK_MILLISEC},
{"msec", UNITS, DTK_MILLISEC},
{DMILLISEC, UNITS, DTK_MILLISEC},
{"mseconds", UNITS, DTK_MILLISEC},
{"msecs", UNITS, DTK_MILLISEC},
{"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
{"qtr", UNITS, DTK_QUARTER},/* "quarter" relative */
{DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
{"reltime", IGNORE, 0}, /* pre-v6.1 "Undefined Reltime" */
{"s", UNITS, DTK_SECOND},
@@ -289,12 +289,12 @@ static datetkn deltatktbl[] = {
{DSECOND, UNITS, DTK_SECOND},
{"seconds", UNITS, DTK_SECOND},
{"secs", UNITS, DTK_SECOND},
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"timezone", UNITS, DTK_TZ}, /* "timezone" time offset */
{"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
{"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
{"timezone", UNITS, DTK_TZ},/* "timezone" time offset */
{"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
{"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
{"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
{"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"us", UNITS, DTK_MICROSEC},/* "microsecond" relative */
{"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
{"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
@@ -391,7 +391,7 @@ j2day(int date)
void
TrimTrailingZeros(char *str)
{
int len = strlen(str);
int len = strlen(str);
#if 0
/* chop off trailing one to cope with interval rounding */
@@ -585,7 +585,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
int fmask = 0,
tmask,
type;
int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */
int ptype = 0; /* "prefix type" for ISO y2001m02d04
* format */
int i;
int flen,
val;
@@ -594,16 +595,17 @@ DecodeDateTime(char **field, int *ftype, int nf,
int is2digits = FALSE;
int bc = FALSE;
/* We'll insist on at least all of the date fields,
* but initialize the remaining fields in case they are not
* set later...
/*
* We'll insist on at least all of the date fields, but initialize the
* remaining fields in case they are not set later...
*/
*dtype = DTK_DATE;
tm->tm_hour = 0;
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;
@@ -612,13 +614,17 @@ DecodeDateTime(char **field, int *ftype, int nf,
switch (ftype[i])
{
case DTK_DATE:
/* Previous field was a label for "julian date"?
* then this should be a julian date with fractional day...
/*
* Previous field was a label for "julian date"? then this
* should be a julian date with fractional day...
*/
if (ptype == JULIAN)
{
char *cp;
double dt, date, time;
char *cp;
double dt,
date,
time;
dt = strtod(field[i], &cp);
if (*cp != '\0')
@@ -633,9 +639,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
*dtype = 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
*/
else if ((fmask & DTK_DATE_M) == DTK_DATE_M)
{
@@ -647,16 +654,15 @@ DecodeDateTime(char **field, int *ftype, int nf,
tmask = DTK_M(TZ);
}
else if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
{
return -1;
}
break;
case DTK_TIME:
if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
return -1;
/* Check upper limit on hours; other limits checked in
/*
* Check upper limit on hours; other limits checked in
* DecodeTime()
*/
if (tm->tm_hour > 23)
@@ -696,19 +702,21 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_NUMBER:
flen = strlen(field[i]);
/* Was this an "ISO date" with embedded field labels?
* An example is "y2001m02d04" - thomas 2001-02-04
/*
* Was this an "ISO date" with embedded field labels? An
* example is "y2001m02d04" - thomas 2001-02-04
*/
if (ptype != 0)
{
char *cp;
int val;
char *cp;
int val;
val = strtol(field[i], &cp, 10);
if (*cp != '\0')
return -1;
switch (ptype) {
switch (ptype)
{
case YEAR:
tm->tm_year = val;
tmask = DTK_M(ptype);
@@ -740,9 +748,12 @@ DecodeDateTime(char **field, int *ftype, int nf,
break;
case JULIAN:
/* previous field was a label for "julian date"?
* then this is a julian day with no fractional part
* (see DTK_DATE for cases involving fractional parts)
/*
* previous field was a label for "julian
* date"? then this is a julian day with no
* fractional part (see DTK_DATE for cases
* involving fractional parts)
*/
j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
@@ -757,6 +768,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
ptype = 0;
*dtype = DTK_DATE;
}
/*
* long numeric string and either no date or no time read
* yet? then interpret as a concatenated date or time...
@@ -769,9 +781,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
}
/* otherwise it is a single date/time field... */
else if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0)
{
return -1;
}
break;
case DTK_STRING:
@@ -916,9 +926,9 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_ISO_TIME:
tmask = 0;
if ((i < 1) || (i >= (nf-1))
|| (ftype[i-1] != DTK_DATE)
|| (ftype[i+1] != DTK_TIME))
if ((i < 1) || (i >= (nf - 1))
|| (ftype[i - 1] != DTK_DATE)
|| (ftype[i + 1] != DTK_TIME))
return -1;
break;
@@ -977,7 +987,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
if (((fmask & DTK_DATE_M) == DTK_DATE_M)
&& (tzp != NULL) && (!(fmask & DTK_M(TZ))))
{
/*
* daylight savings time modifier but no standard timezone?
* then error
@@ -1008,16 +1017,16 @@ DetermineLocalTimeZone(struct tm * tm)
int tz;
if (HasCTZSet)
{
tz = CTimeZone;
}
else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
/*
* Some buggy mktime() implementations may change the year/month/day
* when given a time right at a DST boundary. To prevent corruption
* of the caller's data, give mktime() a copy...
* Some buggy mktime() implementations may change the
* year/month/day when given a time right at a DST boundary. To
* prevent corruption of the caller's data, give mktime() a
* copy...
*/
struct tm tt,
*tmp = &tt;
@@ -1500,9 +1509,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
* 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
*/
else if (flen >= 4)
@@ -1745,7 +1753,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
tp = NULL;
if (Australian_timezones)
tp = datebsearch(lowtoken, australian_datetktbl,
australian_szdatetktbl);
australian_szdatetktbl);
if (!tp)
tp = datebsearch(lowtoken, datetktbl, szdatetktbl);
}
@@ -1863,7 +1871,6 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do
{
if (*cp == '.')
{
/*
* Got a decimal point? Then assume some sort of
* seconds specification
@@ -1872,7 +1879,6 @@ DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, do
}
else if (*cp == '\0')
{
/*
* Only a signed integer? Then must assume a
* timezone-like usage
@@ -2062,9 +2068,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
&& (strncmp(lowtoken, deltacache[field]->token, TOKMAXLEN) == 0))
tp = deltacache[field];
else
{
tp = datebsearch(lowtoken, deltatktbl, szdeltatktbl);
}
deltacache[field] = tp;
if (tp == NULL)
{
@@ -2189,25 +2193,23 @@ EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str)
sprintf(str, "%02d:%02d", tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
/*
* If we have fractional seconds, then include a decimal point We will
* do up to 6 fractional digits, and we have rounded any inputs to
* eliminate anything to the right of 6 digits anyway. If there are no
* fractional seconds, then do not bother printing a decimal point at
* all. - thomas 2001-09-29
*/
if (fsec != 0) {
if (fsec != 0)
{
sprintf((str + strlen(str)), ":%013.10f", sec);
/* chop off trailing pairs of zeros... */
while ((strcmp((str + strlen(str) - 2), "00") == 0)
&& (*(str + strlen(str) - 3) != '.'))
{
*(str + strlen(str) - 2) = '\0';
}
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if (tzp != NULL)
{
@@ -2257,24 +2259,28 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
sprintf(str, "%04d-%02d-%02d %02d:%02d",
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
/*
* If we have fractional seconds, then include a decimal
* point We will do up to 6 fractional digits, and we have
* rounded any inputs to eliminate anything to the right
* of 6 digits anyway. If there are no fractional seconds,
* then do not bother printing a decimal point at all. -
* thomas 2001-09-29
*/
if (fsec != 0) {
if (fsec != 0)
{
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
/* tzp == NULL indicates that we don't want *any* time zone info in the output string.
* *tzn != NULL indicates that we have alpha time zone info available.
* tm_isdst != -1 indicates that we have a valid time zone translation.
/*
* tzp == NULL indicates that we don't want *any* time
* zone info in the output string. *tzn != NULL indicates
* that we have alpha time zone info available. tm_isdst
* != -1 indicates that we have a valid time zone
* translation.
*/
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
@@ -2306,27 +2312,26 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
sprintf((str + 5), "/%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
/*
* If we have fractional seconds, then include a decimal
* point We will do up to 6 fractional digits, and we have
* rounded any inputs to eliminate anything to the right
* of 6 digits anyway. If there are no fractional seconds,
* then do not bother printing a decimal point at all. -
* thomas 2001-09-29
*/
if (fsec != 0) {
if (fsec != 0)
{
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
{
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
}
else
{
hour = -(*tzp / 3600);
@@ -2348,27 +2353,26 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
sprintf((str + 5), ".%04d %02d:%02d",
tm->tm_year, tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
/*
* If we have fractional seconds, then include a decimal
* point We will do up to 6 fractional digits, and we have
* rounded any inputs to eliminate anything to the right
* of 6 digits anyway. If there are no fractional seconds,
* then do not bother printing a decimal point at all. -
* thomas 2001-09-29
*/
if (fsec != 0) {
if (fsec != 0)
{
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
{
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
}
else
{
hour = -(*tzp / 3600);
@@ -2400,35 +2404,36 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha
{
sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min);
/* If we have fractional seconds, then include a decimal point
* We will do up to 6 fractional digits, and we have rounded any inputs
* to eliminate anything to the right of 6 digits anyway.
* If there are no fractional seconds, then do not bother printing
* a decimal point at all. - thomas 2001-09-29
/*
* If we have fractional seconds, then include a decimal
* point We will do up to 6 fractional digits, and we have
* rounded any inputs to eliminate anything to the right
* of 6 digits anyway. If there are no fractional seconds,
* then do not bother printing a decimal point at all. -
* thomas 2001-09-29
*/
if (fsec != 0) {
if (fsec != 0)
{
sprintf((str + strlen(str)), ":%013.10f", sec);
TrimTrailingZeros(str);
}
else
{
sprintf((str + strlen(str)), ":%02.0f", sec);
}
sprintf((str + strlen(str)), " %04d", tm->tm_year);
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
if (*tzn != NULL)
{
sprintf((str + strlen(str)), " %.*s", MAXTZLEN, *tzn);
}
else
{
/* We have a time zone, but no string version.
* Use the numeric form, but be sure to include a leading space
* to avoid formatting something which would be rejected by the
* date/time parser later. - thomas 2001-10-19
/*
* We have a time zone, but no string version. Use
* the numeric form, but be sure to include a
* leading space to avoid formatting something
* which would be rejected by the date/time parser
* later. - thomas 2001-10-19
*/
hour = -(*tzp / 3600);
min = ((abs(*tzp) / 60) % 60);
@@ -2663,10 +2668,11 @@ EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str)
} /* EncodeTimeSpan() */
void ClearDateCache(bool dummy)
void
ClearDateCache(bool dummy)
{
int i;
int i;
for (i=0; i < MAXDATEFIELDS; i++)
for (i = 0; i < MAXDATEFIELDS; i++)
datecache[i] = NULL;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.21 2001/07/15 22:48:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.22 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -133,7 +133,6 @@ datumFree(Datum value, bool typByVal, int typLen)
pfree(s);
}
}
#endif
/*-------------------------------------------------------------------------
@@ -157,7 +156,6 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen)
if (typByVal)
{
/*
* just compare the two datums. NOTE: just comparing "len" bytes
* will not do the work, because we do not know how these bytes

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.3 2001/09/30 22:03:41 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/encode.c,v 1.4 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,13 +20,13 @@
struct pg_encoding
{
unsigned (*encode_len) (const uint8 *data, unsigned dlen);
unsigned (*decode_len) (const uint8 *data, unsigned dlen);
unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res);
unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res);
unsigned (*encode_len) (const uint8 *data, unsigned dlen);
unsigned (*decode_len) (const uint8 *data, unsigned dlen);
unsigned (*encode) (const uint8 *data, unsigned dlen, uint8 *res);
unsigned (*decode) (const uint8 *data, unsigned dlen, uint8 *res);
};
static struct pg_encoding * pg_find_encoding(const char *name);
static struct pg_encoding *pg_find_encoding(const char *name);
/*
* SQL functions.
@@ -39,7 +39,9 @@ binary_encode(PG_FUNCTION_ARGS)
Datum name = PG_GETARG_DATUM(1);
text *result;
char *namebuf;
int datalen, resultlen, res;
int datalen,
resultlen,
res;
struct pg_encoding *enc;
datalen = VARSIZE(data) - VARHDRSZ;
@@ -70,8 +72,10 @@ binary_decode(PG_FUNCTION_ARGS)
text *data = PG_GETARG_TEXT_P(0);
Datum name = PG_GETARG_DATUM(1);
bytea *result;
char *namebuf;
int datalen, resultlen, res;
char *namebuf;
int datalen,
resultlen,
res;
struct pg_encoding *enc;
datalen = VARSIZE(data) - VARHDRSZ;
@@ -115,9 +119,9 @@ static const int8 hexlookup[128] = {
};
static unsigned
hex_encode(const uint8 * src, unsigned len, uint8 * dst)
hex_encode(const uint8 *src, unsigned len, uint8 *dst)
{
const uint8 *end = src + len;
const uint8 *end = src + len;
while (src < end)
{
@@ -131,7 +135,7 @@ hex_encode(const uint8 * src, unsigned len, uint8 * dst)
static uint8
get_hex(unsigned c)
{
int res = -1;
int res = -1;
if (c > 0 && c < 127)
res = hexlookup[c];
@@ -139,11 +143,11 @@ get_hex(unsigned c)
if (res < 0)
elog(ERROR, "Bad hex code: '%c'", c);
return (uint8)res;
return (uint8) res;
}
static unsigned
hex_decode(const uint8 * src, unsigned len, uint8 * dst)
hex_decode(const uint8 *src, unsigned len, uint8 *dst)
{
const uint8 *s,
*srcend;
@@ -172,13 +176,13 @@ hex_decode(const uint8 * src, unsigned len, uint8 * dst)
}
static unsigned
hex_enc_len(const uint8 * src, unsigned srclen)
hex_enc_len(const uint8 *src, unsigned srclen)
{
return srclen << 1;
}
static unsigned
hex_dec_len(const uint8 * src, unsigned srclen)
hex_dec_len(const uint8 *src, unsigned srclen)
{
return srclen >> 1;
}
@@ -202,7 +206,7 @@ static const int8 b64lookup[128] = {
};
static unsigned
b64_encode(const uint8 * src, unsigned len, uint8 * dst)
b64_encode(const uint8 *src, unsigned len, uint8 *dst)
{
uint8 *p,
*lend = dst + 76;
@@ -249,9 +253,9 @@ b64_encode(const uint8 * src, unsigned len, uint8 * dst)
}
static unsigned
b64_decode(const uint8 * src, unsigned len, uint8 * dst)
b64_decode(const uint8 *src, unsigned len, uint8 *dst)
{
const char *srcend = src + len,
const char *srcend = src + len,
*s = src;
uint8 *p = dst;
unsigned c;
@@ -281,7 +285,8 @@ b64_decode(const uint8 * src, unsigned len, uint8 * dst)
}
b = 0;
}
else {
else
{
b = -1;
if (c > 0 && c < 127)
b = b64lookup[c];
@@ -311,14 +316,14 @@ b64_decode(const uint8 * src, unsigned len, uint8 * dst)
static unsigned
b64_enc_len(const uint8 * src, unsigned srclen)
b64_enc_len(const uint8 *src, unsigned srclen)
{
/* 3 bytes will be converted to 4, linefeed after 76 chars */
return (srclen + 2) * 4 / 3 + srclen / (76 * 3 / 4);
}
static unsigned
b64_dec_len(const uint8 * src, unsigned srclen)
b64_dec_len(const uint8 *src, unsigned srclen)
{
return (srclen * 3) >> 2;
}
@@ -327,10 +332,10 @@ b64_dec_len(const uint8 * src, unsigned srclen)
* Escape
* Minimally escape bytea to text.
* De-escape text to bytea.
*
*
* Only two characters are escaped:
* \0 (null) and \\ (backslash)
*
*
* De-escapes \\ and any \### octal
*/
@@ -340,9 +345,9 @@ b64_dec_len(const uint8 * src, unsigned srclen)
static unsigned
esc_encode(const uint8 *src, unsigned srclen, uint8 *dst)
{
const uint8 *end = src + srclen;
uint8 *rp = dst;
int len = 0;
const uint8 *end = src + srclen;
uint8 *rp = dst;
int len = 0;
while (src < end)
{
@@ -377,22 +382,20 @@ esc_encode(const uint8 *src, unsigned srclen, uint8 *dst)
static unsigned
esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
{
const uint8 *end = src + srclen;
uint8 *rp = dst;
int len = 0;
const uint8 *end = src + srclen;
uint8 *rp = dst;
int len = 0;
while (src < end)
{
if (src[0] != '\\')
{
*rp++ = *src++;
}
else if ( src+3 < end &&
(src[1] >= '0' && src[1] <= '3') &&
(src[2] >= '0' && src[2] <= '7') &&
(src[3] >= '0' && src[3] <= '7') )
else if (src + 3 < end &&
(src[1] >= '0' && src[1] <= '3') &&
(src[2] >= '0' && src[2] <= '7') &&
(src[3] >= '0' && src[3] <= '7'))
{
int val;
int val;
val = VAL(src[1]);
val <<= 3;
@@ -401,8 +404,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
*rp++ = val + VAL(src[3]);
src += 4;
}
else if ( src+1 < end &&
(src[1] == '\\') )
else if (src + 1 < end &&
(src[1] == '\\'))
{
*rp++ = '\\';
src += 2;
@@ -410,8 +413,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
else
{
/*
* One backslash, not followed by ### valid octal.
* Should never get here, since esc_dec_len does same check.
* One backslash, not followed by ### valid octal. Should
* never get here, since esc_dec_len does same check.
*/
elog(ERROR, "decode: Bad input string for type bytea");
}
@@ -425,8 +428,8 @@ esc_decode(const uint8 *src, unsigned srclen, uint8 *dst)
static unsigned
esc_enc_len(const uint8 *src, unsigned srclen)
{
const uint8 *end = src + srclen;
int len = 0;
const uint8 *end = src + srclen;
int len = 0;
while (src < end)
{
@@ -446,27 +449,25 @@ esc_enc_len(const uint8 *src, unsigned srclen)
static unsigned
esc_dec_len(const uint8 *src, unsigned srclen)
{
const uint8 *end = src + srclen;
int len = 0;
const uint8 *end = src + srclen;
int len = 0;
while (src < end)
{
if (src[0] != '\\')
{
src++;
}
else if ( src+3 < end &&
(src[1] >= '0' && src[1] <= '3') &&
(src[2] >= '0' && src[2] <= '7') &&
(src[3] >= '0' && src[3] <= '7') )
else if (src + 3 < end &&
(src[1] >= '0' && src[1] <= '3') &&
(src[2] >= '0' && src[2] <= '7') &&
(src[3] >= '0' && src[3] <= '7'))
{
/*
* backslash + valid octal
*/
src += 4;
}
else if ( src+1 < end &&
(src[1] == '\\') )
else if (src + 1 < end &&
(src[1] == '\\'))
{
/*
* two backslashes = backslash
@@ -490,20 +491,43 @@ esc_dec_len(const uint8 *src, unsigned srclen)
* Common
*/
static struct {
static struct
{
const char *name;
struct pg_encoding enc;
} enclist[] = {
{"hex", { hex_enc_len, hex_dec_len, hex_encode, hex_decode }},
{"base64", { b64_enc_len, b64_dec_len, b64_encode, b64_decode }},
{"escape", { esc_enc_len, esc_dec_len, esc_encode, esc_decode }},
{NULL, { NULL, NULL, NULL, NULL } }
} enclist[] =
{
{
"hex",
{
hex_enc_len, hex_dec_len, hex_encode, hex_decode
}
},
{
"base64",
{
b64_enc_len, b64_dec_len, b64_encode, b64_decode
}
},
{
"escape",
{
esc_enc_len, esc_dec_len, esc_encode, esc_decode
}
},
{
NULL,
{
NULL, NULL, NULL, NULL
}
}
};
static struct pg_encoding *
pg_find_encoding(const char *name)
{
int i;
int i;
for (i = 0; enclist[i].name; i++)
if (strcasecmp(enclist[i].name, name) == 0)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.74 2001/06/07 00:09:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.75 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -71,7 +71,6 @@
#ifndef atof
extern double atof(const char *p);
#endif
#ifndef HAVE_CBRT
@@ -81,7 +80,6 @@ static double cbrt(double x);
#else
#if !defined(nextstep)
extern double cbrt(double x);
#endif
#endif /* HAVE_CBRT */
@@ -91,9 +89,7 @@ static double rint(double x);
#else
extern double rint(double x);
#endif /* HAVE_RINT */
#endif /* NeXT check */
@@ -140,7 +136,6 @@ static void CheckFloat8Val(double val);
static void
CheckFloat4Val(double val)
{
/*
* defining unsafe floats's will make float4 and float8 ops faster at
* the cost of safety, of course!
@@ -165,7 +160,6 @@ CheckFloat4Val(double val)
static void
CheckFloat8Val(double val)
{
/*
* defining unsafe floats's will make float4 and float8 ops faster at
* the cost of safety, of course!
@@ -344,6 +338,7 @@ Datum
float4up(PG_FUNCTION_ARGS)
{
float4 arg = PG_GETARG_FLOAT4(0);
PG_RETURN_FLOAT4(arg);
}
@@ -410,6 +405,7 @@ Datum
float8up(PG_FUNCTION_ARGS)
{
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg);
}
@@ -578,9 +574,9 @@ static int
float4_cmp_internal(float4 a, float4 b)
{
/*
* We consider all NANs to be equal and larger than any non-NAN.
* This is somewhat arbitrary; the important thing is to have a
* consistent sort order.
* We consider all NANs to be equal and larger than any non-NAN. This
* is somewhat arbitrary; the important thing is to have a consistent
* sort order.
*/
if (isnan(a))
{
@@ -674,9 +670,9 @@ static int
float8_cmp_internal(float8 a, float8 b)
{
/*
* We consider all NANs to be equal and larger than any non-NAN.
* This is somewhat arbitrary; the important thing is to have a
* consistent sort order.
* We consider all NANs to be equal and larger than any non-NAN. This
* is somewhat arbitrary; the important thing is to have a consistent
* sort order.
*/
if (isnan(a))
{
@@ -1479,7 +1475,6 @@ setseed(PG_FUNCTION_ARGS)
static float8 *
check_float8_array(ArrayType *transarray, const char *caller)
{
/*
* We expect the input to be a 3-element float array; verify that. We
* don't need to use deconstruct_array() since the array data is just
@@ -1974,7 +1969,6 @@ rint(double x)
w = TWO52[sx] + x;
return w - TWO52[sx];
}
#endif /* !HAVE_RINT */
#ifndef HAVE_CBRT
@@ -1987,5 +1981,4 @@ cbrt(double x)
return isneg ? -tmpres : tmpres;
}
#endif /* !HAVE_CBRT */

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.20 2001/10/23 20:12:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.21 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -216,8 +216,8 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
case INTERVALOID:
if (with_typemod)
{
int fields = typemod >> 16;
int precision = typemod & 0xFFFF;
int fields = typemod >> 16;
int precision = typemod & 0xFFFF;
const char *fieldstr;
switch (fields)

View File

@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.41 2001/09/28 08:09:11 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.42 2001/10/25 05:49:44 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@@ -44,9 +44,9 @@
*
* Karel Zak
*
* TODO
* - better number building (formatting) / parsing, now it isn't
* ideal code
* TODO
* - better number building (formatting) / parsing, now it isn't
* ideal code
* - use Assert()
* - add support for abstime
* - add support for roman number to standard number conversion
@@ -374,11 +374,11 @@ typedef struct
yyyy,
yyy,
yy,
y,
y,
bc,
iw,
ww,
w,
w,
cc,
q,
j,
@@ -414,13 +414,13 @@ typedef struct
*/
typedef struct TmToChar
{
struct tm tm; /* classic 'tm' struct */
double fsec; /* milliseconds */
char *tzn; /* timezone */
struct tm tm; /* classic 'tm' struct */
double fsec; /* milliseconds */
char *tzn; /* timezone */
} TmToChar;
#define tmtcTm(_X) (&(_X)->tm)
#define tmtcTzn(_X) ((_X)->tzn)
#define tmtcTzn(_X) ((_X)->tzn)
#define tmtcFsec(_X) ((_X)->fsec)
#define ZERO_tm( _X ) \
@@ -521,132 +521,132 @@ static KeySuffix DCH_suff[] = {
typedef enum
{
DCH_A_D,
DCH_A_M,
DCH_AD,
DCH_AM,
DCH_B_C,
DCH_BC,
DCH_CC,
DCH_DAY,
DCH_DDD,
DCH_DD,
DCH_DY,
DCH_Day,
DCH_Dy,
DCH_D,
DCH_FX, /* global suffix */
DCH_HH24,
DCH_HH12,
DCH_HH,
DCH_IW,
DCH_J,
DCH_MI,
DCH_MM,
DCH_MONTH,
DCH_MON,
DCH_MS,
DCH_Month,
DCH_Mon,
DCH_P_M,
DCH_PM,
DCH_Q,
DCH_RM,
DCH_SSSS,
DCH_SS,
DCH_TZ,
DCH_US,
DCH_WW,
DCH_W,
DCH_Y_YYY,
DCH_YYYY,
DCH_YYY,
DCH_YY,
DCH_Y,
DCH_a_d,
DCH_a_m,
DCH_ad,
DCH_am,
DCH_b_c,
DCH_bc,
DCH_cc,
DCH_day,
DCH_ddd,
DCH_dd,
DCH_dy,
DCH_d,
DCH_fx,
DCH_hh24,
DCH_hh12,
DCH_hh,
DCH_iw,
DCH_j,
DCH_mi,
DCH_mm,
DCH_month,
DCH_mon,
DCH_ms,
DCH_p_m,
DCH_pm,
DCH_q,
DCH_rm,
DCH_ssss,
DCH_ss,
DCH_tz,
DCH_us,
DCH_ww,
DCH_w,
DCH_y_yyy,
DCH_yyyy,
DCH_yyy,
DCH_yy,
DCH_y,
DCH_A_D,
DCH_A_M,
DCH_AD,
DCH_AM,
DCH_B_C,
DCH_BC,
DCH_CC,
DCH_DAY,
DCH_DDD,
DCH_DD,
DCH_DY,
DCH_Day,
DCH_Dy,
DCH_D,
DCH_FX, /* global suffix */
DCH_HH24,
DCH_HH12,
DCH_HH,
DCH_IW,
DCH_J,
DCH_MI,
DCH_MM,
DCH_MONTH,
DCH_MON,
DCH_MS,
DCH_Month,
DCH_Mon,
DCH_P_M,
DCH_PM,
DCH_Q,
DCH_RM,
DCH_SSSS,
DCH_SS,
DCH_TZ,
DCH_US,
DCH_WW,
DCH_W,
DCH_Y_YYY,
DCH_YYYY,
DCH_YYY,
DCH_YY,
DCH_Y,
DCH_a_d,
DCH_a_m,
DCH_ad,
DCH_am,
DCH_b_c,
DCH_bc,
DCH_cc,
DCH_day,
DCH_ddd,
DCH_dd,
DCH_dy,
DCH_d,
DCH_fx,
DCH_hh24,
DCH_hh12,
DCH_hh,
DCH_iw,
DCH_j,
DCH_mi,
DCH_mm,
DCH_month,
DCH_mon,
DCH_ms,
DCH_p_m,
DCH_pm,
DCH_q,
DCH_rm,
DCH_ssss,
DCH_ss,
DCH_tz,
DCH_us,
DCH_ww,
DCH_w,
DCH_y_yyy,
DCH_yyyy,
DCH_yyy,
DCH_yy,
DCH_y,
/* last */
_DCH_last_
_DCH_last_
} DCH_poz;
typedef enum
{
NUM_COMMA,
NUM_DEC,
NUM_0,
NUM_9,
NUM_B,
NUM_C,
NUM_D,
NUM_E,
NUM_FM,
NUM_G,
NUM_L,
NUM_MI,
NUM_PL,
NUM_PR,
NUM_RN,
NUM_SG,
NUM_SP,
NUM_S,
NUM_TH,
NUM_V,
NUM_b,
NUM_c,
NUM_d,
NUM_e,
NUM_fm,
NUM_g,
NUM_l,
NUM_mi,
NUM_pl,
NUM_pr,
NUM_rn,
NUM_sg,
NUM_sp,
NUM_s,
NUM_th,
NUM_v,
NUM_COMMA,
NUM_DEC,
NUM_0,
NUM_9,
NUM_B,
NUM_C,
NUM_D,
NUM_E,
NUM_FM,
NUM_G,
NUM_L,
NUM_MI,
NUM_PL,
NUM_PR,
NUM_RN,
NUM_SG,
NUM_SP,
NUM_S,
NUM_TH,
NUM_V,
NUM_b,
NUM_c,
NUM_d,
NUM_e,
NUM_fm,
NUM_g,
NUM_l,
NUM_mi,
NUM_pl,
NUM_pr,
NUM_rn,
NUM_sg,
NUM_sp,
NUM_s,
NUM_th,
NUM_v,
/* last */
_NUM_last_
_NUM_last_
} NUM_poz;
/* ----------
@@ -689,7 +689,7 @@ static KeyWord DCH_keywords[] = {
{"SSSS", 4, dch_time, DCH_SSSS, TRUE}, /* S */
{"SS", 2, dch_time, DCH_SS, TRUE},
{"TZ", 2, dch_time, DCH_TZ, FALSE}, /* T */
{"US", 2, dch_time, DCH_US, TRUE}, /* U */
{"US", 2, dch_time, DCH_US, TRUE}, /* U */
{"WW", 2, dch_date, DCH_WW, TRUE}, /* W */
{"W", 1, dch_date, DCH_W, TRUE},
{"Y,YYY", 5, dch_date, DCH_Y_YYY, TRUE}, /* Y */
@@ -883,12 +883,11 @@ static char *DCH_processor(FormatNode *node, char *inout, int flag, void *data);
#ifdef DEBUG_TO_FROM_CHAR
static void dump_index(KeyWord *k, int *index);
static void dump_node(FormatNode *node, int max);
#endif
static char *get_th(char *num, int type);
static char *str_numth(char *dest, char *num, int type);
static int strdigits_len(char *str);
static int strdigits_len(char *str);
static char *str_toupper(char *buff);
static char *str_tolower(char *buff);
@@ -1196,7 +1195,6 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
}
else if (*str)
{
/*
* Special characters '\' and '"'
*/
@@ -1299,7 +1297,6 @@ DCH_processor(FormatNode *node, char *inout, int flag, void *data)
}
else
{
/*
* Remove to output char from input in TO_CHAR
*/
@@ -1308,7 +1305,6 @@ DCH_processor(FormatNode *node, char *inout, int flag, void *data)
else
{
/*
* Skip blank space in FROM_CHAR's input
*/
@@ -1364,8 +1360,7 @@ dump_node(FormatNode *node, int max)
}
}
#endif /* DEBUG */
#endif /* DEBUG */
/*****************************************************************************
* Private utils
@@ -1571,8 +1566,7 @@ dump_index(KeyWord *k, int *index)
elog(DEBUG_elog_output, "\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
count, free_i);
}
#endif /* DEBUG */
#endif /* DEBUG */
/* ----------
* Skip TM / th in FROM_CHAR
@@ -1630,10 +1624,10 @@ is_next_separator(FormatNode *n)
static int
strdigits_len(char *str)
{
char *p = str;
int len = 0;
while (*p && isdigit((unsigned char ) *p) && len <= DCH_MAX_ITEM_SIZ)
char *p = str;
int len = 0;
while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ)
{
len++;
p++;
@@ -1652,12 +1646,12 @@ strdigits_len(char *str)
static int
dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
{
char *p_inout = inout;
struct tm *tm = NULL;
TmFromChar *tmfc = NULL;
TmToChar *tmtc = NULL;
char *p_inout = inout;
struct tm *tm = NULL;
TmFromChar *tmfc = NULL;
TmToChar *tmtc = NULL;
if (flag==TO_CHAR)
if (flag == TO_CHAR)
{
tmtc = (TmToChar *) data;
tm = tmtcTm(tmtc);
@@ -1850,7 +1844,7 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
}
}
break;
case DCH_MS: /* millisecond */
case DCH_MS: /* millisecond */
if (flag == TO_CHAR)
{
sprintf(inout, "%03d", (int) rint(tmtc->fsec * 1000));
@@ -1864,34 +1858,39 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
}
else if (flag == FROM_CHAR)
{
int len, x;
int len,
x;
if (is_next_separator(node))
{
sscanf(inout, "%d", &tmfc->ms);
len = x = strdigits_len(inout);
}
else
else
{
sscanf(inout, "%03d", &tmfc->ms);
x = strdigits_len(inout);
len = x = x > 3 ? 3 : x;
}
/* 25 is 0.25 and 250 is 0.25 too;
* 025 is 0.025 and not 0.25
len = x = x > 3 ? 3 : x;
}
/*
* 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not
* 0.25
*/
tmfc->ms *= x == 1 ? 100 :
x == 2 ? 10 : 1;
/*
* elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms,
* len);
*/
tmfc->ms *= x==1 ? 100 :
x==2 ? 10 : 1;
/* elog(NOTICE, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, len); */
return len - 1 + SKIP_THth(suf);
}
break;
case DCH_US: /* microsecond */
case DCH_US: /* microsecond */
if (flag == TO_CHAR)
{
sprintf(inout, "%06d", (int)rint(tmtc->fsec * 1000000));
sprintf(inout, "%06d", (int) rint(tmtc->fsec * 1000000));
if (S_THth(suf))
str_numth(p_inout, inout, S_TH_TYPE(suf));
if (S_THth(suf))
@@ -1901,27 +1900,31 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
}
else if (flag == FROM_CHAR)
{
int len, x;
int len,
x;
if (is_next_separator(node))
{
sscanf(inout, "%d", &tmfc->us);
len = x = strdigits_len(inout);
}
else
else
{
sscanf(inout, "%06d", &tmfc->us);
x = strdigits_len(inout);
len = x = x > 6 ? 6 : x;
}
len = x = x > 6 ? 6 : x;
}
tmfc->us *= x==1 ? 100000 :
x==2 ? 10000 :
x==3 ? 1000 :
x==4 ? 100 :
x==5 ? 10 : 1;
/* elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us, len); */
tmfc->us *= x == 1 ? 100000 :
x == 2 ? 10000 :
x == 3 ? 1000 :
x == 4 ? 100 :
x == 5 ? 10 : 1;
/*
* elog(NOTICE, "X: %d, US: %d, LEN: %d", x, tmfc->us,
* len);
*/
return len - 1 + SKIP_THth(suf);
}
break;
@@ -1953,7 +1956,7 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
case DCH_TZ:
if (flag == TO_CHAR && tmtcTzn(tmtc))
{
int siz = strlen(tmtcTzn(tmtc));
int siz = strlen(tmtcTzn(tmtc));
if (arg == DCH_TZ)
strcpy(inout, tmtcTzn(tmtc));
@@ -1990,13 +1993,15 @@ do { \
static int
dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
{
char buff[DCH_CACHE_SIZE], *p_inout;
int i, len;
struct tm *tm = NULL;
TmFromChar *tmfc = NULL;
TmToChar *tmtc = NULL;
char buff[DCH_CACHE_SIZE],
*p_inout;
int i,
len;
struct tm *tm = NULL;
TmFromChar *tmfc = NULL;
TmToChar *tmtc = NULL;
if (flag==TO_CHAR)
if (flag == TO_CHAR)
{
tmtc = (TmToChar *) data;
tm = tmtcTm(tmtc);
@@ -2394,7 +2399,7 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
sscanf(inout, "%d,%03d", &cc, &tmfc->yyyy);
tmfc->yyyy += (cc * 1000);
return strdigits_len(inout) + 3 + SKIP_THth(suf);
return strdigits_len(inout) + 3 + SKIP_THth(suf);
}
break;
case DCH_YYYY:
@@ -2648,10 +2653,11 @@ static text *
datetime_to_char_body(TmToChar *tmtc, text *fmt)
{
FormatNode *format;
struct tm *tm = NULL;
char *str_fmt, *result;
bool incache;
int len = VARSIZE(fmt) - VARHDRSZ;
struct tm *tm = NULL;
char *str_fmt,
*result;
bool incache;
int len = VARSIZE(fmt) - VARHDRSZ;
tm = tmtcTm(tmtc);
tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
@@ -2671,7 +2677,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt)
/*
* Allocate new memory if format picture is bigger than static cache
* and not use cache (call parser always) - incache=FALSE show this variant
* and not use cache (call parser always) - incache=FALSE show this
* variant
*/
if (len > DCH_CACHE_SIZE)
{
@@ -2686,11 +2693,11 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt)
}
else
{
/*
* Use cache buffers
*/
DCHCacheEntry *ent;
incache = TRUE;
if ((ent = DCH_cache_search(str_fmt)) == NULL)
@@ -2730,7 +2737,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt)
pfree(result);
else
{
text *res = (text *) palloc(len + 1 + VARHDRSZ);
text *res = (text *) palloc(len + 1 + VARHDRSZ);
memcpy(VARDATA(res), result, len);
VARATT_SIZEP(res) = len + VARHDRSZ;
@@ -2750,12 +2757,13 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt)
Datum
timestamp_to_char(PG_FUNCTION_ARGS)
{
Timestamp dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1), *res;
TmToChar tmtc;
int r = 0;
Timestamp dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1),
*res;
TmToChar tmtc;
int r = 0;
if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
PG_RETURN_NULL();
ZERO_tmtc(&tmtc);
@@ -2765,7 +2773,7 @@ timestamp_to_char(PG_FUNCTION_ARGS)
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
if (!(res=datetime_to_char_body(&tmtc, fmt)))
if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
@@ -2775,11 +2783,13 @@ Datum
timestamptz_to_char(PG_FUNCTION_ARGS)
{
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1), *res;
TmToChar tmtc;
int tz, r = 0;
text *fmt = PG_GETARG_TEXT_P(1),
*res;
TmToChar tmtc;
int tz,
r = 0;
if ((VARSIZE(fmt) - VARHDRSZ) <=0 || TIMESTAMP_NOT_FINITE(dt))
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
PG_RETURN_NULL();
ZERO_tmtc(&tmtc);
@@ -2789,7 +2799,7 @@ timestamptz_to_char(PG_FUNCTION_ARGS)
if (r != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
if (!(res=datetime_to_char_body(&tmtc, fmt)))
if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
@@ -2803,9 +2813,10 @@ timestamptz_to_char(PG_FUNCTION_ARGS)
Datum
interval_to_char(PG_FUNCTION_ARGS)
{
Interval *it = PG_GETARG_INTERVAL_P(0);
text *fmt = PG_GETARG_TEXT_P(1), *res;
TmToChar tmtc;
Interval *it = PG_GETARG_INTERVAL_P(0);
text *fmt = PG_GETARG_TEXT_P(1),
*res;
TmToChar tmtc;
if ((VARSIZE(fmt) - VARHDRSZ) <= 0)
PG_RETURN_NULL();
@@ -2815,7 +2826,7 @@ interval_to_char(PG_FUNCTION_ARGS)
if (interval2tm(*it, tmtcTm(&tmtc), &tmtcFsec(&tmtc)) != 0)
PG_RETURN_NULL();
if (!(res=datetime_to_char_body(&tmtc, fmt)))
if (!(res = datetime_to_char_body(&tmtc, fmt)))
PG_RETURN_NULL();
PG_RETURN_TEXT_P(res);
@@ -2831,19 +2842,21 @@ interval_to_char(PG_FUNCTION_ARGS)
Datum
to_timestamp(PG_FUNCTION_ARGS)
{
text *date_txt = PG_GETARG_TEXT_P(0);
text *fmt = PG_GETARG_TEXT_P(1);
Timestamp result;
text *date_txt = PG_GETARG_TEXT_P(0);
text *fmt = PG_GETARG_TEXT_P(1);
Timestamp result;
FormatNode *format;
TmFromChar tmfc;
bool incache;
char *str;
char *date_str;
int len, date_len, tz = 0;
struct tm tm;
double fsec = 0;
TmFromChar tmfc;
bool incache;
char *str;
char *date_str;
int len,
date_len,
tz = 0;
struct tm tm;
double fsec = 0;
ZERO_tm(&tm);
ZERO_tmfc(&tmfc);
@@ -2858,7 +2871,7 @@ to_timestamp(PG_FUNCTION_ARGS)
/*
* Allocate new memory if format picture is bigger than static
* cache and not use cache (call parser always) - incache=FALSE
* cache and not use cache (call parser always) - incache=FALSE
* show this variant
*/
if (len > DCH_CACHE_SIZE)
@@ -2873,11 +2886,11 @@ to_timestamp(PG_FUNCTION_ARGS)
}
else
{
/*
* Use cache buffers
*/
DCHCacheEntry *ent;
incache = 0;
if ((ent = DCH_cache_search(str)) == NULL)
@@ -2924,7 +2937,7 @@ to_timestamp(PG_FUNCTION_ARGS)
pfree(format);
}
DEBUG_TMFC(&tmfc);
DEBUG_TMFC(&tmfc);
/*
* Convert values that user define for FROM_CHAR
@@ -2932,7 +2945,7 @@ to_timestamp(PG_FUNCTION_ARGS)
*/
if (tmfc.ssss)
{
int x = tmfc.ssss;
int x = tmfc.ssss;
tm.tm_hour = x / 3600;
x %= 3600;
@@ -2994,7 +3007,6 @@ to_timestamp(PG_FUNCTION_ARGS)
else if (tmfc.y)
{
/*
* 1-digit year: always +2000
*/
@@ -3096,7 +3108,7 @@ to_timestamp(PG_FUNCTION_ARGS)
DEBUG_TM(&tm);
tz = DetermineLocalTimeZone(&tm);
if (tm2timestamp(&tm, fsec, &tz, &result) != 0)
elog(ERROR, "to_timestamp(): can't convert 'tm' to timestamp.");
@@ -3111,7 +3123,6 @@ to_timestamp(PG_FUNCTION_ARGS)
Datum
to_date(PG_FUNCTION_ARGS)
{
/*
* Quick hack: since our inputs are just like to_timestamp, hand over
* the whole input info struct...
@@ -3173,7 +3184,6 @@ NUM_cache_getnew(char *str)
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
{
/*
* entry removed via NUM_cache_remove() can be used here
*/
@@ -3291,7 +3301,6 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
}
else
{
/*
* Use cache buffers
*/
@@ -3453,7 +3462,6 @@ NUM_prepare_locale(NUMProc *Np)
}
else
{
#endif
/*
@@ -3678,7 +3686,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
#endif
if (IS_LSIGN(Np->Num))
{
/*
* Write locale SIGN
*/
@@ -3713,7 +3720,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
(Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0)
+ (IS_DECIMAL(Np->Num) ? 1 : 0)))
{
/*
* Write close BRACKET
*/
@@ -3734,7 +3740,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
if (Np->num_curr < Np->num_pre &&
(Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num)))
{
/*
* Write blank space
*/
@@ -3752,7 +3757,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
Np->num_curr < Np->num_pre &&
Np->Num->zero_start <= Np->num_curr)
{
/*
* Write ZERO
*/
@@ -3766,7 +3770,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
}
else
{
/*
* Write Decinal point
*/
@@ -3796,7 +3799,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
}
else
{
/*
* Write Digits
*/
@@ -3946,7 +3948,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
if (!Np->sign_wrote)
{
/*
* Set SING position
*/
@@ -4029,7 +4030,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
if (Np->type == FROM_CHAR)
{
/*
* Check non-string inout end
*/
@@ -4042,7 +4042,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
*/
if (n->type == NODE_TYPE_ACTION)
{
/*
* Create/reading digit/zero/blank/sing
*/
@@ -4143,7 +4142,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
else
Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) - 1;
break;
case NUM_rn:
if (IS_FILLMODE(Np->Num))
{
@@ -4228,7 +4227,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
}
else
{
/*
* Remove to output char from input in TO_CHAR
*/

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.59 2001/10/13 17:40:24 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.60 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -484,11 +484,11 @@ box_ov(BOX *box1, BOX *box2)
FPle(box1->low.x, box2->high.x)) ||
(FPge(box2->high.x, box1->high.x) &&
FPle(box2->low.x, box1->high.x)))
&&
((FPge(box1->high.y, box2->high.y) &&
FPle(box1->low.y, box2->high.y)) ||
(FPge(box2->high.y, box1->high.y) &&
FPle(box2->low.y, box1->high.y)));
&&
((FPge(box1->high.y, box2->high.y) &&
FPle(box1->low.y, box2->high.y)) ||
(FPge(box2->high.y, box1->high.y) &&
FPle(box2->low.y, box1->high.y)));
}
/* box_overleft - is the right edge of box1 to the left of
@@ -811,7 +811,6 @@ line_in(PG_FUNCTION_ARGS)
{
#ifdef ENABLE_LINE_TYPE
char *str = PG_GETARG_CSTRING(0);
#endif
LINE *line;
@@ -840,7 +839,6 @@ line_out(PG_FUNCTION_ARGS)
{
#ifdef ENABLE_LINE_TYPE
LINE *line = PG_GETARG_LINE_P(0);
#endif
char *result;
@@ -1403,28 +1401,28 @@ path_inter(PG_FUNCTION_ARGS)
/* pairwise check lseg intersections */
for (i = 0; i < p1->npts; i++)
{
int iprev;
int iprev;
if (i > 0)
iprev = i-1;
iprev = i - 1;
else
{
if (!p1->closed)
continue;
iprev = p1->npts-1; /* include the closure segment */
iprev = p1->npts - 1; /* include the closure segment */
}
for (j = 0; j < p2->npts; j++)
{
int jprev;
int jprev;
if (j > 0)
jprev = j-1;
jprev = j - 1;
else
{
if (!p2->closed)
continue;
jprev = p2->npts-1; /* include the closure segment */
jprev = p2->npts - 1; /* include the closure segment */
}
statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
@@ -1457,28 +1455,28 @@ path_distance(PG_FUNCTION_ARGS)
for (i = 0; i < p1->npts; i++)
{
int iprev;
int iprev;
if (i > 0)
iprev = i-1;
iprev = i - 1;
else
{
if (!p1->closed)
continue;
iprev = p1->npts-1; /* include the closure segment */
iprev = p1->npts - 1; /* include the closure segment */
}
for (j = 0; j < p2->npts; j++)
{
int jprev;
int jprev;
if (j > 0)
jprev = j-1;
jprev = j - 1;
else
{
if (!p2->closed)
continue;
jprev = p2->npts-1; /* include the closure segment */
jprev = p2->npts - 1; /* include the closure segment */
}
statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
@@ -1515,15 +1513,15 @@ path_length(PG_FUNCTION_ARGS)
for (i = 0; i < path->npts; i++)
{
int iprev;
int iprev;
if (i > 0)
iprev = i-1;
iprev = i - 1;
else
{
if (!path->closed)
continue;
iprev = path->npts-1; /* include the closure segment */
iprev = path->npts - 1; /* include the closure segment */
}
result += point_dt(&path->p[iprev], &path->p[i]);
@@ -2114,7 +2112,7 @@ static double
dist_pl_internal(Point *pt, LINE *line)
{
return (line->A * pt->x + line->B * pt->y + line->C) /
HYPOT(line->A, line->B);
HYPOT(line->A, line->B);
}
Datum
@@ -2216,15 +2214,16 @@ dist_ppath(PG_FUNCTION_ARGS)
*/
for (i = 0; i < path->npts; i++)
{
int iprev;
int iprev;
if (i > 0)
iprev = i-1;
iprev = i - 1;
else
{
if (!path->closed)
continue;
iprev = path->npts-1; /* include the closure segment */
iprev = path->npts - 1; /* include the closure
* segment */
}
statlseg_construct(&lseg, &path->p[iprev], &path->p[i]);
@@ -2307,7 +2306,6 @@ dist_lb(PG_FUNCTION_ARGS)
#ifdef NOT_USED
LINE *line = PG_GETARG_LINE_P(0);
BOX *box = PG_GETARG_BOX_P(1);
#endif
/* think about this one for a while */
@@ -2830,7 +2828,6 @@ close_lb(PG_FUNCTION_ARGS)
#ifdef NOT_USED
LINE *line = PG_GETARG_LINE_P(0);
BOX *box = PG_GETARG_BOX_P(1);
#endif
/* think about this one for a while */
@@ -3430,7 +3427,6 @@ poly_distance(PG_FUNCTION_ARGS)
#ifdef NOT_USED
POLYGON *polya = PG_GETARG_POLYGON_P(0);
POLYGON *polyb = PG_GETARG_POLYGON_P(1);
#endif
elog(ERROR, "poly_distance not implemented");
@@ -3737,7 +3733,6 @@ path_center(PG_FUNCTION_ARGS)
{
#ifdef NOT_USED
PATH *path = PG_GETARG_PATH_P(0);
#endif
elog(ERROR, "path_center not implemented");

View File

@@ -16,8 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.10 2001/03/22 03:59:51 momjian Exp $";
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.11 2001/10/25 05:49:44 momjian Exp $";
#endif
#include <sys/types.h>
@@ -56,7 +55,7 @@ inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
switch (af)
{
case AF_INET:
case AF_INET:
return (inet_cidr_ntop_ipv4(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
@@ -157,7 +156,7 @@ inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
switch (af)
{
case AF_INET:
case AF_INET:
return (inet_net_ntop_ipv4(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;

View File

@@ -16,8 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.12 2000/12/03 20:45:36 tgl Exp $";
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.13 2001/10/25 05:49:44 momjian Exp $";
#endif
#include <sys/types.h>
@@ -64,10 +63,10 @@ inet_net_pton(int af, const char *src, void *dst, size_t size)
{
switch (af)
{
case AF_INET:
case AF_INET:
return size == -1 ?
inet_net_pton_ipv4(src, dst) :
inet_cidr_pton_ipv4(src, dst, size);
inet_net_pton_ipv4(src, dst) :
inet_cidr_pton_ipv4(src, dst, size);
default:
errno = EAFNOSUPPORT;
return (-1);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.33 2001/09/07 01:33:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.34 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,7 +67,7 @@ int8in(PG_FUNCTION_ARGS)
* Do our own scan, rather than relying on sscanf which might be
* broken for long long.
*/
while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */
while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */
ptr++;
if (*ptr == '-') /* handle sign */
sign = -1, ptr++;

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.47 2001/10/04 02:15:47 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.48 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,14 +35,14 @@ static int MatchText(unsigned char *t, int tlen,
static int MatchTextIC(unsigned char *t, int tlen,
unsigned char *p, int plen);
static int MatchBytea(unsigned char *t, int tlen,
unsigned char *p, int plen);
unsigned char *p, int plen);
static text *do_like_escape(text *, text *);
#ifdef MULTIBYTE
static int MBMatchText(unsigned char *t, int tlen,
unsigned char *p, int plen);
static int MBMatchTextIC(unsigned char *t, int tlen,
unsigned char *p, int plen);
static int MBMatchTextIC(unsigned char *t, int tlen,
unsigned char *p, int plen);
static text *MB_do_like_escape(text *, text *);
/*--------------------
@@ -107,7 +107,6 @@ iwchareq(unsigned char *p1, unsigned char *p2)
c2[0] = tolower(c2[0]);
return (c1[0] == c2[0]);
}
#endif
#ifdef MULTIBYTE
@@ -123,7 +122,7 @@ iwchareq(unsigned char *p1, unsigned char *p2)
} while (0)
#define MatchText MBMatchText
#define MatchTextIC MBMatchTextIC
#define MatchTextIC MBMatchTextIC
#define do_like_escape MB_do_like_escape
#include "like_match.c"
#undef CHAREQ
@@ -167,11 +166,11 @@ namelike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
else
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
#else
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -195,11 +194,11 @@ namenlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
else
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
#else
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -215,6 +214,7 @@ textlike(PG_FUNCTION_ARGS)
*p;
int slen,
plen;
s = VARDATA(str);
slen = (VARSIZE(str) - VARHDRSZ);
p = VARDATA(pat);
@@ -222,11 +222,11 @@ textlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
else
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
#else
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -250,11 +250,11 @@ textnlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
else
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
#else
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -324,11 +324,11 @@ nameiclike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
else
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#else
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -352,11 +352,11 @@ nameicnlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
else
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#else
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -380,11 +380,11 @@ texticlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
else
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#else
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -408,11 +408,11 @@ texticnlike(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
else
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#else
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
#endif
PG_RETURN_BOOL(result);
@@ -431,9 +431,9 @@ like_escape(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
if (pg_database_encoding_max_length() == 1)
result = do_like_escape(pat, esc);
result = do_like_escape(pat, esc);
else
result = MB_do_like_escape(pat, esc);
result = MB_do_like_escape(pat, esc);
#else
result = do_like_escape(pat, esc);
#endif
@@ -472,7 +472,6 @@ like_escape_bytea(PG_FUNCTION_ARGS)
if (elen == 0)
{
/*
* No escape character is wanted. Double any backslashes in the
* pattern to make them act like ordinary characters.
@@ -486,7 +485,6 @@ like_escape_bytea(PG_FUNCTION_ARGS)
}
else
{
/*
* The specified escape must be only a single character.
*/
@@ -574,7 +572,6 @@ MatchBytea(unsigned char *t, int tlen, unsigned char *p, int plen)
*/
while (tlen > 0)
{
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
@@ -598,7 +595,6 @@ MatchBytea(unsigned char *t, int tlen, unsigned char *p, int plen)
}
else if ((*p != '_') && !BYTEA_CHAREQ(t, p))
{
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...

View File

@@ -18,7 +18,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.1 2001/10/04 02:15:47 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like_match.c,v 1.2 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -101,7 +101,6 @@ MatchText(unsigned char *t, int tlen, unsigned char *p, int plen)
*/
while (tlen > 0)
{
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
@@ -125,7 +124,6 @@ MatchText(unsigned char *t, int tlen, unsigned char *p, int plen)
}
else if ((*p != '_') && !CHAREQ(t, p))
{
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
@@ -189,7 +187,6 @@ MatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen)
*/
while (tlen > 0)
{
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
@@ -213,7 +210,6 @@ MatchTextIC(unsigned char *t, int tlen, unsigned char *p, int plen)
}
else if ((*p != '_') && !ICHAREQ(t, p))
{
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
@@ -271,7 +267,6 @@ do_like_escape(text *pat, text *esc)
if (elen == 0)
{
/*
* No escape character is wanted. Double any backslashes in the
* pattern to make them act like ordinary characters.
@@ -285,7 +280,6 @@ do_like_escape(text *pat, text *esc)
}
else
{
/*
* The specified escape must be only a single character.
*/

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.22 2001/03/22 03:59:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.23 2001/10/25 05:49:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,7 +66,6 @@ oidrand(PG_FUNCTION_ARGS)
{
#ifdef NOT_USED
Oid o = PG_GETARG_OID(0);
#endif
int32 X = PG_GETARG_INT32(1);
bool result;

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.90 2001/10/20 01:02:18 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.91 2001/10/25 05:49:44 momjian Exp $
*
* NOTES
*
@@ -90,7 +90,6 @@ static int sec_tab[] = {
1, 1, 60, 60,
3600, 3600, 86400, 86400, 604800, 604800,
2592000, 2592000, 31536000, 31536000};
#endif
/*
@@ -103,7 +102,6 @@ static void reltime2tm(RelativeTime time, struct tm * tm);
#ifdef NOT_USED
static int correct_unit(char *unit, int *unptr);
static int correct_dir(char *direction, int *signptr);
#endif
static int istinterval(char *i_string,
@@ -188,13 +186,15 @@ GetCurrentAbsoluteTime(void)
AbsoluteTime
GetCurrentAbsoluteTimeUsec(int *usec)
{
time_t now;
time_t now;
struct timeval tp;
#ifdef NOT_USED
struct timezone tpz;
#endif
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
struct tm *tm;
#else
struct timeb tb; /* the old V7-ism */
#endif
@@ -271,7 +271,7 @@ GetCurrentTime(struct tm * tm)
void
GetCurrentTimeUsec(struct tm *tm, double *fsec)
GetCurrentTimeUsec(struct tm * tm, double *fsec)
{
int tz;
int usec;
@@ -297,15 +297,16 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
ftime(&tb);
#endif
/* If HasCTZSet is true then we have a brute force time zone specified.
* Go ahead and rotate to the local time zone since we will later bypass
* any calls which adjust the tm fields.
/*
* If HasCTZSet is true then we have a brute force time zone
* specified. Go ahead and rotate to the local time zone since we will
* later bypass any calls which adjust the tm fields.
*/
if (HasCTZSet && (tzp != NULL))
time -= CTimeZone;
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
if ((! HasCTZSet) && (tzp != NULL))
if ((!HasCTZSet) && (tzp != NULL))
{
tx = localtime((time_t *) &time);
#ifdef NO_MKTIME_BEFORE_1970
@@ -336,9 +337,9 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
if (tzp != NULL)
{
/* We have a brute force time zone per SQL99?
* Then use it without change
* since we have already rotated to the time zone.
/*
* We have a brute force time zone per SQL99? Then use it without
* change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
@@ -351,14 +352,18 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
}
else
{
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
/* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
/*
* 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 + 1);
if (strlen(tm->tm_zone) > MAXTZLEN)
@@ -367,15 +372,13 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
}
}
else
{
tm->tm_isdst = -1;
}
#elif defined(HAVE_INT_TIMEZONE)
if (tzp != NULL)
{
/* We have a brute force time zone per SQL99?
* Then use it without change
* since we have already rotated to the time zone.
/*
* We have a brute force time zone per SQL99? Then use it without
* change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
@@ -390,10 +393,10 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
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 + 1);
if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
@@ -402,16 +405,14 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
}
}
else
{
tm->tm_isdst = -1;
}
#endif
#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
if (tzp != NULL)
{
/* We have a brute force time zone per SQL99?
* Then use it without change
* since we have already rotated to the time zone.
/*
* We have a brute force time zone per SQL99? Then use it without
* change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
@@ -424,20 +425,19 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
*tzp = tb.timezone * 60;
/*
* XXX does this work to get the local timezone string in V7? - tgl
* 97/03/18
* XXX does this work to get the local timezone string in V7?
* - tgl 97/03/18
*/
if (tzn != NULL)
{
strftime(*tzn, MAXTZLEN, "%Z", localtime(&now));
tzn[MAXTZLEN] = '\0'; /* let's just be sure it's null-terminated */
tzn[MAXTZLEN] = '\0'; /* let's just be sure it's
* null-terminated */
}
}
}
else
{
tm->tm_isdst = -1;
}
#endif
return;
@@ -517,8 +517,11 @@ nabstimein(PG_FUNCTION_ARGS)
break;
case DTK_EPOCH:
/* Don't bother retaining this as a reserved value,
* but instead just set to the actual epoch time (1970-01-01) */
/*
* Don't bother retaining this as a reserved value, but
* instead just set to the actual epoch time (1970-01-01)
*/
result = 0;
break;
@@ -562,9 +565,10 @@ nabstimeout(PG_FUNCTION_ARGS)
switch (time)
{
/* Note that timestamp no longer supports 'invalid'.
* Retain 'invalid' for abstime for now, but dump it someday.
*/
/*
* Note that timestamp no longer supports 'invalid'. Retain
* 'invalid' for abstime for now, but dump it someday.
*/
case INVALID_ABSTIME:
strcpy(buf, INVALID);
break;
@@ -611,14 +615,14 @@ abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b)
*/
if (a == INVALID_ABSTIME)
{
if (b == INVALID_ABSTIME)
return 0; /* INVALID = INVALID */
else
return 1; /* INVALID > non-INVALID */
if (b == INVALID_ABSTIME)
return 0; /* INVALID = INVALID */
else
return 1; /* INVALID > non-INVALID */
}
if (b == INVALID_ABSTIME)
return -1; /* non-INVALID < INVALID */
return -1; /* non-INVALID < INVALID */
#if 0
/* CURRENT is no longer stored internally... */
@@ -777,7 +781,7 @@ abstime_timestamp(PG_FUNCTION_ARGS)
Datum
timestamptz_abstime(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
AbsoluteTime result;
double fsec;
struct tm tt,
@@ -805,7 +809,7 @@ Datum
abstime_timestamptz(PG_FUNCTION_ARGS)
{
AbsoluteTime abstime = PG_GETARG_ABSOLUTETIME(0);
TimestampTz result;
TimestampTz result;
switch (abstime)
{
@@ -928,7 +932,7 @@ tintervalin(PG_FUNCTION_ARGS)
elog(ERROR, "Unable to decode tinterval '%s'", intervalstr);
if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME)
interval->status = T_INTERVAL_INVAL; /* undefined */
interval->status = T_INTERVAL_INVAL; /* undefined */
else
interval->status = T_INTERVAL_VALID;
@@ -1273,11 +1277,11 @@ tintervalsame(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(false);
if (DatumGetBool(DirectFunctionCall2(abstimeeq,
AbsoluteTimeGetDatum(i1->data[0]),
AbsoluteTimeGetDatum(i2->data[0]))) &&
AbsoluteTimeGetDatum(i1->data[0]),
AbsoluteTimeGetDatum(i2->data[0]))) &&
DatumGetBool(DirectFunctionCall2(abstimeeq,
AbsoluteTimeGetDatum(i1->data[1]),
AbsoluteTimeGetDatum(i2->data[1]))))
AbsoluteTimeGetDatum(i1->data[1]),
AbsoluteTimeGetDatum(i2->data[1]))))
PG_RETURN_BOOL(true);
PG_RETURN_BOOL(false);
}
@@ -1293,9 +1297,9 @@ tintervaleq(PG_FUNCTION_ARGS)
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
t11,
t20,
t21;
t11,
t20,
t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
@@ -1318,9 +1322,9 @@ tintervalne(PG_FUNCTION_ARGS)
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
t11,
t20,
t21;
t11,
t20,
t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
@@ -1343,9 +1347,9 @@ tintervallt(PG_FUNCTION_ARGS)
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
t11,
t20,
t21;
t11,
t20,
t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
@@ -1368,9 +1372,9 @@ tintervalle(PG_FUNCTION_ARGS)
TimeInterval i1 = PG_GETARG_TIMEINTERVAL(0);
TimeInterval i2 = PG_GETARG_TIMEINTERVAL(1);
AbsoluteTime t10,
t11,
t20,
t21;
t11,
t20,
t21;
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
@@ -1462,7 +1466,7 @@ tintervalleneq(PG_FUNCTION_ARGS)
if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME)
PG_RETURN_BOOL(false);
rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel,
TimeIntervalGetDatum(i)));
TimeIntervalGetDatum(i)));
PG_RETURN_BOOL((rt != INVALID_RELTIME) && (rt == t));
}
@@ -1569,11 +1573,11 @@ tintervalov(PG_FUNCTION_ARGS)
if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL)
PG_RETURN_BOOL(false);
if (DatumGetBool(DirectFunctionCall2(abstimelt,
AbsoluteTimeGetDatum(i1->data[1]),
AbsoluteTimeGetDatum(i2->data[0]))) ||
AbsoluteTimeGetDatum(i1->data[1]),
AbsoluteTimeGetDatum(i2->data[0]))) ||
DatumGetBool(DirectFunctionCall2(abstimegt,
AbsoluteTimeGetDatum(i1->data[0]),
AbsoluteTimeGetDatum(i2->data[1]))))
AbsoluteTimeGetDatum(i1->data[0]),
AbsoluteTimeGetDatum(i2->data[1]))))
PG_RETURN_BOOL(false);
PG_RETURN_BOOL(true);
}

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.31 2001/01/24 19:43:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.32 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -155,7 +155,6 @@ namecat(Name n1, Name n2)
return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer
* than n1 */
}
#endif
#ifdef NOT_USED
@@ -164,7 +163,6 @@ namecmp(Name n1, Name n2)
{
return strncmp(NameStr(*n1), NameStr(*n2), NAMEDATALEN);
}
#endif
int
@@ -196,7 +194,6 @@ namestrcat(Name name, const char *str)
}
return 0;
}
#endif
int
@@ -243,5 +240,4 @@ NameComputeLength(Name name)
;
return (uint32) length;
}
#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.
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.33 2001/08/27 20:03:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.34 2001/10/25 05:49:45 momjian Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
@@ -153,44 +153,43 @@ cidr_out(PG_FUNCTION_ARGS)
static Datum
text_network(text *src, int type)
{
int len = VARSIZE(src) - VARHDRSZ;
int len = VARSIZE(src) - VARHDRSZ;
char *str = palloc(len + 1);
memcpy(str, VARDATA(src), len);
*(str + len) = '\0';
char *str = palloc(len + 1);
PG_RETURN_INET_P(network_in( str, type));
memcpy(str, VARDATA(src), len);
*(str + len) = '\0';
PG_RETURN_INET_P(network_in(str, type));
}
Datum
text_cidr(PG_FUNCTION_ARGS)
{
return text_network( PG_GETARG_TEXT_P(0), 1);
return text_network(PG_GETARG_TEXT_P(0), 1);
}
Datum
text_inet(PG_FUNCTION_ARGS)
{
return text_network( PG_GETARG_TEXT_P(0), 0);
return text_network(PG_GETARG_TEXT_P(0), 0);
}
Datum
inet_set_masklen(PG_FUNCTION_ARGS)
{
inet *src = PG_GETARG_INET_P(0);
int bits = PG_GETARG_INT32(1);
inet *dst;
inet *src = PG_GETARG_INET_P(0);
int bits = PG_GETARG_INT32(1);
inet *dst;
if ((bits < 0) || (bits > 32)) /* no support for v6 yet */
{
elog(ERROR, "set_masklen - invalid value '%d'", bits);
}
if ((bits < 0) || (bits > 32)) /* no support for v6 yet */
elog(ERROR, "set_masklen - invalid value '%d'", bits);
/* clone the original data */
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
memcpy(dst, src, VARHDRSZ + sizeof(inet_struct));
ip_bits(dst) = bits;
ip_bits(dst) = bits;
PG_RETURN_INET_P(dst);
}
@@ -618,7 +617,7 @@ network_netmask(PG_FUNCTION_ARGS)
* involving network types.
*
* Currently, inet/cidr values are simply converted to the IPv4 address;
* this will need more thought when IPv6 is supported too. MAC addresses
* this will need more thought when IPv6 is supported too. MAC addresses
* are converted to their numeric equivalent as well (OK since we have a
* double to play in).
*/
@@ -629,26 +628,26 @@ convert_network_to_scalar(Datum value, Oid typid)
{
case INETOID:
case CIDROID:
{
inet *ip = DatumGetInetP(value);
{
inet *ip = DatumGetInetP(value);
if (ip_family(ip) == AF_INET)
return (double) ip_v4addr(ip);
else
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "unknown address family (%d)", ip_family(ip));
break;
}
if (ip_family(ip) == AF_INET)
return (double) ip_v4addr(ip);
else
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "unknown address family (%d)", ip_family(ip));
break;
}
case MACADDROID:
{
macaddr *mac = DatumGetMacaddrP(value);
double res;
{
macaddr *mac = DatumGetMacaddrP(value);
double res;
res = (mac->a << 16) | (mac->b << 8) | (mac->c);
res *= 256*256*256;
res += (mac->d << 16) | (mac->e << 8) | (mac->f);
return res;
}
res = (mac->a << 16) | (mac->b << 8) | (mac->c);
res *= 256 * 256 * 256;
res += (mac->d << 16) | (mac->e << 8) | (mac->f);
return res;
}
}
/*
@@ -722,7 +721,7 @@ network_scan_first(Datum in)
}
/*
* return "last" IP on a given network. It's the broadcast address,
* return "last" IP on a given network. It's the broadcast address,
* however, masklen has to be set to 32, since
* 192.168.0.255/24 is considered less than 192.168.0.255/32
*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.26 2001/03/22 03:59:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.27 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,7 +113,6 @@ oidnotin(PG_FUNCTION_ARGS)
#ifdef NOT_USED
text *relation_and_attr = PG_GETARG_TEXT_P(1);
#endif
if (the_oid == InvalidOid)

View File

@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.45 2001/10/13 23:32:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.46 2001/10/25 05:49:45 momjian Exp $
*
* ----------
*/
@@ -193,6 +193,7 @@ Datum
numeric_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -440,7 +441,6 @@ numeric_sign(PG_FUNCTION_ARGS)
set_var_from_var(&const_zero, &result);
else
{
/*
* And if there are some, we return a copy of ONE with the sign of
* our argument
@@ -496,7 +496,6 @@ numeric_round(PG_FUNCTION_ARGS)
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.
@@ -518,7 +517,7 @@ numeric_round(PG_FUNCTION_ARGS)
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++;
@@ -781,9 +780,9 @@ cmp_numerics(Numeric num1, Numeric num2)
int result;
/*
* We consider all NANs to be equal and larger than any non-NAN.
* This is somewhat arbitrary; the important thing is to have a
* consistent sort order.
* We consider all NANs to be equal and larger than any non-NAN. This
* is somewhat arbitrary; the important thing is to have a consistent
* sort order.
*/
if (NUMERIC_IS_NAN(num1))
{
@@ -1799,9 +1798,9 @@ numeric_accum(PG_FUNCTION_ARGS)
/*
* Integer data types all use Numeric accumulators to share code and
* avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation
* avoid risk of overflow. For int2 and int4 inputs, Numeric accumulation
* is overkill for the N and sum(X) values, but definitely not overkill
* for the sum(X*X) value. Hence, we use int2_accum and int4_accum only
* for the sum(X*X) value. Hence, we use int2_accum and int4_accum only
* for stddev/variance --- there are faster special-purpose accumulator
* routines for SUM and AVG of these datatypes.
*/
@@ -2020,7 +2019,7 @@ numeric_stddev(PG_FUNCTION_ARGS)
* the initial condition of the transition data value needs to be NULL. This
* means we can't rely on ExecAgg to automatically insert the first non-null
* data value into the transition data: it doesn't know how to do the type
* conversion. The upshot is that these routines have to be marked non-strict
* conversion. The upshot is that these routines have to be marked non-strict
* and handle substitution of the first non-null input themselves.
*/
@@ -2269,7 +2268,6 @@ dump_var(char *str, NumericVar *var)
printf("\n");
}
#endif /* NUMERIC_DEBUG */
@@ -2795,7 +2793,6 @@ cmp_var(NumericVar *var1, NumericVar *var2)
static void
add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
/*
* Decide on the signs of the two variables what to do
*/
@@ -2803,7 +2800,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
if (var2->sign == NUMERIC_POS)
{
/*
* Both are positive result = +(ABS(var1) + ABS(var2))
*/
@@ -2812,7 +2808,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
}
else
{
/*
* var1 is positive, var2 is negative Must compare absolute
* values
@@ -2919,7 +2914,6 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
static void
sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
/*
* Decide on the signs of the two variables what to do
*/

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.45 2001/03/22 03:59:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.46 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -345,7 +345,6 @@ frac_out:
return avail;
#endif
}
#endif
/*
@@ -476,5 +475,4 @@ atof1(char *str, double *val)
*val = v;
return 0;
}
#endif

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.35 2001/09/23 11:02:01 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.36 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -171,8 +171,9 @@ lpad(PG_FUNCTION_ARGS)
int m,
s1len,
s2len;
#ifdef MULTIBYTE
int bytelen;
int bytelen;
#endif
/* Negative len is silently taken as zero */
@@ -188,7 +189,7 @@ lpad(PG_FUNCTION_ARGS)
s2len = 0; /* shouldn't happen */
#ifdef MULTIBYTE
s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len);
s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
#endif
if (s1len > len)
s1len = len; /* truncate string1 to len chars */
@@ -213,12 +214,13 @@ lpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (m--)
{
int mlen = pg_mblen(ptr2);
memcpy(ptr_ret, ptr2, mlen);
ptr_ret += mlen;
ptr2 += mlen;
if (ptr2 == ptr2end) /* wrap around at end of s2 */
ptr2 = VARDATA(string2);
int mlen = pg_mblen(ptr2);
memcpy(ptr_ret, ptr2, mlen);
ptr_ret += mlen;
ptr2 += mlen;
if (ptr2 == ptr2end) /* wrap around at end of s2 */
ptr2 = VARDATA(string2);
}
#else
while (m--)
@@ -234,10 +236,11 @@ lpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (s1len--)
{
int mlen = pg_mblen(ptr1);
memcpy(ptr_ret, ptr1, mlen);
ptr_ret += mlen;
ptr1 += mlen;
int mlen = pg_mblen(ptr1);
memcpy(ptr_ret, ptr1, mlen);
ptr_ret += mlen;
ptr1 += mlen;
}
#else
while (s1len--)
@@ -278,8 +281,9 @@ rpad(PG_FUNCTION_ARGS)
int m,
s1len,
s2len;
#ifdef MULTIBYTE
int bytelen;
int bytelen;
#endif
/* Negative len is silently taken as zero */
@@ -295,7 +299,7 @@ rpad(PG_FUNCTION_ARGS)
s2len = 0; /* shouldn't happen */
#ifdef MULTIBYTE
s1len = pg_mbstrlen_with_len(VARDATA(string1),s1len);
s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
#endif
if (s1len > len)
@@ -320,10 +324,11 @@ rpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (s1len--)
{
int mlen = pg_mblen(ptr1);
memcpy(ptr_ret, ptr1, mlen);
ptr_ret += mlen;
ptr1 += mlen;
int mlen = pg_mblen(ptr1);
memcpy(ptr_ret, ptr1, mlen);
ptr_ret += mlen;
ptr1 += mlen;
}
#else
while (s1len--)
@@ -336,12 +341,13 @@ rpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (m--)
{
int mlen = pg_mblen(ptr2);
memcpy(ptr_ret, ptr2, mlen);
ptr_ret += mlen;
ptr2 += mlen;
if (ptr2 == ptr2end) /* wrap around at end of s2 */
ptr2 = VARDATA(string2);
int mlen = pg_mblen(ptr2);
memcpy(ptr_ret, ptr2, mlen);
ptr_ret += mlen;
ptr2 += mlen;
if (ptr2 == ptr2end) /* wrap around at end of s2 */
ptr2 = VARDATA(string2);
}
#else
while (m--)
@@ -384,11 +390,11 @@ btrim(PG_FUNCTION_ARGS)
int m;
#ifdef MULTIBYTE
char **mp;
int mplen;
char *p;
int mblen;
int len;
char **mp;
int mplen;
char *p;
int mblen;
int len;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
@@ -398,18 +404,18 @@ btrim(PG_FUNCTION_ARGS)
ptr = VARDATA(string);
#ifdef MULTIBYTE
len = m;
mp = (char **)palloc(len*sizeof(char *));
len = m;
mp = (char **) palloc(len * sizeof(char *));
p = ptr;
mplen = 0;
/* build the mb pointer array */
while (len > 0)
{
mp[mplen++] = p;
mblen = pg_mblen(p);
p += mblen;
len -= mblen;
mp[mplen++] = p;
mblen = pg_mblen(p);
p += mblen;
len -= mblen;
}
mplen--;
#else
@@ -420,16 +426,17 @@ btrim(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (m > 0)
{
int str_len = pg_mblen(ptr);
int str_len = pg_mblen(ptr);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
int set_len = pg_mblen(ptr2);
int set_len = pg_mblen(ptr2);
if (str_len == set_len &&
memcmp(ptr,ptr2,str_len) == 0)
if (str_len == set_len &&
memcmp(ptr, ptr2, str_len) == 0)
break;
ptr2 += set_len;
ptr2 += set_len;
}
if (ptr2 > end2)
break;
@@ -439,18 +446,19 @@ btrim(PG_FUNCTION_ARGS)
while (m > 0)
{
int str_len;
int str_len;
end = mp[mplen--];
str_len = pg_mblen(end);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
int set_len = pg_mblen(ptr2);
int set_len = pg_mblen(ptr2);
if (str_len == set_len &&
memcmp(end,ptr2,str_len) == 0)
if (str_len == set_len &&
memcmp(end, ptr2, str_len) == 0)
break;
ptr2 += set_len;
ptr2 += set_len;
}
if (ptr2 > end2)
break;
@@ -604,16 +612,17 @@ ltrim(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (m > 0)
{
int str_len = pg_mblen(ptr);
int str_len = pg_mblen(ptr);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
int set_len = pg_mblen(ptr2);
int set_len = pg_mblen(ptr2);
if (str_len == set_len &&
memcmp(ptr,ptr2,str_len) == 0)
if (str_len == set_len &&
memcmp(ptr, ptr2, str_len) == 0)
break;
ptr2 += set_len;
ptr2 += set_len;
}
if (ptr2 > end2)
break;
@@ -673,11 +682,11 @@ rtrim(PG_FUNCTION_ARGS)
int m;
#ifdef MULTIBYTE
char **mp;
int mplen;
char *p;
int mblen;
int len;
char **mp;
int mplen;
char *p;
int mblen;
int len;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
@@ -687,18 +696,18 @@ rtrim(PG_FUNCTION_ARGS)
ptr = VARDATA(string);
#ifdef MULTIBYTE
len = m;
mp = (char **)palloc(len*sizeof(char *));
len = m;
mp = (char **) palloc(len * sizeof(char *));
p = ptr;
mplen = 0;
/* build the mb pointer array */
while (len > 0)
{
mp[mplen++] = p;
mblen = pg_mblen(p);
p += mblen;
len -= mblen;
mp[mplen++] = p;
mblen = pg_mblen(p);
p += mblen;
len -= mblen;
}
mplen--;
#else
@@ -709,18 +718,19 @@ rtrim(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
while (m > 0)
{
int str_len;
int str_len;
end = mp[mplen--];
str_len = pg_mblen(end);
ptr2 = VARDATA(set);
while (ptr2 <= end2)
{
int set_len = pg_mblen(ptr2);
int set_len = pg_mblen(ptr2);
if (str_len == set_len &&
memcmp(end,ptr2,str_len) == 0)
if (str_len == set_len &&
memcmp(end, ptr2, str_len) == 0)
break;
ptr2 += set_len;
ptr2 += set_len;
}
if (ptr2 > end2)
break;
@@ -784,12 +794,13 @@ translate(PG_FUNCTION_ARGS)
tolen,
retlen,
i;
#ifdef MULTIBYTE
int str_len;
int estimate_len;
int len;
int source_len;
int from_index;
int str_len;
int estimate_len;
int len;
int source_len;
int from_index;
#endif
if ((m = VARSIZE(string) - VARHDRSZ) <= 0)
@@ -802,8 +813,8 @@ translate(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
str_len = VARSIZE(string);
estimate_len = (tolen*1.0/fromlen + 0.5)*str_len;
estimate_len = estimate_len>str_len?estimate_len:str_len;
estimate_len = (tolen * 1.0 / fromlen + 0.5) * str_len;
estimate_len = estimate_len > str_len ? estimate_len : str_len;
result = (text *) palloc(estimate_len);
#else
result = (text *) palloc(VARSIZE(string));
@@ -821,38 +832,39 @@ translate(PG_FUNCTION_ARGS)
for (i = 0; i < fromlen; i += len)
{
len = pg_mblen(&from_ptr[i]);
if (len == source_len &&
memcmp(source, &from_ptr[i], len) == 0)
break;
len = pg_mblen(&from_ptr[i]);
if (len == source_len &&
memcmp(source, &from_ptr[i], len) == 0)
break;
from_index++;
from_index++;
}
if (i < fromlen)
{
/* substitute */
char *p = to_ptr;
for (i=0;i<from_index;i++)
{
p += pg_mblen(p);
if (p >= (to_ptr + tolen))
break;
}
if (p < (to_ptr + tolen))
{
len = pg_mblen(p);
memcpy(target, p, len);
target += len;
retlen += len;
}
/* substitute */
char *p = to_ptr;
for (i = 0; i < from_index; i++)
{
p += pg_mblen(p);
if (p >= (to_ptr + tolen))
break;
}
if (p < (to_ptr + tolen))
{
len = pg_mblen(p);
memcpy(target, p, len);
target += len;
retlen += len;
}
}
else
{
/* no match, so copy */
memcpy(target, source, source_len);
target += source_len;
retlen += source_len;
memcpy(target, source, source_len);
target += source_len;
retlen += source_len;
}
source += source_len;

View File

@@ -4,7 +4,7 @@
* The PostgreSQL locale utils.
*
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.10 2001/09/29 21:16:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.11 2001/10/25 05:49:45 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
@@ -28,15 +28,15 @@ static bool CurrentLocaleConvValid = false;
static struct lconv CurrentLocaleConv;
static void PGLC_setlocale(PG_LocaleCategories * lc);
static void PGLC_setlocale(PG_LocaleCategories *lc);
/*------
* Frees memory used in PG_LocaleCategories -- this memory is
* Frees memory used in PG_LocaleCategories -- this memory is
* allocated in PGLC_current().
*------
*/
void
PGLC_free_categories(PG_LocaleCategories * lc)
PGLC_free_categories(PG_LocaleCategories *lc)
{
if (lc->lc_ctype)
pfree(lc->lc_ctype);
@@ -47,7 +47,7 @@ PGLC_free_categories(PG_LocaleCategories * lc)
if (lc->lc_collate)
pfree(lc->lc_collate);
if (lc->lc_monetary);
pfree(lc->lc_monetary);
pfree(lc->lc_monetary);
#ifdef LC_MESSAGES
if (lc->lc_messages)
pfree(lc->lc_messages);
@@ -61,17 +61,17 @@ PGLC_free_categories(PG_LocaleCategories * lc)
*------
*/
void
PGLC_current(PG_LocaleCategories * lc)
PGLC_current(PG_LocaleCategories *lc)
{
lc->lang = getenv("LANG");
lc->lc_ctype = pstrdup( setlocale(LC_CTYPE, NULL) );
lc->lc_numeric = pstrdup( setlocale(LC_NUMERIC, NULL) );
lc->lc_time = pstrdup( setlocale(LC_TIME, NULL) );
lc->lc_collate = pstrdup( setlocale(LC_COLLATE, NULL) );
lc->lc_monetary = pstrdup( setlocale(LC_MONETARY, NULL) );
lc->lc_ctype = pstrdup(setlocale(LC_CTYPE, NULL));
lc->lc_numeric = pstrdup(setlocale(LC_NUMERIC, NULL));
lc->lc_time = pstrdup(setlocale(LC_TIME, NULL));
lc->lc_collate = pstrdup(setlocale(LC_COLLATE, NULL));
lc->lc_monetary = pstrdup(setlocale(LC_MONETARY, NULL));
#ifdef LC_MESSAGES
lc->lc_messages = pstrdup( setlocale(LC_MESSAGES, NULL) );
lc->lc_messages = pstrdup(setlocale(LC_MESSAGES, NULL));
#endif
}
@@ -83,7 +83,7 @@ PGLC_current(PG_LocaleCategories * lc)
*------
*/
static void
PGLC_debug_lc(PG_LocaleCategories * lc)
PGLC_debug_lc(PG_LocaleCategories *lc)
{
#ifdef LC_MESSAGES
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",
@@ -104,7 +104,6 @@ PGLC_debug_lc(PG_LocaleCategories * lc)
lc->lc_monetary);
#endif
}
#endif
/*------
@@ -117,7 +116,7 @@ PGLC_debug_lc(PG_LocaleCategories * lc)
*------
*/
static void
PGLC_setlocale(PG_LocaleCategories * lc)
PGLC_setlocale(PG_LocaleCategories *lc)
{
if (!setlocale(LC_COLLATE, lc->lc_collate))
elog(NOTICE, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.",
@@ -172,7 +171,10 @@ PGLC_localeconv(void)
/* Get formatting information for the external environment */
extlconv = localeconv();
/* Must copy all values since restoring internal settings may overwrite */
/*
* Must copy all values since restoring internal settings may
* overwrite
*/
CurrentLocaleConv = *extlconv;
CurrentLocaleConv.currency_symbol = strdup(extlconv->currency_symbol);
CurrentLocaleConv.decimal_point = strdup(extlconv->decimal_point);
@@ -194,5 +196,4 @@ PGLC_localeconv(void)
CurrentLocaleConvValid = true;
return &CurrentLocaleConv;
}
#endif /* USE_LOCALE */

View File

@@ -1,7 +1,7 @@
/* ----------
* pg_lzcompress.c -
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.12 2001/10/25 01:29:37 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.13 2001/10/25 05:49:45 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
@@ -394,7 +394,6 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
hent = hstart[pglz_hist_idx(input, end)];
while (hent && len < good_match)
{
/*
* Be happy with lesser good matches the more entries we visited.
*/
@@ -566,7 +565,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
*/
while (dp < dend)
{
/*
* If we already exceeded the maximum result size, set no
* compression flag and stop this. But don't check too often.
@@ -583,7 +581,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
if (pglz_find_match(hist_start, dp, dend, &match_len,
&match_off, good_match, good_drop))
{
/*
* Create the tag and add history entries for all matched
* characters.
@@ -598,7 +595,6 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
}
else
{
/*
* No match found. Copy one literal byte.
*/
@@ -671,7 +667,6 @@ pglz_decompress(PGLZ_Header *source, char *dest)
while (dp < dend)
{
/*
* Read one control byte and process the next 8 items.
*/
@@ -680,7 +675,6 @@ pglz_decompress(PGLZ_Header *source, char *dest)
{
if (ctrl & 1)
{
/*
* Otherwise it contains the match length minus 3 and the
* upper 4 bits of the offset. The next following byte
@@ -708,7 +702,6 @@ pglz_decompress(PGLZ_Header *source, char *dest)
}
else
{
/*
* An unset control bit means LITERAL BYTE. So we just
* copy one from INPUT to OUTPUT.
@@ -744,7 +737,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
if (dstate->tocopy > 0)
{
/*
* Copy one byte from output to output until we did it for the
* length specified by the last tag. Return that byte.
@@ -755,7 +747,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
if (dstate->ctrl_count == 0)
{
/*
* Get the next control byte if we need to, but check for EOF
* before.
@@ -838,7 +829,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
dstate->ctrl_count--;
if (dstate->ctrl & 0x01)
{
/*
* Bit is set, so tag is following. Setup copy information and do
* the copy for the first byte as above.
@@ -857,7 +847,6 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
}
else
{
/*
* Bit is unset, so literal byte follows.
*/

View File

@@ -9,41 +9,41 @@
#include "pgstat.h"
extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_numscans(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS);
Datum
pg_stat_get_numscans(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->numscans);
result = (int64) (tabentry->numscans);
PG_RETURN_INT64(result);
}
@@ -52,16 +52,16 @@ pg_stat_get_numscans(PG_FUNCTION_ARGS)
Datum
pg_stat_get_tuples_returned(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->tuples_returned);
result = (int64) (tabentry->tuples_returned);
PG_RETURN_INT64(result);
}
@@ -70,16 +70,16 @@ pg_stat_get_tuples_returned(PG_FUNCTION_ARGS)
Datum
pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->tuples_fetched);
result = (int64) (tabentry->tuples_fetched);
PG_RETURN_INT64(result);
}
@@ -88,16 +88,16 @@ pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS)
Datum
pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->tuples_inserted);
result = (int64) (tabentry->tuples_inserted);
PG_RETURN_INT64(result);
}
@@ -106,16 +106,16 @@ pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS)
Datum
pg_stat_get_tuples_updated(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->tuples_updated);
result = (int64) (tabentry->tuples_updated);
PG_RETURN_INT64(result);
}
@@ -124,16 +124,16 @@ pg_stat_get_tuples_updated(PG_FUNCTION_ARGS)
Datum
pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->tuples_deleted);
result = (int64) (tabentry->tuples_deleted);
PG_RETURN_INT64(result);
}
@@ -142,16 +142,16 @@ pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS)
Datum
pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->blocks_fetched);
result = (int64) (tabentry->blocks_fetched);
PG_RETURN_INT64(result);
}
@@ -160,16 +160,16 @@ pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
Datum
pg_stat_get_blocks_hit(PG_FUNCTION_ARGS)
{
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
PgStat_StatTabEntry *tabentry;
Oid relid;
int64 result;
relid = PG_GETARG_OID(0);
relid = PG_GETARG_OID(0);
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64)(tabentry->blocks_hit);
result = (int64) (tabentry->blocks_hit);
PG_RETURN_INT64(result);
}
@@ -178,8 +178,8 @@ pg_stat_get_blocks_hit(PG_FUNCTION_ARGS)
Datum
pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
{
FmgrInfo *fmgr_info = fcinfo->flinfo;
int32 result;
FmgrInfo *fmgr_info = fcinfo->flinfo;
int32 result;
if (fcinfo->resultinfo == NULL ||
!IsA(fcinfo->resultinfo, ReturnSetInfo))
@@ -191,22 +191,22 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
elog(ERROR, "No function memory context in set-function");
fmgr_info->fn_extra = MemoryContextAlloc(fmgr_info->fn_mcxt,
2 * sizeof(int));
((int *)(fmgr_info->fn_extra))[0] = 0;
((int *)(fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends();
((int *) (fmgr_info->fn_extra))[0] = 0;
((int *) (fmgr_info->fn_extra))[1] = pgstat_fetch_stat_numbackends();
}
((int *)(fmgr_info->fn_extra))[0] += 1;
result = ((int *)(fmgr_info->fn_extra))[0];
((int *) (fmgr_info->fn_extra))[0] += 1;
result = ((int *) (fmgr_info->fn_extra))[0];
if (result > ((int *)(fmgr_info->fn_extra))[1])
if (result > ((int *) (fmgr_info->fn_extra))[1])
{
pfree(fmgr_info->fn_extra);
fmgr_info->fn_extra = NULL;
((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprEndResult;
((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprEndResult;
PG_RETURN_NULL();
}
((ReturnSetInfo *)(fcinfo->resultinfo))->isDone = ExprMultipleResult;
((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprMultipleResult;
PG_RETURN_INT32(result);
}
@@ -214,10 +214,10 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
Datum
pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
{
PgStat_StatBeEntry *beentry;
int32 beid;
PgStat_StatBeEntry *beentry;
int32 beid;
beid = PG_GETARG_INT32(0);
beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
@@ -229,10 +229,10 @@ pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
Datum
pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
{
PgStat_StatBeEntry *beentry;
int32 beid;
PgStat_StatBeEntry *beentry;
int32 beid;
beid = PG_GETARG_INT32(0);
beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
@@ -244,10 +244,10 @@ pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
Datum
pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
{
PgStat_StatBeEntry *beentry;
int32 beid;
PgStat_StatBeEntry *beentry;
int32 beid;
beid = PG_GETARG_INT32(0);
beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
@@ -259,15 +259,15 @@ pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
Datum
pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
{
PgStat_StatBeEntry *beentry;
int32 beid;
int len;
text *result;
PgStat_StatBeEntry *beentry;
int32 beid;
int len;
text *result;
if (!superuser())
PG_RETURN_NULL();
beid = PG_GETARG_INT32(0);
beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
PG_RETURN_NULL();
@@ -284,16 +284,16 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
Datum
pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
{
PgStat_StatDBEntry *dbentry;
Oid dbid;
int32 result;
PgStat_StatDBEntry *dbentry;
Oid dbid;
int32 result;
dbid = PG_GETARG_OID(0);
dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
result = (int32)(dbentry->n_backends);
result = (int32) (dbentry->n_backends);
PG_RETURN_INT32(result);
}
@@ -302,16 +302,16 @@ pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
Datum
pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS)
{
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
dbid = PG_GETARG_OID(0);
dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
result = (int64)(dbentry->n_xact_commit);
result = (int64) (dbentry->n_xact_commit);
PG_RETURN_INT64(result);
}
@@ -320,16 +320,16 @@ pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS)
Datum
pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS)
{
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
dbid = PG_GETARG_OID(0);
dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
result = (int64)(dbentry->n_xact_rollback);
result = (int64) (dbentry->n_xact_rollback);
PG_RETURN_INT64(result);
}
@@ -338,16 +338,16 @@ pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS)
Datum
pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS)
{
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
dbid = PG_GETARG_OID(0);
dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
result = (int64)(dbentry->n_blocks_fetched);
result = (int64) (dbentry->n_blocks_fetched);
PG_RETURN_INT64(result);
}
@@ -356,18 +356,16 @@ pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS)
Datum
pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS)
{
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
PgStat_StatDBEntry *dbentry;
Oid dbid;
int64 result;
dbid = PG_GETARG_OID(0);
dbid = PG_GETARG_OID(0);
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0;
else
result = (int64)(dbentry->n_blocks_hit);
result = (int64) (dbentry->n_blocks_hit);
PG_RETURN_INT64(result);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.4 2001/03/22 03:59:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.5 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -289,5 +289,4 @@ do_quote_literal(text *lptr)
return result;
}
#endif

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.36 2001/03/22 03:59:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.37 2001/10/25 05:49:45 momjian Exp $
*
* Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance
@@ -121,7 +121,6 @@ RE_compile_and_execute(text *text_re, char *text, int cflags)
regcomp_result = pg95_regcomp(&rev[oldest].cre_re, re, cflags);
if (regcomp_result == 0)
{
/*
* use malloc/free for the cre_s field because the storage has to
* persist across transactions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.63 2001/08/21 16:36:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.64 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,9 +53,9 @@ regprocin(PG_FUNCTION_ARGS)
Oid searchOid;
searchOid = DatumGetObjectId(DirectFunctionCall1(oidin,
CStringGetDatum(pro_name_or_oid)));
CStringGetDatum(pro_name_or_oid)));
result = (RegProcedure) GetSysCacheOid(PROCOID,
ObjectIdGetDatum(searchOid),
ObjectIdGetDatum(searchOid),
0, 0, 0);
if (!RegProcedureIsValid(result))
elog(ERROR, "No procedure with oid %s", pro_name_or_oid);

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group
* Copyright 1999 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.28 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.29 2001/10/25 05:49:45 momjian Exp $
*
* ----------
*/
@@ -423,7 +423,6 @@ RI_FKey_check(PG_FUNCTION_ARGS)
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
/*
* We can implement MATCH PARTIAL by excluding this column from
* the query if it is null. Simple! Unfortunately, the
@@ -2140,7 +2139,6 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
qualsep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++)
{
/*
* MATCH <unspecified> - only change columns
* corresponding to changed columns in pk_rel's key
@@ -2402,7 +2400,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
defval = NULL;
for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
{
/*
* For each key attribute lookup the tuple constructor
* for a corresponding default value
@@ -2412,7 +2409,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
/*
* That's the one - push the expression from
* defval.adbin into the plan's targetlist
@@ -2629,7 +2625,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
qualsep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++)
{
/*
* MATCH <unspecified> - only change columns
* corresponding to changed columns in pk_rel's key
@@ -2669,7 +2664,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
defval = NULL;
for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
{
/*
* MATCH <unspecified> - only change columns
* corresponding to changed columns in pk_rel's key.
@@ -2680,7 +2674,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
!ri_OneKeyEqual(pk_rel, i, old_row,
new_row, &qkey, RI_KEYPAIR_PK_IDX))
{
/*
* For each key attribute lookup the tuple
* constructor for a corresponding default value
@@ -2690,7 +2683,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
/*
* That's the one - push the expression
* from defval.adbin into the plan's
@@ -2807,7 +2799,6 @@ RI_FKey_keyequal_upd(TriggerData *trigdata)
switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
{
/*
* MATCH <UNSPECIFIED>
*/
@@ -3079,7 +3070,6 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
for (i = 0; i < key->nkeypairs; i++)
{
/*
* Get one attributes oldvalue. If it is NULL - they're not equal.
*/
@@ -3129,7 +3119,6 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
keys_unequal = true;
for (i = 0; keys_unequal && i < key->nkeypairs; i++)
{
/*
* Get one attributes oldvalue. If it is NULL - they're not equal.
*/
@@ -3252,17 +3241,17 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
CharGetDatum('b'));
if (!HeapTupleIsValid(opr_tup))
elog(ERROR,
"ri_AttributesEqual(): cannot find '=' operator for type %u",
"ri_AttributesEqual(): cannot find '=' operator for type %u",
typeid);
opr_proc = ((Form_pg_operator) GETSTRUCT(opr_tup))->oprcode;
ReleaseSysCache(opr_tup);
/*
* Since fmgr_info could fail, call it *before* creating the
* hashtable entry --- otherwise we could elog leaving an incomplete
* entry in the hashtable. Also, because this will be a permanent
* table entry, we must make sure any subsidiary structures of the
* fmgr record are kept in TopMemoryContext.
* hashtable entry --- otherwise we could elog leaving an
* incomplete entry in the hashtable. Also, because this will be
* a permanent table entry, we must make sure any subsidiary
* structures of the fmgr record are kept in TopMemoryContext.
*/
fmgr_info_cxt(opr_proc, &finfo, TopMemoryContext);

View File

@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.85 2001/10/08 19:55:07 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.86 2001/10/25 05:49:45 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -84,7 +84,7 @@ typedef struct
List *rtable; /* List of RangeTblEntry nodes */
List *namespace; /* List of joinlist items (RangeTblRef and
* JoinExpr nodes) */
} deparse_namespace;
} deparse_namespace;
/* ----------
@@ -118,8 +118,8 @@ static void get_basic_select_query(Query *query, deparse_context *context);
static void get_setop_query(Node *setOp, Query *query,
deparse_context *context, bool toplevel);
static void get_rule_sortgroupclause(SortClause *srt, List *tlist,
bool force_colno,
deparse_context *context);
bool force_colno,
deparse_context *context);
static void get_names_for_var(Var *var, deparse_context *context,
char **refname, char **attname);
static bool get_alias_for_case(CaseExpr *caseexpr, deparse_context *context,
@@ -138,7 +138,7 @@ static void get_from_clause(Query *query, deparse_context *context);
static void get_from_clause_item(Node *jtnode, Query *query,
deparse_context *context);
static void get_opclass_name(Oid opclass, Oid actual_datatype,
StringInfo buf);
StringInfo buf);
static bool tleIsArrayAssign(TargetEntry *tle);
static char *quote_identifier(char *ident);
static char *get_relation_name(Oid relid);
@@ -302,7 +302,6 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
appendStringInfo(&buf, "Not a view");
else
{
/*
* Get the rules definition and put it into executors memory
*/
@@ -409,7 +408,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
sep = "";
for (keyno = 0; keyno < INDEX_MAX_KEYS; keyno++)
{
AttrNumber attnum = idxrec->indkey[keyno];
AttrNumber attnum = idxrec->indkey[keyno];
if (attnum == InvalidAttrNumber)
break;
@@ -470,16 +469,17 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
*/
if (VARSIZE(&idxrec->indpred) > VARHDRSZ)
{
Node *node;
List *context;
char *exprstr;
char *str;
Node *node;
List *context;
char *exprstr;
char *str;
/* Convert TEXT object to C string */
exprstr = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&idxrec->indpred)));
PointerGetDatum(&idxrec->indpred)));
/* Convert expression to node tree */
node = (Node *) stringToNode(exprstr);
/*
* If top level is a List, assume it is an implicit-AND structure,
* and convert to explicit AND. This is needed for partial index
@@ -528,14 +528,14 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
Datum
pg_get_expr(PG_FUNCTION_ARGS)
{
text *expr = PG_GETARG_TEXT_P(0);
Oid relid = PG_GETARG_OID(1);
text *result;
Node *node;
List *context;
char *exprstr;
char *relname;
char *str;
text *expr = PG_GETARG_TEXT_P(0);
Oid relid = PG_GETARG_OID(1);
text *result;
Node *node;
List *context;
char *exprstr;
char *relname;
char *str;
/* Get the name for the relation */
relname = get_rel_name(relid);
@@ -550,19 +550,17 @@ pg_get_expr(PG_FUNCTION_ARGS)
node = (Node *) stringToNode(exprstr);
/*
* If top level is a List, assume it is an implicit-AND structure,
* and convert to explicit AND. This is needed for partial index
* If top level is a List, assume it is an implicit-AND structure, and
* convert to explicit AND. This is needed for partial index
* predicates.
*/
if (node && IsA(node, List))
{
node = (Node *) make_ands_explicit((List *) node);
}
/* Deparse */
context = deparse_context_for(relname, relid);
str = deparse_expression(node, context, false);
/* Pass the result back as TEXT */
result = DatumGetTextP(DirectFunctionCall1(textin,
CStringGetDatum(str)));
@@ -1178,10 +1176,11 @@ get_rule_sortgroupclause(SortClause *srt, List *tlist, bool force_colno,
tle = get_sortgroupclause_tle(srt, tlist);
expr = tle->expr;
/*
* Use column-number form if requested by caller or if expression is a
* constant --- a constant is ambiguous (and will be misinterpreted
* by findTargetlistEntry()) if we dump it explicitly.
* constant --- a constant is ambiguous (and will be misinterpreted by
* findTargetlistEntry()) if we dump it explicitly.
*/
if (force_colno || (expr && IsA(expr, Const)))
{
@@ -1938,54 +1937,54 @@ get_rule_expr(Node *node, deparse_context *context)
case T_NullTest:
{
NullTest *ntest = (NullTest *) node;
NullTest *ntest = (NullTest *) node;
appendStringInfo(buf, "(");
get_rule_expr(ntest->arg, context);
switch (ntest->nulltesttype)
{
case IS_NULL:
switch (ntest->nulltesttype)
{
case IS_NULL:
appendStringInfo(buf, " IS NULL)");
break;
case IS_NOT_NULL:
case IS_NOT_NULL:
appendStringInfo(buf, " IS NOT NULL)");
break;
default:
elog(ERROR, "get_rule_expr: unexpected nulltesttype %d",
(int) ntest->nulltesttype);
default:
elog(ERROR, "get_rule_expr: unexpected nulltesttype %d",
(int) ntest->nulltesttype);
}
}
break;
case T_BooleanTest:
{
BooleanTest *btest = (BooleanTest *) node;
BooleanTest *btest = (BooleanTest *) node;
appendStringInfo(buf, "(");
get_rule_expr(btest->arg, context);
switch (btest->booltesttype)
{
case IS_TRUE:
switch (btest->booltesttype)
{
case IS_TRUE:
appendStringInfo(buf, " IS TRUE)");
break;
case IS_NOT_TRUE:
case IS_NOT_TRUE:
appendStringInfo(buf, " IS NOT TRUE)");
break;
case IS_FALSE:
case IS_FALSE:
appendStringInfo(buf, " IS FALSE)");
break;
case IS_NOT_FALSE:
case IS_NOT_FALSE:
appendStringInfo(buf, " IS NOT FALSE)");
break;
case IS_UNKNOWN:
case IS_UNKNOWN:
appendStringInfo(buf, " IS UNKNOWN)");
break;
case IS_NOT_UNKNOWN:
case IS_NOT_UNKNOWN:
appendStringInfo(buf, " IS NOT UNKNOWN)");
break;
default:
elog(ERROR, "get_rule_expr: unexpected booltesttype %d",
(int) btest->booltesttype);
default:
elog(ERROR, "get_rule_expr: unexpected booltesttype %d",
(int) btest->booltesttype);
}
}
break;
@@ -2051,14 +2050,15 @@ get_func_expr(Expr *expr, deparse_context *context)
appendStringInfoChar(buf, '(');
get_rule_expr(arg, context);
/*
* Show typename with appropriate length decoration. Note that
* since exprIsLengthCoercion succeeded, the function's output
* type is the right thing to use.
*
* XXX In general it is incorrect to quote the result of
* format_type_with_typemod, but are there any special cases
* where we should do so?
* format_type_with_typemod, but are there any special cases where
* we should do so?
*/
typdesc = format_type_with_typemod(procStruct->prorettype,
coercedTypmod);
@@ -2107,7 +2107,7 @@ strip_type_coercion(Node *expr, Oid resultType)
if (IsA(expr, RelabelType))
return strip_type_coercion(((RelabelType *) expr)->arg, resultType);
if (IsA(expr, Expr) && ((Expr *) expr)->opType == FUNC_EXPR)
if (IsA(expr, Expr) &&((Expr *) expr)->opType == FUNC_EXPR)
{
Func *func;
HeapTuple procTuple;
@@ -2135,7 +2135,7 @@ strip_type_coercion(Node *expr, Oid resultType)
}
/* See if function has same name as its result type */
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(procStruct->prorettype),
ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup for type %u failed",
@@ -2221,7 +2221,6 @@ 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
@@ -2625,7 +2624,6 @@ tleIsArrayAssign(TargetEntry *tle)
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
@@ -2657,7 +2655,6 @@ quote_identifier(char *ident)
if (safe)
{
/*
* Check for keyword. This test is overly strong, since many of
* the "keywords" known to the parser are usable as column names,

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.27 2001/09/17 00:29:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.28 2001/10/25 05:49:45 momjian Exp $
*
* NOTES
* input routine largely stolen from boxin().
@@ -116,7 +116,6 @@ tidne(PG_FUNCTION_ARGS)
BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
arg1->ip_posid != arg2->ip_posid);
}
#endif
/*
@@ -125,7 +124,7 @@ tidne(PG_FUNCTION_ARGS)
* Maybe these implementations should be moved to another place
*/
static ItemPointerData Current_last_tid = { {0, 0}, 0};
static ItemPointerData Current_last_tid = {{0, 0}, 0};
void
setLastTid(const ItemPointer tid)
@@ -142,11 +141,11 @@ currtid_byreloid(PG_FUNCTION_ARGS)
Relation rel;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
if (!reloid)
{
*result = Current_last_tid;
PG_RETURN_ITEMPOINTER(result);
}
if (!reloid)
{
*result = Current_last_tid;
PG_RETURN_ITEMPOINTER(result);
}
ItemPointerCopy(tid, result);
if ((rel = heap_open(reloid, AccessShareLock)) != NULL)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.58 2001/10/20 01:02:18 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.59 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,6 +47,7 @@ Datum
timestamp_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -146,7 +147,7 @@ timestamp_scale(PG_FUNCTION_ARGS)
static void
AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
{
if (! TIMESTAMP_NOT_FINITE(*time) &&
if (!TIMESTAMP_NOT_FINITE(*time) &&
(typmod >= 0) && (typmod <= 13))
{
static double TimestampScale = 1;
@@ -158,7 +159,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
TimestampTypmod = typmod;
}
*time = (rint(((double) *time) * TimestampScale)/TimestampScale);
*time = (rint(((double) *time) * TimestampScale) / TimestampScale);
}
}
@@ -170,11 +171,12 @@ Datum
timestamptz_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimestampTz result;
TimestampTz result;
double fsec;
struct tm tt,
*tm = &tt;
@@ -229,7 +231,7 @@ timestamptz_in(PG_FUNCTION_ARGS)
Datum
timestamptz_out(PG_FUNCTION_ARGS)
{
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
char *result;
int tz;
struct tm tt,
@@ -256,9 +258,9 @@ timestamptz_out(PG_FUNCTION_ARGS)
Datum
timestamptz_scale(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
int32 typmod = PG_GETARG_INT32(1);
TimestampTz result;
TimestampTz result;
result = timestamp;
@@ -278,6 +280,7 @@ Datum
interval_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -374,8 +377,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
if (typmod != -1)
{
int range = ((typmod >> 16) & 0x7FFF);
int precision = (typmod & 0xFFFF);
int range = ((typmod >> 16) & 0x7FFF);
int precision = (typmod & 0xFFFF);
if (range == 0x7FFF)
{
@@ -392,69 +395,65 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
interval->time = 0;
}
/* YEAR TO MONTH */
else if (range == (MASK(YEAR) | MASK(MONTH)))
{
else if (range == (MASK(YEAR) | MASK(MONTH)))
interval->time = 0;
}
else if (range == MASK(DAY))
{
interval->month = 0;
interval->time = (((int)(interval->time / 86400)) * 86400);
interval->time = (((int) (interval->time / 86400)) * 86400);
}
else if (range == MASK(HOUR))
{
double day;
double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
interval->time = (((int)(interval->time / 3600)) * 3600.0);
interval->time = (((int) (interval->time / 3600)) * 3600.0);
}
else if (range == MASK(MINUTE))
{
double hour;
double hour;
interval->month = 0;
TMODULO(interval->time, hour, 3600.0);
interval->time = (((int)(interval->time / 60)) * 60);
interval->time = (((int) (interval->time / 60)) * 60);
}
else if (range == MASK(SECOND))
{
double hour;
double hour;
interval->month = 0;
TMODULO(interval->time, hour, 60.0);
// interval->time = (int)(interval->time);
/* interval->time = (int)(interval->time); */
}
/* DAY TO HOUR */
else if (range == (MASK(DAY) | MASK(HOUR)))
{
interval->month = 0;
interval->time = (((int)(interval->time / 3600)) * 3600);
interval->time = (((int) (interval->time / 3600)) * 3600);
}
/* DAY TO MINUTE */
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE)))
{
interval->month = 0;
interval->time = (((int)(interval->time / 60)) * 60);
interval->time = (((int) (interval->time / 60)) * 60);
}
/* DAY TO SECOND */
else if (range == (MASK(DAY) | MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
{
interval->month = 0;
}
/* HOUR TO MINUTE */
else if (range == (MASK(HOUR) | MASK(MINUTE)))
{
double day;
double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
interval->time = (((int)(interval->time / 60)) * 60);
interval->time = (((int) (interval->time / 60)) * 60);
}
/* HOUR TO SECOND */
else if (range == (MASK(HOUR) | MASK(MINUTE) | MASK(SECOND)))
{
double day;
double day;
interval->month = 0;
TMODULO(interval->time, day, 86400.0);
@@ -462,20 +461,18 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
/* MINUTE TO SECOND */
else if (range == (MASK(MINUTE) | MASK(SECOND)))
{
double hour;
double hour;
interval->month = 0;
TMODULO(interval->time, hour, 3600.0);
}
else
{
elog(ERROR, "AdjustIntervalForTypmod(): internal coding error");
}
if (precision != 0xFFFF)
{
static double IntervalScale = 1;
static int IntervalTypmod = 0;
static int IntervalTypmod = 0;
if (precision != IntervalTypmod)
{
@@ -483,15 +480,15 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
IntervalScale = pow(10.0, IntervalTypmod);
}
/* Hmm. For the time field, we can get to a large value
* since we store everything related to an absolute interval
* (e.g. years worth of days) in this one field. So we have
/*
* Hmm. For the time field, we can get to a large value since
* we store everything related to an absolute interval (e.g.
* years worth of days) in this one field. So we have
* precision problems doing rint() on this field if the field
* is too large. This resulted in an annoying "...0001" appended
* to the printed result on my Linux box.
* I hate doing an expensive math operation like log10()
* to avoid this, but what else can we do??
* - thomas 2001-10-19
* is too large. This resulted in an annoying "...0001"
* appended to the printed result on my Linux box. I hate
* doing an expensive math operation like log10() to avoid
* this, but what else can we do?? - thomas 2001-10-19
*/
if ((log10(interval->time) + IntervalTypmod) <= 13)
interval->time = (rint(interval->time * IntervalScale) / IntervalScale);
@@ -521,7 +518,7 @@ EncodeSpecialTimestamp(Timestamp dt, char *str)
Datum
now(PG_FUNCTION_ARGS)
{
TimestampTz result;
TimestampTz result;
AbsoluteTime sec;
int usec;
@@ -571,14 +568,14 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
struct tm *tx;
#endif
date0 = date2j(2000, 1, 1);
/* If HasCTZSet is true then we have a brute force time zone specified.
* Go ahead and rotate to the local time zone since we will later bypass
* any calls which adjust the tm fields.
/*
* If HasCTZSet is true then we have a brute force time zone
* specified. Go ahead and rotate to the local time zone since we will
* later bypass any calls which adjust the tm fields.
*/
if (HasCTZSet && (tzp != NULL))
dt -= CTimeZone;
@@ -607,9 +604,9 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
if (tzp != NULL)
{
/* We have a brute force time zone per SQL99?
* Then use it without change
* since we have already rotated to the time zone.
/*
* We have a brute force time zone per SQL99? Then use it without
* change since we have already rotated to the time zone.
*/
if (HasCTZSet)
{
@@ -623,8 +620,9 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn)
*tzn = NULL;
}
/* Does this fall within the capabilities of the localtime() interface?
* Then use this to rotate to the local time zone.
/*
* Does this fall within the capabilities of the localtime()
* interface? Then use this to rotate to the local time zone.
*/
else if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
@@ -1031,7 +1029,6 @@ interval_hash(PG_FUNCTION_ARGS)
Datum
overlaps_timestamp(PG_FUNCTION_ARGS)
{
/*
* The arguments are Timestamps, but we leave them as generic Datums
* to avoid unnecessary conversions between value and reference forms
@@ -1101,7 +1098,6 @@ overlaps_timestamp(PG_FUNCTION_ARGS)
*/
if (TIMESTAMP_GT(ts1, ts2))
{
/*
* This case is ts1 < te2 OR te1 < te2, which may look redundant
* but in the presence of nulls it's not quite completely so.
@@ -1137,7 +1133,6 @@ overlaps_timestamp(PG_FUNCTION_ARGS)
}
else
{
/*
* For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a
* rather silly way of saying "true if both are nonnull, else
@@ -1225,9 +1220,7 @@ timestamp_pl_span(PG_FUNCTION_ARGS)
Timestamp result;
if (TIMESTAMP_NOT_FINITE(timestamp))
{
result = timestamp;
}
else
{
if (span->month != 0)
@@ -1309,16 +1302,14 @@ timestamp_mi_span(PG_FUNCTION_ARGS)
Datum
timestamptz_pl_span(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
TimestampTz result;
TimestampTz result;
int tz;
char *tzn;
if (TIMESTAMP_NOT_FINITE(timestamp))
{
result = timestamp;
}
else
{
if (span->month != 0)
@@ -1349,7 +1340,7 @@ timestamptz_pl_span(PG_FUNCTION_ARGS)
if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
elog(ERROR, "Unable to add TIMESTAMP and INTERVAL"
"\n\ttimestamptz_pl_span() internal error encoding timestamp");
"\n\ttimestamptz_pl_span() internal error encoding timestamp");
}
else
{
@@ -1373,7 +1364,7 @@ timestamptz_pl_span(PG_FUNCTION_ARGS)
Datum
timestamptz_mi_span(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
Interval tspan;
@@ -1584,8 +1575,8 @@ interval_accum(PG_FUNCTION_ARGS)
memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval));
newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
IntervalPGetDatum(&sumX),
IntervalPGetDatum(newval)));
IntervalPGetDatum(&sumX),
IntervalPGetDatum(newval)));
N.time += 1;
transdatums[0] = IntervalPGetDatum(newsum);
@@ -1750,8 +1741,8 @@ timestamp_age(PG_FUNCTION_ARGS)
Datum
timestamptz_age(PG_FUNCTION_ARGS)
{
TimestampTz dt1 = PG_GETARG_TIMESTAMP(0);
TimestampTz dt2 = PG_GETARG_TIMESTAMP(1);
TimestampTz dt1 = PG_GETARG_TIMESTAMP(0);
TimestampTz dt2 = PG_GETARG_TIMESTAMP(1);
Interval *result;
double fsec,
fsec1,
@@ -1978,7 +1969,7 @@ interval_text(PG_FUNCTION_ARGS)
int len;
str = DatumGetCString(DirectFunctionCall1(interval_out,
IntervalPGetDatum(interval)));
IntervalPGetDatum(interval)));
len = (strlen(str) + VARHDRSZ);
@@ -2043,7 +2034,7 @@ timestamp_trunc(PG_FUNCTION_ARGS)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
@@ -2113,8 +2104,8 @@ Datum
timestamptz_trunc(PG_FUNCTION_ARGS)
{
text *units = PG_GETARG_TEXT_P(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz result;
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz result;
int tz;
int type,
val;
@@ -2130,7 +2121,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP WITH TIME ZONE units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
@@ -2218,7 +2209,7 @@ interval_trunc(PG_FUNCTION_ARGS)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
@@ -2281,7 +2272,7 @@ interval_trunc(PG_FUNCTION_ARGS)
{
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
*result = *interval;
}
@@ -2390,7 +2381,7 @@ timestamp_part(PG_FUNCTION_ARGS)
if (VARSIZE(units) - VARHDRSZ > MAXDATELEN)
elog(ERROR, "TIMESTAMP units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
up = VARDATA(units);
lp = lowunits;
for (i = 0; i < (VARSIZE(units) - VARHDRSZ); i++)
@@ -2517,7 +2508,7 @@ Datum
timestamptz_part(PG_FUNCTION_ARGS)
{
text *units = PG_GETARG_TEXT_P(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
float8 result;
int tz;
int type,
@@ -2756,7 +2747,7 @@ interval_part(PG_FUNCTION_ARGS)
default:
elog(ERROR, "INTERVAL units '%s' not supported",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
result = 0;
}
@@ -2781,7 +2772,7 @@ interval_part(PG_FUNCTION_ARGS)
{
elog(ERROR, "INTERVAL units '%s' not recognized",
DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(units))));
PointerGetDatum(units))));
result = 0;
}
@@ -2797,7 +2788,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
{
text *zone = PG_GETARG_TEXT_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz result;
TimestampTz result;
int tz;
int type,
val;
@@ -2845,7 +2836,7 @@ timestamp_izone(PG_FUNCTION_ARGS)
{
Interval *zone = PG_GETARG_INTERVAL_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz result;
TimestampTz result;
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
@@ -2869,16 +2860,14 @@ Datum
timestamp_timestamptz(PG_FUNCTION_ARGS)
{
Timestamp timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz result;
TimestampTz result;
struct tm tt,
*tm = &tt;
double fsec;
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
{
result = timestamp;
}
else
{
if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL) != 0)
@@ -2899,7 +2888,7 @@ timestamp_timestamptz(PG_FUNCTION_ARGS)
Datum
timestamptz_timestamp(PG_FUNCTION_ARGS)
{
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(0);
Timestamp result;
struct tm tt,
*tm = &tt;
@@ -2908,9 +2897,7 @@ timestamptz_timestamp(PG_FUNCTION_ARGS)
int tz;
if (TIMESTAMP_NOT_FINITE(timestamp))
{
result = timestamp;
}
else
{
if (timestamp2tm(timestamp, &tz, tm, &fsec, &tzn) != 0)
@@ -2930,9 +2917,9 @@ Datum
timestamptz_zone(PG_FUNCTION_ARGS)
{
text *zone = PG_GETARG_TEXT_P(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
text *result;
TimestampTz dt;
TimestampTz dt;
int tz;
int type,
val;
@@ -3007,9 +2994,9 @@ Datum
timestamptz_izone(PG_FUNCTION_ARGS)
{
Interval *zone = PG_GETARG_INTERVAL_P(0);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
TimestampTz timestamp = PG_GETARG_TIMESTAMP(1);
text *result;
TimestampTz dt;
TimestampTz dt;
int tz;
char *tzn = "";
double fsec;
@@ -3033,7 +3020,7 @@ timestamptz_izone(PG_FUNCTION_ARGS)
if (timestamp2tm(dt, NULL, tm, &fsec, NULL) != 0)
elog(ERROR, "Unable to decode TIMESTAMP WITH TIME ZONE"
"\n\ttimestamptz_izone() internal coding error");
"\n\ttimestamptz_izone() internal coding error");
EncodeDateTime(tm, fsec, &tz, &tzn, USE_ISO_DATES, buf);
len = (strlen(buf) + VARHDRSZ);

View File

@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.19 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.20 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,6 @@ bit_in(PG_FUNCTION_ARGS)
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarBit *result; /* The resulting bit string */
@@ -77,7 +76,6 @@ bit_in(PG_FUNCTION_ARGS)
}
else
{
/*
* Otherwise it's binary. This allows things like cast('1001' as
* bit) to work transparently.
@@ -233,8 +231,8 @@ _bit(PG_FUNCTION_ARGS)
FunctionCallInfoData locfcinfo;
/*
* Since bit() is a built-in function, we should only need to look
* it up once per run.
* Since bit() is a built-in function, we should only need to look it
* up once per run.
*/
static FmgrInfo bit_finfo;
@@ -264,7 +262,6 @@ varbit_in(PG_FUNCTION_ARGS)
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarBit *result; /* The resulting bit string */
@@ -733,7 +730,6 @@ bitsubstr(PG_FUNCTION_ARGS)
}
else
{
/*
* OK, we've got a true substring starting at position s1-1 and
* ending at position e1-1

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.84 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.85 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -65,23 +65,26 @@ Datum
bpcharin(PG_FUNCTION_ARGS)
{
char *s = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
BpChar *result;
char *r;
size_t len, maxlen;
size_t len,
maxlen;
int i;
#ifdef MULTIBYTE
int charlen; /* number of charcters in the input string */
char *ermsg;
int charlen; /* number of charcters in the input string */
char *ermsg;
#endif
len = strlen(s);
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(s, len)))
elog(ERROR,"%s",ermsg);
elog(ERROR, "%s", ermsg);
charlen = pg_mbstrlen(s);
#endif
@@ -104,19 +107,21 @@ bpcharin(PG_FUNCTION_ARGS)
{
/* Verify that extra characters are spaces, and clip them off */
#ifdef MULTIBYTE
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
/*
* at this point, len is the actual BYTE length of the
* input string, maxlen is the max number of
* CHARACTERS allowed for this bpchar type.
* at this point, len is the actual BYTE length of the input
* string, maxlen is the max number of CHARACTERS allowed for this
* bpchar type.
*/
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
len = mbmaxlen;
else
elog(ERROR, "value too long for type character(%d)", maxlen);
/*
* XXX: at this point, maxlen is the necessary byte
* length, not the number of CHARACTERS!
* XXX: at this point, maxlen is the necessary byte length, not
* the number of CHARACTERS!
*/
maxlen = len;
#else
@@ -130,8 +135,8 @@ bpcharin(PG_FUNCTION_ARGS)
else
{
/*
* XXX: at this point, maxlen is the necessary byte
* length, not the number of CHARACTERS!
* XXX: at this point, maxlen is the necessary byte length, not
* the number of CHARACTERS!
*/
maxlen = len + (maxlen - charlen);
}
@@ -194,9 +199,10 @@ bpchar(PG_FUNCTION_ARGS)
char *r;
char *s;
int i;
#ifdef MULTIBYTE
int charlen; /* number of charcters in the input string
+ VARHDRSZ*/
int charlen; /* number of charcters in the input string
* + VARHDRSZ */
#endif
len = VARSIZE(source);
@@ -217,7 +223,7 @@ bpchar(PG_FUNCTION_ARGS)
size_t maxmblen;
maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ,
maxlen - VARHDRSZ) + VARHDRSZ;
maxlen - VARHDRSZ) + VARHDRSZ;
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
@@ -225,6 +231,7 @@ bpchar(PG_FUNCTION_ARGS)
maxlen - VARHDRSZ);
len = maxmblen;
/*
* XXX: at this point, maxlen is the necessary byte
* length+VARHDRSZ, not the number of CHARACTERS!
@@ -403,20 +410,23 @@ Datum
varcharin(PG_FUNCTION_ARGS)
{
char *s = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarChar *result;
size_t len, maxlen;
size_t len,
maxlen;
#ifdef MULTIBYTE
char *ermsg;
char *ermsg;
#endif
len = strlen(s);
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(s, len)))
elog(ERROR,"%s",ermsg);
elog(ERROR, "%s", ermsg);
#endif
maxlen = atttypmod - VARHDRSZ;
@@ -424,7 +434,7 @@ varcharin(PG_FUNCTION_ARGS)
{
/* Verify that extra characters are spaces, and clip them off */
#ifdef MULTIBYTE
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
len = mbmaxlen;
@@ -499,7 +509,7 @@ varchar(PG_FUNCTION_ARGS)
/* truncate multi-byte string preserving multi-byte boundary */
maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ,
maxlen - VARHDRSZ) + VARHDRSZ;
maxlen - VARHDRSZ) + VARHDRSZ;
for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++)
if (*(VARDATA(source) + i) != ' ')
@@ -586,8 +596,8 @@ bpcharlen(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
PG_RETURN_INT32(
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);
#else
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
#endif
@@ -794,8 +804,8 @@ varcharlen(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
PG_RETURN_INT32(
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);
#else
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
#endif

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.73 2001/09/14 17:46:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.74 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,21 +54,15 @@ byteain(PG_FUNCTION_ARGS)
for (byte = 0, tp = inputText; *tp != '\0'; byte++)
{
if (tp[0] != '\\')
{
tp++;
}
else if ( (tp[0] == '\\') &&
(tp[1] >= '0' && tp[1] <= '3') &&
(tp[2] >= '0' && tp[2] <= '7') &&
(tp[3] >= '0' && tp[3] <= '7') )
{
else if ((tp[0] == '\\') &&
(tp[1] >= '0' && tp[1] <= '3') &&
(tp[2] >= '0' && tp[2] <= '7') &&
(tp[3] >= '0' && tp[3] <= '7'))
tp += 4;
}
else if ( (tp[0] == '\\') &&
(tp[1] == '\\') )
{
else if ((tp[0] == '\\') &&
(tp[1] == '\\'))
tp += 2;
}
else
{
/*
@@ -87,13 +81,11 @@ byteain(PG_FUNCTION_ARGS)
while (*tp != '\0')
{
if (tp[0] != '\\')
{
*rp++ = *tp++;
}
else if ( (tp[0] == '\\') &&
(tp[1] >= '0' && tp[1] <= '3') &&
(tp[2] >= '0' && tp[2] <= '7') &&
(tp[3] >= '0' && tp[3] <= '7') )
else if ((tp[0] == '\\') &&
(tp[1] >= '0' && tp[1] <= '3') &&
(tp[2] >= '0' && tp[2] <= '7') &&
(tp[3] >= '0' && tp[3] <= '7'))
{
byte = VAL(tp[1]);
byte <<= 3;
@@ -102,8 +94,8 @@ byteain(PG_FUNCTION_ARGS)
*rp++ = byte + VAL(tp[3]);
tp += 4;
}
else if ( (tp[0] == '\\') &&
(tp[1] == '\\') )
else if ((tp[0] == '\\') &&
(tp[1] == '\\'))
{
*rp++ = '\\';
tp += 2;
@@ -111,8 +103,8 @@ byteain(PG_FUNCTION_ARGS)
else
{
/*
* We should never get here. The first pass should
* not allow it.
* We should never get here. The first pass should not allow
* it.
*/
elog(ERROR, "Bad input string for type bytea");
}
@@ -188,15 +180,16 @@ textin(PG_FUNCTION_ARGS)
char *inputText = PG_GETARG_CSTRING(0);
text *result;
int len;
#ifdef MULTIBYTE
char *ermsg;
char *ermsg;
#endif
len = strlen(inputText) + VARHDRSZ;
#ifdef MULTIBYTE
if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ)))
elog(ERROR,"%s",ermsg);
elog(ERROR, "%s", ermsg);
#endif
result = (text *) palloc(len);
@@ -368,7 +361,6 @@ text_substr(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
int i;
char *p;
#endif
len = VARSIZE(string) - VARHDRSZ;
@@ -442,7 +434,6 @@ textpos(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
pg_wchar *ps1,
*ps2;
#endif
if (VARSIZE(t2) <= VARHDRSZ)
@@ -819,8 +810,8 @@ byteapos(PG_FUNCTION_ARGS)
p;
int len1,
len2;
char *p1,
*p2;
char *p1,
*p2;
if (VARSIZE(t2) <= VARHDRSZ)
PG_RETURN_INT32(1); /* result for empty pattern */
@@ -1072,8 +1063,8 @@ name_text(PG_FUNCTION_ARGS)
Datum
byteaeq(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
bool result;
@@ -1096,8 +1087,8 @@ byteaeq(PG_FUNCTION_ARGS)
Datum
byteane(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
bool result;
@@ -1120,8 +1111,8 @@ byteane(PG_FUNCTION_ARGS)
Datum
bytealt(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
@@ -1140,8 +1131,8 @@ bytealt(PG_FUNCTION_ARGS)
Datum
byteale(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
@@ -1160,8 +1151,8 @@ byteale(PG_FUNCTION_ARGS)
Datum
byteagt(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
@@ -1180,8 +1171,8 @@ byteagt(PG_FUNCTION_ARGS)
Datum
byteage(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;
@@ -1200,8 +1191,8 @@ byteage(PG_FUNCTION_ARGS)
Datum
byteacmp(PG_FUNCTION_ARGS)
{
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
bytea *arg1 = PG_GETARG_BYTEA_P(0);
bytea *arg2 = PG_GETARG_BYTEA_P(1);
int len1,
len2;
int cmp;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.83 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.84 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,13 +30,13 @@
#include "utils/syscache.h"
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
/* #define CACHEDEBUG *//* turns DEBUG elogs on */
/*
* Constants related to size of the catcache.
*
* NCCBUCKETS should be prime and must be less than 64K (because
* SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In
* SharedInvalCatcacheMsg crams hash indexes into a uint16 field). In
* practice it should be a lot less, anyway, to avoid chewing up too much
* space on hash bucket headers.
*
@@ -642,13 +642,13 @@ CatalogCacheFlushRelation(Oid relId)
tupRelid = ct->tuple.t_data->t_oid;
else
{
bool isNull;
bool isNull;
tupRelid = DatumGetObjectId(
fastgetattr(&ct->tuple,
cache->cc_reloidattr,
cache->cc_tupdesc,
&isNull));
fastgetattr(&ct->tuple,
cache->cc_reloidattr,
cache->cc_tupdesc,
&isNull));
Assert(!isNull);
}
@@ -707,8 +707,8 @@ InitCatCache(int id,
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
/*
* if first time through, initialize the cache group header,
* including global LRU list header
* if first time through, initialize the cache group header, including
* global LRU list header
*/
if (CacheHdr == NULL)
{
@@ -740,7 +740,7 @@ InitCatCache(int id,
cp->cc_relname = relname;
cp->cc_indname = indname;
cp->cc_reloidattr = reloidattr;
cp->cc_relisshared = false; /* temporary */
cp->cc_relisshared = false; /* temporary */
cp->cc_tupdesc = (TupleDesc) NULL;
cp->cc_ntup = 0;
cp->cc_size = NCCBUCKETS;
@@ -749,8 +749,8 @@ InitCatCache(int id,
cp->cc_key[i] = key[i];
/*
* new cache is initialized as far as we can go for now.
* print some debugging information, if appropriate.
* new cache is initialized as far as we can go for now. print some
* debugging information, if appropriate.
*/
InitCatCache_DEBUG1;
@@ -1105,9 +1105,7 @@ ReleaseCatCache(HeapTuple tuple)
&& ct->dead
#endif
)
{
CatCacheRemoveCTup(ct->my_cache, ct);
}
}
/*
@@ -1141,7 +1139,7 @@ ReleaseCatCache(HeapTuple tuple)
void
PrepareToInvalidateCacheTuple(Relation relation,
HeapTuple tuple,
void (*function) (int, Index, ItemPointer, Oid))
void (*function) (int, Index, ItemPointer, Oid))
{
CatCache *ccp;

View File

@@ -22,14 +22,14 @@
* second lives till end of transaction. Finally, we need a third list of
* all tuples outdated in the current transaction; if we commit, we send
* those invalidation events to all other backends (via the SI message queue)
* so that they can flush obsolete entries from their caches. This list
* so that they can flush obsolete entries from their caches. This list
* definitely can't be processed until after we commit, otherwise the other
* backends won't see our updated tuples as good.
*
* We do not need to register EVERY tuple operation in this way, just those
* on tuples in relations that have associated catcaches. We do, however,
* on tuples in relations that have associated catcaches. We do, however,
* have to register every operation on every tuple that *could* be in a
* catcache, whether or not it currently is in our cache. Also, if the
* catcache, whether or not it currently is in our cache. Also, if the
* tuple is in a relation that has multiple catcaches, we need to register
* an invalidation message for each such catcache. catcache.c's
* PrepareToInvalidateCacheTuple() routine provides the knowledge of which
@@ -56,7 +56,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.45 2001/06/19 19:42:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.46 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,15 +74,15 @@
/*
* To minimize palloc traffic, we keep pending requests in successively-
* larger chunks (a slightly more sophisticated version of an expansible
* array). All request types can be stored as SharedInvalidationMessage
* array). All request types can be stored as SharedInvalidationMessage
* records.
*/
typedef struct InvalidationChunk
{
struct InvalidationChunk *next; /* list link */
struct InvalidationChunk *next; /* list link */
int nitems; /* # items currently stored in chunk */
int maxitems; /* size of allocated array in this chunk */
SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */
SharedInvalidationMessage msgs[1]; /* VARIABLE LENGTH ARRAY */
} InvalidationChunk; /* VARIABLE LENGTH STRUCTURE */
typedef struct InvalidationListHeader
@@ -148,7 +148,7 @@ AddInvalidationMessage(InvalidationChunk **listHdr,
chunk = (InvalidationChunk *)
MemoryContextAlloc(TopTransactionContext,
sizeof(InvalidationChunk) +
(FIRSTCHUNKSIZE-1) * sizeof(SharedInvalidationMessage));
(FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = FIRSTCHUNKSIZE;
chunk->next = *listHdr;
@@ -157,12 +157,12 @@ AddInvalidationMessage(InvalidationChunk **listHdr,
else if (chunk->nitems >= chunk->maxitems)
{
/* Need another chunk; double size of last chunk */
int chunksize = 2 * chunk->maxitems;
int chunksize = 2 * chunk->maxitems;
chunk = (InvalidationChunk *)
MemoryContextAlloc(TopTransactionContext,
sizeof(InvalidationChunk) +
(chunksize-1) * sizeof(SharedInvalidationMessage));
(chunksize - 1) *sizeof(SharedInvalidationMessage));
chunk->nitems = 0;
chunk->maxitems = chunksize;
chunk->next = *listHdr;
@@ -279,7 +279,10 @@ DiscardInvalidationMessages(InvalidationListHeader *hdr, bool physicalFree)
}
else
{
/* Assume the storage will go away at xact end, just reset pointers */
/*
* Assume the storage will go away at xact end, just reset
* pointers
*/
hdr->cclist = NULL;
hdr->rclist = NULL;
}
@@ -421,7 +424,7 @@ InvalidateSystemCaches(void)
static void
PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
void (*CacheIdRegisterFunc) (int, Index,
ItemPointer, Oid),
ItemPointer, Oid),
void (*RelationIdRegisterFunc) (Oid, Oid))
{
Oid tupleRelId;
@@ -460,12 +463,12 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
* Yes. We need to register a relcache invalidation event for the
* relation identified by relationId.
*
* KLUGE ALERT: we always send the relcache event with MyDatabaseId,
* even if the rel in question is shared. This essentially means that
* only backends in this same database will react to the relcache flush
* request. This is in fact appropriate, since only those backends could
* see our pg_class or pg_attribute change anyway. It looks a bit ugly
* though.
* KLUGE ALERT: we always send the relcache event with MyDatabaseId, even
* if the rel in question is shared. This essentially means that only
* backends in this same database will react to the relcache flush
* request. This is in fact appropriate, since only those backends
* could see our pg_class or pg_attribute change anyway. It looks a
* bit ugly though.
*/
(*RelationIdRegisterFunc) (MyDatabaseId, relationId);
}
@@ -498,7 +501,7 @@ AcceptInvalidationMessages(void)
* If isCommit, we must send out the messages in our GlobalInvalidMsgs list
* to the shared invalidation message queue. Note that these will be read
* not only by other backends, but also by our own backend at the next
* transaction start (via AcceptInvalidationMessages). Therefore, it's okay
* transaction start (via AcceptInvalidationMessages). Therefore, it's okay
* to discard any pending LocalInvalidMsgs, since these will be redundant
* with the global list.
*
@@ -538,7 +541,7 @@ AtEOXactInvalidationMessages(bool isCommit)
* in a transaction.
*
* Here, we send no messages to the shared queue, since we don't know yet if
* we will commit. But we do need to locally process the LocalInvalidMsgs
* we will commit. But we do need to locally process the LocalInvalidMsgs
* list, so as to flush our caches of any tuples we have outdated in the
* current command.
*
@@ -563,9 +566,10 @@ CommandEndInvalidationMessages(bool isCommit)
ProcessInvalidationMessages(&RollbackMsgs,
LocalExecuteInvalidationMessage);
}
/*
* LocalInvalidMsgs list is not interesting anymore, so flush it
* (for real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs.
* LocalInvalidMsgs list is not interesting anymore, so flush it (for
* real). Do *not* clear GlobalInvalidMsgs or RollbackMsgs.
*/
DiscardInvalidationMessages(&LocalInvalidMsgs, true);
}

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.58 2001/09/06 02:07:42 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.59 2001/10/25 05:49:46 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -589,7 +589,6 @@ get_relnatts(Oid relid)
else
return InvalidAttrNumber;
}
#endif
/*
@@ -723,7 +722,6 @@ get_typalign(Oid typid)
else
return 'i';
}
#endif
char
@@ -778,8 +776,8 @@ get_typdefault(Oid typid, Datum *defaultValue)
typelem = type->typelem;
/*
* typdefault is potentially null, so don't try to access it as a struct
* field. Must do it the hard way with SysCacheGetAttr.
* typdefault is potentially null, so don't try to access it as a
* struct field. Must do it the hard way with SysCacheGetAttr.
*/
textDefaultVal = SysCacheGetAttr(TYPEOID,
typeTuple,
@@ -828,6 +826,7 @@ get_typavgwidth(Oid typid, int32 typmod)
*/
if (typlen > 0)
return typlen;
/*
* type_maximum_size knows the encoding of typmod for some datatypes;
* don't duplicate that knowledge here.
@@ -836,16 +835,17 @@ get_typavgwidth(Oid typid, int32 typmod)
if (maxwidth > 0)
{
/*
* For BPCHAR, the max width is also the only width. Otherwise
* we need to guess about the typical data width given the max.
* A sliding scale for percentage of max width seems reasonable.
* For BPCHAR, the max width is also the only width. Otherwise we
* need to guess about the typical data width given the max. A
* sliding scale for percentage of max width seems reasonable.
*/
if (typid == BPCHAROID)
return maxwidth;
if (maxwidth <= 32)
return maxwidth; /* assume full width */
if (maxwidth < 1000)
return 32 + (maxwidth - 32) / 2; /* assume 50% */
return 32 + (maxwidth - 32) / 2; /* assume 50% */
/*
* Beyond 1000, assume we're looking at something like
* "varchar(10000)" where the limit isn't actually reached often,
@@ -853,6 +853,7 @@ get_typavgwidth(Oid typid, int32 typmod)
*/
return 32 + (1000 - 32) / 2;
}
/*
* Ooops, we have no idea ... wild guess time.
*/
@@ -887,7 +888,6 @@ get_typtype(Oid typid)
else
return '\0';
}
#endif
/* ---------- STATISTICS CACHE ---------- */
@@ -909,7 +909,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
0, 0);
if (HeapTupleIsValid(tp))
{
int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
int32 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
ReleaseSysCache(tp);
if (stawidth > 0)
@@ -977,14 +977,17 @@ get_attstatsslot(HeapTuple statstuple,
if (isnull)
elog(ERROR, "get_attstatsslot: stavalues is null");
statarray = DatumGetArrayTypeP(val);
/*
* Do initial examination of the array. This produces a list
* of text Datums --- ie, pointers into the text array value.
* Do initial examination of the array. This produces a list of
* text Datums --- ie, pointers into the text array value.
*/
deconstruct_array(statarray, false, -1, 'i', values, nvalues);
narrayelem = *nvalues;
/*
* We now need to replace each text Datum by its internal equivalent.
* We now need to replace each text Datum by its internal
* equivalent.
*
* Get the type input proc and typelem for the column datatype.
*/
@@ -997,9 +1000,10 @@ get_attstatsslot(HeapTuple statstuple,
fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc);
typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem;
ReleaseSysCache(typeTuple);
/*
* Do the conversions. The palloc'd array of Datums is reused
* in place.
* Do the conversions. The palloc'd array of Datums is reused in
* place.
*/
for (j = 0; j < narrayelem; j++)
{
@@ -1013,6 +1017,7 @@ get_attstatsslot(HeapTuple statstuple,
Int32GetDatum(atttypmod));
pfree(strval);
}
/*
* Free statarray if it's a detoasted copy.
*/
@@ -1028,10 +1033,11 @@ get_attstatsslot(HeapTuple statstuple,
if (isnull)
elog(ERROR, "get_attstatsslot: stanumbers is null");
statarray = DatumGetArrayTypeP(val);
/*
* We expect the array to be a 1-D float4 array; verify that.
* We don't need to use deconstruct_array() since the array
* data is just going to look like a C array of float4 values.
* We expect the array to be a 1-D float4 array; verify that. We
* don't need to use deconstruct_array() since the array data is
* just going to look like a C array of float4 values.
*/
narrayelem = ARR_DIMS(statarray)[0];
if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
@@ -1040,6 +1046,7 @@ get_attstatsslot(HeapTuple statstuple,
*numbers = (float4 *) palloc(narrayelem * sizeof(float4));
memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4));
*nnumbers = narrayelem;
/*
* Free statarray if it's a detoasted copy.
*/
@@ -1057,9 +1064,9 @@ free_attstatsslot(Oid atttype,
{
if (values)
{
if (! get_typbyval(atttype))
if (!get_typbyval(atttype))
{
int i;
int i;
for (i = 0; i < nvalues; i++)
pfree(DatumGetPointer(values[i]));

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.146 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.147 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -226,7 +226,6 @@ static void RelationClearRelation(Relation relation, bool rebuildIt);
#ifdef ENABLE_REINDEX_NAILED_RELATIONS
static void RelationReloadClassinfo(Relation relation);
#endif /* ENABLE_REINDEX_NAILED_RELATIONS */
static void RelationFlushRelation(Relation relation);
static Relation RelationNameCacheGetRelation(const char *relationName);
@@ -273,7 +272,6 @@ static List *insert_ordered_oid(List *list, Oid datum);
static HeapTuple
ScanPgRelation(RelationBuildDescInfo buildinfo)
{
/*
* If this is bootstrap time (initdb), then we can't use the system
* catalog indices, because they may not exist yet. Otherwise, we
@@ -333,7 +331,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
return_tuple = pg_class_tuple;
else
{
/*
* a satanic bug used to live here: pg_class_tuple used to be
* returned here without having the corresponding buffer pinned.
@@ -382,7 +379,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
default:
elog(ERROR, "ScanPgRelation: bad buildinfo");
return_tuple = NULL;/* keep compiler quiet */
return_tuple = NULL; /* keep compiler quiet */
}
heap_close(pg_class_desc, AccessShareLock);
@@ -461,7 +458,6 @@ static void
RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
Relation relation)
{
/*
* If this is bootstrap time (initdb), then we can't use the system
* catalog indices, because they may not exist yet. Otherwise, we
@@ -649,7 +645,6 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
{
#ifdef _DROP_COLUMN_HACK__
bool columnDropped = false;
#endif /* _DROP_COLUMN_HACK__ */
atttup = AttributeRelidNumIndexScan(attrel,
@@ -767,7 +762,7 @@ RelationBuildRuleLock(Relation relation)
*/
rulescxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(relation),
0, /* minsize */
0, /* minsize */
1024, /* initsize */
1024); /* maxsize */
relation->rd_rulescxt = rulescxt;
@@ -1106,16 +1101,16 @@ RelationInitIndexAccessInfo(Relation relation)
amsupport = relation->rd_am->amsupport;
/*
* Make the private context to hold index access info. The reason
* we need a context, and not just a couple of pallocs, is so that
* we won't leak any subsidiary info attached to fmgr lookup records.
* Make the private context to hold index access info. The reason we
* need a context, and not just a couple of pallocs, is so that we
* won't leak any subsidiary info attached to fmgr lookup records.
*
* Context parameters are set on the assumption that it'll probably not
* contain much data.
*/
indexcxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(relation),
0, /* minsize */
0, /* minsize */
512, /* initsize */
1024); /* maxsize */
relation->rd_indexcxt = indexcxt;
@@ -1128,7 +1123,7 @@ RelationInitIndexAccessInfo(Relation relation)
if (amsupport > 0)
{
int nsupport = natts * amsupport;
int nsupport = natts * amsupport;
support = (RegProcedure *)
MemoryContextAlloc(indexcxt, nsupport * sizeof(RegProcedure));
@@ -1214,8 +1209,9 @@ formrdesc(char *relationName,
strcpy(RelationGetPhysicalRelationName(relation), relationName);
/*
* It's important to distinguish between shared and non-shared relations,
* even at bootstrap time, to make sure we know where they are stored.
* It's important to distinguish between shared and non-shared
* relations, even at bootstrap time, to make sure we know where they
* are stored.
*/
relation->rd_rel->relisshared = IsSharedSystemRelationName(relationName);
@@ -1267,8 +1263,8 @@ formrdesc(char *relationName,
if (!IsBootstrapProcessingMode())
{
/*
* This list is incomplete, but it only has to work for the
* set of rels that formrdesc is used for ...
* This list is incomplete, but it only has to work for the set of
* rels that formrdesc is used for ...
*/
if (strcmp(relationName, RelationRelationName) == 0 ||
strcmp(relationName, AttributeRelationName) == 0 ||
@@ -1560,7 +1556,6 @@ RelationReloadClassinfo(Relation relation)
return;
}
#endif /* ENABLE_REINDEX_NAILED_RELATIONS */
/*
@@ -1649,7 +1644,6 @@ RelationClearRelation(Relation relation, bool rebuildIt)
}
else
{
/*
* When rebuilding an open relcache entry, must preserve ref count
* and myxactonly flag. Also attempt to preserve the tupledesc,
@@ -1663,7 +1657,7 @@ RelationClearRelation(Relation relation, bool rebuildIt)
RuleLock *old_rules = relation->rd_rules;
MemoryContext old_rulescxt = relation->rd_rulescxt;
TriggerDesc *old_trigdesc = relation->trigdesc;
BlockNumber old_nblocks = relation->rd_nblocks;
BlockNumber old_nblocks = relation->rd_nblocks;
RelationBuildDescInfo buildinfo;
buildinfo.infotype = INFO_RELID;
@@ -1730,7 +1724,6 @@ RelationFlushRelation(Relation relation)
if (relation->rd_myxactonly)
{
/*
* Local rels should always be rebuilt, not flushed; the relcache
* entry must live until RelationPurgeLocalRelation().
@@ -1739,7 +1732,6 @@ RelationFlushRelation(Relation relation)
}
else
{
/*
* Nonlocal rels can be dropped from the relcache if not open.
*/
@@ -1837,7 +1829,6 @@ RelationFlushIndexes(Relation *r,
relation->rd_rel->relam == accessMethodId))
RelationFlushRelation(relation);
}
#endif
@@ -1982,8 +1973,8 @@ RelationBuildLocalRelation(const char *relname,
rel->rd_isnailed = true;
/*
* create a new tuple descriptor from the one passed in
* (we do this to copy it into the cache context)
* create a new tuple descriptor from the one passed in (we do this to
* copy it into the cache context)
*/
rel->rd_att = CreateTupleDescCopyConstr(tupDesc);
@@ -2003,9 +1994,10 @@ RelationBuildLocalRelation(const char *relname,
rel->rd_rel->relchecks = tupDesc->constr->num_check;
/*
* Insert relation OID and database/tablespace ID into the right places.
* XXX currently we assume physical tblspace/relnode are same as logical
* dbid/reloid. Probably should pass an extra pair of parameters.
* Insert relation OID and database/tablespace ID into the right
* places. XXX currently we assume physical tblspace/relnode are same
* as logical dbid/reloid. Probably should pass an extra pair of
* parameters.
*/
rel->rd_rel->relisshared = (dbid == InvalidOid);
@@ -2149,7 +2141,6 @@ RelationCacheInitialize(void)
void
RelationCacheInitializePhase2(void)
{
/*
* Get the real pg_class tuple for each nailed-in-cache relcache entry
* that was made by RelationCacheInitialize(), and replace the phony
@@ -2159,7 +2150,6 @@ RelationCacheInitializePhase2(void)
*/
if (!IsBootstrapProcessingMode())
{
/*
* Initialize critical system index relation descriptors, first.
* They are to make building relation descriptors fast.
@@ -2764,9 +2754,9 @@ init_irels(void)
*/
indexcxt = AllocSetContextCreate(CacheMemoryContext,
RelationGetRelationName(ird),
0, /* minsize */
512, /* initsize */
1024); /* maxsize */
0, /* minsize */
512, /* initsize */
1024); /* maxsize */
ird->rd_indexcxt = indexcxt;
/* next, read the index strategy map */
@@ -2848,7 +2838,6 @@ write_irels(void)
fd = PathNameOpenFile(tempfilename, O_WRONLY | O_CREAT | O_TRUNC | PG_BINARY, 0600);
if (fd < 0)
{
/*
* We used to consider this a fatal error, but we might as well
* continue with backend startup ...

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.65 2001/08/21 16:36:05 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.66 2001/10/25 05:49:46 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@@ -133,7 +133,7 @@ static struct cachedesc cacheinfo[] = {
0,
0
}},
{AccessMethodProcedureRelationName, /* AMPROCNUM */
{AccessMethodProcedureRelationName, /* AMPROCNUM */
AccessMethodProcedureIndex,
0,
2,
@@ -365,7 +365,8 @@ static struct cachedesc cacheinfo[] = {
}}
};
static CatCache *SysCache[lengthof(cacheinfo)];
static CatCache *SysCache[
lengthof(cacheinfo)];
static int SysCacheSize = lengthof(cacheinfo);
static bool CacheInitialized = false;
@@ -564,7 +565,6 @@ SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber,
bool *isNull)
{
/*
* We just need to get the TupleDesc out of the cache entry, and then
* we can apply heap_getattr(). We expect that the cache control data

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.89 2001/10/18 23:07:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.90 2001/10/25 05:49:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -135,16 +135,15 @@ elog(int lev, const char *fmt,...)
errorstr = useful_strerror(errno);
/*
* Convert initialization errors into fatal errors. This is
* probably redundant, because Warn_restart_ready won't be set
* anyway.
* Convert initialization errors into fatal errors. This is probably
* redundant, because Warn_restart_ready won't be set anyway.
*/
if (lev == ERROR && IsInitProcessingMode())
lev = FATAL;
/*
* If we are inside a critical section, all errors become
* REALLYFATAL errors. See miscadmin.h.
* If we are inside a critical section, all errors become REALLYFATAL
* errors. See miscadmin.h.
*/
if (lev == ERROR || lev == FATAL)
{
@@ -161,6 +160,7 @@ elog(int lev, const char *fmt,...)
timestamp_size += PID_SIZE;
fmt = gettext(fmt);
/*
* Set up the expanded format, consisting of the prefix string plus
* input format, with any %m replaced by strerror() string (since
@@ -189,11 +189,11 @@ elog(int lev, const char *fmt,...)
lev = ERROR;
prefix = elog_message_prefix(lev);
}
/*
* gettext doesn't allocate memory, except in the very
* first call (which this isn't), so it's safe to
* translate here. Worst case we get the untranslated
* string back.
* gettext doesn't allocate memory, except in the very first
* call (which this isn't), so it's safe to translate here.
* Worst case we get the untranslated string back.
*/
/* translator: This must fit in fmt_fixedbuf. */
fmt = gettext("elog: out of memory");
@@ -329,7 +329,7 @@ elog(int lev, const char *fmt,...)
write_syslog(syslog_level, msg_buf + timestamp_size);
}
#endif /* ENABLE_SYSLOG */
#endif /* ENABLE_SYSLOG */
/* syslog doesn't want a trailing newline, but other destinations do */
strcat(msg_buf, "\n");
@@ -665,8 +665,7 @@ write_syslog(int level, const char *line)
syslog(level, "[%lu] %s", seq, line);
}
}
#endif /* ENABLE_SYSLOG */
#endif /* ENABLE_SYSLOG */
static void
@@ -682,22 +681,22 @@ send_message_to_frontend(int type, const char *msg)
pq_endmessage(&buf);
/*
* This flush is normally not necessary, since postgres.c will
* flush out waiting data when control returns to the main loop.
* But it seems best to leave it here, so that the client has some
* clue what happened if the backend dies before getting back to
* the main loop ... error/notice messages should not be a
* performance-critical path anyway, so an extra flush won't hurt
* much ...
* This flush is normally not necessary, since postgres.c will flush
* out waiting data when control returns to the main loop. But it
* seems best to leave it here, so that the client has some clue what
* happened if the backend dies before getting back to the main loop
* ... error/notice messages should not be a performance-critical path
* anyway, so an extra flush won't hurt much ...
*/
pq_flush();
}
static const char *useful_strerror(int errnum)
static const char *
useful_strerror(int errnum)
{
/* this buffer is only used if errno has a bogus value */
static char errorstr_buf[48];
static char errorstr_buf[48];
char *str;
if (errnum == ERANGE)
@@ -712,7 +711,10 @@ static const char *useful_strerror(int errnum)
*/
if (str == NULL || *str == '\0')
{
/* translator: This string will be truncated at 47 characters expanded. */
/*
* translator: This string will be truncated at 47 characters
* expanded.
*/
snprintf(errorstr_buf, 48, gettext("operating system error %d"), errnum);
str = errorstr_buf;
}
@@ -725,7 +727,7 @@ static const char *useful_strerror(int errnum)
static const char *
elog_message_prefix(int lev)
{
const char * prefix = NULL;
const char *prefix = NULL;
switch (lev)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.37 2001/03/22 03:59:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.38 2001/10/25 05:49:46 momjian Exp $
*
* NOTE
* XXX this code needs improvement--check for state violations and
@@ -138,16 +138,15 @@ ExcPrint(Exception *excP,
}
#ifdef NOT_USED
ExcProc *
ExcProc *
ExcGetUnCaught(void)
{
return ExcUnCaughtP;
}
#endif
#ifdef NOT_USED
ExcProc *
ExcProc *
ExcSetUnCaught(ExcProc *newP)
{
ExcProc *oldP = ExcUnCaughtP;
@@ -156,7 +155,6 @@ ExcSetUnCaught(ExcProc *newP)
return oldP;
}
#endif
static void

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.53 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.54 2001/10/25 05:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,12 +46,12 @@ static DynamicFileList *file_tail = (DynamicFileList *) NULL;
#define SAME_INODE(A,B) ((A).st_ino == (B).inode && (A).st_dev == (B).device)
char * Dynamic_library_path;
char *Dynamic_library_path;
static bool file_exists(const char *name);
static char * find_in_dynamic_libpath(const char * basename);
static char * expand_dynamic_library_name(const char *name);
static char * substitute_libpath_macro(const char * name);
static char *find_in_dynamic_libpath(const char *basename);
static char *expand_dynamic_library_name(const char *name);
static char *substitute_libpath_macro(const char *name);
/*
* Load the specified dynamic-link library file, and look for a function
@@ -237,7 +237,7 @@ file_exists(const char *name)
if (stat(name, &st) == 0)
return S_ISDIR(st.st_mode) ? false : true;
else if (!(errno == ENOENT || errno == ENOTDIR || errno == EACCES))
elog(ERROR, "stat failed on %s: %s", name, strerror(errno));
elog(ERROR, "stat failed on %s: %s", name, strerror(errno));
return false;
}
@@ -258,7 +258,7 @@ file_exists(const char *name)
* If name contains a slash, check if the file exists, if so return
* the name. Else (no slash) try to expand using search path (see
* find_in_dynamic_libpath below); if that works, return the fully
* expanded file name. If the previous failed, append DLSUFFIX and
* expanded file name. If the previous failed, append DLSUFFIX and
* try again. If all fails, return NULL.
*
* A non-NULL result will always be freshly palloc'd.
@@ -266,9 +266,9 @@ file_exists(const char *name)
static char *
expand_dynamic_library_name(const char *name)
{
bool have_slash;
char * new;
char * full;
bool have_slash;
char *new;
char *full;
AssertArg(name);
@@ -288,7 +288,7 @@ expand_dynamic_library_name(const char *name)
pfree(full);
}
new = palloc(strlen(name)+ strlen(DLSUFFIX) + 1);
new = palloc(strlen(name) + strlen(DLSUFFIX) + 1);
strcpy(new, name);
strcat(new, DLSUFFIX);
@@ -307,7 +307,7 @@ expand_dynamic_library_name(const char *name)
return full;
pfree(full);
}
return NULL;
}
@@ -317,10 +317,10 @@ expand_dynamic_library_name(const char *name)
* Result is always freshly palloc'd.
*/
static char *
substitute_libpath_macro(const char * name)
substitute_libpath_macro(const char *name)
{
size_t macroname_len;
char * replacement = NULL;
size_t macroname_len;
char *replacement = NULL;
AssertArg(name != NULL);
@@ -329,7 +329,7 @@ substitute_libpath_macro(const char * name)
macroname_len = strcspn(name + 1, "/") + 1;
if (strncmp(name, "$libdir", macroname_len)==0)
if (strncmp(name, "$libdir", macroname_len) == 0)
replacement = PKGLIBDIR;
else
elog(ERROR, "invalid macro name in dynamic library path");
@@ -338,7 +338,7 @@ substitute_libpath_macro(const char * name)
return pstrdup(replacement);
else
{
char * new;
char *new;
new = palloc(strlen(replacement) + (strlen(name) - macroname_len) + 1);
@@ -357,10 +357,10 @@ substitute_libpath_macro(const char * name)
* return NULL.
*/
static char *
find_in_dynamic_libpath(const char * basename)
find_in_dynamic_libpath(const char *basename)
{
const char *p;
size_t baselen;
size_t baselen;
AssertArg(basename != NULL);
AssertArg(strchr(basename, '/') == NULL);
@@ -374,10 +374,10 @@ find_in_dynamic_libpath(const char * basename)
for (;;)
{
size_t len;
char * piece;
char * mangled;
char *full;
size_t len;
char *piece;
char *mangled;
char *full;
len = strcspn(p, ":");

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.55 2001/10/06 23:21:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.56 2001/10/25 05:49:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,7 +43,6 @@ typedef int32 ((*func_ptr) ());
#else
typedef char *((*func_ptr) ());
#endif
/*
@@ -143,9 +142,9 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
char *prosrc;
/*
* fn_oid *must* be filled in last. Some code assumes that if fn_oid is
* valid, the whole struct is valid. Some FmgrInfo struct's do survive
* elogs.
* fn_oid *must* be filled in last. Some code assumes that if fn_oid
* is valid, the whole struct is valid. Some FmgrInfo struct's do
* survive elogs.
*/
finfo->fn_oid = InvalidOid;
finfo->fn_extra = NULL;
@@ -154,7 +153,8 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
if ((fbp = fmgr_isbuiltin(functionId)) != NULL)
{
/*
* Fast path for builtin functions: don't bother consulting pg_proc
* Fast path for builtin functions: don't bother consulting
* pg_proc
*/
finfo->fn_nargs = fbp->nargs;
finfo->fn_strict = fbp->strict;
@@ -189,6 +189,7 @@ fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
switch (procedureStruct->prolang)
{
case INTERNALlanguageId:
/*
* For an ordinary builtin function, we should never get here
* because the isbuiltin() search above will have succeeded.
@@ -405,7 +406,7 @@ fetch_finfo_record(void *filehandle, char *funcname)
* Copy an FmgrInfo struct
*
* This is inherently somewhat bogus since we can't reliably duplicate
* language-dependent subsidiary info. We cheat by zeroing fn_extra,
* language-dependent subsidiary info. We cheat by zeroing fn_extra,
* instead, meaning that subsidiary info will have to be recomputed.
*/
void
@@ -624,7 +625,6 @@ fmgr_oldstyle(PG_FUNCTION_ARGS)
static Datum
fmgr_untrusted(PG_FUNCTION_ARGS)
{
/*
* Currently these are unsupported. Someday we might do something
* like forking a subprocess to execute 'em.
@@ -1457,19 +1457,20 @@ Int64GetDatum(int64 X)
*retval = X;
return PointerGetDatum(retval);
#else /* INT64_IS_BUSTED */
#else /* INT64_IS_BUSTED */
/*
* On a machine with no 64-bit-int C datatype, sizeof(int64) will not be
* 8, but we want Int64GetDatum to return an 8-byte object anyway, with
* zeroes in the unused bits. This is needed so that, for example,
* hash join of int8 will behave properly.
* On a machine with no 64-bit-int C datatype, sizeof(int64) will not
* be 8, but we want Int64GetDatum to return an 8-byte object anyway,
* with zeroes in the unused bits. This is needed so that, for
* example, hash join of int8 will behave properly.
*/
int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8));
MemSet(retval, 0, Max(sizeof(int64), 8));
*retval = X;
return PointerGetDatum(retval);
#endif /* INT64_IS_BUSTED */
#endif /* INT64_IS_BUSTED */
}
Datum

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.38 2001/10/05 17:28:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.39 2001/10/25 05:49:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,11 +66,11 @@
static void *DynaHashAlloc(Size size);
static uint32 call_hash(HTAB *hashp, void *k);
static HASHSEGMENT seg_alloc(HTAB *hashp);
static bool element_alloc(HTAB *hashp);
static bool dir_realloc(HTAB *hashp);
static bool expand_table(HTAB *hashp);
static bool hdefault(HTAB *hashp);
static bool init_htab(HTAB *hashp, long nelem);
static bool element_alloc(HTAB *hashp);
static bool dir_realloc(HTAB *hashp);
static bool expand_table(HTAB *hashp);
static bool hdefault(HTAB *hashp);
static bool init_htab(HTAB *hashp, long nelem);
static void hash_corrupted(HTAB *hashp);
@@ -104,7 +104,7 @@ HTAB *
hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
{
HTAB *hashp;
HASHHDR *hctl;
HASHHDR *hctl;
/* First time through, create a memory context for hash tables */
if (!DynaHashCxt)
@@ -132,7 +132,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
if (flags & HASH_FUNCTION)
hashp->hash = info->hash;
else
hashp->hash = string_hash; /* default hash function */
hashp->hash = string_hash; /* default hash function */
if (flags & HASH_SHARED_MEM)
{
@@ -212,20 +212,20 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
{
/* hash table structures live in child of given context */
CurrentDynaHashCxt = AllocSetContextCreate(info->hcxt,
"DynaHashTable",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
"DynaHashTable",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
hashp->hcxt = CurrentDynaHashCxt;
}
else
{
/* hash table structures live in child of DynaHashCxt */
CurrentDynaHashCxt = AllocSetContextCreate(DynaHashCxt,
"DynaHashTable",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
"DynaHashTable",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
hashp->hcxt = CurrentDynaHashCxt;
}
}
@@ -244,7 +244,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
static bool
hdefault(HTAB *hashp)
{
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
MemSet(hctl, 0, sizeof(HASHHDR));
@@ -274,7 +274,7 @@ hdefault(HTAB *hashp)
static bool
init_htab(HTAB *hashp, long nelem)
{
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
HASHSEGMENT *segp;
int nbuckets;
int nsegs;
@@ -372,7 +372,7 @@ hash_estimate_size(long num_entries, long entrysize)
nDirEntries <<= 1; /* dir_alloc doubles dsize at each call */
/* fixed control info */
size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */
size += MAXALIGN(sizeof(HASHHDR)); /* but not HTAB, per above */
/* directory */
size += MAXALIGN(nDirEntries * sizeof(HASHSEGMENT));
/* segments */
@@ -429,15 +429,15 @@ hash_destroy(HTAB *hashp)
hash_stats("destroy", hashp);
/*
* Free buckets, dir etc. by destroying the hash table's
* memory context.
* Free buckets, dir etc. by destroying the hash table's memory
* context.
*/
MemoryContextDelete(hashp->hcxt);
/*
* Free the HTAB and control structure, which are allocated
* in the parent context (DynaHashCxt or the context given
* by the caller of hash_create()).
* Free the HTAB and control structure, which are allocated in the
* parent context (DynaHashCxt or the context given by the caller
* of hash_create()).
*/
MEM_FREE(hashp->hctl);
MEM_FREE(hashp->tabname);
@@ -460,7 +460,6 @@ hash_stats(const char *where, HTAB *hashp)
where, hash_accesses, hash_collisions);
fprintf(stderr, "hash_stats: total expansions %ld\n",
hash_expansions);
#endif
}
@@ -470,7 +469,7 @@ hash_stats(const char *where, HTAB *hashp)
static uint32
call_hash(HTAB *hashp, void *k)
{
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
long hash_val,
bucket;
@@ -503,7 +502,7 @@ call_hash(HTAB *hashp, void *k)
* HASH_ENTER case, but is redundant with the return value otherwise.
*
* The HASH_FIND_SAVE/HASH_REMOVE_SAVED interface is a hack to save one
* table lookup in a find/process/remove scenario. Note that no other
* table lookup in a find/process/remove scenario. Note that no other
* addition or removal in the table can safely happen in between.
*----------
*/
@@ -513,17 +512,17 @@ hash_search(HTAB *hashp,
HASHACTION action,
bool *foundPtr)
{
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
uint32 bucket;
long segment_num;
long segment_ndx;
HASHSEGMENT segp;
HASHBUCKET currBucket;
HASHSEGMENT segp;
HASHBUCKET currBucket;
HASHBUCKET *prevBucketPtr;
static struct State
{
HASHBUCKET currBucket;
HASHBUCKET currBucket;
HASHBUCKET *prevBucketPtr;
} saveState;
@@ -631,7 +630,7 @@ hash_search(HTAB *hashp,
{
/* no free elements. allocate another chunk of buckets */
if (!element_alloc(hashp))
return NULL; /* out of memory */
return NULL; /* out of memory */
currBucket = hctl->freeList;
Assert(currBucket != NULL);
}
@@ -651,8 +650,9 @@ hash_search(HTAB *hashp,
if (++hctl->nentries / (hctl->max_bucket + 1) > hctl->ffactor)
{
/*
* NOTE: failure to expand table is not a fatal error, it just
* means we have to run at higher fill factor than we wanted.
* NOTE: failure to expand table is not a fatal error, it
* just means we have to run at higher fill factor than we
* wanted.
*/
expand_table(hashp);
}
@@ -688,13 +688,13 @@ void *
hash_seq_search(HASH_SEQ_STATUS *status)
{
HTAB *hashp = status->hashp;
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
while (status->curBucket <= hctl->max_bucket)
{
long segment_num;
long segment_ndx;
HASHSEGMENT segp;
HASHSEGMENT segp;
if (status->curEntry != NULL)
{
@@ -703,7 +703,7 @@ hash_seq_search(HASH_SEQ_STATUS *status)
curElem = status->curEntry;
status->curEntry = curElem->link;
if (status->curEntry == NULL) /* end of this bucket */
if (status->curEntry == NULL) /* end of this bucket */
++status->curBucket;
return (void *) ELEMENTKEY(curElem);
}
@@ -731,7 +731,7 @@ hash_seq_search(HASH_SEQ_STATUS *status)
*/
status->curEntry = segp[segment_ndx];
if (status->curEntry == NULL) /* empty bucket */
if (status->curEntry == NULL) /* empty bucket */
++status->curBucket;
}
@@ -747,8 +747,8 @@ hash_seq_search(HASH_SEQ_STATUS *status)
static bool
expand_table(HTAB *hashp)
{
HASHHDR *hctl = hashp->hctl;
HASHSEGMENT old_seg,
HASHHDR *hctl = hashp->hctl;
HASHSEGMENT old_seg,
new_seg;
long old_bucket,
new_bucket;
@@ -758,7 +758,7 @@ expand_table(HTAB *hashp)
old_segndx;
HASHBUCKET *oldlink,
*newlink;
HASHBUCKET currElement,
HASHBUCKET currElement,
nextElement;
#ifdef HASH_STATISTICS
@@ -879,7 +879,7 @@ dir_realloc(HTAB *hashp)
static HASHSEGMENT
seg_alloc(HTAB *hashp)
{
HASHSEGMENT segp;
HASHSEGMENT segp;
CurrentDynaHashCxt = hashp->hcxt;
segp = (HASHSEGMENT) hashp->alloc(sizeof(HASHBUCKET) * hashp->hctl->ssize);
@@ -898,7 +898,7 @@ seg_alloc(HTAB *hashp)
static bool
element_alloc(HTAB *hashp)
{
HASHHDR *hctl = hashp->hctl;
HASHHDR *hctl = hashp->hctl;
Size elementSize;
HASHELEMENT *tmpElement;
int i;
@@ -930,7 +930,7 @@ hash_corrupted(HTAB *hashp)
{
/*
* If the corruption is in a shared hashtable, we'd better force a
* systemwide restart. Otherwise, just shut down this one backend.
* systemwide restart. Otherwise, just shut down this one backend.
*/
if (hashp->isshared)
elog(STOP, "Hash table '%s' corrupted", hashp->tabname);

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.14 2001/10/01 05:36:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.15 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,41 +57,41 @@ tag_hash(void *key, int keysize)
* Use four byte chunks in a "jump table" to go a little faster.
*
* Currently the maximum keysize is 16 (mar 17 1992). I have put in
* cases for up to 32. Bigger than this will resort to a for loop
* cases for up to 32. Bigger than this will resort to a for loop
* (see the default case).
*/
switch (keysize)
{
case 8 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 7 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 6 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 5 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 4 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 3 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case 2 * sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
/* fall through */
case sizeof(int):
h = (h * PRIME1) ^ (*k++);
h = (h * PRIME1) ^(*k++);
break;
default:
@@ -102,7 +102,7 @@ tag_hash(void *key, int keysize)
/* Cope with any partial-int leftover bytes */
if (keysize > 0)
{
unsigned char *keybyte = (unsigned char *) k;
unsigned char *keybyte = (unsigned char *) k;
do
h = (h * PRIME1) ^ (*keybyte++);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.3 2001/03/23 18:42:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/hash/pg_crc.c,v 1.4 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -413,5 +413,4 @@ const uint64 crc_table[256] = {
INT64CONST(0x5DEDC41A34BBEEB2), INT64CONST(0x1F1D25F19D51D821),
INT64CONST(0xD80C07CD676F8394), INT64CONST(0x9AFCE626CE85B507)
};
#endif /* INT64_IS_BUSTED */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.61 2001/10/21 03:25:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.62 2001/10/25 05:49:51 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
@@ -57,7 +57,8 @@ Relation reldesc; /* current relation descriptor */
char OutputFileName[MAXPGPATH];
char pg_pathname[MAXPGPATH]; /* full path to postgres executable */
char pg_pathname[MAXPGPATH]; /* full path to postgres
* executable */
BackendId MyBackendId;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.80 2001/10/19 18:19:41 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.81 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -256,7 +256,6 @@ next_token(FILE *fp, char *buf, const int bufsz)
if (c != '\n')
{
/*
* build a token in buf of next characters up to EOF, eol, or
* blank.
@@ -317,8 +316,8 @@ SetCharSet()
if (p && *p != '\0')
{
map_file = malloc(strlen(DataDir) + strlen(p) + 2);
if (! map_file)
map_file = malloc(strlen(DataDir) + strlen(p) + 2);
if (!map_file)
elog(FATAL, "out of memory");
sprintf(map_file, "%s/%s", DataDir, p);
file = AllocateFile(map_file, PG_BINARY_R);
@@ -381,7 +380,6 @@ convertstr(unsigned char *buff, int len, int dest)
}
return ch;
}
#endif
@@ -487,7 +485,8 @@ InitializeSessionUserIdStandalone(void)
/*
* Change session auth ID while running
*/
void SetSessionAuthorization(const char * username)
void
SetSessionAuthorization(const char *username)
{
int32 userid;
@@ -579,13 +578,12 @@ CreateLockFile(const char *filename, bool amPostmaster,
pid_t my_pid = getpid();
/*
* We need a loop here because of race conditions. But don't loop
* We need a loop here because of race conditions. But don't loop
* forever (for example, a non-writable $PGDATA directory might cause
* a failure that won't go away). 100 tries seems like plenty.
*/
for (ntries = 0; ; ntries++)
for (ntries = 0;; ntries++)
{
/*
* Try to create the lock file --- O_EXCL makes this atomic.
*/

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.94 2001/10/19 17:03:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.95 2001/10/25 05:49:51 momjian Exp $
*
*
*-------------------------------------------------------------------------
@@ -221,7 +221,10 @@ InitPostgres(const char *dbname, const char *username)
char *fullpath,
datpath[MAXPGPATH];
/* Formerly we validated DataDir here, but now that's done earlier. */
/*
* Formerly we validated DataDir here, but now that's done
* earlier.
*/
/*
* Find oid and path of the database we're about to open. Since
@@ -257,7 +260,7 @@ InitPostgres(const char *dbname, const char *username)
*/
/*
* Set up my per-backend PROC struct in shared memory. (We need to
* Set up my per-backend PROC struct in shared memory. (We need to
* know MyDatabaseId before we can do this, since it's entered into
* the PROC struct.)
*/
@@ -284,8 +287,8 @@ InitPostgres(const char *dbname, const char *username)
AmiTransactionOverride(bootstrap);
/*
* Initialize the relation descriptor cache.
* The pre-allocated reldescs are created here.
* Initialize the relation descriptor cache. The pre-allocated
* reldescs are created here.
*/
RelationCacheInitialize();
@@ -320,9 +323,8 @@ InitPostgres(const char *dbname, const char *username)
RelationCacheInitializePhase2();
/*
* Figure out our postgres user id. In standalone mode we use a
* fixed id, otherwise we figure it out from the authenticated
* user name.
* Figure out our postgres user id. In standalone mode we use a fixed
* id, otherwise we figure it out from the authenticated user name.
*/
if (bootstrap)
InitializeSessionUserIdStandalone();
@@ -388,7 +390,6 @@ InitPostgres(const char *dbname, const char *username)
static void
ShutdownPostgres(void)
{
/*
* These operations are really just a minimal subset of
* AbortTransaction(). We don't want to do any inessential cleanup,
@@ -408,7 +409,7 @@ ShutdownPostgres(void)
* has to happen before bufmgr shutdown, so having smgr register a
* callback for it wouldn't work.
*/
smgrDoPendingDeletes(false);/* delete as though aborting xact */
smgrDoPendingDeletes(false); /* delete as though aborting xact */
}

View File

@@ -7,7 +7,7 @@
*
* 1999/1/15 Tatsuo Ishii
*
* $Id: big5.c,v 1.7 2001/02/10 02:31:27 tgl Exp $
* $Id: big5.c,v 1.8 2001/10/25 05:49:51 momjian Exp $
*/
/* can be used in either frontend or backend */
@@ -19,7 +19,7 @@ typedef struct
{
unsigned short code,
peer;
} codes_t;
} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
};
static unsigned short BinarySearchRange
(codes_t * array, int high, unsigned short code)
(codes_t *array, int high, unsigned short code)
{
int low,
mid,

View File

@@ -6,7 +6,7 @@
* WIN1250 client encoding support contributed by Pavel Behal
* SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
*
* $Id: conv.c,v 1.32 2001/10/16 10:09:17 ishii Exp $
* $Id: conv.c,v 1.33 2001/10/25 05:49:51 momjian Exp $
*
*
*/
@@ -64,7 +64,6 @@
#include "Unicode/utf8_to_koi8r.map"
#include "Unicode/utf8_to_win1251.map"
#endif /* UNICODE_CONVERSION */
/*
@@ -124,7 +123,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
}
else if (c1 > 0x7f)
{
/*
* JIS X0208, X0212, user defined extended characters
*/
@@ -168,7 +166,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
}
else if (k >= 0xf040 && k < 0xf540)
{
/*
* UDC1 mapping to X0208 85 ku - 94 ku JIS code 0x7521 -
* 0x7e7e EUC 0xf5a1 - 0xfefe
@@ -181,7 +178,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
}
else if (k >= 0xf540 && k < 0xfa40)
{
/*
* UDC2 mapping to X0212 85 ku - 94 ku JIS code 0x7521 -
* 0x7e7e EUC 0x8ff5a1 - 0x8ffefe
@@ -194,7 +190,6 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
}
else if (k >= 0xfa40)
{
/*
* mapping IBM kanji to X0208 and X0212
*
@@ -624,7 +619,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len)
{
if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4)
{
*p++ = 0x9d;/* LCPRV2 */
*p++ = 0x9d; /* LCPRV2 */
}
*p++ = lc; /* Plane No. */
*p++ = (cnsBuf >> 8) & 0x00ff;
@@ -793,7 +788,6 @@ mic2latin5(unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_ISO8859_5);
}
#endif
/*
@@ -1275,7 +1269,7 @@ compare2(const void *p1, const void *p2)
*/
static void
utf_to_local(unsigned char *utf, unsigned char *iso,
pg_utf_to_local * map, int size, int len)
pg_utf_to_local *map, int size, int len)
{
unsigned int iutf;
int l;
@@ -1355,14 +1349,14 @@ utf_to_latin5(unsigned char *utf, unsigned char *iso, int len)
{
utf_to_local(utf, iso, ULmapISO8859_5, sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local), len);
}
#endif /* NOT_USED */
#endif /* NOT_USED */
/*
* Cyrillic charsets
*/
/*
* UTF-8 --->KOI8-R
* UTF-8 --->KOI8-R
*/
static void
utf_to_KOI8R(unsigned char *utf, unsigned char *iso, int len)
@@ -1372,7 +1366,7 @@ utf_to_KOI8R(unsigned char *utf, unsigned char *iso, int len)
}
/*
* UTF-8 --->WIN1251
* UTF-8 --->WIN1251
*/
static void
utf_to_WIN1251(unsigned char *utf, unsigned char *iso, int len)
@@ -1382,7 +1376,7 @@ utf_to_WIN1251(unsigned char *utf, unsigned char *iso, int len)
}
/*
* UTF-8 --->ALT
* UTF-8 --->ALT
*/
static void
utf_to_ALT(unsigned char *utf, unsigned char *iso, int len)
@@ -1396,7 +1390,7 @@ utf_to_ALT(unsigned char *utf, unsigned char *iso, int len)
*/
static void
local_to_utf(unsigned char *iso, unsigned char *utf,
pg_local_to_utf * map, int size, int encoding, int len)
pg_local_to_utf *map, int size, int encoding, int len)
{
unsigned int iiso;
int l;
@@ -1441,7 +1435,7 @@ local_to_utf(unsigned char *iso, unsigned char *utf,
if (p == NULL)
{
elog(NOTICE, "local_to_utf: could not convert (0x%04x) %s to UTF-8. Ignored",
iiso, (&pg_enc2name_tbl[ encoding ])->name);
iiso, (&pg_enc2name_tbl[encoding])->name);
continue;
}
if (p->utf & 0xff000000)
@@ -1492,7 +1486,7 @@ latin5_to_utf(unsigned char *iso, unsigned char *utf, int len)
{
local_to_utf(iso, utf, LUmapISO8859_5, sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf), PG_LATIN5, len);
}
#endif /* NOT_USED */
#endif /* NOT_USED */
#define UTF_ISO8859(_id_) \
static void \
@@ -1546,6 +1540,7 @@ ALT_to_utf(unsigned char *iso, unsigned char *utf, int len)
{
local_to_utf(iso, utf, LUmapALT, sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
}
/*
* UTF-8 ---> EUC_JP
*/
@@ -1564,7 +1559,7 @@ static void
euc_jp_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_JP,
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
}
/*
@@ -1585,7 +1580,7 @@ static void
euc_cn_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_CN,
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
}
/*
@@ -1606,7 +1601,7 @@ static void
euc_kr_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_KR,
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
}
/*
@@ -1627,7 +1622,7 @@ static void
euc_tw_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapEUC_TW,
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
}
/*
@@ -1648,7 +1643,7 @@ static void
sjis_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapSJIS,
sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len);
sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len);
}
/*
@@ -1669,7 +1664,7 @@ static void
big5_to_utf(unsigned char *euc, unsigned char *utf, int len)
{
local_to_utf(euc, utf, LUmapBIG5,
sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len);
sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len);
}
/* ----------
@@ -1678,69 +1673,176 @@ big5_to_utf(unsigned char *euc, unsigned char *utf, int len)
* WARINIG: must by same order as pg_enc in include/mb/pg_wchar.h!
* ----------
*/
pg_enconv pg_enconv_tbl[] =
pg_enconv pg_enconv_tbl[] =
{
{ PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii},
{ PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp},
{ PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn},
{ PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr},
{ PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw},
{ PG_UTF8, 0, 0, 0, 0},
{ PG_MULE_INTERNAL, 0, 0, 0, 0},
{ PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1},
{ PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2},
{ PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3},
{ PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4},
{ PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9},
{ PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10},
{ PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13},
{ PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14},
{ PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15},
{ PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16},
{ PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R},
{ PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251},
{ PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT},
{ PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5},
{ PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6},
{ PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7},
{ PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8},
{
PG_SQL_ASCII, ascii2mic, mic2ascii, ascii2utf, utf2ascii
} ,
{
PG_EUC_JP, euc_jp2mic, mic2euc_jp, euc_jp_to_utf, utf_to_euc_jp
},
{
PG_EUC_CN, euc_cn2mic, mic2euc_cn, euc_cn_to_utf, utf_to_euc_cn
},
{
PG_EUC_KR, euc_kr2mic, mic2euc_kr, euc_kr_to_utf, utf_to_euc_kr
},
{
PG_EUC_TW, euc_tw2mic, mic2euc_tw, euc_tw_to_utf, utf_to_euc_tw
},
{
PG_UTF8, 0, 0, 0, 0
},
{
PG_MULE_INTERNAL, 0, 0, 0, 0
},
{
PG_LATIN1, latin12mic, mic2latin1, iso8859_1_to_utf, utf_to_iso8859_1
},
{
PG_LATIN2, latin22mic, mic2latin2, iso8859_2_to_utf, utf_to_iso8859_2
},
{
PG_LATIN3, latin32mic, mic2latin3, iso8859_3_to_utf, utf_to_iso8859_3
},
{
PG_LATIN4, latin42mic, mic2latin4, iso8859_4_to_utf, utf_to_iso8859_4
},
{
PG_LATIN5, iso2mic, mic2iso, iso8859_9_to_utf, utf_to_iso8859_9
},
{
PG_LATIN6, 0, 0, iso8859_10_to_utf, utf_to_iso8859_10
},
{
PG_LATIN7, 0, 0, iso8859_13_to_utf, utf_to_iso8859_13
},
{
PG_LATIN8, 0, 0, iso8859_14_to_utf, utf_to_iso8859_14
},
{
PG_LATIN9, 0, 0, iso8859_15_to_utf, utf_to_iso8859_15
},
{
PG_LATIN10, 0, 0, iso8859_16_to_utf, utf_to_iso8859_16
},
{
PG_KOI8R, koi8r2mic, mic2koi8r, KOI8R_to_utf, utf_to_KOI8R
},
{
PG_WIN1251, win12512mic, mic2win1251, WIN1251_to_utf, utf_to_WIN1251
},
{
PG_ALT, alt2mic, mic2alt, ALT_to_utf, utf_to_ALT
},
{
PG_ISO_8859_5, 0, 0, iso8859_5_to_utf, utf_to_iso8859_5
},
{
PG_ISO_8859_6, 0, 0, iso8859_6_to_utf, utf_to_iso8859_6
},
{
PG_ISO_8859_7, 0, 0, iso8859_7_to_utf, utf_to_iso8859_7
},
{
PG_ISO_8859_8, 0, 0, iso8859_8_to_utf, utf_to_iso8859_8
},
{ PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis},
{ PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5},
{ PG_WIN1250, win12502mic, mic2win1250, 0, 0},
{
PG_SJIS, sjis2mic, mic2sjis, sjis_to_utf, utf_to_sjis
},
{
PG_BIG5, big52mic, mic2big5, big5_to_utf, utf_to_big5
},
{
PG_WIN1250, win12502mic, mic2win1250, 0, 0
},
};
#else
pg_enconv pg_enconv_tbl[] =
pg_enconv pg_enconv_tbl[] =
{
{ PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0},
{ PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0},
{ PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0},
{ PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0},
{ PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0},
{ PG_UTF8, 0, 0, 0, 0},
{ PG_MULE_INTERNAL, 0, 0, 0, 0},
{ PG_LATIN1, latin12mic, mic2latin1, 0, 0},
{ PG_LATIN2, latin22mic, mic2latin2, 0, 0},
{ PG_LATIN3, latin32mic, mic2latin3, 0, 0},
{ PG_LATIN4, latin42mic, mic2latin4, 0, 0},
{ PG_LATIN5, iso2mic, mic2iso, 0, 0},
{ PG_LATIN6, 0, 0, 0, 0},
{ PG_LATIN7, 0, 0, 0, 0},
{ PG_LATIN8, 0, 0, 0, 0},
{ PG_LATIN9, 0, 0, 0, 0},
{ PG_LATIN10, 0, 0, 0, 0},
{ PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0},
{ PG_WIN1251, win12512mic, mic2win1251, 0, 0},
{ PG_ALT, alt2mic, mic2alt, 0, 0},
{ PG_ISO_8859_5, 0, 0, 0, 0},
{ PG_ISO_8859_6, 0, 0, 0, 0},
{ PG_ISO_8859_7, 0, 0, 0, 0},
{ PG_ISO_8859_8, 0, 0, 0, 0},
{ PG_SJIS, sjis2mic, mic2sjis, 0, 0},
{ PG_BIG5, big52mic, mic2big5, 0, 0},
{ PG_WIN1250, win12502mic, mic2win1250, 0, 0},
{
PG_SQL_ASCII, ascii2mic, mic2ascii, 0, 0
} ,
{
PG_EUC_JP, euc_jp2mic, mic2euc_jp, 0, 0
},
{
PG_EUC_CN, euc_cn2mic, mic2euc_cn, 0, 0
},
{
PG_EUC_KR, euc_kr2mic, mic2euc_kr, 0, 0
},
{
PG_EUC_TW, euc_tw2mic, mic2euc_tw, 0, 0
},
{
PG_UTF8, 0, 0, 0, 0
},
{
PG_MULE_INTERNAL, 0, 0, 0, 0
},
{
PG_LATIN1, latin12mic, mic2latin1, 0, 0
},
{
PG_LATIN2, latin22mic, mic2latin2, 0, 0
},
{
PG_LATIN3, latin32mic, mic2latin3, 0, 0
},
{
PG_LATIN4, latin42mic, mic2latin4, 0, 0
},
{
PG_LATIN5, iso2mic, mic2iso, 0, 0
},
{
PG_LATIN6, 0, 0, 0, 0
},
{
PG_LATIN7, 0, 0, 0, 0
},
{
PG_LATIN8, 0, 0, 0, 0
},
{
PG_LATIN9, 0, 0, 0, 0
},
{
PG_LATIN10, 0, 0, 0, 0
},
{
PG_KOI8R, koi8r2mic, mic2koi8r, 0, 0
},
{
PG_WIN1251, win12512mic, mic2win1251, 0, 0
},
{
PG_ALT, alt2mic, mic2alt, 0, 0
},
{
PG_ISO_8859_5, 0, 0, 0, 0
},
{
PG_ISO_8859_6, 0, 0, 0, 0
},
{
PG_ISO_8859_7, 0, 0, 0, 0
},
{
PG_ISO_8859_8, 0, 0, 0, 0
},
{
PG_SJIS, sjis2mic, mic2sjis, 0, 0
},
{
PG_BIG5, big52mic, mic2big5, 0, 0
},
{
PG_WIN1250, win12502mic, mic2win1250, 0, 0
},
};
#endif /* UNICODE_CONVERSION */

View File

@@ -2,7 +2,7 @@
* Encoding names and routines for work with it. All
* in this file is shared bedween FE and BE.
*
* $Id: encnames.c,v 1.4 2001/10/16 10:09:17 ishii Exp $
* $Id: encnames.c,v 1.5 2001/10/25 05:49:51 momjian Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
@@ -23,7 +23,7 @@
#include <ctype.h>
/* ----------
* All encoding names, sorted: *** A L P H A B E T I C ***
* All encoding names, sorted: *** A L P H A B E T I C ***
*
* All names must be without irrelevan chars, search routines use
* isalnum() chars only. It means ISO-8859-1, iso_8859-1 and Iso8859_1
@@ -34,58 +34,153 @@
* Karel Zak, Aug 2001
* ----------
*/
pg_encname pg_encname_tbl[] =
pg_encname pg_encname_tbl[] =
{
{ "alt", PG_ALT }, /* IBM866 */
{ "big5", PG_BIG5 }, /* Big5; Chinese for Taiwan Multi-byte set */
{ "euccn", PG_EUC_CN }, /* EUC-CN; Extended Unix Code for simplified Chinese */
{ "eucjp", PG_EUC_JP }, /* EUC-JP; Extended UNIX Code fixed Width for Japanese, stdandard OSF */
{ "euckr", PG_EUC_KR }, /* EUC-KR; RFC1557,Choi */
{ "euctw", PG_EUC_TW }, /* EUC-TW; Extended Unix Code for traditional Chinese */
{ "iso88591", PG_LATIN1 }, /* ISO-8859-1; RFC1345,KXS2 */
{ "iso885910", PG_LATIN6 }, /* ISO-8859-10; RFC1345,KXS2 */
{ "iso885913", PG_LATIN7 }, /* ISO-8859-13; RFC1345,KXS2 */
{ "iso885914", PG_LATIN8 }, /* ISO-8859-14; RFC1345,KXS2 */
{ "iso885915", PG_LATIN9 }, /* ISO-8859-15; RFC1345,KXS2 */
{ "iso885916", PG_LATIN10 }, /* ISO-8859-16; RFC1345,KXS2 */
{ "iso88592", PG_LATIN2 }, /* ISO-8859-2; RFC1345,KXS2 */
{ "iso88593", PG_LATIN3 }, /* ISO-8859-3; RFC1345,KXS2 */
{ "iso88594", PG_LATIN4 }, /* ISO-8859-4; RFC1345,KXS2 */
{ "iso88595", PG_ISO_8859_5 }, /* ISO-8859-5; RFC1345,KXS2 */
{ "iso88596", PG_ISO_8859_6 }, /* ISO-8859-6; RFC1345,KXS2 */
{ "iso88597", PG_ISO_8859_7 }, /* ISO-8859-7; RFC1345,KXS2 */
{ "iso88598", PG_ISO_8859_8 }, /* ISO-8859-8; RFC1345,KXS2 */
{ "iso88599", PG_LATIN5 }, /* ISO-8859-9; RFC1345,KXS2 */
{ "koi8", PG_KOI8R }, /* _dirty_ alias for KOI8-R (backward compatibility) */
{ "koi8r", PG_KOI8R }, /* KOI8-R; RFC1489 */
{ "latin1", PG_LATIN1 }, /* alias for ISO-8859-1 */
{ "latin10", PG_LATIN10}, /* alias for ISO-8859-16 */
{ "latin2", PG_LATIN2 }, /* alias for ISO-8859-2 */
{ "latin3", PG_LATIN3 }, /* alias for ISO-8859-3 */
{ "latin4", PG_LATIN4 }, /* alias for ISO-8859-4 */
{ "latin5", PG_LATIN5 }, /* alias for ISO-8859-9 */
{ "latin6", PG_LATIN6}, /* alias for ISO-8859-10 */
{ "latin7", PG_LATIN7}, /* alias for ISO-8859-13 */
{ "latin8", PG_LATIN8}, /* alias for ISO-8859-14 */
{ "latin9", PG_LATIN9}, /* alias for ISO-8859-15 */
{ "mskanji", PG_SJIS }, /* alias for Shift_JIS */
{ "muleinternal",PG_MULE_INTERNAL },
{ "shiftjis", PG_SJIS }, /* Shift_JIS; JIS X 0202-1991 */
{ "sjis", PG_SJIS }, /* alias for Shift_JIS */
{ "sqlascii", PG_SQL_ASCII },
{ "unicode", PG_UTF8 }, /* alias for UTF-8 */
{ "utf8", PG_UTF8 }, /* UTF-8; RFC2279 */
{ "win", PG_WIN1251 }, /* _dirty_ alias for windows-1251 (backward compatibility) */
{ "win1250", PG_WIN1250 }, /* alias for Windows-1250 */
{ "win1251", PG_WIN1251 }, /* alias for Windows-1251 */
{ "windows1250",PG_WIN1250 }, /* Windows-1251; Microsoft */
{ "windows1251",PG_WIN1251 }, /* Windows-1251; Microsoft */
{
"alt", PG_ALT
} , /* IBM866 */
{
"big5", PG_BIG5
}, /* Big5; Chinese for Taiwan Multi-byte set */
{
"euccn", PG_EUC_CN
}, /* EUC-CN; Extended Unix Code for
* simplified Chinese */
{
"eucjp", PG_EUC_JP
}, /* EUC-JP; Extended UNIX Code fixed Width
* for Japanese, stdandard OSF */
{
"euckr", PG_EUC_KR
}, /* EUC-KR; RFC1557,Choi */
{
"euctw", PG_EUC_TW
}, /* EUC-TW; Extended Unix Code for
* traditional Chinese */
{
"iso88591", PG_LATIN1
}, /* ISO-8859-1; RFC1345,KXS2 */
{
"iso885910", PG_LATIN6
}, /* ISO-8859-10; RFC1345,KXS2 */
{
"iso885913", PG_LATIN7
}, /* ISO-8859-13; RFC1345,KXS2 */
{
"iso885914", PG_LATIN8
}, /* ISO-8859-14; RFC1345,KXS2 */
{
"iso885915", PG_LATIN9
}, /* ISO-8859-15; RFC1345,KXS2 */
{
"iso885916", PG_LATIN10
}, /* ISO-8859-16; RFC1345,KXS2 */
{
"iso88592", PG_LATIN2
}, /* ISO-8859-2; RFC1345,KXS2 */
{
"iso88593", PG_LATIN3
}, /* ISO-8859-3; RFC1345,KXS2 */
{
"iso88594", PG_LATIN4
}, /* ISO-8859-4; RFC1345,KXS2 */
{
"iso88595", PG_ISO_8859_5
}, /* ISO-8859-5; RFC1345,KXS2 */
{
"iso88596", PG_ISO_8859_6
}, /* ISO-8859-6; RFC1345,KXS2 */
{
"iso88597", PG_ISO_8859_7
}, /* ISO-8859-7; RFC1345,KXS2 */
{
"iso88598", PG_ISO_8859_8
}, /* ISO-8859-8; RFC1345,KXS2 */
{
"iso88599", PG_LATIN5
}, /* ISO-8859-9; RFC1345,KXS2 */
{
"koi8", PG_KOI8R
}, /* _dirty_ alias for KOI8-R (backward
* compatibility) */
{
"koi8r", PG_KOI8R
}, /* KOI8-R; RFC1489 */
{
"latin1", PG_LATIN1
}, /* alias for ISO-8859-1 */
{
"latin10", PG_LATIN10
}, /* alias for ISO-8859-16 */
{
"latin2", PG_LATIN2
}, /* alias for ISO-8859-2 */
{
"latin3", PG_LATIN3
}, /* alias for ISO-8859-3 */
{
"latin4", PG_LATIN4
}, /* alias for ISO-8859-4 */
{
"latin5", PG_LATIN5
}, /* alias for ISO-8859-9 */
{
"latin6", PG_LATIN6
}, /* alias for ISO-8859-10 */
{
"latin7", PG_LATIN7
}, /* alias for ISO-8859-13 */
{
"latin8", PG_LATIN8
}, /* alias for ISO-8859-14 */
{
"latin9", PG_LATIN9
}, /* alias for ISO-8859-15 */
{
"mskanji", PG_SJIS
}, /* alias for Shift_JIS */
{
"muleinternal", PG_MULE_INTERNAL
},
{
"shiftjis", PG_SJIS
}, /* Shift_JIS; JIS X 0202-1991 */
{
"sjis", PG_SJIS
}, /* alias for Shift_JIS */
{
"sqlascii", PG_SQL_ASCII
},
{
"unicode", PG_UTF8
}, /* alias for UTF-8 */
{
"utf8", PG_UTF8
}, /* UTF-8; RFC2279 */
{
"win", PG_WIN1251
}, /* _dirty_ alias for windows-1251
* (backward compatibility) */
{
"win1250", PG_WIN1250
}, /* alias for Windows-1250 */
{
"win1251", PG_WIN1251
}, /* alias for Windows-1251 */
{
"windows1250", PG_WIN1250
}, /* Windows-1251; Microsoft */
{
"windows1251", PG_WIN1251
}, /* Windows-1251; Microsoft */
{ NULL, 0 } /* last */
{
NULL, 0
} /* last */
};
unsigned int pg_encname_tbl_sz = \
sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) -1;
sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) - 1;
/* ----------
* These are "official" encoding names.
@@ -94,33 +189,87 @@ unsigned int pg_encname_tbl_sz = \
*/
pg_enc2name pg_enc2name_tbl[] =
{
{ "SQL_ASCII", PG_SQL_ASCII },
{ "EUC_JP", PG_EUC_JP },
{ "EUC_CN", PG_EUC_CN },
{ "EUC_KR", PG_EUC_KR },
{ "EUC_TW", PG_EUC_TW },
{ "UNICODE", PG_UTF8 },
{ "MULE_INTERNAL",PG_MULE_INTERNAL },
{ "LATIN1", PG_LATIN1 },
{ "LATIN2", PG_LATIN2 },
{ "LATIN3", PG_LATIN3 },
{ "LATIN4", PG_LATIN4 },
{ "LATIN5", PG_LATIN5 },
{ "LATIN6", PG_LATIN6 },
{ "LATIN7", PG_LATIN7 },
{ "LATIN8", PG_LATIN8 },
{ "LATIN9", PG_LATIN9 },
{ "LATIN10", PG_LATIN10 },
{ "KOI8", PG_KOI8R },
{ "WIN", PG_WIN1251 },
{ "ALT", PG_ALT },
{ "ISO_8859_5", PG_ISO_8859_5 },
{ "ISO_8859_6", PG_ISO_8859_6 },
{ "ISO_8859_7", PG_ISO_8859_7 },
{ "ISO_8859_8", PG_ISO_8859_8 },
{ "SJIS", PG_SJIS },
{ "BIG5", PG_BIG5 },
{ "WIN1250", PG_WIN1250 }
{
"SQL_ASCII", PG_SQL_ASCII
} ,
{
"EUC_JP", PG_EUC_JP
},
{
"EUC_CN", PG_EUC_CN
},
{
"EUC_KR", PG_EUC_KR
},
{
"EUC_TW", PG_EUC_TW
},
{
"UNICODE", PG_UTF8
},
{
"MULE_INTERNAL", PG_MULE_INTERNAL
},
{
"LATIN1", PG_LATIN1
},
{
"LATIN2", PG_LATIN2
},
{
"LATIN3", PG_LATIN3
},
{
"LATIN4", PG_LATIN4
},
{
"LATIN5", PG_LATIN5
},
{
"LATIN6", PG_LATIN6
},
{
"LATIN7", PG_LATIN7
},
{
"LATIN8", PG_LATIN8
},
{
"LATIN9", PG_LATIN9
},
{
"LATIN10", PG_LATIN10
},
{
"KOI8", PG_KOI8R
},
{
"WIN", PG_WIN1251
},
{
"ALT", PG_ALT
},
{
"ISO_8859_5", PG_ISO_8859_5
},
{
"ISO_8859_6", PG_ISO_8859_6
},
{
"ISO_8859_7", PG_ISO_8859_7
},
{
"ISO_8859_8", PG_ISO_8859_8
},
{
"SJIS", PG_SJIS
},
{
"BIG5", PG_BIG5
},
{
"WIN1250", PG_WIN1250
}
};
/* ----------
@@ -130,12 +279,12 @@ pg_enc2name pg_enc2name_tbl[] =
int
pg_valid_client_encoding(const char *name)
{
int enc;
int enc;
if ((enc = pg_char_to_encoding(name)) < 0)
return -1;
if (!PG_VALID_FE_ENCODING( enc))
if (!PG_VALID_FE_ENCODING(enc))
return -1;
return enc;
@@ -144,12 +293,12 @@ pg_valid_client_encoding(const char *name)
int
pg_valid_server_encoding(const char *name)
{
int enc;
int enc;
if ((enc = pg_char_to_encoding(name)) < 0)
return -1;
if (!PG_VALID_BE_ENCODING( enc))
if (!PG_VALID_BE_ENCODING(enc))
return -1;
return enc;
@@ -162,12 +311,13 @@ pg_valid_server_encoding(const char *name)
static char *
clean_encoding_name(char *key, char *newkey)
{
char *p, *np;
char *p,
*np;
for(p=key, np=newkey; *p!='\0'; p++)
for (p = key, np = newkey; *p != '\0'; p++)
{
if (isalnum((unsigned char) *p))
*np++=tolower((unsigned char) *p);
*np++ = tolower((unsigned char) *p);
}
*np = '\0';
return newkey;
@@ -180,15 +330,15 @@ clean_encoding_name(char *key, char *newkey)
pg_encname *
pg_char_to_encname_struct(const char *name)
{
unsigned int nel = pg_encname_tbl_sz;
pg_encname *base = pg_encname_tbl,
*last = base + nel - 1,
*position;
int result;
unsigned int nel = pg_encname_tbl_sz;
pg_encname *base = pg_encname_tbl,
*last = base + nel - 1,
*position;
int result;
char buff[NAMEDATALEN],
*key;
*key;
if(name==NULL || *name=='\0')
if (name == NULL || *name == '\0')
return NULL;
if (strlen(name) > NAMEDATALEN)
@@ -241,6 +391,7 @@ Datum
PG_char_to_encoding(PG_FUNCTION_ARGS)
{
Name s = PG_GETARG_NAME(0);
PG_RETURN_INT32(pg_char_to_encoding(NameStr(*s)));
}
#endif
@@ -250,8 +401,9 @@ pg_encoding_to_char(int encoding)
{
if (PG_VALID_ENCODING(encoding))
{
pg_enc2name *p = &pg_enc2name_tbl[ encoding ];
Assert( encoding == p->encoding );
pg_enc2name *p = &pg_enc2name_tbl[encoding];
Assert(encoding == p->encoding);
return p->name;
}
return "";
@@ -262,9 +414,8 @@ Datum
PG_encoding_to_char(PG_FUNCTION_ARGS)
{
int32 encoding = PG_GETARG_INT32(0);
const char *encoding_name = pg_encoding_to_char(encoding);
const char *encoding_name = pg_encoding_to_char(encoding);
return DirectFunctionCall1(namein, CStringGetDatum(encoding_name));
}
#endif

View File

@@ -3,7 +3,7 @@
* client encoding and server internal encoding.
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
* $Id: mbutils.c,v 1.24 2001/10/12 02:08:34 ishii Exp $
* $Id: mbutils.c,v 1.25 2001/10/25 05:49:51 momjian Exp $
*/
#include "postgres.h"
@@ -12,7 +12,7 @@
#include "utils/builtins.h"
/*
* We handle for actual FE and BE encoding setting encoding-identificator
* We handle for actual FE and BE encoding setting encoding-identificator
* and encoding-name too. It prevent searching and conversion from encoding
* to encoding name in getdatabaseencoding() and other routines.
*
@@ -21,13 +21,13 @@
*
* Karel Zak (Aug 2001)
*/
static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ];
static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[ PG_SQL_ASCII ];
static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
static to_mic_converter client_to_mic; /* something to MIC */
static from_mic_converter client_from_mic; /* MIC to something */
static from_mic_converter client_from_mic; /* MIC to something */
static to_mic_converter server_to_mic; /* something to MIC */
static from_mic_converter server_from_mic; /* MIC to something */
static from_mic_converter server_from_mic; /* MIC to something */
/*
* find encoding table entry by encoding
@@ -37,8 +37,8 @@ pg_get_enconv_by_encoding(int encoding)
{
if (PG_VALID_ENCODING(encoding))
{
Assert((&pg_enconv_tbl[ encoding ])->encoding == encoding);
return &pg_enconv_tbl[ encoding ];
Assert((&pg_enconv_tbl[encoding])->encoding == encoding);
return &pg_enconv_tbl[encoding];
}
return 0;
}
@@ -113,7 +113,7 @@ pg_find_encoding_converters(int src, int dest,
int
pg_set_client_encoding(int encoding)
{
int current_server_encoding = DatabaseEncoding->encoding;
int current_server_encoding = DatabaseEncoding->encoding;
if (!PG_VALID_FE_ENCODING(encoding))
return (-1);
@@ -121,7 +121,7 @@ pg_set_client_encoding(int encoding)
if (pg_find_encoding_converters(encoding, current_server_encoding, &client_to_mic, &server_from_mic) < 0)
return (-1);
ClientEncoding = &pg_enc2name_tbl[ encoding ];
ClientEncoding = &pg_enc2name_tbl[encoding];
Assert(ClientEncoding->encoding == encoding);
@@ -162,7 +162,7 @@ pg_get_client_encoding_name(void)
* function). Another case is you have direct-conversion function from
* src to dest. In this case either src_to_mic or dest_from_mic could
* be set to 0 also.
*
*
* Note that If src or dest is UNICODE, we have to do
* direct-conversion, since we don't support conversion bwteen UNICODE
* and MULE_INTERNAL, we cannot go through MULE_INTERNAL.
@@ -175,7 +175,7 @@ pg_get_client_encoding_name(void)
* to determine whether to pfree the result or not!
*
* Note: we assume that conversion cannot cause more than a 4-to-1 growth
* in the length of the string --- is this enough? */
* in the length of the string --- is this enough? */
unsigned char *
pg_do_encoding_conversion(unsigned char *src, int len,
@@ -212,32 +212,33 @@ pg_do_encoding_conversion(unsigned char *src, int len,
Datum
pg_convert(PG_FUNCTION_ARGS)
{
text *string = PG_GETARG_TEXT_P(0);
Name s = PG_GETARG_NAME(1);
int encoding = pg_char_to_encoding(NameStr(*s));
int db_encoding = DatabaseEncoding->encoding;
text *string = PG_GETARG_TEXT_P(0);
Name s = PG_GETARG_NAME(1);
int encoding = pg_char_to_encoding(NameStr(*s));
int db_encoding = DatabaseEncoding->encoding;
to_mic_converter src;
from_mic_converter dest;
unsigned char *result;
text *retval;
unsigned char *result;
text *retval;
if (encoding < 0)
elog(ERROR, "Invalid encoding name %s", NameStr(*s));
elog(ERROR, "Invalid encoding name %s", NameStr(*s));
if (pg_find_encoding_converters(db_encoding, encoding, &src, &dest) < 0)
{
char *encoding_name = (char *)pg_encoding_to_char(db_encoding);
elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name);
char *encoding_name = (char *) pg_encoding_to_char(db_encoding);
elog(ERROR, "Conversion from %s to %s is not possible", NameStr(*s), encoding_name);
}
result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ,
src, dest);
result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ,
src, dest);
if (result == NULL)
elog(ERROR, "Encoding conversion failed");
elog(ERROR, "Encoding conversion failed");
retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result)));
if (result != (unsigned char *)VARDATA(string))
pfree(result);
if (result != (unsigned char *) VARDATA(string))
pfree(result);
/* free memory if allocated by the toaster */
PG_FREE_IF_COPY(string, 0);
@@ -253,35 +254,35 @@ pg_convert(PG_FUNCTION_ARGS)
Datum
pg_convert2(PG_FUNCTION_ARGS)
{
text *string = PG_GETARG_TEXT_P(0);
char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
int src_encoding = pg_char_to_encoding(src_encoding_name);
char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
int dest_encoding = pg_char_to_encoding(dest_encoding_name);
text *string = PG_GETARG_TEXT_P(0);
char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
int src_encoding = pg_char_to_encoding(src_encoding_name);
char *dest_encoding_name = NameStr(*PG_GETARG_NAME(2));
int dest_encoding = pg_char_to_encoding(dest_encoding_name);
to_mic_converter src;
from_mic_converter dest;
unsigned char *result;
text *retval;
unsigned char *result;
text *retval;
if (src_encoding < 0)
elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
if (dest_encoding < 0)
elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name);
elog(ERROR, "Invalid destination encoding name %s", dest_encoding_name);
if (pg_find_encoding_converters(src_encoding, dest_encoding, &src, &dest) < 0)
{
elog(ERROR, "Conversion from %s to %s is not possible",
src_encoding_name, dest_encoding_name);
elog(ERROR, "Conversion from %s to %s is not possible",
src_encoding_name, dest_encoding_name);
}
result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string)-VARHDRSZ,
src, dest);
result = pg_do_encoding_conversion(VARDATA(string), VARSIZE(string) - VARHDRSZ,
src, dest);
if (result == NULL)
elog(ERROR, "Encoding conversion failed");
elog(ERROR, "Encoding conversion failed");
retval = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(result)));
if (result != (unsigned char *)VARDATA(string))
pfree(result);
if (result != (unsigned char *) VARDATA(string))
pfree(result);
/* free memory if allocated by the toaster */
PG_FREE_IF_COPY(string, 0);
@@ -309,7 +310,7 @@ pg_client_to_server(unsigned char *s, int len)
Assert(ClientEncoding);
if (ClientEncoding->encoding == DatabaseEncoding->encoding)
return s;
return s;
return pg_do_encoding_conversion(s, len, client_to_mic, server_from_mic);
}
@@ -341,23 +342,23 @@ pg_server_to_client(unsigned char *s, int len)
/* convert a multi-byte string to a wchar */
int
pg_mb2wchar(const unsigned char *from, pg_wchar * to)
pg_mb2wchar(const unsigned char *from, pg_wchar *to)
{
return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, strlen(from));
return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, strlen(from));
}
/* convert a multi-byte string to a wchar with a limited length */
int
pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
return (*pg_wchar_table[ DatabaseEncoding->encoding ].mb2wchar_with_len) (from, to, len);
return (*pg_wchar_table[DatabaseEncoding->encoding].mb2wchar_with_len) (from, to, len);
}
/* returns the byte length of a multi-byte word */
int
pg_mblen(const unsigned char *mbstr)
{
return ((*pg_wchar_table[ DatabaseEncoding->encoding ].mblen) (mbstr));
return ((*pg_wchar_table[DatabaseEncoding->encoding].mblen) (mbstr));
}
/* returns the length (counted as a wchar) of a multi-byte string */
@@ -447,7 +448,7 @@ SetDatabaseEncoding(int encoding)
if (!PG_VALID_BE_ENCODING(encoding))
elog(ERROR, "SetDatabaseEncoding(): invalid database encoding");
DatabaseEncoding = &pg_enc2name_tbl[ encoding ];
DatabaseEncoding = &pg_enc2name_tbl[encoding];
Assert(DatabaseEncoding->encoding == encoding);
}

View File

@@ -1,7 +1,7 @@
/*
* conversion functions between pg_wchar and multi-byte streams.
* Tatsuo Ishii
* $Id: wchar.c,v 1.24 2001/10/15 01:19:15 ishii Exp $
* $Id: wchar.c,v 1.25 2001/10/25 05:49:51 momjian Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
@@ -29,7 +29,7 @@
* SQL/ASCII
*/
static int pg_ascii2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -54,7 +54,7 @@ pg_ascii_mblen(const unsigned char *s)
*/
static int pg_euc2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -111,7 +111,7 @@ pg_euc_mblen(const unsigned char *s)
* EUC_JP
*/
static int pg_eucjp2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
return (pg_euc2wchar_with_len(from, to, len));
}
@@ -126,7 +126,7 @@ pg_eucjp_mblen(const unsigned char *s)
* EUC_KR
*/
static int pg_euckr2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
return (pg_euc2wchar_with_len(from, to, len));
}
@@ -141,7 +141,7 @@ pg_euckr_mblen(const unsigned char *s)
* EUC_CN
*/
static int pg_euccn2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -195,7 +195,7 @@ pg_euccn_mblen(const unsigned char *s)
* EUC_TW
*/
static int pg_euctw2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -257,7 +257,7 @@ pg_euctw_mblen(const unsigned char *s)
* "from" not necessarily null terminated.
*/
static int
pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
unsigned char c1,
c2,
@@ -325,7 +325,7 @@ pg_utf_mblen(const unsigned char *s)
* "from" not necessarily null terminated.
*/
static int
pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -395,7 +395,7 @@ pg_mule_mblen(const unsigned char *s)
* ISO8859-1
*/
static int
pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -458,33 +458,33 @@ pg_big5_mblen(const unsigned char *s)
}
pg_wchar_tbl pg_wchar_table[] = {
{pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
{pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */
{pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */
{pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
{pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
{pg_euccn2wchar_with_len, pg_euccn_mblen, 3}, /* 2; PG_EUC_CN */
{pg_euckr2wchar_with_len, pg_euckr_mblen, 3}, /* 3; PG_EUC_KR */
{pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
{pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 5; PG_UNICODE */
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */
{0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */
{0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 6; PG_MULE_INTERNAL */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 7; PG_LATIN1 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN2 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN3 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN4 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 11; PG_LATIN5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 12; PG_KOI8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 13; PG_WIN1251 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 14; PG_ALT */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 15; ISO-8859-5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 16; ISO-8859-6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 17; ISO-8859-7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 18; ISO-8859-8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 19; ISO-8859-10 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 20; ISO-8859-13 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 21; ISO-8859-14 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 22; ISO-8859-15 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 23; ISO-8859-16 */
{0, pg_sjis_mblen, 2}, /* 24; PG_SJIS */
{0, pg_big5_mblen, 2}, /* 25; PG_BIG5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, 1} /* 26; PG_WIN1250 */
};
/* returns the byte length of a word for mule internal code */
@@ -502,9 +502,9 @@ pg_encoding_mblen(int encoding, const unsigned char *mbstr)
{
Assert(PG_VALID_ENCODING(encoding));
return( (encoding >= 0 &&
encoding < sizeof(pg_wchar_table)/sizeof(pg_wchar_tbl)) ?
((*pg_wchar_table[encoding].mblen) (mbstr)) :
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
((*pg_wchar_table[encoding].mblen) (mbstr)) :
((*pg_wchar_table[PG_SQL_ASCII].mblen) (mbstr)));
}
@@ -531,59 +531,62 @@ pg_encoding_max_length(int encoding)
char *
pg_verifymbstr(const unsigned char *mbstr, int len)
{
int l;
int i, j;
static char buf[256];
int slen = 0;
int l;
int i,
j;
static char buf[256];
int slen = 0;
/* we do not check single byte encodings */
if (pg_database_encoding_max_length() <= 1)
return NULL;
return NULL;
while (len > 0 && *mbstr)
{
/* special UTF-8 check */
if (GetDatabaseEncoding() == PG_UTF8 &&
(*mbstr & 0xf8) == 0xf0)
(*mbstr & 0xf8) == 0xf0)
{
snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted");
return(buf);
snprintf(buf, sizeof(buf), "Unicode >= 0x10000 is not supoorted");
return (buf);
}
l = pg_mblen(mbstr);
/* multi-byte letter? */
if (l > 1)
{
for (i=1;i<l;i++)
{
if (i > len || *(mbstr+i) == '\0' ||
/* we assume that every muti-byte letter
* consists of bytes being the 8th bit set
*/
((*(mbstr+i) & 0x80) == 0))
for (i = 1; i < l; i++)
{
int remains = sizeof(buf);
char *p = buf;
if (i > len || *(mbstr + i) == '\0' ||
slen = snprintf(p, remains, "Invalid %s character sequence found (0x",
GetDatabaseEncodingName());
p += slen;
remains -= slen;
/*
* we assume that every muti-byte letter consists of bytes
* being the 8th bit set
*/
((*(mbstr + i) & 0x80) == 0))
{
int remains = sizeof(buf);
char *p = buf;
i = ((*(mbstr+i) & 0x80) == 0)?l:i;
slen = snprintf(p, remains, "Invalid %s character sequence found (0x",
GetDatabaseEncodingName());
p += slen;
remains -= slen;
for (j=0;j<i;j++)
{
slen = snprintf(p, remains, "%02x",
*(mbstr+j));
p += slen;
remains -= slen;
}
snprintf(p, remains, ")");
return(buf);
i = ((*(mbstr + i) & 0x80) == 0) ? l : i;
for (j = 0; j < i; j++)
{
slen = snprintf(p, remains, "%02x",
*(mbstr + j));
p += slen;
remains -= slen;
}
snprintf(p, remains, ")");
return (buf);
}
}
}
}
len -= l;
mbstr += l;
@@ -599,5 +602,4 @@ pg_database_encoding_max_length(void)
{
return pg_wchar_table[GetDatabaseEncoding()].maxmblen;
}
#endif

View File

@@ -43,7 +43,7 @@ pg_char_and_wchar_strcmp(s1, s2)
register const char *s1;
register const pg_wchar *s2;
{
while ((pg_wchar) * s1 == *s2++)
while ((pg_wchar) *s1 == *s2++)
if (*s1++ == 0)
return 0;
return *(const unsigned char *) s1 - *(const pg_wchar *) (s2 - 1);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.48 2001/08/25 18:52:42 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.49 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -89,7 +89,6 @@ ExpandDatabasePath(const char *dbpath)
*/
for (cp = buf; *cp; cp++)
{
/*
* The following characters will not be allowed anywhere in the
* database path. (Do not include the slash or '.' here.)

View File

@@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.55 2001/09/30 20:16:21 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.56 2001/10/25 05:49:51 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -95,11 +95,11 @@ bool Password_encryption = false;
*/
enum config_type
{
PGC_NONE = 0,
PGC_BOOL,
PGC_INT,
PGC_REAL,
PGC_STRING
PGC_NONE = 0,
PGC_BOOL,
PGC_INT,
PGC_REAL,
PGC_STRING
};
@@ -161,7 +161,7 @@ struct config_string
const char *boot_default_val;
bool (*parse_hook) (const char *proposed);
void (*assign_hook) (const char *newval);
char *default_val;
char *default_val;
};
@@ -192,92 +192,196 @@ struct config_string
static struct config_bool
ConfigureNamesBool[] =
{
{"enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL},
{"enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL},
{"enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL},
{"enable_sort", PGC_USERSET, &enable_sort, true, NULL},
{"enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL},
{"enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL},
{"enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL},
{
"enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL
} ,
{
"enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL
},
{
"enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL
},
{
"enable_sort", PGC_USERSET, &enable_sort, true, NULL
},
{
"enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL
},
{
"enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL
},
{
"enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL
},
{"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL},
{"geqo", PGC_USERSET, &enable_geqo, true, NULL},
{
"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL
},
{
"geqo", PGC_USERSET, &enable_geqo, true, NULL
},
{"tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL},
{"ssl", PGC_POSTMASTER, &EnableSSL, false, NULL},
{"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
{"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
{
"tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL
},
{
"ssl", PGC_POSTMASTER, &EnableSSL, false, NULL
},
{
"fsync", PGC_SIGHUP, &enableFsync, true, NULL
},
{
"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL
},
{"log_connections", PGC_BACKEND, &Log_connections, false, NULL},
{"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
{"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
{
"log_connections", PGC_BACKEND, &Log_connections, false, NULL
},
{
"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL
},
{
"log_pid", PGC_SIGHUP, &Log_pid, false, NULL
},
#ifdef USE_ASSERT_CHECKING
{"debug_assertions", PGC_USERSET, &assert_enabled, true, NULL},
{
"debug_assertions", PGC_USERSET, &assert_enabled, true, NULL
},
#endif
{"debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL},
{"debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL},
{"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL},
{"debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL},
{"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL},
{
"debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL
},
{
"debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL
},
{
"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL
},
{
"debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL
},
{
"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL
},
{"show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL},
{"show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL},
{"show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL},
{"show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL},
{
"show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL
},
{
"show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL
},
{
"show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL
},
{
"show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL
},
#ifdef BTREE_BUILD_STATS
{"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL},
{
"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL
},
#endif
{"stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL},
{"stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL},
{"stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL},
{"stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL},
{"stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL},
{
"stats_start_collector", PGC_POSTMASTER, &pgstat_collect_startcollector, true, NULL
},
{
"stats_reset_on_server_start", PGC_POSTMASTER, &pgstat_collect_resetonpmstart, true, NULL
},
{
"stats_command_string", PGC_SUSET, &pgstat_collect_querystring, false, NULL
},
{
"stats_row_level", PGC_SUSET, &pgstat_collect_tuplelevel, false, NULL
},
{
"stats_block_level", PGC_SUSET, &pgstat_collect_blocklevel, false, NULL
},
{"trace_notify", PGC_USERSET, &Trace_notify, false, NULL},
{
"trace_notify", PGC_USERSET, &Trace_notify, false, NULL
},
#ifdef LOCK_DEBUG
{"trace_locks", PGC_SUSET, &Trace_locks, false, NULL},
{"trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL},
{"trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL},
{"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL},
{
"trace_locks", PGC_SUSET, &Trace_locks, false, NULL
},
{
"trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL
},
{
"trace_lwlocks", PGC_SUSET, &Trace_lwlocks, false, NULL
},
{
"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL
},
#endif
{"hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL},
{"show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL},
{
"hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL
},
{
"show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL
},
{"sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL},
{"australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache},
{"fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL},
{"password_encryption", PGC_USERSET, &Password_encryption, false, NULL},
{"transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL},
{
"sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL
},
{
"australian_timezones", PGC_USERSET, &Australian_timezones, false, ClearDateCache
},
{
"fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL
},
{
"password_encryption", PGC_USERSET, &Password_encryption, false, NULL
},
{
"transform_null_equals", PGC_USERSET, &Transform_null_equals, false, NULL
},
{NULL, 0, NULL, false, NULL}
{
NULL, 0, NULL, false, NULL
}
};
static struct config_int
ConfigureNamesInt[] =
{
{"geqo_threshold", PGC_USERSET, &geqo_rels,
DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL},
{"geqo_pool_size", PGC_USERSET, &Geqo_pool_size,
DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL},
{"geqo_effort", PGC_USERSET, &Geqo_effort,
1, 1, INT_MAX, NULL, NULL},
{"geqo_generations", PGC_USERSET, &Geqo_generations,
0, 0, INT_MAX, NULL, NULL},
{"geqo_random_seed", PGC_USERSET, &Geqo_random_seed,
-1, INT_MIN, INT_MAX, NULL, NULL},
{
"geqo_threshold", PGC_USERSET, &geqo_rels,
DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL
} ,
{
"geqo_pool_size", PGC_USERSET, &Geqo_pool_size,
DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL
},
{
"geqo_effort", PGC_USERSET, &Geqo_effort,
1, 1, INT_MAX, NULL, NULL
},
{
"geqo_generations", PGC_USERSET, &Geqo_generations,
0, 0, INT_MAX, NULL, NULL
},
{
"geqo_random_seed", PGC_USERSET, &Geqo_random_seed,
-1, INT_MIN, INT_MAX, NULL, NULL
},
{"deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout,
1000, 0, INT_MAX, NULL, NULL},
{
"deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout,
1000, 0, INT_MAX, NULL, NULL
},
#ifdef ENABLE_SYSLOG
{"syslog", PGC_SIGHUP, &Use_syslog,
0, 0, 2, NULL, NULL},
{
"syslog", PGC_SIGHUP, &Use_syslog,
0, 0, 2, NULL, NULL
},
#endif
/*
@@ -285,133 +389,215 @@ static struct config_int
* sure the buffers are at least twice the number of backends, so the
* constraints here are partially unused.
*/
{"max_connections", PGC_POSTMASTER, &MaxBackends,
DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL},
{
"max_connections", PGC_POSTMASTER, &MaxBackends,
DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL
},
{"shared_buffers", PGC_POSTMASTER, &NBuffers,
DEF_NBUFFERS, 16, INT_MAX, NULL, NULL},
{
"shared_buffers", PGC_POSTMASTER, &NBuffers,
DEF_NBUFFERS, 16, INT_MAX, NULL, NULL
},
{"port", PGC_POSTMASTER, &PostPortNumber,
DEF_PGPORT, 1, 65535, NULL, NULL},
{
"port", PGC_POSTMASTER, &PostPortNumber,
DEF_PGPORT, 1, 65535, NULL, NULL
},
{"unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions,
0777, 0000, 0777, NULL, NULL},
{
"unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions,
0777, 0000, 0777, NULL, NULL
},
{"sort_mem", PGC_USERSET, &SortMem,
512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
{
"sort_mem", PGC_USERSET, &SortMem,
512, 4 * BLCKSZ / 1024, INT_MAX, NULL, NULL
},
{"vacuum_mem", PGC_USERSET, &VacuumMem,
8192, 1024, INT_MAX, NULL, NULL},
{
"vacuum_mem", PGC_USERSET, &VacuumMem,
8192, 1024, INT_MAX, NULL, NULL
},
{"max_files_per_process", PGC_BACKEND, &max_files_per_process,
1000, 25, INT_MAX, NULL, NULL},
{
"max_files_per_process", PGC_BACKEND, &max_files_per_process,
1000, 25, INT_MAX, NULL, NULL
},
{"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16, NULL, NULL},
{
"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16, NULL, NULL
},
#ifdef LOCK_DEBUG
{"trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin,
BootstrapObjectIdData, 1, INT_MAX, NULL, NULL},
{"trace_lock_table", PGC_SUSET, &Trace_lock_table,
0, 0, INT_MAX, NULL, NULL},
{
"trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin,
BootstrapObjectIdData, 1, INT_MAX, NULL, NULL
},
{
"trace_lock_table", PGC_SUSET, &Trace_lock_table,
0, 0, INT_MAX, NULL, NULL
},
#endif
{"max_expr_depth", PGC_USERSET, &max_expr_depth,
DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL},
{
"max_expr_depth", PGC_USERSET, &max_expr_depth,
DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL
},
{"max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations,
100, 10, INT_MAX, NULL, NULL},
{"max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages,
10000, 1000, INT_MAX, NULL, NULL},
{
"max_fsm_relations", PGC_POSTMASTER, &MaxFSMRelations,
100, 10, INT_MAX, NULL, NULL
},
{
"max_fsm_pages", PGC_POSTMASTER, &MaxFSMPages,
10000, 1000, INT_MAX, NULL, NULL
},
{"max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact,
64, 10, INT_MAX, NULL, NULL},
{
"max_locks_per_transaction", PGC_POSTMASTER, &max_locks_per_xact,
64, 10, INT_MAX, NULL, NULL
},
{"authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout,
60, 1, 600, NULL, NULL},
{
"authentication_timeout", PGC_SIGHUP, &AuthenticationTimeout,
60, 1, 600, NULL, NULL
},
{"pre_auth_delay", PGC_SIGHUP, &PreAuthDelay,
0, 0, 60, NULL, NULL},
{
"pre_auth_delay", PGC_SIGHUP, &PreAuthDelay,
0, 0, 60, NULL, NULL
},
{"checkpoint_segments", PGC_SIGHUP, &CheckPointSegments,
3, 1, INT_MAX, NULL, NULL},
{
"checkpoint_segments", PGC_SIGHUP, &CheckPointSegments,
3, 1, INT_MAX, NULL, NULL
},
{"checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout,
300, 30, 3600, NULL, NULL},
{
"checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout,
300, 30, 3600, NULL, NULL
},
{"wal_buffers", PGC_POSTMASTER, &XLOGbuffers,
8, 4, INT_MAX, NULL, NULL},
{
"wal_buffers", PGC_POSTMASTER, &XLOGbuffers,
8, 4, INT_MAX, NULL, NULL
},
{"wal_files", PGC_SIGHUP, &XLOGfiles,
0, 0, 64, NULL, NULL},
{
"wal_files", PGC_SIGHUP, &XLOGfiles,
0, 0, 64, NULL, NULL
},
{"wal_debug", PGC_SUSET, &XLOG_DEBUG,
0, 0, 16, NULL, NULL},
{
"wal_debug", PGC_SUSET, &XLOG_DEBUG,
0, 0, 16, NULL, NULL
},
{"commit_delay", PGC_USERSET, &CommitDelay,
0, 0, 100000, NULL, NULL},
{
"commit_delay", PGC_USERSET, &CommitDelay,
0, 0, 100000, NULL, NULL
},
{"commit_siblings", PGC_USERSET, &CommitSiblings,
5, 1, 1000, NULL, NULL},
{
"commit_siblings", PGC_USERSET, &CommitSiblings,
5, 1, 1000, NULL, NULL
},
{NULL, 0, NULL, 0, 0, 0, NULL, NULL}
{
NULL, 0, NULL, 0, 0, 0, NULL, NULL
}
};
static struct config_real
ConfigureNamesReal[] =
{
{"effective_cache_size", PGC_USERSET, &effective_cache_size,
DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL},
{"random_page_cost", PGC_USERSET, &random_page_cost,
DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL},
{"cpu_tuple_cost", PGC_USERSET, &cpu_tuple_cost,
DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
{"cpu_index_tuple_cost", PGC_USERSET, &cpu_index_tuple_cost,
DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
{"cpu_operator_cost", PGC_USERSET, &cpu_operator_cost,
DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL},
{
"effective_cache_size", PGC_USERSET, &effective_cache_size,
DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL
} ,
{
"random_page_cost", PGC_USERSET, &random_page_cost,
DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL
},
{
"cpu_tuple_cost", PGC_USERSET, &cpu_tuple_cost,
DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL
},
{
"cpu_index_tuple_cost", PGC_USERSET, &cpu_index_tuple_cost,
DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL
},
{
"cpu_operator_cost", PGC_USERSET, &cpu_operator_cost,
DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL
},
{"geqo_selection_bias", PGC_USERSET, &Geqo_selection_bias,
DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
MAX_GEQO_SELECTION_BIAS, NULL, NULL},
{
"geqo_selection_bias", PGC_USERSET, &Geqo_selection_bias,
DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
MAX_GEQO_SELECTION_BIAS, NULL, NULL
},
{NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL}
{
NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL
}
};
static struct config_string
ConfigureNamesString[] =
{
{"default_transaction_isolation", PGC_USERSET, &default_iso_level_string,
"read committed", check_defaultxactisolevel, assign_defaultxactisolevel},
{
"default_transaction_isolation", PGC_USERSET, &default_iso_level_string,
"read committed", check_defaultxactisolevel, assign_defaultxactisolevel
} ,
{"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
"$libdir", NULL, NULL},
{
"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
"$libdir", NULL, NULL
},
{"krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile,
PG_KRB_SRVTAB, NULL, NULL},
{
"krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile,
PG_KRB_SRVTAB, NULL, NULL
},
#ifdef ENABLE_SYSLOG
{"syslog_facility", PGC_POSTMASTER, &Syslog_facility,
"LOCAL0", check_facility, NULL},
{"syslog_ident", PGC_POSTMASTER, &Syslog_ident,
"postgres", NULL, NULL},
{
"syslog_facility", PGC_POSTMASTER, &Syslog_facility,
"LOCAL0", check_facility, NULL
},
{
"syslog_ident", PGC_POSTMASTER, &Syslog_ident,
"postgres", NULL, NULL
},
#endif
{"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
"", NULL, NULL},
{
"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
"", NULL, NULL
},
{"unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir,
"", NULL, NULL},
{
"unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir,
"", NULL, NULL
},
{"virtual_host", PGC_POSTMASTER, &VirtualHost,
"", NULL, NULL},
{
"virtual_host", PGC_POSTMASTER, &VirtualHost,
"", NULL, NULL
},
{"wal_sync_method", PGC_SIGHUP, &XLOG_sync_method,
XLOG_sync_method_default, check_xlog_sync_method,
assign_xlog_sync_method},
{
"wal_sync_method", PGC_SIGHUP, &XLOG_sync_method,
XLOG_sync_method_default, check_xlog_sync_method,
assign_xlog_sync_method
},
{NULL, 0, NULL, NULL, NULL, NULL}
{
NULL, 0, NULL, NULL, NULL, NULL
}
};
/******** end of options list ********/
@@ -628,10 +814,10 @@ parse_int(const char *value, int *result)
val = strtol(value, &endptr, 0);
if (endptr == value || *endptr != '\0' || errno == ERANGE
#ifdef HAVE_LONG_INT_64
/* if long > 32 bits, check for overflow of int4 */
/* if long > 32 bits, check for overflow of int4 */
|| val != (long) ((int32) val)
#endif
)
)
return false;
if (result)
*result = (int) val;
@@ -715,23 +901,24 @@ set_config_option(const char *name, const char *value,
case PGC_SIGHUP:
if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
elog(ERROR, "'%s' cannot be changed now", name);
/*
* Hmm, the idea of the SIGHUP context is "ought to be global, but
* can be changed after postmaster start". But there's nothing
* that prevents a crafty administrator from sending SIGHUP
* signals to individual backends only.
* Hmm, the idea of the SIGHUP context is "ought to be global,
* but can be changed after postmaster start". But there's
* nothing that prevents a crafty administrator from sending
* SIGHUP signals to individual backends only.
*/
break;
case PGC_BACKEND:
if (context == PGC_SIGHUP)
{
/*
* If a PGC_BACKEND parameter is changed in the config file,
* we want to accept the new value in the postmaster (whence
* it will propagate to subsequently-started backends), but
* ignore it in existing backends. This is a tad klugy, but
* necessary because we don't re-read the config file during
* backend start.
* If a PGC_BACKEND parameter is changed in the config
* file, we want to accept the new value in the postmaster
* (whence it will propagate to subsequently-started
* backends), but ignore it in existing backends. This is
* a tad klugy, but necessary because we don't re-read the
* config file during backend start.
*/
if (IsUnderPostmaster)
return true;
@@ -903,7 +1090,8 @@ set_config_option(const char *name, const char *value,
if (makeDefault)
{
str = strdup(value);
if (str == NULL) {
if (str == NULL)
{
elog(elevel, "out of memory");
return false;
}
@@ -1006,10 +1194,10 @@ GetConfigOption(const char *name)
}
static void
_ShowOption(enum config_type opttype, struct config_generic *record)
_ShowOption(enum config_type opttype, struct config_generic * record)
{
char buffer[256];
char *val;
char buffer[256];
char *val;
switch (opttype)
{
@@ -1046,16 +1234,16 @@ ShowAllGUCConfig(void)
int i;
for (i = 0; ConfigureNamesBool[i].name; i++)
_ShowOption(PGC_BOOL, (struct config_generic *)&ConfigureNamesBool[i]);
_ShowOption(PGC_BOOL, (struct config_generic *) & ConfigureNamesBool[i]);
for (i = 0; ConfigureNamesInt[i].name; i++)
_ShowOption(PGC_INT, (struct config_generic *)&ConfigureNamesInt[i]);
_ShowOption(PGC_INT, (struct config_generic *) & ConfigureNamesInt[i]);
for (i = 0; ConfigureNamesReal[i].name; i++)
_ShowOption(PGC_REAL, (struct config_generic *)&ConfigureNamesReal[i]);
_ShowOption(PGC_REAL, (struct config_generic *) & ConfigureNamesReal[i]);
for (i = 0; ConfigureNamesString[i].name; i++)
_ShowOption(PGC_STRING, (struct config_generic *)&ConfigureNamesString[i]);
_ShowOption(PGC_STRING, (struct config_generic *) & ConfigureNamesString[i]);
}
@@ -1132,7 +1320,6 @@ check_facility(const char *facility)
return true;
return false;
}
#endif

View File

@@ -5,7 +5,7 @@
* to contain some useful information. Mechanism differs wildly across
* platforms.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.7 2001/10/22 19:41:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.8 2001/10/25 05:49:51 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* various details abducted from various places
@@ -83,7 +83,6 @@ static const size_t ps_buffer_size = PS_BUFFER_SIZE;
#else /* PS_USE_CLOBBER_ARGV */
static char *ps_buffer; /* will point to argv area */
static size_t ps_buffer_size; /* space determined at run time */
#endif /* PS_USE_CLOBBER_ARGV */
static size_t ps_buffer_fixed_size; /* size of the constant prefix */
@@ -97,7 +96,7 @@ static char **save_argv;
* Call this early in startup to save the original argc/argv values.
*
* argv[] will not be overwritten by this routine, but may be overwritten
* during init_ps_display. Also, the physical location of the environment
* during init_ps_display. Also, the physical location of the environment
* strings may be moved, so this should be called before any code that
* might try to hang onto a getenv() result.
*/
@@ -108,6 +107,7 @@ save_ps_display_args(int argc, char *argv[])
save_argv = argv;
#ifdef PS_USE_CLOBBER_ARGV
/*
* If we're going to overwrite the argv area, count the available
* space. Also move the environment to make additional room.
@@ -126,7 +126,7 @@ save_ps_display_args(int argc, char *argv[])
end_of_area = argv[i] + strlen(argv[i]);
}
if (end_of_area == NULL) /* probably can't happen? */
if (end_of_area == NULL)/* probably can't happen? */
{
ps_buffer = NULL;
ps_buffer_size = 0;
@@ -159,7 +159,7 @@ save_ps_display_args(int argc, char *argv[])
/*
* Call this once during subprocess startup to set the identification
* values. At this point, the original argv[] array may be overwritten.
* values. At this point, the original argv[] array may be overwritten.
*/
void
init_ps_display(const char *username, const char *dbname,
@@ -201,6 +201,7 @@ init_ps_display(const char *username, const char *dbname,
*/
#ifdef PS_USE_SETPROCTITLE
/*
* apparently setproctitle() already adds a `progname:' prefix to the
* ps line
@@ -273,7 +274,6 @@ set_ps_display(const char *activity)
*cp = PS_PADDING;
}
#endif /* PS_USE_CLOBBER_ARGV */
#endif /* not PS_USE_NONE */
}

View File

@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.41 2001/03/22 04:00:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.42 2001/10/25 05:49:51 momjian Exp $
*
* NOTE:
* This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -207,7 +207,6 @@ static void AllocSetDelete(MemoryContext context);
#ifdef MEMORY_CONTEXT_CHECKING
static void AllocSetCheck(MemoryContext context);
#endif
static void AllocSetStats(MemoryContext context);
@@ -359,7 +358,6 @@ AllocSetContextCreate(MemoryContext parent,
static void
AllocSetInit(MemoryContext context)
{
/*
* Since MemoryContextCreate already zeroed the context node, we don't
* have to do anything here: it's already OK.
@@ -581,7 +579,6 @@ AllocSetAlloc(MemoryContext context, Size size)
if (availspace < (chunk_size + ALLOC_CHUNKHDRSZ))
{
/*
* The existing active (top) block does not have enough room
* for the requested allocation, but it might still have a
@@ -745,7 +742,6 @@ AllocSetFree(MemoryContext context, void *pointer)
if (chunk->size > ALLOC_CHUNK_LIMIT)
{
/*
* Big chunks are certain to have been allocated as single-chunk
* blocks. Find the containing block and return it to malloc().
@@ -837,7 +833,6 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
if (oldsize > ALLOC_CHUNK_LIMIT)
{
/*
* The chunk must been allocated as a single-chunk block. Find
* the containing block and use realloc() to make it bigger with
@@ -893,7 +888,6 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
}
else
{
/*
* Small-chunk case. If the chunk is the last one in its block,
* there might be enough free space after it that we can just
@@ -1088,5 +1082,4 @@ AllocSetCheck(MemoryContext context)
name, block);
}
}
#endif /* MEMORY_CONTEXT_CHECKING */

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.28 2001/03/22 04:00:08 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.29 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -263,7 +263,6 @@ MemoryContextCheck(MemoryContext context)
for (child = context->firstchild; child != NULL; child = child->nextchild)
MemoryContextCheck(child);
}
#endif
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.43 2001/10/05 17:28:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.44 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -257,7 +257,7 @@ PortalDrop(Portal portal)
*
* XXX This assumes that portals can be deleted in a random order, ie,
* no portal has a reference to any other (at least not one that will be
* exercised during deletion). I think this is okay at the moment, but
* exercised during deletion). I think this is okay at the moment, but
* we've had bugs of that ilk in the past. Keep a close eye on cursor
* references...
*/
@@ -270,7 +270,5 @@ AtEOXact_portals(void)
hash_seq_init(&status, PortalHashTable);
while ((hentry = (PortalHashEnt *) hash_seq_search(&status)) != NULL)
{
PortalDrop(hentry->portal);
}
}

View File

@@ -64,7 +64,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.6 2001/01/24 19:43:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/logtape.c,v 1.7 2001/10/25 05:49:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -224,7 +224,6 @@ ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
static long
ltsGetFreeBlock(LogicalTapeSet *lts)
{
/*
* If there are multiple free blocks, we select the one appearing last
* in freeBlocks[]. If there are none, assign the next block at the
@@ -286,7 +285,6 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect,
{
if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK)
{
/*
* This indirect block is full, so dump it out and recursively
* save its address in the next indirection level. Create a new
@@ -365,7 +363,6 @@ static long
ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts,
IndirectBlock *indirect)
{
/*
* If block is not topmost, recurse to obtain address of first block
* in this hierarchy level. Read that one in.
@@ -612,7 +609,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
{
if (lt->writing)
{
/*
* Completion of a write phase. Flush last partial data
* block, flush any partial indirect blocks, rewind for normal
@@ -626,7 +622,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
}
else
{
/*
* This is only OK if tape is frozen; we rewind for (another)
* read pass.
@@ -649,7 +644,6 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
}
else
{
/*
* Completion of a read phase. Rewind and prepare for write.
*

View File

@@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.18 2001/08/21 16:36:05 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.19 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -104,12 +104,13 @@
*/
typedef enum
{
TSS_INITIAL, /* Loading tuples; still within memory
TSS_INITIAL, /* Loading tuples; still within memory
* limit */
TSS_BUILDRUNS, /* Loading tuples; writing to tape */
TSS_SORTEDINMEM, /* Sort completed entirely in memory */
TSS_SORTEDONTAPE, /* Sort completed, final run is on tape */
TSS_FINALMERGE /* Performing final merge on-the-fly */
TSS_BUILDRUNS, /* Loading tuples; writing to tape */
TSS_SORTEDINMEM,/* Sort completed entirely in memory */
TSS_SORTEDONTAPE, /* Sort completed, final run is on
* tape */
TSS_FINALMERGE /* Performing final merge on-the-fly */
} TupSortStatus;
/*
@@ -135,10 +136,9 @@ struct Tuplesortstate
* kind of tuple we are sorting from the routines that don't need to
* know it. They are set up by the tuplesort_begin_xxx routines.
*
* Function to compare two tuples; result is per qsort() convention,
* ie:
* Function to compare two tuples; result is per qsort() convention, ie:
*
* <0, 0, >0 according as a<b, a=b, a>b.
* <0, 0, >0 according as a<b, a=b, a>b.
*/
int (*comparetup) (Tuplesortstate *state, const void *a, const void *b);
@@ -584,7 +584,10 @@ tuplesort_end(Tuplesortstate *state)
if (state->memtupindex)
pfree(state->memtupindex);
/* this stuff might better belong in a variant-specific shutdown routine */
/*
* this stuff might better belong in a variant-specific shutdown
* routine
*/
if (state->scanKeys)
pfree(state->scanKeys);
if (state->sortFnKinds)
@@ -601,7 +604,6 @@ tuplesort_end(Tuplesortstate *state)
void
tuplesort_puttuple(Tuplesortstate *state, void *tuple)
{
/*
* Copy the given tuple into memory we control, and decrease availMem.
* Then call the code shared with the Datum case.
@@ -660,7 +662,7 @@ puttuple_common(Tuplesortstate *state, void *tuple)
{
switch (state->status)
{
case TSS_INITIAL:
case TSS_INITIAL:
/*
* Save the copied tuple into the unsorted array.
@@ -732,7 +734,7 @@ tuplesort_performsort(Tuplesortstate *state)
{
switch (state->status)
{
case TSS_INITIAL:
case TSS_INITIAL:
/*
* We were able to accumulate all the tuples within the
@@ -843,7 +845,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
*/
if (state->eof_reached)
{
/*
* Seek position is pointing just past the zero tuplen at
* the end of file; back up to fetch last tuple's ending
@@ -858,7 +859,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
}
else
{
/*
* Back up and fetch previously-returned tuple's ending
* length word. If seek fails, assume we are at start of
@@ -877,7 +877,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
state->result_tape,
tuplen + 2 * sizeof(unsigned int)))
{
/*
* If that fails, presumably the prev tuple is the
* first in the file. Back up so that it becomes next
@@ -928,7 +927,6 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward,
tuplesort_heap_siftup(state, false);
if ((tupIndex = state->mergenext[srcTape]) == 0)
{
/*
* out of preloaded data on this tape, try to read
* more
@@ -1457,7 +1455,6 @@ dumptuples(Tuplesortstate *state, bool alltuples)
while (alltuples ||
(LACKMEM(state) && state->memtupcount > 1))
{
/*
* Dump the heap's frontmost entry, and sift up to remove it from
* the heap.
@@ -2037,10 +2034,10 @@ tuplesize_datum(Tuplesortstate *state, void *tup)
/*
* This routine selects an appropriate sorting function to implement
* a sort operator as efficiently as possible. The straightforward
* a sort operator as efficiently as possible. The straightforward
* method is to use the operator's implementation proc --- ie, "<"
* comparison. However, that way often requires two calls of the function
* per comparison. If we can find a btree three-way comparator function
* comparison. However, that way often requires two calls of the function
* per comparison. If we can find a btree three-way comparator function
* associated with the operator, we can use it to do the comparisons
* more efficiently. We also support the possibility that the operator
* is ">" (descending sort), in which case we have to reverse the output
@@ -2061,12 +2058,12 @@ SelectSortFunction(Oid sortOperator,
Oid opclass = InvalidOid;
/*
* Scan pg_amop to see if the target operator is registered as the
* "<" or ">" operator of any btree opclass. It's possible that it
* might be registered both ways (eg, if someone were to build a
* "reverse sort" opclass for some reason); prefer the "<" case if so.
* If the operator is registered the same way in multiple opclasses,
* assume we can use the associated comparator function from any one.
* Scan pg_amop to see if the target operator is registered as the "<"
* or ">" operator of any btree opclass. It's possible that it might
* be registered both ways (eg, if someone were to build a "reverse
* sort" opclass for some reason); prefer the "<" case if so. If the
* operator is registered the same way in multiple opclasses, assume
* we can use the associated comparator function from any one.
*/
ScanKeyEntryInitialize(&skey[0], 0x0,
Anum_pg_amop_amopopr,
@@ -2109,6 +2106,7 @@ SelectSortFunction(Oid sortOperator,
if (HeapTupleIsValid(tuple))
{
Form_pg_amproc aform = (Form_pg_amproc) GETSTRUCT(tuple);
*sortFunction = aform->amproc;
ReleaseSysCache(tuple);
Assert(RegProcedureIsValid(*sortFunction));
@@ -2119,7 +2117,8 @@ SelectSortFunction(Oid sortOperator,
/*
* Can't find a comparator, so use the operator as-is. Decide whether
* it is forward or reverse sort by looking at its name (grotty, but
* this only matters for deciding which end NULLs should get sorted to).
* this only matters for deciding which end NULLs should get sorted
* to).
*/
tuple = SearchSysCache(OPEROID,
ObjectIdGetDatum(sortOperator),
@@ -2202,8 +2201,8 @@ ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind,
}
if (isNull2)
return 1;
return - DatumGetInt32(FunctionCall2(sortFunction,
datum1, datum2));
return -DatumGetInt32(FunctionCall2(sortFunction,
datum1, datum2));
default:
elog(ERROR, "Invalid SortFunctionKind %d", (int) kind);

View File

@@ -26,7 +26,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.3 2001/03/22 04:00:10 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.4 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,11 +43,11 @@
*/
typedef enum
{
TSS_INITIAL, /* Loading tuples; still within memory
TSS_INITIAL, /* Loading tuples; still within memory
* limit */
TSS_WRITEFILE, /* Loading tuples; writing to temp file */
TSS_READMEM, /* Reading tuples; entirely in memory */
TSS_READFILE /* Reading tuples from temp file */
TSS_WRITEFILE, /* Loading tuples; writing to temp file */
TSS_READMEM, /* Reading tuples; entirely in memory */
TSS_READFILE /* Reading tuples from temp file */
} TupStoreStatus;
/*
@@ -271,7 +271,6 @@ tuplestore_end(Tuplestorestate *state)
void
tuplestore_puttuple(Tuplestorestate *state, void *tuple)
{
/*
* Copy the tuple. (Must do this even in WRITEFILE case.)
*/
@@ -324,7 +323,7 @@ tuplestore_donestoring(Tuplestorestate *state)
{
switch (state->status)
{
case TSS_INITIAL:
case TSS_INITIAL:
/*
* We were able to accumulate all the tuples within the
@@ -432,7 +431,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
*/
if (state->eof_reached)
{
/*
* Seek position is pointing just past the zero tuplen at
* the end of file; back up to fetch last tuple's ending
@@ -447,7 +445,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
}
else
{
/*
* Back up and fetch previously-returned tuple's ending
* length word. If seek fails, assume we are at start of
@@ -466,7 +463,6 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
-(long) (tuplen + 2 * sizeof(unsigned int)),
SEEK_CUR) != 0)
{
/*
* If that fails, presumably the prev tuple is the
* first in the file. Back up so that it becomes next

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.42 2001/08/26 16:56:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.43 2001/10/25 05:49:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -324,7 +324,7 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple)
{
if (th->t_infomask & HEAP_MARKED_FOR_UPDATE)
return HeapTupleMayBeUpdated;
return HeapTupleUpdated;/* updated by other */
return HeapTupleUpdated; /* updated by other */
}
if (TransactionIdIsCurrentTransactionId(th->t_xmax))
@@ -374,7 +374,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
if (tuple->t_infomask & HEAP_MOVED_OFF)
{
/*
* HeapTupleSatisfiesDirty is used by unique btree-s and so
* may be used while vacuuming.
@@ -592,7 +591,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
* HeapTupleSatisfiesVacuum - determine tuple status for VACUUM and related
* operations
*
* OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples
* OldestXmin is a cutoff XID (obtained from GetOldestXmin()). Tuples
* deleted by XIDs >= OldestXmin are deemed "recently dead"; they might
* still be visible to some open transaction, so we can't remove them,
* even if we see that the deleting transaction has committed.
@@ -614,9 +613,9 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
* NOTE: must check TransactionIdIsInProgress (which looks in PROC array)
* before TransactionIdDidCommit/TransactionIdDidAbort (which look in
* pg_clog). Otherwise we have a race condition where we might decide
* that a just-committed transaction crashed, because none of the tests
* succeed. xact.c is careful to record commit/abort in pg_clog before
* it unsets MyProc->xid in PROC array.
* that a just-committed transaction crashed, because none of the
* tests succeed. xact.c is careful to record commit/abort in pg_clog
* before it unsets MyProc->xid in PROC array.
*/
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{
@@ -655,8 +654,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
else
{
/*
* Not in Progress, Not Committed, Not Aborted -
* so it's from crashed process. - vadim 11/26/96
* Not in Progress, Not Committed, Not Aborted - so it's from
* crashed process. - vadim 11/26/96
*/
tuple->t_infomask |= HEAP_XMIN_INVALID;
return HEAPTUPLE_DEAD;
@@ -666,7 +665,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
}
/*
* Okay, the inserter committed, so it was good at some point. Now
* Okay, the inserter committed, so it was good at some point. Now
* what about the deleting transaction?
*/
if (tuple->t_infomask & HEAP_XMAX_INVALID)
@@ -686,8 +685,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
else
{
/*
* Not in Progress, Not Committed, Not Aborted -
* so it's from crashed process. - vadim 06/02/97
* Not in Progress, Not Committed, Not Aborted - so it's from
* crashed process. - vadim 06/02/97
*/
tuple->t_infomask |= HEAP_XMAX_INVALID;
return HEAPTUPLE_LIVE;
@@ -708,7 +707,10 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
if (TransactionIdEquals(tuple->t_xmin, tuple->t_xmax))
{
/* inserter also deleted it, so it was never visible to anyone else */
/*
* inserter also deleted it, so it was never visible to anyone
* else
*/
return HEAPTUPLE_DEAD;
}