diff options
Diffstat (limited to 'src/backend/utils/adt')
23 files changed, 544 insertions, 478 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index dd1f1649fad..a29d31bd6eb 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.132 2006/09/29 21:22:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.133 2006/10/04 00:29:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2050,21 +2050,21 @@ array_set(ArrayType *array, dim[0] += addedbefore; lb[0] = indx[0]; if (addedbefore > 1) - newhasnulls = true; /* will insert nulls */ + newhasnulls = true; /* will insert nulls */ } if (indx[0] >= (dim[0] + lb[0])) { addedafter = indx[0] - (dim[0] + lb[0]) + 1; dim[0] += addedafter; if (addedafter > 1) - newhasnulls = true; /* will insert nulls */ + newhasnulls = true; /* will insert nulls */ } } else { /* - * XXX currently we do not support extending multi-dimensional - * arrays during assignment + * XXX currently we do not support extending multi-dimensional arrays + * during assignment */ for (i = 0; i < ndim; i++) { @@ -2338,7 +2338,7 @@ array_set_slice(ArrayType *array, if (lowerIndx[0] < lb[0]) { if (upperIndx[0] < lb[0] - 1) - newhasnulls = true; /* will insert nulls */ + newhasnulls = true; /* will insert nulls */ addedbefore = lb[0] - lowerIndx[0]; dim[0] += addedbefore; lb[0] = lowerIndx[0]; @@ -2346,7 +2346,7 @@ array_set_slice(ArrayType *array, if (upperIndx[0] >= (dim[0] + lb[0])) { if (lowerIndx[0] > (dim[0] + lb[0])) - newhasnulls = true; /* will insert nulls */ + newhasnulls = true; /* will insert nulls */ addedafter = upperIndx[0] - (dim[0] + lb[0]) + 1; dim[0] += addedafter; } @@ -2354,15 +2354,15 @@ array_set_slice(ArrayType *array, else { /* - * XXX currently we do not support extending multi-dimensional - * arrays during assignment + * XXX currently we do not support extending multi-dimensional arrays + * during assignment */ for (i = 0; i < nSubscripts; i++) { if (lowerIndx[i] > upperIndx[i]) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("upper bound cannot be less than lower bound"))); + errmsg("upper bound cannot be less than lower bound"))); if (lowerIndx[i] < lb[i] || upperIndx[i] >= (dim[i] + lb[i])) ereport(ERROR, @@ -2377,7 +2377,7 @@ array_set_slice(ArrayType *array, if (lowerIndx[i] > upperIndx[i]) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("upper bound cannot be less than lower bound"))); + errmsg("upper bound cannot be less than lower bound"))); } } @@ -3417,8 +3417,8 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall, /* * We arrange to look up the equality function only once per series of * calls, assuming the element type doesn't change underneath us. The - * typcache is used so that we have no memory leakage when being used - * as an index support function. + * typcache is used so that we have no memory leakage when being used as + * an index support function. */ typentry = (TypeCacheEntry *) *fn_extra; if (typentry == NULL || @@ -3429,8 +3429,8 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall, if (!OidIsValid(typentry->eq_opr_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(element_type)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(element_type)))); *fn_extra = (void *) typentry; } typlen = typentry->typlen; @@ -3486,9 +3486,9 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall, } /* - * We assume that the comparison operator is strict, so a NULL - * can't match anything. XXX this diverges from the "NULL=NULL" - * behavior of array_eq, should we act like that? + * We assume that the comparison operator is strict, so a NULL can't + * match anything. XXX this diverges from the "NULL=NULL" behavior of + * array_eq, should we act like that? */ if (isnull1) { diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 81f7e63650c..fac642ddc97 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.171 2006/09/16 20:14:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.172 2006/10/04 00:29:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,7 +97,7 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", */ static datetkn *timezonetktbl = NULL; -static int sztimezonetktbl = 0; +static int sztimezonetktbl = 0; static const datetkn datetktbl[] = { /* text, token, lexval */ @@ -176,7 +176,7 @@ static const datetkn datetktbl[] = { {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */ }; -static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; +static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; static datetkn deltatktbl[] = { /* text, token, lexval */ @@ -246,7 +246,7 @@ static datetkn deltatktbl[] = { {"yrs", UNITS, DTK_YEAR}, /* "years" relative */ }; -static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; +static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; static const datetkn *datecache[MAXDATEFIELDS] = {NULL}; @@ -562,12 +562,19 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, if (*cp == '/') { ftype[nf] = DTK_TZ; - /* set the first character of the region to upper case - * again*/ + + /* + * set the first character of the region to upper case + * again + */ field[nf][0] = pg_toupper((unsigned char) field[nf][0]); - /* we have seen "Region/" of a POSIX timezone, continue to - * read the City part */ - do { + + /* + * we have seen "Region/" of a POSIX timezone, continue to + * read the City part + */ + do + { APPEND_CHAR(bufp, bufend, *cp++); /* there is for example America/New_York */ } while (isalpha((unsigned char) *cp) || *cp == '_'); @@ -1303,13 +1310,14 @@ DecodeDateTime(char **field, int *ftype, int nf, if (zicTzFnum != -1) { - Datum tsTz; - Timestamp timestamp; + Datum tsTz; + Timestamp timestamp; + tm2timestamp(tm, *fsec, NULL, ×tamp); tsTz = DirectFunctionCall2(timestamp_zone, - DirectFunctionCall1(textin, - CStringGetDatum(field[zicTzFnum])), - TimestampGetDatum(timestamp)); + DirectFunctionCall1(textin, + CStringGetDatum(field[zicTzFnum])), + TimestampGetDatum(timestamp)); timestamp2tm(DatumGetTimestampTz(tsTz), tzp, tm, fsec, NULL, NULL); fmask &= ~DTK_M(TZ); } @@ -2920,7 +2928,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, tm->tm_mday += val * 7; if (fval != 0) { - int extra_days; + int extra_days; + fval *= 7; extra_days = (int32) fval; tm->tm_mday += extra_days; @@ -2928,6 +2937,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, if (fval != 0) { int sec; + fval *= SECS_PER_DAY; sec = fval; tm->tm_sec += sec; @@ -2945,7 +2955,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, tm->tm_mon += val; if (fval != 0) { - int day; + int day; + fval *= DAYS_PER_MONTH; day = fval; tm->tm_mday += day; @@ -2953,6 +2964,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, if (fval != 0) { int sec; + fval *= SECS_PER_DAY; sec = fval; tm->tm_sec += sec; @@ -3808,7 +3820,7 @@ CheckDateTokenTables(void) void InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n) { - datetkn *newtbl; + datetkn *newtbl; int i; /* @@ -3844,29 +3856,28 @@ InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n) Datum pg_timezone_abbrevs(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - int *pindex; - Datum result; - HeapTuple tuple; - Datum values[3]; - bool nulls[3]; - char buffer[TOKMAXLEN + 1]; - unsigned char *p; - struct pg_tm tm; - Interval *resInterval; + FuncCallContext *funcctx; + int *pindex; + Datum result; + HeapTuple tuple; + Datum values[3]; + bool nulls[3]; + char buffer[TOKMAXLEN + 1]; + unsigned char *p; + struct pg_tm tm; + Interval *resInterval; /* stuff done only on the first call of the function */ 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); @@ -3901,8 +3912,8 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS) MemSet(nulls, 0, sizeof(nulls)); /* - * Convert name to text, using upcasing conversion that is the inverse - * of what ParseDateTime() uses. + * Convert name to text, using upcasing conversion that is the inverse of + * what ParseDateTime() uses. */ strncpy(buffer, timezonetktbl[*pindex].token, TOKMAXLEN); buffer[TOKMAXLEN] = '\0'; /* may not be null-terminated */ @@ -3936,32 +3947,31 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS) Datum pg_timezone_names(PG_FUNCTION_ARGS) { - MemoryContext oldcontext; - FuncCallContext *funcctx; - pg_tzenum *tzenum; - pg_tz *tz; - Datum result; - HeapTuple tuple; - Datum values[4]; - bool nulls[4]; + MemoryContext oldcontext; + FuncCallContext *funcctx; + pg_tzenum *tzenum; + pg_tz *tz; + Datum result; + HeapTuple tuple; + Datum values[4]; + bool nulls[4]; int tzoff; - struct pg_tm tm; + struct pg_tm tm; fsec_t fsec; char *tzn; - Interval *resInterval; - struct pg_tm itm; + Interval *resInterval; + struct pg_tm itm; /* stuff done only on the first call of the function */ if (SRF_IS_FIRSTCALL()) { - TupleDesc tupdesc; + TupleDesc tupdesc; /* 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); @@ -4021,7 +4031,7 @@ pg_timezone_names(PG_FUNCTION_ARGS) MemSet(nulls, 0, sizeof(nulls)); values[0] = DirectFunctionCall1(textin, - CStringGetDatum(pg_get_timezone_name(tz))); + CStringGetDatum(pg_get_timezone_name(tz))); values[1] = DirectFunctionCall1(textin, CStringGetDatum(tzn ? tzn : "")); diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c index 2126c6b87b2..590c561589d 100644 --- a/src/backend/utils/adt/domains.c +++ b/src/backend/utils/adt/domains.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.3 2006/08/04 21:33:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.4 2006/10/04 00:29:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -146,8 +146,8 @@ domain_check_input(Datum value, bool isnull, DomainIOData *my_extra) /* * Set up value to be returned by CoerceToDomainValue * nodes. Unlike ExecEvalCoerceToDomain, this econtext - * couldn't be shared with anything else, so no need - * to save and restore fields. + * couldn't be shared with anything else, so no need to + * save and restore fields. */ econtext->domainValue_datum = value; econtext->domainValue_isNull = isnull; @@ -174,8 +174,8 @@ domain_check_input(Datum value, bool isnull, DomainIOData *my_extra) /* * Before exiting, call any shutdown callbacks and reset econtext's - * per-tuple memory. This avoids leaking non-memory resources, - * if anything in the expression(s) has any. + * per-tuple memory. This avoids leaking non-memory resources, if + * anything in the expression(s) has any. */ if (econtext) ReScanExprContext(econtext); @@ -194,9 +194,9 @@ domain_in(PG_FUNCTION_ARGS) Datum value; /* - * Since domain_in is not strict, we have to check for null inputs. - * The typioparam argument should never be null in normal system usage, - * but it could be null in a manual invocation --- if so, just return null. + * Since domain_in is not strict, we have to check for null inputs. The + * typioparam argument should never be null in normal system usage, but it + * could be null in a manual invocation --- if so, just return null. */ if (PG_ARGISNULL(0)) string = NULL; @@ -207,8 +207,8 @@ domain_in(PG_FUNCTION_ARGS) domainType = PG_GETARG_OID(1); /* - * We arrange to look up the needed info just once per series of - * calls, assuming the domain type doesn't change underneath us. + * We arrange to look up the needed info just once per series of calls, + * assuming the domain type doesn't change underneath us. */ my_extra = (DomainIOData *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) @@ -254,9 +254,9 @@ domain_recv(PG_FUNCTION_ARGS) Datum value; /* - * Since domain_recv is not strict, we have to check for null inputs. - * The typioparam argument should never be null in normal system usage, - * but it could be null in a manual invocation --- if so, just return null. + * Since domain_recv is not strict, we have to check for null inputs. The + * typioparam argument should never be null in normal system usage, but it + * could be null in a manual invocation --- if so, just return null. */ if (PG_ARGISNULL(0)) buf = NULL; @@ -267,8 +267,8 @@ domain_recv(PG_FUNCTION_ARGS) domainType = PG_GETARG_OID(1); /* - * We arrange to look up the needed info just once per series of - * calls, assuming the domain type doesn't change underneath us. + * We arrange to look up the needed info just once per series of calls, + * assuming the domain type doesn't change underneath us. */ my_extra = (DomainIOData *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 1f8d081c8bf..c4fbe89455c 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.128 2006/07/28 18:33:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.129 2006/10/04 00:29:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,11 +78,12 @@ #define HAVE_FINITE 1 #endif -/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0. NAN definition from +/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0. NAN definition from * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrfNotNumberNANItems.asp */ #if defined(WIN32) && !defined(NAN) static const uint32 nan[2] = {0xffffffff, 0x7fffffff}; + #define NAN (*(const double *) nan) #endif @@ -2137,7 +2138,7 @@ float8_stddev_samp(PG_FUNCTION_ARGS) * in that order. Note that Y is the first argument to the aggregates! * * It might seem attractive to optimize this by having multiple accumulator - * functions that only calculate the sums actually needed. But on most + * functions that only calculate the sums actually needed. But on most * modern machines, a couple of extra floating-point multiplies will be * insignificant compared to the other per-tuple overhead, so I've chosen * to minimize code space instead. @@ -2150,7 +2151,12 @@ float8_regr_accum(PG_FUNCTION_ARGS) float8 newvalY = PG_GETARG_FLOAT8(1); float8 newvalX = PG_GETARG_FLOAT8(2); float8 *transvalues; - float8 N, sumX, sumX2, sumY, sumY2, sumXY; + float8 N, + sumX, + sumX2, + sumY, + sumY2, + sumXY; transvalues = check_float8_array(transarray, "float8_regr_accum", 6); N = transvalues[0]; @@ -2265,7 +2271,11 @@ float8_regr_sxy(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumY, sumXY, numerator; + float8 N, + sumX, + sumY, + sumXY, + numerator; transvalues = check_float8_array(transarray, "float8_regr_sxy", 6); N = transvalues[0]; @@ -2327,7 +2337,11 @@ float8_covar_pop(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumY, sumXY, numerator; + float8 N, + sumX, + sumY, + sumXY, + numerator; transvalues = check_float8_array(transarray, "float8_covar_pop", 6); N = transvalues[0]; @@ -2349,7 +2363,11 @@ float8_covar_samp(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumY, sumXY, numerator; + float8 N, + sumX, + sumY, + sumXY, + numerator; transvalues = check_float8_array(transarray, "float8_covar_samp", 6); N = transvalues[0]; @@ -2371,8 +2389,15 @@ float8_corr(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumX2, sumY, sumY2, sumXY, numeratorX, - numeratorY, numeratorXY; + float8 N, + sumX, + sumX2, + sumY, + sumY2, + sumXY, + numeratorX, + numeratorY, + numeratorXY; transvalues = check_float8_array(transarray, "float8_corr", 6); N = transvalues[0]; @@ -2391,7 +2416,7 @@ float8_corr(PG_FUNCTION_ARGS) numeratorXY = N * sumXY - sumX * sumY; if (numeratorX <= 0 || numeratorY <= 0) PG_RETURN_NULL(); - + PG_RETURN_FLOAT8(sqrt((numeratorXY * numeratorXY) / (numeratorX * numeratorY))); } @@ -2401,8 +2426,15 @@ float8_regr_r2(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumX2, sumY, sumY2, sumXY, numeratorX, - numeratorY, numeratorXY; + float8 N, + sumX, + sumX2, + sumY, + sumY2, + sumXY, + numeratorX, + numeratorY, + numeratorXY; transvalues = check_float8_array(transarray, "float8_regr_r2", 6); N = transvalues[0]; @@ -2434,8 +2466,13 @@ float8_regr_slope(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumX2, sumY, sumXY, numeratorX, - numeratorXY; + float8 N, + sumX, + sumX2, + sumY, + sumXY, + numeratorX, + numeratorXY; transvalues = check_float8_array(transarray, "float8_regr_slope", 6); N = transvalues[0]; @@ -2452,7 +2489,7 @@ float8_regr_slope(PG_FUNCTION_ARGS) numeratorXY = N * sumXY - sumX * sumY; if (numeratorX <= 0) PG_RETURN_NULL(); - + PG_RETURN_FLOAT8(numeratorXY / numeratorX); } @@ -2461,8 +2498,13 @@ float8_regr_intercept(PG_FUNCTION_ARGS) { ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0); float8 *transvalues; - float8 N, sumX, sumX2, sumY, sumXY, numeratorX, - numeratorXXY; + float8 N, + sumX, + sumX2, + sumY, + sumXY, + numeratorX, + numeratorXXY; transvalues = check_float8_array(transarray, "float8_regr_intercept", 6); N = transvalues[0]; @@ -2479,7 +2521,7 @@ float8_regr_intercept(PG_FUNCTION_ARGS) numeratorXXY = sumY * sumX2 - sumX * sumXY; if (numeratorX <= 0) PG_RETURN_NULL(); - + PG_RETURN_FLOAT8(numeratorXXY / numeratorX); } @@ -2744,13 +2786,13 @@ cbrt(double x) double tmpres = pow(absx, (double) 1.0 / (double) 3.0); /* - * The result is somewhat inaccurate --- not really pow()'s fault, - * as the exponent it's handed contains roundoff error. We can improve - * the accuracy by doing one iteration of Newton's formula. Beware of - * zero input however. + * The result is somewhat inaccurate --- not really pow()'s fault, as the + * exponent it's handed contains roundoff error. We can improve the + * accuracy by doing one iteration of Newton's formula. Beware of zero + * input however. */ if (tmpres > 0.0) - tmpres -= (tmpres - absx/(tmpres*tmpres)) / (double) 3.0; + tmpres -= (tmpres - absx / (tmpres * tmpres)) / (double) 3.0; return isneg ? -tmpres : tmpres; } diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 53cf15319d4..d97c1bf405a 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.112 2006/09/10 22:54:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.113 2006/10/04 00:29:59 momjian Exp $ * * * Portions Copyright (c) 1999-2006, PostgreSQL Global Development Group @@ -83,7 +83,7 @@ #include "utils/numeric.h" #include "utils/pg_locale.h" -#define _(x) gettext((x)) +#define _(x) gettext((x)) /* ---------- * Routines type @@ -1708,7 +1708,7 @@ strdigits_len(char *str) len = strspace_len(str); p += len; - + while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ) { len++; @@ -1828,7 +1828,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, { sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 : - tm->tm_hour % (HOURS_PER_DAY / 2)); + tm->tm_hour % (HOURS_PER_DAY / 2)); if (S_THth(suf)) str_numth(p_inout, inout, 0); return strlen(p_inout); @@ -2084,8 +2084,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, tmfc = (TmFromChar *) data; /* - * In the FROM-char there is no difference between "January" or "JANUARY" or - * "january", all is before search convert to "first-upper". This + * In the FROM-char there is no difference between "January" or "JANUARY" + * or "january", all is before search convert to "first-upper". This * convention is used for MONTH, MON, DAY, DY */ if (!is_to_char) @@ -2863,7 +2863,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval) static char * localize_month_full(int index) { - char *m = NULL; + char *m = NULL; switch (index) { @@ -2911,7 +2911,7 @@ localize_month_full(int index) static char * localize_month(int index) { - char *m = NULL; + char *m = NULL; switch (index) { @@ -2959,7 +2959,7 @@ localize_month(int index) static char * localize_day_full(int index) { - char *d = NULL; + char *d = NULL; switch (index) { @@ -2992,7 +2992,7 @@ localize_day_full(int index) static char * localize_day(int index) { - char *d = NULL; + char *d = NULL; switch (index) { diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 0a93354697c..3970bda83d2 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.74 2006/06/12 16:28:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.75 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -209,10 +209,10 @@ int2vectorrecv(PG_FUNCTION_ARGS) int2vector *result; /* - * Normally one would call array_recv() using DirectFunctionCall3, - * but that does not work since array_recv wants to cache some data - * using fcinfo->flinfo->fn_extra. So we need to pass it our own - * flinfo parameter. + * Normally one would call array_recv() using DirectFunctionCall3, but + * that does not work since array_recv wants to cache some data using + * fcinfo->flinfo->fn_extra. So we need to pass it our own flinfo + * parameter. */ InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL); @@ -736,9 +736,10 @@ int4mul(PG_FUNCTION_ARGS) int32 result; #ifdef WIN32 + /* - * Win32 doesn't throw a catchable exception for - * SELECT -2147483648 * (-1); -- INT_MIN + * Win32 doesn't throw a catchable exception for SELECT -2147483648 * + * (-1); -- INT_MIN */ if (arg2 == -1 && arg1 == INT_MIN) ereport(ERROR, @@ -782,9 +783,10 @@ int4div(PG_FUNCTION_ARGS) errmsg("division by zero"))); #ifdef WIN32 + /* - * Win32 doesn't throw a catchable exception for - * SELECT -2147483648 / (-1); -- INT_MIN + * Win32 doesn't throw a catchable exception for SELECT -2147483648 / + * (-1); -- INT_MIN */ if (arg2 == -1 && arg1 == INT_MIN) ereport(ERROR, diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 00432994c5b..903d415327f 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 - * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.61 2006/07/28 18:33:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.62 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -696,7 +696,7 @@ int8inc(PG_FUNCTION_ARGS) /* * These functions are exactly like int8inc but are used for aggregates that - * count only non-null values. Since the functions are declared strict, + * count only non-null values. Since the functions are declared strict, * the null checks happen before we ever get here, and all we need do is * increment the state value. We could actually make these pg_proc entries * point right at int8inc, but then the opr_sanity regression test would diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index e2026218bf5..4223bffb188 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.65 2006/09/04 18:32:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.66 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,12 +66,12 @@ wchareq(char *p1, char *p2) /* * Formerly we had a routine iwchareq() here that tried to do case-insensitive - * comparison of multibyte characters. It did not work at all, however, + * comparison of multibyte characters. It did not work at all, however, * because it relied on tolower() which has a single-byte API ... and * towlower() wouldn't be much better since we have no suitably cheap way * of getting a single character transformed to the system's wchar_t format. * So now, we just downcase the strings using lower() and apply regular LIKE - * comparison. This should be revisited when we install better locale support. + * comparison. This should be revisited when we install better locale support. * * Note that MBMatchText and MBMatchTextIC do exactly the same thing now. * Is it worth refactoring to avoid duplicated code? They might become @@ -286,12 +286,12 @@ nameiclike(PG_FUNCTION_ARGS) else { /* Force inputs to lower case to achieve case insensitivity */ - text *strtext; + text *strtext; strtext = DatumGetTextP(DirectFunctionCall1(name_text, NameGetDatum(str))); strtext = DatumGetTextP(DirectFunctionCall1(lower, - PointerGetDatum(strtext))); + PointerGetDatum(strtext))); pat = DatumGetTextP(DirectFunctionCall1(lower, PointerGetDatum(pat))); @@ -327,12 +327,12 @@ nameicnlike(PG_FUNCTION_ARGS) else { /* Force inputs to lower case to achieve case insensitivity */ - text *strtext; + text *strtext; strtext = DatumGetTextP(DirectFunctionCall1(name_text, NameGetDatum(str))); strtext = DatumGetTextP(DirectFunctionCall1(lower, - PointerGetDatum(strtext))); + PointerGetDatum(strtext))); pat = DatumGetTextP(DirectFunctionCall1(lower, PointerGetDatum(pat))); diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index a9d8b8b88f4..8e0a7bcf98d 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2002-2006, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.26 2006/09/22 23:20:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.27 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -258,8 +258,8 @@ pg_lock_status(PG_FUNCTION_ARGS) else nulls[10] = 'n'; values[11] = DirectFunctionCall1(textin, - CStringGetDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock), - mode))); + CStringGetDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock), + mode))); values[12] = BoolGetDatum(granted); tuple = heap_formtuple(funcctx->tuple_desc, values, nulls); @@ -361,7 +361,7 @@ pg_try_advisory_lock_shared_int8(PG_FUNCTION_ARGS) } /* - * pg_advisory_unlock(int8) - release exclusive lock on an int8 key + * pg_advisory_unlock(int8) - release exclusive lock on an int8 key * * Returns true if successful, false if lock was not held */ @@ -473,7 +473,7 @@ pg_try_advisory_lock_shared_int4(PG_FUNCTION_ARGS) } /* - * pg_advisory_unlock(int4, int4) - release exclusive lock on 2 int4 keys + * pg_advisory_unlock(int4, int4) - release exclusive lock on 2 int4 keys * * Returns true if successful, false if lock was not held */ diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 22c8af482c1..014d2c8bf6d 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.53 2006/07/14 14:52:24 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.54 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -272,16 +272,16 @@ pg_sleep(PG_FUNCTION_ARGS) float8 endtime; /* - * We break the requested sleep into segments of no more than 1 second, - * to put an upper bound on how long it will take us to respond to a - * cancel or die interrupt. (Note that pg_usleep is interruptible by - * signals on some platforms but not others.) Also, this method avoids - * exposing pg_usleep's upper bound on allowed delays. + * We break the requested sleep into segments of no more than 1 second, to + * put an upper bound on how long it will take us to respond to a cancel + * or die interrupt. (Note that pg_usleep is interruptible by signals on + * some platforms but not others.) Also, this method avoids exposing + * pg_usleep's upper bound on allowed delays. * - * By computing the intended stop time initially, we avoid accumulation - * of extra delay across multiple sleeps. This also ensures we won't - * delay less than the specified time if pg_usleep is interrupted - * by other signals such as SIGHUP. + * By computing the intended stop time initially, we avoid accumulation of + * extra delay across multiple sleeps. This also ensures we won't delay + * less than the specified time if pg_usleep is interrupted by other + * signals such as SIGHUP. */ #ifdef HAVE_INT64_TIMESTAMP diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 2624c203f7c..bd7406bc2b5 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for the INET and CIDR types. * - * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.65 2006/02/11 20:39:58 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.66 2006/10/04 00:29:59 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -181,7 +181,7 @@ cidr_out(PG_FUNCTION_ARGS) * family, bits, is_cidr, address length, address in network byte order. * * Presence of is_cidr is largely for historical reasons, though it might - * allow some code-sharing on the client side. We send it correctly on + * allow some code-sharing on the client side. We send it correctly on * output, but ignore the value on input. */ static inet * @@ -201,14 +201,14 @@ network_recv(StringInfo buf, bool is_cidr) ip_family(addr) != PGSQL_AF_INET6) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - /* translator: %s is inet or cidr */ + /* translator: %s is inet or cidr */ errmsg("invalid address family in external \"%s\" value", is_cidr ? "cidr" : "inet"))); bits = pq_getmsgbyte(buf); if (bits < 0 || bits > ip_maxbits(addr)) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - /* translator: %s is inet or cidr */ + /* translator: %s is inet or cidr */ errmsg("invalid bits in external \"%s\" value", is_cidr ? "cidr" : "inet"))); ip_bits(addr) = bits; @@ -217,7 +217,7 @@ network_recv(StringInfo buf, bool is_cidr) if (nb != ip_addrsize(addr)) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - /* translator: %s is inet or cidr */ + /* translator: %s is inet or cidr */ errmsg("invalid length in external \"%s\" value", is_cidr ? "cidr" : "inet"))); VARATT_SIZEP(addr) = VARHDRSZ + @@ -1262,9 +1262,9 @@ inetnot(PG_FUNCTION_ARGS) dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); { - int nb = ip_addrsize(ip); - unsigned char *pip = ip_addr(ip); - unsigned char *pdst = ip_addr(dst); + int nb = ip_addrsize(ip); + unsigned char *pip = ip_addr(ip); + unsigned char *pdst = ip_addr(dst); while (nb-- > 0) pdst[nb] = ~pip[nb]; @@ -1295,10 +1295,10 @@ inetand(PG_FUNCTION_ARGS) errmsg("cannot AND inet values of different sizes"))); else { - int nb = ip_addrsize(ip); - unsigned char *pip = ip_addr(ip); - unsigned char *pip2 = ip_addr(ip2); - unsigned char *pdst = ip_addr(dst); + int nb = ip_addrsize(ip); + unsigned char *pip = ip_addr(ip); + unsigned char *pip2 = ip_addr(ip2); + unsigned char *pdst = ip_addr(dst); while (nb-- > 0) pdst[nb] = pip[nb] & pip2[nb]; @@ -1329,10 +1329,10 @@ inetor(PG_FUNCTION_ARGS) errmsg("cannot OR inet values of different sizes"))); else { - int nb = ip_addrsize(ip); - unsigned char *pip = ip_addr(ip); - unsigned char *pip2 = ip_addr(ip2); - unsigned char *pdst = ip_addr(dst); + int nb = ip_addrsize(ip); + unsigned char *pip = ip_addr(ip); + unsigned char *pip2 = ip_addr(ip2); + unsigned char *pdst = ip_addr(dst); while (nb-- > 0) pdst[nb] = pip[nb] | pip2[nb]; @@ -1356,32 +1356,34 @@ internal_inetpl(inet *ip, int64 addend) dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); { - int nb = ip_addrsize(ip); - unsigned char *pip = ip_addr(ip); - unsigned char *pdst = ip_addr(dst); - int carry = 0; + int nb = ip_addrsize(ip); + unsigned char *pip = ip_addr(ip); + unsigned char *pdst = ip_addr(dst); + int carry = 0; while (nb-- > 0) { carry = pip[nb] + (int) (addend & 0xFF) + carry; pdst[nb] = (unsigned char) (carry & 0xFF); carry >>= 8; + /* * We have to be careful about right-shifting addend because - * right-shift isn't portable for negative values, while - * simply dividing by 256 doesn't work (the standard rounding - * is in the wrong direction, besides which there may be machines - * out there that round the wrong way). So, explicitly clear - * the low-order byte to remove any doubt about the correct - * result of the division, and then divide rather than shift. + * right-shift isn't portable for negative values, while simply + * dividing by 256 doesn't work (the standard rounding is in the + * wrong direction, besides which there may be machines out there + * that round the wrong way). So, explicitly clear the low-order + * byte to remove any doubt about the correct result of the + * division, and then divide rather than shift. */ addend &= ~((int64) 0xFF); addend /= 0x100; } + /* - * At this point we should have addend and carry both zero if - * original addend was >= 0, or addend -1 and carry 1 if original - * addend was < 0. Anything else means overflow. + * At this point we should have addend and carry both zero if original + * addend was >= 0, or addend -1 and carry 1 if original addend was < + * 0. Anything else means overflow. */ if (!((addend == 0 && carry == 0) || (addend == -1 && carry == 1))) @@ -1403,8 +1405,8 @@ internal_inetpl(inet *ip, int64 addend) Datum inetpl(PG_FUNCTION_ARGS) { - inet *ip = PG_GETARG_INET_P(0); - int64 addend = PG_GETARG_INT64(1); + inet *ip = PG_GETARG_INET_P(0); + int64 addend = PG_GETARG_INT64(1); PG_RETURN_INET_P(internal_inetpl(ip, addend)); } @@ -1413,8 +1415,8 @@ inetpl(PG_FUNCTION_ARGS) Datum inetmi_int8(PG_FUNCTION_ARGS) { - inet *ip = PG_GETARG_INET_P(0); - int64 addend = PG_GETARG_INT64(1); + inet *ip = PG_GETARG_INET_P(0); + int64 addend = PG_GETARG_INT64(1); PG_RETURN_INET_P(internal_inetpl(ip, -addend)); } @@ -1434,20 +1436,20 @@ inetmi(PG_FUNCTION_ARGS) else { /* - * We form the difference using the traditional complement, - * increment, and add rule, with the increment part being handled - * by starting the carry off at 1. If you don't think integer - * arithmetic is done in two's complement, too bad. + * We form the difference using the traditional complement, increment, + * and add rule, with the increment part being handled by starting the + * carry off at 1. If you don't think integer arithmetic is done in + * two's complement, too bad. */ - int nb = ip_addrsize(ip); - int byte = 0; - unsigned char *pip = ip_addr(ip); - unsigned char *pip2 = ip_addr(ip2); - int carry = 1; + int nb = ip_addrsize(ip); + int byte = 0; + unsigned char *pip = ip_addr(ip); + unsigned char *pip2 = ip_addr(ip2); + int carry = 1; while (nb-- > 0) { - int lobyte; + int lobyte; carry = pip[nb] + (~pip2[nb] & 0xFF) + carry; lobyte = carry & 0xFF; @@ -1458,9 +1460,9 @@ inetmi(PG_FUNCTION_ARGS) else { /* - * Input wider than int64: check for overflow. All bytes - * to the left of what will fit should be 0 or 0xFF, - * depending on sign of the now-complete result. + * Input wider than int64: check for overflow. All bytes to + * the left of what will fit should be 0 or 0xFF, depending on + * sign of the now-complete result. */ if ((res < 0) ? (lobyte != 0xFF) : (lobyte != 0)) ereport(ERROR, @@ -1472,8 +1474,8 @@ inetmi(PG_FUNCTION_ARGS) } /* - * If input is narrower than int64, overflow is not possible, but - * we have to do proper sign extension. + * If input is narrower than int64, overflow is not possible, but we + * have to do proper sign extension. */ if (carry == 0 && byte < sizeof(int64)) res |= ((int64) -1) << (byte * 8); diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 6d77c49c123..35b0221b85d 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2006, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.95 2006/10/03 21:25:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.96 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -253,10 +253,10 @@ static double numericvar_to_double_no_overflow(NumericVar *var); static int cmp_numerics(Numeric num1, Numeric num2); static int cmp_var(NumericVar *var1, NumericVar *var2); -static int cmp_var_common(const NumericDigit *var1digits, int var1ndigits, - int var1weight, int var1sign, - const NumericDigit *var2digits, int var2ndigits, - int var2weight, int var2sign); +static int cmp_var_common(const NumericDigit *var1digits, int var1ndigits, + int var1weight, int var1sign, + const NumericDigit *var2digits, int var2ndigits, + int var2weight, int var2sign); 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, @@ -278,10 +278,10 @@ static void power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale); static int cmp_abs(NumericVar *var1, NumericVar *var2); -static int cmp_abs_common(const NumericDigit *var1digits, int var1ndigits, - int var1weight, - const NumericDigit *var2digits, int var2ndigits, - int var2weight); +static int cmp_abs_common(const NumericDigit *var1digits, int var1ndigits, + int var1weight, + const NumericDigit *var2digits, int var2ndigits, + int var2weight); static void add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result); static void sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result); static void round_var(NumericVar *var, int rscale); @@ -2228,9 +2228,8 @@ numeric_stddev_internal(ArrayType *transarray, set_var_from_num(N, &vN); /* - * Sample stddev and variance are undefined when N <= 1; - * population stddev is undefined when N == 0. Return NULL in - * either case. + * Sample stddev and variance are undefined when N <= 1; population stddev + * is undefined when N == 0. Return NULL in either case. */ if (sample) comp = &const_one; @@ -2257,7 +2256,7 @@ numeric_stddev_internal(ArrayType *transarray, mul_var(&vsumX, &vsumX, &vsumX, rscale); /* vsumX = sumX * sumX */ mul_var(&vN, &vsumX2, &vsumX2, rscale); /* vsumX2 = N * sumX2 */ - sub_var(&vsumX2, &vsumX, &vsumX2); /* N * sumX2 - sumX * sumX */ + sub_var(&vsumX2, &vsumX, &vsumX2); /* N * sumX2 - sumX * sumX */ if (cmp_var(&vsumX2, &const_zero) <= 0) { @@ -2266,11 +2265,11 @@ numeric_stddev_internal(ArrayType *transarray, } else { - mul_var(&vN, &vNminus1, &vNminus1, 0); /* N * (N - 1) */ + mul_var(&vN, &vNminus1, &vNminus1, 0); /* N * (N - 1) */ rscale = select_div_scale(&vsumX2, &vNminus1); - div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ + div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ if (!variance) - sqrt_var(&vsumX, &vsumX, rscale); /* stddev */ + sqrt_var(&vsumX, &vsumX, rscale); /* stddev */ res = make_result(&vsumX); } @@ -2286,8 +2285,8 @@ numeric_stddev_internal(ArrayType *transarray, Datum numeric_var_samp(PG_FUNCTION_ARGS) { - Numeric res; - bool is_null; + Numeric res; + bool is_null; res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0), true, true, &is_null); @@ -2301,8 +2300,8 @@ numeric_var_samp(PG_FUNCTION_ARGS) Datum numeric_stddev_samp(PG_FUNCTION_ARGS) { - Numeric res; - bool is_null; + Numeric res; + bool is_null; res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0), false, true, &is_null); @@ -2316,8 +2315,8 @@ numeric_stddev_samp(PG_FUNCTION_ARGS) Datum numeric_var_pop(PG_FUNCTION_ARGS) { - Numeric res; - bool is_null; + Numeric res; + bool is_null; res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0), true, false, &is_null); @@ -2331,8 +2330,8 @@ numeric_var_pop(PG_FUNCTION_ARGS) Datum numeric_stddev_pop(PG_FUNCTION_ARGS) { - Numeric res; - bool is_null; + Numeric res; + bool is_null; res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0), false, false, &is_null); @@ -3219,7 +3218,7 @@ apply_typmod(NumericVar *var, int32 typmod) errmsg("numeric field overflow"), errdetail("A field with precision %d, scale %d must round to an absolute value less than %s%d.", precision, scale, - /* Display 10^0 as 1 */ + /* Display 10^0 as 1 */ maxdigits ? "10^" : "", maxdigits ? maxdigits : 1 ))); @@ -3415,8 +3414,8 @@ cmp_var(NumericVar *var1, NumericVar *var2) /* * cmp_var_common() - * - * Main routine of cmp_var(). This function can be used by both - * NumericVar and Numeric. + * Main routine of cmp_var(). This function can be used by both + * NumericVar and Numeric. */ static int cmp_var_common(const NumericDigit *var1digits, int var1ndigits, @@ -4853,13 +4852,13 @@ cmp_abs(NumericVar *var1, NumericVar *var2) /* ---------- * cmp_abs_common() - * - * Main routine of cmp_abs(). This function can be used by both - * NumericVar and Numeric. + * Main routine of cmp_abs(). This function can be used by both + * NumericVar and Numeric. * ---------- */ static int cmp_abs_common(const NumericDigit *var1digits, int var1ndigits, int var1weight, - const NumericDigit *var2digits, int var2ndigits, int var2weight) + const NumericDigit *var2digits, int var2ndigits, int var2weight) { int i1 = 0; int i2 = 0; diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index 8ba769fafa3..20142cb771a 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.68 2006/03/05 15:58:43 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.69 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -258,10 +258,10 @@ oidvectorrecv(PG_FUNCTION_ARGS) oidvector *result; /* - * Normally one would call array_recv() using DirectFunctionCall3, - * but that does not work since array_recv wants to cache some data - * using fcinfo->flinfo->fn_extra. So we need to pass it our own - * flinfo parameter. + * Normally one would call array_recv() using DirectFunctionCall3, but + * that does not work since array_recv wants to cache some data using + * fcinfo->flinfo->fn_extra. So we need to pass it our own flinfo + * parameter. */ InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL); diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index aa08c7bc8d0..da81d79f392 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 2002-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.36 2006/06/03 17:36:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.37 2006/10/04 00:29:59 momjian Exp $ * *----------------------------------------------------------------------- */ @@ -70,6 +70,7 @@ static bool CurrentLocaleConvValid = false; static char lc_collate_envbuf[LC_ENV_BUFSIZE]; static char lc_ctype_envbuf[LC_ENV_BUFSIZE]; + #ifdef LC_MESSAGES static char lc_messages_envbuf[LC_ENV_BUFSIZE]; #endif @@ -93,18 +94,19 @@ static char lc_time_envbuf[LC_ENV_BUFSIZE]; char * pg_perm_setlocale(int category, const char *locale) { - char *result; + char *result; const char *envvar; - char *envbuf; + char *envbuf; #ifndef WIN32 result = setlocale(category, locale); #else + /* - * On Windows, setlocale(LC_MESSAGES) does not work, so just assume - * that the given value is good and set it in the environment variables. - * We must ignore attempts to set to "", which means "keep using the - * old environment value". + * On Windows, setlocale(LC_MESSAGES) does not work, so just assume that + * the given value is good and set it in the environment variables. We + * must ignore attempts to set to "", which means "keep using the old + * environment value". */ #ifdef LC_MESSAGES if (category == LC_MESSAGES) @@ -116,7 +118,7 @@ pg_perm_setlocale(int category, const char *locale) else #endif result = setlocale(category, locale); -#endif /* WIN32 */ +#endif /* WIN32 */ if (result == NULL) return result; /* fall out immediately on failure */ @@ -156,12 +158,13 @@ pg_perm_setlocale(int category, const char *locale) break; } - snprintf(envbuf, LC_ENV_BUFSIZE-1, "%s=%s", envvar, result); + snprintf(envbuf, LC_ENV_BUFSIZE - 1, "%s=%s", envvar, result); #ifndef WIN32 if (putenv(envbuf)) return NULL; #else + /* * On Windows, we need to modify both the process environment and the * cached version in msvcrt @@ -251,8 +254,8 @@ locale_messages_assign(const char *value, bool doit, GucSource source) /* * LC_MESSAGES category does not exist everywhere, but accept it anyway * - * On Windows, we can't even check the value, so the non-doit case - * is a no-op + * On Windows, we can't even check the value, so the non-doit case is a + * no-op */ #ifdef LC_MESSAGES if (doit) diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index d14a4c8e2f6..e2d302b5a64 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.33 2006/08/19 01:36:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.34 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -186,7 +186,7 @@ Datum pg_stat_get_last_vacuum_time(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); - TimestampTz result; + TimestampTz result; PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) @@ -204,7 +204,7 @@ Datum pg_stat_get_last_autovacuum_time(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); - TimestampTz result; + TimestampTz result; PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) @@ -222,7 +222,7 @@ Datum pg_stat_get_last_analyze_time(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); - TimestampTz result; + TimestampTz result; PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) @@ -240,7 +240,7 @@ Datum pg_stat_get_last_autoanalyze_time(PG_FUNCTION_ARGS) { Oid relid = PG_GETARG_OID(0); - TimestampTz result; + TimestampTz result; PgStat_StatTabEntry *tabentry; if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index a7d11eaa6d5..d249772064b 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.65 2006/07/14 14:52:24 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.66 2006/10/04 00:29:59 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -554,7 +554,7 @@ similar_escape(PG_FUNCTION_ARGS) * which is bizarre enough to require some explanation. "***:" is a * director prefix to force the regex to be treated as an ARE regardless * of the current regex_flavor setting. We need "^" and "$" to force - * the pattern to match the entire input string as per SQL99 spec. The + * the pattern to match the entire input string as per SQL99 spec. The * "(?:" and ")" are a non-capturing set of parens; we have to have * parens in case the string contains "|", else the "^" and "$" will * be bound into the first and last alternatives which is not what we diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index b58b99d2c8b..747ef66bf77 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-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.88 2006/08/27 21:41:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.89 2006/10/04 00:29:59 momjian Exp $ * * ---------- */ @@ -214,17 +214,17 @@ 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 (so the deferred check should be skipped) - * or updated (in which case only the latest version of the row should - * be checked). Test its liveness with HeapTupleSatisfiesItself. + * or updated (in which case only the latest version of the row should be + * checked). Test its liveness with HeapTupleSatisfiesItself. * * NOTE: The normal coding rule is that one must acquire the buffer - * content lock to call HeapTupleSatisfiesFOO. We can skip that here + * content lock to call HeapTupleSatisfiesFOO. We can skip that here * because we know that AfterTriggerExecute just fetched the tuple - * successfully, so there cannot be a VACUUM compaction in progress - * on the page (either heap_fetch would have waited for the VACUUM, - * or the VACUUM's LockBufferForCleanup would be waiting for us to drop - * pin). And since this is a row inserted by our open transaction, - * no one else can be entitled to change its xmin/xmax. + * successfully, so there cannot be a VACUUM compaction in progress on the + * page (either heap_fetch would have waited for the VACUUM, or the + * VACUUM's LockBufferForCleanup would be waiting for us to drop pin). + * And since this is a row inserted by our open transaction, no one else + * can be entitled to change its xmin/xmax. */ Assert(new_row_buf != InvalidBuffer); if (!HeapTupleSatisfiesItself(new_row->t_data, new_row_buf)) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 821cc99e9f2..f5b42524be7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2,7 +2,7 @@ * ruleutils.c - Functions to convert stored expressions/querytrees * back to source text * - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.233 2006/10/01 17:23:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.234 2006/10/04 00:29:59 momjian Exp $ **********************************************************************/ #include "postgres.h" @@ -141,7 +141,7 @@ static void get_utility_query_def(Query *query, deparse_context *context); static void get_basic_select_query(Query *query, deparse_context *context, TupleDesc resultDesc); static void get_target_list(List *targetList, deparse_context *context, - TupleDesc resultDesc); + TupleDesc resultDesc); static void get_setop_query(Node *setOp, Query *query, deparse_context *context, TupleDesc resultDesc); @@ -176,7 +176,7 @@ static void get_from_clause_coldeflist(List *names, List *types, List *typmods, static void get_opclass_name(Oid opclass, Oid actual_datatype, StringInfo buf); static Node *processIndirection(Node *node, deparse_context *context, - bool printit); + bool printit); static void printSubscripts(ArrayRef *aref, deparse_context *context); static char *generate_relation_name(Oid relid); static char *generate_function_name(Oid funcid, int nargs, Oid *argtypes); @@ -530,10 +530,11 @@ pg_get_triggerdef(PG_FUNCTION_ARGS) { if (i > 0) appendStringInfo(&buf, ", "); + /* * We form the string literal according to the prevailing setting - * of standard_conforming_strings; we never use E''. - * User is responsible for making sure result is used correctly. + * of standard_conforming_strings; we never use E''. User is + * responsible for making sure result is used correctly. */ appendStringInfoChar(&buf, '\''); while (*p) @@ -1017,7 +1018,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, if (fullCommand && OidIsValid(conForm->conrelid)) { - char *options = flatten_reloptions(conForm->conrelid); + char *options = flatten_reloptions(conForm->conrelid); if (options) { @@ -1467,9 +1468,9 @@ deparse_context_for_subplan(const char *name, Node *subplan) RangeTblEntry *rte = makeNode(RangeTblEntry); /* - * We create an RTE_SPECIAL RangeTblEntry, and store the subplan in - * its funcexpr field. RTE_SPECIAL nodes shouldn't appear in - * deparse contexts otherwise. + * We create an RTE_SPECIAL RangeTblEntry, and store the subplan in its + * funcexpr field. RTE_SPECIAL nodes shouldn't appear in deparse contexts + * otherwise. */ rte->rtekind = RTE_SPECIAL; rte->relid = InvalidOid; @@ -1831,7 +1832,7 @@ get_values_def(List *values_lists, deparse_context *context) appendStringInfoChar(buf, '('); foreach(lc, sublist) { - Node *col = (Node *) lfirst(lc); + Node *col = (Node *) lfirst(lc); if (first_col) first_col = false; @@ -1964,10 +1965,10 @@ get_basic_select_query(Query *query, deparse_context *context, } /* - * If the query looks like SELECT * FROM (VALUES ...), then print just - * the VALUES part. This reverses what transformValuesClause() did at - * parse time. If the jointree contains just a single VALUES RTE, - * we assume this case applies (without looking at the targetlist...) + * If the query looks like SELECT * FROM (VALUES ...), then print just the + * VALUES part. This reverses what transformValuesClause() did at parse + * time. If the jointree contains just a single VALUES RTE, we assume + * this case applies (without looking at the targetlist...) */ if (list_length(query->jointree->fromlist) == 1) { @@ -2083,10 +2084,10 @@ get_target_list(List *targetList, deparse_context *context, colno++; /* - * We special-case Var nodes rather than using get_rule_expr. - * This is needed because get_rule_expr will display a whole-row Var - * as "foo.*", which is the preferred notation in most contexts, but - * at the top level of a SELECT list it's not right (the parser will + * We special-case Var nodes rather than using get_rule_expr. This is + * needed because get_rule_expr will display a whole-row Var as + * "foo.*", which is the preferred notation in most contexts, but at + * the top level of a SELECT list it's not right (the parser will * expand that notation into multiple columns, yielding behavior * different from a whole-row Var). We want just "foo", instead. */ @@ -2287,8 +2288,8 @@ get_insert_query_def(Query *query, deparse_context *context) List *strippedexprs; /* - * If it's an INSERT ... SELECT or VALUES (...), (...), ... - * there will be a single RTE for the SELECT or VALUES. + * If it's an INSERT ... SELECT or VALUES (...), (...), ... there will be + * a single RTE for the SELECT or VALUES. */ foreach(l, query->rtable) { @@ -2300,7 +2301,7 @@ get_insert_query_def(Query *query, deparse_context *context) elog(ERROR, "too many subquery RTEs in INSERT"); select_rte = rte; } - + if (rte->rtekind == RTE_VALUES) { if (values_rte) @@ -2326,12 +2327,12 @@ get_insert_query_def(Query *query, deparse_context *context) generate_relation_name(rte->relid)); /* - * Add the insert-column-names list. To handle indirection properly, - * we need to look for indirection nodes in the top targetlist (if it's + * Add the insert-column-names list. To handle indirection properly, we + * need to look for indirection nodes in the top targetlist (if it's * INSERT ... SELECT or INSERT ... single VALUES), or in the first - * expression list of the VALUES RTE (if it's INSERT ... multi VALUES). - * We assume that all the expression lists will have similar indirection - * in the latter case. + * expression list of the VALUES RTE (if it's INSERT ... multi VALUES). We + * assume that all the expression lists will have similar indirection in + * the latter case. */ if (values_rte) values_cell = list_head((List *) linitial(values_rte->values_lists)); @@ -2589,10 +2590,10 @@ get_rte_for_var(Var *var, int levelsup, deparse_context *context, /* * Try to find the relevant RTE in this rtable. In a plan tree, it's - * likely that varno is OUTER, INNER, or 0, in which case we try to - * use varnoold instead. If the Var references an expression computed - * by a subplan, varnoold will be 0, and we fall back to looking at the - * special subplan RTEs. + * likely that varno is OUTER, INNER, or 0, in which case we try to use + * varnoold instead. If the Var references an expression computed by a + * subplan, varnoold will be 0, and we fall back to looking at the special + * subplan RTEs. */ if (var->varno >= 1 && var->varno <= list_length(dpns->rtable)) rte = rt_fetch(var->varno, dpns->rtable); @@ -2692,10 +2693,10 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context, /* * This case occurs during EXPLAIN when we are looking at a * deparse context node set up by deparse_context_for_subplan(). - * If the subplan tlist provides a name, use it, but usually - * we'll end up with "?columnN?". + * If the subplan tlist provides a name, use it, but usually we'll + * end up with "?columnN?". */ - List *tlist = ((Plan *) rte->funcexpr)->targetlist; + List *tlist = ((Plan *) rte->funcexpr)->targetlist; TargetEntry *tle = get_tle_by_resno(tlist, attnum); if (tle && tle->resname) @@ -2704,7 +2705,7 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context, } else { - char buf[32]; + char buf[32]; snprintf(buf, sizeof(buf), "?column%d?", attnum); *attname = pstrdup(buf); @@ -2767,8 +2768,8 @@ get_name_for_var_field(Var *var, int fieldno, /* * This case should not occur: a column of a table or values list - * shouldn't have type RECORD. Fall through and fail - * (most likely) at the bottom. + * shouldn't have type RECORD. Fall through and fail (most + * likely) at the bottom. */ break; case RTE_SUBQUERY: @@ -2836,7 +2837,7 @@ get_name_for_var_field(Var *var, int fieldno, * that's not a Var, and then pass it to * get_expr_result_type(). */ - Plan *subplan = (Plan *) rte->funcexpr; + Plan *subplan = (Plan *) rte->funcexpr; for (;;) { @@ -3484,7 +3485,7 @@ get_rule_expr(Node *node, deparse_context *context, if (get_expr_result_type(arg, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) tupdesc = lookup_rowtype_tupdesc_copy(exprType(arg), - exprTypmod(arg)); + exprTypmod(arg)); Assert(tupdesc); /* Got the tupdesc, so we can extract the field name */ Assert(fno >= 1 && fno <= tupdesc->natts); @@ -3577,16 +3578,16 @@ get_rule_expr(Node *node, deparse_context *context, if (caseexpr->arg) { /* - * The parser should have produced WHEN clauses of - * the form "CaseTestExpr = RHS"; we want to show - * just the RHS. If the user wrote something silly - * like "CASE boolexpr WHEN TRUE THEN ...", then - * the optimizer's simplify_boolean_equality() may - * have reduced this to just "CaseTestExpr" or - * "NOT CaseTestExpr", for which we have to show - * "TRUE" or "FALSE". Also, depending on context - * the original CaseTestExpr might have been reduced - * to a Const (but we won't see "WHEN Const"). + * The parser should have produced WHEN clauses of the + * form "CaseTestExpr = RHS"; we want to show just the + * RHS. If the user wrote something silly like "CASE + * boolexpr WHEN TRUE THEN ...", then the optimizer's + * simplify_boolean_equality() may have reduced this + * to just "CaseTestExpr" or "NOT CaseTestExpr", for + * which we have to show "TRUE" or "FALSE". Also, + * depending on context the original CaseTestExpr + * might have been reduced to a Const (but we won't + * see "WHEN Const"). */ if (IsA(w, OpExpr)) { @@ -3719,17 +3720,18 @@ get_rule_expr(Node *node, deparse_context *context, get_rule_expr(e, context, true); sep = ", "; } + /* - * We assume that the name of the first-column operator - * will do for all the rest too. This is definitely - * open to failure, eg if some but not all operators - * were renamed since the construct was parsed, but there - * seems no way to be perfect. + * We assume that the name of the first-column operator will + * do for all the rest too. This is definitely open to + * failure, eg if some but not all operators were renamed + * since the construct was parsed, but there seems no way to + * be perfect. */ appendStringInfo(buf, ") %s ROW(", - generate_operator_name(linitial_oid(rcexpr->opnos), - exprType(linitial(rcexpr->largs)), - exprType(linitial(rcexpr->rargs)))); + generate_operator_name(linitial_oid(rcexpr->opnos), + exprType(linitial(rcexpr->largs)), + exprType(linitial(rcexpr->rargs)))); sep = ""; foreach(arg, rcexpr->rargs) { @@ -4052,7 +4054,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context) } appendStringInfo(buf, "%s(%s", - generate_function_name(aggref->aggfnoid, nargs, argtypes), + generate_function_name(aggref->aggfnoid, nargs, argtypes), aggref->aggdistinct ? "DISTINCT " : ""); /* aggstar can be set only in zero-argument aggregates */ if (aggref->aggstar) @@ -4142,8 +4144,8 @@ get_const_expr(Const *constval, deparse_context *context) /* * We form the string literal according to the prevailing setting - * of standard_conforming_strings; we never use E''. - * User is responsible for making sure result is used correctly. + * of standard_conforming_strings; we never use E''. User is + * responsible for making sure result is used correctly. */ appendStringInfoChar(buf, '\''); for (valptr = extval; *valptr; valptr++) @@ -4205,18 +4207,18 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) appendStringInfoChar(buf, '('); /* - * Note that we print the name of only the first operator, when there - * are multiple combining operators. This is an approximation that - * could go wrong in various scenarios (operators in different schemas, - * renamed operators, etc) but there is not a whole lot we can do about - * it, since the syntax allows only one operator to be shown. + * Note that we print the name of only the first operator, when there are + * multiple combining operators. This is an approximation that could go + * wrong in various scenarios (operators in different schemas, renamed + * operators, etc) but there is not a whole lot we can do about it, since + * the syntax allows only one operator to be shown. */ if (sublink->testexpr) { if (IsA(sublink->testexpr, OpExpr)) { /* single combining operator */ - OpExpr *opexpr = (OpExpr *) sublink->testexpr; + OpExpr *opexpr = (OpExpr *) sublink->testexpr; get_rule_expr(linitial(opexpr->args), context, true); opname = generate_operator_name(opexpr->opno, @@ -4233,7 +4235,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) sep = ""; foreach(l, ((BoolExpr *) sublink->testexpr)->args) { - OpExpr *opexpr = (OpExpr *) lfirst(l); + OpExpr *opexpr = (OpExpr *) lfirst(l); Assert(IsA(opexpr, OpExpr)); appendStringInfoString(buf, sep); @@ -4255,7 +4257,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) get_rule_expr((Node *) rcexpr->largs, context, true); opname = generate_operator_name(linitial_oid(rcexpr->opnos), exprType(linitial(rcexpr->largs)), - exprType(linitial(rcexpr->rargs))); + exprType(linitial(rcexpr->rargs))); appendStringInfoChar(buf, ')'); } else @@ -5129,8 +5131,8 @@ flatten_reloptions(Oid relid) Anum_pg_class_reloptions, &isnull); if (!isnull) { - Datum sep, - txt; + Datum sep, + txt; /* * We want to use array_to_text(reloptions, ', ') --- but diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 44879d20a28..4eed9619b70 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.213 2006/09/20 19:50:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.214 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -101,8 +101,8 @@ static double ineq_histogram_selectivity(VariableStatData *vardata, - FmgrInfo *opproc, bool isgt, - Datum constval, Oid consttype); + FmgrInfo *opproc, bool isgt, + Datum constval, Oid consttype); static bool convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, Datum lobound, Datum hibound, Oid boundstypid, double *scaledlobound, double *scaledhibound); @@ -128,7 +128,7 @@ static double convert_timevalue_to_scalar(Datum value, Oid typid); static bool get_variable_maximum(PlannerInfo *root, VariableStatData *vardata, Oid sortop, Datum *max); static Selectivity prefix_selectivity(VariableStatData *vardata, - Oid opclass, Const *prefixcon); + Oid opclass, Const *prefixcon); static Selectivity pattern_selectivity(Const *patt, Pattern_Type ptype); static Datum string_to_datum(const char *str, Oid datatype); static Const *string_to_const(const char *str, Oid datatype); @@ -315,10 +315,9 @@ eqsel(PG_FUNCTION_ARGS) else { /* - * No ANALYZE stats available, so make a guess using estimated - * number of distinct values and assuming they are equally common. - * (The guess is unlikely to be very good, but we do know a few - * special cases.) + * No ANALYZE stats available, so make a guess using estimated number + * of distinct values and assuming they are equally common. (The guess + * is unlikely to be very good, but we do know a few special cases.) */ selec = 1.0 / get_variable_numdistinct(&vardata); } @@ -523,7 +522,7 @@ mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, * * Note that the result disregards both the most-common-values (if any) and * null entries. The caller is expected to combine this result with - * statistics for those portions of the column population. It may also be + * statistics for those portions of the column population. It may also be * prudent to clamp the result range, ie, disbelieve exact 0 or 1 outputs. */ double @@ -618,20 +617,20 @@ ineq_histogram_selectivity(VariableStatData *vardata, if (nvalues > 1) { /* - * Use binary search to find proper location, ie, the first - * slot at which the comparison fails. (If the given operator - * isn't actually sort-compatible with the histogram, you'll - * get garbage results ... but probably not any more garbage-y - * than you would from the old linear search.) + * Use binary search to find proper location, ie, the first slot + * at which the comparison fails. (If the given operator isn't + * actually sort-compatible with the histogram, you'll get garbage + * results ... but probably not any more garbage-y than you would + * from the old linear search.) */ - double histfrac; - int lobound = 0; /* first possible slot to search */ - int hibound = nvalues; /* last+1 slot to search */ + double histfrac; + int lobound = 0; /* first possible slot to search */ + int hibound = nvalues; /* last+1 slot to search */ while (lobound < hibound) { - int probe = (lobound + hibound) / 2; - bool ltcmp; + int probe = (lobound + hibound) / 2; + bool ltcmp; ltcmp = DatumGetBool(FunctionCall2(opproc, values[probe], @@ -688,10 +687,10 @@ ineq_histogram_selectivity(VariableStatData *vardata, binfrac = (val - low) / (high - low); /* - * Watch out for the possibility that we got a NaN - * or Infinity from the division. This can happen - * despite the previous checks, if for example - * "low" is -Infinity. + * Watch out for the possibility that we got a NaN or + * Infinity from the division. This can happen + * despite the previous checks, if for example "low" + * is -Infinity. */ if (isnan(binfrac) || binfrac < 0.0 || binfrac > 1.0) @@ -701,20 +700,20 @@ ineq_histogram_selectivity(VariableStatData *vardata, else { /* - * Ideally we'd produce an error here, on the grounds - * that the given operator shouldn't have scalarXXsel - * registered as its selectivity func unless we can - * deal with its operand types. But currently, all - * manner of stuff is invoking scalarXXsel, so give a - * default estimate until that can be fixed. + * Ideally we'd produce an error here, on the grounds that + * the given operator shouldn't have scalarXXsel + * registered as its selectivity func unless we can deal + * with its operand types. But currently, all manner of + * stuff is invoking scalarXXsel, so give a default + * estimate until that can be fixed. */ binfrac = 0.5; } /* * Now, compute the overall selectivity across the values - * represented by the histogram. We have i-1 full bins - * and binfrac partial bin below the constant. + * represented by the histogram. We have i-1 full bins and + * binfrac partial bin below the constant. */ histfrac = (double) (i - 1) + binfrac; histfrac /= (double) (nvalues - 1); @@ -1093,7 +1092,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) /* * If we have most-common-values info, add up the fractions of the MCV * entries that satisfy MCV OP PATTERN. These fractions contribute - * directly to the result selectivity. Also add up the total fraction + * directly to the result selectivity. Also add up the total fraction * represented by MCV entries. */ mcv_selec = mcv_selectivity(&vardata, &opproc, constval, true, @@ -1467,11 +1466,11 @@ scalararraysel(PlannerInfo *root, RegProcedure oprsel; FmgrInfo oprselproc; Datum selarg4; - Selectivity s1; + Selectivity s1; /* - * First, look up the underlying operator's selectivity estimator. - * Punt if it hasn't got one. + * First, look up the underlying operator's selectivity estimator. Punt if + * it hasn't got one. */ if (is_join_clause) { @@ -1491,9 +1490,8 @@ scalararraysel(PlannerInfo *root, * We consider three cases: * * 1. rightop is an Array constant: deconstruct the array, apply the - * operator's selectivity function for each array element, and merge - * the results in the same way that clausesel.c does for AND/OR - * combinations. + * operator's selectivity function for each array element, and merge the + * results in the same way that clausesel.c does for AND/OR combinations. * * 2. rightop is an ARRAY[] construct: apply the operator's selectivity * function for each element of the ARRAY[] construct, and merge. @@ -1529,7 +1527,7 @@ scalararraysel(PlannerInfo *root, s1 = useOr ? 0.0 : 1.0; for (i = 0; i < num_elems; i++) { - List *args; + List *args; Selectivity s2; args = list_make2(leftop, @@ -1562,7 +1560,7 @@ scalararraysel(PlannerInfo *root, s1 = useOr ? 0.0 : 1.0; foreach(l, arrayexpr->elements) { - List *args; + List *args; Selectivity s2; args = list_make2(leftop, lfirst(l)); @@ -1580,14 +1578,14 @@ scalararraysel(PlannerInfo *root, else { CaseTestExpr *dummyexpr; - List *args; + List *args; Selectivity s2; - int i; + int i; /* * We need a dummy rightop to pass to the operator selectivity - * routine. It can be pretty much anything that doesn't look like - * a constant; CaseTestExpr is a convenient choice. + * routine. It can be pretty much anything that doesn't look like a + * constant; CaseTestExpr is a convenient choice. */ dummyexpr = makeNode(CaseTestExpr); dummyexpr->typeId = get_element_type(exprType(rightop)); @@ -1599,9 +1597,10 @@ scalararraysel(PlannerInfo *root, PointerGetDatum(args), selarg4)); s1 = useOr ? 0.0 : 1.0; + /* - * Arbitrarily assume 10 elements in the eventual array value - * (see also estimate_array_length) + * Arbitrarily assume 10 elements in the eventual array value (see + * also estimate_array_length) */ for (i = 0; i < 10; i++) { @@ -3050,14 +3049,19 @@ convert_string_datum(Datum value, Oid typid) * == as you'd expect. Can't any of these people program their way * out of a paper bag? */ -#if _MSC_VER == 1400 /* VS.Net 2005 */ - /* http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99694 */ +#if _MSC_VER == 1400 /* VS.Net 2005 */ + + /* + * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx + * ?FeedbackID=99694 + */ { - char x[1]; + char x[1]; + xfrmlen = strxfrm(x, val, 0); } #else - xfrmlen = strxfrm(NULL, val, 0); + xfrmlen = strxfrm(NULL, val, 0); #endif xfrmstr = (char *) palloc(xfrmlen + 1); xfrmlen2 = strxfrm(xfrmstr, val, xfrmlen + 1); @@ -3399,9 +3403,9 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, if (rte->inh) { /* - * XXX This means the Var represents a column of an append relation. - * Later add code to look at the member relations and try to derive - * some kind of combined statistics? + * XXX This means the Var represents a column of an append + * relation. Later add code to look at the member relations and + * try to derive some kind of combined statistics? */ } else if (rte->rtekind == RTE_RELATION) @@ -4154,7 +4158,7 @@ prefix_selectivity(VariableStatData *vardata, Oid opclass, Const *prefixcon) /* * Merge the two selectivities in the same way as for a range query - * (see clauselist_selectivity()). Note that we don't need to worry + * (see clauselist_selectivity()). Note that we don't need to worry * about double-exclusion of nulls, since ineq_histogram_selectivity * doesn't count those anyway. */ @@ -4162,8 +4166,8 @@ prefix_selectivity(VariableStatData *vardata, Oid opclass, Const *prefixcon) /* * A zero or negative prefixsel should be converted into a small - * positive value; we probably are dealing with a very tight range - * and got a bogus result due to roundoff errors. + * positive value; we probably are dealing with a very tight range and + * got a bogus result due to roundoff errors. */ if (prefixsel <= 0.0) prefixsel = 1.0e-10; @@ -4640,8 +4644,8 @@ genericcostestimate(PlannerInfo *root, selectivityQuals = indexQuals; /* - * Check for ScalarArrayOpExpr index quals, and estimate the number - * of index scans that will be performed. + * Check for ScalarArrayOpExpr index quals, and estimate the number of + * index scans that will be performed. */ num_sa_scans = 1; foreach(l, indexQuals) @@ -4651,7 +4655,7 @@ genericcostestimate(PlannerInfo *root, if (IsA(rinfo->clause, ScalarArrayOpExpr)) { ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) rinfo->clause; - int alength = estimate_array_length(lsecond(saop->args)); + int alength = estimate_array_length(lsecond(saop->args)); if (alength > 1) num_sa_scans *= alength; @@ -4679,8 +4683,8 @@ genericcostestimate(PlannerInfo *root, numIndexTuples = rint(numIndexTuples / num_sa_scans); /* - * We can bound the number of tuples by the index size in any case. - * Also, always estimate at least one tuple is touched, even when + * We can bound the number of tuples by the index size in any case. Also, + * always estimate at least one tuple is touched, even when * indexSelectivity estimate is tiny. */ if (numIndexTuples > index->tuples) @@ -4691,12 +4695,11 @@ genericcostestimate(PlannerInfo *root, /* * Estimate the number of index pages that will be retrieved. * - * We use the simplistic method of taking a pro-rata fraction of the - * total number of index pages. In effect, this counts only leaf pages - * and not any overhead such as index metapage or upper tree levels. - * In practice this seems a better approximation than charging for - * access to the upper levels, perhaps because those tend to stay in - * cache under load. + * We use the simplistic method of taking a pro-rata fraction of the total + * number of index pages. In effect, this counts only leaf pages and not + * any overhead such as index metapage or upper tree levels. In practice + * this seems a better approximation than charging for access to the upper + * levels, perhaps because those tend to stay in cache under load. */ if (index->pages > 1 && index->tuples > 1) numIndexPages = ceil(numIndexTuples * index->pages / index->tuples); @@ -4706,19 +4709,19 @@ genericcostestimate(PlannerInfo *root, /* * Now compute the disk access costs. * - * The above calculations are all per-index-scan. However, if we are - * in a nestloop inner scan, we can expect the scan to be repeated (with + * The above calculations are all per-index-scan. However, if we are in a + * nestloop inner scan, we can expect the scan to be repeated (with * different search keys) for each row of the outer relation. Likewise, - * ScalarArrayOpExpr quals result in multiple index scans. This - * creates the potential for cache effects to reduce the number of - * disk page fetches needed. We want to estimate the average per-scan - * I/O cost in the presence of caching. + * ScalarArrayOpExpr quals result in multiple index scans. This creates + * the potential for cache effects to reduce the number of disk page + * fetches needed. We want to estimate the average per-scan I/O cost in + * the presence of caching. * * We use the Mackert-Lohman formula (see costsize.c for details) to * estimate the total number of page fetches that occur. While this * wasn't what it was designed for, it seems a reasonable model anyway. - * Note that we are counting pages not tuples anymore, so we take - * N = T = index size, as if there were one "tuple" per page. + * Note that we are counting pages not tuples anymore, so we take N = T = + * index size, as if there were one "tuple" per page. */ if (outer_rel != NULL && outer_rel->rows > 1) { @@ -4745,9 +4748,9 @@ genericcostestimate(PlannerInfo *root, root); /* - * Now compute the total disk access cost, and then report a - * pro-rated share for each outer scan. (Don't pro-rate for - * ScalarArrayOpExpr, since that's internal to the indexscan.) + * Now compute the total disk access cost, and then report a pro-rated + * share for each outer scan. (Don't pro-rate for ScalarArrayOpExpr, + * since that's internal to the indexscan.) */ *indexTotalCost = (pages_fetched * random_page_cost) / num_outer_scans; } @@ -4761,20 +4764,20 @@ genericcostestimate(PlannerInfo *root, } /* - * A difficulty with the leaf-pages-only cost approach is that for - * small selectivities (eg, single index tuple fetched) all indexes - * will look equally attractive because we will estimate exactly 1 - * leaf page to be fetched. All else being equal, we should prefer - * physically smaller indexes over larger ones. (An index might be - * smaller because it is partial or because it contains fewer columns; - * presumably the other columns in the larger index aren't useful to - * the query, or the larger index would have better selectivity.) + * A difficulty with the leaf-pages-only cost approach is that for small + * selectivities (eg, single index tuple fetched) all indexes will look + * equally attractive because we will estimate exactly 1 leaf page to be + * fetched. All else being equal, we should prefer physically smaller + * indexes over larger ones. (An index might be smaller because it is + * partial or because it contains fewer columns; presumably the other + * columns in the larger index aren't useful to the query, or the larger + * index would have better selectivity.) * * We can deal with this by adding a very small "fudge factor" that * depends on the index size. The fudge factor used here is one - * random_page_cost per 100000 index pages, which should be small - * enough to not alter index-vs-seqscan decisions, but will prevent - * indexes of different sizes from looking exactly equally attractive. + * random_page_cost per 100000 index pages, which should be small enough + * to not alter index-vs-seqscan decisions, but will prevent indexes of + * different sizes from looking exactly equally attractive. */ *indexTotalCost += index->pages * random_page_cost / 100000.0; @@ -4841,8 +4844,8 @@ btcostestimate(PG_FUNCTION_ARGS) * For a RowCompareExpr, we consider only the first column, just as * rowcomparesel() does. * - * If there's a ScalarArrayOpExpr in the quals, we'll actually perform - * N index scans not one, but the ScalarArrayOpExpr's operator can be + * If there's a ScalarArrayOpExpr in the quals, we'll actually perform N + * index scans not one, but the ScalarArrayOpExpr's operator can be * considered to act the same as it normally does. */ indexBoundQuals = NIL; @@ -4960,9 +4963,9 @@ btcostestimate(PG_FUNCTION_ARGS) * ordering, but don't negate it entirely. Before 8.0 we divided the * correlation by the number of columns, but that seems too strong.) * - * We can skip all this if we found a ScalarArrayOpExpr, because then - * the call must be for a bitmap index scan, and the caller isn't going - * to care what the index correlation is. + * We can skip all this if we found a ScalarArrayOpExpr, because then the + * call must be for a bitmap index scan, and the caller isn't going to + * care what the index correlation is. */ if (found_saop) PG_RETURN_VOID(); diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 1362d0a3f87..33b551aed88 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.55 2006/08/25 04:06:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.56 2006/10/04 00:29:59 momjian Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -164,7 +164,7 @@ tideq(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) == 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) == 0); } Datum @@ -173,7 +173,7 @@ tidne(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) != 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) != 0); } Datum @@ -182,7 +182,7 @@ tidlt(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) < 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) < 0); } Datum @@ -191,7 +191,7 @@ tidle(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) <= 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) <= 0); } Datum @@ -200,7 +200,7 @@ tidgt(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) > 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) > 0); } Datum @@ -209,7 +209,7 @@ tidge(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) >= 0); + PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) >= 0); } Datum @@ -227,7 +227,7 @@ tidlarger(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1,arg2) >= 0 ? arg1 : arg2); + PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1, arg2) >= 0 ? arg1 : arg2); } Datum @@ -236,7 +236,7 @@ tidsmaller(PG_FUNCTION_ARGS) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0); ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1); - PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1,arg2) <= 0 ? arg1 : arg2); + PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1, arg2) <= 0 ? arg1 : arg2); } diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index fcd90432af9..e06fa99dc17 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.167 2006/09/05 01:13:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.168 2006/10/04 00:29:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1029,10 +1029,10 @@ timestamptz_to_time_t(TimestampTz t) #ifdef HAVE_INT64_TIMESTAMP result = (time_t) (t / USECS_PER_SEC + - ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)); + ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)); #else result = (time_t) (t + - ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)); + ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)); #endif return result; @@ -2015,7 +2015,7 @@ timestamp_mi(PG_FUNCTION_ARGS) * test=> SET timezone = 'EST5EDT'; * test=> SELECT * test-> ('2005-10-30 13:22:00-05'::timestamptz - - * test(> '2005-10-29 13:22:00-04'::timestamptz); + * test(> '2005-10-29 13:22:00-04'::timestamptz); * ?column? * ---------------- * 1 day 01:00:00 @@ -2027,7 +2027,7 @@ timestamp_mi(PG_FUNCTION_ARGS) * test-> ('2005-10-29 13:22:00-04'::timestamptz + * test(> ('2005-10-30 13:22:00-05'::timestamptz - * test(> '2005-10-29 13:22:00-04'::timestamptz)) at time zone 'EST'; - * timezone + * timezone * -------------------- * 2005-10-30 14:22:00 * (1 row) @@ -2040,23 +2040,23 @@ timestamp_mi(PG_FUNCTION_ARGS) } /* - * interval_justify_interval() + * interval_justify_interval() * - * Adjust interval so 'month', 'day', and 'time' portions are within - * customary bounds. Specifically: + * Adjust interval so 'month', 'day', and 'time' portions are within + * customary bounds. Specifically: * - * 0 <= abs(time) < 24 hours - * 0 <= abs(day) < 30 days + * 0 <= abs(time) < 24 hours + * 0 <= abs(day) < 30 days * - * Also, the sign bit on all three fields is made equal, so either - * all three fields are negative or all are positive. + * Also, the sign bit on all three fields is made equal, so either + * all three fields are negative or all are positive. */ Datum interval_justify_interval(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); Interval *result; - + #ifdef HAVE_INT64_TIMESTAMP int64 wholeday; #else @@ -2087,7 +2087,7 @@ interval_justify_interval(PG_FUNCTION_ARGS) result->month--; } else if (result->month < 0 && - (result->day > 0 || (result->day == 0 && result->time > 0))) + (result->day > 0 || (result->day == 0 && result->time > 0))) { result->day -= DAYS_PER_MONTH; result->month++; @@ -2103,7 +2103,7 @@ interval_justify_interval(PG_FUNCTION_ARGS) result->day--; } else if (result->day < 0 && result->time > 0) - { + { #ifdef HAVE_INT64_TIMESTAMP result->time -= USECS_PER_DAY; #else @@ -2492,8 +2492,10 @@ interval_mul(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); - double month_remainder_days, sec_remainder; - int32 orig_month = span->month, orig_day = span->day; + double month_remainder_days, + sec_remainder; + int32 orig_month = span->month, + orig_day = span->day; Interval *result; result = (Interval *) palloc(sizeof(Interval)); @@ -2512,28 +2514,28 @@ interval_mul(PG_FUNCTION_ARGS) */ /* - * Fractional months full days into days. + * Fractional months full days into days. * - * Floating point calculation are inherently inprecise, so these - * calculations are crafted to produce the most reliable result - * possible. TSROUND() is needed to more accurately produce whole - * numbers where appropriate. + * Floating point calculation are inherently inprecise, so these + * calculations are crafted to produce the most reliable result possible. + * TSROUND() is needed to more accurately produce whole numbers where + * appropriate. */ month_remainder_days = (orig_month * factor - result->month) * DAYS_PER_MONTH; month_remainder_days = TSROUND(month_remainder_days); sec_remainder = (orig_day * factor - result->day + - month_remainder_days - (int)month_remainder_days) * SECS_PER_DAY; + month_remainder_days - (int) month_remainder_days) * SECS_PER_DAY; sec_remainder = TSROUND(sec_remainder); /* - * Might have 24:00:00 hours due to rounding, or >24 hours because of - * time cascade from months and days. It might still be >24 if the - * combination of cascade and the seconds factor operation itself. + * Might have 24:00:00 hours due to rounding, or >24 hours because of time + * cascade from months and days. It might still be >24 if the combination + * of cascade and the seconds factor operation itself. */ if (Abs(sec_remainder) >= SECS_PER_DAY) { - result->day += (int)(sec_remainder / SECS_PER_DAY); - sec_remainder -= (int)(sec_remainder / SECS_PER_DAY) * SECS_PER_DAY; + result->day += (int) (sec_remainder / SECS_PER_DAY); + sec_remainder -= (int) (sec_remainder / SECS_PER_DAY) * SECS_PER_DAY; } /* cascade units down */ @@ -2562,10 +2564,12 @@ interval_div(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); - double month_remainder_days, sec_remainder; - int32 orig_month = span->month, orig_day = span->day; + double month_remainder_days, + sec_remainder; + int32 orig_month = span->month, + orig_day = span->day; Interval *result; - + result = (Interval *) palloc(sizeof(Interval)); if (factor == 0.0) @@ -2577,18 +2581,17 @@ interval_div(PG_FUNCTION_ARGS) result->day = (int32) (span->day / factor); /* - * Fractional months full days into days. See comment in - * interval_mul(). + * Fractional months full days into days. See comment in interval_mul(). */ month_remainder_days = (orig_month / factor - result->month) * DAYS_PER_MONTH; month_remainder_days = TSROUND(month_remainder_days); sec_remainder = (orig_day / factor - result->day + - month_remainder_days - (int)month_remainder_days) * SECS_PER_DAY; + month_remainder_days - (int) month_remainder_days) * SECS_PER_DAY; sec_remainder = TSROUND(sec_remainder); if (Abs(sec_remainder) >= SECS_PER_DAY) { - result->day += (int)(sec_remainder / SECS_PER_DAY); - sec_remainder -= (int)(sec_remainder / SECS_PER_DAY) * SECS_PER_DAY; + result->day += (int) (sec_remainder / SECS_PER_DAY); + sec_remainder -= (int) (sec_remainder / SECS_PER_DAY) * SECS_PER_DAY; } /* cascade units down */ diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 5124bee765c..937cf96ebef 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.118 2006/07/14 14:52:24 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.119 2006/10/04 00:30:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -604,8 +604,8 @@ bpchareq(PG_FUNCTION_ARGS) len2 = bcTruelen(arg2); /* - * Since we only care about equality or not-equality, we can avoid all - * the expense of strcoll() here, and just do bitwise comparison. + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. */ if (len1 != len2) result = false; @@ -631,8 +631,8 @@ bpcharne(PG_FUNCTION_ARGS) len2 = bcTruelen(arg2); /* - * Since we only care about equality or not-equality, we can avoid all - * the expense of strcoll() here, and just do bitwise comparison. + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. */ if (len1 != len2) result = true; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 6215e3eda5a..33f40b685c7 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.150 2006/07/14 14:52:24 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.151 2006/10/04 00:30:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -985,8 +985,8 @@ texteq(PG_FUNCTION_ARGS) bool result; /* - * Since we only care about equality or not-equality, we can avoid all - * the expense of strcoll() here, and just do bitwise comparison. + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. */ if (VARSIZE(arg1) != VARSIZE(arg2)) result = false; @@ -1008,8 +1008,8 @@ textne(PG_FUNCTION_ARGS) bool result; /* - * Since we only care about equality or not-equality, we can avoid all - * the expense of strcoll() here, and just do bitwise comparison. + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. */ if (VARSIZE(arg1) != VARSIZE(arg2)) result = true; @@ -2217,7 +2217,7 @@ replace_text_regexp(text *src_text, void *regexp, text *ret_text; regex_t *re = (regex_t *) regexp; int src_text_len = VARSIZE(src_text) - VARHDRSZ; - StringInfoData buf; + StringInfoData buf; regmatch_t pmatch[REGEXP_REPLACE_BACKREF_CNT]; pg_wchar *data; size_t data_len; @@ -2236,7 +2236,7 @@ replace_text_regexp(text *src_text, void *regexp, for (search_start = data_pos = 0; search_start <= data_len;) { - int regexec_result; + int regexec_result; regexec_result = pg_regexec(re, data, @@ -2503,7 +2503,7 @@ array_to_text(PG_FUNCTION_ARGS) int typlen; bool typbyval; char typalign; - StringInfoData buf; + StringInfoData buf; bool printed = false; char *p; bits8 *bitmap; |