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

pgindent run for 8.2.

This commit is contained in:
Bruce Momjian
2006-10-04 00:30:14 +00:00
parent 451e419e98
commit f99a569a2e
522 changed files with 21297 additions and 17170 deletions

View File

@@ -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)
{

View File

@@ -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, &timestamp);
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 : ""));

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -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,

View File

@@ -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

View File

@@ -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)));

View File

@@ -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
*/

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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))

View File

@@ -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

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.132 2006/07/31 20:09:05 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.133 2006/10/04 00:30:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -786,8 +786,8 @@ InitCatCache(int id,
/*
* nbuckets is the number of hash buckets to use in this catcache.
* Currently we just use a hard-wired estimate of an appropriate size
* for each cache; maybe later make them dynamically resizable?
* Currently we just use a hard-wired estimate of an appropriate size for
* each cache; maybe later make them dynamically resizable?
*
* nbuckets must be a power of two. We check this via Assert rather than
* a full runtime check because the values will be coming from constant

View File

@@ -80,7 +80,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.77 2006/07/14 14:52:25 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.78 2006/10/04 00:30:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -633,11 +633,11 @@ AcceptInvalidationMessages(void)
* However, it also makes the system unbelievably slow --- the regression
* tests take about 100 times longer than normal.
*
* If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY.
* This slows things by at least a factor of 10000, so I wouldn't suggest
* trying to run the entire regression tests that way. It's useful to
* try a few simple tests, to make sure that cache reload isn't subject
* to internal cache-flush hazards, but after you've done a few thousand
* If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY. This
* slows things by at least a factor of 10000, so I wouldn't suggest
* trying to run the entire regression tests that way. It's useful to try
* a few simple tests, to make sure that cache reload isn't subject to
* internal cache-flush hazards, but after you've done a few thousand
* recursive reloads it's unlikely you'll learn more.
*/
#if defined(CLOBBER_CACHE_ALWAYS)

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.137 2006/09/28 20:51:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.138 2006/10/04 00:30:00 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -206,9 +206,9 @@ get_op_btree_interpretation(Oid opno, List **opclasses, List **opstrats)
/*
* Get the nominal left-hand input type of the operator; we will ignore
* opclasses that don't have that as the expected input datatype. This
* is a kluge to avoid being confused by binary-compatible opclasses
* (such as text_ops and varchar_ops, which share the same operators).
* opclasses that don't have that as the expected input datatype. This is
* a kluge to avoid being confused by binary-compatible opclasses (such as
* text_ops and varchar_ops, which share the same operators).
*/
op_input_types(opno, &lefttype, &righttype);
Assert(OidIsValid(lefttype));
@@ -219,14 +219,15 @@ get_op_btree_interpretation(Oid opno, List **opclasses, List **opstrats)
catlist = SearchSysCacheList(AMOPOPID, 1,
ObjectIdGetDatum(opno),
0, 0, 0);
/*
* If we can't find any opclass containing the op, perhaps it is a
* <> operator. See if it has a negator that is in an opclass.
* If we can't find any opclass containing the op, perhaps it is a <>
* operator. See if it has a negator that is in an opclass.
*/
op_negated = false;
if (catlist->n_members == 0)
{
Oid op_negator = get_negator(opno);
Oid op_negator = get_negator(opno);
if (OidIsValid(op_negator))
{
@@ -1395,13 +1396,13 @@ get_type_io_data(Oid typid,
Form_pg_type typeStruct;
/*
* In bootstrap mode, pass it off to bootstrap.c. This hack allows
* us to use array_in and array_out during bootstrap.
* In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
* use array_in and array_out during bootstrap.
*/
if (IsBootstrapProcessingMode())
{
Oid typinput;
Oid typoutput;
Oid typinput;
Oid typoutput;
boot_get_type_io_data(typid,
typlen,

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.248 2006/09/05 21:08:36 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.249 2006/10/04 00:30:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -182,7 +182,7 @@ static void RelationReloadClassinfo(Relation relation);
static void RelationFlushRelation(Relation relation);
static bool load_relcache_init_file(void);
static void write_relcache_init_file(void);
static void write_item(const void *data, Size len, FILE *fp);
static void write_item(const void *data, Size len, FILE *fp);
static void formrdesc(const char *relationName, Oid relationReltype,
bool hasoids, int natts, FormData_pg_attribute *att);
@@ -298,14 +298,14 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
/*
* Copy the relation tuple form
*
* We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE.
* The variable-length fields (relacl, reloptions) are NOT stored in the
* We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE. The
* variable-length fields (relacl, reloptions) are NOT stored in the
* relcache --- there'd be little point in it, since we don't copy the
* tuple's nulls bitmap and hence wouldn't know if the values are valid.
* Bottom line is that relacl *cannot* be retrieved from the relcache.
* Get it from the syscache if you need it. The same goes for the
* original form of reloptions (however, we do store the parsed form
* of reloptions in rd_options).
* Bottom line is that relacl *cannot* be retrieved from the relcache. Get
* it from the syscache if you need it. The same goes for the original
* form of reloptions (however, we do store the parsed form of reloptions
* in rd_options).
*/
relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
@@ -355,9 +355,9 @@ RelationParseRelOptions(Relation relation, HeapTuple tuple)
}
/*
* Fetch reloptions from tuple; have to use a hardwired descriptor
* because we might not have any other for pg_class yet (consider
* executing this code for pg_class itself)
* Fetch reloptions from tuple; have to use a hardwired descriptor because
* we might not have any other for pg_class yet (consider executing this
* code for pg_class itself)
*/
datum = fastgetattr(tuple,
Anum_pg_class_reloptions,
@@ -620,8 +620,8 @@ RelationBuildRuleLock(Relation relation)
*
* Note: since we scan the rules using RewriteRelRulenameIndexId, we will
* be reading the rules in name order, except possibly during
* emergency-recovery operations (ie, IgnoreSystemIndexes). This in
* turn ensures that rules will be fired in name order.
* emergency-recovery operations (ie, IgnoreSystemIndexes). This in turn
* ensures that rules will be fired in name order.
*/
rewrite_desc = heap_open(RewriteRelationId, AccessShareLock);
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
@@ -649,10 +649,10 @@ RelationBuildRuleLock(Relation relation)
rule->isInstead = rewrite_form->is_instead;
/*
* Must use heap_getattr to fetch ev_action and ev_qual. Also,
* the rule strings are often large enough to be toasted. To avoid
* leaking memory in the caller's context, do the detoasting here
* so we can free the detoasted version.
* Must use heap_getattr to fetch ev_action and ev_qual. Also, the
* rule strings are often large enough to be toasted. To avoid
* leaking memory in the caller's context, do the detoasting here so
* we can free the detoasted version.
*/
rule_datum = heap_getattr(rewrite_tuple,
Anum_pg_rewrite_ev_action,
@@ -686,16 +686,16 @@ RelationBuildRuleLock(Relation relation)
/*
* We want the rule's table references to be checked as though by the
* table owner, not the user referencing the rule. Therefore, scan
* table owner, not the user referencing the rule. Therefore, scan
* through the rule's actions and set the checkAsUser field on all
* rtable entries. We have to look at the qual as well, in case it
* rtable entries. We have to look at the qual as well, in case it
* contains sublinks.
*
* The reason for doing this when the rule is loaded, rather than
* when it is stored, is that otherwise ALTER TABLE OWNER would have
* to grovel through stored rules to update checkAsUser fields.
* Scanning the rule tree during load is relatively cheap (compared
* to constructing it in the first place), so we do it here.
* The reason for doing this when the rule is loaded, rather than when
* it is stored, is that otherwise ALTER TABLE OWNER would have to
* grovel through stored rules to update checkAsUser fields. Scanning
* the rule tree during load is relatively cheap (compared to
* constructing it in the first place), so we do it here.
*/
setRuleCheckAsUser((Node *) rule->actions, relation->rd_rel->relowner);
setRuleCheckAsUser(rule->qual, relation->rd_rel->relowner);
@@ -1626,14 +1626,14 @@ RelationClearRelation(Relation relation, bool rebuild)
* Even non-system indexes should not be blown away if they are open and
* have valid index support information. This avoids problems with active
* use of the index support information. As with nailed indexes, we
* re-read the pg_class row to handle possible physical relocation of
* the index.
* re-read the pg_class row to handle possible physical relocation of the
* index.
*/
if (relation->rd_rel->relkind == RELKIND_INDEX &&
relation->rd_refcnt > 0 &&
relation->rd_indexcxt != NULL)
{
relation->rd_isvalid = false; /* needs to be revalidated */
relation->rd_isvalid = false; /* needs to be revalidated */
RelationReloadClassinfo(relation);
return;
}
@@ -2140,9 +2140,9 @@ RelationBuildLocalRelation(const char *relname,
/*
* check that hardwired list of shared rels matches what's in the
* bootstrap .bki file. If you get a failure here during initdb,
* you probably need to fix IsSharedRelation() to match whatever
* you've done to the set of shared relations.
* bootstrap .bki file. If you get a failure here during initdb, you
* probably need to fix IsSharedRelation() to match whatever you've done
* to the set of shared relations.
*/
if (shared_relation != IsSharedRelation(relid))
elog(ERROR, "shared_relation flag for \"%s\" does not match IsSharedRelation(%u)",
@@ -2308,7 +2308,7 @@ RelationCacheInitialize(void)
* the system catalogs. We first try to read pre-computed relcache
* entries from the pg_internal.init file. If that's missing or
* broken, make phony entries for the minimum set of nailed-in-cache
* relations. Then (unless bootstrapping) make sure we have entries
* relations. Then (unless bootstrapping) make sure we have entries
* for the critical system indexes. Once we've done all this, we
* have enough infrastructure to open any system catalog or use any
* catcache. The last step is to rewrite pg_internal.init if needed.
@@ -2319,7 +2319,7 @@ RelationCacheInitializePhase2(void)
HASH_SEQ_STATUS status;
RelIdCacheEnt *idhentry;
MemoryContext oldcxt;
bool needNewCacheFile = false;
bool needNewCacheFile = false;
/*
* switch to cache memory context
@@ -2375,7 +2375,7 @@ RelationCacheInitializePhase2(void)
* RewriteRelRulenameIndexId and TriggerRelidNameIndexId are not critical
* in the same way as the others, because the critical catalogs don't
* (currently) have any rules or triggers, and so these indexes can be
* rebuilt without inducing recursion. However they are used during
* rebuilt without inducing recursion. However they are used during
* relcache load when a rel does have rules or triggers, so we choose to
* nail them for performance reasons.
*/
@@ -2505,7 +2505,7 @@ BuildHardcodedDescriptor(int natts, Form_pg_attribute attrs, bool hasoids)
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
result = CreateTemplateTupleDesc(natts, hasoids);
result->tdtypeid = RECORDOID; /* not right, but we don't care */
result->tdtypeid = RECORDOID; /* not right, but we don't care */
result->tdtypmod = -1;
for (i = 0; i < natts; i++)
@@ -3166,7 +3166,7 @@ load_relcache_init_file(void)
if ((nread = fread(rel->rd_options, 1, len, fp)) != len)
goto read_failed;
if (len != VARATT_SIZE(rel->rd_options))
goto read_failed; /* sanity check */
goto read_failed; /* sanity check */
}
else
{
@@ -3457,7 +3457,7 @@ write_relcache_init_file(void)
/* finally, write the vector of support procedures */
write_item(rel->rd_support,
relform->relnatts * (am->amsupport * sizeof(RegProcedure)),
relform->relnatts * (am->amsupport * sizeof(RegProcedure)),
fp);
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.106 2006/07/14 14:52:25 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.107 2006/10/04 00:30:00 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@@ -516,7 +516,8 @@ static const struct cachedesc cacheinfo[] = {
}
};
static CatCache *SysCache[lengthof(cacheinfo)];
static CatCache *SysCache[
lengthof(cacheinfo)];
static int SysCacheSize = lengthof(cacheinfo);
static bool CacheInitialized = false;

View File

@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.21 2006/07/14 14:52:25 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.22 2006/10/04 00:30:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -268,9 +268,9 @@ lookup_type_cache(Oid type_id, int flags)
Assert(rel->rd_rel->reltype == typentry->type_id);
/*
* Link to the tupdesc and increment its refcount (we assert it's
* a refcounted descriptor). We don't use IncrTupleDescRefCount()
* for this, because the reference mustn't be entered in the current
* Link to the tupdesc and increment its refcount (we assert it's a
* refcounted descriptor). We don't use IncrTupleDescRefCount() for
* this, because the reference mustn't be entered in the current
* resource owner; it can outlive the current query.
*/
typentry->tupDesc = RelationGetDescr(rel);
@@ -372,7 +372,7 @@ lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod, bool noError)
TupleDesc
lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod)
{
TupleDesc tmp;
TupleDesc tmp;
tmp = lookup_rowtype_tupdesc_internal(type_id, typmod, false);
return CreateTupleDescCopyConstr(tmp);
@@ -501,9 +501,9 @@ flush_rowtype_cache(Oid type_id)
return; /* tupdesc hasn't been requested */
/*
* Release our refcount and free the tupdesc if none remain.
* (Can't use DecrTupleDescRefCount because this reference is not
* logged in current resource owner.)
* Release our refcount and free the tupdesc if none remain. (Can't use
* DecrTupleDescRefCount because this reference is not logged in current
* resource owner.)
*/
Assert(typentry->tupDesc->tdrefcount > 0);
if (--typentry->tupDesc->tdrefcount == 0)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.90 2006/09/27 18:40:09 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.91 2006/10/04 00:30:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,14 +27,14 @@
/* signatures for PostgreSQL-specific library init/fini functions */
typedef void (*PG_init_t)(void);
typedef void (*PG_fini_t)(void);
typedef void (*PG_init_t) (void);
typedef void (*PG_fini_t) (void);
/* hashtable entry for rendezvous variables */
typedef struct
{
char varName[NAMEDATALEN]; /* hash key (must be first) */
void *varValue;
{
char varName[NAMEDATALEN]; /* hash key (must be first) */
void *varValue;
} rendezvousHashEntry;
/*
@@ -168,7 +168,7 @@ lookup_external_function(void *filehandle, char *funcname)
/*
* Load the specified dynamic-link library file, unless it already is
* loaded. Return the pg_dl* handle for the file.
* loaded. Return the pg_dl* handle for the file.
*
* Note: libname is expected to be an exact name for the library file.
*/
@@ -248,7 +248,7 @@ internal_load_library(const char *libname)
const Pg_magic_struct *magic_data_ptr = (*magic_func) ();
if (magic_data_ptr->len != magic_data.len ||
memcmp(magic_data_ptr, &magic_data, magic_data.len) != 0)
memcmp(magic_data_ptr, &magic_data, magic_data.len) != 0)
{
/* copy data block before unlinking library */
Pg_magic_struct module_magic_data = *magic_data_ptr;
@@ -258,22 +258,22 @@ internal_load_library(const char *libname)
free((char *) file_scanner);
/*
* Report suitable error. It's probably not worth writing
* a separate error message for each field; only the most
* common case of wrong major version gets its own message.
* Report suitable error. It's probably not worth writing a
* separate error message for each field; only the most common
* case of wrong major version gets its own message.
*/
if (module_magic_data.version != magic_data.version)
ereport(ERROR,
(errmsg("incompatible library \"%s\": version mismatch",
libname),
errdetail("Server is version %d.%d, library is version %d.%d.",
magic_data.version/100,
magic_data.version % 100,
module_magic_data.version/100,
module_magic_data.version % 100)));
(errmsg("incompatible library \"%s\": version mismatch",
libname),
errdetail("Server is version %d.%d, library is version %d.%d.",
magic_data.version / 100,
magic_data.version % 100,
module_magic_data.version / 100,
module_magic_data.version % 100)));
ereport(ERROR,
(errmsg("incompatible library \"%s\": magic block mismatch",
libname)));
(errmsg("incompatible library \"%s\": magic block mismatch",
libname)));
}
}
else
@@ -283,9 +283,9 @@ internal_load_library(const char *libname)
free((char *) file_scanner);
/* complain */
ereport(ERROR,
(errmsg("incompatible library \"%s\": missing magic block",
libname),
errhint("Extension libraries are now required to use the PG_MODULE_MAGIC macro.")));
(errmsg("incompatible library \"%s\": missing magic block",
libname),
errhint("Extension libraries are now required to use the PG_MODULE_MAGIC macro.")));
}
/*
@@ -293,7 +293,7 @@ internal_load_library(const char *libname)
*/
PG_init = (PG_init_t) pg_dlsym(file_scanner->handle, "_PG_init");
if (PG_init)
(*PG_init)();
(*PG_init) ();
/* OK to link it into list */
if (file_list == NULL)
@@ -351,7 +351,7 @@ internal_unload_library(const char *libname)
*/
PG_fini = (PG_fini_t) pg_dlsym(file_scanner->handle, "_PG_fini");
if (PG_fini)
(*PG_fini)();
(*PG_fini) ();
clear_external_function_hash(file_scanner->handle);
pg_dlclose(file_scanner->handle);
@@ -441,8 +441,8 @@ expand_dynamic_library_name(const char *name)
}
/*
* If we can't find the file, just return the string as-is.
* The ensuing load attempt will fail and report a suitable message.
* If we can't find the file, just return the string as-is. The ensuing
* load attempt will fail and report a suitable message.
*/
return pstrdup(name);
}
@@ -575,7 +575,7 @@ find_in_dynamic_libpath(const char *basename)
/*
* Find (or create) a rendezvous variable that one dynamically
* Find (or create) a rendezvous variable that one dynamically
* loaded library can use to meet up with another.
*
* On the first call of this function for a particular varName,
@@ -589,22 +589,22 @@ find_in_dynamic_libpath(const char *basename)
* to find each other and share information: they just need to agree
* on the variable name and the data it will point to.
*/
void **
void **
find_rendezvous_variable(const char *varName)
{
static HTAB *rendezvousHash = NULL;
static HTAB *rendezvousHash = NULL;
rendezvousHashEntry *hentry;
bool found;
bool found;
/* Create a hashtable if we haven't already done so in this process */
if (rendezvousHash == NULL)
{
HASHCTL ctl;
HASHCTL ctl;
MemSet(&ctl, 0, sizeof(ctl));
ctl.keysize = NAMEDATALEN;
ctl.entrysize = sizeof(rendezvousHashEntry);
ctl.keysize = NAMEDATALEN;
ctl.entrysize = sizeof(rendezvousHashEntry);
rendezvousHash = hash_create("Rendezvous variable hash",
16,
&ctl,

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.101 2006/05/30 21:21:30 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.102 2006/10/04 00:30:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1798,7 +1798,7 @@ ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf,
*
* This is little more than window dressing for FunctionCall1, but its use is
* recommended anyway so that code invoking output functions can be identified
* easily. Note however that it does guarantee a non-toasted result.
* easily. Note however that it does guarantee a non-toasted result.
*/
bytea *
SendFunctionCall(FmgrInfo *flinfo, Datum val)

View File

@@ -5,19 +5,19 @@
*
* dynahash.c supports both local-to-a-backend hash tables and hash tables in
* shared memory. For shared hash tables, it is the caller's responsibility
* to provide appropriate access interlocking. The simplest convention is
* that a single LWLock protects the whole hash table. Searches (HASH_FIND or
* to provide appropriate access interlocking. The simplest convention is
* that a single LWLock protects the whole hash table. Searches (HASH_FIND or
* hash_seq_search) need only shared lock, but any update requires exclusive
* lock. For heavily-used shared tables, the single-lock approach creates a
* concurrency bottleneck, so we also support "partitioned" locking wherein
* there are multiple LWLocks guarding distinct subsets of the table. To use
* a hash table in partitioned mode, the HASH_PARTITION flag must be given
* to hash_create. This prevents any attempt to split buckets on-the-fly.
* to hash_create. This prevents any attempt to split buckets on-the-fly.
* Therefore, each hash bucket chain operates independently, and no fields
* of the hash header change after init except nentries and freeList.
* A partitioned table uses a spinlock to guard changes of those two fields.
* This lets any subset of the hash buckets be treated as a separately
* lockable partition. We expect callers to use the low-order bits of a
* lockable partition. We expect callers to use the low-order bits of a
* lookup key's hash value as a partition number --- this will work because
* of the way calc_bucket() maps hash values to bucket numbers.
*
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.72 2006/09/27 18:40:09 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.73 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -124,7 +124,7 @@ struct HASHHDR
/* These fields are fixed at hashtable creation */
Size keysize; /* hash key length in bytes */
Size entrysize; /* total user element size in bytes */
long num_partitions; /* # partitions (must be power of 2), or 0 */
long num_partitions; /* # partitions (must be power of 2), or 0 */
long ffactor; /* target fill factor */
long max_dsize; /* 'dsize' limit if directory is fixed size */
long ssize; /* segment size --- must be power of 2 */
@@ -132,9 +132,10 @@ struct HASHHDR
int nelem_alloc; /* number of entries to allocate at once */
#ifdef HASH_STATISTICS
/*
* Count statistics here. NB: stats code doesn't bother with mutex,
* so counts could be corrupted a bit in a partitioned table.
* Count statistics here. NB: stats code doesn't bother with mutex, so
* counts could be corrupted a bit in a partitioned table.
*/
long accesses;
long collisions;
@@ -287,8 +288,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
hashp->hash = string_hash; /* default hash function */
/*
* If you don't specify a match function, it defaults to string_compare
* if you used string_hash (either explicitly or by default) and to memcmp
* If you don't specify a match function, it defaults to string_compare if
* you used string_hash (either explicitly or by default) and to memcmp
* otherwise. (Prior to PostgreSQL 7.4, memcmp was always used.)
*/
if (flags & HASH_COMPARE)
@@ -317,8 +318,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
{
/*
* ctl structure and directory are preallocated for shared memory
* tables. Note that HASH_DIRSIZE and HASH_ALLOC had better be set
* as well.
* tables. Note that HASH_DIRSIZE and HASH_ALLOC had better be set as
* well.
*/
hashp->hctl = info->hctl;
hashp->dir = (HASHSEGMENT *) (((char *) info->hctl) + sizeof(HASHHDR));
@@ -413,8 +414,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
* This reduces problems with run-time out-of-shared-memory conditions.
*
* For a non-shared hash table, preallocate the requested number of
* elements if it's less than our chosen nelem_alloc. This avoids
* wasting space if the caller correctly estimates a small table size.
* elements if it's less than our chosen nelem_alloc. This avoids wasting
* space if the caller correctly estimates a small table size.
*/
if ((flags & HASH_SHARED_MEM) ||
nelem < hctl->nelem_alloc)
@@ -479,15 +480,16 @@ choose_nelem_alloc(Size entrysize)
elementSize = MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(entrysize);
/*
* The idea here is to choose nelem_alloc at least 32, but round up
* so that the allocation request will be a power of 2 or just less.
* This makes little difference for hash tables in shared memory,
* but for hash tables managed by palloc, the allocation request
* will be rounded up to a power of 2 anyway. If we fail to take
* this into account, we'll waste as much as half the allocated space.
* The idea here is to choose nelem_alloc at least 32, but round up so
* that the allocation request will be a power of 2 or just less. This
* makes little difference for hash tables in shared memory, but for hash
* tables managed by palloc, the allocation request will be rounded up to
* a power of 2 anyway. If we fail to take this into account, we'll waste
* as much as half the allocated space.
*/
allocSize = 32 * 4; /* assume elementSize at least 8 */
do {
do
{
allocSize <<= 1;
nelem_alloc = allocSize / elementSize;
} while (nelem_alloc < 32);
@@ -926,7 +928,7 @@ hash_search_with_hash_value(HTAB *hashp,
/* Check if it is time to split a bucket */
/* Can't split if running in partitioned mode */
if (!IS_PARTITIONED(hctl) &&
hctl->nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor)
hctl->nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor)
{
/*
* NOTE: failure to expand table is not a fatal error, it just

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.28 2006/09/27 18:40:09 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.29 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,9 +32,9 @@ string_hash(const void *key, Size keysize)
* because when it is copied into the hash table it will be truncated at
* that length.
*/
Size s_len = strlen((const char *) key);
Size s_len = strlen((const char *) key);
s_len = Min(s_len, keysize-1);
s_len = Min(s_len, keysize - 1);
return DatumGetUInt32(hash_any((const unsigned char *) key,
(int) s_len));
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.98 2006/05/02 11:28:55 teodor Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.99 2006/10/04 00:30:02 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
@@ -108,4 +108,4 @@ int VacuumCostDelay = 0;
int VacuumCostBalance = 0; /* working state for vacuum */
bool VacuumCostActive = false;
int GinFuzzySearchLimit = 0;
int GinFuzzySearchLimit = 0;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.158 2006/08/16 04:32:48 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.159 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -60,7 +60,7 @@ static char socketLockFile[MAXPGPATH];
* ----------------------------------------------------------------
*/
bool IgnoreSystemIndexes = false;
bool IgnoreSystemIndexes = false;
/* ----------------------------------------------------------------
* system index reindexing support
@@ -1097,7 +1097,7 @@ ValidatePgVersion(const char *path)
*-------------------------------------------------------------------------
*/
/*
/*
* GUC variables: lists of library names to be preloaded at postmaster
* start and at backend start
*/
@@ -1146,7 +1146,7 @@ load_libraries(const char *libraries, const char *gucname, bool restricted)
/* If restricting, insert $libdir/plugins if not mentioned already */
if (restricted && first_dir_separator(filename) == NULL)
{
char *expanded;
char *expanded;
expanded = palloc(strlen("$libdir/plugins/") + strlen(filename) + 1);
strcpy(expanded, "$libdir/plugins/");

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.170 2006/09/18 22:40:38 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.171 2006/10/04 00:30:02 momjian Exp $
*
*
*-------------------------------------------------------------------------
@@ -132,9 +132,9 @@ CheckMyDatabase(const char *name, bool am_superuser)
/*
* Check permissions to connect to the database.
*
* These checks are not enforced when in standalone mode, so that
* there is a way to recover from disabling all access to all databases,
* for example "UPDATE pg_database SET datallowconn = false;".
* These checks are not enforced when in standalone mode, so that there is
* a way to recover from disabling all access to all databases, for
* example "UPDATE pg_database SET datallowconn = false;".
*
* We do not enforce them for the autovacuum process either.
*/
@@ -150,9 +150,9 @@ CheckMyDatabase(const char *name, bool am_superuser)
name)));
/*
* Check privilege to connect to the database. (The am_superuser
* test is redundant, but since we have the flag, might as well
* check it and save a few cycles.)
* Check privilege to connect to the database. (The am_superuser test
* is redundant, but since we have the flag, might as well check it
* and save a few cycles.)
*/
if (!am_superuser &&
pg_database_aclcheck(MyDatabaseId, GetUserId(),
@@ -294,8 +294,8 @@ InitPostgres(const char *dbname, const char *username)
char *fullpath;
/*
* Set up the global variables holding database id and path. But note
* we won't actually try to touch the database just yet.
* Set up the global variables holding database id and path. But note we
* won't actually try to touch the database just yet.
*
* We take a shortcut in the bootstrap case, otherwise we have to look up
* the db name in pg_database.
@@ -324,8 +324,8 @@ InitPostgres(const char *dbname, const char *username)
SetDatabasePath(fullpath);
/*
* Finish filling in the PGPROC struct, and add it to the ProcArray.
* (We need to know MyDatabaseId before we can do this, since it's entered
* Finish filling in the PGPROC struct, and add it to the ProcArray. (We
* need to know MyDatabaseId before we can do this, since it's entered
* into the PGPROC struct.)
*
* Once I have done this, I am visible to other backends!
@@ -360,8 +360,8 @@ InitPostgres(const char *dbname, const char *username)
/*
* Initialize the relation cache and the system catalog caches. Note that
* no catalog access happens here; we only set up the hashtable structure.
* We must do this before starting a transaction because transaction
* abort would try to touch these hashtables.
* We must do this before starting a transaction because transaction abort
* would try to touch these hashtables.
*/
RelationCacheInitialize();
InitCatalogCache();
@@ -388,20 +388,19 @@ InitPostgres(const char *dbname, const char *username)
/*
* Now that we have a transaction, we can take locks. Take a writer's
* lock on the database we are trying to connect to. If there is
* a concurrently running DROP DATABASE on that database, this will
* block us until it finishes (and has updated the flat file copy
* of pg_database).
* lock on the database we are trying to connect to. If there is a
* concurrently running DROP DATABASE on that database, this will block us
* until it finishes (and has updated the flat file copy of pg_database).
*
* Note that the lock is not held long, only until the end of this
* startup transaction. This is OK since we are already advertising
* our use of the database in the PGPROC array; anyone trying a DROP
* DATABASE after this point will see us there.
* Note that the lock is not held long, only until the end of this startup
* transaction. This is OK since we are already advertising our use of
* the database in the PGPROC array; anyone trying a DROP DATABASE after
* this point will see us there.
*
* Note: use of RowExclusiveLock here is reasonable because we envision
* our session as being a concurrent writer of the database. If we had
* a way of declaring a session as being guaranteed-read-only, we could
* use AccessShareLock for such sessions and thereby not conflict against
* our session as being a concurrent writer of the database. If we had a
* way of declaring a session as being guaranteed-read-only, we could use
* AccessShareLock for such sessions and thereby not conflict against
* CREATE DATABASE.
*/
if (!bootstrap)
@@ -415,8 +414,8 @@ InitPostgres(const char *dbname, const char *username)
*/
if (!bootstrap)
{
Oid dbid2;
Oid tsid2;
Oid dbid2;
Oid tsid2;
if (!FindMyDatabase(dbname, &dbid2, &tsid2) ||
dbid2 != MyDatabaseId || tsid2 != MyDatabaseTableSpace)
@@ -424,12 +423,12 @@ InitPostgres(const char *dbname, const char *username)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist",
dbname),
errdetail("It seems to have just been dropped or renamed.")));
errdetail("It seems to have just been dropped or renamed.")));
}
/*
* Now we should be able to access the database directory safely.
* Verify it's there and looks reasonable.
* Now we should be able to access the database directory safely. Verify
* it's there and looks reasonable.
*/
if (!bootstrap)
{
@@ -440,8 +439,8 @@ InitPostgres(const char *dbname, const char *username)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist",
dbname),
errdetail("The database subdirectory \"%s\" is missing.",
fullpath)));
errdetail("The database subdirectory \"%s\" is missing.",
fullpath)));
else
ereport(FATAL,
(errcode_for_file_access(),
@@ -493,10 +492,10 @@ InitPostgres(const char *dbname, const char *username)
initialize_acl();
/*
* Read the real pg_database row for our database, check permissions
* and set up database-specific GUC settings. We can't do this until all
* the database-access infrastructure is up. (Also, it wants to know if
* the user is a superuser, so the above stuff has to happen first.)
* Read the real pg_database row for our database, check permissions and
* set up database-specific GUC settings. We can't do this until all the
* database-access infrastructure is up. (Also, it wants to know if the
* user is a superuser, so the above stuff has to happen first.)
*/
if (!bootstrap)
CheckMyDatabase(dbname, am_superuser);

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.60 2006/05/21 20:05:19 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.61 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,7 +70,7 @@ mic2latin(const unsigned char *mic, unsigned char *p, int len,
}
else
{
int l = pg_mic_mblen(mic);
int l = pg_mic_mblen(mic);
if (len < l)
report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
@@ -217,7 +217,7 @@ mic2latin_with_table(const unsigned char *mic,
}
else
{
int l = pg_mic_mblen(mic);
int l = pg_mic_mblen(mic);
if (len < l)
report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.15 2006/05/30 22:12:14 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.16 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -173,7 +173,7 @@ euc_tw2mic(const unsigned char *euc, unsigned char *p, int len)
(const char *) euc, len);
if (c1 == SS2)
{
c1 = euc[1]; /* plane No. */
c1 = euc[1]; /* plane No. */
if (c1 == 0xa1)
*p++ = LC_CNS11643_1;
else if (c1 == 0xa2)
@@ -187,7 +187,7 @@ euc_tw2mic(const unsigned char *euc, unsigned char *p, int len)
*p++ = euc[3];
}
else
{ /* CNS11643-1 */
{ /* CNS11643-1 */
*p++ = LC_CNS11643_1;
*p++ = c1;
*p++ = euc[1];
@@ -302,7 +302,7 @@ big52mic(const unsigned char *big5, unsigned char *p, int len)
{
*p++ = 0x9d; /* LCPRV2 */
}
*p++ = lc; /* Plane No. */
*p++ = lc; /* Plane No. */
*p++ = (cnsBuf >> 8) & 0x00ff;
*p++ = cnsBuf & 0x00ff;
}

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.16 2006/05/30 22:12:15 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.17 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -69,4 +69,3 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.15 2006/05/30 22:12:15 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.16 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -64,7 +64,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
Assert(len >= 0);
UtfToLocal(src, dest, ULmapGB18030,
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), PG_GB18030, len);
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), PG_GB18030, len);
PG_RETURN_VOID();
}

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.21 2006/07/11 18:26:11 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.22 2006/10/04 00:30:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -118,12 +118,12 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
int i;
int i;
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len >= 0);
for (i=0;i<sizeof(maps)/sizeof(pg_conv_map);i++)
for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
{
if (encoding == maps[i].encoding)
{
@@ -134,7 +134,7 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
PG_RETURN_VOID();
}
@@ -146,12 +146,12 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
int i;
int i;
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(len >= 0);
for (i=0;i<sizeof(maps)/sizeof(pg_conv_map);i++)
for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
{
if (encoding == maps[i].encoding)
{
@@ -162,7 +162,7 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
PG_RETURN_VOID();
}

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.17 2006/05/30 22:12:15 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.18 2006/10/04 00:30:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -93,7 +93,7 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
}
else
{
int l = pg_utf_mblen(src);
int l = pg_utf_mblen(src);
if (l > len || !pg_utf8_islegal(src, l))
report_invalid_encoding(PG_UTF8, (const char *) src, len);

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c,v 1.5 2006/07/11 18:26:11 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c,v 1.6 2006/10/04 00:30:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,37 +68,37 @@ typedef struct
static pg_conv_map maps[] = {
{PG_WIN866, LUmapWIN866, ULmapWIN866,
sizeof(LUmapWIN866) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN866) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN866) / sizeof(pg_utf_to_local)},
{PG_WIN874, LUmapWIN874, ULmapWIN874,
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local)},
{PG_WIN1250, LUmapWIN1250, ULmapWIN1250,
sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local)},
{PG_WIN1251, LUmapWIN1251, ULmapWIN1251,
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1251) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1251) / sizeof(pg_utf_to_local)},
{PG_WIN1252, LUmapWIN1252, ULmapWIN1252,
sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local)},
{PG_WIN1253, LUmapWIN1253, ULmapWIN1253,
sizeof(LUmapWIN1253) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1253) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1253) / sizeof(pg_utf_to_local)},
{PG_WIN1254, LUmapWIN1254, ULmapWIN1254,
sizeof(LUmapWIN1254) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1254) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1254) / sizeof(pg_utf_to_local)},
{PG_WIN1255, LUmapWIN1255, ULmapWIN1255,
sizeof(LUmapWIN1255) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1255) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1255) / sizeof(pg_utf_to_local)},
{PG_WIN1256, LUmapWIN1256, ULmapWIN1256,
sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local)},
{PG_WIN1257, LUmapWIN1257, ULmapWIN1257,
sizeof(LUmapWIN1257) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1257) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1257) / sizeof(pg_utf_to_local)},
{PG_WIN1258, LUmapWIN1258, ULmapWIN1258,
sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf),
sizeof(ULmapWIN1258) / sizeof(pg_utf_to_local)},
sizeof(ULmapWIN1258) / sizeof(pg_utf_to_local)},
};
Datum
@@ -108,12 +108,12 @@ win_to_utf8(PG_FUNCTION_ARGS)
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
int i;
int i;
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len >= 0);
for (i=0;i<sizeof(maps)/sizeof(pg_conv_map);i++)
for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
{
if (encoding == maps[i].encoding)
{
@@ -136,12 +136,12 @@ utf8_to_win(PG_FUNCTION_ARGS)
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
int i;
int i;
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(len >= 0);
for (i=0;i<sizeof(maps)/sizeof(pg_conv_map);i++)
for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
{
if (encoding == maps[i].encoding)
{

View File

@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
*
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.58 2006/07/14 14:52:25 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.59 2006/10/04 00:30:02 momjian Exp $
*/
#include "postgres.h"
@@ -133,9 +133,9 @@ SetClientEncoding(int encoding, bool doit)
else
{
/*
* This is the first time through, so create the context. Make
* it a child of TopMemoryContext so that these values survive
* across transactions.
* This is the first time through, so create the context. Make it a
* child of TopMemoryContext so that these values survive across
* transactions.
*/
MbProcContext = AllocSetContextCreate(TopMemoryContext,
"MbProcContext",
@@ -378,28 +378,27 @@ pg_client_to_server(const char *s, int len)
{
/*
* No conversion is possible, but we must still validate the data,
* because the client-side code might have done string escaping
* using the selected client_encoding. If the client encoding is
* ASCII-safe then we just do a straight validation under that
* encoding. For an ASCII-unsafe encoding we have a problem:
* we dare not pass such data to the parser but we have no way
* to convert it. We compromise by rejecting the data if it
* contains any non-ASCII characters.
* because the client-side code might have done string escaping using
* the selected client_encoding. If the client encoding is ASCII-safe
* then we just do a straight validation under that encoding. For an
* ASCII-unsafe encoding we have a problem: we dare not pass such data
* to the parser but we have no way to convert it. We compromise by
* rejecting the data if it contains any non-ASCII characters.
*/
if (PG_VALID_BE_ENCODING(ClientEncoding->encoding))
(void) pg_verify_mbstr(ClientEncoding->encoding, s, len, false);
else
{
int i;
int i;
for (i = 0; i < len; i++)
{
if (s[i] == '\0' || IS_HIGHBIT_SET(s[i]))
ereport(ERROR,
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
errmsg("invalid byte value for encoding \"%s\": 0x%02x",
pg_enc2name_tbl[PG_SQL_ASCII].name,
(unsigned char) s[i])));
errmsg("invalid byte value for encoding \"%s\": 0x%02x",
pg_enc2name_tbl[PG_SQL_ASCII].name,
(unsigned char) s[i])));
}
}
return (char *) s;

View File

@@ -1,7 +1,7 @@
/*
* conversion functions between pg_wchar and multibyte streams.
* Tatsuo Ishii
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.57 2006/08/22 12:11:28 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.58 2006/10/04 00:30:02 momjian Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
@@ -40,7 +40,7 @@
* SQL/ASCII
*/
static int
pg_ascii2wchar_with_len
pg_ascii2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
{
int cnt = 0;
@@ -68,7 +68,7 @@ pg_ascii_dsplen(const unsigned char *s)
return 0;
if (*s < 0x20 || *s == 0x7f)
return -1;
return 1;
}
@@ -82,7 +82,8 @@ static int pg_euc2wchar_with_len
while (len > 0 && *from)
{
if (*from == SS2 && len >= 2) /* JIS X 0201 (so called "1 byte KANA") */
if (*from == SS2 && len >= 2) /* JIS X 0201 (so called "1 byte
* KANA") */
{
from++;
*to = (SS2 << 8) | *from++;
@@ -95,13 +96,14 @@ static int pg_euc2wchar_with_len
*to |= *from++;
len -= 3;
}
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* JIS X 0208 KANJI */
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* JIS X 0208 KANJI */
{
*to = *from++ << 8;
*to |= *from++;
len -= 2;
}
else /* must be ASCII */
else
/* must be ASCII */
{
*to = *from++;
len--;
@@ -222,7 +224,7 @@ static int pg_euccn2wchar_with_len
*to |= *from++;
len -= 3;
}
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 1 */
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 1 */
{
*to = *from++ << 8;
*to |= *from++;
@@ -278,7 +280,7 @@ static int pg_euctw2wchar_with_len
if (*from == SS2 && len >= 4) /* code set 2 */
{
from++;
*to = (SS2 << 24) | (*from++ << 16) ;
*to = (SS2 << 24) | (*from++ << 16);
*to |= *from++ << 8;
*to |= *from++;
len -= 4;
@@ -290,7 +292,7 @@ static int pg_euctw2wchar_with_len
*to |= *from++;
len -= 3;
}
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 2 */
else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 2 */
{
*to = *from++ << 8;
*to |= *from++;
@@ -455,7 +457,7 @@ struct mbinterval
/* auxiliary function for binary search in interval table */
static int
mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max)
{
int min = 0;
int mid;
@@ -677,14 +679,14 @@ pg_mule_mblen(const unsigned char *s)
else if (IS_LCPRV2(*s))
len = 4;
else
len = 1; /* assume ASCII */
len = 1; /* assume ASCII */
return len;
}
static int
pg_mule_dsplen(const unsigned char *s)
{
int len;
int len;
if (IS_LC1(*s))
len = 1;
@@ -695,7 +697,7 @@ pg_mule_dsplen(const unsigned char *s)
else if (IS_LCPRV2(*s))
len = 2;
else
len = 1; /* assume ASCII */
len = 1; /* assume ASCII */
return len;
}
@@ -739,11 +741,11 @@ pg_sjis_mblen(const unsigned char *s)
int len;
if (*s >= 0xa1 && *s <= 0xdf)
len = 1; /* 1 byte kana? */
len = 1; /* 1 byte kana? */
else if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = 1; /* should be ASCII */
len = 1; /* should be ASCII */
return len;
}
@@ -753,11 +755,11 @@ pg_sjis_dsplen(const unsigned char *s)
int len;
if (*s >= 0xa1 && *s <= 0xdf)
len = 1; /* 1 byte kana? */
len = 1; /* 1 byte kana? */
else if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = pg_ascii_dsplen(s); /* should be ASCII */
len = pg_ascii_dsplen(s); /* should be ASCII */
return len;
}
@@ -770,9 +772,9 @@ pg_big5_mblen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = 1; /* should be ASCII */
len = 1; /* should be ASCII */
return len;
}
@@ -782,9 +784,9 @@ pg_big5_dsplen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = pg_ascii_dsplen(s); /* should be ASCII */
len = pg_ascii_dsplen(s); /* should be ASCII */
return len;
}
@@ -797,9 +799,9 @@ pg_gbk_mblen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = 1; /* should be ASCII */
len = 1; /* should be ASCII */
return len;
}
@@ -809,9 +811,9 @@ pg_gbk_dsplen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */
len = 2; /* kanji? */
else
len = pg_ascii_dsplen(s); /* should be ASCII */
len = pg_ascii_dsplen(s); /* should be ASCII */
return len;
}
@@ -824,9 +826,9 @@ pg_uhc_mblen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* 2byte? */
len = 2; /* 2byte? */
else
len = 1; /* should be ASCII */
len = 1; /* should be ASCII */
return len;
}
@@ -836,9 +838,9 @@ pg_uhc_dsplen(const unsigned char *s)
int len;
if (IS_HIGHBIT_SET(*s))
len = 2; /* 2byte? */
len = 2; /* 2byte? */
else
len = pg_ascii_dsplen(s); /* should be ASCII */
len = pg_ascii_dsplen(s); /* should be ASCII */
return len;
}
@@ -852,7 +854,7 @@ pg_gb18030_mblen(const unsigned char *s)
int len;
if (!IS_HIGHBIT_SET(*s))
len = 1; /* ASCII */
len = 1; /* ASCII */
else
{
if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) || (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
@@ -873,7 +875,7 @@ pg_gb18030_dsplen(const unsigned char *s)
if (IS_HIGHBIT_SET(*s))
len = 2;
else
len = pg_ascii_dsplen(s); /* ASCII */
len = pg_ascii_dsplen(s); /* ASCII */
return len;
}
@@ -906,13 +908,14 @@ static int
pg_eucjp_verifier(const unsigned char *s, int len)
{
int l;
unsigned char c1, c2;
unsigned char c1,
c2;
c1 = *s++;
switch (c1)
{
case SS2: /* JIS X 0201 */
case SS2: /* JIS X 0201 */
l = 2;
if (l > len)
return -1;
@@ -921,7 +924,7 @@ pg_eucjp_verifier(const unsigned char *s, int len)
return -1;
break;
case SS3: /* JIS X 0212 */
case SS3: /* JIS X 0212 */
l = 3;
if (l > len)
return -1;
@@ -945,7 +948,8 @@ pg_eucjp_verifier(const unsigned char *s, int len)
if (!IS_EUC_RANGE_VALID(c2))
return -1;
}
else /* must be ASCII */
else
/* must be ASCII */
{
l = 1;
}
@@ -959,7 +963,8 @@ static int
pg_euckr_verifier(const unsigned char *s, int len)
{
int l;
unsigned char c1, c2;
unsigned char c1,
c2;
c1 = *s++;
@@ -974,7 +979,8 @@ pg_euckr_verifier(const unsigned char *s, int len)
if (!IS_EUC_RANGE_VALID(c2))
return -1;
}
else /* must be ASCII */
else
/* must be ASCII */
{
l = 1;
}
@@ -989,13 +995,14 @@ static int
pg_euctw_verifier(const unsigned char *s, int len)
{
int l;
unsigned char c1, c2;
unsigned char c1,
c2;
c1 = *s++;
switch (c1)
{
case SS2: /* CNS 11643 Plane 1-7 */
case SS2: /* CNS 11643 Plane 1-7 */
l = 4;
if (l > len)
return -1;
@@ -1010,7 +1017,7 @@ pg_euctw_verifier(const unsigned char *s, int len)
return -1;
break;
case SS3: /* unused */
case SS3: /* unused */
return -1;
default:
@@ -1024,7 +1031,8 @@ pg_euctw_verifier(const unsigned char *s, int len)
if (!IS_EUC_RANGE_VALID(c2))
return -1;
}
else /* must be ASCII */
else
/* must be ASCII */
{
l = 1;
}
@@ -1036,7 +1044,8 @@ pg_euctw_verifier(const unsigned char *s, int len)
static int
pg_johab_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
unsigned char c;
l = mbl = pg_johab_mblen(s);
@@ -1059,7 +1068,8 @@ pg_johab_verifier(const unsigned char *s, int len)
static int
pg_mule_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
unsigned char c;
l = mbl = pg_mule_mblen(s);
@@ -1085,8 +1095,10 @@ pg_latin1_verifier(const unsigned char *s, int len)
static int
pg_sjis_verifier(const unsigned char *s, int len)
{
int l, mbl;
unsigned char c1, c2;
int l,
mbl;
unsigned char c1,
c2;
l = mbl = pg_sjis_mblen(s);
@@ -1106,7 +1118,8 @@ pg_sjis_verifier(const unsigned char *s, int len)
static int
pg_big5_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
l = mbl = pg_big5_mblen(s);
@@ -1125,7 +1138,8 @@ pg_big5_verifier(const unsigned char *s, int len)
static int
pg_gbk_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
l = mbl = pg_gbk_mblen(s);
@@ -1144,7 +1158,8 @@ pg_gbk_verifier(const unsigned char *s, int len)
static int
pg_uhc_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
l = mbl = pg_uhc_mblen(s);
@@ -1163,7 +1178,8 @@ pg_uhc_verifier(const unsigned char *s, int len)
static int
pg_gb18030_verifier(const unsigned char *s, int len)
{
int l, mbl;
int l,
mbl;
l = mbl = pg_gb18030_mblen(s);
@@ -1182,7 +1198,7 @@ pg_gb18030_verifier(const unsigned char *s, int len)
static int
pg_utf8_verifier(const unsigned char *s, int len)
{
int l = pg_utf_mblen(s);
int l = pg_utf_mblen(s);
if (len < l)
return -1;
@@ -1270,45 +1286,45 @@ pg_utf8_islegal(const unsigned char *source, int length)
*-------------------------------------------------------------------
*/
pg_wchar_tbl pg_wchar_table[] = {
{pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* 0; PG_SQL_ASCII */
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* 1; PG_EUC_JP */
{pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 3}, /* 2; PG_EUC_CN */
{pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* 3; PG_EUC_KR */
{pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 3}, /* 4; PG_EUC_TW */
{pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* 5; PG_JOHAB */
{pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* 0; PG_SQL_ASCII */
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* 1; PG_EUC_JP */
{pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 3}, /* 2; PG_EUC_CN */
{pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* 3; PG_EUC_KR */
{pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 3}, /* 4; PG_EUC_TW */
{pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* 5; PG_JOHAB */
{pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4}, /* 6; PG_UTF8 */
{pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 3}, /* 7; PG_MULE_INTERNAL */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 8; PG_LATIN1 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 9; PG_LATIN2 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 10; PG_LATIN3 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 11; PG_LATIN4 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 12; PG_LATIN5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 13; PG_LATIN6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 14; PG_LATIN7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 15; PG_LATIN8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 16; PG_LATIN9 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 17; PG_LATIN10 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 18; PG_WIN1256 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 19; PG_WIN1258 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 20; PG_WIN874 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 21; PG_KOI8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 22; PG_WIN1251 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 22; PG_WIN1252 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 23; PG_WIN866 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 24; ISO-8859-5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 25; ISO-8859-6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 26; ISO-8859-7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 27; ISO-8859-8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 28; PG_WIN1250 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 29; PG_WIN1253 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 30; PG_WIN1254 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 31; PG_WIN1255 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 32; PG_WIN1257 */
{0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2}, /* 33; PG_SJIS */
{0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2}, /* 34; PG_BIG5 */
{pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 3}, /* 7; PG_MULE_INTERNAL */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 8; PG_LATIN1 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 9; PG_LATIN2 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 10; PG_LATIN3 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 11; PG_LATIN4 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 12; PG_LATIN5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 13; PG_LATIN6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 14; PG_LATIN7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 15; PG_LATIN8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 16; PG_LATIN9 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 17; PG_LATIN10 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 18; PG_WIN1256 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 19; PG_WIN1258 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 20; PG_WIN874 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 21; PG_KOI8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 22; PG_WIN1251 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 22; PG_WIN1252 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 23; PG_WIN866 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 24; ISO-8859-5 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 25; ISO-8859-6 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 26; ISO-8859-7 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 27; ISO-8859-8 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 28; PG_WIN1250 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 29; PG_WIN1253 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 30; PG_WIN1254 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 31; PG_WIN1255 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 32; PG_WIN1257 */
{0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2}, /* 33; PG_SJIS */
{0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2}, /* 34; PG_BIG5 */
{0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2}, /* 35; PG_GBK */
{0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2}, /* 36; PG_UHC */
{0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 2} /* 37; PG_GB18030 */
{0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 2} /* 37; PG_GB18030 */
};
/* returns the byte length of a word for mule internal code */
@@ -1358,8 +1374,8 @@ pg_encoding_verifymb(int encoding, const char *mbstr, int len)
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) :
((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len)));
((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) :
((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len)));
}
/*
@@ -1487,9 +1503,9 @@ report_invalid_encoding(int encoding, const char *mbstr, int len)
errmsg("invalid byte sequence for encoding \"%s\": 0x%s",
pg_enc2name_tbl[encoding].name,
buf),
errhint("This error can also happen if the byte sequence does not "
"match the encoding expected by the server, which is controlled "
"by \"client_encoding\".")));
errhint("This error can also happen if the byte sequence does not "
"match the encoding expected by the server, which is controlled "
"by \"client_encoding\".")));
}
/*
@@ -1516,10 +1532,10 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
ereport(ERROR,
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"",
buf,
pg_enc2name_tbl[src_encoding].name,
pg_enc2name_tbl[dest_encoding].name)));
errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"",
buf,
pg_enc2name_tbl[src_encoding].name,
pg_enc2name_tbl[dest_encoding].name)));
}
#endif

View File

@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.353 2006/10/03 21:11:54 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.354 2006/10/04 00:30:03 momjian Exp $
*
*--------------------------------------------------------------------
*/
@@ -204,6 +204,7 @@ static char *log_error_verbosity_str;
static char *log_statement_str;
static char *log_min_error_statement_str;
static char *log_destination_string;
#ifdef HAVE_SYSLOG
static char *syslog_facility_str;
static char *syslog_ident_str;
@@ -220,7 +221,7 @@ static char *locale_ctype;
static char *regex_flavor_string;
static char *server_encoding_string;
static char *server_version_string;
static int server_version_num;
static int server_version_num;
static char *timezone_string;
static char *timezone_abbreviations_string;
static char *XactIsoLevel_string;
@@ -992,9 +993,9 @@ static struct config_bool ConfigureNamesBool[] =
{
{"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
gettext_noop("Allows modifications of the structure of system tables."),
NULL,
GUC_NOT_IN_SAMPLE
gettext_noop("Allows modifications of the structure of system tables."),
NULL,
GUC_NOT_IN_SAMPLE
},
&allowSystemTableMods,
false, NULL, NULL
@@ -1002,10 +1003,10 @@ static struct config_bool ConfigureNamesBool[] =
{
{"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
gettext_noop("Disables reading from system indexes."),
gettext_noop("It does not prevent updating the indexes, so it is safe "
"to use. The worst consequence is slowness."),
GUC_NOT_IN_SAMPLE
gettext_noop("Disables reading from system indexes."),
gettext_noop("It does not prevent updating the indexes, so it is safe "
"to use. The worst consequence is slowness."),
GUC_NOT_IN_SAMPLE
},
&IgnoreSystemIndexes,
false, NULL, NULL
@@ -1022,19 +1023,19 @@ static struct config_int ConfigureNamesInt[] =
{
{
{"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
gettext_noop("Forces a switch to the next xlog file if a "
"new file has not been started within N seconds."),
NULL,
GUC_UNIT_S
gettext_noop("Forces a switch to the next xlog file if a "
"new file has not been started within N seconds."),
NULL,
GUC_UNIT_S
},
&XLogArchiveTimeout,
0, 0, INT_MAX, NULL, NULL
},
{
{"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
gettext_noop("Waits N seconds on connection startup after authentication."),
gettext_noop("This allows attaching a debugger to the process."),
GUC_NOT_IN_SAMPLE | GUC_UNIT_S
gettext_noop("Waits N seconds on connection startup after authentication."),
gettext_noop("This allows attaching a debugger to the process."),
GUC_NOT_IN_SAMPLE | GUC_UNIT_S
},
&PostAuthDelay,
0, 0, INT_MAX, NULL, NULL
@@ -1863,7 +1864,7 @@ static struct config_string ConfigureNamesString[] =
{"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the default tablespace to create tables and indexes in."),
gettext_noop("An empty string selects the database's default tablespace."),
GUC_IS_NAME
GUC_IS_NAME
},
&default_tablespace,
"", assign_default_tablespace, NULL
@@ -2295,7 +2296,7 @@ static void ReportGUCOption(struct config_generic * record);
static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
static void ShowAllGUCConfig(DestReceiver *dest);
static char *_ShowOption(struct config_generic * record, bool use_units);
static bool is_newvalue_equal(struct config_generic *record, const char *newvalue);
static bool is_newvalue_equal(struct config_generic * record, const char *newvalue);
/*
@@ -3584,7 +3585,7 @@ parse_int(const char *value, int *result, int flags)
if ((flags & GUC_UNIT_MEMORY) && endptr != value)
{
bool used = false;
bool used = false;
while (*endptr == ' ')
endptr++;
@@ -3612,10 +3613,10 @@ parse_int(const char *value, int *result, int flags)
switch (flags & GUC_UNIT_MEMORY)
{
case GUC_UNIT_BLOCKS:
val /= (BLCKSZ/1024);
val /= (BLCKSZ / 1024);
break;
case GUC_UNIT_XBLOCKS:
val /= (XLOG_BLCKSZ/1024);
val /= (XLOG_BLCKSZ / 1024);
break;
}
}
@@ -3623,7 +3624,7 @@ parse_int(const char *value, int *result, int flags)
if ((flags & GUC_UNIT_TIME) && endptr != value)
{
bool used = false;
bool used = false;
while (*endptr == ' ')
endptr++;
@@ -3662,12 +3663,12 @@ parse_int(const char *value, int *result, int flags)
{
switch (flags & GUC_UNIT_TIME)
{
case GUC_UNIT_S:
val /= MS_PER_S;
break;
case GUC_UNIT_MIN:
val /= MS_PER_MIN;
break;
case GUC_UNIT_S:
val /= MS_PER_S;
break;
case GUC_UNIT_MIN:
val /= MS_PER_MIN;
break;
}
}
}
@@ -4173,9 +4174,10 @@ set_config_option(const char *name, const char *value,
newval = guc_strdup(elevel, value);
if (newval == NULL)
return false;
/*
* The only sort of "parsing" check we need to do is
* apply truncation if GUC_IS_NAME.
* The only sort of "parsing" check we need to do is apply
* truncation if GUC_IS_NAME.
*/
if (conf->gen.flags & GUC_IS_NAME)
truncate_identifier(newval, strlen(newval), true);
@@ -4988,11 +4990,11 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
values[2] = "kB";
break;
case GUC_UNIT_BLOCKS:
snprintf(buf, sizeof(buf), "%dkB", BLCKSZ/1024);
snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
values[2] = buf;
break;
case GUC_UNIT_XBLOCKS:
snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ/1024);
snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
values[2] = buf;
break;
case GUC_UNIT_MS:
@@ -5271,18 +5273,18 @@ _ShowOption(struct config_generic * record, bool use_units)
val = (*conf->show_hook) ();
else
{
char unit[4];
int result = *conf->variable;
char unit[4];
int result = *conf->variable;
if (use_units && result > 0 && (record->flags & GUC_UNIT_MEMORY))
{
switch (record->flags & GUC_UNIT_MEMORY)
{
case GUC_UNIT_BLOCKS:
result *= BLCKSZ/1024;
result *= BLCKSZ / 1024;
break;
case GUC_UNIT_XBLOCKS:
result *= XLOG_BLCKSZ/1024;
result *= XLOG_BLCKSZ / 1024;
break;
}
@@ -5342,7 +5344,7 @@ _ShowOption(struct config_generic * record, bool use_units)
strcpy(unit, "");
snprintf(buffer, sizeof(buffer), "%d%s",
(int)result, unit);
(int) result, unit);
val = buffer;
}
}
@@ -5387,37 +5389,37 @@ _ShowOption(struct config_generic * record, bool use_units)
static bool
is_newvalue_equal(struct config_generic *record, const char *newvalue)
is_newvalue_equal(struct config_generic * record, const char *newvalue)
{
switch (record->vartype)
{
case PGC_BOOL:
{
struct config_bool *conf = (struct config_bool *) record;
bool newval;
{
struct config_bool *conf = (struct config_bool *) record;
bool newval;
return parse_bool(newvalue, &newval) && *conf->variable == newval;
}
return parse_bool(newvalue, &newval) && *conf->variable == newval;
}
case PGC_INT:
{
struct config_int *conf = (struct config_int *) record;
int newval;
{
struct config_int *conf = (struct config_int *) record;
int newval;
return parse_int(newvalue, &newval, record->flags) && *conf->variable == newval;
}
return parse_int(newvalue, &newval, record->flags) && *conf->variable == newval;
}
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) record;
double newval;
{
struct config_real *conf = (struct config_real *) record;
double newval;
return parse_real(newvalue, &newval) && *conf->variable == newval;
}
return parse_real(newvalue, &newval) && *conf->variable == newval;
}
case PGC_STRING:
{
struct config_string *conf = (struct config_string *) record;
{
struct config_string *conf = (struct config_string *) record;
return strcmp(*conf->variable, newvalue) == 0;
}
return strcmp(*conf->variable, newvalue) == 0;
}
}
return false;
@@ -6251,7 +6253,7 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
if (newval)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("assertion checking is not supported by this build")));
errmsg("assertion checking is not supported by this build")));
#endif
return true;
}
@@ -6338,12 +6340,11 @@ static const char *
assign_backslash_quote(const char *newval, bool doit, GucSource source)
{
BackslashQuoteType bq;
bool bqbool;
bool bqbool;
/*
* Although only "on", "off", and "safe_encoding" are documented,
* we use parse_bool so we can accept all the likely variants of
* "on" and "off".
* Although only "on", "off", and "safe_encoding" are documented, we use
* parse_bool so we can accept all the likely variants of "on" and "off".
*/
if (pg_strcasecmp(newval, "safe_encoding") == 0)
bq = BACKSLASH_QUOTE_SAFE_ENCODING;
@@ -6367,14 +6368,14 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
* The powerup value shown above for timezone_abbreviations is "UNKNOWN".
* When we see this we just do nothing. If this value isn't overridden
* from the config file then pg_timezone_abbrev_initialize() will
* eventually replace it with "Default". This hack has two purposes:
* to avoid wasting cycles loading values that might soon be overridden
* from the config file, and to avoid trying to read the timezone abbrev
* files during InitializeGUCOptions(). The latter doesn't work in an
* EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and
* so we can't locate PGSHAREDIR. (Essentially the same hack is used
* to delay initializing TimeZone ... if we have any more, we should
* try to clean up and centralize this mechanism ...)
* eventually replace it with "Default". This hack has two purposes: to
* avoid wasting cycles loading values that might soon be overridden from
* the config file, and to avoid trying to read the timezone abbrev files
* during InitializeGUCOptions(). The latter doesn't work in an
* EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
* we can't locate PGSHAREDIR. (Essentially the same hack is used to
* delay initializing TimeZone ... if we have any more, we should try to
* clean up and centralize this mechanism ...)
*/
if (strcmp(newval, "UNKNOWN") == 0)
{
@@ -6385,11 +6386,11 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
if (timezone_abbreviations_string == NULL ||
strcmp(timezone_abbreviations_string, newval) != 0)
{
int elevel;
int elevel;
/*
* If reading config file, only the postmaster should bleat loudly
* about problems. Otherwise, it's just this one process doing it,
* about problems. Otherwise, it's just this one process doing it,
* and we use WARNING message level.
*/
if (source == PGC_S_FILE)

View File

@@ -5,7 +5,7 @@
* to contain some useful information. Mechanism differs wildly across
* platforms.
*
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.32 2006/09/27 18:40:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.33 2006/10/04 00:30:04 momjian Exp $
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
* various details abducted from various places
@@ -31,7 +31,7 @@
#include "utils/ps_status.h"
extern char **environ;
bool update_process_title = true;
bool update_process_title = true;
/*
@@ -287,7 +287,7 @@ set_ps_display(const char *activity, bool force)
if (!force && !update_process_title)
return;
#ifndef PS_USE_NONE
/* no ps display for stand-alone backend */
if (!IsUnderPostmaster)
@@ -336,8 +336,8 @@ set_ps_display(const char *activity, bool force)
#ifdef PS_USE_WIN32
{
/*
* Win32 does not support showing any changed arguments. To make it
* at all possible to track which backend is doing what, we create a
* Win32 does not support showing any changed arguments. To make it at
* all possible to track which backend is doing what, we create a
* named object that can be viewed with for example Process Explorer.
*/
static HANDLE ident_handle = INVALID_HANDLE_VALUE;
@@ -351,7 +351,6 @@ set_ps_display(const char *activity, bool force)
ident_handle = CreateEvent(NULL, TRUE, FALSE, name);
}
#endif /* PS_USE_WIN32 */
#endif /* not PS_USE_NONE */
}

View File

@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.1 2006/07/25 03:51:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.2 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,11 +35,11 @@ static int tz_elevel; /* to avoid passing this around a lot */
static bool validateTzEntry(tzEntry *tzentry);
static bool splitTzLine(const char *filename, int lineno,
char *line, tzEntry *tzentry);
static int addToArray(tzEntry **base, int *arraysize, int n,
tzEntry *entry, bool override);
static int ParseTzFile(const char *filename, int depth,
tzEntry **base, int *arraysize, int n);
char *line, tzEntry *tzentry);
static int addToArray(tzEntry **base, int *arraysize, int n,
tzEntry *entry, bool override);
static int ParseTzFile(const char *filename, int depth,
tzEntry **base, int *arraysize, int n);
/*
@@ -53,7 +53,8 @@ validateTzEntry(tzEntry *tzentry)
unsigned char *p;
/*
* Check restrictions imposed by datetkntbl storage format (see datetime.c)
* Check restrictions imposed by datetkntbl storage format (see
* datetime.c)
*/
if (strlen(tzentry->abbrev) > TOKMAXLEN)
{
@@ -77,8 +78,8 @@ validateTzEntry(tzEntry *tzentry)
/*
* Sanity-check the offset: shouldn't exceed 14 hours
*/
if (tzentry->offset > 14*60*60 ||
tzentry->offset < -14*60*60)
if (tzentry->offset > 14 * 60 * 60 ||
tzentry->offset < -14 * 60 * 60)
{
ereport(tz_elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -105,11 +106,11 @@ validateTzEntry(tzEntry *tzentry)
static bool
splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
{
char *abbrev;
char *offset;
char *offset_endptr;
char *remain;
char *is_dst;
char *abbrev;
char *offset;
char *offset_endptr;
char *remain;
char *is_dst;
tzentry->lineno = lineno;
tzentry->filename = filename;
@@ -130,8 +131,8 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
{
ereport(tz_elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("missing time zone offset in time zone file \"%s\", line %d",
filename, lineno)));
errmsg("missing time zone offset in time zone file \"%s\", line %d",
filename, lineno)));
return false;
}
tzentry->offset = strtol(offset, &offset_endptr, 10);
@@ -157,7 +158,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
remain = is_dst;
}
if (!remain) /* no more non-whitespace chars */
if (!remain) /* no more non-whitespace chars */
return true;
if (remain[0] != '#') /* must be a comment */
@@ -186,23 +187,23 @@ static int
addToArray(tzEntry **base, int *arraysize, int n,
tzEntry *entry, bool override)
{
tzEntry* arrayptr;
tzEntry *arrayptr;
int low;
int high;
/*
* Search the array for a duplicate; as a useful side effect, the array
* is maintained in sorted order. We use strcmp() to ensure we match
* the sort order datetime.c expects.
* Search the array for a duplicate; as a useful side effect, the array is
* maintained in sorted order. We use strcmp() to ensure we match the
* sort order datetime.c expects.
*/
arrayptr = *base;
low = 0;
high = n-1;
high = n - 1;
while (low <= high)
{
int mid = (low + high) >> 1;
tzEntry *midptr = arrayptr + mid;
int cmp;
int mid = (low + high) >> 1;
tzEntry *midptr = arrayptr + mid;
int cmp;
cmp = strcmp(entry->abbrev, midptr->abbrev);
if (cmp < 0)
@@ -214,7 +215,7 @@ addToArray(tzEntry **base, int *arraysize, int n,
/*
* Found a duplicate entry; complain unless it's the same.
*/
if (midptr->offset == entry->offset &&
if (midptr->offset == entry->offset &&
midptr->is_dst == entry->is_dst)
{
/* return unchanged array */
@@ -230,8 +231,8 @@ addToArray(tzEntry **base, int *arraysize, int n,
/* same abbrev but something is different, complain */
ereport(tz_elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("time zone abbreviation \"%s\" is multiply defined",
entry->abbrev),
errmsg("time zone abbreviation \"%s\" is multiply defined",
entry->abbrev),
errdetail("Time zone file \"%s\", line %d conflicts with file \"%s\", line %d.",
midptr->filename, midptr->lineno,
entry->filename, entry->lineno)));
@@ -257,7 +258,7 @@ addToArray(tzEntry **base, int *arraysize, int n,
/* Must dup the abbrev to ensure it survives */
arrayptr->abbrev = pstrdup(entry->abbrev);
return n+1;
return n + 1;
}
/*
@@ -275,15 +276,15 @@ static int
ParseTzFile(const char *filename, int depth,
tzEntry **base, int *arraysize, int n)
{
char share_path[MAXPGPATH];
char file_path[MAXPGPATH];
FILE *tzFile;
char tzbuf[1024];
char *line;
tzEntry tzentry;
int lineno = 0;
bool override = false;
const char *p;
char share_path[MAXPGPATH];
char file_path[MAXPGPATH];
FILE *tzFile;
char tzbuf[1024];
char *line;
tzEntry tzentry;
int lineno = 0;
bool override = false;
const char *p;
/*
* We enforce that the filename is all alpha characters. This may be
@@ -299,23 +300,23 @@ ParseTzFile(const char *filename, int depth,
if (depth > 0)
ereport(tz_elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid time zone file name \"%s\"",
filename)));
errmsg("invalid time zone file name \"%s\"",
filename)));
return -1;
}
}
/*
* The maximal recursion depth is a pretty arbitrary setting.
* It is hard to imagine that someone needs more than 3 levels so stick
* with this conservative setting until someone complains.
* The maximal recursion depth is a pretty arbitrary setting. It is hard
* to imagine that someone needs more than 3 levels so stick with this
* conservative setting until someone complains.
*/
if (depth > 3)
{
ereport(tz_elevel,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("time zone file recursion limit exceeded in file \"%s\"",
filename)));
errmsg("time zone file recursion limit exceeded in file \"%s\"",
filename)));
return -1;
}
@@ -350,13 +351,13 @@ ParseTzFile(const char *filename, int depth,
/* else we're at EOF after all */
break;
}
if (strlen(tzbuf) == sizeof(tzbuf)-1)
if (strlen(tzbuf) == sizeof(tzbuf) - 1)
{
/* the line is too long for tzbuf */
ereport(tz_elevel,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("line is too long in time zone file \"%s\", line %d",
filename, lineno)));
errmsg("line is too long in time zone file \"%s\", line %d",
filename, lineno)));
return -1;
}
@@ -365,15 +366,15 @@ ParseTzFile(const char *filename, int depth,
while (*line && isspace((unsigned char) *line))
line++;
if (*line == '\0') /* empty line */
if (*line == '\0') /* empty line */
continue;
if (*line == '#') /* comment line */
if (*line == '#') /* comment line */
continue;
if (pg_strncasecmp(line, "@INCLUDE", strlen("@INCLUDE")) == 0)
{
/* pstrdup so we can use filename in result data structure */
char* includeFile = pstrdup(line + strlen("@INCLUDE"));
char *includeFile = pstrdup(line + strlen("@INCLUDE"));
includeFile = strtok(includeFile, WHITESPACE);
if (!includeFile || !*includeFile)
@@ -425,15 +426,15 @@ load_tzoffsets(const char *filename, bool doit, int elevel)
{
MemoryContext tmpContext;
MemoryContext oldContext;
tzEntry *array;
tzEntry *array;
int arraysize;
int n;
tz_elevel = elevel;
/*
* Create a temp memory context to work in. This makes it easy to
* clean up afterwards.
* Create a temp memory context to work in. This makes it easy to clean
* up afterwards.
*/
tmpContext = AllocSetContextCreate(CurrentMemoryContext,
"TZParserMemory",

View File

@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.67 2006/06/28 22:05:37 neilc Exp $
* $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.68 2006/10/04 00:30:04 momjian Exp $
*
* NOTE:
* This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -883,7 +883,7 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
if (oldsize > ALLOC_CHUNK_LIMIT)
{
/*
* The chunk must have been allocated as a single-chunk block. Find
* The chunk must have been allocated as a single-chunk block. Find
* the containing block and use realloc() to make it bigger with
* minimum space wastage.
*/

View File

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.95 2006/09/27 18:40:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.96 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -69,7 +69,7 @@ do { \
PortalHashEnt *hentry; bool found; \
\
hentry = (PortalHashEnt *) hash_search(PortalHashTable, \
(NAME), HASH_ENTER, &found); \
(NAME), HASH_ENTER, &found); \
if (found) \
elog(ERROR, "duplicate portal name"); \
hentry->portal = PORTAL; \
@@ -145,11 +145,11 @@ GetPortalByName(const char *name)
* Get the "primary" Query within a portal, ie, the one marked canSetTag.
*
* Returns NULL if no such Query. If multiple Query structs within the
* portal are marked canSetTag, returns the first one. Neither of these
* portal are marked canSetTag, returns the first one. Neither of these
* cases should occur in present usages of this function.
*
* Note: the reason this is just handed a List is so that prepared statements
* can share the code. For use with a portal, use PortalGetPrimaryQuery
* can share the code. For use with a portal, use PortalGetPrimaryQuery
* rather than calling this directly.
*/
Query *
@@ -790,22 +790,21 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
Datum
pg_cursor(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
HASH_SEQ_STATUS *hash_seq;
PortalHashEnt *hentry;
FuncCallContext *funcctx;
HASH_SEQ_STATUS *hash_seq;
PortalHashEnt *hentry;
/* stuff done only on the first call of the function */
if (SRF_IS_FIRSTCALL())
{
MemoryContext oldcontext;
TupleDesc tupdesc;
MemoryContext oldcontext;
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);
@@ -819,8 +818,8 @@ pg_cursor(PG_FUNCTION_ARGS)
funcctx->user_fctx = NULL;
/*
* build tupdesc for result tuples. This must match the
* definition of the pg_cursors view in system_views.sql
* build tupdesc for result tuples. This must match the definition of
* the pg_cursors view in system_views.sql
*/
tupdesc = CreateTemplateTupleDesc(6, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
@@ -871,7 +870,7 @@ pg_cursor(PG_FUNCTION_ARGS)
nulls[1] = true;
else
values[1] = DirectFunctionCall1(textin,
CStringGetDatum(portal->sourceText));
CStringGetDatum(portal->sourceText));
values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD);
values[3] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_BINARY);
values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL);
@@ -884,4 +883,3 @@ pg_cursor(PG_FUNCTION_ARGS)
SRF_RETURN_DONE(funcctx);
}

View File

@@ -55,7 +55,7 @@
* To support the above policy of writing to the lowest free block,
* ltsGetFreeBlock sorts the list of free block numbers into decreasing
* order each time it is asked for a block and the list isn't currently
* sorted. This is an efficient way to handle it because we expect cycles
* sorted. This is an efficient way to handle it because we expect cycles
* of releasing many blocks followed by re-using many blocks, due to
* tuplesort.c's "preread" behavior.
*
@@ -70,7 +70,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.21 2006/03/07 23:46:24 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.22 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -157,7 +157,7 @@ struct LogicalTapeSet
*
* If blocksSorted is true then the block numbers in freeBlocks are in
* *decreasing* order, so that removing the last entry gives us the lowest
* free block. We re-sort the blocks whenever a block is demanded; this
* free block. We re-sort the blocks whenever a block is demanded; this
* should be reasonably efficient given the expected usage pattern.
*/
bool forgetFreeSpace; /* are we remembering free blocks? */
@@ -171,7 +171,7 @@ struct LogicalTapeSet
* is of length nTapes.
*/
int nTapes; /* # of logical tapes in set */
LogicalTape tapes[1]; /* must be last in struct! */
LogicalTape tapes[1]; /* must be last in struct! */
};
static void ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer);
@@ -303,12 +303,12 @@ ltsReleaseBlock(LogicalTapeSet *lts, long blocknum)
}
/*
* Add blocknum to array, and mark the array unsorted if it's no longer
* in decreasing order.
* Add blocknum to array, and mark the array unsorted if it's no longer in
* decreasing order.
*/
ndx = lts->nFreeBlocks++;
lts->freeBlocks[ndx] = blocknum;
if (ndx > 0 && lts->freeBlocks[ndx-1] < blocknum)
if (ndx > 0 && lts->freeBlocks[ndx - 1] < blocknum)
lts->blocksSorted = false;
}
@@ -522,12 +522,12 @@ LogicalTapeSetCreate(int ntapes)
int i;
/*
* Create top-level struct including per-tape LogicalTape structs.
* First LogicalTape struct is already counted in sizeof(LogicalTapeSet).
* Create top-level struct including per-tape LogicalTape structs. First
* LogicalTape struct is already counted in sizeof(LogicalTapeSet).
*/
Assert(ntapes > 0);
lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet) +
(ntapes - 1) * sizeof(LogicalTape));
(ntapes - 1) *sizeof(LogicalTape));
lts->pfile = BufFileCreateTemp(false);
lts->nFileBlocks = 0L;
lts->forgetFreeSpace = false;
@@ -540,7 +540,7 @@ LogicalTapeSetCreate(int ntapes)
/*
* Initialize per-tape structs. Note we allocate the I/O buffer and
* first-level indirect block for a tape only when it is first actually
* written to. This avoids wasting memory space when tuplesort.c
* written to. This avoids wasting memory space when tuplesort.c
* overestimates the number of tapes needed.
*/
for (i = 0; i < ntapes; i++)
@@ -591,7 +591,7 @@ LogicalTapeSetClose(LogicalTapeSet *lts)
* Mark a logical tape set as not needing management of free space anymore.
*
* This should be called if the caller does not intend to write any more data
* into the tape set, but is reading from un-frozen tapes. Since no more
* into the tape set, but is reading from un-frozen tapes. Since no more
* writes are planned, remembering free blocks is no longer useful. Setting
* this flag lets us avoid wasting time and space in ltsReleaseBlock(), which
* is not designed to handle large numbers of free blocks.

