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.c38
-rw-r--r--src/backend/utils/adt/arrayfuncs.c109
-rw-r--r--src/backend/utils/adt/cash.c6
-rw-r--r--src/backend/utils/adt/date.c49
-rw-r--r--src/backend/utils/adt/datetime.c557
-rw-r--r--src/backend/utils/adt/datum.c10
-rw-r--r--src/backend/utils/adt/float.c6
-rw-r--r--src/backend/utils/adt/format_type.c77
-rw-r--r--src/backend/utils/adt/formatting.c12
-rw-r--r--src/backend/utils/adt/geo_ops.c14
-rw-r--r--src/backend/utils/adt/int8.c10
-rw-r--r--src/backend/utils/adt/lockfuncs.c60
-rw-r--r--src/backend/utils/adt/mac.c4
-rw-r--r--src/backend/utils/adt/misc.c4
-rw-r--r--src/backend/utils/adt/nabstime.c4
-rw-r--r--src/backend/utils/adt/name.c26
-rw-r--r--src/backend/utils/adt/not_in.c6
-rw-r--r--src/backend/utils/adt/numeric.c8
-rw-r--r--src/backend/utils/adt/numutils.c6
-rw-r--r--src/backend/utils/adt/oracle_compat.c6
-rw-r--r--src/backend/utils/adt/pg_locale.c27
-rw-r--r--src/backend/utils/adt/pg_lzcompress.c15
-rw-r--r--src/backend/utils/adt/pseudotypes.c6
-rw-r--r--src/backend/utils/adt/regexp.c35
-rw-r--r--src/backend/utils/adt/regproc.c100
-rw-r--r--src/backend/utils/adt/ri_triggers.c161
-rw-r--r--src/backend/utils/adt/ruleutils.c382
-rw-r--r--src/backend/utils/adt/selfuncs.c58
-rw-r--r--src/backend/utils/adt/sets.c10
-rw-r--r--src/backend/utils/adt/tid.c21
-rw-r--r--src/backend/utils/adt/timestamp.c120
-rw-r--r--src/backend/utils/adt/varbit.c6
-rw-r--r--src/backend/utils/adt/varchar.c3
-rw-r--r--src/backend/utils/adt/varlena.c251
34 files changed, 1143 insertions, 1064 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index aa65bd650b1..02d2e6746b5 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.78 2002/09/03 22:17:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.79 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,15 +36,15 @@ static const char *aclparse(const char *s, AclItem *aip, unsigned *modechg);
static bool aclitemeq(const AclItem *a1, const AclItem *a2);
static bool aclitemgt(const AclItem *a1, const AclItem *a2);
-static Oid convert_table_name(text *tablename);
+static Oid convert_table_name(text *tablename);
static AclMode convert_table_priv_string(text *priv_type_text);
-static Oid convert_database_name(text *databasename);
+static Oid convert_database_name(text *databasename);
static AclMode convert_database_priv_string(text *priv_type_text);
-static Oid convert_function_name(text *functionname);
+static Oid convert_function_name(text *functionname);
static AclMode convert_function_priv_string(text *priv_type_text);
-static Oid convert_language_name(text *languagename);
+static Oid convert_language_name(text *languagename);
static AclMode convert_language_priv_string(text *priv_type_text);
-static Oid convert_schema_name(text *schemaname);
+static Oid convert_schema_name(text *schemaname);
static AclMode convert_schema_priv_string(text *priv_type_text);
@@ -413,7 +413,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
owner_default = ACL_ALL_RIGHTS_RELATION;
break;
case ACL_OBJECT_DATABASE:
- world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */
+ world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */
owner_default = ACL_ALL_RIGHTS_DATABASE;
break;
case ACL_OBJECT_FUNCTION:
@@ -430,7 +430,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
break;
default:
elog(ERROR, "acldefault: bogus objtype %d", (int) objtype);
- world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
+ world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
owner_default = ACL_NO_RIGHTS;
break;
}
@@ -819,7 +819,7 @@ convert_table_name(text *tablename)
RangeVar *relrv;
relrv = makeRangeVarFromNameList(textToQualifiedNameList(tablename,
- "has_table_privilege"));
+ "has_table_privilege"));
return RangeVarGetRelid(relrv, false);
}
@@ -834,7 +834,7 @@ convert_table_priv_string(text *priv_type_text)
char *priv_type;
priv_type = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(priv_type_text)));
+ PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
@@ -1030,7 +1030,7 @@ convert_database_name(text *databasename)
Oid oid;
dbname = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(databasename)));
+ PointerGetDatum(databasename)));
oid = get_database_oid(dbname);
if (!OidIsValid(oid))
@@ -1049,7 +1049,7 @@ convert_database_priv_string(text *priv_type_text)
char *priv_type;
priv_type = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(priv_type_text)));
+ PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
@@ -1233,10 +1233,10 @@ convert_function_name(text *functionname)
Oid oid;
funcname = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(functionname)));
+ PointerGetDatum(functionname)));
oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein,
- CStringGetDatum(funcname)));
+ CStringGetDatum(funcname)));
if (!OidIsValid(oid))
elog(ERROR, "function \"%s\" does not exist", funcname);
@@ -1254,7 +1254,7 @@ convert_function_priv_string(text *priv_type_text)
char *priv_type;
priv_type = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(priv_type_text)));
+ PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
@@ -1432,7 +1432,7 @@ convert_language_name(text *languagename)
Oid oid;
langname = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(languagename)));
+ PointerGetDatum(languagename)));
oid = GetSysCacheOid(LANGNAME,
CStringGetDatum(langname),
@@ -1453,7 +1453,7 @@ convert_language_priv_string(text *priv_type_text)
char *priv_type;
priv_type = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(priv_type_text)));
+ PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
@@ -1631,7 +1631,7 @@ convert_schema_name(text *schemaname)
Oid oid;
nspname = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(schemaname)));
+ PointerGetDatum(schemaname)));
oid = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(nspname),
@@ -1652,7 +1652,7 @@ convert_schema_priv_string(text *priv_type_text)
char *priv_type;
priv_type = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(priv_type_text)));
+ PointerGetDatum(priv_type_text)));
/*
* Return mode from priv_type string
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 53a4c83d639..5d53eca999f 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.79 2002/08/26 17:53:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.80 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -80,27 +80,27 @@ static void system_cache_lookup(Oid element_type, bool input, int *typlen,
bool *typbyval, char *typdelim, Oid *typelem,
Oid *proc, char *typalign);
static Datum ArrayCast(char *value, bool byval, int len);
-static int ArrayCastAndSet(Datum src,
- int typlen, bool typbyval, char typalign,
- char *dest);
-static int array_nelems_size(char *ptr, int nitems,
- int typlen, bool typbyval, char typalign);
+static int ArrayCastAndSet(Datum src,
+ int typlen, bool typbyval, char typalign,
+ char *dest);
+static int array_nelems_size(char *ptr, int nitems,
+ int typlen, bool typbyval, char typalign);
static char *array_seek(char *ptr, int nitems,
- int typlen, bool typbyval, char typalign);
-static int array_copy(char *destptr, int nitems, char *srcptr,
- int typlen, bool typbyval, char typalign);
+ int typlen, bool typbyval, char typalign);
+static int array_copy(char *destptr, int nitems, char *srcptr,
+ int typlen, bool typbyval, char typalign);
static int array_slice_size(int ndim, int *dim, int *lb, char *arraydataptr,
- int *st, int *endp,
- int typlen, bool typbyval, char typalign);
+ int *st, int *endp,
+ int typlen, bool typbyval, char typalign);
static void array_extract_slice(int ndim, int *dim, int *lb,
- char *arraydataptr,
- int *st, int *endp, char *destPtr,
- int typlen, bool typbyval, char typalign);
+ char *arraydataptr,
+ int *st, int *endp, char *destPtr,
+ int typlen, bool typbyval, char typalign);
static void array_insert_slice(int ndim, int *dim, int *lb,
- char *origPtr, int origdatasize,
- char *destPtr,
- int *st, int *endp, char *srcPtr,
- int typlen, bool typbyval, char typalign);
+ char *origPtr, int origdatasize,
+ char *destPtr,
+ int *st, int *endp, char *srcPtr,
+ int typlen, bool typbyval, char typalign);
/*---------------------------------------------------------------------
@@ -422,28 +422,28 @@ ReadArrayStr(char *arrayStr,
elog(ERROR, "malformed array constant: %s", arrayStr);
break;
case '\\':
- {
- char *cptr;
-
- /* Crunch the string on top of the backslash. */
- for (cptr = ptr; *cptr != '\0'; cptr++)
- *cptr = *(cptr + 1);
- if (*ptr == '\0')
- elog(ERROR, "malformed array constant: %s", arrayStr);
- break;
- }
+ {
+ char *cptr;
+
+ /* Crunch the string on top of the backslash. */
+ for (cptr = ptr; *cptr != '\0'; cptr++)
+ *cptr = *(cptr + 1);
+ if (*ptr == '\0')
+ elog(ERROR, "malformed array constant: %s", arrayStr);
+ break;
+ }
case '\"':
- {
- char *cptr;
-
- scanning_string = !scanning_string;
- /* Crunch the string on top of the quote. */
- for (cptr = ptr; *cptr != '\0'; cptr++)
- *cptr = *(cptr + 1);
- /* Back up to not miss following character. */
- ptr--;
- break;
- }
+ {
+ char *cptr;
+
+ scanning_string = !scanning_string;
+ /* Crunch the string on top of the quote. */
+ for (cptr = ptr; *cptr != '\0'; cptr++)
+ *cptr = *(cptr + 1);
+ /* Back up to not miss following character. */
+ ptr--;
+ break;
+ }
case '{':
if (!scanning_string)
{
@@ -452,9 +452,9 @@ ReadArrayStr(char *arrayStr,
nest_level++;
indx[nest_level - 1] = 0;
/* skip leading whitespace */
- while (isspace((unsigned char) *(ptr+1)))
+ while (isspace((unsigned char) *(ptr + 1)))
ptr++;
- itemstart = ptr+1;
+ itemstart = ptr + 1;
}
break;
case '}':
@@ -471,11 +471,11 @@ ReadArrayStr(char *arrayStr,
else
{
/*
- * tricky coding: terminate item value string at
- * first '}', but don't process it till we see
- * a typdelim char or end of array. This handles
- * case where several '}'s appear successively
- * in a multidimensional array.
+ * tricky coding: terminate item value string
+ * at first '}', but don't process it till we
+ * see a typdelim char or end of array. This
+ * handles case where several '}'s appear
+ * successively in a multidimensional array.
*/
*ptr = '\0';
indx[nest_level - 1]++;
@@ -641,8 +641,8 @@ array_out(PG_FUNCTION_ARGS)
/*
* Convert all values to string form, count total space needed
- * (including any overhead such as escaping backslashes),
- * and detect whether each item needs double quotes.
+ * (including any overhead such as escaping backslashes), and detect
+ * whether each item needs double quotes.
*/
values = (char **) palloc(nitems * sizeof(char *));
needquotes = (bool *) palloc(nitems * sizeof(bool));
@@ -665,7 +665,7 @@ array_out(PG_FUNCTION_ARGS)
nq = (values[i][0] == '\0'); /* force quotes for empty string */
for (tmp = values[i]; *tmp; tmp++)
{
- char ch = *tmp;
+ char ch = *tmp;
overall_length += 1;
if (ch == '"' || ch == '\\')
@@ -716,7 +716,7 @@ array_out(PG_FUNCTION_ARGS)
#ifndef TCL_ARRAYS
for (tmp = values[k]; *tmp; tmp++)
{
- char ch = *tmp;
+ char ch = *tmp;
if (ch == '"' || ch == '\\')
*p++ = '\\';
@@ -919,8 +919,8 @@ array_get_slice(ArrayType *array,
elog(ERROR, "Slices of fixed-length arrays not implemented");
/*
- * fixed-length arrays -- these are assumed to be 1-d, 0-based
- * XXX where would we get the correct ELEMTYPE from?
+ * fixed-length arrays -- these are assumed to be 1-d, 0-based XXX
+ * where would we get the correct ELEMTYPE from?
*/
ndim = 1;
fixedDim[0] = arraylen / elmlen;
@@ -980,8 +980,9 @@ array_get_slice(ArrayType *array,
newarray->flags = 0;
newarray->elemtype = ARR_ELEMTYPE(array);
memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int));
+
/*
- * Lower bounds of the new array are set to 1. Formerly (before 7.3)
+ * Lower bounds of the new array are set to 1. Formerly (before 7.3)
* we copied the given lowerIndx values ... but that seems confusing.
*/
newlb = ARR_LBOUND(newarray);
@@ -1513,9 +1514,7 @@ construct_array(Datum *elems, int nelems,
/* compute required space */
if (elmlen > 0)
- {
nbytes = nelems * att_align(elmlen, elmalign);
- }
else
{
Assert(!elmbyval);
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index 3664a6053f4..c33bca654e8 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.55 2002/09/03 21:45:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.56 2002/09/04 20:31:27 momjian Exp $
*/
#include "postgres.h"
@@ -662,8 +662,8 @@ cash_words(PG_FUNCTION_ARGS)
m0 = val % 100; /* cents */
m1 = (val / 100) % 1000; /* hundreds */
- m2 = (val / 100000) % 1000; /* thousands */
- m3 = val / 100000000 % 1000; /* millions */
+ m2 = (val / 100000) % 1000; /* thousands */
+ m3 = val / 100000000 % 1000; /* millions */
if (m3)
{
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index f02dee4dd84..733b8fb304b 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.71 2002/09/03 19:41:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.72 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,10 +28,10 @@
#include "utils/timestamp.h"
-int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec);
-int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp);
-int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result);
-int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result);
+int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec);
+int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp);
+int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result);
+int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result);
static void AdjustTimeForTypmod(TimeADT *time, int32 typmod);
/*****************************************************************************
@@ -343,7 +343,7 @@ date_timestamptz(PG_FUNCTION_ARGS)
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
- int tz;
+ int tz;
tm->tm_hour = 0;
tm->tm_min = 0;
@@ -494,6 +494,7 @@ Datum
time_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
+
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
@@ -529,7 +530,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result)
{
#ifdef HAVE_INT64_TIMESTAMP
*result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
- * INT64CONST(1000000)) + fsec);
+ * INT64CONST(1000000)) + fsec);
#else
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
#endif
@@ -542,7 +543,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result)
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/
int
-time2tm(TimeADT time, struct tm *tm, fsec_t *fsec)
+time2tm(TimeADT time, struct tm * tm, fsec_t *fsec)
{
#ifdef HAVE_INT64_TIMESTAMP
tm->tm_hour = (time / INT64CONST(3600000000));
@@ -610,7 +611,7 @@ static void
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
- static const int64 TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
+ static const int64 TimeScales[MAX_TIMESTAMP_PRECISION + 1] = {
INT64CONST(1000000),
INT64CONST(100000),
INT64CONST(10000),
@@ -620,7 +621,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
INT64CONST(1)
};
- static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
+ static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
INT64CONST(-500000),
INT64CONST(-50000),
INT64CONST(-5000),
@@ -629,8 +630,9 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
INT64CONST(-5),
INT64CONST(0)
};
+
#else
- static const double TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
+ static const double TimeScales[MAX_TIMESTAMP_PRECISION + 1] = {
1,
10,
100,
@@ -640,7 +642,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
1000000
};
- static const double TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
+ static const double TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
0.5,
0.05,
0.005,
@@ -674,7 +676,10 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
}
else
{
- /* Scale and truncate first, then add to help the rounding behavior */
+ /*
+ * Scale and truncate first, then add to help the rounding
+ * behavior
+ */
*time = (rint((((double) *time) * TimeScales[typmod]) + TimeOffsets[typmod])
/ TimeScales[typmod]);
}
@@ -915,8 +920,10 @@ timestamp_time(PG_FUNCTION_ARGS)
elog(ERROR, "Unable to convert timestamp to time");
#ifdef HAVE_INT64_TIMESTAMP
- /* Could also do this with
- * time = (timestamp / 86400000000 * 86400000000) - timestamp;
+
+ /*
+ * Could also do this with time = (timestamp / 86400000000 *
+ * 86400000000) - timestamp;
*/
result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
* INT64CONST(1000000)) + fsec);
@@ -948,8 +955,10 @@ timestamptz_time(PG_FUNCTION_ARGS)
elog(ERROR, "Unable to convert timestamptz to time");
#ifdef HAVE_INT64_TIMESTAMP
- /* Could also do this with
- * time = (timestamp / 86400000000 * 86400000000) - timestamp;
+
+ /*
+ * Could also do this with time = (timestamp / 86400000000 *
+ * 86400000000) - timestamp;
*/
result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
* INT64CONST(1000000)) + fsec);
@@ -1349,7 +1358,7 @@ timetz_out(PG_FUNCTION_ARGS)
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/
int
-timetz2tm(TimeTzADT *time, struct tm *tm, fsec_t *fsec, int *tzp)
+timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp)
{
#ifdef HAVE_INT64_TIMESTAMP
tm->tm_hour = (time->time / INT64CONST(3600000000));
@@ -1537,6 +1546,7 @@ timetz_pl_interval(PG_FUNCTION_ARGS)
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
TimeTzADT *result;
+
#ifndef HAVE_INT64_TIMESTAMP
TimeTzADT time1;
#endif
@@ -1569,6 +1579,7 @@ timetz_mi_interval(PG_FUNCTION_ARGS)
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
Interval *span = PG_GETARG_INTERVAL_P(1);
TimeTzADT *result;
+
#ifndef HAVE_INT64_TIMESTAMP
TimeTzADT time1;
#endif
@@ -1798,7 +1809,7 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
result = (((date * INT64CONST(86400000000)) + time->time)
- + (time->zone * INT64CONST(1000000)));
+ + (time->zone * INT64CONST(1000000)));
#else
result = (((date * 86400.0) + time->time) + time->zone);
#endif
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 40d1dbc74ca..b4daa35f223 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.95 2002/09/03 19:46:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,13 +42,13 @@ 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};
/*****************************************************************************
@@ -92,7 +92,7 @@ static datetkn datetktbl[] = {
{"acst", DTZ, NEG(16)}, /* Atlantic/Porto Acre */
{"act", TZ, NEG(20)}, /* Atlantic/Porto Acre */
{DA_D, ADBC, AD}, /* "ad" for years >= 0 */
- {"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */
+ {"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */
{"adt", DTZ, NEG(12)}, /* Atlantic Daylight Time */
{"aesst", DTZ, POS(44)}, /* E. Australia */
{"aest", TZ, POS(40)}, /* Australia Eastern Std Time */
@@ -100,7 +100,7 @@ static datetkn datetktbl[] = {
{"ahst", TZ, NEG(40)}, /* Alaska-Hawaii Std Time */
{"akdt", DTZ, NEG(32)}, /* Alaska Daylight Time */
{"akst", DTZ, NEG(36)}, /* Alaska Standard Time */
- {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
+ {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
{"almt", TZ, POS(24)}, /* Almaty Time */
{"almst", TZ, POS(28)}, /* Almaty Savings Time */
{"am", AMPM, AM},
@@ -112,14 +112,15 @@ static datetkn datetktbl[] = {
{"anast", DTZ, POS(52)}, /* Anadyr Summer Time (Russia) */
{"anat", TZ, POS(48)}, /* Anadyr Time (Russia) */
#if 0
-aqtst
-aqtt
-arst
+ aqtst
+ aqtt
+ arst
#endif
{"art", TZ, NEG(12)}, /* Argentina Time */
#if 0
-ashst
-ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */
+ ashst
+ ast /* Atlantic Standard Time, Arabia Standard
+ * Time, Acre Standard Time */
#endif
{"apr", MONTH, 4},
{"april", MONTH, 4},
@@ -140,14 +141,14 @@ ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */
{"bnt", TZ, POS(32)}, /* Brunei Darussalam Time */
{"bort", TZ, POS(32)}, /* Borneo Time (Indonesia) */
#if 0
-bortst
-bost
+ bortst
+ bost
#endif
{"bot", TZ, NEG(16)}, /* Bolivia Time */
{"bra", TZ, NEG(12)}, /* Brazil Time */
#if 0
-brst
-brt
+ brst
+ brt
#endif
{"bst", DTZ, POS(4)}, /* British Summer Time */
#if 0
@@ -165,23 +166,23 @@ brt
#endif
{"cdt", DTZ, NEG(20)}, /* Central Daylight Time */
{"cest", DTZ, POS(8)}, /* Central European Dayl.Time */
- {"cet", TZ, POS(4)}, /* Central European Time */
+ {"cet", TZ, POS(4)}, /* Central European Time */
{"cetdst", DTZ, POS(8)}, /* Central European Dayl.Time */
- {"chadt", DTZ, POS(55)}, /* Chatham Island Daylight Time (13:45) */
+ {"chadt", DTZ, POS(55)}, /* Chatham Island Daylight Time (13:45) */
{"chast", TZ, POS(51)}, /* Chatham Island Time (12:45) */
#if 0
-ckhst
+ ckhst
#endif
{"ckt", TZ, POS(48)}, /* Cook Islands Time */
{"clst", DTZ, NEG(12)}, /* Chile Summer Time */
{"clt", TZ, NEG(16)}, /* Chile Time */
#if 0
-cost
+ cost
#endif
{"cot", TZ, NEG(20)}, /* Columbia Time */
{"cst", TZ, NEG(24)}, /* Central Standard Time */
#if 0
-cvst
+ cvst
#endif
{"cvt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */
{"cxt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */
@@ -214,7 +215,7 @@ cvst
{"egst", DTZ, POS(0)}, /* East Greenland Summer Time */
{"egt", TZ, NEG(4)}, /* East Greenland Time */
#if 0
-ehdt
+ ehdt
#endif
{EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */
{"est", TZ, NEG(20)}, /* Eastern Standard Time */
@@ -225,8 +226,8 @@ ehdt
{"fkst", DTZ, NEG(12)}, /* Falkland Islands Summer Time */
{"fkt", TZ, NEG(8)}, /* Falkland Islands Time */
#if 0
-fnst
-fnt
+ fnst
+ fnt
#endif
{"fri", DOW, 5},
{"friday", DOW, 5},
@@ -238,7 +239,7 @@ fnt
{"get", TZ, POS(16)}, /* Georgia Time */
{"gft", TZ, NEG(12)}, /* French Guiana Time */
#if 0
-ghst
+ ghst
#endif
{"gilt", TZ, POS(48)}, /* Gilbert Islands Time */
{"gmt", TZ, POS(0)}, /* Greenwish Mean Time */
@@ -246,37 +247,37 @@ ghst
{"gyt", TZ, NEG(16)}, /* Guyana Time */
{"h", UNITS, DTK_HOUR}, /* "hour" */
#if 0
-hadt
-hast
+ hadt
+ hast
#endif
{"hdt", DTZ, NEG(36)}, /* Hawaii/Alaska Daylight Time */
#if 0
-hkst
+ hkst
#endif
{"hkt", TZ, POS(32)}, /* Hong Kong Time */
#if 0
{"hmt", TZ, POS(12)}, /* Hellas ? ? */
-hovst
-hovt
+ hovst
+ hovt
#endif
{"hst", TZ, NEG(40)}, /* Hawaii Std Time */
#if 0
-hwt
+ hwt
#endif
{"ict", TZ, POS(28)}, /* Indochina Time */
{"idle", TZ, POS(48)}, /* Intl. Date Line, East */
{"idlw", TZ, NEG(48)}, /* Intl. Date Line, West */
#if 0
-idt /* Israeli, Iran, Indian Daylight Time */
+ idt /* Israeli, Iran, Indian Daylight Time */
#endif
{LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */
- {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */
+ {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */
{"iot", TZ, POS(20)}, /* Indian Chagos Time */
{"irkst", DTZ, POS(36)}, /* Irkutsk Summer Time */
{"irkt", TZ, POS(32)}, /* Irkutsk Time */
{"irt", TZ, POS(14)}, /* Iran Time */
#if 0
-isst
+ isst
#endif
{"ist", TZ, POS(8)}, /* Israel */
{"it", TZ, POS(14)}, /* Iran Time */
@@ -303,7 +304,8 @@ isst
{"lhdt", DTZ, POS(44)}, /* Lord Howe Daylight Time, Australia */
{"lhst", TZ, POS(42)}, /* Lord Howe Standard Time, Australia */
{"ligt", TZ, POS(40)}, /* From Melbourne, Australia */
- {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 hours!) */
+ {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14
+ * hours!) */
{"lkt", TZ, POS(24)}, /* Lanka Time */
{"m", UNITS, DTK_MONTH}, /* "month" for ISO input */
{"magst", DTZ, POS(48)}, /* Magadan Summer Time */
@@ -325,7 +327,7 @@ isst
{"mon", DOW, 1},
{"monday", DOW, 1},
#if 0
-most
+ most
#endif
{"mpt", TZ, POS(40)}, /* North Mariana Islands Time */
{"msd", DTZ, POS(16)}, /* Moscow Summer Time */
@@ -336,7 +338,7 @@ most
{"mvt", TZ, POS(20)}, /* Maldives Island Time */
{"myt", TZ, POS(32)}, /* Malaysia Time */
#if 0
-ncst
+ ncst
#endif
{"nct", TZ, POS(44)}, /* New Caledonia Time */
{"ndt", DTZ, NEG(10)}, /* Nfld. Daylight Time */
@@ -361,7 +363,7 @@ ncst
{"on", IGNORE_DTF, 0}, /* "on" (throwaway) */
{"pdt", DTZ, NEG(28)}, /* Pacific Daylight Time */
#if 0
-pest
+ pest
#endif
{"pet", TZ, NEG(20)}, /* Peru Time */
{"petst", DTZ, POS(52)}, /* Petropavlovsk-Kamchatski Summer Time */
@@ -369,14 +371,14 @@ pest
{"pgt", TZ, POS(40)}, /* Papua New Guinea Time */
{"phot", TZ, POS(52)}, /* Phoenix Islands (Kiribati) Time */
#if 0
-phst
+ phst
#endif
{"pht", TZ, POS(32)}, /* Phillipine Time */
{"pkt", TZ, POS(20)}, /* Pakistan Time */
{"pm", AMPM, PM},
{"pmdt", DTZ, NEG(8)}, /* Pierre & Miquelon Daylight Time */
#if 0
-pmst
+ pmst
#endif
{"pont", TZ, POS(44)}, /* Ponape Time (Micronesia) */
{"pst", TZ, NEG(32)}, /* Pacific Standard Time */
@@ -387,14 +389,14 @@ pmst
{"s", UNITS, DTK_SECOND}, /* "seconds" for ISO input */
{"sadt", DTZ, POS(42)}, /* S. Australian Dayl. Time */
#if 0
-samst
-samt
+ samst
+ samt
#endif
{"sast", TZ, POS(38)}, /* South Australian Std Time */
{"sat", DOW, 6},
{"saturday", DOW, 6},
#if 0
-sbt
+ sbt
#endif
{"sct", DTZ, POS(16)}, /* Mahe Island Time */
{"sep", MONTH, 9},
@@ -402,14 +404,14 @@ sbt
{"september", MONTH, 9},
{"set", TZ, NEG(4)}, /* Seychelles Time ?? */
#if 0
-sgt
+ sgt
#endif
{"sst", DTZ, POS(8)}, /* Swedish Summer Time */
{"sun", DOW, 0},
{"sunday", DOW, 0},
{"swt", TZ, POS(4)}, /* Swedish Winter Time */
#if 0
-syot
+ syot
#endif
{"t", ISOTIME, DTK_TIME}, /* Filler for ISO time fields */
{"that", TZ, NEG(40)}, /* Tahiti Time */
@@ -424,11 +426,11 @@ syot
{TODAY, RESERV, DTK_TODAY}, /* midnight */
{TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */
#if 0
-tost
+ tost
#endif
{"tot", TZ, POS(52)}, /* Tonga Time */
#if 0
-tpt
+ tpt
#endif
{"truk", TZ, POS(40)}, /* Truk Time */
{"tue", DOW, 2},
@@ -436,7 +438,7 @@ tpt
{"tuesday", DOW, 2},
{"tvt", TZ, POS(48)}, /* Tuvalu Time */
#if 0
-uct
+ uct
#endif
{"ulast", DTZ, POS(36)}, /* Ulan Bator Summer Time */
{"ulat", TZ, POS(32)}, /* Ulan Bator Time */
@@ -451,13 +453,13 @@ uct
{"vlast", DTZ, POS(44)}, /* Vladivostok Summer Time */
{"vlat", TZ, POS(40)}, /* Vladivostok Time */
#if 0
-vust
+ vust
#endif
{"vut", TZ, POS(44)}, /* Vanuata Time */
{"wadt", DTZ, POS(32)}, /* West Australian DST */
{"wakt", TZ, POS(48)}, /* Wake Time */
#if 0
-warst
+ warst
#endif
{"wast", TZ, POS(28)}, /* West Australian Std Time */
{"wat", TZ, NEG(4)}, /* West Africa Time */
@@ -515,22 +517,22 @@ static datetkn deltatktbl[] = {
{"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 */
+ {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 */
- {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
+ {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 */
- {"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
- {"min", 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 */
{DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */
@@ -545,19 +547,19 @@ static datetkn deltatktbl[] = {
{"mseconds", UNITS, DTK_MILLISEC},
{"msecs", UNITS, DTK_MILLISEC},
{"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
- {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
- {"reltime", IGNORE_DTF, 0}, /* pre-v6.1 "Undefined Reltime" */
+ {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
+ {"reltime", IGNORE_DTF, 0}, /* pre-v6.1 "Undefined Reltime" */
{"s", UNITS, DTK_SECOND},
{"sec", UNITS, DTK_SECOND},
{DSECOND, UNITS, DTK_SECOND},
{"seconds", UNITS, DTK_SECOND},
{"secs", UNITS, DTK_SECOND},
- {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
+ {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 */
+ {"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 */
@@ -679,16 +681,16 @@ TrimTrailingZeros(char *str)
/* ParseDateTime()
* Break string into tokens based on a date/time context.
* Several field types are assigned:
- * DTK_NUMBER - digits and (possibly) a decimal point
- * DTK_DATE - digits and two delimiters, or digits and text
- * DTK_TIME - digits, colon delimiters, and possibly a decimal point
- * DTK_STRING - text (no digits)
- * DTK_SPECIAL - leading "+" or "-" followed by text
- * DTK_TZ - leading "+" or "-" followed by digits
+ * DTK_NUMBER - digits and (possibly) a decimal point
+ * DTK_DATE - digits and two delimiters, or digits and text
+ * DTK_TIME - digits, colon delimiters, and possibly a decimal point
+ * DTK_STRING - text (no digits)
+ * DTK_SPECIAL - leading "+" or "-" followed by text
+ * DTK_TZ - leading "+" or "-" followed by digits
* Note that some field types can hold unexpected items:
- * DTK_NUMBER can hold date fields (yy.ddd)
- * DTK_STRING can hold months (January) and time zones (PST)
- * DTK_DATE can hold Posix time zones (GMT-8)
+ * DTK_NUMBER can hold date fields (yy.ddd)
+ * DTK_STRING can hold months (January) and time zones (PST)
+ * DTK_DATE can hold Posix time zones (GMT-8)
*/
int
ParseDateTime(char *timestr, char *lowstr,
@@ -723,17 +725,20 @@ ParseDateTime(char *timestr, char *lowstr,
else if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
{
/* save delimiting character to use later */
- char *dp = cp;
+ char *dp = cp;
*lp++ = *cp++;
/* second field is all digits? then no embedded text month */
if (isdigit((unsigned char) *cp))
{
- ftype[nf] = ((*dp == '.')? DTK_NUMBER: DTK_DATE);
+ ftype[nf] = ((*dp == '.') ? DTK_NUMBER : DTK_DATE);
while (isdigit((unsigned char) *cp))
*lp++ = *cp++;
- /* insist that the delimiters match to get a three-field date. */
+ /*
+ * insist that the delimiters match to get a
+ * three-field date.
+ */
if (*cp == *dp)
{
ftype[nf] = DTK_DATE;
@@ -749,13 +754,13 @@ ParseDateTime(char *timestr, char *lowstr,
*lp++ = tolower((unsigned char) *cp++);
}
}
- /* otherwise, number only and will determine
- * year, month, day, or concatenated fields later...
+
+ /*
+ * otherwise, number only and will determine year, month, day,
+ * or concatenated fields later...
*/
else
- {
ftype[nf] = DTK_NUMBER;
- }
}
/* Leading decimal point? Then fractional seconds... */
else if (*cp == '.')
@@ -766,6 +771,7 @@ ParseDateTime(char *timestr, char *lowstr,
ftype[nf] = DTK_NUMBER;
}
+
/*
* text? then date string, month, day of week, special, or
* timezone
@@ -783,7 +789,7 @@ ParseDateTime(char *timestr, char *lowstr,
*/
if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
{
- char *dp = cp;
+ char *dp = cp;
ftype[nf] = DTK_DATE;
*lp++ = *cp++;
@@ -823,9 +829,7 @@ ParseDateTime(char *timestr, char *lowstr,
}
/* otherwise something wrong... */
else
- {
return -1;
- }
}
/* ignore punctuation but use as delimiter */
else if (ispunct((unsigned char) *cp))
@@ -836,9 +840,7 @@ ParseDateTime(char *timestr, char *lowstr,
}
/* otherwise, something is not right... */
else
- {
return -1;
- }
/* force in a delimiter after each field */
*lp++ = '\0';
@@ -880,7 +882,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 val;
int mer = HR24;
@@ -948,7 +951,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
if (isdigit((unsigned char) *field[i]) || ptype != 0)
{
- char *cp;
+ char *cp;
if (ptype != 0)
{
@@ -958,8 +961,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
ptype = 0;
}
- /* Starts with a digit but we already have a time field?
- * Then we are in trouble with a date and time already...
+ /*
+ * Starts with a digit but we already have a time
+ * field? Then we are in trouble with a date and
+ * time already...
*/
if ((fmask & DTK_TIME_M) == DTK_TIME_M)
return -1;
@@ -972,12 +977,18 @@ DecodeDateTime(char **field, int *ftype, int nf,
return -1;
*cp = '\0';
- /* Then read the rest of the field as a concatenated time */
+ /*
+ * Then read the rest of the field as a
+ * concatenated time
+ */
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask,
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
- /* modify tmask after returning from DecodeNumberField() */
+ /*
+ * modify tmask after returning from
+ * DecodeNumberField()
+ */
tmask |= DTK_M(TZ);
}
else
@@ -990,9 +1001,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
}
}
else if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
- {
return -1;
- }
break;
case DTK_TIME:
@@ -1009,7 +1018,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_TZ:
{
- int tz;
+ int tz;
if (tzp == NULL)
return -1;
@@ -1038,6 +1047,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
break;
case DTK_NUMBER:
+
/*
* Was this an "ISO date" with embedded field labels? An
* example is "y2001m02d04" - thomas 2001-02-04
@@ -1048,7 +1058,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
int val;
val = strtol(field[i], &cp, 10);
- /* only a few kinds are allowed to have an embedded decimal */
+
+ /*
+ * only a few kinds are allowed to have an embedded
+ * decimal
+ */
if (*cp == '.')
switch (ptype)
{
@@ -1071,7 +1085,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
break;
case DTK_MONTH:
- /* already have a month and hour? then assume minutes */
+
+ /*
+ * already have a month and hour? then assume
+ * minutes
+ */
if (((fmask & DTK_M(MONTH)) != 0)
&& ((fmask & DTK_M(HOUR)) != 0))
{
@@ -1105,7 +1123,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
tmask = DTK_M(SECOND);
if (*cp == '.')
{
- double frac;
+ double frac;
+
frac = strtod(cp, &cp);
if (*cp != '\0')
return -1;
@@ -1132,7 +1151,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
/* fractional Julian Day? */
if (*cp == '.')
{
- double time;
+ double time;
time = strtod(cp, &cp);
if (*cp != '\0')
@@ -1140,9 +1159,9 @@ DecodeDateTime(char **field, int *ftype, int nf,
tmask |= DTK_TIME_M;
#ifdef HAVE_INT64_TIMESTAMP
- dt2time((time*86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
+ dt2time((time * 86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
#else
- dt2time((time*86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
+ dt2time((time * 86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
#endif
}
break;
@@ -1150,7 +1169,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_TIME:
/* previous field was "t" for ISO time */
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
if (tmask != DTK_TIME_M)
@@ -1167,8 +1186,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
}
else
{
- char *cp;
- int flen;
+ char *cp;
+ int flen;
flen = strlen(field[i]);
cp = strchr(field[i], '.');
@@ -1182,26 +1201,25 @@ DecodeDateTime(char **field, int *ftype, int nf,
/* embedded decimal and several digits before? */
else if ((cp != NULL) && ((flen - strlen(cp)) > 2))
{
- /* Interpret as a concatenated date or time
- * Set the type field to allow decoding other fields later.
- * Example: 20011223 or 040506
+ /*
+ * Interpret as a concatenated date or time Set
+ * the type field to allow decoding other fields
+ * later. Example: 20011223 or 040506
*/
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
}
else if (flen > 4)
{
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits)) < 0)
- return -1;
+ &tmask, tm, fsec, &is2digits)) < 0)
+ return -1;
}
/* otherwise it is a single date/time field... */
else if (DecodeNumber(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits) != 0)
- {
+ &tmask, tm, fsec, &is2digits) != 0)
return -1;
- }
}
break;
@@ -1350,9 +1368,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
break;
case ISOTIME:
- /* This is a filler field "t"
- * indicating that the next field is time.
- * Try to verify that this is sensible.
+
+ /*
+ * This is a filler field "t" indicating that the
+ * next field is time. Try to verify that this is
+ * sensible.
*/
tmask = 0;
@@ -1362,9 +1382,9 @@ DecodeDateTime(char **field, int *ftype, int nf,
/***
* We will need one of the following fields:
- * DTK_NUMBER should be hhmmss.fff
- * DTK_TIME should be hh:mm:ss.fff
- * DTK_DATE should be hhmmss-zz
+ * DTK_NUMBER should be hhmmss.fff
+ * DTK_TIME should be hh:mm:ss.fff
+ * DTK_DATE should be hhmmss-zz
***/
if ((i >= (nf - 1))
|| ((ftype[i + 1] != DTK_NUMBER)
@@ -1522,34 +1542,38 @@ DetermineLocalTimeZone(struct tm * tm)
date2j(1970, 1, 1));
mysec = tm->tm_sec + (tm->tm_min + (day * 24 + tm->tm_hour) * 60) * 60;
mytime = (time_t) mysec;
+
/*
- * Use localtime to convert that time_t to broken-down time, and
- * reassemble to get a representation of local time.
+ * Use localtime to convert that time_t to broken-down time,
+ * and reassemble to get a representation of local time.
*/
tmp = localtime(&mytime);
day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) -
date2j(1970, 1, 1));
locsec = tmp->tm_sec + (tmp->tm_min + (day * 24 + tmp->tm_hour) * 60) * 60;
+
/*
- * The local time offset corresponding to that GMT time is
- * now computable as mysec - locsec.
+ * The local time offset corresponding to that GMT time is now
+ * computable as mysec - locsec.
*/
delta1 = mysec - locsec;
+
/*
- * However, if that GMT time and the local time we are actually
- * interested in are on opposite sides of a daylight-savings-time
- * transition, then this is not the time offset we want. So,
- * adjust the time_t to be what we think the GMT time corresponding
- * to our target local time is, and repeat the localtime() call
- * and delta calculation. We may have to do it twice before we
- * have a trustworthy delta.
+ * However, if that GMT time and the local time we are
+ * actually interested in are on opposite sides of a
+ * daylight-savings-time transition, then this is not the time
+ * offset we want. So, adjust the time_t to be what we think
+ * the GMT time corresponding to our target local time is, and
+ * repeat the localtime() call and delta calculation. We may
+ * have to do it twice before we have a trustworthy delta.
*
* Note: think not to put a loop here, since if we've been given
- * an "impossible" local time (in the gap during a spring-forward
- * transition) we'd never get out of the loop. Twice is enough
- * to give the behavior we want, which is that "impossible" times
- * are taken as standard time, while at a fall-back boundary
- * ambiguous times are also taken as standard.
+ * an "impossible" local time (in the gap during a
+ * spring-forward transition) we'd never get out of the loop.
+ * Twice is enough to give the behavior we want, which is that
+ * "impossible" times are taken as standard time, while at a
+ * fall-back boundary ambiguous times are also taken as
+ * standard.
*/
mysec += delta1;
mytime = (time_t) mysec;
@@ -1604,7 +1628,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
int fmask = 0,
tmask,
type;
- int ptype = 0; /* "prefix type" for ISO h04mm05s06 format */
+ int ptype = 0; /* "prefix type" for ISO h04mm05s06 format */
int i;
int val;
int is2digits = FALSE;
@@ -1626,16 +1650,17 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
switch (ftype[i])
{
case DTK_DATE:
- /* Time zone not allowed?
- * Then should not accept dates or time zones
- * no matter what else!
+
+ /*
+ * Time zone not allowed? Then should not accept dates or
+ * time zones no matter what else!
*/
if (tzp == NULL)
return -1;
/* Under limited circumstances, we will accept a date... */
if ((i == 0) && (nf >= 2)
- && ((ftype[nf-1] == DTK_DATE)
+ && ((ftype[nf - 1] == DTK_DATE)
|| (ftype[1] == DTK_TIME)))
{
if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
@@ -1646,15 +1671,20 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
{
if (isdigit((unsigned char) *field[i]))
{
- char *cp;
+ char *cp;
- /* Starts with a digit but we already have a time field?
- * Then we are in trouble with time already...
+ /*
+ * Starts with a digit but we already have a time
+ * field? Then we are in trouble with time
+ * already...
*/
if ((fmask & DTK_TIME_M) == DTK_TIME_M)
return -1;
- /* Should not get here and fail. Sanity check only... */
+ /*
+ * Should not get here and fail. Sanity check
+ * only...
+ */
if ((cp = strchr(field[i], '-')) == NULL)
return -1;
@@ -1663,9 +1693,12 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
return -1;
*cp = '\0';
- /* Then read the rest of the field as a concatenated time */
+ /*
+ * Then read the rest of the field as a
+ * concatenated time
+ */
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
tmask |= DTK_M(TZ);
@@ -1716,6 +1749,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
break;
case DTK_NUMBER:
+
/*
* Was this an "ISO time" with embedded field labels? An
* example is "h04m05s06" - thomas 2001-02-04
@@ -1739,7 +1773,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
}
val = strtol(field[i], &cp, 10);
- /* only a few kinds are allowed to have an embedded decimal */
+
+ /*
+ * only a few kinds are allowed to have an embedded
+ * decimal
+ */
if (*cp == '.')
switch (ptype)
{
@@ -1762,7 +1800,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
break;
case DTK_MONTH:
- /* already have a month and hour? then assume minutes */
+
+ /*
+ * already have a month and hour? then assume
+ * minutes
+ */
if (((fmask & DTK_M(MONTH)) != 0)
&& ((fmask & DTK_M(HOUR)) != 0))
{
@@ -1816,7 +1858,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
if (*cp == '.')
{
- double time;
+ double time;
time = strtod(cp, &cp);
if (*cp != '\0')
@@ -1824,9 +1866,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tmask |= DTK_TIME_M;
#ifdef HAVE_INT64_TIMESTAMP
- dt2time((time*86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
+ dt2time((time * 86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
#else
- dt2time((time*86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
+ dt2time((time * 86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
#endif
}
break;
@@ -1834,7 +1876,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
case DTK_TIME:
/* previous field was "t" for ISO time */
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
if (tmask != DTK_TIME_M)
@@ -1851,8 +1893,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
}
else
{
- char *cp;
- int flen;
+ char *cp;
+ int flen;
flen = strlen(field[i]);
cp = strchr(field[i], '.');
@@ -1860,8 +1902,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
/* Embedded decimal? */
if (cp != NULL)
{
- /* Under limited circumstances, we will accept a date... */
- if ((i == 0) && ((nf >= 2) && (ftype[nf-1] == DTK_DATE)))
+ /*
+ * Under limited circumstances, we will accept a
+ * date...
+ */
+ if ((i == 0) && ((nf >= 2) && (ftype[nf - 1] == DTK_DATE)))
{
if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
return -1;
@@ -1869,31 +1914,28 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
/* embedded decimal and several digits before? */
else if ((flen - strlen(cp)) > 2)
{
- /* Interpret as a concatenated date or time
- * Set the type field to allow decoding other fields later.
- * Example: 20011223 or 040506
+ /*
+ * Interpret as a concatenated date or time
+ * Set the type field to allow decoding other
+ * fields later. Example: 20011223 or 040506
*/
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
}
else
- {
return -1;
- }
}
else if (flen > 4)
{
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits)) < 0)
- return -1;
+ &tmask, tm, fsec, &is2digits)) < 0)
+ return -1;
}
/* otherwise it is a single date/time field... */
else if (DecodeNumber(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits) != 0)
- {
+ &tmask, tm, fsec, &is2digits) != 0)
return -1;
- }
}
break;
@@ -1987,9 +2029,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
/***
* We will need one of the following fields:
- * DTK_NUMBER should be hhmmss.fff
- * DTK_TIME should be hh:mm:ss.fff
- * DTK_DATE should be hhmmss-zz
+ * DTK_NUMBER should be hhmmss.fff
+ * DTK_TIME should be hh:mm:ss.fff
+ * DTK_DATE should be hhmmss-zz
***/
if ((i >= (nf - 1))
|| ((ftype[i + 1] != DTK_NUMBER)
@@ -2051,9 +2093,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
return -1;
if ((fmask & DTK_DATE_M) == 0)
- {
GetCurrentDateTime(tmp);
- }
else
{
tmp->tm_year = tm->tm_year;
@@ -2221,9 +2261,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
*fsec = 0;
}
else if (*cp != ':')
- {
return -1;
- }
else
{
str = cp + 1;
@@ -2233,15 +2271,16 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
else if (*cp == '.')
{
#ifdef HAVE_INT64_TIMESTAMP
- char fstr[MAXDATELEN + 1];
+ char fstr[MAXDATELEN + 1];
- /* OK, we have at most six digits to work with.
- * Let's construct a string and then do the conversion
- * to an integer.
+ /*
+ * OK, we have at most six digits to work with. Let's
+ * construct a string and then do the conversion to an
+ * integer.
*/
- strncpy(fstr, (cp+1), 7);
- strcpy((fstr+strlen(fstr)), "000000");
- *(fstr+6) = '\0';
+ strncpy(fstr, (cp + 1), 7);
+ strcpy((fstr + strlen(fstr)), "000000");
+ *(fstr + 6) = '\0';
*fsec = strtol(fstr, &cp, 10);
#else
str = cp;
@@ -2291,10 +2330,9 @@ DecodeNumber(int flen, char *str, int fmask,
if (*cp == '.')
{
- /* More than two digits?
- * Then could be a date or a run-together time:
- * 2001.360
- * 20011225 040506.789
+ /*
+ * More than two digits? Then could be a date or a run-together
+ * time: 2001.360 20011225 040506.789
*/
if ((cp - str) > 2)
return DecodeNumberField(flen, str, (fmask | DTK_DATE_M),
@@ -2305,9 +2343,7 @@ DecodeNumber(int flen, char *str, int fmask,
return -1;
}
else if (*cp != '\0')
- {
return -1;
- }
/* Special case day of year? */
if ((flen == 3) && (fmask & DTK_M(YEAR))
@@ -2397,26 +2433,27 @@ DecodeNumber(int flen, char *str, int fmask,
*/
static int
DecodeNumberField(int len, char *str, int fmask,
- int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
+ int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
{
char *cp;
- /* Have a decimal point?
- * Then this is a date or something with a seconds field...
+ /*
+ * Have a decimal point? Then this is a date or something with a
+ * seconds field...
*/
if ((cp = strchr(str, '.')) != NULL)
{
#ifdef HAVE_INT64_TIMESTAMP
- char fstr[MAXDATELEN + 1];
+ char fstr[MAXDATELEN + 1];
- /* OK, we have at most six digits to care about.
- * Let's construct a string and then do the conversion
- * to an integer.
- */
- strcpy(fstr, (cp+1));
- strcpy((fstr+strlen(fstr)), "000000");
- *(fstr+6) = '\0';
- *fsec = strtol(fstr, NULL, 10);
+ /*
+ * OK, we have at most six digits to care about. Let's construct a
+ * string and then do the conversion to an integer.
+ */
+ strcpy(fstr, (cp + 1));
+ strcpy((fstr + strlen(fstr)), "000000");
+ *(fstr + 6) = '\0';
+ *fsec = strtol(fstr, NULL, 10);
#else
*fsec = strtod(cp, NULL);
#endif
@@ -2515,9 +2552,7 @@ DecodeTimezone(char *str, int *tzp)
/* explicit delimiter? */
if (*cp == ':')
- {
min = strtol((cp + 1), &cp, 10);
- }
/* otherwise, might have run things together... */
else if ((*cp == '\0') && ((len = strlen(str)) > 3))
{
@@ -2531,9 +2566,7 @@ DecodeTimezone(char *str, int *tzp)
return -1;
}
else
- {
min = 0;
- }
tz = (hr * 60 + min) * 60;
if (*str == '-')
@@ -2794,7 +2827,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
tm->tm_min += val;
if (fval != 0)
{
- int sec;
+ int sec;
+
fval *= 60;
sec = fval;
tm->tm_sec += sec;
@@ -2811,7 +2845,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
tm->tm_hour += val;
if (fval != 0)
{
- int sec;
+ int sec;
+
fval *= 3600;
sec = fval;
tm->tm_sec += sec;
@@ -2828,7 +2863,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
tm->tm_mday += val;
if (fval != 0)
{
- int sec;
+ int sec;
+
fval *= 86400;
sec = fval;
tm->tm_sec += sec;
@@ -2845,8 +2881,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
tm->tm_mday += val * 7;
if (fval != 0)
{
- int sec;
- fval *= (7*86400);
+ int sec;
+
+ fval *= (7 * 86400);
sec = fval;
tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP
@@ -2862,8 +2899,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
tm->tm_mon += val;
if (fval != 0)
{
- int sec;
- fval *= (30*86400);
+ int sec;
+
+ fval *= (30 * 86400);
sec = fval;
tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP
@@ -2947,7 +2985,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
if (*fsec != 0)
{
- int sec;
+ int sec;
#ifdef HAVE_INT64_TIMESTAMP
sec = (*fsec / INT64CONST(1000000));
@@ -3175,13 +3213,14 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
int day,
hour,
min;
+
#ifndef HAVE_INT64_TIMESTAMP
fsec_t sec;
#endif
- /* Why are we checking only the month field? Change this to an assert...
- * if ((tm->tm_mon < 1) || (tm->tm_mon > 12))
- * return -1;
+ /*
+ * Why are we checking only the month field? Change this to an
+ * assert... if ((tm->tm_mon < 1) || (tm->tm_mon > 12)) return -1;
*/
Assert((tm->tm_mon >= 1) && (tm->tm_mon <= 12));
@@ -3195,16 +3234,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
/* Compatible with ISO-8601 date formats */
sprintf(str, "%04d-%02d-%02d %02d:%02d",
- ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)),
+ ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)),
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
*/
#ifdef HAVE_INT64_TIMESTAMP
if (fsec != 0)
@@ -3219,22 +3257,16 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02d", tm->tm_sec);
- }
if (tm->tm_year <= 0)
- {
sprintf((str + strlen(str)), " BC");
- }
/*
- * 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))
{
@@ -3253,16 +3285,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
sprintf(str, "%02d/%02d", tm->tm_mon, tm->tm_mday);
sprintf((str + 5), "/%04d %02d:%02d",
- ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)),
+ ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)),
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
*/
#ifdef HAVE_INT64_TIMESTAMP
if (fsec != 0)
@@ -3277,14 +3308,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02d", tm->tm_sec);
- }
if (tm->tm_year <= 0)
- {
sprintf((str + strlen(str)), " BC");
- }
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
@@ -3305,16 +3332,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon);
sprintf((str + 5), ".%04d %02d:%02d",
- ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)),
+ ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)),
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
*/
#ifdef HAVE_INT64_TIMESTAMP
if (fsec != 0)
@@ -3329,14 +3355,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02d", tm->tm_sec);
- }
if (tm->tm_year <= 0)
- {
sprintf((str + strlen(str)), " BC");
- }
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
@@ -3369,12 +3391,11 @@ EncodeDateTime(struct tm * tm, fsec_t 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
*/
#ifdef HAVE_INT64_TIMESTAMP
if (fsec != 0)
@@ -3389,16 +3410,12 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
TrimTrailingZeros(str);
}
else
- {
sprintf((str + strlen(str)), ":%02d", tm->tm_sec);
- }
sprintf((str + strlen(str)), " %04d",
- ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)));
+ ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)));
if (tm->tm_year <= 0)
- {
sprintf((str + strlen(str)), " BC");
- }
if ((tzp != NULL) && (tm->tm_isdst >= 0))
{
@@ -3407,11 +3424,11 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
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);
@@ -3497,7 +3514,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
#ifdef HAVE_INT64_TIMESTAMP
sprintf(cp, ":%02d", abs(tm->tm_sec));
cp += strlen(cp);
- sprintf(cp, ".%06d", ((fsec >= 0)? fsec: -(fsec)));
+ sprintf(cp, ".%06d", ((fsec >= 0) ? fsec : -(fsec)));
#else
fsec += tm->tm_sec;
sprintf(cp, ":%013.10f", fabs(fsec));
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index 0a751ff1dff..9519ef2b674 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.24 2002/08/24 15:00:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.25 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -81,7 +81,7 @@ datumGetSize(Datum value, bool typByVal, int typLen)
else if (typLen == -2)
{
/* It is a cstring datatype */
- char *s = (char *) DatumGetPointer(value);
+ char *s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s))
elog(ERROR, "datumGetSize: Invalid Datum Pointer");
@@ -175,9 +175,9 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen)
/*
* just compare the two datums. NOTE: just comparing "len" bytes
* will not do the work, because we do not know how these bytes
- * are aligned inside the "Datum". We assume instead that any
- * given datatype is consistent about how it fills extraneous
- * bits in the Datum.
+ * are aligned inside the "Datum". We assume instead that any
+ * given datatype is consistent about how it fills extraneous bits
+ * in the Datum.
*/
res = (value1 == value2);
}
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 5edea787afa..7b1798d75ca 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.80 2002/08/26 17:53:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.81 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1515,7 +1515,7 @@ float8_accum(PG_FUNCTION_ARGS)
result = construct_array(transdatums, 3,
FLOAT8OID,
- sizeof(float8), false /*float8 byval*/, 'd');
+ sizeof(float8), false /* float8 byval */ , 'd');
PG_RETURN_ARRAYTYPE_P(result);
}
@@ -1551,7 +1551,7 @@ float4_accum(PG_FUNCTION_ARGS)
result = construct_array(transdatums, 3,
FLOAT8OID,
- sizeof(float8), false /*float8 byval*/, 'd');
+ sizeof(float8), false /* float8 byval */ , 'd');
PG_RETURN_ARRAYTYPE_P(result);
}
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 02e0dc8f27d..c852ed26f3c 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.33 2002/08/29 07:22:26 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.34 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,8 +31,9 @@
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
static char *format_type_internal(Oid type_oid, int32 typemod,
- bool typemod_given, bool allow_invalid);
-static char *psnprintf(size_t len, const char *fmt, ...)
+ bool typemod_given, bool allow_invalid);
+static char *
+psnprintf(size_t len, const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 2, 3)));
@@ -47,14 +48,14 @@ __attribute__((format(printf, 2, 3)));
* double quoted if it contains funny characters or matches a keyword.
*
* If typemod is NULL then we are formatting a type name in a context where
- * no typemod is available, eg a function argument or result type. This
+ * no typemod is available, eg a function argument or result type. This
* yields a slightly different result from specifying typemod = -1 in some
* cases. Given typemod = -1 we feel compelled to produce an output that
* the parser will interpret as having typemod -1, so that pg_dump will
- * produce CREATE TABLE commands that recreate the original state. But
+ * produce CREATE TABLE commands that recreate the original state. But
* given NULL typemod, we assume that the parser's interpretation of
* typemod doesn't matter, and so we are willing to output a slightly
- * "prettier" representation of the same type. For example, type = bpchar
+ * "prettier" representation of the same type. For example, type = bpchar
* and typemod = NULL gets you "character", whereas typemod = -1 gets you
* "bpchar" --- the former will be interpreted as character(1) by the
* parser, which does not yield typemod -1.
@@ -77,9 +78,7 @@ format_type(PG_FUNCTION_ARGS)
type_oid = PG_GETARG_OID(0);
if (PG_ARGISNULL(1))
- {
result = format_type_internal(type_oid, -1, false, true);
- }
else
{
typemod = PG_GETARG_INT32(1);
@@ -141,7 +140,7 @@ format_type_internal(Oid type_oid, int32 typemod,
/*
* Check if it's an array (and not a domain --- we don't want to show
- * the substructure of a domain type). Fixed-length array types such
+ * the substructure of a domain type). Fixed-length array types such
* as "name" shouldn't get deconstructed either.
*/
array_base_type = typeform->typelem;
@@ -171,15 +170,15 @@ format_type_internal(Oid type_oid, int32 typemod,
is_array = false;
/*
- * See if we want to special-case the output for certain built-in types.
- * Note that these special cases should all correspond to special
- * productions in gram.y, to ensure that the type name will be taken as
- * a system type, not a user type of the same name.
+ * See if we want to special-case the output for certain built-in
+ * types. Note that these special cases should all correspond to
+ * special productions in gram.y, to ensure that the type name will be
+ * taken as a system type, not a user type of the same name.
*
- * If we do not provide a special-case output here, the type name will
- * be handled the same way as a user type name --- in particular, it
- * will be double-quoted if it matches any lexer keyword. This behavior
- * is essential for some cases, such as types "bit" and "char".
+ * If we do not provide a special-case output here, the type name will be
+ * handled the same way as a user type name --- in particular, it will
+ * be double-quoted if it matches any lexer keyword. This behavior is
+ * essential for some cases, such as types "bit" and "char".
*/
buf = NULL; /* flag for no special case */
@@ -277,36 +276,36 @@ format_type_internal(Oid type_oid, int32 typemod,
case INTERVAL_MASK(SECOND):
fieldstr = " second";
break;
- case INTERVAL_MASK(YEAR)
- | INTERVAL_MASK(MONTH):
+ case INTERVAL_MASK(YEAR)
+ | INTERVAL_MASK(MONTH):
fieldstr = " year to month";
break;
- case INTERVAL_MASK(DAY)
- | INTERVAL_MASK(HOUR):
+ case INTERVAL_MASK(DAY)
+ | INTERVAL_MASK(HOUR):
fieldstr = " day to hour";
break;
- case INTERVAL_MASK(DAY)
- | INTERVAL_MASK(HOUR)
- | INTERVAL_MASK(MINUTE):
+ case INTERVAL_MASK(DAY)
+ | INTERVAL_MASK(HOUR)
+ | INTERVAL_MASK(MINUTE):
fieldstr = " day to minute";
break;
- case INTERVAL_MASK(DAY)
- | INTERVAL_MASK(HOUR)
- | INTERVAL_MASK(MINUTE)
- | INTERVAL_MASK(SECOND):
+ case INTERVAL_MASK(DAY)
+ | INTERVAL_MASK(HOUR)
+ | INTERVAL_MASK(MINUTE)
+ | INTERVAL_MASK(SECOND):
fieldstr = " day to second";
break;
- case INTERVAL_MASK(HOUR)
- | INTERVAL_MASK(MINUTE):
+ case INTERVAL_MASK(HOUR)
+ | INTERVAL_MASK(MINUTE):
fieldstr = " hour to minute";
break;
- case INTERVAL_MASK(HOUR)
- | INTERVAL_MASK(MINUTE)
- | INTERVAL_MASK(SECOND):
+ case INTERVAL_MASK(HOUR)
+ | INTERVAL_MASK(MINUTE)
+ | INTERVAL_MASK(SECOND):
fieldstr = " hour to second";
break;
- case INTERVAL_MASK(MINUTE)
- | INTERVAL_MASK(SECOND):
+ case INTERVAL_MASK(MINUTE)
+ | INTERVAL_MASK(SECOND):
fieldstr = " minute to second";
break;
case INTERVAL_FULL_RANGE:
@@ -382,9 +381,9 @@ format_type_internal(Oid type_oid, int32 typemod,
{
/*
* Default handling: report the name as it appears in the catalog.
- * Here, we must qualify the name if it is not visible in the search
- * path, and we must double-quote it if it's not a standard identifier
- * or if it matches any keyword.
+ * Here, we must qualify the name if it is not visible in the
+ * search path, and we must double-quote it if it's not a standard
+ * identifier or if it matches any keyword.
*/
char *nspname;
char *typname;
@@ -518,7 +517,7 @@ oidvectortypes(PG_FUNCTION_ARGS)
/* snprintf into a palloc'd string */
static char *
-psnprintf(size_t len, const char *fmt, ...)
+psnprintf(size_t len, const char *fmt,...)
{
va_list ap;
char *buf;
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 7d28d16001f..b92a14e72a8 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.53 2002/04/21 19:48:12 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.54 2002/09/04 20:31:27 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@@ -2438,9 +2438,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
sscanf(inout, "%03d", &tmfc->year);
/*
- * 3-digit year:
- * '100' ... '999' = 1100 ... 1999
- * '000' ... '099' = 2000 ... 2099
+ * 3-digit year: '100' ... '999' = 1100 ... 1999 '000' ...
+ * '099' = 2000 ... 2099
*/
if (tmfc->year >= 100)
tmfc->year += 1000;
@@ -2469,9 +2468,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
sscanf(inout, "%02d", &tmfc->year);
/*
- * 2-digit year:
- * '00' ... '69' = 2000 ... 2069
- * '70' ... '99' = 1970 ... 1999
+ * 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ...
+ * '99' = 1970 ... 1999
*/
if (tmfc->year < 70)
tmfc->year += 2000;
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index ec970bbcbaf..c19cbc42cf6 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.64 2002/08/29 23:05:44 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.65 2002/09/04 20:31:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1236,7 +1236,7 @@ path_in(PG_FUNCTION_ARGS)
depth++;
}
- size = offsetof(PATH, p[0]) + sizeof(path->p[0]) * npts;
+ size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts;
path = (PATH *) palloc(size);
path->size = size;
@@ -2155,8 +2155,8 @@ dist_ps_internal(Point *pt, LSEG *lseg)
#endif
/*
- * Calculate distance to the line segment
- * or to the endpoints of the segment.
+ * Calculate distance to the line segment or to the endpoints of the
+ * segment.
*/
/* intersection is on the line segment? */
@@ -2397,9 +2397,7 @@ interpt_sl(LSEG *lseg, LINE *line)
#endif
}
else
- {
p = NULL;
- }
}
return p;
@@ -3610,7 +3608,7 @@ path_add(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts);
- size = offsetof(PATH, p[0]) + base_size;
+ size = offsetof(PATH, p[0]) +base_size;
/* Check for integer overflow */
if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
@@ -4436,7 +4434,7 @@ circle_poly(PG_FUNCTION_ARGS)
elog(ERROR, "Unable to convert circle to polygon");
base_size = sizeof(poly->p[0]) * npts;
- size = offsetof(POLYGON, p[0]) + base_size;
+ size = offsetof(POLYGON, p[0]) +base_size;
/* Check for integer overflow */
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 33e0b41fe59..267ad821037 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.40 2002/06/20 20:29:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.41 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,14 +70,16 @@ int8in(PG_FUNCTION_ARGS)
{
ptr++;
sign = -1;
+
/*
- * Do an explicit check for INT64_MIN. Ugly though this is, it's
- * cleaner than trying to get the loop below to handle it portably.
+ * Do an explicit check for INT64_MIN. Ugly though this is, it's
+ * cleaner than trying to get the loop below to handle it
+ * portably.
*/
#ifndef INT64_IS_BUSTED
if (strcmp(ptr, "9223372036854775808") == 0)
{
- result = - INT64CONST(0x7fffffffffffffff) - 1;
+ result = -INT64CONST(0x7fffffffffffffff) - 1;
PG_RETURN_INT64(result);
}
#endif
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index a5dda27f640..ba851793a33 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -2,11 +2,11 @@
*
* lockfuncs.c
* Set-returning functions to view the state of locks within the DB.
- *
+ *
* Copyright (c) 2002, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.6 2002/09/02 01:05:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.7 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,19 +33,22 @@ typedef struct
Datum
pg_lock_status(PG_FUNCTION_ARGS)
{
- FuncCallContext *funcctx;
- PG_Lock_Status *mystatus;
+ FuncCallContext *funcctx;
+ PG_Lock_Status *mystatus;
LockData *lockData;
if (SRF_IS_FIRSTCALL())
{
- TupleDesc tupdesc;
- MemoryContext oldcontext;
+ TupleDesc tupdesc;
+ MemoryContext oldcontext;
/* create a function context for cross-call persistence */
funcctx = SRF_FIRSTCALL_INIT();
- /* switch to memory context appropriate for multiple function calls */
+ /*
+ * switch to memory context appropriate for multiple function
+ * calls
+ */
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
@@ -67,8 +70,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
funcctx->slot = TupleDescGetSlot(tupdesc);
/*
- * Collect all the locking information that we will format
- * and send out as a result set.
+ * Collect all the locking information that we will format and
+ * send out as a result set.
*/
mystatus = (PG_Lock_Status *) palloc(sizeof(PG_Lock_Status));
funcctx->user_fctx = (void *) mystatus;
@@ -79,25 +82,25 @@ pg_lock_status(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldcontext);
}
- funcctx = SRF_PERCALL_SETUP();
+ funcctx = SRF_PERCALL_SETUP();
mystatus = (PG_Lock_Status *) funcctx->user_fctx;
lockData = mystatus->lockData;
while (mystatus->currIdx < lockData->nelements)
{
- PROCLOCK *holder;
- LOCK *lock;
- PGPROC *proc;
- bool granted;
- LOCKMODE mode;
- Datum values[6];
- char nulls[6];
- HeapTuple tuple;
- Datum result;
-
- holder = &(lockData->holders[mystatus->currIdx]);
- lock = &(lockData->locks[mystatus->currIdx]);
- proc = &(lockData->procs[mystatus->currIdx]);
+ PROCLOCK *holder;
+ LOCK *lock;
+ PGPROC *proc;
+ bool granted;
+ LOCKMODE mode;
+ Datum values[6];
+ char nulls[6];
+ HeapTuple tuple;
+ Datum result;
+
+ holder = &(lockData->holders[mystatus->currIdx]);
+ lock = &(lockData->locks[mystatus->currIdx]);
+ proc = &(lockData->procs[mystatus->currIdx]);
/*
* Look to see if there are any held lock modes in this PROCLOCK.
@@ -116,8 +119,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
}
/*
- * If no (more) held modes to report, see if PROC is waiting for
- * a lock on this lock.
+ * If no (more) held modes to report, see if PROC is waiting for a
+ * lock on this lock.
*/
if (!granted)
{
@@ -125,6 +128,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
{
/* Yes, so report it with proper mode */
mode = proc->waitLockMode;
+
/*
* We are now done with this PROCLOCK, so advance pointer
* to continue with next one on next call.
@@ -134,8 +138,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
else
{
/*
- * Okay, we've displayed all the locks associated with this
- * PROCLOCK, proceed to the next one.
+ * Okay, we've displayed all the locks associated with
+ * this PROCLOCK, proceed to the next one.
*/
mystatus->currIdx++;
continue;
@@ -166,7 +170,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
values[3] = Int32GetDatum(proc->pid);
values[4] = DirectFunctionCall1(textin,
- CStringGetDatum(GetLockmodeName(mode)));
+ CStringGetDatum(GetLockmodeName(mode)));
values[5] = BoolGetDatum(granted);
tuple = heap_formtuple(funcctx->slot->ttc_tupleDescriptor,
diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c
index c12163921db..e307542bd86 100644
--- a/src/backend/utils/adt/mac.c
+++ b/src/backend/utils/adt/mac.c
@@ -1,7 +1,7 @@
/*
* PostgreSQL type definitions for MAC addresses.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.25 2002/08/28 20:46:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.26 2002/09/04 20:31:28 momjian Exp $
*/
#include "postgres.h"
@@ -81,7 +81,7 @@ macaddr_out(PG_FUNCTION_ARGS)
result = (char *) palloc(32);
snprintf(result, 32, "%02x:%02x:%02x:%02x:%02x:%02x",
- addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
+ addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
PG_RETURN_CSTRING(result);
}
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 363b6ca3eca..6b105fdef4d 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.26 2002/09/02 02:47:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.27 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -119,7 +119,7 @@ userfntest(PG_FUNCTION_ARGS)
Datum
current_database(PG_FUNCTION_ARGS)
{
- Name db;
+ Name db;
db = (Name) palloc(NAMEDATALEN);
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index d96f5441c42..3b9c3ac272b 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.98 2002/09/02 02:47:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.99 2002/09/04 20:31:28 momjian Exp $
*
* NOTES
*
@@ -980,8 +980,10 @@ interval_reltime(PG_FUNCTION_ARGS)
RelativeTime time;
int year,
month;
+
#ifdef HAVE_INT64_TIMESTAMP
int64 span;
+
#else
double span;
#endif
diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c
index 41eca445f63..63ea829812a 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.40 2002/08/26 17:53:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.41 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,7 @@ namein(PG_FUNCTION_ARGS)
if ((ermsg = pg_verifymbstr(s, len)))
elog(ERROR, "%s", ermsg);
- len = pg_mbcliplen(s, len, NAMEDATALEN-1);
+ len = pg_mbcliplen(s, len, NAMEDATALEN - 1);
result = (NameData *) palloc(NAMEDATALEN);
/* always keep it null-padded */
@@ -240,8 +240,8 @@ session_user(PG_FUNCTION_ARGS)
Datum
current_schema(PG_FUNCTION_ARGS)
{
- List *search_path = fetch_search_path(false);
- char *nspname;
+ List *search_path = fetch_search_path(false);
+ char *nspname;
if (search_path == NIL)
PG_RETURN_NULL();
@@ -252,18 +252,18 @@ current_schema(PG_FUNCTION_ARGS)
Datum
current_schemas(PG_FUNCTION_ARGS)
{
- List *search_path = fetch_search_path(PG_GETARG_BOOL(0));
- int nnames = length(search_path);
- Datum *names;
- int i;
- ArrayType *array;
+ List *search_path = fetch_search_path(PG_GETARG_BOOL(0));
+ int nnames = length(search_path);
+ Datum *names;
+ int i;
+ ArrayType *array;
/* +1 here is just to avoid palloc(0) error */
names = (Datum *) palloc((nnames + 1) * sizeof(Datum));
i = 0;
while (search_path)
{
- char *nspname;
+ char *nspname;
nspname = get_namespace_name((Oid) lfirsti(search_path));
names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname));
@@ -273,9 +273,9 @@ current_schemas(PG_FUNCTION_ARGS)
array = construct_array(names, nnames,
NAMEOID,
- NAMEDATALEN, /* sizeof(Name) */
- false, /* Name is not by-val */
- 'i'); /* alignment of Name */
+ NAMEDATALEN, /* sizeof(Name) */
+ false, /* Name is not by-val */
+ 'i'); /* alignment of Name */
PG_RETURN_POINTER(array);
}
diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c
index 7c6be4533eb..ef29e065138 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.31 2002/08/02 18:15:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.32 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -60,8 +60,8 @@ int4notin(PG_FUNCTION_ARGS)
nnames = length(names);
if (nnames < 2)
elog(ERROR, "int4notin: must provide relationname.attributename");
- attribute = strVal(nth(nnames-1, names));
- names = ltruncate(nnames-1, names);
+ attribute = strVal(nth(nnames - 1, names));
+ names = ltruncate(nnames - 1, names);
relrv = makeRangeVarFromNameList(names);
/* Open the relation and get a relation descriptor */
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index acbf0bff211..228c43c6c46 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.52 2002/09/02 02:47:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.53 2002/09/04 20:31:28 momjian Exp $
*
* ----------
*/
@@ -152,7 +152,7 @@ static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
static void div_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
-static int select_div_scale(NumericVar *var1, NumericVar *var2);
+static int select_div_scale(NumericVar *var1, NumericVar *var2);
static void mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
static void ceil_var(NumericVar *var, NumericVar *result);
static void floor_var(NumericVar *var, NumericVar *result);
@@ -1906,7 +1906,7 @@ numeric_variance(PG_FUNCTION_ARGS)
}
else
{
- mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
+ mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
div_dscale = select_div_scale(&vsumX2, &vNminus1);
div_var(&vsumX2, &vNminus1, &vsumX); /* variance */
vsumX.dscale = div_dscale;
@@ -1985,7 +1985,7 @@ numeric_stddev(PG_FUNCTION_ARGS)
}
else
{
- mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
+ mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
div_dscale = select_div_scale(&vsumX2, &vNminus1);
div_var(&vsumX2, &vNminus1, &vsumX); /* variance */
vsumX.dscale = div_dscale;
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index f14c10b8f52..a88330cec17 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.53 2002/08/27 20:54:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.54 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,8 +63,8 @@ pg_atoi(char *s, int size, int c)
errno = 0;
/*
- * Some versions of strtol treat the empty string as an error, but some
- * seem not to. Make an explicit test to be sure we catch it.
+ * Some versions of strtol treat the empty string as an error, but
+ * some seem not to. Make an explicit test to be sure we catch it.
*/
if (s == (char *) NULL)
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c
index e71604719f7..48453c4ad6b 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.42 2002/08/29 07:22:27 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.43 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -850,8 +850,8 @@ repeat(PG_FUNCTION_ARGS)
/* Check for integer overflow */
if (slen != 0 && count != 0)
{
- int check = count * slen;
- int check2 = check + VARHDRSZ;
+ int check = count * slen;
+ int check2 = check + VARHDRSZ;
if ((check / slen) != count || check2 <= check)
elog(ERROR, "Requested buffer is too large.");
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 33a7a105eda..3b6114542be 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -2,7 +2,7 @@
*
* PostgreSQL locale utilities
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.18 2002/08/09 22:52:04 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.19 2002/09/04 20:31:28 momjian Exp $
*
* Portions Copyright (c) 2002, PostgreSQL Global Development Group
*
@@ -20,7 +20,7 @@
*
* The other categories, LC_MONETARY, LC_NUMERIC, and LC_TIME are also
* settable at run-time. However, we don't actually set those locale
- * categories permanently. This would have bizzare effects like no
+ * categories permanently. This would have bizzare effects like no
* longer accepting standard floating-point literals in some locales.
* Instead, we only set the locales briefly when needed, cache the
* required information obtained from localeconv(), and set them back.
@@ -44,10 +44,10 @@ static bool CurrentLocaleConvValid = false;
/* GUC storage area */
-char *locale_messages;
-char *locale_monetary;
-char *locale_numeric;
-char *locale_time;
+char *locale_messages;
+char *locale_monetary;
+char *locale_numeric;
+char *locale_time;
/* GUC assign hooks */
@@ -60,7 +60,7 @@ char *locale_time;
static const char *
locale_xxx_assign(int category, const char *value, bool doit, bool interactive)
{
- char *save;
+ char *save;
save = setlocale(category, NULL);
if (!save)
@@ -104,7 +104,10 @@ locale_time_assign(const char *value, bool doit, bool interactive)
const char *
locale_messages_assign(const char *value, bool doit, bool interactive)
{
- /* LC_MESSAGES category does not exist everywhere, but accept it anyway */
+ /*
+ * LC_MESSAGES category does not exist everywhere, but accept it
+ * anyway
+ */
#ifdef LC_MESSAGES
if (doit)
{
@@ -113,15 +116,15 @@ locale_messages_assign(const char *value, bool doit, bool interactive)
}
else
{
- char *save;
+ char *save;
save = setlocale(LC_MESSAGES, NULL);
if (!save)
return NULL;
-
+
if (!setlocale(LC_MESSAGES, value))
return NULL;
-
+
setlocale(LC_MESSAGES, save);
}
#endif
@@ -161,7 +164,7 @@ lc_collate_is_c(void)
* itself.)
*/
static void
-free_struct_lconv(struct lconv *s)
+free_struct_lconv(struct lconv * s)
{
if (s == NULL)
return;
diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c
index 49886fea548..c16e59038ee 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.14 2001/11/17 06:09:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.15 2002/09/04 20:31:28 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
@@ -184,7 +184,7 @@
* Local definitions
* ----------
*/
-#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */
+#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */
#define PGLZ_HISTORY_MASK (PGLZ_HISTORY_LISTS - 1)
#define PGLZ_HISTORY_SIZE 4096
#define PGLZ_MAX_MATCH 273
@@ -202,7 +202,7 @@
*/
typedef struct PGLZ_HistEntry
{
- struct PGLZ_HistEntry *next; /* links for my hash key's list */
+ struct PGLZ_HistEntry *next; /* links for my hash key's list */
struct PGLZ_HistEntry *prev;
int hindex; /* my current hash key */
char *pos; /* my input position */
@@ -418,8 +418,8 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
* the best so far. And if we already have a match of 16 or more
* bytes, it's worth the call overhead to use memcmp() to check if
* this match is equal for the same size. After that we must
- * fallback to character by character comparison to know the
- * exact position where the diff occured.
+ * fallback to character by character comparison to know the exact
+ * position where the diff occured.
*/
thislen = 0;
if (len >= 16)
@@ -559,9 +559,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
good_drop = 100;
/*
- * Initialize the history lists to empty. We do not need to zero
- * the hist_entries[] array; its entries are initialized as they
- * are used.
+ * Initialize the history lists to empty. We do not need to zero the
+ * hist_entries[] array; its entries are initialized as they are used.
*/
memset((void *) hist_start, 0, sizeof(hist_start));
diff --git a/src/backend/utils/adt/pseudotypes.c b/src/backend/utils/adt/pseudotypes.c
index 63f585fe32e..b93d738be1d 100644
--- a/src/backend/utils/adt/pseudotypes.c
+++ b/src/backend/utils/adt/pseudotypes.c
@@ -6,7 +6,7 @@
* A pseudo-type isn't really a type and never has any operations, but
* we do need to supply input and output functions to satisfy the links
* in the pseudo-type's entry in pg_type. In most cases the functions
- * just throw an error if invoked. (XXX the error messages here cover
+ * just throw an error if invoked. (XXX the error messages here cover
* the most common case, but might be confusing in some contexts. Can
* we do better?)
*
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.3 2002/08/26 17:53:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.4 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -127,7 +127,7 @@ anyarray_out(PG_FUNCTION_ARGS)
* void_in - input routine for pseudo-type VOID.
*
* We allow this so that PL functions can return VOID without any special
- * hack in the PL handler. Whatever value the PL thinks it's returning
+ * hack in the PL handler. Whatever value the PL thinks it's returning
* will just be ignored.
*/
Datum
diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c
index 69d00f18505..b64d6ede65a 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.41 2002/06/20 20:29:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.42 2002/09/04 20:31:28 momjian Exp $
*
* Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance
@@ -53,7 +53,7 @@ struct cached_re_str
static int rec = 0; /* # of cached re's */
static struct cached_re_str rev[MAX_CACHED_RES]; /* cached re's */
static unsigned long lru; /* system lru tag */
-static int pg_lastrec = 0;
+static int pg_lastrec = 0;
/* attempt to compile `re' as an re, then match it against text */
/* cflags - flag to regcomp indicates case sensitivity */
@@ -70,9 +70,9 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
re = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(text_re)));
- /* Find a previously compiled regular expression.
- * Run the cache as a ring buffer, starting the search
- * from the previous match if any.
+ /*
+ * Find a previously compiled regular expression. Run the cache as a
+ * ring buffer, starting the search from the previous match if any.
*/
i = pg_lastrec;
while (i < rec)
@@ -92,19 +92,16 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
}
i++;
- /* If we were not at the first slot to start,
- * then think about wrapping if necessary.
+ /*
+ * If we were not at the first slot to start, then think about
+ * wrapping if necessary.
*/
if (pg_lastrec != 0)
{
if (i >= rec)
- {
i = 0;
- }
else if (i == pg_lastrec)
- {
break;
- }
}
}
@@ -119,9 +116,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
}
}
else
- {
oldest = rec++;
- }
/* if there was an old re, then de-allocate the space it used */
if (rev[oldest].cre_s != (char *) NULL)
@@ -148,6 +143,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
if (regcomp_result == 0)
{
pg_lastrec = oldest;
+
/*
* use malloc/free for the cre_s field because the storage has to
* persist across transactions
@@ -329,10 +325,11 @@ textregexsubstr(PG_FUNCTION_ARGS)
sterm = (char *) palloc(len + 1);
memcpy(sterm, VARDATA(s), len);
sterm[len] = '\0';
- /* We need the match info back from the pattern match
- * to be able to actually extract the substring.
- * It seems to be adequate to pass in a structure to return
- * only one result.
+
+ /*
+ * We need the match info back from the pattern match to be able to
+ * actually extract the substring. It seems to be adequate to pass in
+ * a structure to return only one result.
*/
match = RE_compile_and_execute(p, sterm, REG_EXTENDED, nmatch, &pmatch);
pfree(sterm);
@@ -342,8 +339,8 @@ textregexsubstr(PG_FUNCTION_ARGS)
{
return (DirectFunctionCall3(text_substr,
PointerGetDatum(s),
- Int32GetDatum(pmatch.rm_so+1),
- Int32GetDatum(pmatch.rm_eo-pmatch.rm_so)));
+ Int32GetDatum(pmatch.rm_so + 1),
+ Int32GetDatum(pmatch.rm_eo - pmatch.rm_so)));
}
PG_RETURN_NULL();
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index c39d176ece8..22c93c431a0 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.74 2002/09/02 01:05:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.75 2002/09/04 20:31:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,8 +38,8 @@
#include "utils/syscache.h"
static void parseNameAndArgTypes(const char *string, const char *caller,
- bool allowNone,
- List **names, int *nargs, Oid *argtypes);
+ bool allowNone,
+ List **names, int *nargs, Oid *argtypes);
/*****************************************************************************
@@ -87,7 +87,7 @@ regprocin(PG_FUNCTION_ARGS)
/*
* In bootstrap mode we assume the given name is not schema-qualified,
- * and just search pg_proc for a unique match. This is needed for
+ * and just search pg_proc for a unique match. This is needed for
* initializing other system catalogs (pg_namespace may not exist yet,
* and certainly there are no schemas other than pg_catalog).
*/
@@ -96,7 +96,7 @@ regprocin(PG_FUNCTION_ARGS)
int matches = 0;
Relation hdesc;
ScanKeyData skey[1];
- SysScanDesc sysscan;
+ SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0x0,
@@ -127,8 +127,8 @@ regprocin(PG_FUNCTION_ARGS)
}
/*
- * Normal case: parse the name into components and see if it
- * matches any pg_proc entries in the current search path.
+ * Normal case: parse the name into components and see if it matches
+ * any pg_proc entries in the current search path.
*/
names = stringToQualifiedNameList(pro_name_or_oid, "regprocin");
clist = FuncnameGetCandidates(names, -1);
@@ -175,17 +175,15 @@ regprocout(PG_FUNCTION_ARGS)
* output anyway.)
*/
if (IsBootstrapProcessingMode())
- {
result = pstrdup(proname);
- }
else
{
char *nspname;
FuncCandidateList clist;
/*
- * Would this proc be found (uniquely!) by regprocin?
- * If not, qualify it.
+ * Would this proc be found (uniquely!) by regprocin? If not,
+ * qualify it.
*/
clist = FuncnameGetCandidates(makeList1(makeString(proname)), -1);
if (clist != NULL && clist->next == NULL &&
@@ -250,10 +248,10 @@ regprocedurein(PG_FUNCTION_ARGS)
}
/*
- * Else it's a name and arguments. Parse the name and arguments,
- * look up potential matches in the current namespace search list,
- * and scan to see which one exactly matches the given argument
- * types. (There will not be more than one match.)
+ * Else it's a name and arguments. Parse the name and arguments, look
+ * up potential matches in the current namespace search list, and scan
+ * to see which one exactly matches the given argument types. (There
+ * will not be more than one match.)
*
* XXX at present, this code will not work in bootstrap mode, hence this
* datatype cannot be used for any system column that needs to receive
@@ -308,8 +306,8 @@ format_procedure(Oid procedure_oid)
initStringInfo(&buf);
/*
- * Would this proc be found (given the right args) by regprocedurein?
- * If not, we need to qualify it.
+ * Would this proc be found (given the right args) by
+ * regprocedurein? If not, we need to qualify it.
*/
if (FunctionIsVisible(procedure_oid))
nspname = NULL;
@@ -320,7 +318,7 @@ format_procedure(Oid procedure_oid)
quote_qualified_identifier(nspname, proname));
for (i = 0; i < nargs; i++)
{
- Oid thisargtype = procform->proargtypes[i];
+ Oid thisargtype = procform->proargtypes[i];
if (i > 0)
appendStringInfoChar(&buf, ',');
@@ -401,7 +399,7 @@ regoperin(PG_FUNCTION_ARGS)
/*
* In bootstrap mode we assume the given name is not schema-qualified,
- * and just search pg_operator for a unique match. This is needed for
+ * and just search pg_operator for a unique match. This is needed for
* initializing other system catalogs (pg_namespace may not exist yet,
* and certainly there are no schemas other than pg_catalog).
*/
@@ -410,7 +408,7 @@ regoperin(PG_FUNCTION_ARGS)
int matches = 0;
Relation hdesc;
ScanKeyData skey[1];
- SysScanDesc sysscan;
+ SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0x0,
@@ -441,8 +439,8 @@ regoperin(PG_FUNCTION_ARGS)
}
/*
- * Normal case: parse the name into components and see if it
- * matches any pg_operator entries in the current search path.
+ * Normal case: parse the name into components and see if it matches
+ * any pg_operator entries in the current search path.
*/
names = stringToQualifiedNameList(opr_name_or_oid, "regoperin");
clist = OpernameGetCandidates(names, '\0');
@@ -489,16 +487,14 @@ regoperout(PG_FUNCTION_ARGS)
* output anyway.)
*/
if (IsBootstrapProcessingMode())
- {
result = pstrdup(oprname);
- }
else
{
FuncCandidateList clist;
/*
- * Would this oper be found (uniquely!) by regoperin?
- * If not, qualify it.
+ * Would this oper be found (uniquely!) by regoperin? If not,
+ * qualify it.
*/
clist = OpernameGetCandidates(makeList1(makeString(oprname)),
'\0');
@@ -511,7 +507,7 @@ regoperout(PG_FUNCTION_ARGS)
nspname = get_namespace_name(operform->oprnamespace);
nspname = quote_identifier(nspname);
- result = (char *) palloc(strlen(nspname)+strlen(oprname)+2);
+ result = (char *) palloc(strlen(nspname) + strlen(oprname) + 2);
sprintf(result, "%s.%s", nspname, oprname);
}
}
@@ -520,7 +516,10 @@ regoperout(PG_FUNCTION_ARGS)
}
else
{
- /* If OID doesn't match any pg_operator entry, return it numerically */
+ /*
+ * If OID doesn't match any pg_operator entry, return it
+ * numerically
+ */
result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", oprid);
}
@@ -570,10 +569,10 @@ regoperatorin(PG_FUNCTION_ARGS)
}
/*
- * Else it's a name and arguments. Parse the name and arguments,
- * look up potential matches in the current namespace search list,
- * and scan to see which one exactly matches the given argument
- * types. (There will not be more than one match.)
+ * Else it's a name and arguments. Parse the name and arguments, look
+ * up potential matches in the current namespace search list, and scan
+ * to see which one exactly matches the given argument types. (There
+ * will not be more than one match.)
*
* XXX at present, this code will not work in bootstrap mode, hence this
* datatype cannot be used for any system column that needs to receive
@@ -637,8 +636,8 @@ format_operator(Oid operator_oid)
initStringInfo(&buf);
/*
- * Would this oper be found (given the right args) by regoperatorin?
- * If not, we need to qualify it.
+ * Would this oper be found (given the right args) by
+ * regoperatorin? If not, we need to qualify it.
*/
if (!OperatorIsVisible(operator_oid))
{
@@ -667,7 +666,10 @@ format_operator(Oid operator_oid)
}
else
{
- /* If OID doesn't match any pg_operator entry, return it numerically */
+ /*
+ * If OID doesn't match any pg_operator entry, return it
+ * numerically
+ */
result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", operator_oid);
}
@@ -715,12 +717,12 @@ regclassin(PG_FUNCTION_ARGS)
/* Numeric OID? */
if (class_name_or_oid[0] >= '0' &&
class_name_or_oid[0] <= '9' &&
- strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))
+ strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))
{
Oid searchOid;
searchOid = DatumGetObjectId(DirectFunctionCall1(oidin,
- CStringGetDatum(class_name_or_oid)));
+ CStringGetDatum(class_name_or_oid)));
result = GetSysCacheOid(RELOID,
ObjectIdGetDatum(searchOid),
0, 0, 0);
@@ -741,7 +743,7 @@ regclassin(PG_FUNCTION_ARGS)
{
Relation hdesc;
ScanKeyData skey[1];
- SysScanDesc sysscan;
+ SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0x0,
@@ -767,8 +769,8 @@ regclassin(PG_FUNCTION_ARGS)
}
/*
- * Normal case: parse the name into components and see if it
- * matches any pg_class entries in the current search path.
+ * Normal case: parse the name into components and see if it matches
+ * any pg_class entries in the current search path.
*/
names = stringToQualifiedNameList(class_name_or_oid, "regclassin");
@@ -808,16 +810,14 @@ regclassout(PG_FUNCTION_ARGS)
* output anyway.)
*/
if (IsBootstrapProcessingMode())
- {
result = pstrdup(classname);
- }
else
{
char *nspname;
/*
- * Would this class be found by regclassin?
- * If not, qualify it.
+ * Would this class be found by regclassin? If not, qualify
+ * it.
*/
if (RelationIsVisible(classid))
nspname = NULL;
@@ -894,7 +894,7 @@ regtypein(PG_FUNCTION_ARGS)
{
Relation hdesc;
ScanKeyData skey[1];
- SysScanDesc sysscan;
+ SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0x0,
@@ -920,8 +920,8 @@ regtypein(PG_FUNCTION_ARGS)
}
/*
- * Normal case: invoke the full parser to deal with special cases
- * such as array syntax.
+ * Normal case: invoke the full parser to deal with special cases such
+ * as array syntax.
*/
parseTypeString(typ_name_or_oid, &result, &typmod);
@@ -964,9 +964,7 @@ regtypeout(PG_FUNCTION_ARGS)
result = pstrdup(typname);
}
else
- {
result = format_type_be(typid);
- }
ReleaseSysCache(typetup);
}
@@ -1003,7 +1001,7 @@ stringToQualifiedNameList(const char *string, const char *caller)
foreach(l, namelist)
{
- char *curname = (char *) lfirst(l);
+ char *curname = (char *) lfirst(l);
result = lappend(result, makeString(pstrdup(curname)));
}
@@ -1020,7 +1018,7 @@ stringToQualifiedNameList(const char *string, const char *caller)
/*
* Given a C string, parse it into a qualified function or operator name
- * followed by a parenthesized list of type names. Reduce the
+ * followed by a parenthesized list of type names. Reduce the
* type names to an array of OIDs (returned into *nargs and *argtypes;
* the argtypes array should be of size FUNC_MAX_ARGS). The function or
* operator name is returned to *names as a List of Strings.
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index f6d56d0d553..d66fe4d95d0 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -17,7 +17,7 @@
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.41 2002/09/02 06:11:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.42 2002/09/04 20:31:28 momjian Exp $
*
* ----------
*/
@@ -131,9 +131,9 @@ static void ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id,
Relation fk_rel, Relation pk_rel,
int argc, char **argv);
static void ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id,
- int32 constr_queryno,
- Relation pk_rel,
- int argc, char **argv);
+ int32 constr_queryno,
+ Relation pk_rel,
+ int argc, char **argv);
static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
RI_QueryKey *key, int pairidx);
static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
@@ -141,8 +141,8 @@ static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
static bool ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup,
HeapTuple newtup, RI_QueryKey *key, int pairidx);
static bool ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue);
-static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row,
- Oid tgoid, int match_type, int tgnargs, char **tgargs);
+static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row,
+ Oid tgoid, int match_type, int tgnargs, char **tgargs);
static void ri_InitHashTables(void);
static void *ri_FetchPreparedPlan(RI_QueryKey *key);
@@ -205,8 +205,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
* Get the relation descriptors of the FK and PK tables and the new
* tuple.
*
- * pk_rel is opened in RowShareLock mode since that's what our
- * eventual SELECT FOR UPDATE will get on it.
+ * pk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR UPDATE will get on it.
*/
fk_rel = trigdata->tg_relation;
pk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
@@ -223,11 +223,13 @@ RI_FKey_check(PG_FUNCTION_ARGS)
/*
* We should not even consider checking the row if it is no longer
- * valid since it was either deleted (doesn't matter) or updated
- * (in which case it'll be checked with its final values).
+ * valid since it was either deleted (doesn't matter) or updated (in
+ * which case it'll be checked with its final values).
*/
- if (new_row) {
- if (!HeapTupleSatisfiesItself(new_row->t_data)) {
+ if (new_row)
+ {
+ if (!HeapTupleSatisfiesItself(new_row->t_data))
+ {
heap_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
}
@@ -263,7 +265,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
*/
quoteRelationName(pkrelname, pk_rel);
snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x FOR UPDATE OF x",
- pkrelname);
+ pkrelname);
/*
* Prepare, save and remember the new plan.
@@ -418,9 +420,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
for (i = 0; i < qkey.nkeypairs; i++)
{
quoteOneName(attname,
- tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
+ tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(fk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_FK_IDX]);
@@ -521,32 +523,36 @@ RI_FKey_check_upd(PG_FUNCTION_ARGS)
/* ----------
* ri_Check_Pk_Match
*
- * Check for matching value of old pk row in current state for
+ * Check for matching value of old pk row in current state for
* noaction triggers. Returns false if no row was found and a fk row
* could potentially be referencing this row, true otherwise.
* ----------
*/
static bool
-ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs) {
- void *qplan;
+ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs)
+{
+ void *qplan;
RI_QueryKey qkey;
- bool isnull;
+ bool isnull;
Datum check_values[RI_MAX_NUMKEYS];
char check_nulls[RI_MAX_NUMKEYS + 1];
- int i;
+ int i;
Oid save_uid;
- bool result;
+ bool result;
+
save_uid = GetUserId();
ri_BuildQueryKeyPkCheck(&qkey, tgoid,
- RI_PLAN_CHECK_LOOKUPPK, pk_rel,
- tgnargs, tgargs);
+ RI_PLAN_CHECK_LOOKUPPK, pk_rel,
+ tgnargs, tgargs);
switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
{
case RI_KEYS_ALL_NULL:
+
/*
- * No check - nothing could have been referencing this row anyway.
+ * No check - nothing could have been referencing this row
+ * anyway.
*/
return true;
@@ -560,10 +566,10 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
{
case RI_MATCH_TYPE_FULL:
case RI_MATCH_TYPE_UNSPECIFIED:
-
+
/*
- * MATCH <unspecified>/FULL - if ANY column is null, we
- * can't be matching to this row already.
+ * MATCH <unspecified>/FULL - if ANY column is null,
+ * we can't be matching to this row already.
*/
return true;
@@ -619,9 +625,9 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
for (i = 0; i < qkey.nkeypairs; i++)
{
quoteOneName(attname,
- tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
+ tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -644,7 +650,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
{
check_values[i] = SPI_getbinval(old_row,
pk_rel->rd_att,
- qkey.keypair[i][RI_KEYPAIR_PK_IDX],
+ qkey.keypair[i][RI_KEYPAIR_PK_IDX],
&isnull);
if (isnull)
check_nulls[i] = 'n';
@@ -664,7 +670,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
SetUserId(save_uid);
- result = (SPI_processed!=0);
+ result = (SPI_processed != 0);
if (SPI_finish() != SPI_OK_FINISH)
elog(WARNING, "SPI_finish() failed in ri_Check_Pk_Match()");
@@ -736,8 +742,8 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
* Get the relation descriptors of the FK and PK tables and the old
* tuple.
*
- * fk_rel is opened in RowShareLock mode since that's what our
- * eventual SELECT FOR UPDATE will get on it.
+ * fk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR UPDATE will get on it.
*/
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
pk_rel = trigdata->tg_relation;
@@ -745,10 +751,11 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid,
- match_type, tgnargs, tgargs)) {
- /*
- * There's either another row, or no row could match this
- * one. In either case, we don't need to do the check.
+ match_type, tgnargs, tgargs))
+ {
+ /*
+ * There's either another row, or no row could match this one. In
+ * either case, we don't need to do the check.
*/
heap_close(fk_rel, RowShareLock);
return PointerGetDatum(NULL);
@@ -800,7 +807,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
const char *querysep;
@@ -823,7 +830,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -959,8 +966,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
* Get the relation descriptors of the FK and PK tables and the new
* and old tuple.
*
- * fk_rel is opened in RowShareLock mode since that's what our
- * eventual SELECT FOR UPDATE will get on it.
+ * fk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR UPDATE will get on it.
*/
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
pk_rel = trigdata->tg_relation;
@@ -969,10 +976,11 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid,
- match_type, tgnargs, tgargs)) {
- /*
- * There's either another row, or no row could match this
- * one. In either case, we don't need to do the check.
+ match_type, tgnargs, tgargs))
+ {
+ /*
+ * There's either another row, or no row could match this one. In
+ * either case, we don't need to do the check.
*/
heap_close(fk_rel, RowShareLock);
return PointerGetDatum(NULL);
@@ -1034,7 +1042,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
const char *querysep;
@@ -1057,7 +1065,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -1241,7 +1249,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
const char *querysep;
@@ -1264,7 +1272,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -1455,7 +1463,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
@@ -1483,9 +1491,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
- qualsep, attname, j+1);
+ qualsep, attname, j + 1);
querysep = ",";
qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@@ -1628,8 +1636,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
* Get the relation descriptors of the FK and PK tables and the old
* tuple.
*
- * fk_rel is opened in RowShareLock mode since that's what our
- * eventual SELECT FOR UPDATE will get on it.
+ * fk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR UPDATE will get on it.
*/
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
pk_rel = trigdata->tg_relation;
@@ -1682,7 +1690,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
const char *querysep;
@@ -1705,7 +1713,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -1845,8 +1853,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
* Get the relation descriptors of the FK and PK tables and the new
* and old tuple.
*
- * fk_rel is opened in RowShareLock mode since that's what our
- * eventual SELECT FOR UPDATE will get on it.
+ * fk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR UPDATE will get on it.
*/
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
pk_rel = trigdata->tg_relation;
@@ -1910,7 +1918,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
const char *querysep;
@@ -1933,7 +1941,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
- querysep, attname, i+1);
+ querysep, attname, i + 1);
querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -2121,7 +2129,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
@@ -2149,9 +2157,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
- querysep, attname);
+ querysep, attname);
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
- qualsep, attname, i+1);
+ qualsep, attname, i + 1);
querysep = ",";
qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@@ -2365,7 +2373,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
(qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
@@ -2392,6 +2400,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
{
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
+
/*
* MATCH <unspecified> - only change columns
* corresponding to changed columns in pk_rel's key
@@ -2401,11 +2410,11 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
RI_KEYPAIR_PK_IDX))
{
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
- querysep, attname);
+ querysep, attname);
querysep = ",";
}
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
- qualsep, attname, i+1);
+ qualsep, attname, i + 1);
qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -2592,7 +2601,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
*/
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
@@ -2625,9 +2634,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
- querysep, attname);
+ querysep, attname);
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
- qualsep, attname, i+1);
+ qualsep, attname, i + 1);
querysep = ",";
qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@@ -2861,7 +2870,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
*/
{
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
- (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
+ (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char attname[MAX_QUOTED_NAME_LEN];
@@ -2893,6 +2902,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
{
quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
+
/*
* MATCH <unspecified> - only change columns
* corresponding to changed columns in pk_rel's key
@@ -2902,11 +2912,11 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
new_row, &qkey, RI_KEYPAIR_PK_IDX))
{
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
- querysep, attname);
+ querysep, attname);
querysep = ",";
}
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
- qualsep, attname, i+1);
+ qualsep, attname, i + 1);
qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
@@ -3245,8 +3255,8 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
*/
static void
ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
- Relation pk_rel,
- int argc, char **argv)
+ Relation pk_rel,
+ int argc, char **argv)
{
int i;
int j;
@@ -3588,7 +3598,7 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
typeid, typeid, true);
if (!OidIsValid(opr_proc))
elog(ERROR,
- "ri_AttributesEqual(): cannot find '=' operator for type %u",
+ "ri_AttributesEqual(): cannot find '=' operator for type %u",
typeid);
/*
@@ -3616,4 +3626,3 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
return DatumGetBool(FunctionCall2(&(entry->oprfmgrinfo),
oldvalue, newvalue));
}
-
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index c7da14ad7ea..740dde36dd4 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.120 2002/08/31 22:10:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.121 2002/09/04 20:31:28 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -124,29 +124,29 @@ static char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_c
*/
static text *pg_do_getviewdef(Oid viewoid);
static void decompile_column_index_array(Datum column_index_array, Oid relId,
- StringInfo buf);
+ StringInfo buf);
static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc);
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc);
static void get_query_def(Query *query, StringInfo buf, List *parentnamespace,
- TupleDesc resultDesc);
+ TupleDesc resultDesc);
static void get_select_query_def(Query *query, deparse_context *context,
- TupleDesc resultDesc);
+ TupleDesc resultDesc);
static void get_insert_query_def(Query *query, deparse_context *context);
static void get_update_query_def(Query *query, deparse_context *context);
static void get_delete_query_def(Query *query, deparse_context *context);
static void get_utility_query_def(Query *query, deparse_context *context);
static void get_basic_select_query(Query *query, deparse_context *context,
- TupleDesc resultDesc);
+ TupleDesc resultDesc);
static void get_setop_query(Node *setOp, Query *query,
- deparse_context *context,
- TupleDesc resultDesc);
+ deparse_context *context,
+ TupleDesc resultDesc);
static Node *get_rule_sortgroupclause(SortClause *srt, List *tlist,
bool force_colno,
deparse_context *context);
static void get_names_for_var(Var *var, deparse_context *context,
char **schemaname, char **refname, char **attname);
static RangeTblEntry *find_rte_by_refname(const char *refname,
- deparse_context *context);
+ deparse_context *context);
static void get_rule_expr(Node *node, deparse_context *context);
static void get_oper_expr(Expr *expr, deparse_context *context);
static void get_func_expr(Expr *expr, deparse_context *context);
@@ -159,7 +159,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_from_clause_coldeflist(List *coldeflist,
- deparse_context *context);
+ deparse_context *context);
static void get_opclass_name(Oid opclass, Oid actual_datatype,
StringInfo buf);
static bool tleIsArrayAssign(TargetEntry *tle);
@@ -284,7 +284,7 @@ pg_get_viewdef_name(PG_FUNCTION_ARGS)
text *ruledef;
viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname,
- "get_viewdef"));
+ "get_viewdef"));
viewoid = RangeVarGetRelid(viewrel, false);
ruledef = pg_do_getviewdef(viewoid);
@@ -425,8 +425,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
amrec = (Form_pg_am) GETSTRUCT(ht_am);
/*
- * Start the index definition. Note that the index's name should never
- * be schema-qualified, but the indexed rel's name may be.
+ * Start the index definition. Note that the index's name should
+ * never be schema-qualified, but the indexed rel's name may be.
*/
initStringInfo(&buf);
appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
@@ -551,15 +551,15 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
Datum
pg_get_constraintdef(PG_FUNCTION_ARGS)
{
- Oid constraintId = PG_GETARG_OID(0);
- text *result;
- StringInfoData buf;
- int len;
- Relation conDesc;
- SysScanDesc conscan;
- ScanKeyData skey[1];
- HeapTuple tup;
- Form_pg_constraint conForm;
+ Oid constraintId = PG_GETARG_OID(0);
+ text *result;
+ StringInfoData buf;
+ int len;
+ Relation conDesc;
+ SysScanDesc conscan;
+ ScanKeyData skey[1];
+ HeapTuple tup;
+ Form_pg_constraint conForm;
/*
* Fetch the pg_constraint row. There's no syscache for pg_constraint
@@ -584,111 +584,111 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
switch (conForm->contype)
{
case CONSTRAINT_FOREIGN:
- {
- Datum val;
- bool isnull;
- const char *string;
+ {
+ Datum val;
+ bool isnull;
+ const char *string;
- /* Start off the constraint definition */
- appendStringInfo(&buf, "FOREIGN KEY (");
+ /* Start off the constraint definition */
+ appendStringInfo(&buf, "FOREIGN KEY (");
- /* Fetch and build referencing-column list */
- val = heap_getattr(tup, Anum_pg_constraint_conkey,
- RelationGetDescr(conDesc), &isnull);
- if (isnull)
- elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
- constraintId);
+ /* Fetch and build referencing-column list */
+ val = heap_getattr(tup, Anum_pg_constraint_conkey,
+ RelationGetDescr(conDesc), &isnull);
+ if (isnull)
+ elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
+ constraintId);
- decompile_column_index_array(val, conForm->conrelid, &buf);
+ decompile_column_index_array(val, conForm->conrelid, &buf);
- /* add foreign relation name */
- appendStringInfo(&buf, ") REFERENCES %s(",
+ /* add foreign relation name */
+ appendStringInfo(&buf, ") REFERENCES %s(",
generate_relation_name(conForm->confrelid));
- /* Fetch and build referenced-column list */
- val = heap_getattr(tup, Anum_pg_constraint_confkey,
- RelationGetDescr(conDesc), &isnull);
- if (isnull)
- elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u",
- constraintId);
+ /* Fetch and build referenced-column list */
+ val = heap_getattr(tup, Anum_pg_constraint_confkey,
+ RelationGetDescr(conDesc), &isnull);
+ if (isnull)
+ elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u",
+ constraintId);
- decompile_column_index_array(val, conForm->confrelid, &buf);
+ decompile_column_index_array(val, conForm->confrelid, &buf);
- appendStringInfo(&buf, ")");
+ appendStringInfo(&buf, ")");
- /* Add match type */
- switch (conForm->confmatchtype)
- {
- case FKCONSTR_MATCH_FULL:
- string = " MATCH FULL";
- break;
- case FKCONSTR_MATCH_PARTIAL:
- string = " MATCH PARTIAL";
- break;
- case FKCONSTR_MATCH_UNSPECIFIED:
- string = "";
- break;
- default:
- elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u",
- conForm->confmatchtype, constraintId);
- string = ""; /* keep compiler quiet */
- break;
- }
- appendStringInfo(&buf, "%s", string);
+ /* Add match type */
+ switch (conForm->confmatchtype)
+ {
+ case FKCONSTR_MATCH_FULL:
+ string = " MATCH FULL";
+ break;
+ case FKCONSTR_MATCH_PARTIAL:
+ string = " MATCH PARTIAL";
+ break;
+ case FKCONSTR_MATCH_UNSPECIFIED:
+ string = "";
+ break;
+ default:
+ elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u",
+ conForm->confmatchtype, constraintId);
+ string = ""; /* keep compiler quiet */
+ break;
+ }
+ appendStringInfo(&buf, "%s", string);
- /* Add ON UPDATE and ON DELETE clauses */
- switch (conForm->confupdtype)
- {
- case FKCONSTR_ACTION_NOACTION:
- string = "NO ACTION";
- break;
- case FKCONSTR_ACTION_RESTRICT:
- string = "RESTRICT";
- break;
- case FKCONSTR_ACTION_CASCADE:
- string = "CASCADE";
- break;
- case FKCONSTR_ACTION_SETNULL:
- string = "SET NULL";
- break;
- case FKCONSTR_ACTION_SETDEFAULT:
- string = "SET DEFAULT";
- break;
- default:
- elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u",
- conForm->confupdtype, constraintId);
- string = ""; /* keep compiler quiet */
- break;
- }
- appendStringInfo(&buf, " ON UPDATE %s", string);
+ /* Add ON UPDATE and ON DELETE clauses */
+ switch (conForm->confupdtype)
+ {
+ case FKCONSTR_ACTION_NOACTION:
+ string = "NO ACTION";
+ break;
+ case FKCONSTR_ACTION_RESTRICT:
+ string = "RESTRICT";
+ break;
+ case FKCONSTR_ACTION_CASCADE:
+ string = "CASCADE";
+ break;
+ case FKCONSTR_ACTION_SETNULL:
+ string = "SET NULL";
+ break;
+ case FKCONSTR_ACTION_SETDEFAULT:
+ string = "SET DEFAULT";
+ break;
+ default:
+ elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u",
+ conForm->confupdtype, constraintId);
+ string = ""; /* keep compiler quiet */
+ break;
+ }
+ appendStringInfo(&buf, " ON UPDATE %s", string);
- switch (conForm->confdeltype)
- {
- case FKCONSTR_ACTION_NOACTION:
- string = "NO ACTION";
- break;
- case FKCONSTR_ACTION_RESTRICT:
- string = "RESTRICT";
- break;
- case FKCONSTR_ACTION_CASCADE:
- string = "CASCADE";
- break;
- case FKCONSTR_ACTION_SETNULL:
- string = "SET NULL";
- break;
- case FKCONSTR_ACTION_SETDEFAULT:
- string = "SET DEFAULT";
- break;
- default:
- elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u",
- conForm->confdeltype, constraintId);
- string = ""; /* keep compiler quiet */
- break;
- }
- appendStringInfo(&buf, " ON DELETE %s", string);
+ switch (conForm->confdeltype)
+ {
+ case FKCONSTR_ACTION_NOACTION:
+ string = "NO ACTION";
+ break;
+ case FKCONSTR_ACTION_RESTRICT:
+ string = "RESTRICT";
+ break;
+ case FKCONSTR_ACTION_CASCADE:
+ string = "CASCADE";
+ break;
+ case FKCONSTR_ACTION_SETNULL:
+ string = "SET NULL";
+ break;
+ case FKCONSTR_ACTION_SETDEFAULT:
+ string = "SET DEFAULT";
+ break;
+ default:
+ elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u",
+ conForm->confdeltype, constraintId);
+ string = ""; /* keep compiler quiet */
+ break;
+ }
+ appendStringInfo(&buf, " ON DELETE %s", string);
- break;
- }
+ break;
+ }
/*
* XXX Add more code here for other contypes
@@ -735,7 +735,7 @@ decompile_column_index_array(Datum column_index_array, Oid relId,
{
char *colName;
- colName = get_attname(relId, DatumGetInt16(keys[j]));
+ colName = get_attname(relId, DatumGetInt16(keys[j]));
if (j == 0)
appendStringInfo(buf, "%s",
@@ -875,7 +875,7 @@ deparse_expression(Node *expr, List *dpcontext, bool forceprefix)
*
* Given the reference name (alias) and OID of a relation, build deparsing
* context for an expression referencing only that relation (as varno 1,
- * varlevelsup 0). This is sufficient for many uses of deparse_expression.
+ * varlevelsup 0). This is sufficient for many uses of deparse_expression.
* ----------
*/
List *
@@ -972,7 +972,7 @@ deparse_context_for_subplan(const char *name, List *tlist,
foreach(tl, tlist)
{
TargetEntry *tle = lfirst(tl);
- Resdom *resdom = tle->resdom;
+ Resdom *resdom = tle->resdom;
nattrs++;
Assert(resdom->resno == nattrs);
@@ -983,13 +983,13 @@ deparse_context_for_subplan(const char *name, List *tlist,
}
if (tle->expr && IsA(tle->expr, Var))
{
- Var *var = (Var *) tle->expr;
+ Var *var = (Var *) tle->expr;
/* varno/varattno won't be any good, but varnoold might be */
if (var->varnoold > 0 && var->varnoold <= rtablelength)
{
RangeTblEntry *varrte = rt_fetch(var->varnoold, rtable);
- char *varname;
+ char *varname;
varname = get_rte_attribute_name(varrte, var->varoattno);
attrs = lappend(attrs, makeString(varname));
@@ -1001,7 +1001,7 @@ deparse_context_for_subplan(const char *name, List *tlist,
attrs = lappend(attrs, makeString(pstrdup(buf)));
}
- rte->rtekind = RTE_SPECIAL; /* XXX */
+ rte->rtekind = RTE_SPECIAL; /* XXX */
rte->relid = InvalidOid;
rte->eref = makeAlias(name, attrs);
rte->inh = false;
@@ -1127,9 +1127,9 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
query = (Query *) lfirst(actions);
/*
- * If the action is INSERT...SELECT, OLD/NEW have been pushed
- * down into the SELECT, and that's what we need to look at.
- * (Ugly kluge ... try to fix this when we redesign querytrees.)
+ * If the action is INSERT...SELECT, OLD/NEW have been pushed down
+ * into the SELECT, and that's what we need to look at. (Ugly
+ * kluge ... try to fix this when we redesign querytrees.)
*/
query = getInsertSelectQuery(query, NULL);
@@ -1434,13 +1434,13 @@ get_basic_select_query(Query *query, deparse_context *context,
get_rule_expr(tle->expr, context);
/*
- * Figure out what the result column should be called. In the
+ * Figure out what the result column should be called. In the
* context of a view, use the view's tuple descriptor (so as to
- * pick up the effects of any column RENAME that's been done on the
- * view). Otherwise, just use what we can find in the TLE.
+ * pick up the effects of any column RENAME that's been done on
+ * the view). Otherwise, just use what we can find in the TLE.
*/
if (resultDesc && colno <= resultDesc->natts)
- colname = NameStr(resultDesc->attrs[colno-1]->attname);
+ colname = NameStr(resultDesc->attrs[colno - 1]->attname);
else
colname = tle->resdom->resname;
@@ -1751,8 +1751,8 @@ get_utility_query_def(Query *query, deparse_context *context)
NotifyStmt *stmt = (NotifyStmt *) query->utilityStmt;
appendStringInfo(buf, "NOTIFY %s",
- quote_qualified_identifier(stmt->relation->schemaname,
- stmt->relation->relname));
+ quote_qualified_identifier(stmt->relation->schemaname,
+ stmt->relation->relname));
}
else
elog(ERROR, "get_utility_query_def: unexpected statement type");
@@ -1762,7 +1762,7 @@ get_utility_query_def(Query *query, deparse_context *context)
/*
* Get the schemaname, refname and attname for a (possibly nonlocal) Var.
*
- * schemaname is usually returned as NULL. It will be non-null only if
+ * schemaname is usually returned as NULL. It will be non-null only if
* use of the unqualified refname would find the wrong RTE.
*
* refname will be returned as NULL if the Var references an unnamed join.
@@ -1813,9 +1813,10 @@ get_names_for_var(Var *var, deparse_context *context,
if (rte->rtekind == RTE_RELATION)
{
/*
- * It's possible that use of the bare refname would find another
- * more-closely-nested RTE, or be ambiguous, in which case
- * we need to specify the schemaname to avoid these errors.
+ * It's possible that use of the bare refname would find
+ * another more-closely-nested RTE, or be ambiguous, in which
+ * case we need to specify the schemaname to avoid these
+ * errors.
*/
if (find_rte_by_refname(rte->eref->aliasname, context) != rte)
*schemaname =
@@ -1864,7 +1865,7 @@ find_rte_by_refname(const char *refname, deparse_context *context)
if (strcmp(rte->eref->aliasname, refname) == 0)
{
if (result)
- return NULL; /* it's ambiguous */
+ return NULL; /* it's ambiguous */
result = rte;
}
}
@@ -1964,8 +1965,8 @@ get_rule_expr(Node *node, deparse_context *context)
Assert(length(args) == 2);
{
/* binary operator */
- Node *arg1 = (Node *) lfirst(args);
- Node *arg2 = (Node *) lsecond(args);
+ Node *arg1 = (Node *) lfirst(args);
+ Node *arg2 = (Node *) lsecond(args);
get_rule_expr(arg1, context);
appendStringInfo(buf, " IS DISTINCT FROM ");
@@ -2007,10 +2008,11 @@ get_rule_expr(Node *node, deparse_context *context)
break;
case SUBPLAN_EXPR:
+
/*
- * We cannot see an already-planned subplan in rule
- * deparsing, only while EXPLAINing a query plan.
- * For now, just punt.
+ * We cannot see an already-planned subplan in
+ * rule deparsing, only while EXPLAINing a query
+ * plan. For now, just punt.
*/
appendStringInfo(buf, "(subplan)");
break;
@@ -2089,6 +2091,7 @@ get_rule_expr(Node *node, deparse_context *context)
ReleaseSysCache(typetup);
fieldname = get_relid_attribute_name(typrelid,
fselect->fieldnum);
+
/*
* If the argument is simple enough, we could emit
* arg.fieldname, but most cases where FieldSelect is used
@@ -2108,7 +2111,7 @@ get_rule_expr(Node *node, deparse_context *context)
get_rule_expr(relabel->arg, context);
appendStringInfo(buf, ")::%s",
format_type_with_typemod(relabel->resulttype,
- relabel->resulttypmod));
+ relabel->resulttypmod));
}
break;
@@ -2246,8 +2249,8 @@ get_oper_expr(Expr *expr, deparse_context *context)
if (length(args) == 2)
{
/* binary operator */
- Node *arg1 = (Node *) lfirst(args);
- Node *arg2 = (Node *) lsecond(args);
+ Node *arg1 = (Node *) lfirst(args);
+ Node *arg2 = (Node *) lsecond(args);
get_rule_expr(arg1, context);
appendStringInfo(buf, " %s ",
@@ -2332,9 +2335,9 @@ get_func_expr(Expr *expr, deparse_context *context)
/*
* Show typename with appropriate length decoration. Note that
* since exprIsLengthCoercion succeeded, the function's output
- * type is the right thing to report. Also note we don't need
- * to quote the result of format_type_with_typemod: it takes
- * care of double-quoting any identifier that needs it.
+ * type is the right thing to report. Also note we don't need to
+ * quote the result of format_type_with_typemod: it takes care of
+ * double-quoting any identifier that needs it.
*/
typdesc = format_type_with_typemod(rettype, coercedTypmod);
appendStringInfo(buf, ")::%s", typdesc);
@@ -2344,8 +2347,8 @@ get_func_expr(Expr *expr, deparse_context *context)
}
/*
- * Normal function: display as proname(args). First we need to extract
- * the argument datatypes.
+ * Normal function: display as proname(args). First we need to
+ * extract the argument datatypes.
*/
nargs = 0;
foreach(l, expr->args)
@@ -2354,7 +2357,7 @@ get_func_expr(Expr *expr, deparse_context *context)
argtypes[nargs] = exprType((Node *) lfirst(l));
nargs++;
}
-
+
appendStringInfo(buf, "%s(",
generate_function_name(funcoid, nargs, argtypes));
@@ -2378,7 +2381,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context)
Oid argtype = exprType(aggref->target);
appendStringInfo(buf, "%s(%s",
- generate_function_name(aggref->aggfnoid, 1, &argtype),
+ generate_function_name(aggref->aggfnoid, 1, &argtype),
aggref->aggdistinct ? "DISTINCT " : "");
if (aggref->aggstar)
appendStringInfo(buf, "*");
@@ -2438,8 +2441,8 @@ strip_type_coercion(Node *expr, Oid resultType)
}
/* See if function has is actually declared as a cast */
castTuple = SearchSysCache(CASTSOURCETARGET,
- ObjectIdGetDatum(procStruct->proargtypes[0]),
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->proargtypes[0]),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0);
if (!HeapTupleIsValid(castTuple))
{
@@ -2519,11 +2522,11 @@ get_const_expr(Const *constval, deparse_context *context)
if (constval->constisnull)
{
/*
- * Always label the type of a NULL constant to prevent misdecisions
- * about type when reparsing.
+ * Always label the type of a NULL constant to prevent
+ * misdecisions about type when reparsing.
*/
appendStringInfo(buf, "NULL::%s",
- format_type_with_typemod(constval->consttype, -1));
+ format_type_with_typemod(constval->consttype, -1));
return;
}
@@ -2549,23 +2552,23 @@ get_const_expr(Const *constval, deparse_context *context)
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
- {
- /*
- * These types are printed without quotes unless they
- * contain values that aren't accepted by the scanner
- * unquoted (e.g., 'NaN'). Note that strtod() and friends
- * might accept NaN, so we can't use that to test.
- *
- * In reality we only need to defend against infinity and
- * NaN, so we need not get too crazy about pattern
- * matching here.
- */
- if (strspn(extval, "0123456789 +-eE.") == strlen(extval))
- appendStringInfo(buf, extval);
- else
- appendStringInfo(buf, "'%s'", extval);
- }
- break;
+ {
+ /*
+ * These types are printed without quotes unless they
+ * contain values that aren't accepted by the scanner
+ * unquoted (e.g., 'NaN'). Note that strtod() and friends
+ * might accept NaN, so we can't use that to test.
+ *
+ * In reality we only need to defend against infinity and
+ * NaN, so we need not get too crazy about pattern
+ * matching here.
+ */
+ if (strspn(extval, "0123456789 +-eE.") == strlen(extval))
+ appendStringInfo(buf, extval);
+ else
+ appendStringInfo(buf, "'%s'", extval);
+ }
+ break;
case BITOID:
case VARBITOID:
@@ -2573,13 +2576,14 @@ get_const_expr(Const *constval, deparse_context *context)
break;
case BOOLOID:
- if (strcmp(extval, "t")==0)
+ if (strcmp(extval, "t") == 0)
appendStringInfo(buf, "true");
else
appendStringInfo(buf, "false");
break;
default:
+
/*
* We must quote any funny characters in the constant's
* representation. XXX Any MULTIBYTE considerations here?
@@ -2665,9 +2669,10 @@ get_sublink_expr(Node *node, deparse_context *context)
/*
* XXX we assume here that we can get away without qualifying the
- * operator name. Since the name may imply multiple physical operators
- * it's rather difficult to do otherwise --- in fact, if the operators
- * are in different namespaces any attempt to qualify would surely fail.
+ * operator name. Since the name may imply multiple physical
+ * operators it's rather difficult to do otherwise --- in fact, if the
+ * operators are in different namespaces any attempt to qualify would
+ * surely fail.
*/
switch (sublink->subLinkType)
{
@@ -2812,13 +2817,13 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
}
}
else if (rte->rtekind == RTE_RELATION &&
- strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0)
+ strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0)
{
/*
- * Apparently the rel has been renamed since the rule was made.
- * Emit a fake alias clause so that variable references will
- * still work. This is not a 100% solution but should work in
- * most reasonable situations.
+ * Apparently the rel has been renamed since the rule was
+ * made. Emit a fake alias clause so that variable references
+ * will still work. This is not a 100% solution but should
+ * work in most reasonable situations.
*/
appendStringInfo(buf, " %s",
quote_identifier(rte->eref->aliasname));
@@ -2981,7 +2986,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype,
opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc);
if (actual_datatype != opcrec->opcintype || !opcrec->opcdefault)
{
- /* Okay, we need the opclass name. Do we need to qualify it? */
+ /* Okay, we need the opclass name. Do we need to qualify it? */
opcname = NameStr(opcrec->opcname);
if (OpclassIsVisible(opclass))
appendStringInfo(buf, " %s", quote_identifier(opcname));
@@ -3031,9 +3036,10 @@ const char *
quote_identifier(const char *ident)
{
/*
- * Can avoid quoting if ident starts with a lowercase letter or underscore
- * and contains only lowercase letters, digits, and underscores, *and* is
- * not any SQL keyword. Otherwise, supply quotes.
+ * Can avoid quoting if ident starts with a lowercase letter or
+ * underscore and contains only lowercase letters, digits, and
+ * underscores, *and* is not any SQL keyword. Otherwise, supply
+ * quotes.
*/
int nquotes = 0;
bool safe;
@@ -3187,8 +3193,8 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes)
/*
* The idea here is to schema-qualify only if the parser would fail to
- * resolve the correct function given the unqualified func name
- * with the specified argtypes.
+ * resolve the correct function given the unqualified func name with
+ * the specified argtypes.
*/
p_result = func_get_detail(makeList1(makeString(proname)),
NIL, nargs, argtypes,
@@ -3239,8 +3245,8 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
/*
* The idea here is to schema-qualify only if the parser would fail to
- * resolve the correct operator given the unqualified op name
- * with the specified argtypes.
+ * resolve the correct operator given the unqualified op name with the
+ * specified argtypes.
*/
switch (operform->oprkind)
{
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 44037b1a376..c5a7b33b67b 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.116 2002/09/03 21:45:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.117 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -855,9 +855,12 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
return 0.0;
constval = ((Const *) other)->constvalue;
- /* the right-hand const is type text or bytea for all supported operators */
+ /*
+ * the right-hand const is type text or bytea for all supported
+ * operators
+ */
Assert(((Const *) other)->consttype == TEXTOID ||
- ((Const *) other)->consttype == BYTEAOID);
+ ((Const *) other)->consttype == BYTEAOID);
/* divide pattern into fixed prefix and remainder */
patt = (Const *) other;
@@ -1860,11 +1863,12 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
get_typlenbyval(var->vartype, &typLen, &typByVal);
/*
- * If there is a histogram, grab the last or first value as appropriate.
+ * If there is a histogram, grab the last or first value as
+ * appropriate.
*
- * If there is a histogram that is sorted with some other operator
- * than the one we want, fail --- this suggests that there is data
- * we can't use.
+ * If there is a histogram that is sorted with some other operator than
+ * the one we want, fail --- this suggests that there is data we can't
+ * use.
*/
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
STATISTIC_KIND_HISTOGRAM, sortop,
@@ -1873,14 +1877,14 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
{
if (nvalues > 0)
{
- tmax = datumCopy(values[nvalues-1], typByVal, typLen);
+ tmax = datumCopy(values[nvalues - 1], typByVal, typLen);
have_max = true;
}
free_attstatsslot(var->vartype, values, nvalues, NULL, 0);
}
else
{
- Oid rsortop = get_commutator(sortop);
+ Oid rsortop = get_commutator(sortop);
if (OidIsValid(rsortop) &&
get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
@@ -1907,8 +1911,8 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
}
/*
- * If we have most-common-values info, look for a large MCV. This
- * is needed even if we also have a histogram, since the histogram
+ * If we have most-common-values info, look for a large MCV. This is
+ * needed even if we also have a histogram, since the histogram
* excludes the MCVs. However, usually the MCVs will not be the
* extreme values, so avoid unnecessary data copying.
*/
@@ -1917,7 +1921,7 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
&values, &nvalues,
NULL, NULL))
{
- bool large_mcv = false;
+ bool large_mcv = false;
FmgrInfo opproc;
fmgr_info(get_opcode(sortop), &opproc);
@@ -2724,7 +2728,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
patt = DatumGetCString(DirectFunctionCall1(byteaout, patt_const->constvalue));
pattlen = toast_raw_datum_size(patt_const->constvalue) - VARHDRSZ;
}
-
+
prefix = match = palloc(pattlen + 1);
match_pos = 0;
@@ -2760,8 +2764,8 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
match[match_pos] = '\0';
rest = &patt[pos];
- *prefix_const = string_to_const(prefix, typeid);
- *rest_const = string_to_const(rest, typeid);
+ *prefix_const = string_to_const(prefix, typeid);
+ *rest_const = string_to_const(rest, typeid);
pfree(patt);
pfree(match);
@@ -2807,8 +2811,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
{
rest = patt;
- *prefix_const = NULL;
- *rest_const = string_to_const(rest, typeid);
+ *prefix_const = NULL;
+ *rest_const = string_to_const(rest, typeid);
return Pattern_Prefix_None;
}
@@ -2824,8 +2828,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
{
rest = patt;
- *prefix_const = NULL;
- *rest_const = string_to_const(rest, typeid);
+ *prefix_const = NULL;
+ *rest_const = string_to_const(rest, typeid);
return Pattern_Prefix_None;
}
@@ -2898,14 +2902,14 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
{
rest = &patt[pos + 1];
- *prefix_const = string_to_const(prefix, typeid);
- *rest_const = string_to_const(rest, typeid);
+ *prefix_const = string_to_const(prefix, typeid);
+ *rest_const = string_to_const(rest, typeid);
return Pattern_Prefix_Exact; /* pattern specifies exact match */
}
- *prefix_const = string_to_const(prefix, typeid);
- *rest_const = string_to_const(rest, typeid);
+ *prefix_const = string_to_const(prefix, typeid);
+ *rest_const = string_to_const(rest, typeid);
pfree(patt);
pfree(match);
@@ -3279,7 +3283,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
* we must be able to generate another string "fop" that is greater
* than all strings "foobar" starting with "foo". Unfortunately, a
* non-C locale may have arbitrary collation rules in which "fop" >
- * "foo" is not sufficient to ensure "fop" > "foobar". Until we can
+ * "foo" is not sufficient to ensure "fop" > "foobar". Until we can
* come up with a more bulletproof way of generating the upper-bound
* string, the optimization is disabled in all non-C locales.
*
@@ -3356,8 +3360,8 @@ make_greater_string(const Const *str_const)
(*lastchar)++;
if (string_lessthan(str, workstr, datatype))
{
- /* Success! */
- Const *workstr_const = string_to_const(workstr, datatype);
+ /* Success! */
+ Const *workstr_const = string_to_const(workstr, datatype);
pfree(str);
pfree(workstr);
@@ -3372,7 +3376,7 @@ make_greater_string(const Const *str_const)
if (datatype != BYTEAOID && pg_database_encoding_max_length() > 1)
len = pg_mbcliplen((const unsigned char *) workstr, len, len - 1);
else
- len -= - 1;
+ len -= -1;
if (datatype != BYTEAOID)
workstr[len] = '\0';
diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c
index 321b9c6855e..3c4838c0fe7 100644
--- a/src/backend/utils/adt/sets.c
+++ b/src/backend/utils/adt/sets.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.53 2002/09/02 01:05:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.54 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,19 +54,19 @@ SetDefine(char *querystr, Oid elemType)
char repl[Natts_pg_proc];
setoid = ProcedureCreate(procname, /* changed below, after oid known */
- PG_CATALOG_NAMESPACE, /* XXX wrong */
+ PG_CATALOG_NAMESPACE, /* XXX wrong */
false, /* don't replace */
true, /* returnsSet */
elemType, /* returnType */
- SQLlanguageId, /* language */
+ SQLlanguageId, /* language */
F_FMGR_SQL_VALIDATOR,
querystr, /* prosrc */
fileName, /* probin */
false, /* not aggregate */
false, /* security invoker */
false, /* isStrict (irrelevant, no args) */
- PROVOLATILE_VOLATILE, /* assume unsafe */
- 0, /* parameterCount */
+ PROVOLATILE_VOLATILE, /* assume unsafe */
+ 0, /* parameterCount */
NULL); /* parameterTypes */
/*
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index d90c20adf98..49400082234 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.35 2002/08/29 00:17:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.36 2002/09/04 20:31:29 momjian Exp $
*
* NOTES
* input routine largely stolen from boxin().
@@ -154,14 +154,16 @@ setLastTid(const ItemPointer tid)
* correspond to the CTID of a base relation.
*/
static Datum
-currtid_for_view(Relation viewrel, ItemPointer tid)
+currtid_for_view(Relation viewrel, ItemPointer tid)
{
TupleDesc att = RelationGetDescr(viewrel);
- RuleLock *rulelock;
- RewriteRule *rewrite;
- int i, natts = att->natts, tididx = -1;
+ RuleLock *rulelock;
+ RewriteRule *rewrite;
+ int i,
+ natts = att->natts,
+ tididx = -1;
- for (i = 0; i < natts ; i++)
+ for (i = 0; i < natts; i++)
{
if (strcasecmp(NameStr(att->attrs[i]->attname), "ctid") == 0)
{
@@ -179,7 +181,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
rewrite = rulelock->rules[i];
if (rewrite->event == CMD_SELECT)
{
- Query *query;
+ Query *query;
TargetEntry *tle;
if (length(rewrite->actions) != 1)
@@ -188,8 +190,9 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
tle = (TargetEntry *) nth(tididx, query->targetList);
if (tle && tle->expr && nodeTag(tle->expr) == T_Var)
{
- Var *var = (Var *) tle->expr;
+ Var *var = (Var *) tle->expr;
RangeTblEntry *rte;
+
if (var->varno > 0 && var->varno < INNER && var->varattno == SelfItemPointerAttributeNumber)
{
rte = (RangeTblEntry *) nth(var->varno - 1, query->rtable);
@@ -244,7 +247,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
Relation rel;
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,
- "currtid_byrelname"));
+ "currtid_byrelname"));
rel = heap_openrv(relrv, AccessShareLock);
if (rel->rd_rel->relkind == RELKIND_VIEW)
return currtid_for_view(rel, tid);
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index a381fd47cd6..bfdb7d06efc 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.72 2002/09/03 22:55:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.73 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,6 +31,7 @@
#ifdef HAVE_INT64_TIMESTAMP
static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec);
+
#else
static double time2t(const int hour, const int min, const int sec, const fsec_t fsec);
#endif
@@ -155,7 +156,7 @@ static void
AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
- static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION+1] = {
+ static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = {
INT64CONST(1000000),
INT64CONST(100000),
INT64CONST(10000),
@@ -165,7 +166,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
INT64CONST(1)
};
- static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = {
+ static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
INT64CONST(-500000),
INT64CONST(-50000),
INT64CONST(-5000),
@@ -174,8 +175,9 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
INT64CONST(-5),
INT64CONST(0)
};
+
#else
- static const double TimestampScales[MAX_TIMESTAMP_PRECISION+1] = {
+ static const double TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = {
1,
10,
100,
@@ -185,7 +187,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
1000000
};
- static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = {
+ static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
0.5,
0.05,
0.005,
@@ -224,7 +226,10 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
}
else
{
- /* Scale and truncate first, then add to help the rounding behavior */
+ /*
+ * Scale and truncate first, then add to help the rounding
+ * behavior
+ */
*time = (rint((((double) *time) * TimestampScales[typmod]) + TimestampOffsets[typmod])
/ TimestampScales[typmod]);
}
@@ -450,7 +455,7 @@ static void
AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
- static const int64 IntervalScales[MAX_INTERVAL_PRECISION+1] = {
+ static const int64 IntervalScales[MAX_INTERVAL_PRECISION + 1] = {
INT64CONST(1000000),
INT64CONST(100000),
INT64CONST(10000),
@@ -460,7 +465,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
INT64CONST(1)
};
- static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION+1] = {
+ static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = {
INT64CONST(-500000),
INT64CONST(-50000),
INT64CONST(-5000),
@@ -469,8 +474,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
INT64CONST(-5),
INT64CONST(0)
};
+
#else
- static const double IntervalScales[MAX_INTERVAL_PRECISION+1] = {
+ static const double IntervalScales[MAX_INTERVAL_PRECISION + 1] = {
1,
10,
100,
@@ -480,7 +486,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
1000000
};
- static const double IntervalOffsets[MAX_INTERVAL_PRECISION+1] = {
+ static const double IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = {
0.5,
0.05,
0.005,
@@ -491,7 +497,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
};
#endif
- /* Unspecified range and precision? Then not necessary to adjust.
+ /*
+ * Unspecified range and precision? Then not necessary to adjust.
* Setting typmod to -1 is the convention for all types.
*/
if (typmod != -1)
@@ -515,9 +522,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
}
/* YEAR TO MONTH */
else if (range == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH)))
- {
interval->time = 0;
- }
else if (range == INTERVAL_MASK(DAY))
{
interval->month = 0;
@@ -532,6 +537,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 day;
+
#else
double day;
#endif
@@ -551,6 +557,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 hour;
+
#else
double hour;
#endif
@@ -570,6 +577,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 minute;
+
#else
double minute;
#endif
@@ -613,15 +621,14 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
INTERVAL_MASK(HOUR) |
INTERVAL_MASK(MINUTE) |
INTERVAL_MASK(SECOND)))
- {
interval->month = 0;
- }
/* HOUR TO MINUTE */
else if (range == (INTERVAL_MASK(HOUR) |
INTERVAL_MASK(MINUTE)))
{
#ifdef HAVE_INT64_TIMESTAMP
int64 day;
+
#else
double day;
#endif
@@ -644,6 +651,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 day;
+
#else
double day;
#endif
@@ -662,6 +670,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 hour;
+
#else
double hour;
#endif
@@ -706,7 +715,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
else
{
interval->time = (rint((((double) interval->time) + IntervalOffsets[precision])
- * IntervalScales[precision]) / IntervalScales[precision]);
+ * IntervalScales[precision]) / IntervalScales[precision]);
}
#endif
}
@@ -756,6 +765,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 time;
+
#else
double time;
#endif
@@ -794,18 +804,19 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/
int
-timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn)
+timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
{
#ifdef HAVE_INT64_TIMESTAMP
- int date,
- date0;
- int64 time;
+ int date,
+ date0;
+ int64 time;
+
#else
- double date,
- date0;
- double time;
+ double date,
+ date0;
+ double time;
#endif
- time_t utime;
+ time_t utime;
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
struct tm *tx;
@@ -880,7 +891,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn)
{
#ifdef HAVE_INT64_TIMESTAMP
utime = ((dt / INT64CONST(1000000))
- + ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400)));
+ + ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400)));
#else
utime = (dt + ((date0 - date2j(1970, 1, 1)) * 86400));
#endif
@@ -963,8 +974,9 @@ int
tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
{
#ifdef HAVE_INT64_TIMESTAMP
- int date;
- int64 time;
+ int date;
+ int64 time;
+
#else
double date,
time;
@@ -996,6 +1008,7 @@ interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
{
#ifdef HAVE_INT64_TIMESTAMP
int64 time;
+
#else
double time;
#endif
@@ -1040,9 +1053,9 @@ tm2interval(struct tm * tm, fsec_t fsec, Interval *span)
span->month = ((tm->tm_year * 12) + tm->tm_mon);
#ifdef HAVE_INT64_TIMESTAMP
span->time = ((((((((tm->tm_mday * INT64CONST(24))
- + tm->tm_hour) * INT64CONST(60))
- + tm->tm_min) * INT64CONST(60))
- + tm->tm_sec) * INT64CONST(1000000)) + fsec);
+ + tm->tm_hour) * INT64CONST(60))
+ + tm->tm_min) * INT64CONST(60))
+ + tm->tm_sec) * INT64CONST(1000000)) + fsec);
#else
span->time = ((((((tm->tm_mday * 24.0)
+ tm->tm_hour) * 60.0)
@@ -1060,6 +1073,7 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec)
{
return ((((((hour * 60) + min) * 60) + sec) * INT64CONST(1000000)) + fsec);
} /* time2t() */
+
#else
static double
time2t(const int hour, const int min, const int sec, const fsec_t fsec)
@@ -1226,6 +1240,7 @@ interval_cmp_internal(Interval *interval1, Interval *interval2)
#ifdef HAVE_INT64_TIMESTAMP
int64 span1,
span2;
+
#else
double span1,
span2;
@@ -1532,9 +1547,7 @@ timestamp_pl_span(PG_FUNCTION_ARGS)
Timestamp result;
if (TIMESTAMP_NOT_FINITE(timestamp))
- {
result = timestamp;
- }
else
{
if (span->month != 0)
@@ -1702,9 +1715,11 @@ interval_smaller(PG_FUNCTION_ARGS)
Interval *interval1 = PG_GETARG_INTERVAL_P(0);
Interval *interval2 = PG_GETARG_INTERVAL_P(1);
Interval *result;
+
#ifdef HAVE_INT64_TIMESTAMP
int64 span1,
span2;
+
#else
double span1,
span2;
@@ -1746,9 +1761,11 @@ interval_larger(PG_FUNCTION_ARGS)
Interval *interval1 = PG_GETARG_INTERVAL_P(0);
Interval *interval2 = PG_GETARG_INTERVAL_P(1);
Interval *result;
+
#ifdef HAVE_INT64_TIMESTAMP
int64 span1,
span2;
+
#else
double span1,
span2;
@@ -1828,8 +1845,10 @@ interval_mul(PG_FUNCTION_ARGS)
Interval *span1 = PG_GETARG_INTERVAL_P(0);
float8 factor = PG_GETARG_FLOAT8(1);
Interval *result;
+
#ifdef HAVE_INT64_TIMESTAMP
int64 months;
+
#else
double months;
#endif
@@ -1868,6 +1887,7 @@ interval_div(PG_FUNCTION_ARGS)
Interval *span = PG_GETARG_INTERVAL_P(0);
float8 factor = PG_GETARG_FLOAT8(1);
Interval *result;
+
#ifndef HAVE_INT64_TIMESTAMP
double months;
#endif
@@ -1882,7 +1902,7 @@ interval_div(PG_FUNCTION_ARGS)
result->time = (span->time / factor);
/* evaluate fractional months as 30 days */
result->time += (((span->month - (result->month * factor))
- * INT64CONST(30) * INT64CONST(86400000000)) / factor);
+ * INT64CONST(30) * INT64CONST(86400000000)) / factor);
#else
months = (span->month / factor);
result->month = rint(months);
@@ -1928,8 +1948,8 @@ interval_accum(PG_FUNCTION_ARGS)
* objects on machines where double requires 8-byte alignment. That
* should be fixed, but in the meantime...
*
- * Note: must use DatumGetPointer here, not DatumGetIntervalP,
- * else some compilers optimize into double-aligned load/store anyway.
+ * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some
+ * compilers optimize into double-aligned load/store anyway.
*/
memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
@@ -1970,8 +1990,8 @@ interval_avg(PG_FUNCTION_ARGS)
* objects on machines where double requires 8-byte alignment. That
* should be fixed, but in the meantime...
*
- * Note: must use DatumGetPointer here, not DatumGetIntervalP,
- * else some compilers optimize into double-aligned load/store anyway.
+ * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some
+ * compilers optimize into double-aligned load/store anyway.
*/
memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
@@ -3131,29 +3151,29 @@ interval_part(PG_FUNCTION_ARGS)
{
switch (val)
{
- case DTK_MICROSEC:
+ case DTK_MICROSEC:
#ifdef HAVE_INT64_TIMESTAMP
- result = ((tm->tm_sec * 1000000e0) + fsec);
+ result = ((tm->tm_sec * 1000000e0) + fsec);
#else
- result = (tm->tm_sec + fsec) * 1000000;
+ result = (tm->tm_sec + fsec) * 1000000;
#endif
- break;
+ break;
- case DTK_MILLISEC:
+ case DTK_MILLISEC:
#ifdef HAVE_INT64_TIMESTAMP
- result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0));
+ result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0));
#else
- result = (tm->tm_sec + fsec) * 1000;
+ result = (tm->tm_sec + fsec) * 1000;
#endif
- break;
+ break;
- case DTK_SECOND:
+ case DTK_SECOND:
#ifdef HAVE_INT64_TIMESTAMP
- result = (tm->tm_sec + (fsec / 1000000e0));
+ result = (tm->tm_sec + (fsec / 1000000e0));
#else
- result = (tm->tm_sec + fsec);
+ result = (tm->tm_sec + fsec);
#endif
- break;
+ break;
case DTK_MINUTE:
result = tm->tm_min;
@@ -3234,7 +3254,7 @@ interval_part(PG_FUNCTION_ARGS)
/* timestamp_zone()
* Encode timestamp type with specified time zone.
* Returns timestamp with time zone, with the input
- * rotated from local time to the specified zone.
+ * rotated from local time to the specified zone.
*/
Datum
timestamp_zone(PG_FUNCTION_ARGS)
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 97c3567f1ac..f0c31a3961b 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.24 2002/08/26 17:53:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.25 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1138,8 +1138,8 @@ bitfromint8(PG_FUNCTION_ARGS)
VARBITLEN(result) = sizeof(a) * BITS_PER_BYTE;
/*
- * masks and shifts here are just too painful and we know that an int64
- * has got 8 bytes
+ * masks and shifts here are just too painful and we know that an
+ * int64 has got 8 bytes
*/
r = VARBITS(result);
r[0] = (bits8) ((a >> (7 * BITS_PER_BYTE)) & BITMASK);
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 819e3122c3c..780daf75655 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.93 2002/09/03 21:45:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.94 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -182,6 +182,7 @@ bpchar(PG_FUNCTION_ARGS)
int charlen; /* number of charcters in the input string
* + VARHDRSZ */
+
len = VARSIZE(source);
charlen = pg_mbstrlen_with_len(VARDATA(source), len - VARHDRSZ) + VARHDRSZ;
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 12230a70655..e21e59e1be8 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.91 2002/09/03 21:45:42 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.92 2002/09/04 20:31:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,11 +30,11 @@ typedef struct varlena unknown;
#define PG_GETARG_UNKNOWN_P(n) DatumGetUnknownP(PG_GETARG_DATUM(n))
#define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x)
#define PG_TEXTARG_GET_STR(arg_) \
- DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_)))
+ DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_)))
#define PG_TEXT_GET_STR(textp_) \
- DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_)))
+ DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_)))
#define PG_STR_GET_TEXT(str_) \
- DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_)))
+ DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_)))
#define TEXTLEN(textp) \
text_length(PointerGetDatum(textp))
#define TEXTPOS(buf_text, from_sub_text) \
@@ -54,9 +54,9 @@ static int text_cmp(text *arg1, text *arg2);
static int32 text_length(Datum str);
static int32 text_position(Datum str, Datum search_str, int matchnum);
static text *text_substring(Datum str,
- int32 start,
- int32 length,
- bool length_not_specified);
+ int32 start,
+ int32 length,
+ bool length_not_specified);
/*****************************************************************************
@@ -266,7 +266,7 @@ Datum
unknownin(PG_FUNCTION_ARGS)
{
char *inputStr = PG_GETARG_CSTRING(0);
- unknown *result;
+ unknown *result;
int len;
len = strlen(inputStr) + VARHDRSZ;
@@ -286,7 +286,7 @@ unknownin(PG_FUNCTION_ARGS)
Datum
unknownout(PG_FUNCTION_ARGS)
{
- unknown *t = PG_GETARG_UNKNOWN_P(0);
+ unknown *t = PG_GETARG_UNKNOWN_P(0);
int len;
char *result;
@@ -330,12 +330,12 @@ text_length(Datum str)
text *t = DatumGetTextP(str);
PG_RETURN_INT32(pg_mbstrlen_with_len(VARDATA(t),
- VARSIZE(t) - VARHDRSZ));
+ VARSIZE(t) - VARHDRSZ));
}
/* should never get here */
elog(ERROR, "Invalid backend encoding; encoding max length "
- "is less than one.");
+ "is less than one.");
/* not reached: suppress compiler warning */
return 0;
@@ -425,7 +425,7 @@ textcat(PG_FUNCTION_ARGS)
* behaviors conflicting with SQL92 to meet SQL92 (if E = S + L < S throw
* error; if E < 1, return '', not entire string). Fixed MB related bug when
* S > LC and < LC + 4 sometimes garbage characters are returned.
- * - Joe Conway 2002-08-10
+ * - Joe Conway 2002-08-10
*/
Datum
text_substr(PG_FUNCTION_ARGS)
@@ -455,25 +455,26 @@ text_substr_no_len(PG_FUNCTION_ARGS)
* This is broken out so it can be called directly by other string processing
* functions.
*/
-static text*
+static text *
text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
{
int32 eml = pg_database_encoding_max_length();
- int32 S = start; /* start position */
- int32 S1; /* adjusted start position */
- int32 L1; /* adjusted substring length */
+ int32 S = start; /* start position */
+ int32 S1; /* adjusted start position */
+ int32 L1; /* adjusted substring length */
/* life is easy if the encoding max length is 1 */
if (eml == 1)
{
S1 = Max(S, 1);
- if (length_not_specified) /* special case - get length to end of string */
+ if (length_not_specified) /* special case - get length to
+ * end of string */
L1 = -1;
else
{
/* end position */
- int E = S + length;
+ int E = S + length;
/*
* A negative value for L is the only way for the end position
@@ -482,9 +483,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
if (E < S)
elog(ERROR, "negative substring length not allowed");
- /*
- * A zero or negative value for the end position can happen if the start
- * was negative or one. SQL99 says to return a zero-length string.
+ /*
+ * A zero or negative value for the end position can happen if
+ * the start was negative or one. SQL99 says to return a
+ * zero-length string.
*/
if (E < 1)
return PG_STR_GET_TEXT("");
@@ -492,11 +494,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
L1 = E - S1;
}
- /*
- * If the start position is past the end of the string,
- * SQL99 says to return a zero-length string --
- * PG_GETARG_TEXT_P_SLICE() will do that for us.
- * Convert to zero-based starting position
+ /*
+ * If the start position is past the end of the string, SQL99 says
+ * to return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will
+ * do that for us. Convert to zero-based starting position
*/
return DatumGetTextPSlice(str, S1 - 1, L1);
}
@@ -504,13 +505,13 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
{
/*
* When encoding max length is > 1, we can't get LC without
- * detoasting, so we'll grab a conservatively large slice
- * now and go back later to do the right thing
+ * detoasting, so we'll grab a conservatively large slice now and
+ * go back later to do the right thing
*/
int32 slice_start;
int32 slice_size;
int32 slice_strlen;
- text *slice;
+ text *slice;
int32 E1;
int32 i;
char *p;
@@ -518,23 +519,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
text *ret;
/*
- * if S is past the end of the string, the tuple toaster
- * will return a zero-length string to us
+ * if S is past the end of the string, the tuple toaster will
+ * return a zero-length string to us
*/
S1 = Max(S, 1);
/*
- * We need to start at position zero because there is no
- * way to know in advance which byte offset corresponds to
- * the supplied start position.
+ * We need to start at position zero because there is no way to
+ * know in advance which byte offset corresponds to the supplied
+ * start position.
*/
slice_start = 0;
- if (length_not_specified) /* special case - get length to end of string */
+ if (length_not_specified) /* special case - get length to
+ * end of string */
slice_size = L1 = -1;
else
{
- int E = S + length;
+ int E = S + length;
/*
* A negative value for L is the only way for the end position
@@ -543,22 +545,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
if (E < S)
elog(ERROR, "negative substring length not allowed");
- /*
- * A zero or negative value for the end position can happen if the start
- * was negative or one. SQL99 says to return a zero-length string.
+ /*
+ * A zero or negative value for the end position can happen if
+ * the start was negative or one. SQL99 says to return a
+ * zero-length string.
*/
if (E < 1)
return PG_STR_GET_TEXT("");
/*
- * if E is past the end of the string, the tuple toaster
- * will truncate the length for us
+ * if E is past the end of the string, the tuple toaster will
+ * truncate the length for us
*/
L1 = E - S1;
/*
- * Total slice size in bytes can't be any longer than the start
- * position plus substring length times the encoding max length.
+ * Total slice size in bytes can't be any longer than the
+ * start position plus substring length times the encoding max
+ * length.
*/
slice_size = (S1 + L1) * eml;
}
@@ -569,9 +573,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
return PG_STR_GET_TEXT("");
/* Now we can get the actual length of the slice in MB characters */
- slice_strlen = pg_mbstrlen_with_len (VARDATA(slice), VARSIZE(slice) - VARHDRSZ);
+ slice_strlen = pg_mbstrlen_with_len(VARDATA(slice), VARSIZE(slice) - VARHDRSZ);
- /* Check that the start position wasn't > slice_strlen. If so,
+ /*
+ * Check that the start position wasn't > slice_strlen. If so,
* SQL99 says to return a zero-length string.
*/
if (S1 > slice_strlen)
@@ -579,16 +584,17 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
/*
* Adjust L1 and E1 now that we know the slice string length.
- * Again remember that S1 is one based, and slice_start is zero based.
+ * Again remember that S1 is one based, and slice_start is zero
+ * based.
*/
if (L1 > -1)
- E1 = Min(S1 + L1 , slice_start + 1 + slice_strlen);
+ E1 = Min(S1 + L1, slice_start + 1 + slice_strlen);
else
E1 = slice_start + 1 + slice_strlen;
/*
- * Find the start position in the slice;
- * remember S1 is not zero based
+ * Find the start position in the slice; remember S1 is not zero
+ * based
*/
p = VARDATA(slice);
for (i = 0; i < S1 - 1; i++)
@@ -598,8 +604,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
s = p;
/*
- * Count the actual bytes used by the substring of
- * the requested length.
+ * Count the actual bytes used by the substring of the requested
+ * length.
*/
for (i = S1; i < E1; i++)
p += pg_mblen(p);
@@ -612,7 +618,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
}
else
elog(ERROR, "Invalid backend encoding; encoding max length "
- "is less than one.");
+ "is less than one.");
/* not reached: suppress compiler warning */
return PG_STR_GET_TEXT("");
@@ -650,8 +656,8 @@ text_position(Datum str, Datum search_str, int matchnum)
len1,
len2;
- if(matchnum == 0)
- return 0; /* result for 0th match */
+ if (matchnum == 0)
+ return 0; /* result for 0th match */
if (VARSIZE(t2) <= VARHDRSZ)
PG_RETURN_INT32(1); /* result for empty pattern */
@@ -662,10 +668,10 @@ text_position(Datum str, Datum search_str, int matchnum)
/* no use in searching str past point where search_str will fit */
px = (len1 - len2);
- if (eml == 1) /* simple case - single byte encoding */
+ if (eml == 1) /* simple case - single byte encoding */
{
- char *p1,
- *p2;
+ char *p1,
+ *p2;
p1 = VARDATA(t1);
p2 = VARDATA(t2);
@@ -683,7 +689,7 @@ text_position(Datum str, Datum search_str, int matchnum)
p1++;
}
}
- else if (eml > 1) /* not as simple - multibyte encoding */
+ else if (eml > 1) /* not as simple - multibyte encoding */
{
pg_wchar *p1,
*p2,
@@ -715,7 +721,7 @@ text_position(Datum str, Datum search_str, int matchnum)
}
else
elog(ERROR, "Invalid backend encoding; encoding max length "
- "is less than one.");
+ "is less than one.");
PG_RETURN_INT32(pos);
}
@@ -734,10 +740,10 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
*a2p;
/*
- * Unfortunately, there is no strncoll(), so in the non-C locale
- * case we have to do some memory copying. This turns out to be
- * significantly slower, so we optimize the case where LC_COLLATE
- * is C.
+ * Unfortunately, there is no strncoll(), so in the non-C locale case
+ * we have to do some memory copying. This turns out to be
+ * significantly slower, so we optimize the case where LC_COLLATE is
+ * C.
*/
if (!lc_collate_is_c())
{
@@ -990,7 +996,7 @@ byteacat(PG_FUNCTION_ARGS)
}
#define PG_STR_GET_BYTEA(str_) \
- DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
+ DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
/*
* bytea_substr()
* Return a substring starting at the specified position.
@@ -1009,36 +1015,37 @@ byteacat(PG_FUNCTION_ARGS)
Datum
bytea_substr(PG_FUNCTION_ARGS)
{
- int S = PG_GETARG_INT32(1); /* start position */
- int S1; /* adjusted start position */
- int L1; /* adjusted substring length */
+ int S = PG_GETARG_INT32(1); /* start position */
+ int S1; /* adjusted start position */
+ int L1; /* adjusted substring length */
S1 = Max(S, 1);
if (fcinfo->nargs == 2)
{
/*
- * Not passed a length - PG_GETARG_BYTEA_P_SLICE()
- * grabs everything to the end of the string if we pass it
- * a negative value for length.
+ * Not passed a length - PG_GETARG_BYTEA_P_SLICE() grabs
+ * everything to the end of the string if we pass it a negative
+ * value for length.
*/
L1 = -1;
}
else
{
/* end position */
- int E = S + PG_GETARG_INT32(2);
+ int E = S + PG_GETARG_INT32(2);
/*
- * A negative value for L is the only way for the end position
- * to be before the start. SQL99 says to throw an error.
+ * A negative value for L is the only way for the end position to
+ * be before the start. SQL99 says to throw an error.
*/
if (E < S)
elog(ERROR, "negative substring length not allowed");
- /*
- * A zero or negative value for the end position can happen if the start
- * was negative or one. SQL99 says to return a zero-length string.
+ /*
+ * A zero or negative value for the end position can happen if the
+ * start was negative or one. SQL99 says to return a zero-length
+ * string.
*/
if (E < 1)
PG_RETURN_BYTEA_P(PG_STR_GET_BYTEA(""));
@@ -1046,13 +1053,12 @@ bytea_substr(PG_FUNCTION_ARGS)
L1 = E - S1;
}
- /*
- * If the start position is past the end of the string,
- * SQL99 says to return a zero-length string --
- * PG_GETARG_TEXT_P_SLICE() will do that for us.
- * Convert to zero-based starting position
+ /*
+ * If the start position is past the end of the string, SQL99 says to
+ * return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do
+ * that for us. Convert to zero-based starting position
*/
- PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE (0, S1 - 1, L1));
+ PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE(0, S1 - 1, L1));
}
/*
@@ -1343,7 +1349,7 @@ textToQualifiedNameList(text *textval, const char *caller)
/* Convert to C string (handles possible detoasting). */
/* Note we rely on being able to modify rawname below. */
rawname = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(textval)));
+ PointerGetDatum(textval)));
if (!SplitIdentifierString(rawname, '.', &namelist))
elog(ERROR, "%s: invalid name syntax", caller);
@@ -1353,7 +1359,7 @@ textToQualifiedNameList(text *textval, const char *caller)
foreach(l, namelist)
{
- char *curname = (char *) lfirst(l);
+ char *curname = (char *) lfirst(l);
result = lappend(result, makeString(pstrdup(curname)));
}
@@ -1368,15 +1374,15 @@ textToQualifiedNameList(text *textval, const char *caller)
* SplitIdentifierString --- parse a string containing identifiers
*
* This is the guts of textToQualifiedNameList, and is exported for use in
- * other situations such as parsing GUC variables. In the GUC case, it's
+ * other situations such as parsing GUC variables. In the GUC case, it's
* important to avoid memory leaks, so the API is designed to minimize the
* amount of stuff that needs to be allocated and freed.
*
* Inputs:
- * rawstring: the input string; must be overwritable! On return, it's
+ * rawstring: the input string; must be overwritable! On return, it's
* been modified to contain the separated identifiers.
* separator: the separator punctuation expected between identifiers
- * (typically '.' or ','). Whitespace may also appear around
+ * (typically '.' or ','). Whitespace may also appear around
* identifiers.
* Outputs:
* namelist: filled with a palloc'd list of pointers to identifiers within
@@ -1417,11 +1423,11 @@ SplitIdentifierString(char *rawstring, char separator,
{
endp = strchr(nextp + 1, '\"');
if (endp == NULL)
- return false; /* mismatched quotes */
+ return false; /* mismatched quotes */
if (endp[1] != '\"')
break; /* found end of quoted name */
/* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp+1, strlen(endp));
+ memmove(endp, endp + 1, strlen(endp));
nextp = endp;
}
/* endp now points at the terminating quote */
@@ -1435,8 +1441,8 @@ SplitIdentifierString(char *rawstring, char separator,
!isspace((unsigned char) *nextp))
{
/*
- * It's important that this match the identifier downcasing
- * code used by backend/parser/scan.l.
+ * It's important that this match the identifier
+ * downcasing code used by backend/parser/scan.l.
*/
if (isupper((unsigned char) *nextp))
*nextp = tolower((unsigned char) *nextp);
@@ -1647,24 +1653,24 @@ byteacmp(PG_FUNCTION_ARGS)
* replace_text
* replace all occurences of 'old_sub_str' in 'orig_str'
* with 'new_sub_str' to form 'new_str'
- *
+ *
* returns 'orig_str' if 'old_sub_str' == '' or 'orig_str' == ''
- * otherwise returns 'new_str'
+ * otherwise returns 'new_str'
*/
Datum
replace_text(PG_FUNCTION_ARGS)
{
- text *left_text;
- text *right_text;
- text *buf_text;
- text *ret_text;
+ text *left_text;
+ text *right_text;
+ text *buf_text;
+ text *ret_text;
int curr_posn;
- text *src_text = PG_GETARG_TEXT_P(0);
+ text *src_text = PG_GETARG_TEXT_P(0);
int src_text_len = TEXTLEN(src_text);
- text *from_sub_text = PG_GETARG_TEXT_P(1);
+ text *from_sub_text = PG_GETARG_TEXT_P(1);
int from_sub_text_len = TEXTLEN(from_sub_text);
- text *to_sub_text = PG_GETARG_TEXT_P(2);
- char *to_sub_str = PG_TEXT_GET_STR(to_sub_text);
+ text *to_sub_text = PG_GETARG_TEXT_P(2);
+ char *to_sub_str = PG_TEXT_GET_STR(to_sub_text);
StringInfo str = makeStringInfo();
if (src_text_len == 0 || from_sub_text_len == 0)
@@ -1713,7 +1719,7 @@ split_text(PG_FUNCTION_ARGS)
int fldnum = PG_GETARG_INT32(2);
int start_posn = 0;
int end_posn = 0;
- text *result_text;
+ text *result_text;
/* return empty string for empty input string */
if (inputstring_len < 1)
@@ -1722,9 +1728,11 @@ split_text(PG_FUNCTION_ARGS)
/* empty field separator */
if (fldsep_len < 1)
{
- if (fldnum == 1) /* first field - just return the input string */
+ if (fldnum == 1) /* first field - just return the input
+ * string */
PG_RETURN_TEXT_P(inputstring);
- else /* otherwise return an empty string */
+ else
+/* otherwise return an empty string */
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
}
@@ -1733,17 +1741,19 @@ split_text(PG_FUNCTION_ARGS)
elog(ERROR, "field position must be > 0");
start_posn = text_position(PointerGetDatum(inputstring),
- PointerGetDatum(fldsep),
- fldnum - 1);
+ PointerGetDatum(fldsep),
+ fldnum - 1);
end_posn = text_position(PointerGetDatum(inputstring),
- PointerGetDatum(fldsep),
- fldnum);
+ PointerGetDatum(fldsep),
+ fldnum);
if ((start_posn == 0) && (end_posn == 0)) /* fldsep not found */
{
- if (fldnum == 1) /* first field - just return the input string */
+ if (fldnum == 1) /* first field - just return the input
+ * string */
PG_RETURN_TEXT_P(inputstring);
- else /* otherwise return an empty string */
+ else
+/* otherwise return an empty string */
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
}
else if ((start_posn != 0) && (end_posn == 0))
@@ -1774,11 +1784,11 @@ split_text(PG_FUNCTION_ARGS)
Datum
to_hex32(PG_FUNCTION_ARGS)
{
- static char digits[] = "0123456789abcdef";
- char buf[32]; /* bigger than needed, but reasonable */
- char *ptr;
- text *result_text;
- int32 value = PG_GETARG_INT32(0);
+ static char digits[] = "0123456789abcdef";
+ char buf[32]; /* bigger than needed, but reasonable */
+ char *ptr;
+ text *result_text;
+ int32 value = PG_GETARG_INT32(0);
ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
@@ -1800,11 +1810,11 @@ to_hex32(PG_FUNCTION_ARGS)
Datum
to_hex64(PG_FUNCTION_ARGS)
{
- static char digits[] = "0123456789abcdef";
- char buf[32]; /* bigger than needed, but reasonable */
- char *ptr;
- text *result_text;
- int64 value = PG_GETARG_INT64(0);
+ static char digits[] = "0123456789abcdef";
+ char buf[32]; /* bigger than needed, but reasonable */
+ char *ptr;
+ text *result_text;
+ int64 value = PG_GETARG_INT64(0);
ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
@@ -1818,4 +1828,3 @@ to_hex64(PG_FUNCTION_ARGS)
result_text = PG_STR_GET_TEXT(ptr);
PG_RETURN_TEXT_P(result_text);
}
-