mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
pgindent run.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.78 2002/09/03 22:17:35 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.79 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -36,15 +36,15 @@ static const char *aclparse(const char *s, AclItem *aip, unsigned *modechg);
|
||||
static bool aclitemeq(const AclItem *a1, const AclItem *a2);
|
||||
static bool aclitemgt(const AclItem *a1, const AclItem *a2);
|
||||
|
||||
static Oid convert_table_name(text *tablename);
|
||||
static Oid convert_table_name(text *tablename);
|
||||
static AclMode convert_table_priv_string(text *priv_type_text);
|
||||
static Oid convert_database_name(text *databasename);
|
||||
static Oid convert_database_name(text *databasename);
|
||||
static AclMode convert_database_priv_string(text *priv_type_text);
|
||||
static Oid convert_function_name(text *functionname);
|
||||
static Oid convert_function_name(text *functionname);
|
||||
static AclMode convert_function_priv_string(text *priv_type_text);
|
||||
static Oid convert_language_name(text *languagename);
|
||||
static Oid convert_language_name(text *languagename);
|
||||
static AclMode convert_language_priv_string(text *priv_type_text);
|
||||
static Oid convert_schema_name(text *schemaname);
|
||||
static Oid convert_schema_name(text *schemaname);
|
||||
static AclMode convert_schema_priv_string(text *priv_type_text);
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
|
||||
owner_default = ACL_ALL_RIGHTS_RELATION;
|
||||
break;
|
||||
case ACL_OBJECT_DATABASE:
|
||||
world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */
|
||||
world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */
|
||||
owner_default = ACL_ALL_RIGHTS_DATABASE;
|
||||
break;
|
||||
case ACL_OBJECT_FUNCTION:
|
||||
@@ -430,7 +430,7 @@ acldefault(GrantObjectType objtype, AclId ownerid)
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "acldefault: bogus objtype %d", (int) objtype);
|
||||
world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
|
||||
owner_default = ACL_NO_RIGHTS;
|
||||
break;
|
||||
}
|
||||
@@ -819,7 +819,7 @@ convert_table_name(text *tablename)
|
||||
RangeVar *relrv;
|
||||
|
||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(tablename,
|
||||
"has_table_privilege"));
|
||||
"has_table_privilege"));
|
||||
|
||||
return RangeVarGetRelid(relrv, false);
|
||||
}
|
||||
@@ -834,7 +834,7 @@ convert_table_priv_string(text *priv_type_text)
|
||||
char *priv_type;
|
||||
|
||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(priv_type_text)));
|
||||
PointerGetDatum(priv_type_text)));
|
||||
|
||||
/*
|
||||
* Return mode from priv_type string
|
||||
@@ -1030,7 +1030,7 @@ convert_database_name(text *databasename)
|
||||
Oid oid;
|
||||
|
||||
dbname = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(databasename)));
|
||||
PointerGetDatum(databasename)));
|
||||
|
||||
oid = get_database_oid(dbname);
|
||||
if (!OidIsValid(oid))
|
||||
@@ -1049,7 +1049,7 @@ convert_database_priv_string(text *priv_type_text)
|
||||
char *priv_type;
|
||||
|
||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(priv_type_text)));
|
||||
PointerGetDatum(priv_type_text)));
|
||||
|
||||
/*
|
||||
* Return mode from priv_type string
|
||||
@@ -1233,10 +1233,10 @@ convert_function_name(text *functionname)
|
||||
Oid oid;
|
||||
|
||||
funcname = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(functionname)));
|
||||
PointerGetDatum(functionname)));
|
||||
|
||||
oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein,
|
||||
CStringGetDatum(funcname)));
|
||||
CStringGetDatum(funcname)));
|
||||
|
||||
if (!OidIsValid(oid))
|
||||
elog(ERROR, "function \"%s\" does not exist", funcname);
|
||||
@@ -1254,7 +1254,7 @@ convert_function_priv_string(text *priv_type_text)
|
||||
char *priv_type;
|
||||
|
||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(priv_type_text)));
|
||||
PointerGetDatum(priv_type_text)));
|
||||
|
||||
/*
|
||||
* Return mode from priv_type string
|
||||
@@ -1432,7 +1432,7 @@ convert_language_name(text *languagename)
|
||||
Oid oid;
|
||||
|
||||
langname = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(languagename)));
|
||||
PointerGetDatum(languagename)));
|
||||
|
||||
oid = GetSysCacheOid(LANGNAME,
|
||||
CStringGetDatum(langname),
|
||||
@@ -1453,7 +1453,7 @@ convert_language_priv_string(text *priv_type_text)
|
||||
char *priv_type;
|
||||
|
||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(priv_type_text)));
|
||||
PointerGetDatum(priv_type_text)));
|
||||
|
||||
/*
|
||||
* Return mode from priv_type string
|
||||
@@ -1631,7 +1631,7 @@ convert_schema_name(text *schemaname)
|
||||
Oid oid;
|
||||
|
||||
nspname = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(schemaname)));
|
||||
PointerGetDatum(schemaname)));
|
||||
|
||||
oid = GetSysCacheOid(NAMESPACENAME,
|
||||
CStringGetDatum(nspname),
|
||||
@@ -1652,7 +1652,7 @@ convert_schema_priv_string(text *priv_type_text)
|
||||
char *priv_type;
|
||||
|
||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(priv_type_text)));
|
||||
PointerGetDatum(priv_type_text)));
|
||||
|
||||
/*
|
||||
* Return mode from priv_type string
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.79 2002/08/26 17:53:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.80 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -80,27 +80,27 @@ static void system_cache_lookup(Oid element_type, bool input, int *typlen,
|
||||
bool *typbyval, char *typdelim, Oid *typelem,
|
||||
Oid *proc, char *typalign);
|
||||
static Datum ArrayCast(char *value, bool byval, int len);
|
||||
static int ArrayCastAndSet(Datum src,
|
||||
int typlen, bool typbyval, char typalign,
|
||||
char *dest);
|
||||
static int array_nelems_size(char *ptr, int nitems,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static int ArrayCastAndSet(Datum src,
|
||||
int typlen, bool typbyval, char typalign,
|
||||
char *dest);
|
||||
static int array_nelems_size(char *ptr, int nitems,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static char *array_seek(char *ptr, int nitems,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static int array_copy(char *destptr, int nitems, char *srcptr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static int array_copy(char *destptr, int nitems, char *srcptr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static int array_slice_size(int ndim, int *dim, int *lb, char *arraydataptr,
|
||||
int *st, int *endp,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
int *st, int *endp,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static void array_extract_slice(int ndim, int *dim, int *lb,
|
||||
char *arraydataptr,
|
||||
int *st, int *endp, char *destPtr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
char *arraydataptr,
|
||||
int *st, int *endp, char *destPtr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
static void array_insert_slice(int ndim, int *dim, int *lb,
|
||||
char *origPtr, int origdatasize,
|
||||
char *destPtr,
|
||||
int *st, int *endp, char *srcPtr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
char *origPtr, int origdatasize,
|
||||
char *destPtr,
|
||||
int *st, int *endp, char *srcPtr,
|
||||
int typlen, bool typbyval, char typalign);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
@@ -422,28 +422,28 @@ ReadArrayStr(char *arrayStr,
|
||||
elog(ERROR, "malformed array constant: %s", arrayStr);
|
||||
break;
|
||||
case '\\':
|
||||
{
|
||||
char *cptr;
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
/* Crunch the string on top of the backslash. */
|
||||
for (cptr = ptr; *cptr != '\0'; cptr++)
|
||||
*cptr = *(cptr + 1);
|
||||
if (*ptr == '\0')
|
||||
elog(ERROR, "malformed array constant: %s", arrayStr);
|
||||
break;
|
||||
}
|
||||
/* Crunch the string on top of the backslash. */
|
||||
for (cptr = ptr; *cptr != '\0'; cptr++)
|
||||
*cptr = *(cptr + 1);
|
||||
if (*ptr == '\0')
|
||||
elog(ERROR, "malformed array constant: %s", arrayStr);
|
||||
break;
|
||||
}
|
||||
case '\"':
|
||||
{
|
||||
char *cptr;
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
scanning_string = !scanning_string;
|
||||
/* Crunch the string on top of the quote. */
|
||||
for (cptr = ptr; *cptr != '\0'; cptr++)
|
||||
*cptr = *(cptr + 1);
|
||||
/* Back up to not miss following character. */
|
||||
ptr--;
|
||||
break;
|
||||
}
|
||||
scanning_string = !scanning_string;
|
||||
/* Crunch the string on top of the quote. */
|
||||
for (cptr = ptr; *cptr != '\0'; cptr++)
|
||||
*cptr = *(cptr + 1);
|
||||
/* Back up to not miss following character. */
|
||||
ptr--;
|
||||
break;
|
||||
}
|
||||
case '{':
|
||||
if (!scanning_string)
|
||||
{
|
||||
@@ -452,9 +452,9 @@ ReadArrayStr(char *arrayStr,
|
||||
nest_level++;
|
||||
indx[nest_level - 1] = 0;
|
||||
/* skip leading whitespace */
|
||||
while (isspace((unsigned char) *(ptr+1)))
|
||||
while (isspace((unsigned char) *(ptr + 1)))
|
||||
ptr++;
|
||||
itemstart = ptr+1;
|
||||
itemstart = ptr + 1;
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
@@ -471,11 +471,11 @@ ReadArrayStr(char *arrayStr,
|
||||
else
|
||||
{
|
||||
/*
|
||||
* tricky coding: terminate item value string at
|
||||
* first '}', but don't process it till we see
|
||||
* a typdelim char or end of array. This handles
|
||||
* case where several '}'s appear successively
|
||||
* in a multidimensional array.
|
||||
* tricky coding: terminate item value string
|
||||
* at first '}', but don't process it till we
|
||||
* see a typdelim char or end of array. This
|
||||
* handles case where several '}'s appear
|
||||
* successively in a multidimensional array.
|
||||
*/
|
||||
*ptr = '\0';
|
||||
indx[nest_level - 1]++;
|
||||
@@ -641,8 +641,8 @@ array_out(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* Convert all values to string form, count total space needed
|
||||
* (including any overhead such as escaping backslashes),
|
||||
* and detect whether each item needs double quotes.
|
||||
* (including any overhead such as escaping backslashes), and detect
|
||||
* whether each item needs double quotes.
|
||||
*/
|
||||
values = (char **) palloc(nitems * sizeof(char *));
|
||||
needquotes = (bool *) palloc(nitems * sizeof(bool));
|
||||
@@ -665,7 +665,7 @@ array_out(PG_FUNCTION_ARGS)
|
||||
nq = (values[i][0] == '\0'); /* force quotes for empty string */
|
||||
for (tmp = values[i]; *tmp; tmp++)
|
||||
{
|
||||
char ch = *tmp;
|
||||
char ch = *tmp;
|
||||
|
||||
overall_length += 1;
|
||||
if (ch == '"' || ch == '\\')
|
||||
@@ -716,7 +716,7 @@ array_out(PG_FUNCTION_ARGS)
|
||||
#ifndef TCL_ARRAYS
|
||||
for (tmp = values[k]; *tmp; tmp++)
|
||||
{
|
||||
char ch = *tmp;
|
||||
char ch = *tmp;
|
||||
|
||||
if (ch == '"' || ch == '\\')
|
||||
*p++ = '\\';
|
||||
@@ -919,8 +919,8 @@ array_get_slice(ArrayType *array,
|
||||
elog(ERROR, "Slices of fixed-length arrays not implemented");
|
||||
|
||||
/*
|
||||
* fixed-length arrays -- these are assumed to be 1-d, 0-based
|
||||
* XXX where would we get the correct ELEMTYPE from?
|
||||
* fixed-length arrays -- these are assumed to be 1-d, 0-based XXX
|
||||
* where would we get the correct ELEMTYPE from?
|
||||
*/
|
||||
ndim = 1;
|
||||
fixedDim[0] = arraylen / elmlen;
|
||||
@@ -980,8 +980,9 @@ array_get_slice(ArrayType *array,
|
||||
newarray->flags = 0;
|
||||
newarray->elemtype = ARR_ELEMTYPE(array);
|
||||
memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int));
|
||||
|
||||
/*
|
||||
* Lower bounds of the new array are set to 1. Formerly (before 7.3)
|
||||
* Lower bounds of the new array are set to 1. Formerly (before 7.3)
|
||||
* we copied the given lowerIndx values ... but that seems confusing.
|
||||
*/
|
||||
newlb = ARR_LBOUND(newarray);
|
||||
@@ -1513,9 +1514,7 @@ construct_array(Datum *elems, int nelems,
|
||||
|
||||
/* compute required space */
|
||||
if (elmlen > 0)
|
||||
{
|
||||
nbytes = nelems * att_align(elmlen, elmalign);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert(!elmbyval);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* workings can be found in the book "Software Solutions in C" by
|
||||
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.55 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.56 2002/09/04 20:31:27 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@@ -662,8 +662,8 @@ cash_words(PG_FUNCTION_ARGS)
|
||||
|
||||
m0 = val % 100; /* cents */
|
||||
m1 = (val / 100) % 1000; /* hundreds */
|
||||
m2 = (val / 100000) % 1000; /* thousands */
|
||||
m3 = val / 100000000 % 1000; /* millions */
|
||||
m2 = (val / 100000) % 1000; /* thousands */
|
||||
m3 = val / 100000000 % 1000; /* millions */
|
||||
|
||||
if (m3)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.71 2002/09/03 19:41:28 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.72 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -28,10 +28,10 @@
|
||||
#include "utils/timestamp.h"
|
||||
|
||||
|
||||
int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec);
|
||||
int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp);
|
||||
int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result);
|
||||
int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result);
|
||||
int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec);
|
||||
int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp);
|
||||
int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result);
|
||||
int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result);
|
||||
static void AdjustTimeForTypmod(TimeADT *time, int32 typmod);
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -343,7 +343,7 @@ date_timestamptz(PG_FUNCTION_ARGS)
|
||||
|
||||
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
|
||||
{
|
||||
int tz;
|
||||
int tz;
|
||||
|
||||
tm->tm_hour = 0;
|
||||
tm->tm_min = 0;
|
||||
@@ -494,6 +494,7 @@ Datum
|
||||
time_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char *str = PG_GETARG_CSTRING(0);
|
||||
|
||||
#ifdef NOT_USED
|
||||
Oid typelem = PG_GETARG_OID(1);
|
||||
#endif
|
||||
@@ -529,7 +530,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
*result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
|
||||
* INT64CONST(1000000)) + fsec);
|
||||
* INT64CONST(1000000)) + fsec);
|
||||
#else
|
||||
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
|
||||
#endif
|
||||
@@ -542,7 +543,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result)
|
||||
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
|
||||
*/
|
||||
int
|
||||
time2tm(TimeADT time, struct tm *tm, fsec_t *fsec)
|
||||
time2tm(TimeADT time, struct tm * tm, fsec_t *fsec)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
tm->tm_hour = (time / INT64CONST(3600000000));
|
||||
@@ -610,7 +611,7 @@ static void
|
||||
AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
static const int64 TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const int64 TimeScales[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
INT64CONST(1000000),
|
||||
INT64CONST(100000),
|
||||
INT64CONST(10000),
|
||||
@@ -620,7 +621,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
INT64CONST(1)
|
||||
};
|
||||
|
||||
static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
INT64CONST(-500000),
|
||||
INT64CONST(-50000),
|
||||
INT64CONST(-5000),
|
||||
@@ -629,8 +630,9 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
INT64CONST(-5),
|
||||
INT64CONST(0)
|
||||
};
|
||||
|
||||
#else
|
||||
static const double TimeScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const double TimeScales[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
1,
|
||||
10,
|
||||
100,
|
||||
@@ -640,7 +642,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
1000000
|
||||
};
|
||||
|
||||
static const double TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const double TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
0.5,
|
||||
0.05,
|
||||
0.005,
|
||||
@@ -674,7 +676,10 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Scale and truncate first, then add to help the rounding behavior */
|
||||
/*
|
||||
* Scale and truncate first, then add to help the rounding
|
||||
* behavior
|
||||
*/
|
||||
*time = (rint((((double) *time) * TimeScales[typmod]) + TimeOffsets[typmod])
|
||||
/ TimeScales[typmod]);
|
||||
}
|
||||
@@ -915,8 +920,10 @@ timestamp_time(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "Unable to convert timestamp to time");
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
/* Could also do this with
|
||||
* time = (timestamp / 86400000000 * 86400000000) - timestamp;
|
||||
|
||||
/*
|
||||
* Could also do this with time = (timestamp / 86400000000 *
|
||||
* 86400000000) - timestamp;
|
||||
*/
|
||||
result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
|
||||
* INT64CONST(1000000)) + fsec);
|
||||
@@ -948,8 +955,10 @@ timestamptz_time(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "Unable to convert timestamptz to time");
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
/* Could also do this with
|
||||
* time = (timestamp / 86400000000 * 86400000000) - timestamp;
|
||||
|
||||
/*
|
||||
* Could also do this with time = (timestamp / 86400000000 *
|
||||
* 86400000000) - timestamp;
|
||||
*/
|
||||
result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec)
|
||||
* INT64CONST(1000000)) + fsec);
|
||||
@@ -1349,7 +1358,7 @@ timetz_out(PG_FUNCTION_ARGS)
|
||||
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
|
||||
*/
|
||||
int
|
||||
timetz2tm(TimeTzADT *time, struct tm *tm, fsec_t *fsec, int *tzp)
|
||||
timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
tm->tm_hour = (time->time / INT64CONST(3600000000));
|
||||
@@ -1537,6 +1546,7 @@ timetz_pl_interval(PG_FUNCTION_ARGS)
|
||||
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeTzADT *result;
|
||||
|
||||
#ifndef HAVE_INT64_TIMESTAMP
|
||||
TimeTzADT time1;
|
||||
#endif
|
||||
@@ -1569,6 +1579,7 @@ timetz_mi_interval(PG_FUNCTION_ARGS)
|
||||
TimeTzADT *time = PG_GETARG_TIMETZADT_P(0);
|
||||
Interval *span = PG_GETARG_INTERVAL_P(1);
|
||||
TimeTzADT *result;
|
||||
|
||||
#ifndef HAVE_INT64_TIMESTAMP
|
||||
TimeTzADT time1;
|
||||
#endif
|
||||
@@ -1798,7 +1809,7 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS)
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
result = (((date * INT64CONST(86400000000)) + time->time)
|
||||
+ (time->zone * INT64CONST(1000000)));
|
||||
+ (time->zone * INT64CONST(1000000)));
|
||||
#else
|
||||
result = (((date * 86400.0) + time->time) + time->zone);
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.24 2002/08/24 15:00:46 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.25 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -81,7 +81,7 @@ datumGetSize(Datum value, bool typByVal, int typLen)
|
||||
else if (typLen == -2)
|
||||
{
|
||||
/* It is a cstring datatype */
|
||||
char *s = (char *) DatumGetPointer(value);
|
||||
char *s = (char *) DatumGetPointer(value);
|
||||
|
||||
if (!PointerIsValid(s))
|
||||
elog(ERROR, "datumGetSize: Invalid Datum Pointer");
|
||||
@@ -175,9 +175,9 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen)
|
||||
/*
|
||||
* just compare the two datums. NOTE: just comparing "len" bytes
|
||||
* will not do the work, because we do not know how these bytes
|
||||
* are aligned inside the "Datum". We assume instead that any
|
||||
* given datatype is consistent about how it fills extraneous
|
||||
* bits in the Datum.
|
||||
* are aligned inside the "Datum". We assume instead that any
|
||||
* given datatype is consistent about how it fills extraneous bits
|
||||
* in the Datum.
|
||||
*/
|
||||
res = (value1 == value2);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.80 2002/08/26 17:53:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.81 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1515,7 +1515,7 @@ float8_accum(PG_FUNCTION_ARGS)
|
||||
|
||||
result = construct_array(transdatums, 3,
|
||||
FLOAT8OID,
|
||||
sizeof(float8), false /*float8 byval*/, 'd');
|
||||
sizeof(float8), false /* float8 byval */ , 'd');
|
||||
|
||||
PG_RETURN_ARRAYTYPE_P(result);
|
||||
}
|
||||
@@ -1551,7 +1551,7 @@ float4_accum(PG_FUNCTION_ARGS)
|
||||
|
||||
result = construct_array(transdatums, 3,
|
||||
FLOAT8OID,
|
||||
sizeof(float8), false /*float8 byval*/, 'd');
|
||||
sizeof(float8), false /* float8 byval */ , 'd');
|
||||
|
||||
PG_RETURN_ARRAYTYPE_P(result);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.33 2002/08/29 07:22:26 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.34 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,8 +31,9 @@
|
||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
||||
|
||||
static char *format_type_internal(Oid type_oid, int32 typemod,
|
||||
bool typemod_given, bool allow_invalid);
|
||||
static char *psnprintf(size_t len, const char *fmt, ...)
|
||||
bool typemod_given, bool allow_invalid);
|
||||
static char *
|
||||
psnprintf(size_t len, const char *fmt,...)
|
||||
/* This lets gcc check the format string for consistency. */
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
|
||||
@@ -47,14 +48,14 @@ __attribute__((format(printf, 2, 3)));
|
||||
* double quoted if it contains funny characters or matches a keyword.
|
||||
*
|
||||
* If typemod is NULL then we are formatting a type name in a context where
|
||||
* no typemod is available, eg a function argument or result type. This
|
||||
* no typemod is available, eg a function argument or result type. This
|
||||
* yields a slightly different result from specifying typemod = -1 in some
|
||||
* cases. Given typemod = -1 we feel compelled to produce an output that
|
||||
* the parser will interpret as having typemod -1, so that pg_dump will
|
||||
* produce CREATE TABLE commands that recreate the original state. But
|
||||
* produce CREATE TABLE commands that recreate the original state. But
|
||||
* given NULL typemod, we assume that the parser's interpretation of
|
||||
* typemod doesn't matter, and so we are willing to output a slightly
|
||||
* "prettier" representation of the same type. For example, type = bpchar
|
||||
* "prettier" representation of the same type. For example, type = bpchar
|
||||
* and typemod = NULL gets you "character", whereas typemod = -1 gets you
|
||||
* "bpchar" --- the former will be interpreted as character(1) by the
|
||||
* parser, which does not yield typemod -1.
|
||||
@@ -77,9 +78,7 @@ format_type(PG_FUNCTION_ARGS)
|
||||
type_oid = PG_GETARG_OID(0);
|
||||
|
||||
if (PG_ARGISNULL(1))
|
||||
{
|
||||
result = format_type_internal(type_oid, -1, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
typemod = PG_GETARG_INT32(1);
|
||||
@@ -141,7 +140,7 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
|
||||
/*
|
||||
* Check if it's an array (and not a domain --- we don't want to show
|
||||
* the substructure of a domain type). Fixed-length array types such
|
||||
* the substructure of a domain type). Fixed-length array types such
|
||||
* as "name" shouldn't get deconstructed either.
|
||||
*/
|
||||
array_base_type = typeform->typelem;
|
||||
@@ -171,15 +170,15 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
is_array = false;
|
||||
|
||||
/*
|
||||
* See if we want to special-case the output for certain built-in types.
|
||||
* Note that these special cases should all correspond to special
|
||||
* productions in gram.y, to ensure that the type name will be taken as
|
||||
* a system type, not a user type of the same name.
|
||||
* See if we want to special-case the output for certain built-in
|
||||
* types. Note that these special cases should all correspond to
|
||||
* special productions in gram.y, to ensure that the type name will be
|
||||
* taken as a system type, not a user type of the same name.
|
||||
*
|
||||
* If we do not provide a special-case output here, the type name will
|
||||
* be handled the same way as a user type name --- in particular, it
|
||||
* will be double-quoted if it matches any lexer keyword. This behavior
|
||||
* is essential for some cases, such as types "bit" and "char".
|
||||
* If we do not provide a special-case output here, the type name will be
|
||||
* handled the same way as a user type name --- in particular, it will
|
||||
* be double-quoted if it matches any lexer keyword. This behavior is
|
||||
* essential for some cases, such as types "bit" and "char".
|
||||
*/
|
||||
buf = NULL; /* flag for no special case */
|
||||
|
||||
@@ -277,36 +276,36 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
case INTERVAL_MASK(SECOND):
|
||||
fieldstr = " second";
|
||||
break;
|
||||
case INTERVAL_MASK(YEAR)
|
||||
| INTERVAL_MASK(MONTH):
|
||||
case INTERVAL_MASK(YEAR)
|
||||
| INTERVAL_MASK(MONTH):
|
||||
fieldstr = " year to month";
|
||||
break;
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR):
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR):
|
||||
fieldstr = " day to hour";
|
||||
break;
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE):
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE):
|
||||
fieldstr = " day to minute";
|
||||
break;
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(DAY)
|
||||
| INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
fieldstr = " day to second";
|
||||
break;
|
||||
case INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE):
|
||||
case INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE):
|
||||
fieldstr = " hour to minute";
|
||||
break;
|
||||
case INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(HOUR)
|
||||
| INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
fieldstr = " hour to second";
|
||||
break;
|
||||
case INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(MINUTE)
|
||||
| INTERVAL_MASK(SECOND):
|
||||
fieldstr = " minute to second";
|
||||
break;
|
||||
case INTERVAL_FULL_RANGE:
|
||||
@@ -382,9 +381,9 @@ format_type_internal(Oid type_oid, int32 typemod,
|
||||
{
|
||||
/*
|
||||
* Default handling: report the name as it appears in the catalog.
|
||||
* Here, we must qualify the name if it is not visible in the search
|
||||
* path, and we must double-quote it if it's not a standard identifier
|
||||
* or if it matches any keyword.
|
||||
* Here, we must qualify the name if it is not visible in the
|
||||
* search path, and we must double-quote it if it's not a standard
|
||||
* identifier or if it matches any keyword.
|
||||
*/
|
||||
char *nspname;
|
||||
char *typname;
|
||||
@@ -518,7 +517,7 @@ oidvectortypes(PG_FUNCTION_ARGS)
|
||||
|
||||
/* snprintf into a palloc'd string */
|
||||
static char *
|
||||
psnprintf(size_t len, const char *fmt, ...)
|
||||
psnprintf(size_t len, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
char *buf;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* formatting.c
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.53 2002/04/21 19:48:12 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.54 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
|
||||
@@ -2438,9 +2438,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
||||
sscanf(inout, "%03d", &tmfc->year);
|
||||
|
||||
/*
|
||||
* 3-digit year:
|
||||
* '100' ... '999' = 1100 ... 1999
|
||||
* '000' ... '099' = 2000 ... 2099
|
||||
* 3-digit year: '100' ... '999' = 1100 ... 1999 '000' ...
|
||||
* '099' = 2000 ... 2099
|
||||
*/
|
||||
if (tmfc->year >= 100)
|
||||
tmfc->year += 1000;
|
||||
@@ -2469,9 +2468,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
||||
sscanf(inout, "%02d", &tmfc->year);
|
||||
|
||||
/*
|
||||
* 2-digit year:
|
||||
* '00' ... '69' = 2000 ... 2069
|
||||
* '70' ... '99' = 1970 ... 1999
|
||||
* 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ...
|
||||
* '99' = 1970 ... 1999
|
||||
*/
|
||||
if (tmfc->year < 70)
|
||||
tmfc->year += 2000;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.64 2002/08/29 23:05:44 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.65 2002/09/04 20:31:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1236,7 +1236,7 @@ path_in(PG_FUNCTION_ARGS)
|
||||
depth++;
|
||||
}
|
||||
|
||||
size = offsetof(PATH, p[0]) + sizeof(path->p[0]) * npts;
|
||||
size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts;
|
||||
path = (PATH *) palloc(size);
|
||||
|
||||
path->size = size;
|
||||
@@ -2155,8 +2155,8 @@ dist_ps_internal(Point *pt, LSEG *lseg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Calculate distance to the line segment
|
||||
* or to the endpoints of the segment.
|
||||
* Calculate distance to the line segment or to the endpoints of the
|
||||
* segment.
|
||||
*/
|
||||
|
||||
/* intersection is on the line segment? */
|
||||
@@ -2397,9 +2397,7 @@ interpt_sl(LSEG *lseg, LINE *line)
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
@@ -3610,7 +3608,7 @@ path_add(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts);
|
||||
size = offsetof(PATH, p[0]) + base_size;
|
||||
size = offsetof(PATH, p[0]) +base_size;
|
||||
|
||||
/* Check for integer overflow */
|
||||
if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
|
||||
@@ -4436,7 +4434,7 @@ circle_poly(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "Unable to convert circle to polygon");
|
||||
|
||||
base_size = sizeof(poly->p[0]) * npts;
|
||||
size = offsetof(POLYGON, p[0]) + base_size;
|
||||
size = offsetof(POLYGON, p[0]) +base_size;
|
||||
|
||||
/* Check for integer overflow */
|
||||
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.40 2002/06/20 20:29:37 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.41 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -70,14 +70,16 @@ int8in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
ptr++;
|
||||
sign = -1;
|
||||
|
||||
/*
|
||||
* Do an explicit check for INT64_MIN. Ugly though this is, it's
|
||||
* cleaner than trying to get the loop below to handle it portably.
|
||||
* Do an explicit check for INT64_MIN. Ugly though this is, it's
|
||||
* cleaner than trying to get the loop below to handle it
|
||||
* portably.
|
||||
*/
|
||||
#ifndef INT64_IS_BUSTED
|
||||
if (strcmp(ptr, "9223372036854775808") == 0)
|
||||
{
|
||||
result = - INT64CONST(0x7fffffffffffffff) - 1;
|
||||
result = -INT64CONST(0x7fffffffffffffff) - 1;
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
*
|
||||
* lockfuncs.c
|
||||
* Set-returning functions to view the state of locks within the DB.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.6 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.7 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,19 +33,22 @@ typedef struct
|
||||
Datum
|
||||
pg_lock_status(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FuncCallContext *funcctx;
|
||||
PG_Lock_Status *mystatus;
|
||||
FuncCallContext *funcctx;
|
||||
PG_Lock_Status *mystatus;
|
||||
LockData *lockData;
|
||||
|
||||
if (SRF_IS_FIRSTCALL())
|
||||
{
|
||||
TupleDesc tupdesc;
|
||||
MemoryContext oldcontext;
|
||||
TupleDesc tupdesc;
|
||||
MemoryContext oldcontext;
|
||||
|
||||
/* create a function context for cross-call persistence */
|
||||
funcctx = SRF_FIRSTCALL_INIT();
|
||||
|
||||
/* switch to memory context appropriate for multiple function calls */
|
||||
/*
|
||||
* switch to memory context appropriate for multiple function
|
||||
* calls
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||
|
||||
/* build tupdesc for result tuples */
|
||||
@@ -67,8 +70,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
funcctx->slot = TupleDescGetSlot(tupdesc);
|
||||
|
||||
/*
|
||||
* Collect all the locking information that we will format
|
||||
* and send out as a result set.
|
||||
* Collect all the locking information that we will format and
|
||||
* send out as a result set.
|
||||
*/
|
||||
mystatus = (PG_Lock_Status *) palloc(sizeof(PG_Lock_Status));
|
||||
funcctx->user_fctx = (void *) mystatus;
|
||||
@@ -79,25 +82,25 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
|
||||
funcctx = SRF_PERCALL_SETUP();
|
||||
funcctx = SRF_PERCALL_SETUP();
|
||||
mystatus = (PG_Lock_Status *) funcctx->user_fctx;
|
||||
lockData = mystatus->lockData;
|
||||
|
||||
while (mystatus->currIdx < lockData->nelements)
|
||||
{
|
||||
PROCLOCK *holder;
|
||||
LOCK *lock;
|
||||
PGPROC *proc;
|
||||
bool granted;
|
||||
LOCKMODE mode;
|
||||
Datum values[6];
|
||||
char nulls[6];
|
||||
HeapTuple tuple;
|
||||
Datum result;
|
||||
PROCLOCK *holder;
|
||||
LOCK *lock;
|
||||
PGPROC *proc;
|
||||
bool granted;
|
||||
LOCKMODE mode;
|
||||
Datum values[6];
|
||||
char nulls[6];
|
||||
HeapTuple tuple;
|
||||
Datum result;
|
||||
|
||||
holder = &(lockData->holders[mystatus->currIdx]);
|
||||
lock = &(lockData->locks[mystatus->currIdx]);
|
||||
proc = &(lockData->procs[mystatus->currIdx]);
|
||||
holder = &(lockData->holders[mystatus->currIdx]);
|
||||
lock = &(lockData->locks[mystatus->currIdx]);
|
||||
proc = &(lockData->procs[mystatus->currIdx]);
|
||||
|
||||
/*
|
||||
* Look to see if there are any held lock modes in this PROCLOCK.
|
||||
@@ -116,8 +119,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* If no (more) held modes to report, see if PROC is waiting for
|
||||
* a lock on this lock.
|
||||
* If no (more) held modes to report, see if PROC is waiting for a
|
||||
* lock on this lock.
|
||||
*/
|
||||
if (!granted)
|
||||
{
|
||||
@@ -125,6 +128,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* Yes, so report it with proper mode */
|
||||
mode = proc->waitLockMode;
|
||||
|
||||
/*
|
||||
* We are now done with this PROCLOCK, so advance pointer
|
||||
* to continue with next one on next call.
|
||||
@@ -134,8 +138,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Okay, we've displayed all the locks associated with this
|
||||
* PROCLOCK, proceed to the next one.
|
||||
* Okay, we've displayed all the locks associated with
|
||||
* this PROCLOCK, proceed to the next one.
|
||||
*/
|
||||
mystatus->currIdx++;
|
||||
continue;
|
||||
@@ -166,7 +170,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
||||
|
||||
values[3] = Int32GetDatum(proc->pid);
|
||||
values[4] = DirectFunctionCall1(textin,
|
||||
CStringGetDatum(GetLockmodeName(mode)));
|
||||
CStringGetDatum(GetLockmodeName(mode)));
|
||||
values[5] = BoolGetDatum(granted);
|
||||
|
||||
tuple = heap_formtuple(funcctx->slot->ttc_tupleDescriptor,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PostgreSQL type definitions for MAC addresses.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.25 2002/08/28 20:46:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.26 2002/09/04 20:31:28 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@@ -81,7 +81,7 @@ macaddr_out(PG_FUNCTION_ARGS)
|
||||
result = (char *) palloc(32);
|
||||
|
||||
snprintf(result, 32, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
|
||||
addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
|
||||
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.26 2002/09/02 02:47:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.27 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ userfntest(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
current_database(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Name db;
|
||||
Name db;
|
||||
|
||||
db = (Name) palloc(NAMEDATALEN);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.98 2002/09/02 02:47:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.99 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -980,8 +980,10 @@ interval_reltime(PG_FUNCTION_ARGS)
|
||||
RelativeTime time;
|
||||
int year,
|
||||
month;
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 span;
|
||||
|
||||
#else
|
||||
double span;
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.40 2002/08/26 17:53:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.41 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ namein(PG_FUNCTION_ARGS)
|
||||
if ((ermsg = pg_verifymbstr(s, len)))
|
||||
elog(ERROR, "%s", ermsg);
|
||||
|
||||
len = pg_mbcliplen(s, len, NAMEDATALEN-1);
|
||||
len = pg_mbcliplen(s, len, NAMEDATALEN - 1);
|
||||
|
||||
result = (NameData *) palloc(NAMEDATALEN);
|
||||
/* always keep it null-padded */
|
||||
@@ -240,8 +240,8 @@ session_user(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
current_schema(PG_FUNCTION_ARGS)
|
||||
{
|
||||
List *search_path = fetch_search_path(false);
|
||||
char *nspname;
|
||||
List *search_path = fetch_search_path(false);
|
||||
char *nspname;
|
||||
|
||||
if (search_path == NIL)
|
||||
PG_RETURN_NULL();
|
||||
@@ -252,18 +252,18 @@ current_schema(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
current_schemas(PG_FUNCTION_ARGS)
|
||||
{
|
||||
List *search_path = fetch_search_path(PG_GETARG_BOOL(0));
|
||||
int nnames = length(search_path);
|
||||
Datum *names;
|
||||
int i;
|
||||
ArrayType *array;
|
||||
List *search_path = fetch_search_path(PG_GETARG_BOOL(0));
|
||||
int nnames = length(search_path);
|
||||
Datum *names;
|
||||
int i;
|
||||
ArrayType *array;
|
||||
|
||||
/* +1 here is just to avoid palloc(0) error */
|
||||
names = (Datum *) palloc((nnames + 1) * sizeof(Datum));
|
||||
i = 0;
|
||||
while (search_path)
|
||||
{
|
||||
char *nspname;
|
||||
char *nspname;
|
||||
|
||||
nspname = get_namespace_name((Oid) lfirsti(search_path));
|
||||
names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname));
|
||||
@@ -273,9 +273,9 @@ current_schemas(PG_FUNCTION_ARGS)
|
||||
|
||||
array = construct_array(names, nnames,
|
||||
NAMEOID,
|
||||
NAMEDATALEN, /* sizeof(Name) */
|
||||
false, /* Name is not by-val */
|
||||
'i'); /* alignment of Name */
|
||||
NAMEDATALEN, /* sizeof(Name) */
|
||||
false, /* Name is not by-val */
|
||||
'i'); /* alignment of Name */
|
||||
|
||||
PG_RETURN_POINTER(array);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.31 2002/08/02 18:15:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.32 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -60,8 +60,8 @@ int4notin(PG_FUNCTION_ARGS)
|
||||
nnames = length(names);
|
||||
if (nnames < 2)
|
||||
elog(ERROR, "int4notin: must provide relationname.attributename");
|
||||
attribute = strVal(nth(nnames-1, names));
|
||||
names = ltruncate(nnames-1, names);
|
||||
attribute = strVal(nth(nnames - 1, names));
|
||||
names = ltruncate(nnames - 1, names);
|
||||
relrv = makeRangeVarFromNameList(names);
|
||||
|
||||
/* Open the relation and get a relation descriptor */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* 1998 Jan Wieck
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.52 2002/09/02 02:47:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.53 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@@ -152,7 +152,7 @@ static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
|
||||
static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
|
||||
static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
|
||||
static void div_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
|
||||
static int select_div_scale(NumericVar *var1, NumericVar *var2);
|
||||
static int select_div_scale(NumericVar *var1, NumericVar *var2);
|
||||
static void mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
|
||||
static void ceil_var(NumericVar *var, NumericVar *result);
|
||||
static void floor_var(NumericVar *var, NumericVar *result);
|
||||
@@ -1906,7 +1906,7 @@ numeric_variance(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
|
||||
mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
|
||||
div_dscale = select_div_scale(&vsumX2, &vNminus1);
|
||||
div_var(&vsumX2, &vNminus1, &vsumX); /* variance */
|
||||
vsumX.dscale = div_dscale;
|
||||
@@ -1985,7 +1985,7 @@ numeric_stddev(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
|
||||
mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */
|
||||
div_dscale = select_div_scale(&vsumX2, &vNminus1);
|
||||
div_var(&vsumX2, &vNminus1, &vsumX); /* variance */
|
||||
vsumX.dscale = div_dscale;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.53 2002/08/27 20:54:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.54 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ pg_atoi(char *s, int size, int c)
|
||||
errno = 0;
|
||||
|
||||
/*
|
||||
* Some versions of strtol treat the empty string as an error, but some
|
||||
* seem not to. Make an explicit test to be sure we catch it.
|
||||
* Some versions of strtol treat the empty string as an error, but
|
||||
* some seem not to. Make an explicit test to be sure we catch it.
|
||||
*/
|
||||
|
||||
if (s == (char *) NULL)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.42 2002/08/29 07:22:27 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.43 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -850,8 +850,8 @@ repeat(PG_FUNCTION_ARGS)
|
||||
/* Check for integer overflow */
|
||||
if (slen != 0 && count != 0)
|
||||
{
|
||||
int check = count * slen;
|
||||
int check2 = check + VARHDRSZ;
|
||||
int check = count * slen;
|
||||
int check2 = check + VARHDRSZ;
|
||||
|
||||
if ((check / slen) != count || check2 <= check)
|
||||
elog(ERROR, "Requested buffer is too large.");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* PostgreSQL locale utilities
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.18 2002/08/09 22:52:04 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.19 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* Portions Copyright (c) 2002, PostgreSQL Global Development Group
|
||||
*
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
* The other categories, LC_MONETARY, LC_NUMERIC, and LC_TIME are also
|
||||
* settable at run-time. However, we don't actually set those locale
|
||||
* categories permanently. This would have bizzare effects like no
|
||||
* categories permanently. This would have bizzare effects like no
|
||||
* longer accepting standard floating-point literals in some locales.
|
||||
* Instead, we only set the locales briefly when needed, cache the
|
||||
* required information obtained from localeconv(), and set them back.
|
||||
@@ -44,10 +44,10 @@ static bool CurrentLocaleConvValid = false;
|
||||
|
||||
/* GUC storage area */
|
||||
|
||||
char *locale_messages;
|
||||
char *locale_monetary;
|
||||
char *locale_numeric;
|
||||
char *locale_time;
|
||||
char *locale_messages;
|
||||
char *locale_monetary;
|
||||
char *locale_numeric;
|
||||
char *locale_time;
|
||||
|
||||
|
||||
/* GUC assign hooks */
|
||||
@@ -60,7 +60,7 @@ char *locale_time;
|
||||
static const char *
|
||||
locale_xxx_assign(int category, const char *value, bool doit, bool interactive)
|
||||
{
|
||||
char *save;
|
||||
char *save;
|
||||
|
||||
save = setlocale(category, NULL);
|
||||
if (!save)
|
||||
@@ -104,7 +104,10 @@ locale_time_assign(const char *value, bool doit, bool interactive)
|
||||
const char *
|
||||
locale_messages_assign(const char *value, bool doit, bool interactive)
|
||||
{
|
||||
/* LC_MESSAGES category does not exist everywhere, but accept it anyway */
|
||||
/*
|
||||
* LC_MESSAGES category does not exist everywhere, but accept it
|
||||
* anyway
|
||||
*/
|
||||
#ifdef LC_MESSAGES
|
||||
if (doit)
|
||||
{
|
||||
@@ -113,15 +116,15 @@ locale_messages_assign(const char *value, bool doit, bool interactive)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *save;
|
||||
char *save;
|
||||
|
||||
save = setlocale(LC_MESSAGES, NULL);
|
||||
if (!save)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!setlocale(LC_MESSAGES, value))
|
||||
return NULL;
|
||||
|
||||
|
||||
setlocale(LC_MESSAGES, save);
|
||||
}
|
||||
#endif
|
||||
@@ -161,7 +164,7 @@ lc_collate_is_c(void)
|
||||
* itself.)
|
||||
*/
|
||||
static void
|
||||
free_struct_lconv(struct lconv *s)
|
||||
free_struct_lconv(struct lconv * s)
|
||||
{
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* ----------
|
||||
* pg_lzcompress.c -
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.14 2001/11/17 06:09:30 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.15 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* This is an implementation of LZ compression for PostgreSQL.
|
||||
* It uses a simple history table and generates 2-3 byte tags
|
||||
@@ -184,7 +184,7 @@
|
||||
* Local definitions
|
||||
* ----------
|
||||
*/
|
||||
#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */
|
||||
#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */
|
||||
#define PGLZ_HISTORY_MASK (PGLZ_HISTORY_LISTS - 1)
|
||||
#define PGLZ_HISTORY_SIZE 4096
|
||||
#define PGLZ_MAX_MATCH 273
|
||||
@@ -202,7 +202,7 @@
|
||||
*/
|
||||
typedef struct PGLZ_HistEntry
|
||||
{
|
||||
struct PGLZ_HistEntry *next; /* links for my hash key's list */
|
||||
struct PGLZ_HistEntry *next; /* links for my hash key's list */
|
||||
struct PGLZ_HistEntry *prev;
|
||||
int hindex; /* my current hash key */
|
||||
char *pos; /* my input position */
|
||||
@@ -418,8 +418,8 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
|
||||
* the best so far. And if we already have a match of 16 or more
|
||||
* bytes, it's worth the call overhead to use memcmp() to check if
|
||||
* this match is equal for the same size. After that we must
|
||||
* fallback to character by character comparison to know the
|
||||
* exact position where the diff occured.
|
||||
* fallback to character by character comparison to know the exact
|
||||
* position where the diff occured.
|
||||
*/
|
||||
thislen = 0;
|
||||
if (len >= 16)
|
||||
@@ -559,9 +559,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
|
||||
good_drop = 100;
|
||||
|
||||
/*
|
||||
* Initialize the history lists to empty. We do not need to zero
|
||||
* the hist_entries[] array; its entries are initialized as they
|
||||
* are used.
|
||||
* Initialize the history lists to empty. We do not need to zero the
|
||||
* hist_entries[] array; its entries are initialized as they are used.
|
||||
*/
|
||||
memset((void *) hist_start, 0, sizeof(hist_start));
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* A pseudo-type isn't really a type and never has any operations, but
|
||||
* we do need to supply input and output functions to satisfy the links
|
||||
* in the pseudo-type's entry in pg_type. In most cases the functions
|
||||
* just throw an error if invoked. (XXX the error messages here cover
|
||||
* just throw an error if invoked. (XXX the error messages here cover
|
||||
* the most common case, but might be confusing in some contexts. Can
|
||||
* we do better?)
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.3 2002/08/26 17:53:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.4 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -127,7 +127,7 @@ anyarray_out(PG_FUNCTION_ARGS)
|
||||
* void_in - input routine for pseudo-type VOID.
|
||||
*
|
||||
* We allow this so that PL functions can return VOID without any special
|
||||
* hack in the PL handler. Whatever value the PL thinks it's returning
|
||||
* hack in the PL handler. Whatever value the PL thinks it's returning
|
||||
* will just be ignored.
|
||||
*/
|
||||
Datum
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.41 2002/06/20 20:29:38 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.42 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* Alistair Crooks added the code for the regex caching
|
||||
* agc - cached the regular expressions used - there's a good chance
|
||||
@@ -53,7 +53,7 @@ struct cached_re_str
|
||||
static int rec = 0; /* # of cached re's */
|
||||
static struct cached_re_str rev[MAX_CACHED_RES]; /* cached re's */
|
||||
static unsigned long lru; /* system lru tag */
|
||||
static int pg_lastrec = 0;
|
||||
static int pg_lastrec = 0;
|
||||
|
||||
/* attempt to compile `re' as an re, then match it against text */
|
||||
/* cflags - flag to regcomp indicates case sensitivity */
|
||||
@@ -70,9 +70,9 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
|
||||
re = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(text_re)));
|
||||
|
||||
/* Find a previously compiled regular expression.
|
||||
* Run the cache as a ring buffer, starting the search
|
||||
* from the previous match if any.
|
||||
/*
|
||||
* Find a previously compiled regular expression. Run the cache as a
|
||||
* ring buffer, starting the search from the previous match if any.
|
||||
*/
|
||||
i = pg_lastrec;
|
||||
while (i < rec)
|
||||
@@ -92,19 +92,16 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
|
||||
}
|
||||
i++;
|
||||
|
||||
/* If we were not at the first slot to start,
|
||||
* then think about wrapping if necessary.
|
||||
/*
|
||||
* If we were not at the first slot to start, then think about
|
||||
* wrapping if necessary.
|
||||
*/
|
||||
if (pg_lastrec != 0)
|
||||
{
|
||||
if (i >= rec)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
else if (i == pg_lastrec)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +116,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oldest = rec++;
|
||||
}
|
||||
|
||||
/* if there was an old re, then de-allocate the space it used */
|
||||
if (rev[oldest].cre_s != (char *) NULL)
|
||||
@@ -148,6 +143,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags,
|
||||
if (regcomp_result == 0)
|
||||
{
|
||||
pg_lastrec = oldest;
|
||||
|
||||
/*
|
||||
* use malloc/free for the cre_s field because the storage has to
|
||||
* persist across transactions
|
||||
@@ -329,10 +325,11 @@ textregexsubstr(PG_FUNCTION_ARGS)
|
||||
sterm = (char *) palloc(len + 1);
|
||||
memcpy(sterm, VARDATA(s), len);
|
||||
sterm[len] = '\0';
|
||||
/* We need the match info back from the pattern match
|
||||
* to be able to actually extract the substring.
|
||||
* It seems to be adequate to pass in a structure to return
|
||||
* only one result.
|
||||
|
||||
/*
|
||||
* We need the match info back from the pattern match to be able to
|
||||
* actually extract the substring. It seems to be adequate to pass in
|
||||
* a structure to return only one result.
|
||||
*/
|
||||
match = RE_compile_and_execute(p, sterm, REG_EXTENDED, nmatch, &pmatch);
|
||||
pfree(sterm);
|
||||
@@ -342,8 +339,8 @@ textregexsubstr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return (DirectFunctionCall3(text_substr,
|
||||
PointerGetDatum(s),
|
||||
Int32GetDatum(pmatch.rm_so+1),
|
||||
Int32GetDatum(pmatch.rm_eo-pmatch.rm_so)));
|
||||
Int32GetDatum(pmatch.rm_so + 1),
|
||||
Int32GetDatum(pmatch.rm_eo - pmatch.rm_so)));
|
||||
}
|
||||
|
||||
PG_RETURN_NULL();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.74 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.75 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,8 +38,8 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
static void parseNameAndArgTypes(const char *string, const char *caller,
|
||||
bool allowNone,
|
||||
List **names, int *nargs, Oid *argtypes);
|
||||
bool allowNone,
|
||||
List **names, int *nargs, Oid *argtypes);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -87,7 +87,7 @@ regprocin(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* In bootstrap mode we assume the given name is not schema-qualified,
|
||||
* and just search pg_proc for a unique match. This is needed for
|
||||
* and just search pg_proc for a unique match. This is needed for
|
||||
* initializing other system catalogs (pg_namespace may not exist yet,
|
||||
* and certainly there are no schemas other than pg_catalog).
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ regprocin(PG_FUNCTION_ARGS)
|
||||
int matches = 0;
|
||||
Relation hdesc;
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc sysscan;
|
||||
SysScanDesc sysscan;
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
@@ -127,8 +127,8 @@ regprocin(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal case: parse the name into components and see if it
|
||||
* matches any pg_proc entries in the current search path.
|
||||
* Normal case: parse the name into components and see if it matches
|
||||
* any pg_proc entries in the current search path.
|
||||
*/
|
||||
names = stringToQualifiedNameList(pro_name_or_oid, "regprocin");
|
||||
clist = FuncnameGetCandidates(names, -1);
|
||||
@@ -175,17 +175,15 @@ regprocout(PG_FUNCTION_ARGS)
|
||||
* output anyway.)
|
||||
*/
|
||||
if (IsBootstrapProcessingMode())
|
||||
{
|
||||
result = pstrdup(proname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *nspname;
|
||||
FuncCandidateList clist;
|
||||
|
||||
/*
|
||||
* Would this proc be found (uniquely!) by regprocin?
|
||||
* If not, qualify it.
|
||||
* Would this proc be found (uniquely!) by regprocin? If not,
|
||||
* qualify it.
|
||||
*/
|
||||
clist = FuncnameGetCandidates(makeList1(makeString(proname)), -1);
|
||||
if (clist != NULL && clist->next == NULL &&
|
||||
@@ -250,10 +248,10 @@ regprocedurein(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Else it's a name and arguments. Parse the name and arguments,
|
||||
* look up potential matches in the current namespace search list,
|
||||
* and scan to see which one exactly matches the given argument
|
||||
* types. (There will not be more than one match.)
|
||||
* Else it's a name and arguments. Parse the name and arguments, look
|
||||
* up potential matches in the current namespace search list, and scan
|
||||
* to see which one exactly matches the given argument types. (There
|
||||
* will not be more than one match.)
|
||||
*
|
||||
* XXX at present, this code will not work in bootstrap mode, hence this
|
||||
* datatype cannot be used for any system column that needs to receive
|
||||
@@ -308,8 +306,8 @@ format_procedure(Oid procedure_oid)
|
||||
initStringInfo(&buf);
|
||||
|
||||
/*
|
||||
* Would this proc be found (given the right args) by regprocedurein?
|
||||
* If not, we need to qualify it.
|
||||
* Would this proc be found (given the right args) by
|
||||
* regprocedurein? If not, we need to qualify it.
|
||||
*/
|
||||
if (FunctionIsVisible(procedure_oid))
|
||||
nspname = NULL;
|
||||
@@ -320,7 +318,7 @@ format_procedure(Oid procedure_oid)
|
||||
quote_qualified_identifier(nspname, proname));
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
Oid thisargtype = procform->proargtypes[i];
|
||||
Oid thisargtype = procform->proargtypes[i];
|
||||
|
||||
if (i > 0)
|
||||
appendStringInfoChar(&buf, ',');
|
||||
@@ -401,7 +399,7 @@ regoperin(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* In bootstrap mode we assume the given name is not schema-qualified,
|
||||
* and just search pg_operator for a unique match. This is needed for
|
||||
* and just search pg_operator for a unique match. This is needed for
|
||||
* initializing other system catalogs (pg_namespace may not exist yet,
|
||||
* and certainly there are no schemas other than pg_catalog).
|
||||
*/
|
||||
@@ -410,7 +408,7 @@ regoperin(PG_FUNCTION_ARGS)
|
||||
int matches = 0;
|
||||
Relation hdesc;
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc sysscan;
|
||||
SysScanDesc sysscan;
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
@@ -441,8 +439,8 @@ regoperin(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal case: parse the name into components and see if it
|
||||
* matches any pg_operator entries in the current search path.
|
||||
* Normal case: parse the name into components and see if it matches
|
||||
* any pg_operator entries in the current search path.
|
||||
*/
|
||||
names = stringToQualifiedNameList(opr_name_or_oid, "regoperin");
|
||||
clist = OpernameGetCandidates(names, '\0');
|
||||
@@ -489,16 +487,14 @@ regoperout(PG_FUNCTION_ARGS)
|
||||
* output anyway.)
|
||||
*/
|
||||
if (IsBootstrapProcessingMode())
|
||||
{
|
||||
result = pstrdup(oprname);
|
||||
}
|
||||
else
|
||||
{
|
||||
FuncCandidateList clist;
|
||||
|
||||
/*
|
||||
* Would this oper be found (uniquely!) by regoperin?
|
||||
* If not, qualify it.
|
||||
* Would this oper be found (uniquely!) by regoperin? If not,
|
||||
* qualify it.
|
||||
*/
|
||||
clist = OpernameGetCandidates(makeList1(makeString(oprname)),
|
||||
'\0');
|
||||
@@ -511,7 +507,7 @@ regoperout(PG_FUNCTION_ARGS)
|
||||
|
||||
nspname = get_namespace_name(operform->oprnamespace);
|
||||
nspname = quote_identifier(nspname);
|
||||
result = (char *) palloc(strlen(nspname)+strlen(oprname)+2);
|
||||
result = (char *) palloc(strlen(nspname) + strlen(oprname) + 2);
|
||||
sprintf(result, "%s.%s", nspname, oprname);
|
||||
}
|
||||
}
|
||||
@@ -520,7 +516,10 @@ regoperout(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If OID doesn't match any pg_operator entry, return it numerically */
|
||||
/*
|
||||
* If OID doesn't match any pg_operator entry, return it
|
||||
* numerically
|
||||
*/
|
||||
result = (char *) palloc(NAMEDATALEN);
|
||||
snprintf(result, NAMEDATALEN, "%u", oprid);
|
||||
}
|
||||
@@ -570,10 +569,10 @@ regoperatorin(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Else it's a name and arguments. Parse the name and arguments,
|
||||
* look up potential matches in the current namespace search list,
|
||||
* and scan to see which one exactly matches the given argument
|
||||
* types. (There will not be more than one match.)
|
||||
* Else it's a name and arguments. Parse the name and arguments, look
|
||||
* up potential matches in the current namespace search list, and scan
|
||||
* to see which one exactly matches the given argument types. (There
|
||||
* will not be more than one match.)
|
||||
*
|
||||
* XXX at present, this code will not work in bootstrap mode, hence this
|
||||
* datatype cannot be used for any system column that needs to receive
|
||||
@@ -637,8 +636,8 @@ format_operator(Oid operator_oid)
|
||||
initStringInfo(&buf);
|
||||
|
||||
/*
|
||||
* Would this oper be found (given the right args) by regoperatorin?
|
||||
* If not, we need to qualify it.
|
||||
* Would this oper be found (given the right args) by
|
||||
* regoperatorin? If not, we need to qualify it.
|
||||
*/
|
||||
if (!OperatorIsVisible(operator_oid))
|
||||
{
|
||||
@@ -667,7 +666,10 @@ format_operator(Oid operator_oid)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If OID doesn't match any pg_operator entry, return it numerically */
|
||||
/*
|
||||
* If OID doesn't match any pg_operator entry, return it
|
||||
* numerically
|
||||
*/
|
||||
result = (char *) palloc(NAMEDATALEN);
|
||||
snprintf(result, NAMEDATALEN, "%u", operator_oid);
|
||||
}
|
||||
@@ -715,12 +717,12 @@ regclassin(PG_FUNCTION_ARGS)
|
||||
/* Numeric OID? */
|
||||
if (class_name_or_oid[0] >= '0' &&
|
||||
class_name_or_oid[0] <= '9' &&
|
||||
strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))
|
||||
strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))
|
||||
{
|
||||
Oid searchOid;
|
||||
|
||||
searchOid = DatumGetObjectId(DirectFunctionCall1(oidin,
|
||||
CStringGetDatum(class_name_or_oid)));
|
||||
CStringGetDatum(class_name_or_oid)));
|
||||
result = GetSysCacheOid(RELOID,
|
||||
ObjectIdGetDatum(searchOid),
|
||||
0, 0, 0);
|
||||
@@ -741,7 +743,7 @@ regclassin(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Relation hdesc;
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc sysscan;
|
||||
SysScanDesc sysscan;
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
@@ -767,8 +769,8 @@ regclassin(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal case: parse the name into components and see if it
|
||||
* matches any pg_class entries in the current search path.
|
||||
* Normal case: parse the name into components and see if it matches
|
||||
* any pg_class entries in the current search path.
|
||||
*/
|
||||
names = stringToQualifiedNameList(class_name_or_oid, "regclassin");
|
||||
|
||||
@@ -808,16 +810,14 @@ regclassout(PG_FUNCTION_ARGS)
|
||||
* output anyway.)
|
||||
*/
|
||||
if (IsBootstrapProcessingMode())
|
||||
{
|
||||
result = pstrdup(classname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *nspname;
|
||||
|
||||
/*
|
||||
* Would this class be found by regclassin?
|
||||
* If not, qualify it.
|
||||
* Would this class be found by regclassin? If not, qualify
|
||||
* it.
|
||||
*/
|
||||
if (RelationIsVisible(classid))
|
||||
nspname = NULL;
|
||||
@@ -894,7 +894,7 @@ regtypein(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Relation hdesc;
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc sysscan;
|
||||
SysScanDesc sysscan;
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
@@ -920,8 +920,8 @@ regtypein(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal case: invoke the full parser to deal with special cases
|
||||
* such as array syntax.
|
||||
* Normal case: invoke the full parser to deal with special cases such
|
||||
* as array syntax.
|
||||
*/
|
||||
parseTypeString(typ_name_or_oid, &result, &typmod);
|
||||
|
||||
@@ -964,9 +964,7 @@ regtypeout(PG_FUNCTION_ARGS)
|
||||
result = pstrdup(typname);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = format_type_be(typid);
|
||||
}
|
||||
|
||||
ReleaseSysCache(typetup);
|
||||
}
|
||||
@@ -1003,7 +1001,7 @@ stringToQualifiedNameList(const char *string, const char *caller)
|
||||
|
||||
foreach(l, namelist)
|
||||
{
|
||||
char *curname = (char *) lfirst(l);
|
||||
char *curname = (char *) lfirst(l);
|
||||
|
||||
result = lappend(result, makeString(pstrdup(curname)));
|
||||
}
|
||||
@@ -1020,7 +1018,7 @@ stringToQualifiedNameList(const char *string, const char *caller)
|
||||
|
||||
/*
|
||||
* Given a C string, parse it into a qualified function or operator name
|
||||
* followed by a parenthesized list of type names. Reduce the
|
||||
* followed by a parenthesized list of type names. Reduce the
|
||||
* type names to an array of OIDs (returned into *nargs and *argtypes;
|
||||
* the argtypes array should be of size FUNC_MAX_ARGS). The function or
|
||||
* operator name is returned to *names as a List of Strings.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.41 2002/09/02 06:11:42 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.42 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@@ -131,9 +131,9 @@ static void ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id,
|
||||
Relation fk_rel, Relation pk_rel,
|
||||
int argc, char **argv);
|
||||
static void ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id,
|
||||
int32 constr_queryno,
|
||||
Relation pk_rel,
|
||||
int argc, char **argv);
|
||||
int32 constr_queryno,
|
||||
Relation pk_rel,
|
||||
int argc, char **argv);
|
||||
static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
|
||||
RI_QueryKey *key, int pairidx);
|
||||
static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
|
||||
@@ -141,8 +141,8 @@ static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
|
||||
static bool ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup,
|
||||
HeapTuple newtup, RI_QueryKey *key, int pairidx);
|
||||
static bool ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue);
|
||||
static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row,
|
||||
Oid tgoid, int match_type, int tgnargs, char **tgargs);
|
||||
static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row,
|
||||
Oid tgoid, int match_type, int tgnargs, char **tgargs);
|
||||
|
||||
static void ri_InitHashTables(void);
|
||||
static void *ri_FetchPreparedPlan(RI_QueryKey *key);
|
||||
@@ -205,8 +205,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
|
||||
* Get the relation descriptors of the FK and PK tables and the new
|
||||
* tuple.
|
||||
*
|
||||
* pk_rel is opened in RowShareLock mode since that's what our
|
||||
* eventual SELECT FOR UPDATE will get on it.
|
||||
* pk_rel is opened in RowShareLock mode since that's what our eventual
|
||||
* SELECT FOR UPDATE will get on it.
|
||||
*/
|
||||
fk_rel = trigdata->tg_relation;
|
||||
pk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
|
||||
@@ -223,11 +223,13 @@ RI_FKey_check(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* We should not even consider checking the row if it is no longer
|
||||
* valid since it was either deleted (doesn't matter) or updated
|
||||
* (in which case it'll be checked with its final values).
|
||||
* valid since it was either deleted (doesn't matter) or updated (in
|
||||
* which case it'll be checked with its final values).
|
||||
*/
|
||||
if (new_row) {
|
||||
if (!HeapTupleSatisfiesItself(new_row->t_data)) {
|
||||
if (new_row)
|
||||
{
|
||||
if (!HeapTupleSatisfiesItself(new_row->t_data))
|
||||
{
|
||||
heap_close(pk_rel, RowShareLock);
|
||||
return PointerGetDatum(NULL);
|
||||
}
|
||||
@@ -263,7 +265,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
quoteRelationName(pkrelname, pk_rel);
|
||||
snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x FOR UPDATE OF x",
|
||||
pkrelname);
|
||||
pkrelname);
|
||||
|
||||
/*
|
||||
* Prepare, save and remember the new plan.
|
||||
@@ -418,9 +420,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
|
||||
for (i = 0; i < qkey.nkeypairs; i++)
|
||||
{
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(fk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_FK_IDX]);
|
||||
@@ -521,32 +523,36 @@ RI_FKey_check_upd(PG_FUNCTION_ARGS)
|
||||
/* ----------
|
||||
* ri_Check_Pk_Match
|
||||
*
|
||||
* Check for matching value of old pk row in current state for
|
||||
* Check for matching value of old pk row in current state for
|
||||
* noaction triggers. Returns false if no row was found and a fk row
|
||||
* could potentially be referencing this row, true otherwise.
|
||||
* ----------
|
||||
*/
|
||||
static bool
|
||||
ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs) {
|
||||
void *qplan;
|
||||
ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs)
|
||||
{
|
||||
void *qplan;
|
||||
RI_QueryKey qkey;
|
||||
bool isnull;
|
||||
bool isnull;
|
||||
Datum check_values[RI_MAX_NUMKEYS];
|
||||
char check_nulls[RI_MAX_NUMKEYS + 1];
|
||||
int i;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
bool result;
|
||||
bool result;
|
||||
|
||||
save_uid = GetUserId();
|
||||
|
||||
ri_BuildQueryKeyPkCheck(&qkey, tgoid,
|
||||
RI_PLAN_CHECK_LOOKUPPK, pk_rel,
|
||||
tgnargs, tgargs);
|
||||
RI_PLAN_CHECK_LOOKUPPK, pk_rel,
|
||||
tgnargs, tgargs);
|
||||
|
||||
switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX))
|
||||
{
|
||||
case RI_KEYS_ALL_NULL:
|
||||
|
||||
/*
|
||||
* No check - nothing could have been referencing this row anyway.
|
||||
* No check - nothing could have been referencing this row
|
||||
* anyway.
|
||||
*/
|
||||
return true;
|
||||
|
||||
@@ -560,10 +566,10 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
|
||||
{
|
||||
case RI_MATCH_TYPE_FULL:
|
||||
case RI_MATCH_TYPE_UNSPECIFIED:
|
||||
|
||||
|
||||
/*
|
||||
* MATCH <unspecified>/FULL - if ANY column is null, we
|
||||
* can't be matching to this row already.
|
||||
* MATCH <unspecified>/FULL - if ANY column is null,
|
||||
* we can't be matching to this row already.
|
||||
*/
|
||||
return true;
|
||||
|
||||
@@ -619,9 +625,9 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
|
||||
for (i = 0; i < qkey.nkeypairs; i++)
|
||||
{
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -644,7 +650,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
|
||||
{
|
||||
check_values[i] = SPI_getbinval(old_row,
|
||||
pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX],
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX],
|
||||
&isnull);
|
||||
if (isnull)
|
||||
check_nulls[i] = 'n';
|
||||
@@ -664,7 +670,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
|
||||
|
||||
SetUserId(save_uid);
|
||||
|
||||
result = (SPI_processed!=0);
|
||||
result = (SPI_processed != 0);
|
||||
|
||||
if (SPI_finish() != SPI_OK_FINISH)
|
||||
elog(WARNING, "SPI_finish() failed in ri_Check_Pk_Match()");
|
||||
@@ -736,8 +742,8 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
|
||||
* Get the relation descriptors of the FK and PK tables and the old
|
||||
* tuple.
|
||||
*
|
||||
* fk_rel is opened in RowShareLock mode since that's what our
|
||||
* eventual SELECT FOR UPDATE will get on it.
|
||||
* fk_rel is opened in RowShareLock mode since that's what our eventual
|
||||
* SELECT FOR UPDATE will get on it.
|
||||
*/
|
||||
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
|
||||
pk_rel = trigdata->tg_relation;
|
||||
@@ -745,10 +751,11 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
|
||||
|
||||
match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
|
||||
if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid,
|
||||
match_type, tgnargs, tgargs)) {
|
||||
/*
|
||||
* There's either another row, or no row could match this
|
||||
* one. In either case, we don't need to do the check.
|
||||
match_type, tgnargs, tgargs))
|
||||
{
|
||||
/*
|
||||
* There's either another row, or no row could match this one. In
|
||||
* either case, we don't need to do the check.
|
||||
*/
|
||||
heap_close(fk_rel, RowShareLock);
|
||||
return PointerGetDatum(NULL);
|
||||
@@ -800,7 +807,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
const char *querysep;
|
||||
@@ -823,7 +830,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -959,8 +966,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
|
||||
* Get the relation descriptors of the FK and PK tables and the new
|
||||
* and old tuple.
|
||||
*
|
||||
* fk_rel is opened in RowShareLock mode since that's what our
|
||||
* eventual SELECT FOR UPDATE will get on it.
|
||||
* fk_rel is opened in RowShareLock mode since that's what our eventual
|
||||
* SELECT FOR UPDATE will get on it.
|
||||
*/
|
||||
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
|
||||
pk_rel = trigdata->tg_relation;
|
||||
@@ -969,10 +976,11 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
|
||||
|
||||
match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
|
||||
if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid,
|
||||
match_type, tgnargs, tgargs)) {
|
||||
/*
|
||||
* There's either another row, or no row could match this
|
||||
* one. In either case, we don't need to do the check.
|
||||
match_type, tgnargs, tgargs))
|
||||
{
|
||||
/*
|
||||
* There's either another row, or no row could match this one. In
|
||||
* either case, we don't need to do the check.
|
||||
*/
|
||||
heap_close(fk_rel, RowShareLock);
|
||||
return PointerGetDatum(NULL);
|
||||
@@ -1034,7 +1042,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
const char *querysep;
|
||||
@@ -1057,7 +1065,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -1241,7 +1249,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
const char *querysep;
|
||||
@@ -1264,7 +1272,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -1455,7 +1463,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
@@ -1483,9 +1491,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
|
||||
qualsep, attname, j+1);
|
||||
qualsep, attname, j + 1);
|
||||
querysep = ",";
|
||||
qualsep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
@@ -1628,8 +1636,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
|
||||
* Get the relation descriptors of the FK and PK tables and the old
|
||||
* tuple.
|
||||
*
|
||||
* fk_rel is opened in RowShareLock mode since that's what our
|
||||
* eventual SELECT FOR UPDATE will get on it.
|
||||
* fk_rel is opened in RowShareLock mode since that's what our eventual
|
||||
* SELECT FOR UPDATE will get on it.
|
||||
*/
|
||||
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
|
||||
pk_rel = trigdata->tg_relation;
|
||||
@@ -1682,7 +1690,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
const char *querysep;
|
||||
@@ -1705,7 +1713,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -1845,8 +1853,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
|
||||
* Get the relation descriptors of the FK and PK tables and the new
|
||||
* and old tuple.
|
||||
*
|
||||
* fk_rel is opened in RowShareLock mode since that's what our
|
||||
* eventual SELECT FOR UPDATE will get on it.
|
||||
* fk_rel is opened in RowShareLock mode since that's what our eventual
|
||||
* SELECT FOR UPDATE will get on it.
|
||||
*/
|
||||
fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
|
||||
pk_rel = trigdata->tg_relation;
|
||||
@@ -1910,7 +1918,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
const char *querysep;
|
||||
@@ -1933,7 +1941,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
|
||||
querysep, attname, i+1);
|
||||
querysep, attname, i + 1);
|
||||
querysep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -2121,7 +2129,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
@@ -2149,9 +2157,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
|
||||
querysep, attname);
|
||||
querysep, attname);
|
||||
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
|
||||
qualsep, attname, i+1);
|
||||
qualsep, attname, i + 1);
|
||||
querysep = ",";
|
||||
qualsep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
@@ -2365,7 +2373,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
|
||||
(qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
@@ -2392,6 +2400,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
|
||||
{
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
|
||||
/*
|
||||
* MATCH <unspecified> - only change columns
|
||||
* corresponding to changed columns in pk_rel's key
|
||||
@@ -2401,11 +2410,11 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
|
||||
RI_KEYPAIR_PK_IDX))
|
||||
{
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
|
||||
querysep, attname);
|
||||
querysep, attname);
|
||||
querysep = ",";
|
||||
}
|
||||
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
|
||||
qualsep, attname, i+1);
|
||||
qualsep, attname, i + 1);
|
||||
qualsep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -2592,7 +2601,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
@@ -2625,9 +2634,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
|
||||
querysep, attname);
|
||||
querysep, attname);
|
||||
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
|
||||
qualsep, attname, i+1);
|
||||
qualsep, attname, i + 1);
|
||||
querysep = ",";
|
||||
qualsep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
@@ -2861,7 +2870,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
{
|
||||
char querystr[MAX_QUOTED_REL_NAME_LEN + 100 +
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2];
|
||||
char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS];
|
||||
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
|
||||
char attname[MAX_QUOTED_NAME_LEN];
|
||||
@@ -2893,6 +2902,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
|
||||
{
|
||||
quoteOneName(attname,
|
||||
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
|
||||
|
||||
/*
|
||||
* MATCH <unspecified> - only change columns
|
||||
* corresponding to changed columns in pk_rel's key
|
||||
@@ -2902,11 +2912,11 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
|
||||
new_row, &qkey, RI_KEYPAIR_PK_IDX))
|
||||
{
|
||||
snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
|
||||
querysep, attname);
|
||||
querysep, attname);
|
||||
querysep = ",";
|
||||
}
|
||||
snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
|
||||
qualsep, attname, i+1);
|
||||
qualsep, attname, i + 1);
|
||||
qualsep = "AND";
|
||||
queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
|
||||
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
|
||||
@@ -3245,8 +3255,8 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
|
||||
*/
|
||||
static void
|
||||
ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
|
||||
Relation pk_rel,
|
||||
int argc, char **argv)
|
||||
Relation pk_rel,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@@ -3588,7 +3598,7 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
|
||||
typeid, typeid, true);
|
||||
if (!OidIsValid(opr_proc))
|
||||
elog(ERROR,
|
||||
"ri_AttributesEqual(): cannot find '=' operator for type %u",
|
||||
"ri_AttributesEqual(): cannot find '=' operator for type %u",
|
||||
typeid);
|
||||
|
||||
/*
|
||||
@@ -3616,4 +3626,3 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
|
||||
return DatumGetBool(FunctionCall2(&(entry->oprfmgrinfo),
|
||||
oldvalue, newvalue));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* back to source text
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.120 2002/08/31 22:10:46 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.121 2002/09/04 20:31:28 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -124,29 +124,29 @@ static char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_c
|
||||
*/
|
||||
static text *pg_do_getviewdef(Oid viewoid);
|
||||
static void decompile_column_index_array(Datum column_index_array, Oid relId,
|
||||
StringInfo buf);
|
||||
StringInfo buf);
|
||||
static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc);
|
||||
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc);
|
||||
static void get_query_def(Query *query, StringInfo buf, List *parentnamespace,
|
||||
TupleDesc resultDesc);
|
||||
TupleDesc resultDesc);
|
||||
static void get_select_query_def(Query *query, deparse_context *context,
|
||||
TupleDesc resultDesc);
|
||||
TupleDesc resultDesc);
|
||||
static void get_insert_query_def(Query *query, deparse_context *context);
|
||||
static void get_update_query_def(Query *query, deparse_context *context);
|
||||
static void get_delete_query_def(Query *query, deparse_context *context);
|
||||
static void get_utility_query_def(Query *query, deparse_context *context);
|
||||
static void get_basic_select_query(Query *query, deparse_context *context,
|
||||
TupleDesc resultDesc);
|
||||
TupleDesc resultDesc);
|
||||
static void get_setop_query(Node *setOp, Query *query,
|
||||
deparse_context *context,
|
||||
TupleDesc resultDesc);
|
||||
deparse_context *context,
|
||||
TupleDesc resultDesc);
|
||||
static Node *get_rule_sortgroupclause(SortClause *srt, List *tlist,
|
||||
bool force_colno,
|
||||
deparse_context *context);
|
||||
static void get_names_for_var(Var *var, deparse_context *context,
|
||||
char **schemaname, char **refname, char **attname);
|
||||
static RangeTblEntry *find_rte_by_refname(const char *refname,
|
||||
deparse_context *context);
|
||||
deparse_context *context);
|
||||
static void get_rule_expr(Node *node, deparse_context *context);
|
||||
static void get_oper_expr(Expr *expr, deparse_context *context);
|
||||
static void get_func_expr(Expr *expr, deparse_context *context);
|
||||
@@ -159,7 +159,7 @@ static void get_from_clause(Query *query, deparse_context *context);
|
||||
static void get_from_clause_item(Node *jtnode, Query *query,
|
||||
deparse_context *context);
|
||||
static void get_from_clause_coldeflist(List *coldeflist,
|
||||
deparse_context *context);
|
||||
deparse_context *context);
|
||||
static void get_opclass_name(Oid opclass, Oid actual_datatype,
|
||||
StringInfo buf);
|
||||
static bool tleIsArrayAssign(TargetEntry *tle);
|
||||
@@ -284,7 +284,7 @@ pg_get_viewdef_name(PG_FUNCTION_ARGS)
|
||||
text *ruledef;
|
||||
|
||||
viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname,
|
||||
"get_viewdef"));
|
||||
"get_viewdef"));
|
||||
viewoid = RangeVarGetRelid(viewrel, false);
|
||||
|
||||
ruledef = pg_do_getviewdef(viewoid);
|
||||
@@ -425,8 +425,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
|
||||
amrec = (Form_pg_am) GETSTRUCT(ht_am);
|
||||
|
||||
/*
|
||||
* Start the index definition. Note that the index's name should never
|
||||
* be schema-qualified, but the indexed rel's name may be.
|
||||
* Start the index definition. Note that the index's name should
|
||||
* never be schema-qualified, but the indexed rel's name may be.
|
||||
*/
|
||||
initStringInfo(&buf);
|
||||
appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
|
||||
@@ -551,15 +551,15 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid constraintId = PG_GETARG_OID(0);
|
||||
text *result;
|
||||
StringInfoData buf;
|
||||
int len;
|
||||
Relation conDesc;
|
||||
SysScanDesc conscan;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tup;
|
||||
Form_pg_constraint conForm;
|
||||
Oid constraintId = PG_GETARG_OID(0);
|
||||
text *result;
|
||||
StringInfoData buf;
|
||||
int len;
|
||||
Relation conDesc;
|
||||
SysScanDesc conscan;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tup;
|
||||
Form_pg_constraint conForm;
|
||||
|
||||
/*
|
||||
* Fetch the pg_constraint row. There's no syscache for pg_constraint
|
||||
@@ -584,111 +584,111 @@ pg_get_constraintdef(PG_FUNCTION_ARGS)
|
||||
switch (conForm->contype)
|
||||
{
|
||||
case CONSTRAINT_FOREIGN:
|
||||
{
|
||||
Datum val;
|
||||
bool isnull;
|
||||
const char *string;
|
||||
{
|
||||
Datum val;
|
||||
bool isnull;
|
||||
const char *string;
|
||||
|
||||
/* Start off the constraint definition */
|
||||
appendStringInfo(&buf, "FOREIGN KEY (");
|
||||
/* Start off the constraint definition */
|
||||
appendStringInfo(&buf, "FOREIGN KEY (");
|
||||
|
||||
/* Fetch and build referencing-column list */
|
||||
val = heap_getattr(tup, Anum_pg_constraint_conkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
|
||||
constraintId);
|
||||
/* Fetch and build referencing-column list */
|
||||
val = heap_getattr(tup, Anum_pg_constraint_conkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u",
|
||||
constraintId);
|
||||
|
||||
decompile_column_index_array(val, conForm->conrelid, &buf);
|
||||
decompile_column_index_array(val, conForm->conrelid, &buf);
|
||||
|
||||
/* add foreign relation name */
|
||||
appendStringInfo(&buf, ") REFERENCES %s(",
|
||||
/* add foreign relation name */
|
||||
appendStringInfo(&buf, ") REFERENCES %s(",
|
||||
generate_relation_name(conForm->confrelid));
|
||||
|
||||
/* Fetch and build referenced-column list */
|
||||
val = heap_getattr(tup, Anum_pg_constraint_confkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u",
|
||||
constraintId);
|
||||
/* Fetch and build referenced-column list */
|
||||
val = heap_getattr(tup, Anum_pg_constraint_confkey,
|
||||
RelationGetDescr(conDesc), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u",
|
||||
constraintId);
|
||||
|
||||
decompile_column_index_array(val, conForm->confrelid, &buf);
|
||||
decompile_column_index_array(val, conForm->confrelid, &buf);
|
||||
|
||||
appendStringInfo(&buf, ")");
|
||||
appendStringInfo(&buf, ")");
|
||||
|
||||
/* Add match type */
|
||||
switch (conForm->confmatchtype)
|
||||
{
|
||||
case FKCONSTR_MATCH_FULL:
|
||||
string = " MATCH FULL";
|
||||
break;
|
||||
case FKCONSTR_MATCH_PARTIAL:
|
||||
string = " MATCH PARTIAL";
|
||||
break;
|
||||
case FKCONSTR_MATCH_UNSPECIFIED:
|
||||
string = "";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u",
|
||||
conForm->confmatchtype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
/* Add match type */
|
||||
switch (conForm->confmatchtype)
|
||||
{
|
||||
case FKCONSTR_MATCH_FULL:
|
||||
string = " MATCH FULL";
|
||||
break;
|
||||
case FKCONSTR_MATCH_PARTIAL:
|
||||
string = " MATCH PARTIAL";
|
||||
break;
|
||||
case FKCONSTR_MATCH_UNSPECIFIED:
|
||||
string = "";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u",
|
||||
conForm->confmatchtype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, "%s", string);
|
||||
|
||||
/* Add ON UPDATE and ON DELETE clauses */
|
||||
switch (conForm->confupdtype)
|
||||
{
|
||||
case FKCONSTR_ACTION_NOACTION:
|
||||
string = "NO ACTION";
|
||||
break;
|
||||
case FKCONSTR_ACTION_RESTRICT:
|
||||
string = "RESTRICT";
|
||||
break;
|
||||
case FKCONSTR_ACTION_CASCADE:
|
||||
string = "CASCADE";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETNULL:
|
||||
string = "SET NULL";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETDEFAULT:
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u",
|
||||
conForm->confupdtype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, " ON UPDATE %s", string);
|
||||
|
||||
switch (conForm->confdeltype)
|
||||
{
|
||||
case FKCONSTR_ACTION_NOACTION:
|
||||
string = "NO ACTION";
|
||||
break;
|
||||
case FKCONSTR_ACTION_RESTRICT:
|
||||
string = "RESTRICT";
|
||||
break;
|
||||
case FKCONSTR_ACTION_CASCADE:
|
||||
string = "CASCADE";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETNULL:
|
||||
string = "SET NULL";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETDEFAULT:
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u",
|
||||
conForm->confdeltype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, " ON DELETE %s", string);
|
||||
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, "%s", string);
|
||||
|
||||
/* Add ON UPDATE and ON DELETE clauses */
|
||||
switch (conForm->confupdtype)
|
||||
{
|
||||
case FKCONSTR_ACTION_NOACTION:
|
||||
string = "NO ACTION";
|
||||
break;
|
||||
case FKCONSTR_ACTION_RESTRICT:
|
||||
string = "RESTRICT";
|
||||
break;
|
||||
case FKCONSTR_ACTION_CASCADE:
|
||||
string = "CASCADE";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETNULL:
|
||||
string = "SET NULL";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETDEFAULT:
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u",
|
||||
conForm->confupdtype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, " ON UPDATE %s", string);
|
||||
|
||||
switch (conForm->confdeltype)
|
||||
{
|
||||
case FKCONSTR_ACTION_NOACTION:
|
||||
string = "NO ACTION";
|
||||
break;
|
||||
case FKCONSTR_ACTION_RESTRICT:
|
||||
string = "RESTRICT";
|
||||
break;
|
||||
case FKCONSTR_ACTION_CASCADE:
|
||||
string = "CASCADE";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETNULL:
|
||||
string = "SET NULL";
|
||||
break;
|
||||
case FKCONSTR_ACTION_SETDEFAULT:
|
||||
string = "SET DEFAULT";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u",
|
||||
conForm->confdeltype, constraintId);
|
||||
string = ""; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
appendStringInfo(&buf, " ON DELETE %s", string);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX Add more code here for other contypes
|
||||
@@ -735,7 +735,7 @@ decompile_column_index_array(Datum column_index_array, Oid relId,
|
||||
{
|
||||
char *colName;
|
||||
|
||||
colName = get_attname(relId, DatumGetInt16(keys[j]));
|
||||
colName = get_attname(relId, DatumGetInt16(keys[j]));
|
||||
|
||||
if (j == 0)
|
||||
appendStringInfo(buf, "%s",
|
||||
@@ -875,7 +875,7 @@ deparse_expression(Node *expr, List *dpcontext, bool forceprefix)
|
||||
*
|
||||
* Given the reference name (alias) and OID of a relation, build deparsing
|
||||
* context for an expression referencing only that relation (as varno 1,
|
||||
* varlevelsup 0). This is sufficient for many uses of deparse_expression.
|
||||
* varlevelsup 0). This is sufficient for many uses of deparse_expression.
|
||||
* ----------
|
||||
*/
|
||||
List *
|
||||
@@ -972,7 +972,7 @@ deparse_context_for_subplan(const char *name, List *tlist,
|
||||
foreach(tl, tlist)
|
||||
{
|
||||
TargetEntry *tle = lfirst(tl);
|
||||
Resdom *resdom = tle->resdom;
|
||||
Resdom *resdom = tle->resdom;
|
||||
|
||||
nattrs++;
|
||||
Assert(resdom->resno == nattrs);
|
||||
@@ -983,13 +983,13 @@ deparse_context_for_subplan(const char *name, List *tlist,
|
||||
}
|
||||
if (tle->expr && IsA(tle->expr, Var))
|
||||
{
|
||||
Var *var = (Var *) tle->expr;
|
||||
Var *var = (Var *) tle->expr;
|
||||
|
||||
/* varno/varattno won't be any good, but varnoold might be */
|
||||
if (var->varnoold > 0 && var->varnoold <= rtablelength)
|
||||
{
|
||||
RangeTblEntry *varrte = rt_fetch(var->varnoold, rtable);
|
||||
char *varname;
|
||||
char *varname;
|
||||
|
||||
varname = get_rte_attribute_name(varrte, var->varoattno);
|
||||
attrs = lappend(attrs, makeString(varname));
|
||||
@@ -1001,7 +1001,7 @@ deparse_context_for_subplan(const char *name, List *tlist,
|
||||
attrs = lappend(attrs, makeString(pstrdup(buf)));
|
||||
}
|
||||
|
||||
rte->rtekind = RTE_SPECIAL; /* XXX */
|
||||
rte->rtekind = RTE_SPECIAL; /* XXX */
|
||||
rte->relid = InvalidOid;
|
||||
rte->eref = makeAlias(name, attrs);
|
||||
rte->inh = false;
|
||||
@@ -1127,9 +1127,9 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
|
||||
query = (Query *) lfirst(actions);
|
||||
|
||||
/*
|
||||
* If the action is INSERT...SELECT, OLD/NEW have been pushed
|
||||
* down into the SELECT, and that's what we need to look at.
|
||||
* (Ugly kluge ... try to fix this when we redesign querytrees.)
|
||||
* If the action is INSERT...SELECT, OLD/NEW have been pushed down
|
||||
* into the SELECT, and that's what we need to look at. (Ugly
|
||||
* kluge ... try to fix this when we redesign querytrees.)
|
||||
*/
|
||||
query = getInsertSelectQuery(query, NULL);
|
||||
|
||||
@@ -1434,13 +1434,13 @@ get_basic_select_query(Query *query, deparse_context *context,
|
||||
get_rule_expr(tle->expr, context);
|
||||
|
||||
/*
|
||||
* Figure out what the result column should be called. In the
|
||||
* Figure out what the result column should be called. In the
|
||||
* context of a view, use the view's tuple descriptor (so as to
|
||||
* pick up the effects of any column RENAME that's been done on the
|
||||
* view). Otherwise, just use what we can find in the TLE.
|
||||
* pick up the effects of any column RENAME that's been done on
|
||||
* the view). Otherwise, just use what we can find in the TLE.
|
||||
*/
|
||||
if (resultDesc && colno <= resultDesc->natts)
|
||||
colname = NameStr(resultDesc->attrs[colno-1]->attname);
|
||||
colname = NameStr(resultDesc->attrs[colno - 1]->attname);
|
||||
else
|
||||
colname = tle->resdom->resname;
|
||||
|
||||
@@ -1751,8 +1751,8 @@ get_utility_query_def(Query *query, deparse_context *context)
|
||||
NotifyStmt *stmt = (NotifyStmt *) query->utilityStmt;
|
||||
|
||||
appendStringInfo(buf, "NOTIFY %s",
|
||||
quote_qualified_identifier(stmt->relation->schemaname,
|
||||
stmt->relation->relname));
|
||||
quote_qualified_identifier(stmt->relation->schemaname,
|
||||
stmt->relation->relname));
|
||||
}
|
||||
else
|
||||
elog(ERROR, "get_utility_query_def: unexpected statement type");
|
||||
@@ -1762,7 +1762,7 @@ get_utility_query_def(Query *query, deparse_context *context)
|
||||
/*
|
||||
* Get the schemaname, refname and attname for a (possibly nonlocal) Var.
|
||||
*
|
||||
* schemaname is usually returned as NULL. It will be non-null only if
|
||||
* schemaname is usually returned as NULL. It will be non-null only if
|
||||
* use of the unqualified refname would find the wrong RTE.
|
||||
*
|
||||
* refname will be returned as NULL if the Var references an unnamed join.
|
||||
@@ -1813,9 +1813,10 @@ get_names_for_var(Var *var, deparse_context *context,
|
||||
if (rte->rtekind == RTE_RELATION)
|
||||
{
|
||||
/*
|
||||
* It's possible that use of the bare refname would find another
|
||||
* more-closely-nested RTE, or be ambiguous, in which case
|
||||
* we need to specify the schemaname to avoid these errors.
|
||||
* It's possible that use of the bare refname would find
|
||||
* another more-closely-nested RTE, or be ambiguous, in which
|
||||
* case we need to specify the schemaname to avoid these
|
||||
* errors.
|
||||
*/
|
||||
if (find_rte_by_refname(rte->eref->aliasname, context) != rte)
|
||||
*schemaname =
|
||||
@@ -1864,7 +1865,7 @@ find_rte_by_refname(const char *refname, deparse_context *context)
|
||||
if (strcmp(rte->eref->aliasname, refname) == 0)
|
||||
{
|
||||
if (result)
|
||||
return NULL; /* it's ambiguous */
|
||||
return NULL; /* it's ambiguous */
|
||||
result = rte;
|
||||
}
|
||||
}
|
||||
@@ -1964,8 +1965,8 @@ get_rule_expr(Node *node, deparse_context *context)
|
||||
Assert(length(args) == 2);
|
||||
{
|
||||
/* binary operator */
|
||||
Node *arg1 = (Node *) lfirst(args);
|
||||
Node *arg2 = (Node *) lsecond(args);
|
||||
Node *arg1 = (Node *) lfirst(args);
|
||||
Node *arg2 = (Node *) lsecond(args);
|
||||
|
||||
get_rule_expr(arg1, context);
|
||||
appendStringInfo(buf, " IS DISTINCT FROM ");
|
||||
@@ -2007,10 +2008,11 @@ get_rule_expr(Node *node, deparse_context *context)
|
||||
break;
|
||||
|
||||
case SUBPLAN_EXPR:
|
||||
|
||||
/*
|
||||
* We cannot see an already-planned subplan in rule
|
||||
* deparsing, only while EXPLAINing a query plan.
|
||||
* For now, just punt.
|
||||
* We cannot see an already-planned subplan in
|
||||
* rule deparsing, only while EXPLAINing a query
|
||||
* plan. For now, just punt.
|
||||
*/
|
||||
appendStringInfo(buf, "(subplan)");
|
||||
break;
|
||||
@@ -2089,6 +2091,7 @@ get_rule_expr(Node *node, deparse_context *context)
|
||||
ReleaseSysCache(typetup);
|
||||
fieldname = get_relid_attribute_name(typrelid,
|
||||
fselect->fieldnum);
|
||||
|
||||
/*
|
||||
* If the argument is simple enough, we could emit
|
||||
* arg.fieldname, but most cases where FieldSelect is used
|
||||
@@ -2108,7 +2111,7 @@ get_rule_expr(Node *node, deparse_context *context)
|
||||
get_rule_expr(relabel->arg, context);
|
||||
appendStringInfo(buf, ")::%s",
|
||||
format_type_with_typemod(relabel->resulttype,
|
||||
relabel->resulttypmod));
|
||||
relabel->resulttypmod));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2246,8 +2249,8 @@ get_oper_expr(Expr *expr, deparse_context *context)
|
||||
if (length(args) == 2)
|
||||
{
|
||||
/* binary operator */
|
||||
Node *arg1 = (Node *) lfirst(args);
|
||||
Node *arg2 = (Node *) lsecond(args);
|
||||
Node *arg1 = (Node *) lfirst(args);
|
||||
Node *arg2 = (Node *) lsecond(args);
|
||||
|
||||
get_rule_expr(arg1, context);
|
||||
appendStringInfo(buf, " %s ",
|
||||
@@ -2332,9 +2335,9 @@ get_func_expr(Expr *expr, deparse_context *context)
|
||||
/*
|
||||
* Show typename with appropriate length decoration. Note that
|
||||
* since exprIsLengthCoercion succeeded, the function's output
|
||||
* type is the right thing to report. Also note we don't need
|
||||
* to quote the result of format_type_with_typemod: it takes
|
||||
* care of double-quoting any identifier that needs it.
|
||||
* type is the right thing to report. Also note we don't need to
|
||||
* quote the result of format_type_with_typemod: it takes care of
|
||||
* double-quoting any identifier that needs it.
|
||||
*/
|
||||
typdesc = format_type_with_typemod(rettype, coercedTypmod);
|
||||
appendStringInfo(buf, ")::%s", typdesc);
|
||||
@@ -2344,8 +2347,8 @@ get_func_expr(Expr *expr, deparse_context *context)
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal function: display as proname(args). First we need to extract
|
||||
* the argument datatypes.
|
||||
* Normal function: display as proname(args). First we need to
|
||||
* extract the argument datatypes.
|
||||
*/
|
||||
nargs = 0;
|
||||
foreach(l, expr->args)
|
||||
@@ -2354,7 +2357,7 @@ get_func_expr(Expr *expr, deparse_context *context)
|
||||
argtypes[nargs] = exprType((Node *) lfirst(l));
|
||||
nargs++;
|
||||
}
|
||||
|
||||
|
||||
appendStringInfo(buf, "%s(",
|
||||
generate_function_name(funcoid, nargs, argtypes));
|
||||
|
||||
@@ -2378,7 +2381,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context)
|
||||
Oid argtype = exprType(aggref->target);
|
||||
|
||||
appendStringInfo(buf, "%s(%s",
|
||||
generate_function_name(aggref->aggfnoid, 1, &argtype),
|
||||
generate_function_name(aggref->aggfnoid, 1, &argtype),
|
||||
aggref->aggdistinct ? "DISTINCT " : "");
|
||||
if (aggref->aggstar)
|
||||
appendStringInfo(buf, "*");
|
||||
@@ -2438,8 +2441,8 @@ strip_type_coercion(Node *expr, Oid resultType)
|
||||
}
|
||||
/* See if function has is actually declared as a cast */
|
||||
castTuple = SearchSysCache(CASTSOURCETARGET,
|
||||
ObjectIdGetDatum(procStruct->proargtypes[0]),
|
||||
ObjectIdGetDatum(procStruct->prorettype),
|
||||
ObjectIdGetDatum(procStruct->proargtypes[0]),
|
||||
ObjectIdGetDatum(procStruct->prorettype),
|
||||
0, 0);
|
||||
if (!HeapTupleIsValid(castTuple))
|
||||
{
|
||||
@@ -2519,11 +2522,11 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
if (constval->constisnull)
|
||||
{
|
||||
/*
|
||||
* Always label the type of a NULL constant to prevent misdecisions
|
||||
* about type when reparsing.
|
||||
* Always label the type of a NULL constant to prevent
|
||||
* misdecisions about type when reparsing.
|
||||
*/
|
||||
appendStringInfo(buf, "NULL::%s",
|
||||
format_type_with_typemod(constval->consttype, -1));
|
||||
format_type_with_typemod(constval->consttype, -1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2549,23 +2552,23 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
case FLOAT4OID:
|
||||
case FLOAT8OID:
|
||||
case NUMERICOID:
|
||||
{
|
||||
/*
|
||||
* These types are printed without quotes unless they
|
||||
* contain values that aren't accepted by the scanner
|
||||
* unquoted (e.g., 'NaN'). Note that strtod() and friends
|
||||
* might accept NaN, so we can't use that to test.
|
||||
*
|
||||
* In reality we only need to defend against infinity and
|
||||
* NaN, so we need not get too crazy about pattern
|
||||
* matching here.
|
||||
*/
|
||||
if (strspn(extval, "0123456789 +-eE.") == strlen(extval))
|
||||
appendStringInfo(buf, extval);
|
||||
else
|
||||
appendStringInfo(buf, "'%s'", extval);
|
||||
}
|
||||
break;
|
||||
{
|
||||
/*
|
||||
* These types are printed without quotes unless they
|
||||
* contain values that aren't accepted by the scanner
|
||||
* unquoted (e.g., 'NaN'). Note that strtod() and friends
|
||||
* might accept NaN, so we can't use that to test.
|
||||
*
|
||||
* In reality we only need to defend against infinity and
|
||||
* NaN, so we need not get too crazy about pattern
|
||||
* matching here.
|
||||
*/
|
||||
if (strspn(extval, "0123456789 +-eE.") == strlen(extval))
|
||||
appendStringInfo(buf, extval);
|
||||
else
|
||||
appendStringInfo(buf, "'%s'", extval);
|
||||
}
|
||||
break;
|
||||
|
||||
case BITOID:
|
||||
case VARBITOID:
|
||||
@@ -2573,13 +2576,14 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
break;
|
||||
|
||||
case BOOLOID:
|
||||
if (strcmp(extval, "t")==0)
|
||||
if (strcmp(extval, "t") == 0)
|
||||
appendStringInfo(buf, "true");
|
||||
else
|
||||
appendStringInfo(buf, "false");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
/*
|
||||
* We must quote any funny characters in the constant's
|
||||
* representation. XXX Any MULTIBYTE considerations here?
|
||||
@@ -2665,9 +2669,10 @@ get_sublink_expr(Node *node, deparse_context *context)
|
||||
|
||||
/*
|
||||
* XXX we assume here that we can get away without qualifying the
|
||||
* operator name. Since the name may imply multiple physical operators
|
||||
* it's rather difficult to do otherwise --- in fact, if the operators
|
||||
* are in different namespaces any attempt to qualify would surely fail.
|
||||
* operator name. Since the name may imply multiple physical
|
||||
* operators it's rather difficult to do otherwise --- in fact, if the
|
||||
* operators are in different namespaces any attempt to qualify would
|
||||
* surely fail.
|
||||
*/
|
||||
switch (sublink->subLinkType)
|
||||
{
|
||||
@@ -2812,13 +2817,13 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
|
||||
}
|
||||
}
|
||||
else if (rte->rtekind == RTE_RELATION &&
|
||||
strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0)
|
||||
strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0)
|
||||
{
|
||||
/*
|
||||
* Apparently the rel has been renamed since the rule was made.
|
||||
* Emit a fake alias clause so that variable references will
|
||||
* still work. This is not a 100% solution but should work in
|
||||
* most reasonable situations.
|
||||
* Apparently the rel has been renamed since the rule was
|
||||
* made. Emit a fake alias clause so that variable references
|
||||
* will still work. This is not a 100% solution but should
|
||||
* work in most reasonable situations.
|
||||
*/
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
@@ -2981,7 +2986,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype,
|
||||
opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc);
|
||||
if (actual_datatype != opcrec->opcintype || !opcrec->opcdefault)
|
||||
{
|
||||
/* Okay, we need the opclass name. Do we need to qualify it? */
|
||||
/* Okay, we need the opclass name. Do we need to qualify it? */
|
||||
opcname = NameStr(opcrec->opcname);
|
||||
if (OpclassIsVisible(opclass))
|
||||
appendStringInfo(buf, " %s", quote_identifier(opcname));
|
||||
@@ -3031,9 +3036,10 @@ const char *
|
||||
quote_identifier(const char *ident)
|
||||
{
|
||||
/*
|
||||
* Can avoid quoting if ident starts with a lowercase letter or underscore
|
||||
* and contains only lowercase letters, digits, and underscores, *and* is
|
||||
* not any SQL keyword. Otherwise, supply quotes.
|
||||
* Can avoid quoting if ident starts with a lowercase letter or
|
||||
* underscore and contains only lowercase letters, digits, and
|
||||
* underscores, *and* is not any SQL keyword. Otherwise, supply
|
||||
* quotes.
|
||||
*/
|
||||
int nquotes = 0;
|
||||
bool safe;
|
||||
@@ -3187,8 +3193,8 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes)
|
||||
|
||||
/*
|
||||
* The idea here is to schema-qualify only if the parser would fail to
|
||||
* resolve the correct function given the unqualified func name
|
||||
* with the specified argtypes.
|
||||
* resolve the correct function given the unqualified func name with
|
||||
* the specified argtypes.
|
||||
*/
|
||||
p_result = func_get_detail(makeList1(makeString(proname)),
|
||||
NIL, nargs, argtypes,
|
||||
@@ -3239,8 +3245,8 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
|
||||
|
||||
/*
|
||||
* The idea here is to schema-qualify only if the parser would fail to
|
||||
* resolve the correct operator given the unqualified op name
|
||||
* with the specified argtypes.
|
||||
* resolve the correct operator given the unqualified op name with the
|
||||
* specified argtypes.
|
||||
*/
|
||||
switch (operform->oprkind)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.116 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.117 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -855,9 +855,12 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
|
||||
return 0.0;
|
||||
constval = ((Const *) other)->constvalue;
|
||||
|
||||
/* the right-hand const is type text or bytea for all supported operators */
|
||||
/*
|
||||
* the right-hand const is type text or bytea for all supported
|
||||
* operators
|
||||
*/
|
||||
Assert(((Const *) other)->consttype == TEXTOID ||
|
||||
((Const *) other)->consttype == BYTEAOID);
|
||||
((Const *) other)->consttype == BYTEAOID);
|
||||
|
||||
/* divide pattern into fixed prefix and remainder */
|
||||
patt = (Const *) other;
|
||||
@@ -1860,11 +1863,12 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
|
||||
get_typlenbyval(var->vartype, &typLen, &typByVal);
|
||||
|
||||
/*
|
||||
* If there is a histogram, grab the last or first value as appropriate.
|
||||
* If there is a histogram, grab the last or first value as
|
||||
* appropriate.
|
||||
*
|
||||
* If there is a histogram that is sorted with some other operator
|
||||
* than the one we want, fail --- this suggests that there is data
|
||||
* we can't use.
|
||||
* If there is a histogram that is sorted with some other operator than
|
||||
* the one we want, fail --- this suggests that there is data we can't
|
||||
* use.
|
||||
*/
|
||||
if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
|
||||
STATISTIC_KIND_HISTOGRAM, sortop,
|
||||
@@ -1873,14 +1877,14 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
|
||||
{
|
||||
if (nvalues > 0)
|
||||
{
|
||||
tmax = datumCopy(values[nvalues-1], typByVal, typLen);
|
||||
tmax = datumCopy(values[nvalues - 1], typByVal, typLen);
|
||||
have_max = true;
|
||||
}
|
||||
free_attstatsslot(var->vartype, values, nvalues, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Oid rsortop = get_commutator(sortop);
|
||||
Oid rsortop = get_commutator(sortop);
|
||||
|
||||
if (OidIsValid(rsortop) &&
|
||||
get_attstatsslot(statsTuple, var->vartype, var->vartypmod,
|
||||
@@ -1907,8 +1911,8 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have most-common-values info, look for a large MCV. This
|
||||
* is needed even if we also have a histogram, since the histogram
|
||||
* If we have most-common-values info, look for a large MCV. This is
|
||||
* needed even if we also have a histogram, since the histogram
|
||||
* excludes the MCVs. However, usually the MCVs will not be the
|
||||
* extreme values, so avoid unnecessary data copying.
|
||||
*/
|
||||
@@ -1917,7 +1921,7 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max)
|
||||
&values, &nvalues,
|
||||
NULL, NULL))
|
||||
{
|
||||
bool large_mcv = false;
|
||||
bool large_mcv = false;
|
||||
FmgrInfo opproc;
|
||||
|
||||
fmgr_info(get_opcode(sortop), &opproc);
|
||||
@@ -2724,7 +2728,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
patt = DatumGetCString(DirectFunctionCall1(byteaout, patt_const->constvalue));
|
||||
pattlen = toast_raw_datum_size(patt_const->constvalue) - VARHDRSZ;
|
||||
}
|
||||
|
||||
|
||||
prefix = match = palloc(pattlen + 1);
|
||||
match_pos = 0;
|
||||
|
||||
@@ -2760,8 +2764,8 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
match[match_pos] = '\0';
|
||||
rest = &patt[pos];
|
||||
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
|
||||
pfree(patt);
|
||||
pfree(match);
|
||||
@@ -2807,8 +2811,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
{
|
||||
rest = patt;
|
||||
|
||||
*prefix_const = NULL;
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
*prefix_const = NULL;
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
|
||||
return Pattern_Prefix_None;
|
||||
}
|
||||
@@ -2824,8 +2828,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
{
|
||||
rest = patt;
|
||||
|
||||
*prefix_const = NULL;
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
*prefix_const = NULL;
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
|
||||
return Pattern_Prefix_None;
|
||||
}
|
||||
@@ -2898,14 +2902,14 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
|
||||
{
|
||||
rest = &patt[pos + 1];
|
||||
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
|
||||
return Pattern_Prefix_Exact; /* pattern specifies exact match */
|
||||
}
|
||||
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
*prefix_const = string_to_const(prefix, typeid);
|
||||
*rest_const = string_to_const(rest, typeid);
|
||||
|
||||
pfree(patt);
|
||||
pfree(match);
|
||||
@@ -3279,7 +3283,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
|
||||
* we must be able to generate another string "fop" that is greater
|
||||
* than all strings "foobar" starting with "foo". Unfortunately, a
|
||||
* non-C locale may have arbitrary collation rules in which "fop" >
|
||||
* "foo" is not sufficient to ensure "fop" > "foobar". Until we can
|
||||
* "foo" is not sufficient to ensure "fop" > "foobar". Until we can
|
||||
* come up with a more bulletproof way of generating the upper-bound
|
||||
* string, the optimization is disabled in all non-C locales.
|
||||
*
|
||||
@@ -3356,8 +3360,8 @@ make_greater_string(const Const *str_const)
|
||||
(*lastchar)++;
|
||||
if (string_lessthan(str, workstr, datatype))
|
||||
{
|
||||
/* Success! */
|
||||
Const *workstr_const = string_to_const(workstr, datatype);
|
||||
/* Success! */
|
||||
Const *workstr_const = string_to_const(workstr, datatype);
|
||||
|
||||
pfree(str);
|
||||
pfree(workstr);
|
||||
@@ -3372,7 +3376,7 @@ make_greater_string(const Const *str_const)
|
||||
if (datatype != BYTEAOID && pg_database_encoding_max_length() > 1)
|
||||
len = pg_mbcliplen((const unsigned char *) workstr, len, len - 1);
|
||||
else
|
||||
len -= - 1;
|
||||
len -= -1;
|
||||
|
||||
if (datatype != BYTEAOID)
|
||||
workstr[len] = '\0';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.53 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.54 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -54,19 +54,19 @@ SetDefine(char *querystr, Oid elemType)
|
||||
char repl[Natts_pg_proc];
|
||||
|
||||
setoid = ProcedureCreate(procname, /* changed below, after oid known */
|
||||
PG_CATALOG_NAMESPACE, /* XXX wrong */
|
||||
PG_CATALOG_NAMESPACE, /* XXX wrong */
|
||||
false, /* don't replace */
|
||||
true, /* returnsSet */
|
||||
elemType, /* returnType */
|
||||
SQLlanguageId, /* language */
|
||||
SQLlanguageId, /* language */
|
||||
F_FMGR_SQL_VALIDATOR,
|
||||
querystr, /* prosrc */
|
||||
fileName, /* probin */
|
||||
false, /* not aggregate */
|
||||
false, /* security invoker */
|
||||
false, /* isStrict (irrelevant, no args) */
|
||||
PROVOLATILE_VOLATILE, /* assume unsafe */
|
||||
0, /* parameterCount */
|
||||
PROVOLATILE_VOLATILE, /* assume unsafe */
|
||||
0, /* parameterCount */
|
||||
NULL); /* parameterTypes */
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.35 2002/08/29 00:17:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.36 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* input routine largely stolen from boxin().
|
||||
@@ -154,14 +154,16 @@ setLastTid(const ItemPointer tid)
|
||||
* correspond to the CTID of a base relation.
|
||||
*/
|
||||
static Datum
|
||||
currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
{
|
||||
TupleDesc att = RelationGetDescr(viewrel);
|
||||
RuleLock *rulelock;
|
||||
RewriteRule *rewrite;
|
||||
int i, natts = att->natts, tididx = -1;
|
||||
RuleLock *rulelock;
|
||||
RewriteRule *rewrite;
|
||||
int i,
|
||||
natts = att->natts,
|
||||
tididx = -1;
|
||||
|
||||
for (i = 0; i < natts ; i++)
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
if (strcasecmp(NameStr(att->attrs[i]->attname), "ctid") == 0)
|
||||
{
|
||||
@@ -179,7 +181,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
rewrite = rulelock->rules[i];
|
||||
if (rewrite->event == CMD_SELECT)
|
||||
{
|
||||
Query *query;
|
||||
Query *query;
|
||||
TargetEntry *tle;
|
||||
|
||||
if (length(rewrite->actions) != 1)
|
||||
@@ -188,8 +190,9 @@ currtid_for_view(Relation viewrel, ItemPointer tid)
|
||||
tle = (TargetEntry *) nth(tididx, query->targetList);
|
||||
if (tle && tle->expr && nodeTag(tle->expr) == T_Var)
|
||||
{
|
||||
Var *var = (Var *) tle->expr;
|
||||
Var *var = (Var *) tle->expr;
|
||||
RangeTblEntry *rte;
|
||||
|
||||
if (var->varno > 0 && var->varno < INNER && var->varattno == SelfItemPointerAttributeNumber)
|
||||
{
|
||||
rte = (RangeTblEntry *) nth(var->varno - 1, query->rtable);
|
||||
@@ -244,7 +247,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
||||
Relation rel;
|
||||
|
||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,
|
||||
"currtid_byrelname"));
|
||||
"currtid_byrelname"));
|
||||
rel = heap_openrv(relrv, AccessShareLock);
|
||||
if (rel->rd_rel->relkind == RELKIND_VIEW)
|
||||
return currtid_for_view(rel, tid);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.72 2002/09/03 22:55:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.73 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec);
|
||||
|
||||
#else
|
||||
static double time2t(const int hour, const int min, const int sec, const fsec_t fsec);
|
||||
#endif
|
||||
@@ -155,7 +156,7 @@ static void
|
||||
AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
INT64CONST(1000000),
|
||||
INT64CONST(100000),
|
||||
INT64CONST(10000),
|
||||
@@ -165,7 +166,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
|
||||
INT64CONST(1)
|
||||
};
|
||||
|
||||
static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
INT64CONST(-500000),
|
||||
INT64CONST(-50000),
|
||||
INT64CONST(-5000),
|
||||
@@ -174,8 +175,9 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
|
||||
INT64CONST(-5),
|
||||
INT64CONST(0)
|
||||
};
|
||||
|
||||
#else
|
||||
static const double TimestampScales[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const double TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
1,
|
||||
10,
|
||||
100,
|
||||
@@ -185,7 +187,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
|
||||
1000000
|
||||
};
|
||||
|
||||
static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = {
|
||||
static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = {
|
||||
0.5,
|
||||
0.05,
|
||||
0.005,
|
||||
@@ -224,7 +226,10 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Scale and truncate first, then add to help the rounding behavior */
|
||||
/*
|
||||
* Scale and truncate first, then add to help the rounding
|
||||
* behavior
|
||||
*/
|
||||
*time = (rint((((double) *time) * TimestampScales[typmod]) + TimestampOffsets[typmod])
|
||||
/ TimestampScales[typmod]);
|
||||
}
|
||||
@@ -450,7 +455,7 @@ static void
|
||||
AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
static const int64 IntervalScales[MAX_INTERVAL_PRECISION+1] = {
|
||||
static const int64 IntervalScales[MAX_INTERVAL_PRECISION + 1] = {
|
||||
INT64CONST(1000000),
|
||||
INT64CONST(100000),
|
||||
INT64CONST(10000),
|
||||
@@ -460,7 +465,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
INT64CONST(1)
|
||||
};
|
||||
|
||||
static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION+1] = {
|
||||
static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = {
|
||||
INT64CONST(-500000),
|
||||
INT64CONST(-50000),
|
||||
INT64CONST(-5000),
|
||||
@@ -469,8 +474,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
INT64CONST(-5),
|
||||
INT64CONST(0)
|
||||
};
|
||||
|
||||
#else
|
||||
static const double IntervalScales[MAX_INTERVAL_PRECISION+1] = {
|
||||
static const double IntervalScales[MAX_INTERVAL_PRECISION + 1] = {
|
||||
1,
|
||||
10,
|
||||
100,
|
||||
@@ -480,7 +486,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
1000000
|
||||
};
|
||||
|
||||
static const double IntervalOffsets[MAX_INTERVAL_PRECISION+1] = {
|
||||
static const double IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = {
|
||||
0.5,
|
||||
0.05,
|
||||
0.005,
|
||||
@@ -491,7 +497,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Unspecified range and precision? Then not necessary to adjust.
|
||||
/*
|
||||
* Unspecified range and precision? Then not necessary to adjust.
|
||||
* Setting typmod to -1 is the convention for all types.
|
||||
*/
|
||||
if (typmod != -1)
|
||||
@@ -515,9 +522,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
}
|
||||
/* YEAR TO MONTH */
|
||||
else if (range == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH)))
|
||||
{
|
||||
interval->time = 0;
|
||||
}
|
||||
else if (range == INTERVAL_MASK(DAY))
|
||||
{
|
||||
interval->month = 0;
|
||||
@@ -532,6 +537,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 day;
|
||||
|
||||
#else
|
||||
double day;
|
||||
#endif
|
||||
@@ -551,6 +557,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 hour;
|
||||
|
||||
#else
|
||||
double hour;
|
||||
#endif
|
||||
@@ -570,6 +577,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 minute;
|
||||
|
||||
#else
|
||||
double minute;
|
||||
#endif
|
||||
@@ -613,15 +621,14 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
INTERVAL_MASK(HOUR) |
|
||||
INTERVAL_MASK(MINUTE) |
|
||||
INTERVAL_MASK(SECOND)))
|
||||
{
|
||||
interval->month = 0;
|
||||
}
|
||||
/* HOUR TO MINUTE */
|
||||
else if (range == (INTERVAL_MASK(HOUR) |
|
||||
INTERVAL_MASK(MINUTE)))
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 day;
|
||||
|
||||
#else
|
||||
double day;
|
||||
#endif
|
||||
@@ -644,6 +651,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 day;
|
||||
|
||||
#else
|
||||
double day;
|
||||
#endif
|
||||
@@ -662,6 +670,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 hour;
|
||||
|
||||
#else
|
||||
double hour;
|
||||
#endif
|
||||
@@ -706,7 +715,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
|
||||
else
|
||||
{
|
||||
interval->time = (rint((((double) interval->time) + IntervalOffsets[precision])
|
||||
* IntervalScales[precision]) / IntervalScales[precision]);
|
||||
* IntervalScales[precision]) / IntervalScales[precision]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -756,6 +765,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 time;
|
||||
|
||||
#else
|
||||
double time;
|
||||
#endif
|
||||
@@ -794,18 +804,19 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
|
||||
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
|
||||
*/
|
||||
int
|
||||
timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn)
|
||||
timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int date,
|
||||
date0;
|
||||
int64 time;
|
||||
int date,
|
||||
date0;
|
||||
int64 time;
|
||||
|
||||
#else
|
||||
double date,
|
||||
date0;
|
||||
double time;
|
||||
double date,
|
||||
date0;
|
||||
double time;
|
||||
#endif
|
||||
time_t utime;
|
||||
time_t utime;
|
||||
|
||||
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
|
||||
struct tm *tx;
|
||||
@@ -880,7 +891,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
utime = ((dt / INT64CONST(1000000))
|
||||
+ ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400)));
|
||||
+ ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400)));
|
||||
#else
|
||||
utime = (dt + ((date0 - date2j(1970, 1, 1)) * 86400));
|
||||
#endif
|
||||
@@ -963,8 +974,9 @@ int
|
||||
tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int date;
|
||||
int64 time;
|
||||
int date;
|
||||
int64 time;
|
||||
|
||||
#else
|
||||
double date,
|
||||
time;
|
||||
@@ -996,6 +1008,7 @@ interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
|
||||
{
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 time;
|
||||
|
||||
#else
|
||||
double time;
|
||||
#endif
|
||||
@@ -1040,9 +1053,9 @@ tm2interval(struct tm * tm, fsec_t fsec, Interval *span)
|
||||
span->month = ((tm->tm_year * 12) + tm->tm_mon);
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
span->time = ((((((((tm->tm_mday * INT64CONST(24))
|
||||
+ tm->tm_hour) * INT64CONST(60))
|
||||
+ tm->tm_min) * INT64CONST(60))
|
||||
+ tm->tm_sec) * INT64CONST(1000000)) + fsec);
|
||||
+ tm->tm_hour) * INT64CONST(60))
|
||||
+ tm->tm_min) * INT64CONST(60))
|
||||
+ tm->tm_sec) * INT64CONST(1000000)) + fsec);
|
||||
#else
|
||||
span->time = ((((((tm->tm_mday * 24.0)
|
||||
+ tm->tm_hour) * 60.0)
|
||||
@@ -1060,6 +1073,7 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec)
|
||||
{
|
||||
return ((((((hour * 60) + min) * 60) + sec) * INT64CONST(1000000)) + fsec);
|
||||
} /* time2t() */
|
||||
|
||||
#else
|
||||
static double
|
||||
time2t(const int hour, const int min, const int sec, const fsec_t fsec)
|
||||
@@ -1226,6 +1240,7 @@ interval_cmp_internal(Interval *interval1, Interval *interval2)
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 span1,
|
||||
span2;
|
||||
|
||||
#else
|
||||
double span1,
|
||||
span2;
|
||||
@@ -1532,9 +1547,7 @@ timestamp_pl_span(PG_FUNCTION_ARGS)
|
||||
Timestamp result;
|
||||
|
||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||
{
|
||||
result = timestamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (span->month != 0)
|
||||
@@ -1702,9 +1715,11 @@ interval_smaller(PG_FUNCTION_ARGS)
|
||||
Interval *interval1 = PG_GETARG_INTERVAL_P(0);
|
||||
Interval *interval2 = PG_GETARG_INTERVAL_P(1);
|
||||
Interval *result;
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 span1,
|
||||
span2;
|
||||
|
||||
#else
|
||||
double span1,
|
||||
span2;
|
||||
@@ -1746,9 +1761,11 @@ interval_larger(PG_FUNCTION_ARGS)
|
||||
Interval *interval1 = PG_GETARG_INTERVAL_P(0);
|
||||
Interval *interval2 = PG_GETARG_INTERVAL_P(1);
|
||||
Interval *result;
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 span1,
|
||||
span2;
|
||||
|
||||
#else
|
||||
double span1,
|
||||
span2;
|
||||
@@ -1828,8 +1845,10 @@ interval_mul(PG_FUNCTION_ARGS)
|
||||
Interval *span1 = PG_GETARG_INTERVAL_P(0);
|
||||
float8 factor = PG_GETARG_FLOAT8(1);
|
||||
Interval *result;
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
int64 months;
|
||||
|
||||
#else
|
||||
double months;
|
||||
#endif
|
||||
@@ -1868,6 +1887,7 @@ interval_div(PG_FUNCTION_ARGS)
|
||||
Interval *span = PG_GETARG_INTERVAL_P(0);
|
||||
float8 factor = PG_GETARG_FLOAT8(1);
|
||||
Interval *result;
|
||||
|
||||
#ifndef HAVE_INT64_TIMESTAMP
|
||||
double months;
|
||||
#endif
|
||||
@@ -1882,7 +1902,7 @@ interval_div(PG_FUNCTION_ARGS)
|
||||
result->time = (span->time / factor);
|
||||
/* evaluate fractional months as 30 days */
|
||||
result->time += (((span->month - (result->month * factor))
|
||||
* INT64CONST(30) * INT64CONST(86400000000)) / factor);
|
||||
* INT64CONST(30) * INT64CONST(86400000000)) / factor);
|
||||
#else
|
||||
months = (span->month / factor);
|
||||
result->month = rint(months);
|
||||
@@ -1928,8 +1948,8 @@ interval_accum(PG_FUNCTION_ARGS)
|
||||
* objects on machines where double requires 8-byte alignment. That
|
||||
* should be fixed, but in the meantime...
|
||||
*
|
||||
* Note: must use DatumGetPointer here, not DatumGetIntervalP,
|
||||
* else some compilers optimize into double-aligned load/store anyway.
|
||||
* Note: must use DatumGetPointer here, not DatumGetIntervalP, else some
|
||||
* compilers optimize into double-aligned load/store anyway.
|
||||
*/
|
||||
memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
|
||||
memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
|
||||
@@ -1970,8 +1990,8 @@ interval_avg(PG_FUNCTION_ARGS)
|
||||
* objects on machines where double requires 8-byte alignment. That
|
||||
* should be fixed, but in the meantime...
|
||||
*
|
||||
* Note: must use DatumGetPointer here, not DatumGetIntervalP,
|
||||
* else some compilers optimize into double-aligned load/store anyway.
|
||||
* Note: must use DatumGetPointer here, not DatumGetIntervalP, else some
|
||||
* compilers optimize into double-aligned load/store anyway.
|
||||
*/
|
||||
memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
|
||||
memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
|
||||
@@ -3131,29 +3151,29 @@ interval_part(PG_FUNCTION_ARGS)
|
||||
{
|
||||
switch (val)
|
||||
{
|
||||
case DTK_MICROSEC:
|
||||
case DTK_MICROSEC:
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
result = ((tm->tm_sec * 1000000e0) + fsec);
|
||||
result = ((tm->tm_sec * 1000000e0) + fsec);
|
||||
#else
|
||||
result = (tm->tm_sec + fsec) * 1000000;
|
||||
result = (tm->tm_sec + fsec) * 1000000;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case DTK_MILLISEC:
|
||||
case DTK_MILLISEC:
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0));
|
||||
result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0));
|
||||
#else
|
||||
result = (tm->tm_sec + fsec) * 1000;
|
||||
result = (tm->tm_sec + fsec) * 1000;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case DTK_SECOND:
|
||||
case DTK_SECOND:
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
result = (tm->tm_sec + (fsec / 1000000e0));
|
||||
result = (tm->tm_sec + (fsec / 1000000e0));
|
||||
#else
|
||||
result = (tm->tm_sec + fsec);
|
||||
result = (tm->tm_sec + fsec);
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case DTK_MINUTE:
|
||||
result = tm->tm_min;
|
||||
@@ -3234,7 +3254,7 @@ interval_part(PG_FUNCTION_ARGS)
|
||||
/* timestamp_zone()
|
||||
* Encode timestamp type with specified time zone.
|
||||
* Returns timestamp with time zone, with the input
|
||||
* rotated from local time to the specified zone.
|
||||
* rotated from local time to the specified zone.
|
||||
*/
|
||||
Datum
|
||||
timestamp_zone(PG_FUNCTION_ARGS)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.24 2002/08/26 17:53:59 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.25 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1138,8 +1138,8 @@ bitfromint8(PG_FUNCTION_ARGS)
|
||||
VARBITLEN(result) = sizeof(a) * BITS_PER_BYTE;
|
||||
|
||||
/*
|
||||
* masks and shifts here are just too painful and we know that an int64
|
||||
* has got 8 bytes
|
||||
* masks and shifts here are just too painful and we know that an
|
||||
* int64 has got 8 bytes
|
||||
*/
|
||||
r = VARBITS(result);
|
||||
r[0] = (bits8) ((a >> (7 * BITS_PER_BYTE)) & BITMASK);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.93 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.94 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -182,6 +182,7 @@ bpchar(PG_FUNCTION_ARGS)
|
||||
|
||||
int charlen; /* number of charcters in the input string
|
||||
* + VARHDRSZ */
|
||||
|
||||
len = VARSIZE(source);
|
||||
|
||||
charlen = pg_mbstrlen_with_len(VARDATA(source), len - VARHDRSZ) + VARHDRSZ;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.91 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.92 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,11 +30,11 @@ typedef struct varlena unknown;
|
||||
#define PG_GETARG_UNKNOWN_P(n) DatumGetUnknownP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x)
|
||||
#define PG_TEXTARG_GET_STR(arg_) \
|
||||
DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_)))
|
||||
DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_)))
|
||||
#define PG_TEXT_GET_STR(textp_) \
|
||||
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_)))
|
||||
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_)))
|
||||
#define PG_STR_GET_TEXT(str_) \
|
||||
DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_)))
|
||||
DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_)))
|
||||
#define TEXTLEN(textp) \
|
||||
text_length(PointerGetDatum(textp))
|
||||
#define TEXTPOS(buf_text, from_sub_text) \
|
||||
@@ -54,9 +54,9 @@ static int text_cmp(text *arg1, text *arg2);
|
||||
static int32 text_length(Datum str);
|
||||
static int32 text_position(Datum str, Datum search_str, int matchnum);
|
||||
static text *text_substring(Datum str,
|
||||
int32 start,
|
||||
int32 length,
|
||||
bool length_not_specified);
|
||||
int32 start,
|
||||
int32 length,
|
||||
bool length_not_specified);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -266,7 +266,7 @@ Datum
|
||||
unknownin(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char *inputStr = PG_GETARG_CSTRING(0);
|
||||
unknown *result;
|
||||
unknown *result;
|
||||
int len;
|
||||
|
||||
len = strlen(inputStr) + VARHDRSZ;
|
||||
@@ -286,7 +286,7 @@ unknownin(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
unknownout(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unknown *t = PG_GETARG_UNKNOWN_P(0);
|
||||
unknown *t = PG_GETARG_UNKNOWN_P(0);
|
||||
int len;
|
||||
char *result;
|
||||
|
||||
@@ -330,12 +330,12 @@ text_length(Datum str)
|
||||
text *t = DatumGetTextP(str);
|
||||
|
||||
PG_RETURN_INT32(pg_mbstrlen_with_len(VARDATA(t),
|
||||
VARSIZE(t) - VARHDRSZ));
|
||||
VARSIZE(t) - VARHDRSZ));
|
||||
}
|
||||
|
||||
/* should never get here */
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
"is less than one.");
|
||||
|
||||
/* not reached: suppress compiler warning */
|
||||
return 0;
|
||||
@@ -425,7 +425,7 @@ textcat(PG_FUNCTION_ARGS)
|
||||
* behaviors conflicting with SQL92 to meet SQL92 (if E = S + L < S throw
|
||||
* error; if E < 1, return '', not entire string). Fixed MB related bug when
|
||||
* S > LC and < LC + 4 sometimes garbage characters are returned.
|
||||
* - Joe Conway 2002-08-10
|
||||
* - Joe Conway 2002-08-10
|
||||
*/
|
||||
Datum
|
||||
text_substr(PG_FUNCTION_ARGS)
|
||||
@@ -455,25 +455,26 @@ text_substr_no_len(PG_FUNCTION_ARGS)
|
||||
* This is broken out so it can be called directly by other string processing
|
||||
* functions.
|
||||
*/
|
||||
static text*
|
||||
static text *
|
||||
text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
{
|
||||
int32 eml = pg_database_encoding_max_length();
|
||||
int32 S = start; /* start position */
|
||||
int32 S1; /* adjusted start position */
|
||||
int32 L1; /* adjusted substring length */
|
||||
int32 S = start; /* start position */
|
||||
int32 S1; /* adjusted start position */
|
||||
int32 L1; /* adjusted substring length */
|
||||
|
||||
/* life is easy if the encoding max length is 1 */
|
||||
if (eml == 1)
|
||||
{
|
||||
S1 = Max(S, 1);
|
||||
|
||||
if (length_not_specified) /* special case - get length to end of string */
|
||||
if (length_not_specified) /* special case - get length to
|
||||
* end of string */
|
||||
L1 = -1;
|
||||
else
|
||||
{
|
||||
/* end position */
|
||||
int E = S + length;
|
||||
int E = S + length;
|
||||
|
||||
/*
|
||||
* A negative value for L is the only way for the end position
|
||||
@@ -482,9 +483,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if the start
|
||||
* was negative or one. SQL99 says to return a zero-length string.
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if
|
||||
* the start was negative or one. SQL99 says to return a
|
||||
* zero-length string.
|
||||
*/
|
||||
if (E < 1)
|
||||
return PG_STR_GET_TEXT("");
|
||||
@@ -492,11 +494,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
L1 = E - S1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the start position is past the end of the string,
|
||||
* SQL99 says to return a zero-length string --
|
||||
* PG_GETARG_TEXT_P_SLICE() will do that for us.
|
||||
* Convert to zero-based starting position
|
||||
/*
|
||||
* If the start position is past the end of the string, SQL99 says
|
||||
* to return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will
|
||||
* do that for us. Convert to zero-based starting position
|
||||
*/
|
||||
return DatumGetTextPSlice(str, S1 - 1, L1);
|
||||
}
|
||||
@@ -504,13 +505,13 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
{
|
||||
/*
|
||||
* When encoding max length is > 1, we can't get LC without
|
||||
* detoasting, so we'll grab a conservatively large slice
|
||||
* now and go back later to do the right thing
|
||||
* detoasting, so we'll grab a conservatively large slice now and
|
||||
* go back later to do the right thing
|
||||
*/
|
||||
int32 slice_start;
|
||||
int32 slice_size;
|
||||
int32 slice_strlen;
|
||||
text *slice;
|
||||
text *slice;
|
||||
int32 E1;
|
||||
int32 i;
|
||||
char *p;
|
||||
@@ -518,23 +519,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
text *ret;
|
||||
|
||||
/*
|
||||
* if S is past the end of the string, the tuple toaster
|
||||
* will return a zero-length string to us
|
||||
* if S is past the end of the string, the tuple toaster will
|
||||
* return a zero-length string to us
|
||||
*/
|
||||
S1 = Max(S, 1);
|
||||
|
||||
/*
|
||||
* We need to start at position zero because there is no
|
||||
* way to know in advance which byte offset corresponds to
|
||||
* the supplied start position.
|
||||
* We need to start at position zero because there is no way to
|
||||
* know in advance which byte offset corresponds to the supplied
|
||||
* start position.
|
||||
*/
|
||||
slice_start = 0;
|
||||
|
||||
if (length_not_specified) /* special case - get length to end of string */
|
||||
if (length_not_specified) /* special case - get length to
|
||||
* end of string */
|
||||
slice_size = L1 = -1;
|
||||
else
|
||||
{
|
||||
int E = S + length;
|
||||
int E = S + length;
|
||||
|
||||
/*
|
||||
* A negative value for L is the only way for the end position
|
||||
@@ -543,22 +545,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if the start
|
||||
* was negative or one. SQL99 says to return a zero-length string.
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if
|
||||
* the start was negative or one. SQL99 says to return a
|
||||
* zero-length string.
|
||||
*/
|
||||
if (E < 1)
|
||||
return PG_STR_GET_TEXT("");
|
||||
|
||||
/*
|
||||
* if E is past the end of the string, the tuple toaster
|
||||
* will truncate the length for us
|
||||
* if E is past the end of the string, the tuple toaster will
|
||||
* truncate the length for us
|
||||
*/
|
||||
L1 = E - S1;
|
||||
|
||||
/*
|
||||
* Total slice size in bytes can't be any longer than the start
|
||||
* position plus substring length times the encoding max length.
|
||||
* Total slice size in bytes can't be any longer than the
|
||||
* start position plus substring length times the encoding max
|
||||
* length.
|
||||
*/
|
||||
slice_size = (S1 + L1) * eml;
|
||||
}
|
||||
@@ -569,9 +573,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
return PG_STR_GET_TEXT("");
|
||||
|
||||
/* Now we can get the actual length of the slice in MB characters */
|
||||
slice_strlen = pg_mbstrlen_with_len (VARDATA(slice), VARSIZE(slice) - VARHDRSZ);
|
||||
slice_strlen = pg_mbstrlen_with_len(VARDATA(slice), VARSIZE(slice) - VARHDRSZ);
|
||||
|
||||
/* Check that the start position wasn't > slice_strlen. If so,
|
||||
/*
|
||||
* Check that the start position wasn't > slice_strlen. If so,
|
||||
* SQL99 says to return a zero-length string.
|
||||
*/
|
||||
if (S1 > slice_strlen)
|
||||
@@ -579,16 +584,17 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
|
||||
/*
|
||||
* Adjust L1 and E1 now that we know the slice string length.
|
||||
* Again remember that S1 is one based, and slice_start is zero based.
|
||||
* Again remember that S1 is one based, and slice_start is zero
|
||||
* based.
|
||||
*/
|
||||
if (L1 > -1)
|
||||
E1 = Min(S1 + L1 , slice_start + 1 + slice_strlen);
|
||||
E1 = Min(S1 + L1, slice_start + 1 + slice_strlen);
|
||||
else
|
||||
E1 = slice_start + 1 + slice_strlen;
|
||||
|
||||
/*
|
||||
* Find the start position in the slice;
|
||||
* remember S1 is not zero based
|
||||
* Find the start position in the slice; remember S1 is not zero
|
||||
* based
|
||||
*/
|
||||
p = VARDATA(slice);
|
||||
for (i = 0; i < S1 - 1; i++)
|
||||
@@ -598,8 +604,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
s = p;
|
||||
|
||||
/*
|
||||
* Count the actual bytes used by the substring of
|
||||
* the requested length.
|
||||
* Count the actual bytes used by the substring of the requested
|
||||
* length.
|
||||
*/
|
||||
for (i = S1; i < E1; i++)
|
||||
p += pg_mblen(p);
|
||||
@@ -612,7 +618,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
"is less than one.");
|
||||
|
||||
/* not reached: suppress compiler warning */
|
||||
return PG_STR_GET_TEXT("");
|
||||
@@ -650,8 +656,8 @@ text_position(Datum str, Datum search_str, int matchnum)
|
||||
len1,
|
||||
len2;
|
||||
|
||||
if(matchnum == 0)
|
||||
return 0; /* result for 0th match */
|
||||
if (matchnum == 0)
|
||||
return 0; /* result for 0th match */
|
||||
|
||||
if (VARSIZE(t2) <= VARHDRSZ)
|
||||
PG_RETURN_INT32(1); /* result for empty pattern */
|
||||
@@ -662,10 +668,10 @@ text_position(Datum str, Datum search_str, int matchnum)
|
||||
/* no use in searching str past point where search_str will fit */
|
||||
px = (len1 - len2);
|
||||
|
||||
if (eml == 1) /* simple case - single byte encoding */
|
||||
if (eml == 1) /* simple case - single byte encoding */
|
||||
{
|
||||
char *p1,
|
||||
*p2;
|
||||
char *p1,
|
||||
*p2;
|
||||
|
||||
p1 = VARDATA(t1);
|
||||
p2 = VARDATA(t2);
|
||||
@@ -683,7 +689,7 @@ text_position(Datum str, Datum search_str, int matchnum)
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
else if (eml > 1) /* not as simple - multibyte encoding */
|
||||
else if (eml > 1) /* not as simple - multibyte encoding */
|
||||
{
|
||||
pg_wchar *p1,
|
||||
*p2,
|
||||
@@ -715,7 +721,7 @@ text_position(Datum str, Datum search_str, int matchnum)
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Invalid backend encoding; encoding max length "
|
||||
"is less than one.");
|
||||
"is less than one.");
|
||||
|
||||
PG_RETURN_INT32(pos);
|
||||
}
|
||||
@@ -734,10 +740,10 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
|
||||
*a2p;
|
||||
|
||||
/*
|
||||
* Unfortunately, there is no strncoll(), so in the non-C locale
|
||||
* case we have to do some memory copying. This turns out to be
|
||||
* significantly slower, so we optimize the case where LC_COLLATE
|
||||
* is C.
|
||||
* Unfortunately, there is no strncoll(), so in the non-C locale case
|
||||
* we have to do some memory copying. This turns out to be
|
||||
* significantly slower, so we optimize the case where LC_COLLATE is
|
||||
* C.
|
||||
*/
|
||||
if (!lc_collate_is_c())
|
||||
{
|
||||
@@ -990,7 +996,7 @@ byteacat(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
#define PG_STR_GET_BYTEA(str_) \
|
||||
DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
|
||||
DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
|
||||
/*
|
||||
* bytea_substr()
|
||||
* Return a substring starting at the specified position.
|
||||
@@ -1009,36 +1015,37 @@ byteacat(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
bytea_substr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int S = PG_GETARG_INT32(1); /* start position */
|
||||
int S1; /* adjusted start position */
|
||||
int L1; /* adjusted substring length */
|
||||
int S = PG_GETARG_INT32(1); /* start position */
|
||||
int S1; /* adjusted start position */
|
||||
int L1; /* adjusted substring length */
|
||||
|
||||
S1 = Max(S, 1);
|
||||
|
||||
if (fcinfo->nargs == 2)
|
||||
{
|
||||
/*
|
||||
* Not passed a length - PG_GETARG_BYTEA_P_SLICE()
|
||||
* grabs everything to the end of the string if we pass it
|
||||
* a negative value for length.
|
||||
* Not passed a length - PG_GETARG_BYTEA_P_SLICE() grabs
|
||||
* everything to the end of the string if we pass it a negative
|
||||
* value for length.
|
||||
*/
|
||||
L1 = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* end position */
|
||||
int E = S + PG_GETARG_INT32(2);
|
||||
int E = S + PG_GETARG_INT32(2);
|
||||
|
||||
/*
|
||||
* A negative value for L is the only way for the end position
|
||||
* to be before the start. SQL99 says to throw an error.
|
||||
* A negative value for L is the only way for the end position to
|
||||
* be before the start. SQL99 says to throw an error.
|
||||
*/
|
||||
if (E < S)
|
||||
elog(ERROR, "negative substring length not allowed");
|
||||
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if the start
|
||||
* was negative or one. SQL99 says to return a zero-length string.
|
||||
/*
|
||||
* A zero or negative value for the end position can happen if the
|
||||
* start was negative or one. SQL99 says to return a zero-length
|
||||
* string.
|
||||
*/
|
||||
if (E < 1)
|
||||
PG_RETURN_BYTEA_P(PG_STR_GET_BYTEA(""));
|
||||
@@ -1046,13 +1053,12 @@ bytea_substr(PG_FUNCTION_ARGS)
|
||||
L1 = E - S1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the start position is past the end of the string,
|
||||
* SQL99 says to return a zero-length string --
|
||||
* PG_GETARG_TEXT_P_SLICE() will do that for us.
|
||||
* Convert to zero-based starting position
|
||||
/*
|
||||
* If the start position is past the end of the string, SQL99 says to
|
||||
* return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do
|
||||
* that for us. Convert to zero-based starting position
|
||||
*/
|
||||
PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE (0, S1 - 1, L1));
|
||||
PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE(0, S1 - 1, L1));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1343,7 +1349,7 @@ textToQualifiedNameList(text *textval, const char *caller)
|
||||
/* Convert to C string (handles possible detoasting). */
|
||||
/* Note we rely on being able to modify rawname below. */
|
||||
rawname = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(textval)));
|
||||
PointerGetDatum(textval)));
|
||||
|
||||
if (!SplitIdentifierString(rawname, '.', &namelist))
|
||||
elog(ERROR, "%s: invalid name syntax", caller);
|
||||
@@ -1353,7 +1359,7 @@ textToQualifiedNameList(text *textval, const char *caller)
|
||||
|
||||
foreach(l, namelist)
|
||||
{
|
||||
char *curname = (char *) lfirst(l);
|
||||
char *curname = (char *) lfirst(l);
|
||||
|
||||
result = lappend(result, makeString(pstrdup(curname)));
|
||||
}
|
||||
@@ -1368,15 +1374,15 @@ textToQualifiedNameList(text *textval, const char *caller)
|
||||
* SplitIdentifierString --- parse a string containing identifiers
|
||||
*
|
||||
* This is the guts of textToQualifiedNameList, and is exported for use in
|
||||
* other situations such as parsing GUC variables. In the GUC case, it's
|
||||
* other situations such as parsing GUC variables. In the GUC case, it's
|
||||
* important to avoid memory leaks, so the API is designed to minimize the
|
||||
* amount of stuff that needs to be allocated and freed.
|
||||
*
|
||||
* Inputs:
|
||||
* rawstring: the input string; must be overwritable! On return, it's
|
||||
* rawstring: the input string; must be overwritable! On return, it's
|
||||
* been modified to contain the separated identifiers.
|
||||
* separator: the separator punctuation expected between identifiers
|
||||
* (typically '.' or ','). Whitespace may also appear around
|
||||
* (typically '.' or ','). Whitespace may also appear around
|
||||
* identifiers.
|
||||
* Outputs:
|
||||
* namelist: filled with a palloc'd list of pointers to identifiers within
|
||||
@@ -1417,11 +1423,11 @@ SplitIdentifierString(char *rawstring, char separator,
|
||||
{
|
||||
endp = strchr(nextp + 1, '\"');
|
||||
if (endp == NULL)
|
||||
return false; /* mismatched quotes */
|
||||
return false; /* mismatched quotes */
|
||||
if (endp[1] != '\"')
|
||||
break; /* found end of quoted name */
|
||||
/* Collapse adjacent quotes into one quote, and look again */
|
||||
memmove(endp, endp+1, strlen(endp));
|
||||
memmove(endp, endp + 1, strlen(endp));
|
||||
nextp = endp;
|
||||
}
|
||||
/* endp now points at the terminating quote */
|
||||
@@ -1435,8 +1441,8 @@ SplitIdentifierString(char *rawstring, char separator,
|
||||
!isspace((unsigned char) *nextp))
|
||||
{
|
||||
/*
|
||||
* It's important that this match the identifier downcasing
|
||||
* code used by backend/parser/scan.l.
|
||||
* It's important that this match the identifier
|
||||
* downcasing code used by backend/parser/scan.l.
|
||||
*/
|
||||
if (isupper((unsigned char) *nextp))
|
||||
*nextp = tolower((unsigned char) *nextp);
|
||||
@@ -1647,24 +1653,24 @@ byteacmp(PG_FUNCTION_ARGS)
|
||||
* replace_text
|
||||
* replace all occurences of 'old_sub_str' in 'orig_str'
|
||||
* with 'new_sub_str' to form 'new_str'
|
||||
*
|
||||
*
|
||||
* returns 'orig_str' if 'old_sub_str' == '' or 'orig_str' == ''
|
||||
* otherwise returns 'new_str'
|
||||
* otherwise returns 'new_str'
|
||||
*/
|
||||
Datum
|
||||
replace_text(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *left_text;
|
||||
text *right_text;
|
||||
text *buf_text;
|
||||
text *ret_text;
|
||||
text *left_text;
|
||||
text *right_text;
|
||||
text *buf_text;
|
||||
text *ret_text;
|
||||
int curr_posn;
|
||||
text *src_text = PG_GETARG_TEXT_P(0);
|
||||
text *src_text = PG_GETARG_TEXT_P(0);
|
||||
int src_text_len = TEXTLEN(src_text);
|
||||
text *from_sub_text = PG_GETARG_TEXT_P(1);
|
||||
text *from_sub_text = PG_GETARG_TEXT_P(1);
|
||||
int from_sub_text_len = TEXTLEN(from_sub_text);
|
||||
text *to_sub_text = PG_GETARG_TEXT_P(2);
|
||||
char *to_sub_str = PG_TEXT_GET_STR(to_sub_text);
|
||||
text *to_sub_text = PG_GETARG_TEXT_P(2);
|
||||
char *to_sub_str = PG_TEXT_GET_STR(to_sub_text);
|
||||
StringInfo str = makeStringInfo();
|
||||
|
||||
if (src_text_len == 0 || from_sub_text_len == 0)
|
||||
@@ -1713,7 +1719,7 @@ split_text(PG_FUNCTION_ARGS)
|
||||
int fldnum = PG_GETARG_INT32(2);
|
||||
int start_posn = 0;
|
||||
int end_posn = 0;
|
||||
text *result_text;
|
||||
text *result_text;
|
||||
|
||||
/* return empty string for empty input string */
|
||||
if (inputstring_len < 1)
|
||||
@@ -1722,9 +1728,11 @@ split_text(PG_FUNCTION_ARGS)
|
||||
/* empty field separator */
|
||||
if (fldsep_len < 1)
|
||||
{
|
||||
if (fldnum == 1) /* first field - just return the input string */
|
||||
if (fldnum == 1) /* first field - just return the input
|
||||
* string */
|
||||
PG_RETURN_TEXT_P(inputstring);
|
||||
else /* otherwise return an empty string */
|
||||
else
|
||||
/* otherwise return an empty string */
|
||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
||||
}
|
||||
|
||||
@@ -1733,17 +1741,19 @@ split_text(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "field position must be > 0");
|
||||
|
||||
start_posn = text_position(PointerGetDatum(inputstring),
|
||||
PointerGetDatum(fldsep),
|
||||
fldnum - 1);
|
||||
PointerGetDatum(fldsep),
|
||||
fldnum - 1);
|
||||
end_posn = text_position(PointerGetDatum(inputstring),
|
||||
PointerGetDatum(fldsep),
|
||||
fldnum);
|
||||
PointerGetDatum(fldsep),
|
||||
fldnum);
|
||||
|
||||
if ((start_posn == 0) && (end_posn == 0)) /* fldsep not found */
|
||||
{
|
||||
if (fldnum == 1) /* first field - just return the input string */
|
||||
if (fldnum == 1) /* first field - just return the input
|
||||
* string */
|
||||
PG_RETURN_TEXT_P(inputstring);
|
||||
else /* otherwise return an empty string */
|
||||
else
|
||||
/* otherwise return an empty string */
|
||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
||||
}
|
||||
else if ((start_posn != 0) && (end_posn == 0))
|
||||
@@ -1774,11 +1784,11 @@ split_text(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
to_hex32(PG_FUNCTION_ARGS)
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int32 value = PG_GETARG_INT32(0);
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int32 value = PG_GETARG_INT32(0);
|
||||
|
||||
ptr = buf + sizeof(buf) - 1;
|
||||
*ptr = '\0';
|
||||
@@ -1800,11 +1810,11 @@ to_hex32(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
to_hex64(PG_FUNCTION_ARGS)
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int64 value = PG_GETARG_INT64(0);
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int64 value = PG_GETARG_INT64(0);
|
||||
|
||||
ptr = buf + sizeof(buf) - 1;
|
||||
*ptr = '\0';
|
||||
@@ -1818,4 +1828,3 @@ to_hex64(PG_FUNCTION_ARGS)
|
||||
result_text = PG_STR_GET_TEXT(ptr);
|
||||
PG_RETURN_TEXT_P(result_text);
|
||||
}
|
||||
|
||||
|
||||
116
src/backend/utils/cache/catcache.c
vendored
116
src/backend/utils/cache/catcache.c
vendored
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.98 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.99 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
|
||||
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
|
||||
|
||||
/*
|
||||
* Constants related to size of the catcache.
|
||||
@@ -102,6 +102,7 @@ static uint32 CatalogCacheComputeHashValue(CatCache *cache, int nkeys,
|
||||
ScanKey cur_skey);
|
||||
static uint32 CatalogCacheComputeTupleHashValue(CatCache *cache,
|
||||
HeapTuple tuple);
|
||||
|
||||
#ifdef CATCACHE_STATS
|
||||
static void CatCachePrintStats(void);
|
||||
#endif
|
||||
@@ -109,8 +110,8 @@ static void CatCacheRemoveCTup(CatCache *cache, CatCTup *ct);
|
||||
static void CatCacheRemoveCList(CatCache *cache, CatCList *cl);
|
||||
static void CatalogCacheInitializeCache(CatCache *cache);
|
||||
static CatCTup *CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
|
||||
uint32 hashValue, Index hashIndex,
|
||||
bool negative);
|
||||
uint32 hashValue, Index hashIndex,
|
||||
bool negative);
|
||||
static HeapTuple build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys);
|
||||
|
||||
|
||||
@@ -325,8 +326,7 @@ CatCachePrintStats(void)
|
||||
cc_lsearches,
|
||||
cc_lhits);
|
||||
}
|
||||
|
||||
#endif /* CATCACHE_STATS */
|
||||
#endif /* CATCACHE_STATS */
|
||||
|
||||
|
||||
/*
|
||||
@@ -372,7 +372,7 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl)
|
||||
Assert(cl->my_cache == cache);
|
||||
|
||||
/* delink from member tuples */
|
||||
for (i = cl->n_members; --i >= 0; )
|
||||
for (i = cl->n_members; --i >= 0;)
|
||||
{
|
||||
CatCTup *ct = cl->members[i];
|
||||
|
||||
@@ -397,11 +397,11 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl)
|
||||
* item pointer. Positive entries are deleted if they match the item
|
||||
* pointer. Negative entries must be deleted if they match the hash
|
||||
* value (since we do not have the exact key of the tuple that's being
|
||||
* inserted). But this should only rarely result in loss of a cache
|
||||
* inserted). But this should only rarely result in loss of a cache
|
||||
* entry that could have been kept.
|
||||
*
|
||||
* Note that it's not very relevant whether the tuple identified by
|
||||
* the item pointer is being inserted or deleted. We don't expect to
|
||||
* the item pointer is being inserted or deleted. We don't expect to
|
||||
* find matching positive entries in the one case, and we don't expect
|
||||
* to find matching negative entries in the other; but we will do the
|
||||
* right things in any case.
|
||||
@@ -435,8 +435,8 @@ CatalogCacheIdInvalidate(int cacheId,
|
||||
|
||||
/*
|
||||
* We don't bother to check whether the cache has finished
|
||||
* initialization yet; if not, there will be no entries in it
|
||||
* so no problem.
|
||||
* initialization yet; if not, there will be no entries in it so
|
||||
* no problem.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -819,7 +819,7 @@ InitCatCache(int id,
|
||||
cp->id = id;
|
||||
cp->cc_relname = relname;
|
||||
cp->cc_indname = indname;
|
||||
cp->cc_reloid = InvalidOid; /* temporary */
|
||||
cp->cc_reloid = InvalidOid; /* temporary */
|
||||
cp->cc_relisshared = false; /* temporary */
|
||||
cp->cc_tupdesc = (TupleDesc) NULL;
|
||||
cp->cc_reloidattr = reloidattr;
|
||||
@@ -1015,8 +1015,8 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey)
|
||||
{
|
||||
/*
|
||||
* Since the OIDs of indexes aren't hardwired, it's painful to
|
||||
* figure out which is which. Just force all pg_index searches
|
||||
* to be heap scans while building the relcaches.
|
||||
* figure out which is which. Just force all pg_index searches to
|
||||
* be heap scans while building the relcaches.
|
||||
*/
|
||||
if (!criticalRelcachesBuilt)
|
||||
return false;
|
||||
@@ -1037,7 +1037,7 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey)
|
||||
if (!criticalRelcachesBuilt)
|
||||
{
|
||||
/* Looking for an OID comparison function? */
|
||||
Oid lookup_oid = DatumGetObjectId(cur_skey[0].sk_argument);
|
||||
Oid lookup_oid = DatumGetObjectId(cur_skey[0].sk_argument);
|
||||
|
||||
if (lookup_oid >= MIN_OIDCMP && lookup_oid <= MAX_OIDCMP)
|
||||
return false;
|
||||
@@ -1055,7 +1055,7 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey)
|
||||
* if necessary (on the first access to a particular cache).
|
||||
*
|
||||
* The result is NULL if not found, or a pointer to a HeapTuple in
|
||||
* the cache. The caller must not modify the tuple, and must call
|
||||
* the cache. The caller must not modify the tuple, and must call
|
||||
* ReleaseCatCache() when done with it.
|
||||
*
|
||||
* The search key values should be expressed as Datums of the key columns'
|
||||
@@ -1077,7 +1077,7 @@ SearchCatCache(CatCache *cache,
|
||||
Dlelem *elt;
|
||||
CatCTup *ct;
|
||||
Relation relation;
|
||||
SysScanDesc scandesc;
|
||||
SysScanDesc scandesc;
|
||||
HeapTuple ntp;
|
||||
|
||||
/*
|
||||
@@ -1134,18 +1134,18 @@ SearchCatCache(CatCache *cache,
|
||||
continue;
|
||||
|
||||
/*
|
||||
* we found a match in the cache: move it to the front of the global
|
||||
* LRU list. We also move it to the front of the list for its
|
||||
* hashbucket, in order to speed subsequent searches. (The most
|
||||
* frequently accessed elements in any hashbucket will tend to be
|
||||
* near the front of the hashbucket's list.)
|
||||
* we found a match in the cache: move it to the front of the
|
||||
* global LRU list. We also move it to the front of the list for
|
||||
* its hashbucket, in order to speed subsequent searches. (The
|
||||
* most frequently accessed elements in any hashbucket will tend
|
||||
* to be near the front of the hashbucket's list.)
|
||||
*/
|
||||
DLMoveToFront(&ct->lrulist_elem);
|
||||
DLMoveToFront(&ct->cache_elem);
|
||||
|
||||
/*
|
||||
* If it's a positive entry, bump its refcount and return it.
|
||||
* If it's negative, we can report failure to the caller.
|
||||
* If it's a positive entry, bump its refcount and return it. If
|
||||
* it's negative, we can report failure to the caller.
|
||||
*/
|
||||
if (!ct->negative)
|
||||
{
|
||||
@@ -1175,8 +1175,8 @@ SearchCatCache(CatCache *cache,
|
||||
|
||||
/*
|
||||
* Tuple was not found in cache, so we have to try to retrieve it
|
||||
* directly from the relation. If found, we will add it to the
|
||||
* cache; if not found, we will add a negative cache entry instead.
|
||||
* directly from the relation. If found, we will add it to the cache;
|
||||
* if not found, we will add a negative cache entry instead.
|
||||
*
|
||||
* NOTE: it is possible for recursive cache lookups to occur while
|
||||
* reading the relation --- for example, due to shared-cache-inval
|
||||
@@ -1213,8 +1213,8 @@ SearchCatCache(CatCache *cache,
|
||||
|
||||
/*
|
||||
* If tuple was not found, we need to build a negative cache entry
|
||||
* containing a fake tuple. The fake tuple has the correct key columns,
|
||||
* but nulls everywhere else.
|
||||
* containing a fake tuple. The fake tuple has the correct key
|
||||
* columns, but nulls everywhere else.
|
||||
*/
|
||||
if (ct == NULL)
|
||||
{
|
||||
@@ -1307,7 +1307,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
List *ctlist;
|
||||
int nmembers;
|
||||
Relation relation;
|
||||
SysScanDesc scandesc;
|
||||
SysScanDesc scandesc;
|
||||
bool ordered;
|
||||
HeapTuple ntp;
|
||||
MemoryContext oldcxt;
|
||||
@@ -1336,8 +1336,8 @@ SearchCatCacheList(CatCache *cache,
|
||||
|
||||
/*
|
||||
* compute a hash value of the given keys for faster search. We don't
|
||||
* presently divide the CatCList items into buckets, but this still lets
|
||||
* us skip non-matching items quickly most of the time.
|
||||
* presently divide the CatCList items into buckets, but this still
|
||||
* lets us skip non-matching items quickly most of the time.
|
||||
*/
|
||||
lHashValue = CatalogCacheComputeHashValue(cache, nkeys, cur_skey);
|
||||
|
||||
@@ -1373,11 +1373,11 @@ SearchCatCacheList(CatCache *cache,
|
||||
|
||||
/*
|
||||
* we found a matching list: move each of its members to the front
|
||||
* of the global LRU list. Also move the list itself to the front
|
||||
* of the cache's list-of-lists, to speed subsequent searches.
|
||||
* (We do not move the members to the fronts of their hashbucket
|
||||
* of the global LRU list. Also move the list itself to the front
|
||||
* of the cache's list-of-lists, to speed subsequent searches. (We
|
||||
* do not move the members to the fronts of their hashbucket
|
||||
* lists, however, since there's no point in that unless they are
|
||||
* searched for individually.) Also bump the members' refcounts.
|
||||
* searched for individually.) Also bump the members' refcounts.
|
||||
*/
|
||||
for (i = 0; i < cl->n_members; i++)
|
||||
{
|
||||
@@ -1400,9 +1400,9 @@ SearchCatCacheList(CatCache *cache,
|
||||
}
|
||||
|
||||
/*
|
||||
* List was not found in cache, so we have to build it by reading
|
||||
* the relation. For each matching tuple found in the relation,
|
||||
* use an existing cache entry if possible, else build a new one.
|
||||
* List was not found in cache, so we have to build it by reading the
|
||||
* relation. For each matching tuple found in the relation, use an
|
||||
* existing cache entry if possible, else build a new one.
|
||||
*/
|
||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||
|
||||
@@ -1438,17 +1438,17 @@ SearchCatCacheList(CatCache *cache,
|
||||
ct = (CatCTup *) DLE_VAL(elt);
|
||||
|
||||
if (ct->dead || ct->negative)
|
||||
continue; /* ignore dead and negative entries */
|
||||
continue; /* ignore dead and negative entries */
|
||||
|
||||
if (ct->hash_value != hashValue)
|
||||
continue; /* quickly skip entry if wrong hash val */
|
||||
continue; /* quickly skip entry if wrong hash val */
|
||||
|
||||
if (!ItemPointerEquals(&(ct->tuple.t_self), &(ntp->t_self)))
|
||||
continue; /* not same tuple */
|
||||
continue; /* not same tuple */
|
||||
|
||||
/*
|
||||
* Found a match, but can't use it if it belongs to another list
|
||||
* already
|
||||
* Found a match, but can't use it if it belongs to another
|
||||
* list already
|
||||
*/
|
||||
if (ct->c_list)
|
||||
continue;
|
||||
@@ -1498,7 +1498,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
cl->hash_value = lHashValue;
|
||||
cl->n_members = nmembers;
|
||||
/* The list is backwards because we built it with lcons */
|
||||
for (i = nmembers; --i >= 0; )
|
||||
for (i = nmembers; --i >= 0;)
|
||||
{
|
||||
cl->members[i] = ct = (CatCTup *) lfirst(ctlist);
|
||||
Assert(ct->c_list == NULL);
|
||||
@@ -1531,7 +1531,7 @@ ReleaseCatCacheList(CatCList *list)
|
||||
Assert(list->cl_magic == CL_MAGIC);
|
||||
Assert(list->refcount > 0);
|
||||
|
||||
for (i = list->n_members; --i >= 0; )
|
||||
for (i = list->n_members; --i >= 0;)
|
||||
{
|
||||
CatCTup *ct = list->members[i];
|
||||
|
||||
@@ -1558,7 +1558,7 @@ ReleaseCatCacheList(CatCList *list)
|
||||
/*
|
||||
* CatalogCacheCreateEntry
|
||||
* Create a new CatCTup entry, copying the given HeapTuple and other
|
||||
* supplied data into it. The new entry is given refcount 1.
|
||||
* supplied data into it. The new entry is given refcount 1.
|
||||
*/
|
||||
static CatCTup *
|
||||
CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
|
||||
@@ -1568,7 +1568,8 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
|
||||
MemoryContext oldcxt;
|
||||
|
||||
/*
|
||||
* Allocate CatCTup header in cache memory, and copy the tuple there too.
|
||||
* Allocate CatCTup header in cache memory, and copy the tuple there
|
||||
* too.
|
||||
*/
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
ct = (CatCTup *) palloc(sizeof(CatCTup));
|
||||
@@ -1655,27 +1656,26 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys)
|
||||
|
||||
for (i = 0; i < nkeys; i++)
|
||||
{
|
||||
int attindex = cache->cc_key[i];
|
||||
Datum keyval = skeys[i].sk_argument;
|
||||
int attindex = cache->cc_key[i];
|
||||
Datum keyval = skeys[i].sk_argument;
|
||||
|
||||
if (attindex > 0)
|
||||
{
|
||||
/*
|
||||
* Here we must be careful in case the caller passed a
|
||||
* C string where a NAME is wanted: convert the given
|
||||
* argument to a correctly padded NAME. Otherwise the
|
||||
* memcpy() done in heap_formtuple could fall off the
|
||||
* end of memory.
|
||||
* Here we must be careful in case the caller passed a C
|
||||
* string where a NAME is wanted: convert the given argument
|
||||
* to a correctly padded NAME. Otherwise the memcpy() done in
|
||||
* heap_formtuple could fall off the end of memory.
|
||||
*/
|
||||
if (cache->cc_isname[i])
|
||||
{
|
||||
Name newval = &tempNames[i];
|
||||
Name newval = &tempNames[i];
|
||||
|
||||
namestrcpy(newval, DatumGetCString(keyval));
|
||||
keyval = NameGetDatum(newval);
|
||||
}
|
||||
values[attindex-1] = keyval;
|
||||
nulls[attindex-1] = ' ';
|
||||
values[attindex - 1] = keyval;
|
||||
nulls[attindex - 1] = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1727,7 +1727,7 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys)
|
||||
void
|
||||
PrepareToInvalidateCacheTuple(Relation relation,
|
||||
HeapTuple tuple,
|
||||
void (*function) (int, uint32, ItemPointer, Oid))
|
||||
void (*function) (int, uint32, ItemPointer, Oid))
|
||||
{
|
||||
CatCache *ccp;
|
||||
Oid reloid;
|
||||
|
||||
32
src/backend/utils/cache/inval.c
vendored
32
src/backend/utils/cache/inval.c
vendored
@@ -10,7 +10,7 @@
|
||||
* ie, until the next CommandCounterIncrement() or transaction commit.
|
||||
* (See utils/time/tqual.c, and note that system catalogs are generally
|
||||
* scanned under SnapshotNow rules by the system, or plain user snapshots
|
||||
* for user queries.) At the command boundary, the old tuple stops
|
||||
* for user queries.) At the command boundary, the old tuple stops
|
||||
* being valid and the new version, if any, becomes valid. Therefore,
|
||||
* we cannot simply flush a tuple from the system caches during heap_update()
|
||||
* or heap_delete(). The tuple is still good at that point; what's more,
|
||||
@@ -29,12 +29,12 @@
|
||||
*
|
||||
* If we successfully complete the transaction, we have to broadcast all
|
||||
* these invalidation events to other backends (via the SI message queue)
|
||||
* so that they can flush obsolete entries from their caches. Note we have
|
||||
* so that they can flush obsolete entries from their caches. Note we have
|
||||
* to record the transaction commit before sending SI messages, otherwise
|
||||
* the other backends won't see our updated tuples as good.
|
||||
*
|
||||
* In short, we need to remember until xact end every insert or delete
|
||||
* of a tuple that might be in the system caches. Updates are treated as
|
||||
* of a tuple that might be in the system caches. Updates are treated as
|
||||
* two events, delete + insert, for simplicity. (There are cases where
|
||||
* it'd be possible to record just one event, but we don't currently try.)
|
||||
*
|
||||
@@ -74,7 +74,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.54 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.55 2002/09/04 20:31:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -129,7 +129,7 @@ static InvalidationListHeader CurrentCmdInvalidMsgs;
|
||||
/* head of previous-commands event list */
|
||||
static InvalidationListHeader PriorCmdInvalidMsgs;
|
||||
|
||||
static bool RelcacheInitFileInval; /* init file must be invalidated? */
|
||||
static bool RelcacheInitFileInval; /* init file must be invalidated? */
|
||||
|
||||
/*
|
||||
* Dynamically-registered callback functions. Current implementation
|
||||
@@ -395,6 +395,7 @@ RegisterRelcacheInvalidation(Oid dbId, Oid relId)
|
||||
{
|
||||
AddRelcacheInvalidationMessage(&CurrentCmdInvalidMsgs,
|
||||
dbId, relId);
|
||||
|
||||
/*
|
||||
* If the relation being invalidated is one of those cached in the
|
||||
* relcache init file, mark that we need to zap that file at commit.
|
||||
@@ -505,10 +506,11 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
|
||||
*/
|
||||
if (!IsSystemRelation(relation))
|
||||
return;
|
||||
/*
|
||||
* TOAST tuples can likewise be ignored here.
|
||||
* Note that TOAST tables are considered system relations
|
||||
* so they are not filtered by the above test.
|
||||
|
||||
/*
|
||||
* TOAST tuples can likewise be ignored here. Note that TOAST tables
|
||||
* are considered system relations so they are not filtered by the
|
||||
* above test.
|
||||
*/
|
||||
if (IsToastRelation(relation))
|
||||
return;
|
||||
@@ -573,12 +575,12 @@ AcceptInvalidationMessages(void)
|
||||
* If isCommit, we must send out the messages in our PriorCmdInvalidMsgs list
|
||||
* to the shared invalidation message queue. Note that these will be read
|
||||
* not only by other backends, but also by our own backend at the next
|
||||
* transaction start (via AcceptInvalidationMessages). This means that
|
||||
* transaction start (via AcceptInvalidationMessages). This means that
|
||||
* we can skip immediate local processing of anything that's still in
|
||||
* CurrentCmdInvalidMsgs, and just send that list out too.
|
||||
*
|
||||
* If not isCommit, we are aborting, and must locally process the messages
|
||||
* in PriorCmdInvalidMsgs. No messages need be sent to other backends,
|
||||
* in PriorCmdInvalidMsgs. No messages need be sent to other backends,
|
||||
* since they'll not have seen our changed tuples anyway. We can forget
|
||||
* about CurrentCmdInvalidMsgs too, since those changes haven't touched
|
||||
* the caches yet.
|
||||
@@ -596,9 +598,9 @@ AtEOXactInvalidationMessages(bool isCommit)
|
||||
if (isCommit)
|
||||
{
|
||||
/*
|
||||
* Relcache init file invalidation requires processing both
|
||||
* before and after we send the SI messages. However, we need
|
||||
* not do anything unless we committed.
|
||||
* Relcache init file invalidation requires processing both before
|
||||
* and after we send the SI messages. However, we need not do
|
||||
* anything unless we committed.
|
||||
*/
|
||||
if (RelcacheInitFileInval)
|
||||
RelationCacheInitFileInvalidate(true);
|
||||
@@ -694,7 +696,7 @@ CacheInvalidateRelcache(Oid relationId)
|
||||
*
|
||||
* NOTE: currently, the OID argument to the callback routine is not
|
||||
* provided for syscache callbacks; the routine doesn't really get any
|
||||
* useful info as to exactly what changed. It should treat every call
|
||||
* useful info as to exactly what changed. It should treat every call
|
||||
* as a "cache flush" request.
|
||||
*/
|
||||
void
|
||||
|
||||
14
src/backend/utils/cache/lsyscache.c
vendored
14
src/backend/utils/cache/lsyscache.c
vendored
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.82 2002/08/31 22:10:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.83 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@@ -349,7 +349,7 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp)
|
||||
*
|
||||
* Returns the cross-type comparison operators (ltype "<" rtype and
|
||||
* ltype ">" rtype) for an operator previously determined to be
|
||||
* mergejoinable. Optionally, fetches the regproc ids of these
|
||||
* mergejoinable. Optionally, fetches the regproc ids of these
|
||||
* operators, as well as their operator OIDs.
|
||||
*/
|
||||
void
|
||||
@@ -651,7 +651,7 @@ get_relname_relid(const char *relname, Oid relnamespace)
|
||||
Oid
|
||||
get_system_catalog_relid(const char *catname)
|
||||
{
|
||||
Oid relid;
|
||||
Oid relid;
|
||||
|
||||
relid = GetSysCacheOid(RELNAMENSP,
|
||||
PointerGetDatum(catname),
|
||||
@@ -737,7 +737,7 @@ get_rel_namespace(Oid relid)
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
Oid result;
|
||||
Oid result;
|
||||
|
||||
result = reltup->relnamespace;
|
||||
ReleaseSysCache(tp);
|
||||
@@ -766,7 +766,7 @@ get_rel_type_id(Oid relid)
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
|
||||
Oid result;
|
||||
Oid result;
|
||||
|
||||
result = reltup->reltype;
|
||||
ReleaseSysCache(tp);
|
||||
@@ -1105,8 +1105,8 @@ getBaseTypeMod(Oid typid, int32 typmod)
|
||||
/*
|
||||
* The typmod applied to a domain should always be -1.
|
||||
*
|
||||
* We substitute the domain's typmod as we switch attention to
|
||||
* the base type.
|
||||
* We substitute the domain's typmod as we switch attention to the
|
||||
* base type.
|
||||
*/
|
||||
Assert(typmod < 0);
|
||||
|
||||
|
||||
240
src/backend/utils/cache/relcache.c
vendored
240
src/backend/utils/cache/relcache.c
vendored
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.174 2002/09/02 02:47:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.175 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -81,7 +81,7 @@ static FormData_pg_attribute Desc_pg_type[Natts_pg_type] = {Schema_pg_type};
|
||||
* Relations are looked up two ways, by OID and by name,
|
||||
* thus there are two hash tables for referencing them.
|
||||
*
|
||||
* The OID index covers all relcache entries. The name index
|
||||
* The OID index covers all relcache entries. The name index
|
||||
* covers *only* system relations (only those in PG_CATALOG_NAMESPACE).
|
||||
*/
|
||||
static HTAB *RelationIdCache;
|
||||
@@ -98,7 +98,7 @@ static HTAB *RelationNodeCache;
|
||||
* This flag is false until we have prepared the critical relcache entries
|
||||
* that are needed to do indexscans on the tables read by relcache building.
|
||||
*/
|
||||
bool criticalRelcachesBuilt = false;
|
||||
bool criticalRelcachesBuilt = false;
|
||||
|
||||
/*
|
||||
* This flag is set if we discover that we need to write a new relcache
|
||||
@@ -108,7 +108,7 @@ static bool needNewCacheFile = false;
|
||||
|
||||
/*
|
||||
* This counter counts relcache inval events received since backend startup
|
||||
* (but only for rels that are actually in cache). Presently, we use it only
|
||||
* (but only for rels that are actually in cache). Presently, we use it only
|
||||
* to detect whether data about to be written by write_relcache_init_file()
|
||||
* might already be obsolete.
|
||||
*/
|
||||
@@ -260,8 +260,8 @@ typedef struct opclasscacheent
|
||||
StrategyNumber numStrats; /* max # of strategies (from pg_am) */
|
||||
StrategyNumber numSupport; /* max # of support procs (from pg_am) */
|
||||
Oid *operatorOids; /* strategy operators' OIDs */
|
||||
RegProcedure *operatorProcs; /* strategy operators' procs */
|
||||
RegProcedure *supportProcs; /* support procs */
|
||||
RegProcedure *operatorProcs; /* strategy operators' procs */
|
||||
RegProcedure *supportProcs; /* support procs */
|
||||
} OpClassCacheEnt;
|
||||
|
||||
static HTAB *OpClassCache = NULL;
|
||||
@@ -292,15 +292,15 @@ static void AttrDefaultFetch(Relation relation);
|
||||
static void CheckConstraintFetch(Relation relation);
|
||||
static List *insert_ordered_oid(List *list, Oid datum);
|
||||
static void IndexSupportInitialize(Form_pg_index iform,
|
||||
IndexStrategy indexStrategy,
|
||||
Oid *indexOperator,
|
||||
RegProcedure *indexSupport,
|
||||
StrategyNumber maxStrategyNumber,
|
||||
StrategyNumber maxSupportNumber,
|
||||
AttrNumber maxAttributeNumber);
|
||||
IndexStrategy indexStrategy,
|
||||
Oid *indexOperator,
|
||||
RegProcedure *indexSupport,
|
||||
StrategyNumber maxStrategyNumber,
|
||||
StrategyNumber maxSupportNumber,
|
||||
AttrNumber maxAttributeNumber);
|
||||
static OpClassCacheEnt *LookupOpclassInfo(Oid operatorClassOid,
|
||||
StrategyNumber numStrats,
|
||||
StrategyNumber numSupport);
|
||||
StrategyNumber numStrats,
|
||||
StrategyNumber numSupport);
|
||||
|
||||
|
||||
/*
|
||||
@@ -345,7 +345,7 @@ ScanPgRelation(RelationBuildDescInfo buildinfo)
|
||||
ScanKeyEntryInitialize(&key[1], 0,
|
||||
Anum_pg_class_relnamespace,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(PG_CATALOG_NAMESPACE));
|
||||
ObjectIdGetDatum(PG_CATALOG_NAMESPACE));
|
||||
nkeys = 2;
|
||||
indexRelname = ClassNameNspIndex;
|
||||
break;
|
||||
@@ -356,9 +356,9 @@ ScanPgRelation(RelationBuildDescInfo buildinfo)
|
||||
}
|
||||
|
||||
/*
|
||||
* Open pg_class and fetch a tuple. Force heap scan if we haven't
|
||||
* yet built the critical relcache entries (this includes initdb
|
||||
* and startup without a pg_internal.init file).
|
||||
* Open pg_class and fetch a tuple. Force heap scan if we haven't yet
|
||||
* built the critical relcache entries (this includes initdb and
|
||||
* startup without a pg_internal.init file).
|
||||
*/
|
||||
pg_class_desc = heap_openr(RelationRelationName, AccessShareLock);
|
||||
pg_class_scan = systable_beginscan(pg_class_desc, indexRelname,
|
||||
@@ -481,9 +481,9 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
|
||||
Int16GetDatum(0));
|
||||
|
||||
/*
|
||||
* Open pg_attribute and begin a scan. Force heap scan if we haven't
|
||||
* yet built the critical relcache entries (this includes initdb
|
||||
* and startup without a pg_internal.init file).
|
||||
* Open pg_attribute and begin a scan. Force heap scan if we haven't
|
||||
* yet built the critical relcache entries (this includes initdb and
|
||||
* startup without a pg_internal.init file).
|
||||
*/
|
||||
pg_attribute_desc = heap_openr(AttributeRelationName, AccessShareLock);
|
||||
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
|
||||
@@ -653,8 +653,8 @@ RelationBuildRuleLock(Relation relation)
|
||||
relation->rd_rulescxt = rulescxt;
|
||||
|
||||
/*
|
||||
* allocate an array to hold the rewrite rules (the array is extended if
|
||||
* necessary)
|
||||
* allocate an array to hold the rewrite rules (the array is extended
|
||||
* if necessary)
|
||||
*/
|
||||
maxlocks = 4;
|
||||
rules = (RewriteRule **)
|
||||
@@ -672,14 +672,14 @@ RelationBuildRuleLock(Relation relation)
|
||||
/*
|
||||
* open pg_rewrite and begin a scan
|
||||
*
|
||||
* Note: since we scan the rules using RewriteRelRulenameIndex,
|
||||
* we will be reading the rules in name order, except possibly
|
||||
* during emergency-recovery operations (ie, IsIgnoringSystemIndexes).
|
||||
* This in turn ensures that rules will be fired in name order.
|
||||
* Note: since we scan the rules using RewriteRelRulenameIndex, we will
|
||||
* be reading the rules in name order, except possibly during
|
||||
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
||||
* in turn ensures that rules will be fired in name order.
|
||||
*/
|
||||
rewrite_desc = heap_openr(RewriteRelationName, AccessShareLock);
|
||||
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
|
||||
rewrite_scan = systable_beginscan(rewrite_desc,
|
||||
rewrite_scan = systable_beginscan(rewrite_desc,
|
||||
RewriteRelRulenameIndex,
|
||||
true, SnapshotNow,
|
||||
1, &key);
|
||||
@@ -723,7 +723,7 @@ RelationBuildRuleLock(Relation relation)
|
||||
&isnull);
|
||||
Assert(!isnull);
|
||||
rule_evqual_str = DatumGetCString(DirectFunctionCall1(textout,
|
||||
rule_evqual));
|
||||
rule_evqual));
|
||||
oldcxt = MemoryContextSwitchTo(rulescxt);
|
||||
rule->qual = (Node *) stringToNode(rule_evqual_str);
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
@@ -767,9 +767,9 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2)
|
||||
int i;
|
||||
|
||||
/*
|
||||
* As of 7.3 we assume the rule ordering is repeatable,
|
||||
* because RelationBuildRuleLock should read 'em in a
|
||||
* consistent order. So just compare corresponding slots.
|
||||
* As of 7.3 we assume the rule ordering is repeatable, because
|
||||
* RelationBuildRuleLock should read 'em in a consistent order. So
|
||||
* just compare corresponding slots.
|
||||
*/
|
||||
if (rlock1 != NULL)
|
||||
{
|
||||
@@ -860,9 +860,10 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
|
||||
RelationSetReferenceCount(relation, 1);
|
||||
|
||||
/*
|
||||
* normal relations are not nailed into the cache; nor can a pre-existing
|
||||
* relation be new. It could be temp though. (Actually, it could be new
|
||||
* too, but it's okay to forget that fact if forced to flush the entry.)
|
||||
* normal relations are not nailed into the cache; nor can a
|
||||
* pre-existing relation be new. It could be temp though. (Actually,
|
||||
* it could be new too, but it's okay to forget that fact if forced to
|
||||
* flush the entry.)
|
||||
*/
|
||||
relation->rd_isnailed = false;
|
||||
relation->rd_isnew = false;
|
||||
@@ -950,8 +951,8 @@ RelationInitIndexAccessInfo(Relation relation)
|
||||
uint16 amsupport;
|
||||
|
||||
/*
|
||||
* Make a copy of the pg_index entry for the index. Note that this
|
||||
* is a variable-length tuple.
|
||||
* Make a copy of the pg_index entry for the index. Note that this is
|
||||
* a variable-length tuple.
|
||||
*/
|
||||
tuple = SearchSysCache(INDEXRELID,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
@@ -1116,6 +1117,7 @@ IndexSupportInitialize(Form_pg_index iform,
|
||||
MemSet(mapentry, 0, sizeof(*mapentry));
|
||||
mapentry->sk_flags = 0;
|
||||
mapentry->sk_procedure = opcentry->operatorProcs[strategy];
|
||||
|
||||
/*
|
||||
* Mark mapentry->sk_func invalid, until and unless
|
||||
* someone sets it up.
|
||||
@@ -1387,7 +1389,7 @@ formrdesc(const char *relationName,
|
||||
/*
|
||||
* It's important to distinguish between shared and non-shared
|
||||
* relations, even at bootstrap time, to make sure we know where they
|
||||
* are stored. At present, all relations that formrdesc is used for
|
||||
* are stored. At present, all relations that formrdesc is used for
|
||||
* are not shared.
|
||||
*/
|
||||
relation->rd_rel->relisshared = false;
|
||||
@@ -1401,12 +1403,12 @@ formrdesc(const char *relationName,
|
||||
/*
|
||||
* initialize attribute tuple form
|
||||
*
|
||||
* Unlike the case with the relation tuple, this data had better be
|
||||
* right because it will never be replaced. The input values must be
|
||||
* Unlike the case with the relation tuple, this data had better be right
|
||||
* because it will never be replaced. The input values must be
|
||||
* correctly defined by macros in src/include/catalog/ headers.
|
||||
*/
|
||||
relation->rd_att = CreateTemplateTupleDesc(natts,
|
||||
relation->rd_rel->relhasoids);
|
||||
relation->rd_rel->relhasoids);
|
||||
|
||||
/*
|
||||
* initialize tuple desc info
|
||||
@@ -1799,10 +1801,11 @@ RelationClearRelation(Relation relation, bool rebuild)
|
||||
FreeTriggerDesc(old_trigdesc);
|
||||
|
||||
/*
|
||||
* Update rd_nblocks. This is kind of expensive, but I think we must
|
||||
* do it in case relation has been truncated... we definitely must
|
||||
* do it if the rel is new or temp, since RelationGetNumberOfBlocks
|
||||
* will subsequently assume that the block count is correct.
|
||||
* Update rd_nblocks. This is kind of expensive, but I think we
|
||||
* must do it in case relation has been truncated... we definitely
|
||||
* must do it if the rel is new or temp, since
|
||||
* RelationGetNumberOfBlocks will subsequently assume that the
|
||||
* block count is correct.
|
||||
*/
|
||||
RelationUpdateNumberOfBlocks(relation);
|
||||
}
|
||||
@@ -1971,12 +1974,13 @@ AtEOXact_RelationCache(bool commit)
|
||||
/*
|
||||
* Is it a relation created in the current transaction?
|
||||
*
|
||||
* During commit, reset the flag to false, since we are now out of the
|
||||
* creating transaction. During abort, simply delete the relcache
|
||||
* entry --- it isn't interesting any longer. (NOTE: if we have
|
||||
* forgotten the isnew state of a new relation due to a forced cache
|
||||
* flush, the entry will get deleted anyway by shared-cache-inval
|
||||
* processing of the aborted pg_class insertion.)
|
||||
* During commit, reset the flag to false, since we are now out of
|
||||
* the creating transaction. During abort, simply delete the
|
||||
* relcache entry --- it isn't interesting any longer. (NOTE: if
|
||||
* we have forgotten the isnew state of a new relation due to a
|
||||
* forced cache flush, the entry will get deleted anyway by
|
||||
* shared-cache-inval processing of the aborted pg_class
|
||||
* insertion.)
|
||||
*/
|
||||
if (relation->rd_isnew)
|
||||
{
|
||||
@@ -1991,18 +1995,18 @@ AtEOXact_RelationCache(bool commit)
|
||||
|
||||
/*
|
||||
* During transaction abort, we must also reset relcache entry ref
|
||||
* counts to their normal not-in-a-transaction state. A ref count may
|
||||
* be too high because some routine was exited by elog() between
|
||||
* incrementing and decrementing the count.
|
||||
* counts to their normal not-in-a-transaction state. A ref count
|
||||
* may be too high because some routine was exited by elog()
|
||||
* between incrementing and decrementing the count.
|
||||
*
|
||||
* During commit, we should not have to do this, but it's still useful
|
||||
* to check that the counts are correct to catch missed relcache
|
||||
* closes.
|
||||
* During commit, we should not have to do this, but it's still
|
||||
* useful to check that the counts are correct to catch missed
|
||||
* relcache closes.
|
||||
*
|
||||
* In bootstrap mode, do NOT reset the refcnt nor complain that it's
|
||||
* nonzero --- the bootstrap code expects relations to stay open
|
||||
* across start/commit transaction calls. (That seems bogus, but it's
|
||||
* not worth fixing.)
|
||||
* across start/commit transaction calls. (That seems bogus, but
|
||||
* it's not worth fixing.)
|
||||
*/
|
||||
expected_refcnt = relation->rd_isnailed ? 1 : 0;
|
||||
|
||||
@@ -2083,10 +2087,10 @@ RelationBuildLocalRelation(const char *relname,
|
||||
/*
|
||||
* create a new tuple descriptor from the one passed in. We do this
|
||||
* partly to copy it into the cache context, and partly because the
|
||||
* new relation can't have any defaults or constraints yet; they
|
||||
* have to be added in later steps, because they require additions
|
||||
* to multiple system catalogs. We can copy attnotnull constraints
|
||||
* here, however.
|
||||
* new relation can't have any defaults or constraints yet; they have
|
||||
* to be added in later steps, because they require additions to
|
||||
* multiple system catalogs. We can copy attnotnull constraints here,
|
||||
* however.
|
||||
*/
|
||||
rel->rd_att = CreateTupleDescCopy(tupDesc);
|
||||
for (i = 0; i < natts; i++)
|
||||
@@ -2184,12 +2188,12 @@ RelationCacheInitialize(void)
|
||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
/*
|
||||
* Try to load the relcache cache file. If successful, we're done
|
||||
* for now. Otherwise, initialize the cache with pre-made descriptors
|
||||
* for the critical "nailed-in" system catalogs.
|
||||
* Try to load the relcache cache file. If successful, we're done for
|
||||
* now. Otherwise, initialize the cache with pre-made descriptors for
|
||||
* the critical "nailed-in" system catalogs.
|
||||
*/
|
||||
if (IsBootstrapProcessingMode() ||
|
||||
! load_relcache_init_file())
|
||||
!load_relcache_init_file())
|
||||
{
|
||||
formrdesc(RelationRelationName,
|
||||
Natts_pg_class, Desc_pg_class);
|
||||
@@ -2228,22 +2232,23 @@ RelationCacheInitializePhase2(void)
|
||||
* If we didn't get the critical system indexes loaded into relcache,
|
||||
* do so now. These are critical because the catcache depends on them
|
||||
* for catcache fetches that are done during relcache load. Thus, we
|
||||
* have an infinite-recursion problem. We can break the recursion
|
||||
* by doing heapscans instead of indexscans at certain key spots.
|
||||
* To avoid hobbling performance, we only want to do that until we
|
||||
* have the critical indexes loaded into relcache. Thus, the flag
|
||||
* criticalRelcachesBuilt is used to decide whether to do heapscan
|
||||
* or indexscan at the key spots, and we set it true after we've loaded
|
||||
* have an infinite-recursion problem. We can break the recursion by
|
||||
* doing heapscans instead of indexscans at certain key spots. To
|
||||
* avoid hobbling performance, we only want to do that until we have
|
||||
* the critical indexes loaded into relcache. Thus, the flag
|
||||
* criticalRelcachesBuilt is used to decide whether to do heapscan or
|
||||
* indexscan at the key spots, and we set it true after we've loaded
|
||||
* the critical indexes.
|
||||
*
|
||||
* The critical indexes are marked as "nailed in cache", partly to make
|
||||
* it easy for load_relcache_init_file to count them, but mainly
|
||||
* because we cannot flush and rebuild them once we've set
|
||||
* criticalRelcachesBuilt to true. (NOTE: perhaps it would be possible
|
||||
* to reload them by temporarily setting criticalRelcachesBuilt to
|
||||
* false again. For now, though, we just nail 'em in.)
|
||||
* criticalRelcachesBuilt to true. (NOTE: perhaps it would be
|
||||
* possible to reload them by temporarily setting
|
||||
* criticalRelcachesBuilt to false again. For now, though, we just
|
||||
* nail 'em in.)
|
||||
*/
|
||||
if (! criticalRelcachesBuilt)
|
||||
if (!criticalRelcachesBuilt)
|
||||
{
|
||||
RelationBuildDescInfo buildinfo;
|
||||
Relation ird;
|
||||
@@ -2265,7 +2270,7 @@ RelationCacheInitializePhase2(void)
|
||||
LOAD_CRIT_INDEX(AccessMethodProcedureIndex);
|
||||
LOAD_CRIT_INDEX(OperatorOidIndex);
|
||||
|
||||
#define NUM_CRITICAL_INDEXES 7 /* fix if you change list above */
|
||||
#define NUM_CRITICAL_INDEXES 7 /* fix if you change list above */
|
||||
|
||||
criticalRelcachesBuilt = true;
|
||||
}
|
||||
@@ -2273,10 +2278,10 @@ RelationCacheInitializePhase2(void)
|
||||
/*
|
||||
* Now, scan all the relcache entries and update anything that might
|
||||
* be wrong in the results from formrdesc or the relcache cache file.
|
||||
* If we faked up relcache entries using formrdesc, then read
|
||||
* the real pg_class rows and replace the fake entries with them.
|
||||
* Also, if any of the relcache entries have rules or triggers,
|
||||
* load that info the hard way since it isn't recorded in the cache file.
|
||||
* If we faked up relcache entries using formrdesc, then read the real
|
||||
* pg_class rows and replace the fake entries with them. Also, if any
|
||||
* of the relcache entries have rules or triggers, load that info the
|
||||
* hard way since it isn't recorded in the cache file.
|
||||
*/
|
||||
hash_seq_init(&status, RelationIdCache);
|
||||
|
||||
@@ -2293,12 +2298,13 @@ RelationCacheInitializePhase2(void)
|
||||
Form_pg_class relp;
|
||||
|
||||
htup = SearchSysCache(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(htup))
|
||||
elog(FATAL, "RelationCacheInitializePhase2: no pg_class entry for %s",
|
||||
RelationGetRelationName(relation));
|
||||
relp = (Form_pg_class) GETSTRUCT(htup);
|
||||
|
||||
/*
|
||||
* Copy tuple to relation->rd_rel. (See notes in
|
||||
* AllocateRelationDesc())
|
||||
@@ -2335,11 +2341,11 @@ RelationCacheInitializePhase3(void)
|
||||
if (needNewCacheFile)
|
||||
{
|
||||
/*
|
||||
* Force all the catcaches to finish initializing and thereby
|
||||
* open the catalogs and indexes they use. This will preload
|
||||
* the relcache with entries for all the most important system
|
||||
* catalogs and indexes, so that the init file will be most
|
||||
* useful for future backends.
|
||||
* Force all the catcaches to finish initializing and thereby open
|
||||
* the catalogs and indexes they use. This will preload the
|
||||
* relcache with entries for all the most important system
|
||||
* catalogs and indexes, so that the init file will be most useful
|
||||
* for future backends.
|
||||
*/
|
||||
InitCatalogCachePhase2();
|
||||
|
||||
@@ -2509,7 +2515,7 @@ CheckConstraintFetch(Relation relation)
|
||||
RelationGetRelationName(relation));
|
||||
|
||||
check[found].ccname = MemoryContextStrdup(CacheMemoryContext,
|
||||
NameStr(conform->conname));
|
||||
NameStr(conform->conname));
|
||||
|
||||
/* Grab and test conbin is actually set */
|
||||
val = fastgetattr(htup,
|
||||
@@ -2559,7 +2565,7 @@ List *
|
||||
RelationGetIndexList(Relation relation)
|
||||
{
|
||||
Relation indrel;
|
||||
SysScanDesc indscan;
|
||||
SysScanDesc indscan;
|
||||
ScanKeyData skey;
|
||||
HeapTuple htup;
|
||||
List *result;
|
||||
@@ -2724,7 +2730,7 @@ load_relcache_init_file(void)
|
||||
nailed_rels = nailed_indexes = 0;
|
||||
initFileRelationIds = NIL;
|
||||
|
||||
for (relno = 0; ; relno++)
|
||||
for (relno = 0;; relno++)
|
||||
{
|
||||
Size len;
|
||||
size_t nread;
|
||||
@@ -2820,9 +2826,9 @@ load_relcache_init_file(void)
|
||||
*/
|
||||
indexcxt = AllocSetContextCreate(CacheMemoryContext,
|
||||
RelationGetRelationName(rel),
|
||||
0, /* minsize */
|
||||
512, /* initsize */
|
||||
1024); /* maxsize */
|
||||
0, /* minsize */
|
||||
512, /* initsize */
|
||||
1024); /* maxsize */
|
||||
rel->rd_indexcxt = indexcxt;
|
||||
|
||||
/* next, read the index strategy map */
|
||||
@@ -2883,8 +2889,9 @@ load_relcache_init_file(void)
|
||||
/*
|
||||
* Rules and triggers are not saved (mainly because the internal
|
||||
* format is complex and subject to change). They must be rebuilt
|
||||
* if needed by RelationCacheInitializePhase2. This is not expected
|
||||
* to be a big performance hit since few system catalogs have such.
|
||||
* if needed by RelationCacheInitializePhase2. This is not
|
||||
* expected to be a big performance hit since few system catalogs
|
||||
* have such.
|
||||
*/
|
||||
rel->rd_rules = NULL;
|
||||
rel->rd_rulescxt = NULL;
|
||||
@@ -2917,8 +2924,8 @@ load_relcache_init_file(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* We reached the end of the init file without apparent problem.
|
||||
* Did we get the right number of nailed items? (This is a useful
|
||||
* We reached the end of the init file without apparent problem. Did
|
||||
* we get the right number of nailed items? (This is a useful
|
||||
* crosscheck in case the set of critical rels or indexes changes.)
|
||||
*/
|
||||
if (nailed_rels != NUM_CRITICAL_RELS ||
|
||||
@@ -2945,9 +2952,9 @@ load_relcache_init_file(void)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* init file is broken, so do it the hard way. We don't bother
|
||||
* trying to free the clutter we just allocated; it's not in the
|
||||
* relcache so it won't hurt.
|
||||
* init file is broken, so do it the hard way. We don't bother trying
|
||||
* to free the clutter we just allocated; it's not in the relcache so
|
||||
* it won't hurt.
|
||||
*/
|
||||
read_failed:
|
||||
pfree(rels);
|
||||
@@ -3052,7 +3059,7 @@ write_relcache_init_file(void)
|
||||
* afresh using the syscache, and write that.
|
||||
*/
|
||||
tuple = SearchSysCache(INDEXRELID,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "write_relcache_init_file: no pg_index entry for index %u",
|
||||
@@ -3109,14 +3116,14 @@ write_relcache_init_file(void)
|
||||
|
||||
/*
|
||||
* Now we have to check whether the data we've so painstakingly
|
||||
* accumulated is already obsolete due to someone else's just-committed
|
||||
* catalog changes. If so, we just delete the temp file and leave it
|
||||
* to the next backend to try again. (Our own relcache entries will be
|
||||
* updated by SI message processing, but we can't be sure whether what
|
||||
* we wrote out was up-to-date.)
|
||||
* accumulated is already obsolete due to someone else's
|
||||
* just-committed catalog changes. If so, we just delete the temp
|
||||
* file and leave it to the next backend to try again. (Our own
|
||||
* relcache entries will be updated by SI message processing, but we
|
||||
* can't be sure whether what we wrote out was up-to-date.)
|
||||
*
|
||||
* This mustn't run concurrently with RelationCacheInitFileInvalidate,
|
||||
* so grab a serialization lock for the duration.
|
||||
* This mustn't run concurrently with RelationCacheInitFileInvalidate, so
|
||||
* grab a serialization lock for the duration.
|
||||
*/
|
||||
LWLockAcquire(RelCacheInitLock, LW_EXCLUSIVE);
|
||||
|
||||
@@ -3140,9 +3147,10 @@ write_relcache_init_file(void)
|
||||
if (rename(tempfilename, finalfilename) < 0)
|
||||
{
|
||||
elog(WARNING, "Cannot rename init file %s to %s: %m\n\tContinuing anyway, but there's something wrong.", tempfilename, finalfilename);
|
||||
|
||||
/*
|
||||
* If we fail, try to clean up the useless temp file; don't bother
|
||||
* to complain if this fails too.
|
||||
* If we fail, try to clean up the useless temp file; don't
|
||||
* bother to complain if this fails too.
|
||||
*/
|
||||
unlink(tempfilename);
|
||||
}
|
||||
@@ -3206,13 +3214,13 @@ RelationCacheInitFileInvalidate(bool beforeSend)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We need to interlock this against write_relcache_init_file,
|
||||
* to guard against possibility that someone renames a new-but-
|
||||
* We need to interlock this against write_relcache_init_file, to
|
||||
* guard against possibility that someone renames a new-but-
|
||||
* already-obsolete init file into place just after we unlink.
|
||||
* With the interlock, it's certain that write_relcache_init_file
|
||||
* will notice our SI inval message before renaming into place,
|
||||
* or else that we will execute second and successfully unlink
|
||||
* the file.
|
||||
* will notice our SI inval message before renaming into place, or
|
||||
* else that we will execute second and successfully unlink the
|
||||
* file.
|
||||
*/
|
||||
LWLockAcquire(RelCacheInitLock, LW_EXCLUSIVE);
|
||||
unlink(initfilename);
|
||||
|
||||
19
src/backend/utils/cache/syscache.c
vendored
19
src/backend/utils/cache/syscache.c
vendored
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.86 2002/08/05 03:29:17 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.87 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@@ -174,7 +174,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
0
|
||||
}},
|
||||
{
|
||||
CastRelationName, /* CASTSOURCETARGET */
|
||||
CastRelationName, /* CASTSOURCETARGET */
|
||||
CastSourceTargetIndex,
|
||||
0,
|
||||
2,
|
||||
@@ -204,7 +204,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
0,
|
||||
0
|
||||
}},
|
||||
{ConversionRelationName, /* CONDEFAULT */
|
||||
{ConversionRelationName, /* CONDEFAULT */
|
||||
ConversionDefaultIndex,
|
||||
0,
|
||||
4,
|
||||
@@ -214,7 +214,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
Anum_pg_conversion_contoencoding,
|
||||
ObjectIdAttributeNumber,
|
||||
}},
|
||||
{ConversionRelationName, /* CONNAMENSP */
|
||||
{ConversionRelationName, /* CONNAMENSP */
|
||||
ConversionNameNspIndex,
|
||||
0,
|
||||
2,
|
||||
@@ -224,7 +224,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
0,
|
||||
0
|
||||
}},
|
||||
{ConversionRelationName, /* CONOID */
|
||||
{ConversionRelationName, /* CONOID */
|
||||
ConversionOidIndex,
|
||||
0,
|
||||
1,
|
||||
@@ -436,7 +436,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;
|
||||
|
||||
@@ -501,9 +502,7 @@ InitCatalogCachePhase2(void)
|
||||
Assert(CacheInitialized);
|
||||
|
||||
for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
|
||||
{
|
||||
InitCatCachePhase2(SysCache[cacheId]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -531,7 +530,7 @@ SearchSysCache(int cacheId,
|
||||
Datum key4)
|
||||
{
|
||||
if (cacheId < 0 || cacheId >= SysCacheSize ||
|
||||
! PointerIsValid(SysCache[cacheId]))
|
||||
!PointerIsValid(SysCache[cacheId]))
|
||||
elog(ERROR, "SearchSysCache: Bad cache id %d", cacheId);
|
||||
|
||||
return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4);
|
||||
@@ -731,7 +730,7 @@ SearchSysCacheList(int cacheId, int nkeys,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4)
|
||||
{
|
||||
if (cacheId < 0 || cacheId >= SysCacheSize ||
|
||||
! PointerIsValid(SysCache[cacheId]))
|
||||
!PointerIsValid(SysCache[cacheId]))
|
||||
elog(ERROR, "SearchSysCacheList: Bad cache id %d", cacheId);
|
||||
|
||||
return SearchCatCacheList(SysCache[cacheId], nkeys,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.22 2002/08/10 20:29:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.23 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
* NOTE
|
||||
* This should eventually work with elog()
|
||||
@@ -31,9 +31,7 @@ ExceptionalCondition(char *conditionName,
|
||||
if (!PointerIsValid(conditionName)
|
||||
|| !PointerIsValid(fileName)
|
||||
|| !PointerIsValid(errorType))
|
||||
{
|
||||
fprintf(stderr, "TRAP: ExceptionalCondition: bad arguments\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.102 2002/09/02 05:42:54 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.103 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -91,6 +91,7 @@ void
|
||||
elog(int lev, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
/*
|
||||
* The expanded format and final output message are dynamically
|
||||
* allocated if necessary, but not if they fit in the "reasonable
|
||||
@@ -103,22 +104,22 @@ elog(int lev, const char *fmt,...)
|
||||
* Note that we use malloc() not palloc() because we want to retain
|
||||
* control if we run out of memory. palloc() would recursively call
|
||||
* elog(ERROR), which would be all right except if we are working on a
|
||||
* FATAL or PANIC error. We'd lose track of the fatal condition
|
||||
* and report a mere ERROR to outer loop, which would be a Bad Thing.
|
||||
* So, we substitute an appropriate message in-place, without
|
||||
* downgrading the level if it's above ERROR.
|
||||
* FATAL or PANIC error. We'd lose track of the fatal condition and
|
||||
* report a mere ERROR to outer loop, which would be a Bad Thing. So,
|
||||
* we substitute an appropriate message in-place, without downgrading
|
||||
* the level if it's above ERROR.
|
||||
*/
|
||||
char fmt_fixedbuf[128];
|
||||
char msg_fixedbuf[256];
|
||||
char *fmt_buf = fmt_fixedbuf;
|
||||
char *msg_buf = msg_fixedbuf;
|
||||
char copylineno_buf[32]; /* for COPY line numbers */
|
||||
char copylineno_buf[32]; /* for COPY line numbers */
|
||||
const char *errorstr;
|
||||
const char *prefix;
|
||||
const char *cp;
|
||||
char *bp;
|
||||
size_t space_needed;
|
||||
size_t timestamp_size; /* prefix len for timestamp+pid */
|
||||
size_t timestamp_size; /* prefix len for timestamp+pid */
|
||||
bool output_to_server = false;
|
||||
bool output_to_client = false;
|
||||
|
||||
@@ -206,13 +207,13 @@ elog(int lev, const char *fmt,...)
|
||||
* calculation simple, we only allow one %m.
|
||||
*/
|
||||
space_needed = timestamp_size + strlen(prefix) +
|
||||
strlen(fmt) + strlen(errorstr) + 1;
|
||||
strlen(fmt) + strlen(errorstr) + 1;
|
||||
|
||||
if (copy_lineno)
|
||||
{
|
||||
/*
|
||||
* Prints the failure line of the COPY. Wow, what a hack! bjm
|
||||
* Translator: Error message will be truncated at 31 characters.
|
||||
* Prints the failure line of the COPY. Wow, what a hack! bjm
|
||||
* Translator: Error message will be truncated at 31 characters.
|
||||
*/
|
||||
snprintf(copylineno_buf, 32, gettext("copy: line %d, "), copy_lineno);
|
||||
space_needed += strlen(copylineno_buf);
|
||||
@@ -427,13 +428,14 @@ elog(int lev, const char *fmt,...)
|
||||
if (msg_buf != msg_fixedbuf)
|
||||
free(msg_buf);
|
||||
|
||||
/* If the user wants this elog() generating query logged,
|
||||
* do so. We only want to log if the query has been
|
||||
* written to debug_query_string. Also, avoid infinite loops.
|
||||
/*
|
||||
* If the user wants this elog() generating query logged, do so. We
|
||||
* only want to log if the query has been written to
|
||||
* debug_query_string. Also, avoid infinite loops.
|
||||
*/
|
||||
|
||||
if(lev != LOG && lev >= log_min_error_statement && debug_query_string)
|
||||
elog(LOG,"statement: %s",debug_query_string);
|
||||
if (lev != LOG && lev >= log_min_error_statement && debug_query_string)
|
||||
elog(LOG, "statement: %s", debug_query_string);
|
||||
|
||||
/*
|
||||
* Perform error recovery action as specified by lev.
|
||||
@@ -445,7 +447,8 @@ elog(int lev, const char *fmt,...)
|
||||
|
||||
/*
|
||||
* If we just reported a startup failure, the client will
|
||||
* disconnect on receiving it, so don't send any more to the client.
|
||||
* disconnect on receiving it, so don't send any more to the
|
||||
* client.
|
||||
*/
|
||||
if (!Warn_restart_ready && whereToSendOutput == Remote)
|
||||
whereToSendOutput = None;
|
||||
@@ -506,7 +509,7 @@ elog(int lev, const char *fmt,...)
|
||||
proc_exit(2);
|
||||
}
|
||||
|
||||
/* We reach here if lev <= WARNING. OK to return to caller. */
|
||||
/* We reach here if lev <= WARNING. OK to return to caller. */
|
||||
}
|
||||
|
||||
|
||||
@@ -744,8 +747,8 @@ send_message_to_frontend(int type, const char *msg)
|
||||
AssertArg(type <= ERROR);
|
||||
|
||||
pq_beginmessage(&buf);
|
||||
pq_sendbyte(&buf, type != ERROR ? 'N' : 'E'); /* N is INFO, NOTICE,
|
||||
* or WARNING */
|
||||
pq_sendbyte(&buf, type != ERROR ? 'N' : 'E'); /* N is INFO, NOTICE, or
|
||||
* WARNING */
|
||||
pq_sendstring(&buf, msg);
|
||||
pq_endmessage(&buf);
|
||||
|
||||
@@ -835,6 +838,3 @@ elog_message_prefix(int lev)
|
||||
Assert(prefix != NULL);
|
||||
return prefix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.61 2002/08/13 17:22:08 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.62 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ typedef struct
|
||||
|
||||
|
||||
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
|
||||
bool ignore_security);
|
||||
bool ignore_security);
|
||||
static void fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple);
|
||||
static void fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple);
|
||||
static Datum fmgr_oldstyle(PG_FUNCTION_ARGS);
|
||||
@@ -339,8 +339,8 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
|
||||
|
||||
/*
|
||||
* If lookup of the PL handler function produced nonnull fn_extra,
|
||||
* complain --- it must be an oldstyle function! We no longer
|
||||
* support oldstyle PL handlers.
|
||||
* complain --- it must be an oldstyle function! We no longer support
|
||||
* oldstyle PL handlers.
|
||||
*/
|
||||
if (plfinfo.fn_extra != NULL)
|
||||
elog(ERROR, "fmgr_info: language %u has old-style handler",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Copyright (c) 2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.5 2002/08/30 19:56:49 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.6 2002/09/04 20:31:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -62,7 +62,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
fcinfo->flinfo->fn_extra = retval;
|
||||
}
|
||||
else /* second and subsequent calls */
|
||||
else
|
||||
/* second and subsequent calls */
|
||||
{
|
||||
elog(ERROR, "init_MultiFuncCall may not be called more than once");
|
||||
|
||||
@@ -75,7 +76,7 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
|
||||
/*
|
||||
* per_MultiFuncCall
|
||||
*
|
||||
*
|
||||
* Do Multi-function per-call setup
|
||||
*/
|
||||
FuncCallContext *
|
||||
@@ -87,8 +88,8 @@ per_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
* Clear the TupleTableSlot, if present. This is for safety's sake:
|
||||
* the Slot will be in a long-lived context (it better be, if the
|
||||
* FuncCallContext is pointing to it), but in most usage patterns the
|
||||
* tuples stored in it will be in the function's per-tuple context.
|
||||
* So at the beginning of each call, the Slot will hold a dangling
|
||||
* tuples stored in it will be in the function's per-tuple context. So
|
||||
* at the beginning of each call, the Slot will hold a dangling
|
||||
* pointer to an already-recycled tuple. We clear it out here. (See
|
||||
* also the definition of TupleGetDatum() in funcapi.h!)
|
||||
*/
|
||||
@@ -109,8 +110,8 @@ end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx)
|
||||
fcinfo->flinfo->fn_extra = NULL;
|
||||
|
||||
/*
|
||||
* Caller is responsible to free up memory for individual
|
||||
* struct elements other than att_in_funcinfo and elements.
|
||||
* Caller is responsible to free up memory for individual struct
|
||||
* elements other than att_in_funcinfo and elements.
|
||||
*/
|
||||
if (funcctx->attinmeta != NULL)
|
||||
pfree(funcctx->attinmeta);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.29 2002/09/02 02:47:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.30 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -115,7 +115,7 @@ ValidateBinary(char *path)
|
||||
is_x = buf.st_mode & S_IXGRP;
|
||||
if (!(is_r && is_x))
|
||||
elog(DEBUG2, "ValidateBinary: \"%s\" is not group read/execute",
|
||||
path);
|
||||
path);
|
||||
return is_x ? (is_r ? 0 : -2) : -1;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ ValidateBinary(char *path)
|
||||
is_x = buf.st_mode & S_IXOTH;
|
||||
if (!(is_r && is_x))
|
||||
elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute",
|
||||
path);
|
||||
path);
|
||||
return is_x ? (is_r ? 0 : -2) : -1;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
|
||||
case 0: /* found ok */
|
||||
strncpy(full_path, buf, MAXPGPATH);
|
||||
elog(DEBUG1, "FindExec: found \"%s\" using PATH",
|
||||
full_path);
|
||||
full_path);
|
||||
free(path);
|
||||
return 0;
|
||||
case -1: /* wasn't even a candidate, keep looking */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.66 2002/08/12 00:36:11 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.67 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Globals used all over the place should be declared here and not
|
||||
@@ -39,6 +39,7 @@ struct Port *MyProcPort;
|
||||
long MyCancelKey;
|
||||
|
||||
char *DataDir = NULL;
|
||||
|
||||
/*
|
||||
* The PGDATA directory user says to use, or defaults to via environment
|
||||
* variable. NULL if no option given and no environment variable set
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.95 2002/09/02 02:47:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.96 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -176,8 +176,8 @@ SetDataDir(const char *dir)
|
||||
* generating funny-looking paths to individual files.
|
||||
*/
|
||||
newlen = strlen(new);
|
||||
if (newlen > 1 && new[newlen-1] == '/')
|
||||
new[newlen-1] = '\0';
|
||||
if (newlen > 1 && new[newlen - 1] == '/')
|
||||
new[newlen - 1] = '\0';
|
||||
|
||||
if (DataDir)
|
||||
free(DataDir);
|
||||
@@ -470,7 +470,6 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
||||
pfree(ChArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CYR_RECODE */
|
||||
|
||||
|
||||
@@ -561,22 +560,22 @@ InitializeSessionUserId(const char *username)
|
||||
AuthenticatedUserId = usesysid;
|
||||
AuthenticatedUserIsSuperuser = ((Form_pg_shadow) GETSTRUCT(userTup))->usesuper;
|
||||
|
||||
SetSessionUserId(usesysid); /* sets CurrentUserId too */
|
||||
SetSessionUserId(usesysid); /* sets CurrentUserId too */
|
||||
|
||||
/* Record username as a config option too */
|
||||
SetConfigOption("session_authorization", username,
|
||||
PGC_BACKEND, PGC_S_OVERRIDE);
|
||||
|
||||
/*
|
||||
* Set up user-specific configuration variables. This is a good
|
||||
* place to do it so we don't have to read pg_shadow twice during
|
||||
* session startup.
|
||||
* Set up user-specific configuration variables. This is a good place
|
||||
* to do it so we don't have to read pg_shadow twice during session
|
||||
* startup.
|
||||
*/
|
||||
datum = SysCacheGetAttr(SHADOWNAME, userTup,
|
||||
Anum_pg_shadow_useconfig, &isnull);
|
||||
if (!isnull)
|
||||
{
|
||||
ArrayType *a = DatumGetArrayTypeP(datum);
|
||||
ArrayType *a = DatumGetArrayTypeP(datum);
|
||||
|
||||
ProcessGUCArray(a, PGC_S_USER);
|
||||
}
|
||||
@@ -952,7 +951,7 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
* Append key information. Format to try to keep it the same length
|
||||
* Append key information. Format to try to keep it the same length
|
||||
* always (trailing junk won't hurt, but might confuse humans).
|
||||
*/
|
||||
sprintf(ptr, "%9lu %9lu\n", id1, id2);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.115 2002/09/03 21:45:42 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.116 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -124,13 +124,14 @@ ReverifyMyDatabase(const char *name)
|
||||
name);
|
||||
|
||||
/*
|
||||
* OK, we're golden. Only other to-do item is to save the
|
||||
* encoding info out of the pg_database tuple.
|
||||
* OK, we're golden. Only other to-do item is to save the encoding
|
||||
* info out of the pg_database tuple.
|
||||
*/
|
||||
SetDatabaseEncoding(dbform->encoding);
|
||||
/* If we have no other source of client_encoding, use server encoding */
|
||||
SetConfigOption("client_encoding", GetDatabaseEncodingName(),
|
||||
PGC_BACKEND, PGC_S_DEFAULT);
|
||||
|
||||
/*
|
||||
* Set up database-specific configuration variables.
|
||||
*/
|
||||
@@ -143,7 +144,7 @@ ReverifyMyDatabase(const char *name)
|
||||
RelationGetDescr(pgdbrel), &isnull);
|
||||
if (!isnull)
|
||||
{
|
||||
ArrayType *a = DatumGetArrayTypeP(datum);
|
||||
ArrayType *a = DatumGetArrayTypeP(datum);
|
||||
|
||||
ProcessGUCArray(a, PGC_S_DATABASE);
|
||||
}
|
||||
@@ -277,8 +278,8 @@ InitPostgres(const char *dbname, const char *username)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set up my per-backend PGPROC struct in shared memory. (We need to
|
||||
* know MyDatabaseId before we can do this, since it's entered into
|
||||
* Set up my per-backend PGPROC struct in shared memory. (We need
|
||||
* to know MyDatabaseId before we can do this, since it's entered into
|
||||
* the PGPROC struct.)
|
||||
*/
|
||||
InitProcess();
|
||||
@@ -304,9 +305,9 @@ InitPostgres(const char *dbname, const char *username)
|
||||
AmiTransactionOverride(bootstrap);
|
||||
|
||||
/*
|
||||
* Initialize the relation descriptor cache. This must create
|
||||
* at least the minimum set of "nailed-in" cache entries. No
|
||||
* catalog access happens here.
|
||||
* Initialize the relation descriptor cache. This must create at
|
||||
* least the minimum set of "nailed-in" cache entries. No catalog
|
||||
* access happens here.
|
||||
*/
|
||||
RelationCacheInitialize();
|
||||
|
||||
@@ -367,25 +368,26 @@ InitPostgres(const char *dbname, const char *username)
|
||||
ReverifyMyDatabase(dbname);
|
||||
|
||||
/*
|
||||
* Final phase of relation cache startup: write a new cache file
|
||||
* if necessary. This is done after ReverifyMyDatabase to avoid
|
||||
* writing a cache file into a dead database.
|
||||
* Final phase of relation cache startup: write a new cache file if
|
||||
* necessary. This is done after ReverifyMyDatabase to avoid writing
|
||||
* a cache file into a dead database.
|
||||
*/
|
||||
RelationCacheInitializePhase3();
|
||||
|
||||
/*
|
||||
* Initialize various default states that can't be set up until
|
||||
* we've selected the active user and done ReverifyMyDatabase.
|
||||
* Initialize various default states that can't be set up until we've
|
||||
* selected the active user and done ReverifyMyDatabase.
|
||||
*/
|
||||
|
||||
/* set default namespace search path */
|
||||
InitializeSearchPath();
|
||||
|
||||
/*
|
||||
* Set up process-exit callback to do pre-shutdown cleanup. This should
|
||||
* be last because we want shmem_exit to call this routine before the exit
|
||||
* callbacks that are registered by buffer manager, lock manager, etc.
|
||||
* We need to run this code before we close down database access!
|
||||
* Set up process-exit callback to do pre-shutdown cleanup. This
|
||||
* should be last because we want shmem_exit to call this routine
|
||||
* before the exit callbacks that are registered by buffer manager,
|
||||
* lock manager, etc. We need to run this code before we close down
|
||||
* database access!
|
||||
*/
|
||||
on_shmem_exit(ShutdownPostgres, 0);
|
||||
|
||||
@@ -395,10 +397,11 @@ InitPostgres(const char *dbname, const char *username)
|
||||
|
||||
/*
|
||||
* Check a normal user hasn't connected to a superuser reserved slot.
|
||||
* Do this here since we need the user information and that only happens
|
||||
* after we've started bringing the shared memory online. So we wait
|
||||
* until we've registered exit handlers and potentially shut an open
|
||||
* transaction down for an as safety conscious rejection as possible.
|
||||
* Do this here since we need the user information and that only
|
||||
* happens after we've started bringing the shared memory online. So
|
||||
* we wait until we've registered exit handlers and potentially shut
|
||||
* an open transaction down for an as safety conscious rejection as
|
||||
* possible.
|
||||
*/
|
||||
if (CountEmptyBackendSlots() < ReservedBackends && !superuser())
|
||||
elog(ERROR, "Non-superuser connection limit exceeded");
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.42 2002/08/14 02:45:10 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.43 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,11 +52,12 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len)
|
||||
len--;
|
||||
*p++ = c1;
|
||||
}
|
||||
else if(c1 >= 0x81 && c1 <= 0xfe)
|
||||
else if (c1 >= 0x81 && c1 <= 0xfe)
|
||||
{
|
||||
c2 = *gb18030++;
|
||||
|
||||
if(c2 >= 0x30 && c2 <= 0x69){
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x69)
|
||||
{
|
||||
len -= 4;
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
@@ -64,13 +65,15 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len)
|
||||
*p++ = *gb18030++;
|
||||
*p++ = *gb18030++;
|
||||
}
|
||||
else if ((c2 >=0x40 && c2 <= 0x7e) ||(c2 >=0x80 && c2 <= 0xfe)){
|
||||
else if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe))
|
||||
{
|
||||
len -= 2;
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
*p++ = *gb18030++;
|
||||
}
|
||||
else{ /*throw the strange code*/
|
||||
else
|
||||
{ /* throw the strange code */
|
||||
len--;
|
||||
}
|
||||
}
|
||||
@@ -92,39 +95,40 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len)
|
||||
{
|
||||
len -= pg_mic_mblen(mic++);
|
||||
|
||||
if (c1 <= 0x7f) /*ASCII*/
|
||||
{
|
||||
if (c1 <= 0x7f) /* ASCII */
|
||||
*p++ = c1;
|
||||
}
|
||||
else if (c1 >= 0x81 && c1 <= 0xfe)
|
||||
{
|
||||
{
|
||||
c2 = *mic++;
|
||||
|
||||
if((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe)){
|
||||
|
||||
if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe))
|
||||
{
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
}
|
||||
else if(c2 >= 0x30 && c2 <= 0x39){
|
||||
else if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
*p++ = *mic++;
|
||||
*p++ = *mic++;
|
||||
}
|
||||
else{
|
||||
}
|
||||
else
|
||||
{
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -387,7 +391,7 @@ UtfToLocal(unsigned char *utf, unsigned char *iso,
|
||||
*/
|
||||
void
|
||||
LocalToUtf(unsigned char *iso, unsigned char *utf,
|
||||
pg_local_to_utf *map, int size, int encoding, int len)
|
||||
pg_local_to_utf *map, int size, int encoding, int len)
|
||||
{
|
||||
unsigned int iiso;
|
||||
int l;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ ascii_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -53,7 +53,7 @@ mic_to_ascii(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -79,12 +79,12 @@ static void mic2win1251(unsigned char *mic, unsigned char *p, int len);
|
||||
static void alt2mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2alt(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
koi8r_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -95,12 +95,12 @@ koi8r_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
|
||||
@@ -116,7 +116,7 @@ iso_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -132,7 +132,7 @@ mic_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
|
||||
@@ -148,7 +148,7 @@ win1251_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -164,7 +164,7 @@ mic_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
|
||||
@@ -180,7 +180,7 @@ alt_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -196,7 +196,7 @@ mic_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ALT);
|
||||
@@ -212,7 +212,7 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -227,12 +227,12 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -252,7 +252,7 @@ koi8r_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -267,12 +267,12 @@ koi8r_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -287,12 +287,12 @@ alt_to_koi8r(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -307,12 +307,12 @@ alt_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -327,12 +327,12 @@ win1251_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -347,12 +347,12 @@ iso_to_koi8r(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
koi8r_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -367,12 +367,12 @@ koi8r_to_iso(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -387,12 +387,12 @@ iso_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -407,12 +407,12 @@ win1251_to_iso(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -427,12 +427,12 @@ iso_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -627,4 +627,3 @@ mic2alt(unsigned char *mic, unsigned char *p, int len)
|
||||
|
||||
mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2alt);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ euc_cn_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -56,7 +56,7 @@ mic_to_euc_cn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ euc_jp_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
@@ -84,7 +84,7 @@ sjis_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
@@ -104,7 +104,7 @@ euc_jp_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -120,7 +120,7 @@ mic_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
|
||||
@@ -136,7 +136,7 @@ sjis_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -152,7 +152,7 @@ mic_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SJIS);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ euc_kr_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -56,7 +56,7 @@ mic_to_euc_kr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
|
||||
@@ -122,4 +122,3 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* 1999/1/15 Tatsuo Ishii
|
||||
*
|
||||
* $Id: big5.c,v 1.1 2002/07/16 09:25:05 ishii Exp $
|
||||
* $Id: big5.c,v 1.2 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
|
||||
/* can be used in either frontend or backend */
|
||||
@@ -19,7 +19,7 @@ typedef struct
|
||||
{
|
||||
unsigned short code,
|
||||
peer;
|
||||
} codes_t;
|
||||
} codes_t;
|
||||
|
||||
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
|
||||
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
|
||||
@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
|
||||
};
|
||||
|
||||
static unsigned short BinarySearchRange
|
||||
(codes_t *array, int high, unsigned short code)
|
||||
(codes_t * array, int high, unsigned short code)
|
||||
{
|
||||
int low,
|
||||
mid,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ euc_tw_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
@@ -72,7 +72,7 @@ big5_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
@@ -92,7 +92,7 @@ euc_tw_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -108,7 +108,7 @@ mic_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
|
||||
@@ -124,7 +124,7 @@ big5_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -140,7 +140,7 @@ mic_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_BIG5);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,12 +47,12 @@ static void mic2latin2(unsigned char *mic, unsigned char *p, int len);
|
||||
static void win12502mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2win1250(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin2_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -63,12 +63,12 @@ latin2_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin2(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN2);
|
||||
@@ -84,7 +84,7 @@ win1250_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -100,7 +100,7 @@ mic_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
|
||||
@@ -116,7 +116,7 @@ latin2_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
|
||||
@@ -136,7 +136,7 @@ win1250_to_latin2(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,12 +47,12 @@ static void mic2latin3(unsigned char *mic, unsigned char *p, int len);
|
||||
static void latin42mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2latin4(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin1_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -63,12 +63,12 @@ latin1_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin1(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN1);
|
||||
@@ -79,12 +79,12 @@ mic_to_latin1(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin3_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN3);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -95,12 +95,12 @@ latin3_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin3(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN3);
|
||||
@@ -111,12 +111,12 @@ mic_to_latin3(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin4_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN4);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -127,11 +127,12 @@ latin4_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum mic_to_latin4(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
mic_to_latin4(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN4);
|
||||
@@ -172,4 +173,3 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len)
|
||||
{
|
||||
mic2latin(mic, p, len, LC_ISO8859_4);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ ascii_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -53,7 +53,7 @@ utf8_to_ascii(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ big5_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_BIG5);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -51,14 +51,14 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_KOI8R,
|
||||
sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_KOI8R,
|
||||
sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -68,14 +68,14 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapKOI8R,
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
|
||||
LocalToUtf(src, dest, LUmapKOI8R,
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -85,14 +85,14 @@ utf8_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_WIN1251,
|
||||
sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_WIN1251,
|
||||
sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -102,14 +102,14 @@ win1251_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapWIN1251,
|
||||
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
|
||||
LocalToUtf(src, dest, LUmapWIN1251,
|
||||
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -119,14 +119,14 @@ utf8_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ALT);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_ALT,
|
||||
sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_ALT,
|
||||
sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -136,14 +136,14 @@ alt_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapALT,
|
||||
sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
|
||||
LocalToUtf(src, dest, LUmapALT,
|
||||
sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_CN,
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_JP,
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_KR,
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_TW,
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_GB18030);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapGB18030,
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_GB18030);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ gbk_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_GBK);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_gbk(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_GBK);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -58,78 +58,79 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS);
|
||||
* ----------
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
pg_enc encoding;
|
||||
pg_local_to_utf *map1; /* to UTF-8 map name */
|
||||
pg_utf_to_local *map2; /* from UTF-8 map name */
|
||||
int size1; /* size of map1 */
|
||||
int size2; /* size of map2 */
|
||||
} pg_conv_map;
|
||||
typedef struct
|
||||
{
|
||||
pg_enc encoding;
|
||||
pg_local_to_utf *map1; /* to UTF-8 map name */
|
||||
pg_utf_to_local *map2; /* from UTF-8 map name */
|
||||
int size1; /* size of map1 */
|
||||
int size2; /* size of map2 */
|
||||
} pg_conv_map;
|
||||
|
||||
static pg_conv_map maps[] = {
|
||||
{PG_SQL_ASCII}, /* SQL/ASCII */
|
||||
{PG_EUC_JP}, /* EUC for Japanese */
|
||||
{PG_EUC_CN}, /* EUC for Chinese */
|
||||
{PG_EUC_KR}, /* EUC for Korean */
|
||||
{PG_EUC_TW}, /* EUC for Taiwan */
|
||||
{PG_JOHAB}, /* EUC for Korean JOHAB */
|
||||
{PG_UTF8}, /* Unicode UTF-8 */
|
||||
{PG_MULE_INTERNAL}, /* Mule internal code */
|
||||
{PG_LATIN1}, /* ISO-8859-1 Latin 1 */
|
||||
{PG_SQL_ASCII}, /* SQL/ASCII */
|
||||
{PG_EUC_JP}, /* EUC for Japanese */
|
||||
{PG_EUC_CN}, /* EUC for Chinese */
|
||||
{PG_EUC_KR}, /* EUC for Korean */
|
||||
{PG_EUC_TW}, /* EUC for Taiwan */
|
||||
{PG_JOHAB}, /* EUC for Korean JOHAB */
|
||||
{PG_UTF8}, /* Unicode UTF-8 */
|
||||
{PG_MULE_INTERNAL}, /* Mule internal code */
|
||||
{PG_LATIN1}, /* ISO-8859-1 Latin 1 */
|
||||
{PG_LATIN2, LUmapISO8859_2, ULmapISO8859_2,
|
||||
sizeof(LUmapISO8859_2)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_2)/sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */
|
||||
sizeof(LUmapISO8859_2) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_2) / sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */
|
||||
{PG_LATIN3, LUmapISO8859_3, ULmapISO8859_3,
|
||||
sizeof(LUmapISO8859_3)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_3)/sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */
|
||||
sizeof(LUmapISO8859_3) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_3) / sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */
|
||||
{PG_LATIN4, LUmapISO8859_4, ULmapISO8859_4,
|
||||
sizeof(LUmapISO8859_4)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_4)/sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */
|
||||
sizeof(LUmapISO8859_4) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_4) / sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */
|
||||
{PG_LATIN5, LUmapISO8859_9, ULmapISO8859_9,
|
||||
sizeof(LUmapISO8859_9)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_9)/sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */
|
||||
sizeof(LUmapISO8859_9) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_9) / sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */
|
||||
{PG_LATIN6, LUmapISO8859_10, ULmapISO8859_10,
|
||||
sizeof(LUmapISO8859_10)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_10)/sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */
|
||||
sizeof(LUmapISO8859_10) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_10) / sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */
|
||||
{PG_LATIN7, LUmapISO8859_13, ULmapISO8859_13,
|
||||
sizeof(LUmapISO8859_13)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_13)/sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */
|
||||
sizeof(LUmapISO8859_13) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_13) / sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */
|
||||
{PG_LATIN8, LUmapISO8859_14, ULmapISO8859_14,
|
||||
sizeof(LUmapISO8859_14)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_14)/sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */
|
||||
sizeof(LUmapISO8859_14) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_14) / sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */
|
||||
{PG_LATIN9, LUmapISO8859_2, ULmapISO8859_2,
|
||||
sizeof(LUmapISO8859_15)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_15)/sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */
|
||||
sizeof(LUmapISO8859_15) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_15) / sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */
|
||||
{PG_LATIN10, LUmapISO8859_16, ULmapISO8859_16,
|
||||
sizeof(LUmapISO8859_16)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_16)/sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */
|
||||
{PG_WIN1256}, /* windows-1256 */
|
||||
sizeof(LUmapISO8859_16) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_16) / sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */
|
||||
{PG_WIN1256}, /* windows-1256 */
|
||||
{PG_TCVN}, /* TCVN (Windows-1258) */
|
||||
{PG_WIN874}, /* windows-874 */
|
||||
{PG_KOI8R}, /* KOI8-R */
|
||||
{PG_WIN1251}, /* windows-1251 (was: WIN) */
|
||||
{PG_ALT}, /* (MS-DOS CP866) */
|
||||
{PG_ISO_8859_5, LUmapISO8859_5, ULmapISO8859_5,
|
||||
sizeof(LUmapISO8859_5)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_5)/sizeof(pg_utf_to_local)}, /* ISO-8859-5 */
|
||||
sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local)}, /* ISO-8859-5 */
|
||||
{PG_ISO_8859_6, LUmapISO8859_6, ULmapISO8859_6,
|
||||
sizeof(LUmapISO8859_6)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_6)/sizeof(pg_utf_to_local)}, /* ISO-8859-6 */
|
||||
sizeof(LUmapISO8859_6) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_6) / sizeof(pg_utf_to_local)}, /* ISO-8859-6 */
|
||||
{PG_ISO_8859_7, LUmapISO8859_7, ULmapISO8859_7,
|
||||
sizeof(LUmapISO8859_7)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_7)/sizeof(pg_utf_to_local)}, /* ISO-8859-7 */
|
||||
sizeof(LUmapISO8859_7) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_7) / sizeof(pg_utf_to_local)}, /* ISO-8859-7 */
|
||||
{PG_ISO_8859_8, LUmapISO8859_8, ULmapISO8859_8,
|
||||
sizeof(LUmapISO8859_8)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_8)/sizeof(pg_utf_to_local)}, /* ISO-8859-8 */
|
||||
sizeof(LUmapISO8859_8) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_8) / sizeof(pg_utf_to_local)}, /* ISO-8859-8 */
|
||||
};
|
||||
|
||||
|
||||
Datum
|
||||
iso8859_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int encoding = PG_GETARG_INT32(0);
|
||||
int encoding = PG_GETARG_INT32(0);
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
@@ -142,10 +143,10 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
utf8_to_iso8859(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int encoding = PG_GETARG_INT32(1);
|
||||
int encoding = PG_GETARG_INT32(1);
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ iso8859_1_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned short c;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
|
||||
@@ -64,7 +64,7 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned short c,
|
||||
c1,
|
||||
c2;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ johab_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_JOHAB);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapJOHAB,
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_johab(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_JOHAB);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ sjis_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SJIS);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ tcvn_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_TCVN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_tcvn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_TCVN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ uhc_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UHC);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_uhc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UHC);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN1250,
|
||||
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN1250,
|
||||
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ win1250_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win1256(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1256);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN1256,
|
||||
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN1256,
|
||||
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ win1256_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1256);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win874(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN874);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN874,
|
||||
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN874,
|
||||
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,14 +56,14 @@ win874_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN874);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapWIN874,
|
||||
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
|
||||
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Encoding names and routines for work with it. All
|
||||
* in this file is shared bedween FE and BE.
|
||||
*
|
||||
* $Id: encnames.c,v 1.9 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: encnames.c,v 1.10 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
#ifdef FRONTEND
|
||||
#include "postgres_fe.h"
|
||||
@@ -55,12 +55,12 @@ pg_encname pg_encname_tbl[] =
|
||||
* for Japanese, stdandard OSF */
|
||||
{
|
||||
"euckr", PG_EUC_KR
|
||||
}, /* EUC-KR; Extended Unix Code for
|
||||
* Korean , KS X 1001 standard */
|
||||
}, /* EUC-KR; Extended Unix Code for Korean ,
|
||||
* KS X 1001 standard */
|
||||
{
|
||||
"euctw", PG_EUC_TW
|
||||
}, /* EUC-TW; Extended Unix Code for
|
||||
|
||||
*
|
||||
* traditional Chinese */
|
||||
{
|
||||
"gb18030", PG_GB18030
|
||||
@@ -171,7 +171,7 @@ pg_encname pg_encname_tbl[] =
|
||||
"tcvn", PG_TCVN
|
||||
}, /* TCVN; Vietnamese TCVN-5712 */
|
||||
{
|
||||
"tcvn5712",PG_TCVN
|
||||
"tcvn5712", PG_TCVN
|
||||
}, /* alias for TCVN */
|
||||
{
|
||||
"uhc", PG_UHC
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* client encoding and server internal encoding.
|
||||
* (currently mule internal code (mic) is used)
|
||||
* Tatsuo Ishii
|
||||
* $Id: mbutils.c,v 1.34 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: mbutils.c,v 1.35 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "access/xact.h"
|
||||
@@ -27,15 +27,15 @@ static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
|
||||
* allocated in TopMemoryContext so that it survives outside
|
||||
* transactions. See SetClientEncoding() for more details.
|
||||
*/
|
||||
static FmgrInfo *ToServerConvPorc = NULL;
|
||||
static FmgrInfo *ToClientConvPorc = NULL;
|
||||
static FmgrInfo *ToServerConvPorc = NULL;
|
||||
static FmgrInfo *ToClientConvPorc = NULL;
|
||||
|
||||
/* Internal functions */
|
||||
static unsigned char *
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server);
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server);
|
||||
|
||||
static int
|
||||
cliplen(const unsigned char *str, int len, int limit);
|
||||
cliplen(const unsigned char *str, int len, int limit);
|
||||
|
||||
/*
|
||||
* Set the client encoding and save fmgrinfo for the converion
|
||||
@@ -46,9 +46,10 @@ int
|
||||
SetClientEncoding(int encoding, bool doit)
|
||||
{
|
||||
int current_server_encoding;
|
||||
Oid to_server_proc, to_client_proc;
|
||||
FmgrInfo *to_server = NULL;
|
||||
FmgrInfo *to_client = NULL;
|
||||
Oid to_server_proc,
|
||||
to_client_proc;
|
||||
FmgrInfo *to_server = NULL;
|
||||
FmgrInfo *to_client = NULL;
|
||||
MemoryContext oldcontext;
|
||||
|
||||
current_server_encoding = GetDatabaseEncoding();
|
||||
@@ -57,15 +58,15 @@ SetClientEncoding(int encoding, bool doit)
|
||||
return (-1);
|
||||
|
||||
if (current_server_encoding == encoding ||
|
||||
(current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII))
|
||||
(current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII))
|
||||
{
|
||||
ClientEncoding = &pg_enc2name_tbl[encoding];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX We cannot use FindDefaultConversionProc() while in
|
||||
* bootstrap or initprocessing mode since namespace functions will
|
||||
* not work.
|
||||
/*
|
||||
* XXX We cannot use FindDefaultConversionProc() while in bootstrap or
|
||||
* initprocessing mode since namespace functions will not work.
|
||||
*/
|
||||
if (IsTransactionState())
|
||||
{
|
||||
@@ -76,8 +77,8 @@ SetClientEncoding(int encoding, bool doit)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* load the fmgr info into TopMemoryContext so that it
|
||||
* survives outside transaction.
|
||||
* load the fmgr info into TopMemoryContext so that it survives
|
||||
* outside transaction.
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
||||
to_server = palloc(sizeof(FmgrInfo));
|
||||
@@ -94,7 +95,7 @@ SetClientEncoding(int encoding, bool doit)
|
||||
{
|
||||
ClientEncoding = &pg_enc2name_tbl[encoding];
|
||||
|
||||
if(ToServerConvPorc != NULL)
|
||||
if (ToServerConvPorc != NULL)
|
||||
{
|
||||
if (ToServerConvPorc->fn_extra)
|
||||
pfree(ToServerConvPorc->fn_extra);
|
||||
@@ -102,7 +103,7 @@ SetClientEncoding(int encoding, bool doit)
|
||||
}
|
||||
ToServerConvPorc = to_server;
|
||||
|
||||
if(ToClientConvPorc != NULL)
|
||||
if (ToClientConvPorc != NULL)
|
||||
{
|
||||
if (ToClientConvPorc->fn_extra)
|
||||
pfree(ToClientConvPorc->fn_extra);
|
||||
@@ -152,11 +153,11 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
int src_encoding, int dest_encoding)
|
||||
{
|
||||
unsigned char *result;
|
||||
Oid proc;
|
||||
Oid proc;
|
||||
|
||||
if (!IsTransactionState())
|
||||
return src;
|
||||
|
||||
|
||||
if (src_encoding == dest_encoding)
|
||||
return src;
|
||||
|
||||
@@ -171,13 +172,14 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
return src;
|
||||
}
|
||||
|
||||
/* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise
|
||||
* we are going into inifinite loop! So we have to make sure that
|
||||
* the function exists before calling OidFunctionCall.
|
||||
/*
|
||||
* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise we
|
||||
* are going into inifinite loop! So we have to make sure that the
|
||||
* function exists before calling OidFunctionCall.
|
||||
*/
|
||||
if (!SearchSysCacheExists(PROCOID,
|
||||
ObjectIdGetDatum(proc),
|
||||
0, 0, 0))
|
||||
ObjectIdGetDatum(proc),
|
||||
0, 0, 0))
|
||||
{
|
||||
elog(LOG, "default conversion proc %u for %s to %s not found in pg_proc",
|
||||
proc,
|
||||
@@ -204,17 +206,17 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
Datum
|
||||
pg_convert(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum string = PG_GETARG_DATUM(0);
|
||||
Datum dest_encoding_name = PG_GETARG_DATUM(1);
|
||||
Datum src_encoding_name = DirectFunctionCall1(
|
||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||
Datum result;
|
||||
Datum string = PG_GETARG_DATUM(0);
|
||||
Datum dest_encoding_name = PG_GETARG_DATUM(1);
|
||||
Datum src_encoding_name = DirectFunctionCall1(
|
||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||
Datum result;
|
||||
|
||||
result = DirectFunctionCall3(
|
||||
pg_convert2, string, src_encoding_name, dest_encoding_name);
|
||||
pg_convert2, string, src_encoding_name, dest_encoding_name);
|
||||
|
||||
/* free memory allocated by namein */
|
||||
pfree((void *)src_encoding_name);
|
||||
pfree((void *) src_encoding_name);
|
||||
|
||||
PG_RETURN_TEXT_P(result);
|
||||
}
|
||||
@@ -235,7 +237,7 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
unsigned char *result;
|
||||
text *retval;
|
||||
unsigned char *str;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if (src_encoding < 0)
|
||||
elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
|
||||
@@ -252,9 +254,11 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
if (result == NULL)
|
||||
elog(ERROR, "Encoding conversion failed");
|
||||
|
||||
/* build text data type structre. we cannot use textin() here,
|
||||
since textin assumes that input string encoding is same as
|
||||
database encoding. */
|
||||
/*
|
||||
* build text data type structre. we cannot use textin() here, since
|
||||
* textin assumes that input string encoding is same as database
|
||||
* encoding.
|
||||
*/
|
||||
len = strlen(result) + VARHDRSZ;
|
||||
retval = palloc(len);
|
||||
VARATT_SIZEP(retval) = len;
|
||||
@@ -262,7 +266,7 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
|
||||
if (result != str)
|
||||
pfree(result);
|
||||
pfree(str);
|
||||
pfree(str);
|
||||
|
||||
/* free memory if allocated by the toaster */
|
||||
PG_FREE_IF_COPY(string, 0);
|
||||
@@ -301,18 +305,19 @@ pg_server_to_client(unsigned char *s, int len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform default encoding conversion using cached FmgrInfo. Since
|
||||
* this function does not access database at all, it is safe to call
|
||||
* outside transactions. Explicit setting client encoding required
|
||||
* before calling this function. Otherwise no conversion is
|
||||
* performed.
|
||||
* Perform default encoding conversion using cached FmgrInfo. Since
|
||||
* this function does not access database at all, it is safe to call
|
||||
* outside transactions. Explicit setting client encoding required
|
||||
* before calling this function. Otherwise no conversion is
|
||||
* performed.
|
||||
*/
|
||||
static unsigned char *
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server)
|
||||
{
|
||||
unsigned char *result;
|
||||
int src_encoding, dest_encoding;
|
||||
FmgrInfo *flinfo;
|
||||
int src_encoding,
|
||||
dest_encoding;
|
||||
FmgrInfo *flinfo;
|
||||
|
||||
if (is_client_to_server)
|
||||
{
|
||||
@@ -376,7 +381,7 @@ pg_mbstrlen(const unsigned char *mbstr)
|
||||
|
||||
/* optimization for single byte encoding */
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
return strlen((char *)mbstr);
|
||||
return strlen((char *) mbstr);
|
||||
|
||||
while (*mbstr)
|
||||
{
|
||||
@@ -506,9 +511,9 @@ pg_client_encoding(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
static int
|
||||
cliplen(const unsigned char *str, int len, int limit)
|
||||
cliplen(const unsigned char *str, int len, int limit)
|
||||
{
|
||||
int l = 0;
|
||||
int l = 0;
|
||||
const unsigned char *s;
|
||||
|
||||
for (s = str; *s; s++, l++)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* conversion functions between pg_wchar and multibyte streams.
|
||||
* Tatsuo Ishii
|
||||
* $Id: wchar.c,v 1.29 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: wchar.c,v 1.30 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
* WIN1250 client encoding updated by Pavel Behal
|
||||
*
|
||||
@@ -511,30 +511,31 @@ pg_uhc_mblen(const unsigned char *s)
|
||||
}
|
||||
|
||||
/*
|
||||
* * GB18030
|
||||
* * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp>
|
||||
* */
|
||||
* * GB18030
|
||||
* * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp>
|
||||
* */
|
||||
static int
|
||||
pg_gb18030_mblen(const unsigned char *s)
|
||||
{
|
||||
int len;
|
||||
if (*s <= 0x7f)
|
||||
{ /* ASCII */
|
||||
len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((*(s+1) >= 0x40 && *(s+1) <= 0x7e)|| (*(s+1) >= 0x80 && *(s+1) <= 0xfe))
|
||||
len = 2;
|
||||
else if(*(s+1) >= 0x30 && *(s+1) <= 0x39)
|
||||
len = 4;
|
||||
else
|
||||
len = 2;
|
||||
}
|
||||
return (len);
|
||||
int len;
|
||||
|
||||
if (*s <= 0x7f)
|
||||
{ /* ASCII */
|
||||
len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) || (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
|
||||
len = 2;
|
||||
else if (*(s + 1) >= 0x30 && *(s + 1) <= 0x39)
|
||||
len = 4;
|
||||
else
|
||||
len = 2;
|
||||
}
|
||||
return (len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
pg_wchar_tbl pg_wchar_table[] = {
|
||||
{pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
|
||||
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
|
||||
@@ -543,7 +544,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
|
||||
{pg_johab2wchar_with_len, pg_johab_mblen, 3}, /* 5; PG_JOHAB */
|
||||
{pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 6; PG_UNICODE */
|
||||
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */
|
||||
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN1 */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN2 */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN3 */
|
||||
@@ -569,7 +570,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{0, pg_gbk_mblen, 2}, /* 30; PG_GBK */
|
||||
{0, pg_uhc_mblen, 2}, /* 31; PG_UHC */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 32; PG_WIN1250 */
|
||||
{0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */
|
||||
{0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */
|
||||
};
|
||||
|
||||
/* returns the byte length of a word for mule internal code */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.52 2002/07/20 05:16:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.53 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -223,7 +223,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
|
||||
*db_id = HeapTupleGetOid(&tup);
|
||||
pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ;
|
||||
if (pathlen < 0)
|
||||
pathlen = 0; /* pure paranoia */
|
||||
pathlen = 0; /* pure paranoia */
|
||||
if (pathlen >= MAXPGPATH)
|
||||
pathlen = MAXPGPATH - 1; /* more paranoia */
|
||||
strncpy(path, VARDATA(&(tup_db->datpath)), pathlen);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
* to contain some useful information. Mechanism differs wildly across
|
||||
* platforms.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.12 2001/12/21 15:22:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.13 2002/09/04 20:31:33 momjian Exp $
|
||||
*
|
||||
* Copyright 2000 by PostgreSQL Global Development Group
|
||||
* various details abducted from various places
|
||||
@@ -265,7 +265,7 @@ set_ps_display(const char *activity)
|
||||
|
||||
#ifdef PS_USE_CLOBBER_ARGV
|
||||
{
|
||||
int buflen;
|
||||
int buflen;
|
||||
|
||||
/* pad unused memory */
|
||||
buflen = strlen(ps_buffer);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.47 2002/08/12 00:36:12 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.48 2002/09/04 20:31:33 momjian Exp $
|
||||
*
|
||||
* NOTE:
|
||||
* This is a new (Feb. 05, 1999) implementation of the allocation set
|
||||
@@ -206,6 +206,7 @@ static void AllocSetReset(MemoryContext context);
|
||||
static void AllocSetDelete(MemoryContext context);
|
||||
static Size AllocSetGetChunkSpace(MemoryContext context, void *pointer);
|
||||
static void AllocSetStats(MemoryContext context);
|
||||
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
static void AllocSetCheck(MemoryContext context);
|
||||
#endif
|
||||
@@ -223,7 +224,7 @@ static MemoryContextMethods AllocSetMethods = {
|
||||
AllocSetGetChunkSpace,
|
||||
AllocSetStats
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
, AllocSetCheck
|
||||
,AllocSetCheck
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.26 2002/08/24 15:00:46 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.27 2002/09/04 20:31:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1854,8 +1854,8 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b)
|
||||
* otherwise the sort algorithm wouldn't have checked whether one must
|
||||
* appear before the other.
|
||||
*
|
||||
* Some rather brain-dead implementations of qsort will sometimes
|
||||
* call the comparison routine to compare a value to itself. (At this
|
||||
* Some rather brain-dead implementations of qsort will sometimes call
|
||||
* the comparison routine to compare a value to itself. (At this
|
||||
* writing only QNX 4 is known to do such silly things.) Don't raise
|
||||
* a bogus error in that case.
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* NOTE: all the HeapTupleSatisfies routines will update the tuple's
|
||||
* "hint" status bits if we see that the inserting or deleting transaction
|
||||
* has now committed or aborted. The caller is responsible for noticing any
|
||||
* change in t_infomask and scheduling a disk write if so. Note that the
|
||||
* change in t_infomask and scheduling a disk write if so. Note that the
|
||||
* caller must hold at least a shared buffer context lock on the buffer
|
||||
* containing the tuple. (VACUUM FULL assumes it's sufficient to have
|
||||
* exclusive lock on the containing relation, instead.)
|
||||
@@ -16,7 +16,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.59 2002/09/02 01:05:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.60 2002/09/04 20:31:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -309,7 +309,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
|
||||
* This is a simplified version that only checks for VACUUM moving conditions.
|
||||
* It's appropriate for TOAST usage because TOAST really doesn't want to do
|
||||
* its own time qual checks; if you can see the main table row that contains
|
||||
* a TOAST reference, you should be able to see the TOASTed value. However,
|
||||
* a TOAST reference, you should be able to see the TOASTed value. However,
|
||||
* vacuuming a TOAST table is independent of the main table, and in case such
|
||||
* a vacuum fails partway through, we'd better do this much checking.
|
||||
*
|
||||
@@ -412,7 +412,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
return HeapTupleInvisible; /* inserted after scan
|
||||
* started */
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
|
||||
return HeapTupleMayBeUpdated;
|
||||
|
||||
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
|
||||
@@ -430,7 +430,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
|
||||
{
|
||||
if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */
|
||||
return HeapTupleInvisible;
|
||||
}
|
||||
else
|
||||
@@ -439,7 +439,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
|
||||
|
||||
/* by here, the inserting transaction has committed */
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
|
||||
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
|
||||
return HeapTupleMayBeUpdated;
|
||||
|
||||
if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
@@ -701,7 +701,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
* when...
|
||||
*/
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
snapshot->xmin))
|
||||
snapshot->xmin))
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
@@ -712,7 +712,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
for (i = 0; i < snapshot->xcnt; i++)
|
||||
{
|
||||
if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
snapshot->xip[i]))
|
||||
snapshot->xip[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -752,7 +752,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
|
||||
uint32 i;
|
||||
|
||||
if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmax(tuple),
|
||||
snapshot->xmax))
|
||||
snapshot->xmax))
|
||||
return true;
|
||||
for (i = 0; i < snapshot->xcnt; i++)
|
||||
{
|
||||
@@ -867,7 +867,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
return HEAPTUPLE_LIVE;
|
||||
if (TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
|
||||
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
|
||||
else /* it's either aborted or crashed */
|
||||
else
|
||||
/* it's either aborted or crashed */
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;
|
||||
}
|
||||
return HEAPTUPLE_LIVE;
|
||||
@@ -902,7 +903,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
|
||||
*/
|
||||
|
||||
if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple),
|
||||
HeapTupleHeaderGetXmax(tuple)))
|
||||
HeapTupleHeaderGetXmax(tuple)))
|
||||
{
|
||||
/*
|
||||
* inserter also deleted it, so it was never visible to anyone
|
||||
|
||||
Reference in New Issue
Block a user