View File

@@ -77,7 +77,7 @@
* grounds that 7 is the "sweet spot" on the tapes-to-passes curve according
* to Knuth's figure 70 (section 5.4.2). However, Knuth is assuming that
* tape drives are expensive beasts, and in particular that there will always
* be many more runs than tape drives. In our implementation a "tape drive"
* be many more runs than tape drives. In our implementation a "tape drive"
* doesn't cost much more than a few Kb of memory buffers, so we can afford
* to have lots of them. In particular, if we can have as many tape drives
* as sorted runs, we can eliminate any repeated I/O at all. In the current
@@ -91,7 +91,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.69 2006/10/03 22:18:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.70 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -119,28 +119,28 @@ bool trace_sort = false;
/*
* The objects we actually sort are SortTuple structs. These contain
* The objects we actually sort are SortTuple structs. These contain
* a pointer to the tuple proper (might be a MinimalTuple or IndexTuple),
* which is a separate palloc chunk --- we assume it is just one chunk and
* can be freed by a simple pfree(). SortTuples also contain the tuple's
* first key column in Datum/nullflag format, and an index integer.
*
* Storing the first key column lets us save heap_getattr or index_getattr
* calls during tuple comparisons. We could extract and save all the key
* calls during tuple comparisons. We could extract and save all the key
* columns not just the first, but this would increase code complexity and
* overhead, and wouldn't actually save any comparison cycles in the common
* case where the first key determines the comparison result. Note that
* for a pass-by-reference datatype, datum1 points into the "tuple" storage.
*
* When sorting single Datums, the data value is represented directly by
* datum1/isnull1. If the datatype is pass-by-reference and isnull1 is false,
* datum1/isnull1. If the datatype is pass-by-reference and isnull1 is false,
* then datum1 points to a separately palloc'd data value that is also pointed
* to by the "tuple" pointer; otherwise "tuple" is NULL.
*
* While building initial runs, tupindex holds the tuple's run number. During
* merge passes, we re-use it to hold the input tape number that each tuple in
* the heap was read from, or to hold the index of the next tuple pre-read
* from the same tape in the case of pre-read entries. tupindex goes unused
* from the same tape in the case of pre-read entries. tupindex goes unused
* if the sort occurs entirely in memory.
*/
typedef struct
@@ -205,7 +205,7 @@ struct Tuplesortstate
* qsort_arg_comparator.
*/
int (*comparetup) (const SortTuple *a, const SortTuple *b,
Tuplesortstate *state);
Tuplesortstate *state);
/*
* Function to copy a supplied input tuple into palloc'd space and set up
@@ -223,19 +223,19 @@ struct Tuplesortstate
* state->availMem by the amount of memory space thereby released.
*/
void (*writetup) (Tuplesortstate *state, int tapenum,
SortTuple *stup);
SortTuple *stup);
/*
* Function to read a stored tuple from tape back into memory. 'len' is
* the already-read length of the stored tuple. Create a palloc'd copy,
* initialize tuple/datum1/isnull1 in the target SortTuple struct,
* and decrease state->availMem by the amount of memory space consumed.
* initialize tuple/datum1/isnull1 in the target SortTuple struct, and
* decrease state->availMem by the amount of memory space consumed.
*/
void (*readtup) (Tuplesortstate *state, SortTuple *stup,
int tapenum, unsigned int len);
int tapenum, unsigned int len);
/*
* This array holds the tuples now in sort memory. If we are in state
* This array holds the tuples now in sort memory. If we are in state
* INITIAL, the tuples are in no particular order; if we are in state
* SORTEDINMEM, the tuples are in final sorted order; in states BUILDRUNS
* and FINALMERGE, the tuples are organized in "heap" order per Algorithm
@@ -255,8 +255,8 @@ struct Tuplesortstate
int currentRun;
/*
* Unless otherwise noted, all pointer variables below are pointers
* to arrays of length maxTapes, holding per-tape data.
* Unless otherwise noted, all pointer variables below are pointers to
* arrays of length maxTapes, holding per-tape data.
*/
/*
@@ -280,7 +280,7 @@ struct Tuplesortstate
int *mergeavailslots; /* slots left for prereading each tape */
long *mergeavailmem; /* availMem for prereading each tape */
int mergefreelist; /* head of freelist of recycled slots */
int mergefirstfree; /* first slot never used in this merge */
int mergefirstfree; /* first slot never used in this merge */
/*
* Variables for Algorithm D. Note that destTape is a "logical" tape
@@ -314,8 +314,8 @@ struct Tuplesortstate
* tuplesort_begin_heap and used only by the MinimalTuple routines.
*/
TupleDesc tupDesc;
ScanKey scanKeys; /* array of length nKeys */
SortFunctionKind *sortFnKinds; /* array of length nKeys */
ScanKey scanKeys; /* array of length nKeys */
SortFunctionKind *sortFnKinds; /* array of length nKeys */
/*
* These variables are specific to the IndexTuple case; they are set by
@@ -346,7 +346,7 @@ struct Tuplesortstate
};
#define COMPARETUP(state,a,b) ((*(state)->comparetup) (a, b, state))
#define COPYTUP(state,stup,tup) ((*(state)->copytup) (state, stup, tup))
#define COPYTUP(state,stup,tup) ((*(state)->copytup) (state, stup, tup))
#define WRITETUP(state,tape,stup) ((*(state)->writetup) (state, tape, stup))
#define READTUP(state,stup,tape,len) ((*(state)->readtup) (state, stup, tape, len))
#define LACKMEM(state) ((state)->availMem < 0)
@@ -411,26 +411,26 @@ static void tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex);
static unsigned int getlen(Tuplesortstate *state, int tapenum, bool eofOK);
static void markrunend(Tuplesortstate *state, int tapenum);
static int comparetup_heap(const SortTuple *a, const SortTuple *b,
Tuplesortstate *state);
Tuplesortstate *state);
static void copytup_heap(Tuplesortstate *state, SortTuple *stup, void *tup);
static void writetup_heap(Tuplesortstate *state, int tapenum,
SortTuple *stup);
SortTuple *stup);
static void readtup_heap(Tuplesortstate *state, SortTuple *stup,
int tapenum, unsigned int len);
int tapenum, unsigned int len);
static int comparetup_index(const SortTuple *a, const SortTuple *b,
Tuplesortstate *state);
Tuplesortstate *state);
static void copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup);
static void writetup_index(Tuplesortstate *state, int tapenum,
SortTuple *stup);
SortTuple *stup);
static void readtup_index(Tuplesortstate *state, SortTuple *stup,
int tapenum, unsigned int len);
int tapenum, unsigned int len);
static int comparetup_datum(const SortTuple *a, const SortTuple *b,
Tuplesortstate *state);
Tuplesortstate *state);
static void copytup_datum(Tuplesortstate *state, SortTuple *stup, void *tup);
static void writetup_datum(Tuplesortstate *state, int tapenum,
SortTuple *stup);
SortTuple *stup);
static void readtup_datum(Tuplesortstate *state, SortTuple *stup,
int tapenum, unsigned int len);
int tapenum, unsigned int len);
/*
@@ -460,8 +460,8 @@ tuplesort_begin_common(int workMem, bool randomAccess)
MemoryContext oldcontext;
/*
* Create a working memory context for this sort operation.
* All data needed by the sort will live inside this context.
* Create a working memory context for this sort operation. All data
* needed by the sort will live inside this context.
*/
sortcontext = AllocSetContextCreate(CurrentMemoryContext,
"TupleSort",
@@ -470,8 +470,8 @@ tuplesort_begin_common(int workMem, bool randomAccess)
ALLOCSET_DEFAULT_MAXSIZE);
/*
* Make the Tuplesortstate within the per-sort context. This way,
* we don't need a separate pfree() operation for it at shutdown.
* Make the Tuplesortstate within the per-sort context. This way, we
* don't need a separate pfree() operation for it at shutdown.
*/
oldcontext = MemoryContextSwitchTo(sortcontext);
@@ -680,8 +680,8 @@ tuplesort_end(Tuplesortstate *state)
/*
* Delete temporary "tape" files, if any.
*
* Note: want to include this in reported total cost of sort, hence
* need for two #ifdef TRACE_SORT sections.
* Note: want to include this in reported total cost of sort, hence need
* for two #ifdef TRACE_SORT sections.
*/
if (state->tapeset)
LogicalTapeSetClose(state->tapeset);
@@ -701,8 +701,8 @@ tuplesort_end(Tuplesortstate *state)
MemoryContextSwitchTo(oldcontext);
/*
* Free the per-sort memory context, thereby releasing all working
* memory, including the Tuplesortstate struct itself.
* Free the per-sort memory context, thereby releasing all working memory,
* including the Tuplesortstate struct itself.
*/
MemoryContextDelete(state->sortcontext);
}
@@ -721,15 +721,16 @@ grow_memtuples(Tuplesortstate *state)
{
/*
* We need to be sure that we do not cause LACKMEM to become true, else
* the space management algorithm will go nuts. We assume here that
* the memory chunk overhead associated with the memtuples array is
* constant and so there will be no unexpected addition to what we ask
* for. (The minimum array size established in tuplesort_begin_common
* is large enough to force palloc to treat it as a separate chunk, so
* this assumption should be good. But let's check it.)
* the space management algorithm will go nuts. We assume here that the
* memory chunk overhead associated with the memtuples array is constant
* and so there will be no unexpected addition to what we ask for. (The
* minimum array size established in tuplesort_begin_common is large
* enough to force palloc to treat it as a separate chunk, so this
* assumption should be good. But let's check it.)
*/
if (state->availMem <= (long) (state->memtupsize * sizeof(SortTuple)))
return false;
/*
* On a 64-bit machine, allowedMem could be high enough to get us into
* trouble with MaxAllocSize, too.
@@ -804,8 +805,8 @@ tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
SortTuple stup;
/*
* If it's a pass-by-reference value, copy it into memory we control,
* and decrease availMem. Then call the common code.
* If it's a pass-by-reference value, copy it into memory we control, and
* decrease availMem. Then call the common code.
*/
if (isNull || state->datumTypeByVal)
{
@@ -837,10 +838,10 @@ puttuple_common(Tuplesortstate *state, SortTuple *tuple)
case TSS_INITIAL:
/*
* Save the tuple into the unsorted array. First, grow the
* array as needed. Note that we try to grow the array when there
* is still one free slot remaining --- if we fail, there'll still
* be room to store the incoming tuple, and then we'll switch to
* Save the tuple into the unsorted array. First, grow the array
* as needed. Note that we try to grow the array when there is
* still one free slot remaining --- if we fail, there'll still be
* room to store the incoming tuple, and then we'll switch to
* tape-based operation.
*/
if (state->memtupcount >= state->memtupsize - 1)
@@ -869,14 +870,14 @@ puttuple_common(Tuplesortstate *state, SortTuple *tuple)
case TSS_BUILDRUNS:
/*
* Insert the tuple into the heap, with run number
* currentRun if it can go into the current run, else run number
* currentRun+1. The tuple can go into the current run if it is
* >= the first not-yet-output tuple. (Actually, it could go into
* the current run if it is >= the most recently output tuple ...
* but that would require keeping around the tuple we last output,
* and it's simplest to let writetup free each tuple as soon as
* it's written.)
* Insert the tuple into the heap, with run number currentRun if
* it can go into the current run, else run number currentRun+1.
* The tuple can go into the current run if it is >= the first
* not-yet-output tuple. (Actually, it could go into the current
* run if it is >= the most recently output tuple ... but that
* would require keeping around the tuple we last output, and it's
* simplest to let writetup free each tuple as soon as it's
* written.)
*
* Note there will always be at least one tuple in the heap at
* this point; see dumptuples.
@@ -1262,14 +1263,14 @@ tuplesort_merge_order(long allowedMem)
int mOrder;
/*
* We need one tape for each merge input, plus another one for the
* output, and each of these tapes needs buffer space. In addition
* we want MERGE_BUFFER_SIZE workspace per input tape (but the output
* tape doesn't count).
* We need one tape for each merge input, plus another one for the output,
* and each of these tapes needs buffer space. In addition we want
* MERGE_BUFFER_SIZE workspace per input tape (but the output tape doesn't
* count).
*
* Note: you might be thinking we need to account for the memtuples[]
* array in this calculation, but we effectively treat that as part of
* the MERGE_BUFFER_SIZE workspace.
* array in this calculation, but we effectively treat that as part of the
* MERGE_BUFFER_SIZE workspace.
*/
mOrder = (allowedMem - TAPE_BUFFER_OVERHEAD) /
(MERGE_BUFFER_SIZE + TAPE_BUFFER_OVERHEAD);
@@ -1298,8 +1299,8 @@ inittapes(Tuplesortstate *state)
/*
* We must have at least 2*maxTapes slots in the memtuples[] array, else
* we'd not have room for merge heap plus preread. It seems unlikely
* that this case would ever occur, but be safe.
* we'd not have room for merge heap plus preread. It seems unlikely that
* this case would ever occur, but be safe.
*/
maxTapes = Min(maxTapes, state->memtupsize / 2);
@@ -1314,12 +1315,12 @@ inittapes(Tuplesortstate *state)
/*
* Decrease availMem to reflect the space needed for tape buffers; but
* don't decrease it to the point that we have no room for tuples.
* (That case is only likely to occur if sorting pass-by-value Datums;
* in all other scenarios the memtuples[] array is unlikely to occupy
* more than half of allowedMem. In the pass-by-value case it's not
* important to account for tuple space, so we don't care if LACKMEM
* becomes inaccurate.)
* don't decrease it to the point that we have no room for tuples. (That
* case is only likely to occur if sorting pass-by-value Datums; in all
* other scenarios the memtuples[] array is unlikely to occupy more than
* half of allowedMem. In the pass-by-value case it's not important to
* account for tuple space, so we don't care if LACKMEM becomes
* inaccurate.)
*/
tapeSpace = maxTapes * TAPE_BUFFER_OVERHEAD;
if (tapeSpace + GetMemoryChunkSpace(state->memtuples) < state->allowedMem)
@@ -1435,7 +1436,7 @@ mergeruns(Tuplesortstate *state)
/*
* If we produced only one initial run (quite likely if the total data
* volume is between 1X and 2X workMem), we can just use that tape as the
* finished output, rather than doing a useless merge. (This obvious
* finished output, rather than doing a useless merge. (This obvious
* optimization is not in Knuth's algorithm.)
*/
if (state->currentRun == 1)
@@ -1666,7 +1667,7 @@ beginmerge(Tuplesortstate *state)
memset(state->mergelast, 0,
state->maxTapes * sizeof(*state->mergelast));
state->mergefreelist = 0; /* nothing in the freelist */
state->mergefirstfree = activeTapes; /* 1st slot avail for preread */
state->mergefirstfree = activeTapes; /* 1st slot avail for preread */
/*
* Initialize space allocation to let each active input tape have an equal
@@ -1966,7 +1967,7 @@ tuplesort_restorepos(Tuplesortstate *state)
/*
* Heap manipulation routines, per Knuth's Algorithm 5.2.3H.
*
* Compare two SortTuples. If checkIndex is true, use the tuple index
* Compare two SortTuples. If checkIndex is true, use the tuple index
* as the front of the sort key; otherwise, no.
*/
@@ -1977,7 +1978,7 @@ tuplesort_restorepos(Tuplesortstate *state)
/*
* Insert a new tuple into an empty or existing heap, maintaining the
* heap invariant. Caller is responsible for ensuring there's room.
* heap invariant. Caller is responsible for ensuring there's room.
*
* Note: we assume *tuple is a temporary variable that can be scribbled on.
* For some callers, tuple actually points to a memtuples[] entry above the
@@ -1993,10 +1994,10 @@ tuplesort_heap_insert(Tuplesortstate *state, SortTuple *tuple,
int j;
/*
* Save the tupleindex --- see notes above about writing on *tuple.
* It's a historical artifact that tupleindex is passed as a separate
* argument and not in *tuple, but it's notationally convenient so
* let's leave it that way.
* Save the tupleindex --- see notes above about writing on *tuple. It's a
* historical artifact that tupleindex is passed as a separate argument
* and not in *tuple, but it's notationally convenient so let's leave it
* that way.
*/
tuple->tupindex = tupleindex;
@@ -2432,8 +2433,8 @@ comparetup_index(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
{
/*
* This is similar to _bt_tuplecompare(), but we have already done the
* index_getattr calls for the first column, and we need to keep track
* of whether any null fields are present. Also see the special treatment
* index_getattr calls for the first column, and we need to keep track of
* whether any null fields are present. Also see the special treatment
* for equal keys at the end.
*/
ScanKey scanKey = state->indexScanKey;
@@ -2686,7 +2687,7 @@ readtup_datum(Tuplesortstate *state, SortTuple *stup,
}
else
{
void *raddr = palloc(tuplen);
void *raddr = palloc(tuplen);
if (LogicalTapeRead(state->tapeset, tapenum, raddr,
tuplen) != tuplen)

View File

@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.28 2006/06/27 02:51:39 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.29 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -347,6 +347,7 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
switch (state->status)
{
case TSS_INMEM:
/*
* Grow the array as needed. Note that we try to grow the array
* when there is still one free slot remaining --- if we fail,

View File

@@ -32,7 +32,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.97 2006/09/15 16:39:32 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.98 2006/10/04 00:30:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1326,7 +1326,7 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
/*
* Make a quick range check to eliminate most XIDs without looking at the
* xip arrays. Note that this is OK even if we convert a subxact XID to
* xip arrays. Note that this is OK even if we convert a subxact XID to
* its parent below, because a subxact with XID < xmin has surely also got
* a parent with XID < xmin, while one with XID >= xmax must belong to a
* parent that was not yet committed at the time of this snapshot.
@@ -1342,7 +1342,7 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
/*
* If the snapshot contains full subxact data, the fastest way to check
* things is just to compare the given XID against both subxact XIDs and
* top-level XIDs. If the snapshot overflowed, we have to use pg_subtrans
* top-level XIDs. If the snapshot overflowed, we have to use pg_subtrans
* to convert a subxact XID to its parent XID, but then we need only look
* at top-level XIDs not subxacts.
*/
@@ -1365,8 +1365,8 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
xid = SubTransGetTopmostTransaction(xid);
/*
* If xid was indeed a subxact, we might now have an xid < xmin,
* so recheck to avoid an array scan. No point in rechecking xmax.
* If xid was indeed a subxact, we might now have an xid < xmin, so
* recheck to avoid an array scan. No point in rechecking xmax.
*/
if (TransactionIdPrecedes(xid, snapshot->xmin))
return false;