aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/acl.c60
-rw-r--r--src/backend/utils/adt/arrayfuncs.c17
-rw-r--r--src/backend/utils/adt/ascii.c48
-rw-r--r--src/backend/utils/adt/cash.c4
-rw-r--r--src/backend/utils/adt/char.c10
-rw-r--r--src/backend/utils/adt/date.c28
-rw-r--r--src/backend/utils/adt/datetime.c286
-rw-r--r--src/backend/utils/adt/datum.c4
-rw-r--r--src/backend/utils/adt/encode.c144
-rw-r--r--src/backend/utils/adt/float.c25
-rw-r--r--src/backend/utils/adt/format_type.c6
-rw-r--r--src/backend/utils/adt/formatting.c474
-rw-r--r--src/backend/utils/adt/geo_ops.c57
-rw-r--r--src/backend/utils/adt/inet_net_ntop.c7
-rw-r--r--src/backend/utils/adt/inet_net_pton.c9
-rw-r--r--src/backend/utils/adt/int8.c4
-rw-r--r--src/backend/utils/adt/like.c68
-rw-r--r--src/backend/utils/adt/like_match.c8
-rw-r--r--src/backend/utils/adt/misc.c3
-rw-r--r--src/backend/utils/adt/nabstime.c140
-rw-r--r--src/backend/utils/adt/name.c6
-rw-r--r--src/backend/utils/adt/network.c75
-rw-r--r--src/backend/utils/adt/not_in.c3
-rw-r--r--src/backend/utils/adt/numeric.c24
-rw-r--r--src/backend/utils/adt/numutils.c4
-rw-r--r--src/backend/utils/adt/oracle_compat.c206
-rw-r--r--src/backend/utils/adt/pg_locale.c35
-rw-r--r--src/backend/utils/adt/pg_lzcompress.c13
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c218
-rw-r--r--src/backend/utils/adt/quote.c3
-rw-r--r--src/backend/utils/adt/regexp.c3
-rw-r--r--src/backend/utils/adt/regproc.c6
-rw-r--r--src/backend/utils/adt/ri_triggers.c23
-rw-r--r--src/backend/utils/adt/ruleutils.c105
-rw-r--r--src/backend/utils/adt/selfuncs.c606
-rw-r--r--src/backend/utils/adt/tid.c15
-rw-r--r--src/backend/utils/adt/timestamp.c161
-rw-r--r--src/backend/utils/adt/varbit.c10
-rw-r--r--src/backend/utils/adt/varchar.c60
-rw-r--r--src/backend/utils/adt/varlena.c77
40 files changed, 1506 insertions, 1549 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 4a21630b06c..11f4dc52bf0 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -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);
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 84c674071c1..f6687847144 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -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)
{
diff --git a/src/backend/utils/adt/ascii.c b/src/backend/utils/adt/ascii.c
index 99bafca1baa..c08960ca208 100644
--- a/src/backend/utils/adt/ascii.c
+++ b/src/backend/utils/adt/ascii.c
@@ -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 */
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index dbcf881bf6c..7ffa8a82c35 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -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
diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c
index dc6bd5e9765..fa2cc093213 100644
--- a/src/backend/utils/adt/char.c
+++ b/src/backend/utils/adt/char.c
@@ -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);
}
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index d59d9f9e117..8fb2bbad294 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -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;
}
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 6d6fbd6b456..06b249a8e13 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -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;
}
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index 4e278c0489c..bb3fafdafb6 100644
--- a/src/backend/utils/adt/datum.c
+++ b/src/backend/utils/adt/datum.c
@@ -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
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index ce197bd19f4..e5308aca27a 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -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)
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 8e5408af312..c7dc220d078 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -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 */
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index f2cf46200d3..af928933dd0 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -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)
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index d517eb68183..0957783a4ad 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -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;
- }
-
- 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); */
+ 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);
+ */
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
*/
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 4590500ecad..28a04d0725f 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -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");
diff --git a/src/backend/utils/adt/inet_net_ntop.c b/src/backend/utils/adt/inet_net_ntop.c
index 73329300956..c0d782ec089 100644
--- a/src/backend/utils/adt/inet_net_ntop.c
+++ b/src/backend/utils/adt/inet_net_ntop.c
@@ -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;
diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c
index 3784bf04bef..785d333f9d0 100644
--- a/src/backend/utils/adt/inet_net_pton.c
+++ b/src/backend/utils/adt/inet_net_pton.c
@@ -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);
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 8d8f9ed6420..41a60615884 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -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++;
diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c
index f3f8b9854e1..2969f158918 100644
--- a/src/backend/utils/adt/like.c
+++ b/src/backend/utils/adt/like.c
@@ -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...
diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c
index f13b8fea05c..f92d424d3ee 100644
--- a/src/backend/utils/adt/like_match.c
+++ b/src/backend/utils/adt/like_match.c
@@ -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.
*/
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index af08bda8789..5bdd5475c3f 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -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;
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index 29608aa78db..3bbf5ec7c89 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -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);
}
diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c
index 532a9d863a8..cc3c8a791f7 100644
--- a/src/backend/utils/adt/name.c
+++ b/src/backend/utils/adt/name.c
@@ -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
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index 674ed49630b..40044921747 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -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);
-
- 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;
- }
+ {
+ 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;
+ }
case MACADDROID:
- {
- 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;
- }
+ {
+ 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;
+ }
}
/*
@@ -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
*
diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c
index ac596b1f123..8c3ca1b73bc 100644
--- a/src/backend/utils/adt/not_in.c
+++ b/src/backend/utils/adt/not_in.c
@@ -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)
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 5160f690c1e..4e7398448b8 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -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
*/
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index 92af2ab56cf..bb7f8944417 100644
--- a/src/backend/utils/adt/numutils.c
+++ b/src/backend/utils/adt/numutils.c
@@ -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
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c
index 698c309f9d6..46a029caaea 100644
--- a/src/backend/utils/adt/oracle_compat.c
+++ b/src/backend/utils/adt/oracle_compat.c
@@ -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;
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 513328d35c5..17abbbd5a3f 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -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 */
diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c
index 5c6cc6e1e4a..056ad988442 100644
--- a/src/backend/utils/adt/pg_lzcompress.c
+++ b/src/backend/utils/adt/pg_lzcompress.c
@@ -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.
*/
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 01cc5e45b39..b5f3744d510 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -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_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_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_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);
}
-
-
diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c
index 10999150a21..45e4c1133dc 100644
--- a/src/backend/utils/adt/quote.c
+++ b/src/backend/utils/adt/quote.c
@@ -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
diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c
index 146ae742636..926d7875bad 100644
--- a/src/backend/utils/adt/regexp.c
+++ b/src/backend/utils/adt/regexp.c
@@ -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
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 3ae65c6c8e5..b06001af3da 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -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);
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index a03ca774408..b71732a1942 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -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);
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1d1969e68d5..3ed36783f5c 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -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,
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 306758ff77e..e7d319e9b65 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.99 2001/10/13 23:32:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.100 2001/10/25 05:49:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -100,7 +100,7 @@
/*
* Note: the default selectivity estimates are not chosen entirely at random.
* We want them to be small enough to ensure that indexscans will be used if
- * available, for typical table densities of ~100 tuples/page. Thus, for
+ * available, for typical table densities of ~100 tuples/page. Thus, for
* example, 0.01 is not quite small enough, since that makes it appear that
* nearly all pages will be hit anyway. Also, since we sometimes estimate
* eqsel as 1/num_distinct, we probably want DEFAULT_NUM_DISTINCT to equal
@@ -135,22 +135,22 @@ static void convert_string_to_scalar(unsigned char *value,
unsigned char *hibound,
double *scaledhibound);
static void convert_bytea_to_scalar(Datum value,
- double *scaledvalue,
- Datum lobound,
- double *scaledlobound,
- Datum hibound,
- double *scaledhibound);
+ double *scaledvalue,
+ Datum lobound,
+ double *scaledlobound,
+ Datum hibound,
+ double *scaledhibound);
static double convert_one_string_to_scalar(unsigned char *value,
int rangelo, int rangehi);
static double convert_one_bytea_to_scalar(unsigned char *value, int valuelen,
- int rangelo, int rangehi);
+ int rangelo, int rangehi);
static unsigned char *convert_string_datum(Datum value, Oid typid);
static double convert_timevalue_to_scalar(Datum value, Oid typid);
static double get_att_numdistinct(Query *root, Var *var,
- Form_pg_statistic stats);
+ Form_pg_statistic stats);
static bool get_restriction_var(List *args, int varRelid,
- Var **var, Node **other,
- bool *varonleft);
+ Var **var, Node **other,
+ bool *varonleft);
static void get_join_vars(List *args, Var **var1, Var **var2);
static Selectivity prefix_selectivity(Query *root, Var *var, char *prefix);
static Selectivity pattern_selectivity(char *patt, Pattern_Type ptype);
@@ -188,9 +188,9 @@ eqsel(PG_FUNCTION_ARGS)
double selec;
/*
- * If expression is not var = something or something = var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var = something or something = var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
@@ -200,10 +200,10 @@ eqsel(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(DEFAULT_EQ_SEL);
/*
- * If the something is a NULL constant, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the something is a NULL constant, assume operator is strict and
+ * return zero, ie, operator will never return TRUE.
*/
- if (IsA(other, Const) && ((Const *) other)->constisnull)
+ if (IsA(other, Const) &&((Const *) other)->constisnull)
PG_RETURN_FLOAT8(0.0);
/* get stats for the attribute, if available */
@@ -220,15 +220,15 @@ eqsel(PG_FUNCTION_ARGS)
if (IsA(other, Const))
{
/* Var is being compared to a known non-null constant */
- Datum constval = ((Const *) other)->constvalue;
- bool match = false;
- int i;
+ Datum constval = ((Const *) other)->constvalue;
+ bool match = false;
+ int i;
/*
* Is the constant "=" to any of the column's most common
- * values? (Although the given operator may not really be
- * "=", we will assume that seeing whether it returns TRUE
- * is an appropriate test. If you don't like this, maybe you
+ * values? (Although the given operator may not really be
+ * "=", we will assume that seeing whether it returns TRUE is
+ * an appropriate test. If you don't like this, maybe you
* shouldn't be using eqsel for your operator...)
*/
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
@@ -267,41 +267,42 @@ eqsel(PG_FUNCTION_ARGS)
{
/*
* Constant is "=" to this common value. We know
- * selectivity exactly (or as exactly as VACUUM
- * could calculate it, anyway).
+ * selectivity exactly (or as exactly as VACUUM could
+ * calculate it, anyway).
*/
selec = numbers[i];
}
else
{
/*
- * Comparison is against a constant that is neither
- * NULL nor any of the common values. Its selectivity
- * cannot be more than this:
+ * Comparison is against a constant that is neither NULL
+ * nor any of the common values. Its selectivity cannot
+ * be more than this:
*/
- double sumcommon = 0.0;
- double otherdistinct;
+ double sumcommon = 0.0;
+ double otherdistinct;
for (i = 0; i < nnumbers; i++)
sumcommon += numbers[i];
selec = 1.0 - sumcommon - stats->stanullfrac;
+
/*
- * and in fact it's probably a good deal less.
- * We approximate that all the not-common values
- * share this remaining fraction equally, so we
- * divide by the number of other distinct values.
+ * and in fact it's probably a good deal less. We
+ * approximate that all the not-common values share this
+ * remaining fraction equally, so we divide by the number
+ * of other distinct values.
*/
otherdistinct = get_att_numdistinct(root, var, stats)
- nnumbers;
if (otherdistinct > 1)
selec /= otherdistinct;
+
/*
- * Another cross-check: selectivity shouldn't be
- * estimated as more than the least common
- * "most common value".
+ * Another cross-check: selectivity shouldn't be estimated
+ * as more than the least common "most common value".
*/
- if (nnumbers > 0 && selec > numbers[nnumbers-1])
- selec = numbers[nnumbers-1];
+ if (nnumbers > 0 && selec > numbers[nnumbers - 1])
+ selec = numbers[nnumbers - 1];
}
free_attstatsslot(var->vartype, values, nvalues,
@@ -312,22 +313,23 @@ eqsel(PG_FUNCTION_ARGS)
double ndistinct;
/*
- * Search is for a value that we do not know a priori, but
- * we will assume it is not NULL. Estimate the selectivity
- * as non-null fraction divided by number of distinct values,
- * so that we get a result averaged over all possible values
- * whether common or uncommon. (Essentially, we are assuming
+ * Search is for a value that we do not know a priori, but we
+ * will assume it is not NULL. Estimate the selectivity as
+ * non-null fraction divided by number of distinct values, so
+ * that we get a result averaged over all possible values
+ * whether common or uncommon. (Essentially, we are assuming
* that the not-yet-known comparison value is equally likely
* to be any of the possible values, regardless of their
- * frequency in the table. Is that a good idea?)
+ * frequency in the table. Is that a good idea?)
*/
selec = 1.0 - stats->stanullfrac;
ndistinct = get_att_numdistinct(root, var, stats);
if (ndistinct > 1)
selec /= ndistinct;
+
/*
- * Cross-check: selectivity should never be
- * estimated as more than the most common value's.
+ * Cross-check: selectivity should never be estimated as more
+ * than the most common value's.
*/
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
STATISTIC_KIND_MCV, InvalidOid,
@@ -347,8 +349,8 @@ eqsel(PG_FUNCTION_ARGS)
/*
* No VACUUM ANALYZE stats available, so make a guess using
* estimated number of distinct values and assuming they are
- * equally common. (The guess is unlikely to be very good,
- * but we do know a few special cases.)
+ * equally common. (The guess is unlikely to be very good, but we
+ * do know a few special cases.)
*/
selec = 1.0 / get_att_numdistinct(root, var, NULL);
}
@@ -387,10 +389,10 @@ neqsel(PG_FUNCTION_ARGS)
if (eqop)
{
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
- PointerGetDatum(root),
- ObjectIdGetDatum(eqop),
- PointerGetDatum(args),
- Int32GetDatum(varRelid)));
+ PointerGetDatum(root),
+ ObjectIdGetDatum(eqop),
+ PointerGetDatum(args),
+ Int32GetDatum(varRelid)));
}
else
{
@@ -433,23 +435,24 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
int i;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
relid = getrelid(var->varno, root->rtable);
if (relid == InvalidOid)
return DEFAULT_INEQ_SEL;
/*
- * Can't do anything useful if the something is not a constant, either.
+ * Can't do anything useful if the something is not a constant,
+ * either.
*/
- if (! IsA(other, Const))
+ if (!IsA(other, Const))
return DEFAULT_INEQ_SEL;
/*
- * If the constant is NULL, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the constant is NULL, assume operator is strict and return zero,
+ * ie, operator will never return TRUE.
*/
if (((Const *) other)->constisnull)
return 0.0;
@@ -471,9 +474,9 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
fmgr_info(get_opcode(operator), &opproc);
/*
- * If we have most-common-values info, add up the fractions of the
- * MCV entries that satisfy MCV OP CONST. These fractions contribute
- * directly to the result selectivity. Also add up the total fraction
+ * If we have most-common-values info, add up the fractions of the MCV
+ * entries that satisfy MCV OP CONST. These fractions contribute
+ * directly to the result selectivity. Also add up the total fraction
* represented by MCV entries.
*/
mcv_selec = 0.0;
@@ -517,8 +520,8 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
{
if (nvalues > 1)
{
- double histfrac;
- bool ltcmp;
+ double histfrac;
+ bool ltcmp;
ltcmp = DatumGetBool(FunctionCall2(&opproc,
values[0],
@@ -533,9 +536,10 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
else
{
/*
- * Scan to find proper location. This could be made faster
- * by using a binary-search method, but it's probably not
- * worth the trouble for typical histogram sizes.
+ * Scan to find proper location. This could be made
+ * faster by using a binary-search method, but it's
+ * probably not worth the trouble for typical histogram
+ * sizes.
*/
for (i = 1; i < nvalues; i++)
{
@@ -563,11 +567,11 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
* We have values[i-1] < constant < values[i].
*
* Convert the constant and the two nearest bin boundary
- * values to a uniform comparison scale, and do a linear
- * interpolation within this bin.
+ * values to a uniform comparison scale, and do a
+ * linear interpolation within this bin.
*/
if (convert_to_scalar(constval, consttype, &val,
- values[i-1], values[i],
+ values[i - 1], values[i],
var->vartype,
&low, &high))
{
@@ -583,11 +587,12 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
else
{
binfrac = (val - low) / (high - low);
+
/*
- * Watch out for the possibility that we got a NaN
- * or Infinity from the division. This can happen
- * despite the previous checks, if for example
- * "low" is -Infinity.
+ * Watch out for the possibility that we got a
+ * NaN or Infinity from the division. This
+ * can happen despite the previous checks, if
+ * for example "low" is -Infinity.
*/
if (isnan(binfrac) ||
binfrac < 0.0 || binfrac > 1.0)
@@ -597,35 +602,40 @@ scalarineqsel(Query *root, Oid operator, bool isgt,
else
{
/*
- * Ideally we'd produce an error here, on the grounds
- * that the given operator shouldn't have scalarXXsel
- * registered as its selectivity func unless we can
- * deal with its operand types. But currently, all
- * manner of stuff is invoking scalarXXsel, so give a
- * default estimate until that can be fixed.
+ * Ideally we'd produce an error here, on the
+ * grounds that the given operator shouldn't have
+ * scalarXXsel registered as its selectivity func
+ * unless we can deal with its operand types. But
+ * currently, all manner of stuff is invoking
+ * scalarXXsel, so give a default estimate until
+ * that can be fixed.
*/
binfrac = 0.5;
}
+
/*
- * Now, compute the overall selectivity across the values
- * represented by the histogram. We have i-1 full bins
- * and binfrac partial bin below the constant.
+ * Now, compute the overall selectivity across the
+ * values represented by the histogram. We have i-1
+ * full bins and binfrac partial bin below the
+ * constant.
*/
- histfrac = (double) (i-1) + binfrac;
+ histfrac = (double) (i - 1) + binfrac;
histfrac /= (double) (nvalues - 1);
}
}
+
/*
- * Now histfrac = fraction of histogram entries below the constant.
+ * Now histfrac = fraction of histogram entries below the
+ * constant.
*
* Account for "<" vs ">"
*/
hist_selec = isgt ? (1.0 - histfrac) : histfrac;
+
/*
* The histogram boundaries are only approximate to begin
- * with, and may well be out of date anyway. Therefore,
- * don't believe extremely small or large selectivity
- * estimates.
+ * with, and may well be out of date anyway. Therefore, don't
+ * believe extremely small or large selectivity estimates.
*/
if (hist_selec < 0.0001)
hist_selec = 0.0001;
@@ -684,9 +694,9 @@ scalarltsel(PG_FUNCTION_ARGS)
double selec;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
@@ -734,9 +744,9 @@ scalargtsel(PG_FUNCTION_ARGS)
double selec;
/*
- * If expression is not var op something or something op var for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op something or something op var for a
+ * simple var of a real relation (no subqueries, for now), then punt
+ * and return a default estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
@@ -774,6 +784,7 @@ static double
patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
{
Query *root = (Query *) PG_GETARG_POINTER(0);
+
#ifdef NOT_USED
Oid operator = PG_GETARG_OID(1);
#endif
@@ -791,9 +802,9 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
double result;
/*
- * If expression is not var op constant for
- * a simple var of a real relation (no subqueries, for now),
- * then punt and return a default estimate.
+ * If expression is not var op constant for a simple var of a real
+ * relation (no subqueries, for now), then punt and return a default
+ * estimate.
*/
if (!get_restriction_var(args, varRelid,
&var, &other, &varonleft))
@@ -805,8 +816,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
return DEFAULT_MATCH_SEL;
/*
- * If the constant is NULL, assume operator is strict
- * and return zero, ie, operator will never return TRUE.
+ * If the constant is NULL, assume operator is strict and return zero,
+ * ie, operator will never return TRUE.
*/
if (((Const *) other)->constisnull)
return 0.0;
@@ -834,16 +845,16 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
eqargs = makeList2(var, eqcon);
result = DatumGetFloat8(DirectFunctionCall4(eqsel,
PointerGetDatum(root),
- ObjectIdGetDatum(eqopr),
- PointerGetDatum(eqargs),
- Int32GetDatum(varRelid)));
+ ObjectIdGetDatum(eqopr),
+ PointerGetDatum(eqargs),
+ Int32GetDatum(varRelid)));
}
else
{
/*
- * Not exact-match pattern. We estimate selectivity of the
- * fixed prefix and remainder of pattern separately, then
- * combine the two.
+ * Not exact-match pattern. We estimate selectivity of the fixed
+ * prefix and remainder of pattern separately, then combine the
+ * two.
*/
Selectivity prefixsel;
Selectivity restsel;
@@ -964,28 +975,28 @@ icnlikesel(PG_FUNCTION_ARGS)
Selectivity
booltestsel(Query *root, BooleanTest *clause, int varRelid)
{
- Var *var;
- Node *arg;
- Oid relid;
- HeapTuple statsTuple;
- Datum *values;
- int nvalues;
- float4 *numbers;
- int nnumbers;
- double selec;
+ Var *var;
+ Node *arg;
+ Oid relid;
+ HeapTuple statsTuple;
+ Datum *values;
+ int nvalues;
+ float4 *numbers;
+ int nnumbers;
+ double selec;
Assert(clause && IsA(clause, BooleanTest));
arg = (Node *) clause->arg;
/*
- * Ignore any binary-compatible relabeling (probably unnecessary,
- * but can't hurt)
+ * Ignore any binary-compatible relabeling (probably unnecessary, but
+ * can't hurt)
*/
if (IsA(arg, RelabelType))
arg = ((RelabelType *) arg)->arg;
- if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno))
+ if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno))
var = (Var *) arg;
else
{
@@ -996,24 +1007,24 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
* and just assume the value is either TRUE or FALSE.
*/
switch (clause->booltesttype)
- {
+ {
case IS_UNKNOWN:
selec = DEFAULT_UNK_SEL;
break;
case IS_NOT_UNKNOWN:
selec = DEFAULT_NOT_UNK_SEL;
break;
- case IS_TRUE:
- case IS_NOT_FALSE:
+ case IS_TRUE:
+ case IS_NOT_FALSE:
selec = (double) clause_selectivity(root, arg, varRelid);
break;
- case IS_FALSE:
- case IS_NOT_TRUE:
+ case IS_FALSE:
+ case IS_NOT_TRUE:
selec = 1.0 - (double) clause_selectivity(root, arg, varRelid);
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
selec = 0.0; /* Keep compiler quiet */
break;
}
@@ -1033,7 +1044,7 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
if (HeapTupleIsValid(statsTuple))
{
Form_pg_statistic stats;
- double freq_null;
+ double freq_null;
stats = (Form_pg_statistic) GETSTRUCT(statsTuple);
@@ -1045,8 +1056,8 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
&numbers, &nnumbers)
&& nnumbers > 0)
{
- double freq_true;
- double freq_false;
+ double freq_true;
+ double freq_false;
/*
* Get first MCV frequency and derive frequency for true.
@@ -1057,41 +1068,41 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
freq_true = 1.0 - numbers[0] - freq_null;
/*
- * Next derive freqency for false.
- * Then use these as appropriate to derive frequency for each case.
+ * Next derive freqency for false. Then use these as
+ * appropriate to derive frequency for each case.
*/
freq_false = 1.0 - freq_true - freq_null;
switch (clause->booltesttype)
- {
- case IS_UNKNOWN:
+ {
+ case IS_UNKNOWN:
/* select only NULL values */
selec = freq_null;
break;
- case IS_NOT_UNKNOWN:
+ case IS_NOT_UNKNOWN:
/* select non-NULL values */
selec = 1.0 - freq_null;
break;
- case IS_TRUE:
+ case IS_TRUE:
/* select only TRUE values */
selec = freq_true;
break;
- case IS_NOT_TRUE:
+ case IS_NOT_TRUE:
/* select non-TRUE values */
selec = 1.0 - freq_true;
break;
- case IS_FALSE:
+ case IS_FALSE:
/* select only FALSE values */
selec = freq_false;
break;
- case IS_NOT_FALSE:
+ case IS_NOT_FALSE:
/* select non-FALSE values */
selec = 1.0 - freq_false;
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
+ selec = 0.0; /* Keep compiler quiet */
break;
}
@@ -1101,37 +1112,38 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
else
{
/*
- * No most-common-value info available.
- * Still have null fraction information,
- * so use it for IS [NOT] UNKNOWN.
- * Otherwise adjust for null fraction and
- * assume an even split for boolean tests.
+ * No most-common-value info available. Still have null
+ * fraction information, so use it for IS [NOT] UNKNOWN.
+ * Otherwise adjust for null fraction and assume an even split
+ * for boolean tests.
*/
switch (clause->booltesttype)
- {
- case IS_UNKNOWN:
+ {
+ case IS_UNKNOWN:
+
/*
* Use freq_null directly.
*/
selec = freq_null;
break;
- case IS_NOT_UNKNOWN:
+ case IS_NOT_UNKNOWN:
+
/*
- * Select not unknown (not null) values.
- * Calculate from freq_null.
+ * Select not unknown (not null) values. Calculate
+ * from freq_null.
*/
selec = 1.0 - freq_null;
break;
- case IS_TRUE:
- case IS_NOT_TRUE:
- case IS_FALSE:
- case IS_NOT_FALSE:
+ case IS_TRUE:
+ case IS_NOT_TRUE:
+ case IS_FALSE:
+ case IS_NOT_FALSE:
selec = (1.0 - freq_null) / 2.0;
break;
- default:
- elog(ERROR, "booltestsel: unexpected booltesttype %d",
- (int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ default:
+ elog(ERROR, "booltestsel: unexpected booltesttype %d",
+ (int) clause->booltesttype);
+ selec = 0.0; /* Keep compiler quiet */
break;
}
}
@@ -1161,7 +1173,7 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
default:
elog(ERROR, "booltestsel: unexpected booltesttype %d",
(int) clause->booltesttype);
- selec = 0.0; /* Keep compiler quiet */
+ selec = 0.0; /* Keep compiler quiet */
break;
}
}
@@ -1181,28 +1193,28 @@ booltestsel(Query *root, BooleanTest *clause, int varRelid)
Selectivity
nulltestsel(Query *root, NullTest *clause, int varRelid)
{
- Var *var;
- Node *arg;
- Oid relid;
- HeapTuple statsTuple;
- double selec;
- double defselec;
- double freq_null;
+ Var *var;
+ Node *arg;
+ Oid relid;
+ HeapTuple statsTuple;
+ double selec;
+ double defselec;
+ double freq_null;
Assert(clause && IsA(clause, NullTest));
switch (clause->nulltesttype)
- {
- case IS_NULL:
+ {
+ case IS_NULL:
defselec = DEFAULT_UNK_SEL;
break;
- case IS_NOT_NULL:
+ case IS_NOT_NULL:
defselec = DEFAULT_NOT_UNK_SEL;
break;
- default:
- elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
- (int) clause->nulltesttype);
- return (Selectivity) 0; /* keep compiler quiet */
+ default:
+ elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
+ (int) clause->nulltesttype);
+ return (Selectivity) 0; /* keep compiler quiet */
}
arg = (Node *) clause->arg;
@@ -1213,7 +1225,7 @@ nulltestsel(Query *root, NullTest *clause, int varRelid)
if (IsA(arg, RelabelType))
arg = ((RelabelType *) arg)->arg;
- if (IsA(arg, Var) && (varRelid == 0 || varRelid == ((Var *) arg)->varno))
+ if (IsA(arg, Var) &&(varRelid == 0 || varRelid == ((Var *) arg)->varno))
var = (Var *) arg;
else
{
@@ -1225,7 +1237,7 @@ nulltestsel(Query *root, NullTest *clause, int varRelid)
relid = getrelid(var->varno, root->rtable);
if (relid == InvalidOid)
- return (Selectivity) defselec;
+ return (Selectivity) defselec;
/* get stats for the attribute, if available */
statsTuple = SearchSysCache(STATRELATT,
@@ -1240,24 +1252,26 @@ nulltestsel(Query *root, NullTest *clause, int varRelid)
freq_null = stats->stanullfrac;
switch (clause->nulltesttype)
- {
- case IS_NULL:
+ {
+ case IS_NULL:
+
/*
* Use freq_null directly.
*/
selec = freq_null;
break;
- case IS_NOT_NULL:
+ case IS_NOT_NULL:
+
/*
- * Select not unknown (not null) values.
- * Calculate from freq_null.
+ * Select not unknown (not null) values. Calculate from
+ * freq_null.
*/
selec = 1.0 - freq_null;
break;
- default:
- elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
- (int) clause->nulltesttype);
- return (Selectivity) 0; /* keep compiler quiet */
+ default:
+ elog(ERROR, "nulltestsel: unexpected nulltesttype %d",
+ (int) clause->nulltesttype);
+ return (Selectivity) 0; /* keep compiler quiet */
}
ReleaseSysCache(statsTuple);
@@ -1318,13 +1332,13 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (var1 != NULL)
{
/* get stats for the attribute, if available */
- Oid relid1 = getrelid(var1->varno, root->rtable);
+ Oid relid1 = getrelid(var1->varno, root->rtable);
if (relid1 != InvalidOid)
{
statsTuple1 = SearchSysCache(STATRELATT,
ObjectIdGetDatum(relid1),
- Int16GetDatum(var1->varattno),
+ Int16GetDatum(var1->varattno),
0, 0);
if (HeapTupleIsValid(statsTuple1))
{
@@ -1345,13 +1359,13 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (var2 != NULL)
{
/* get stats for the attribute, if available */
- Oid relid2 = getrelid(var2->varno, root->rtable);
+ Oid relid2 = getrelid(var2->varno, root->rtable);
if (relid2 != InvalidOid)
{
statsTuple2 = SearchSysCache(STATRELATT,
ObjectIdGetDatum(relid2),
- Int16GetDatum(var2->varattno),
+ Int16GetDatum(var2->varattno),
0, 0);
if (HeapTupleIsValid(statsTuple2))
{
@@ -1372,17 +1386,18 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (have_mcvs1 && have_mcvs2)
{
/*
- * We have most-common-value lists for both relations. Run
+ * We have most-common-value lists for both relations. Run
* through the lists to see which MCVs actually join to each
* other with the given operator. This allows us to determine
* the exact join selectivity for the portion of the relations
- * represented by the MCV lists. We still have to estimate for
- * the remaining population, but in a skewed distribution this
- * gives us a big leg up in accuracy. For motivation see the
- * analysis in Y. Ioannidis and S. Christodoulakis, "On the
- * propagation of errors in the size of join results", Technical
- * Report 1018, Computer Science Dept., University of Wisconsin,
- * Madison, March 1991 (available from ftp.cs.wisc.edu).
+ * represented by the MCV lists. We still have to estimate
+ * for the remaining population, but in a skewed distribution
+ * this gives us a big leg up in accuracy. For motivation see
+ * the analysis in Y. Ioannidis and S. Christodoulakis, "On
+ * the propagation of errors in the size of join results",
+ * Technical Report 1018, Computer Science Dept., University
+ * of Wisconsin, Madison, March 1991 (available from
+ * ftp.cs.wisc.edu).
*/
FmgrInfo eqproc;
bool *hasmatch1;
@@ -1404,17 +1419,19 @@ eqjoinsel(PG_FUNCTION_ARGS)
memset(hasmatch1, 0, nvalues1 * sizeof(bool));
hasmatch2 = (bool *) palloc(nvalues2 * sizeof(bool));
memset(hasmatch2, 0, nvalues2 * sizeof(bool));
+
/*
- * Note we assume that each MCV will match at most one member of
- * the other MCV list. If the operator isn't really equality,
- * there could be multiple matches --- but we don't look for them,
- * both for speed and because the math wouldn't add up...
+ * Note we assume that each MCV will match at most one member
+ * of the other MCV list. If the operator isn't really
+ * equality, there could be multiple matches --- but we don't
+ * look for them, both for speed and because the math wouldn't
+ * add up...
*/
matchprodfreq = 0.0;
nmatches = 0;
for (i = 0; i < nvalues1; i++)
{
- int j;
+ int j;
for (j = 0; j < nvalues2; j++)
{
@@ -1450,19 +1467,21 @@ eqjoinsel(PG_FUNCTION_ARGS)
}
pfree(hasmatch1);
pfree(hasmatch2);
+
/*
* Compute total frequency of non-null values that are not in
* the MCV lists.
*/
otherfreq1 = 1.0 - stats1->stanullfrac - matchfreq1 - unmatchfreq1;
otherfreq2 = 1.0 - stats2->stanullfrac - matchfreq2 - unmatchfreq2;
+
/*
- * We can estimate the total selectivity from the point of view
- * of relation 1 as: the known selectivity for matched MCVs, plus
- * unmatched MCVs that are assumed to match against random members
- * of relation 2's non-MCV population, plus non-MCV values that
- * are assumed to match against random members of relation 2's
- * unmatched MCVs plus non-MCV values.
+ * We can estimate the total selectivity from the point of
+ * view of relation 1 as: the known selectivity for matched
+ * MCVs, plus unmatched MCVs that are assumed to match against
+ * random members of relation 2's non-MCV population, plus
+ * non-MCV values that are assumed to match against random
+ * members of relation 2's unmatched MCVs plus non-MCV values.
*/
totalsel1 = matchprodfreq;
if (nd2 > nvalues2)
@@ -1477,33 +1496,36 @@ eqjoinsel(PG_FUNCTION_ARGS)
if (nd1 > nmatches)
totalsel2 += otherfreq2 * (otherfreq1 + unmatchfreq1) /
(nd1 - nmatches);
+
/*
- * Use the smaller of the two estimates. This can be justified
- * in essentially the same terms as given below for the no-stats
- * case: to a first approximation, we are estimating from the
- * point of view of the relation with smaller nd.
+ * Use the smaller of the two estimates. This can be
+ * justified in essentially the same terms as given below for
+ * the no-stats case: to a first approximation, we are
+ * estimating from the point of view of the relation with
+ * smaller nd.
*/
selec = (totalsel1 < totalsel2) ? totalsel1 : totalsel2;
}
else
{
/*
- * We do not have MCV lists for both sides. Estimate the
- * join selectivity as MIN(1/nd1, 1/nd2). This is plausible
- * if we assume that the values are about equally distributed:
- * a given tuple of rel1 will join to either 0 or N2/nd2 rows
- * of rel2, so total join rows are at most N1*N2/nd2 giving
- * a join selectivity of not more than 1/nd2. By the same logic
+ * We do not have MCV lists for both sides. Estimate the join
+ * selectivity as MIN(1/nd1, 1/nd2). This is plausible if we
+ * assume that the values are about equally distributed: a
+ * given tuple of rel1 will join to either 0 or N2/nd2 rows of
+ * rel2, so total join rows are at most N1*N2/nd2 giving a
+ * join selectivity of not more than 1/nd2. By the same logic
* it is not more than 1/nd1, so MIN(1/nd1, 1/nd2) is an upper
* bound. Using the MIN() means we estimate from the point of
- * view of the relation with smaller nd (since the larger nd is
- * determining the MIN). It is reasonable to assume that most
- * tuples in this rel will have join partners, so the bound is
- * probably reasonably tight and should be taken as-is.
+ * view of the relation with smaller nd (since the larger nd
+ * is determining the MIN). It is reasonable to assume that
+ * most tuples in this rel will have join partners, so the
+ * bound is probably reasonably tight and should be taken
+ * as-is.
*
- * XXX Can we be smarter if we have an MCV list for just one side?
- * It seems that if we assume equal distribution for the other
- * side, we end up with the same answer anyway.
+ * XXX Can we be smarter if we have an MCV list for just one
+ * side? It seems that if we assume equal distribution for the
+ * other side, we end up with the same answer anyway.
*/
if (nd1 > nd2)
selec = 1.0 / nd1;
@@ -1545,9 +1567,9 @@ neqjoinsel(PG_FUNCTION_ARGS)
if (eqop)
{
result = DatumGetFloat8(DirectFunctionCall3(eqjoinsel,
- PointerGetDatum(root),
- ObjectIdGetDatum(eqop),
- PointerGetDatum(args)));
+ PointerGetDatum(root),
+ ObjectIdGetDatum(eqop),
+ PointerGetDatum(args)));
}
else
@@ -1702,9 +1724,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
{
switch (valuetypid)
{
- /*
- * Built-in numeric types
- */
+ /*
+ * Built-in numeric types
+ */
case BOOLOID:
case INT2OID:
case INT4OID:
@@ -1719,9 +1741,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
*scaledhibound = convert_numeric_to_scalar(hibound, boundstypid);
return true;
- /*
- * Built-in string types
- */
+ /*
+ * Built-in string types
+ */
case CHAROID:
case BPCHAROID:
case VARCHAROID:
@@ -1741,9 +1763,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
return true;
}
- /*
- * Built-in bytea type
- */
+ /*
+ * Built-in bytea type
+ */
case BYTEAOID:
{
convert_bytea_to_scalar(value, scaledvalue,
@@ -1752,9 +1774,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
return true;
}
- /*
- * Built-in time types
- */
+ /*
+ * Built-in time types
+ */
case TIMESTAMPOID:
case TIMESTAMPTZOID:
case ABSTIMEOID:
@@ -1769,9 +1791,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
*scaledhibound = convert_timevalue_to_scalar(hibound, boundstypid);
return true;
- /*
- * Built-in network types
- */
+ /*
+ * Built-in network types
+ */
case INETOID:
case CIDROID:
case MACADDROID:
@@ -1975,7 +1997,6 @@ convert_string_datum(Datum value, Oid typid)
char *xfrmstr;
size_t xfrmsize;
size_t xfrmlen;
-
#endif
switch (typid)
@@ -2016,7 +2037,7 @@ convert_string_datum(Datum value, Oid typid)
#ifdef USE_LOCALE
/* Guess that transformed string is not much bigger than original */
- xfrmsize = strlen(val) + 32;/* arbitrary pad value here... */
+ xfrmsize = strlen(val) + 32; /* arbitrary pad value here... */
xfrmstr = (char *) palloc(xfrmsize);
xfrmlen = strxfrm(xfrmstr, val, xfrmsize);
if (xfrmlen >= xfrmsize)
@@ -2060,8 +2081,8 @@ convert_bytea_to_scalar(Datum value,
i,
minlen;
unsigned char *valstr = (unsigned char *) VARDATA(DatumGetPointer(value)),
- *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)),
- *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound));
+ *lostr = (unsigned char *) VARDATA(DatumGetPointer(lobound)),
+ *histr = (unsigned char *) VARDATA(DatumGetPointer(hibound));
/*
* Assume bytea data is uniformly distributed across all byte values.
@@ -2101,8 +2122,8 @@ convert_one_bytea_to_scalar(unsigned char *value, int valuelen,
return 0.0; /* empty string has scalar value 0 */
/*
- * Since base is 256, need not consider more than about 10
- * chars (even this many seems like overkill)
+ * Since base is 256, need not consider more than about 10 chars (even
+ * this many seems like overkill)
*/
if (valuelen > 10)
valuelen = 10;
@@ -2214,12 +2235,13 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats)
ntuples = rel->tuples;
if (ntuples <= 0.0)
- return DEFAULT_NUM_DISTINCT; /* no data available; return a default */
+ return DEFAULT_NUM_DISTINCT; /* no data available; return a
+ * default */
/*
- * Look to see if there is a unique index on the attribute.
- * If so, we assume it's distinct, ignoring pg_statistic info
- * which could be out of date.
+ * Look to see if there is a unique index on the attribute. If so, we
+ * assume it's distinct, ignoring pg_statistic info which could be out
+ * of date.
*/
if (has_unique_index(rel, var->varattno))
return ntuples;
@@ -2232,12 +2254,12 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats)
if (stats->stadistinct > 0.0)
return stats->stadistinct;
if (stats->stadistinct < 0.0)
- return - stats->stadistinct * ntuples;
+ return -stats->stadistinct * ntuples;
}
/*
- * ANALYZE does not compute stats for system attributes,
- * but some of them can reasonably be assumed unique anyway.
+ * ANALYZE does not compute stats for system attributes, but some of
+ * them can reasonably be assumed unique anyway.
*/
switch (var->varattno)
{
@@ -2249,7 +2271,8 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats)
}
/*
- * Estimate ndistinct = ntuples if the table is small, else use default.
+ * Estimate ndistinct = ntuples if the table is small, else use
+ * default.
*/
if (ntuples < DEFAULT_NUM_DISTINCT)
return ntuples;
@@ -2260,7 +2283,7 @@ get_att_numdistinct(Query *root, Var *var, Form_pg_statistic stats)
/*
* get_restriction_var
* Examine the args of a restriction clause to see if it's of the
- * form (var op something) or (something op var). If so, extract
+ * form (var op something) or (something op var). If so, extract
* and return the var and the other argument.
*
* Inputs:
@@ -2492,7 +2515,6 @@ regex_fixed_prefix(char *patt, bool case_insensitive,
/* note start at pos 1 to skip leading ^ */
for (pos = 1; patt[pos]; pos++)
{
-
/*
* Check for characters that indicate multiple possible matches
* here. XXX I suspect isalpha() is not an adequately
@@ -2609,8 +2631,8 @@ prefix_selectivity(Query *root, Var *var, char *prefix)
/* Assume scalargtsel is appropriate for all supported types */
prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel,
PointerGetDatum(root),
- ObjectIdGetDatum(cmpopr),
- PointerGetDatum(cmpargs),
+ ObjectIdGetDatum(cmpopr),
+ PointerGetDatum(cmpargs),
Int32GetDatum(0)));
/*-------
@@ -2632,8 +2654,8 @@ prefix_selectivity(Query *root, Var *var, char *prefix)
/* Assume scalarltsel is appropriate for all supported types */
topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel,
PointerGetDatum(root),
- ObjectIdGetDatum(cmpopr),
- PointerGetDatum(cmpargs),
+ ObjectIdGetDatum(cmpopr),
+ PointerGetDatum(cmpargs),
Int32GetDatum(0)));
/*
@@ -2655,7 +2677,6 @@ prefix_selectivity(Query *root, Var *var, char *prefix)
{
if (prefixsel < -0.01)
{
-
/*
* No data available --- use a default estimate that is
* small, but not real small.
@@ -2664,7 +2685,6 @@ prefix_selectivity(Query *root, Var *var, char *prefix)
}
else
{
-
/*
* It's just roundoff error; use a small positive value
*/
@@ -2738,7 +2758,7 @@ regex_selectivity_sub(char *patt, int pattlen, bool case_insensitive)
if (patt[pos] == '(')
{
if (paren_depth == 0)
- paren_pos = pos;/* remember start of parenthesized item */
+ paren_pos = pos; /* remember start of parenthesized item */
paren_depth++;
}
else if (patt[pos] == ')' && paren_depth > 0)
@@ -2751,7 +2771,6 @@ regex_selectivity_sub(char *patt, int pattlen, bool case_insensitive)
}
else if (patt[pos] == '|' && paren_depth == 0)
{
-
/*
* If unquoted | is present at paren level 0 in pattern, we
* have multiple alternatives; sum their probabilities.
@@ -3091,30 +3110,31 @@ genericcostestimate(Query *root, RelOptInfo *rel,
List *selectivityQuals = indexQuals;
/*
- * If the index is partial, AND the index predicate with the explicitly
- * given indexquals to produce a more accurate idea of the index
- * restriction. This may produce redundant clauses, which we hope that
- * cnfify and clauselist_selectivity will deal with intelligently.
+ * If the index is partial, AND the index predicate with the
+ * explicitly given indexquals to produce a more accurate idea of the
+ * index restriction. This may produce redundant clauses, which we
+ * hope that cnfify and clauselist_selectivity will deal with
+ * intelligently.
*
- * Note that index->indpred and indexQuals are both in implicit-AND
- * form to start with, which we have to make explicit to hand to
+ * Note that index->indpred and indexQuals are both in implicit-AND form
+ * to start with, which we have to make explicit to hand to
* canonicalize_qual, and then we get back implicit-AND form again.
*/
if (index->indpred != NIL)
{
- Expr *andedQuals;
+ Expr *andedQuals;
andedQuals = make_ands_explicit(nconc(listCopy(index->indpred),
indexQuals));
selectivityQuals = canonicalize_qual(andedQuals, true);
}
- /* Estimate the fraction of main-table tuples that will be visited */
- *indexSelectivity = clauselist_selectivity(root, selectivityQuals,
- lfirsti(rel->relids));
+ /* Estimate the fraction of main-table tuples that will be visited */
+ *indexSelectivity = clauselist_selectivity(root, selectivityQuals,
+ lfirsti(rel->relids));
/*
- * Estimate the number of tuples that will be visited. We do it in
+ * Estimate the number of tuples that will be visited. We do it in
* this rather peculiar-looking way in order to get the right answer
* for partial indexes. We can bound the number of tuples by the
* index size, in any case.
@@ -3124,14 +3144,14 @@ genericcostestimate(Query *root, RelOptInfo *rel,
if (numIndexTuples > index->tuples)
numIndexTuples = index->tuples;
- /*
+ /*
* Always estimate at least one tuple is touched, even when
* indexSelectivity estimate is tiny.
*/
if (numIndexTuples < 1.0)
numIndexTuples = 1.0;
- /*
+ /*
* Estimate the number of index pages that will be retrieved.
*
* For all currently-supported index types, the first page of the index
@@ -3185,11 +3205,11 @@ btcostestimate(PG_FUNCTION_ARGS)
/*
* If it's a functional index, leave the default zero-correlation
- * estimate in place. If not, and if we can get an estimate for
- * the first variable's ordering correlation C from pg_statistic,
- * estimate the index correlation as C / number-of-columns.
- * (The idea here is that multiple columns dilute the importance
- * of the first column's ordering, but don't negate it entirely.)
+ * estimate in place. If not, and if we can get an estimate for the
+ * first variable's ordering correlation C from pg_statistic, estimate
+ * the index correlation as C / number-of-columns. (The idea here is
+ * that multiple columns dilute the importance of the first column's
+ * ordering, but don't negate it entirely.)
*/
if (index->indproc == InvalidOid)
{
@@ -3204,10 +3224,10 @@ btcostestimate(PG_FUNCTION_ARGS)
0, 0);
if (HeapTupleIsValid(tuple))
{
- Oid typid;
- int32 typmod;
- float4 *numbers;
- int nnumbers;
+ Oid typid;
+ int32 typmod;
+ float4 *numbers;
+ int nnumbers;
get_atttypetypmod(relid, index->indexkeys[0],
&typid, &typmod);
@@ -3216,13 +3236,13 @@ btcostestimate(PG_FUNCTION_ARGS)
index->ordering[0],
NULL, NULL, &numbers, &nnumbers))
{
- double varCorrelation;
- int nKeys;
+ double varCorrelation;
+ int nKeys;
Assert(nnumbers == 1);
varCorrelation = numbers[0];
for (nKeys = 1; index->indexkeys[nKeys] != 0; nKeys++)
- /*skip*/;
+ /* skip */ ;
*indexCorrelation = varCorrelation / nKeys;
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 4385b003deb..623d3178e00 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -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)
{
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index f39e85b235e..7bb5bcab882 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -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);
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index a294bfc9fff..b1304fbae72 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -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
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index c963709ac8f..a09bed915ff 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -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
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 1c6de93f014..7b15cfa690f 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -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;