diff options
| author | Tom Lane | 2004-06-16 01:27:00 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-06-16 01:27:00 +0000 |
| commit | d70a42e6424e1531355ce9d1d1aa59e329b3c0e6 (patch) | |
| tree | a562d86d0f5128916ecfd213906996a12940335e /src/include | |
| parent | 8e7349b73806a993f72976bbf7dfaa9b1cf270b8 (diff) | |
Represent type-specific length coercion functions as pg_cast entries,
eliminating the former hard-wired convention about their names. Allow
pg_cast entries to represent both type coercion and length coercion in
a single step --- this is represented by a function that takes an
extra typmod argument, just like a length coercion function. This
nicely merges the type and length coercion mechanisms into something
at least a little cleaner than we had before. Make use of the single-
coercion-step behavior to fix integer-to-bit coercion so that coercing
to bit(n) yields the rightmost n bits of the integer instead of the
leftmost n bits. This should fix recurrent complaints about the odd
behavior of this coercion. Clean up the documentation of the bit string
functions, and try to put it where people might actually find it.
Also, get rid of the unreliable heuristics in ruleutils.c about whether
to display nested coercion steps; instead require parse_coerce.c to
label them properly in the first place.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_cast.h | 21 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.h | 17 | ||||
| -rw-r--r-- | src/include/parser/parse_coerce.h | 8 | ||||
| -rw-r--r-- | src/include/utils/array.h | 5 |
5 files changed, 38 insertions, 17 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 2bebe32b615..6fd25b54f7a 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.235 2004/06/13 21:57:25 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.236 2004/06/16 01:26:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200406131 +#define CATALOG_VERSION_NO 200406151 #endif diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 549fa5f80db..069f2e8e60c 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -4,10 +4,13 @@ * definition of the system "type casts" relation (pg_cast) * along with the relation's initial contents. * + * As of Postgres 7.5, pg_cast describes not only type coercion functions + * but also length coercion functions. + * * * Copyright (c) 2002-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.11 2004/03/15 01:13:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.12 2004/06/16 01:26:49 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -43,7 +46,7 @@ typedef enum CoercionCodes * expression */ COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of * assignment */ - COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */ + COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */ } CoercionCodes; @@ -361,4 +364,18 @@ DATA(insert ( 1042 1266 938 e )); DATA(insert ( 1700 1042 1688 a )); DATA(insert ( 1042 1700 1686 e )); +/* + * Length-coercion functions + */ +DATA(insert ( 1042 1042 668 i )); +DATA(insert ( 1043 1043 669 i )); +DATA(insert ( 1083 1083 1968 i )); +DATA(insert ( 1114 1114 1961 i )); +DATA(insert ( 1184 1184 1967 i )); +DATA(insert ( 1186 1186 1200 i )); +DATA(insert ( 1266 1266 1969 i )); +DATA(insert ( 1560 1560 1685 i )); +DATA(insert ( 1562 1562 1687 i )); +DATA(insert ( 1700 1700 1703 i )); + #endif /* PG_CAST_H */ diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index b7fad1fca52..ecaf82efab1 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.337 2004/06/13 21:57:26 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.338 2004/06/16 01:26:49 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -1028,8 +1028,8 @@ DATA(insert OID = 379 ( array_prepend PGNSP PGUID 12 f f t f i 2 2277 "2283 DESCR("prepend element onto front of array"); DATA(insert OID = 383 ( array_cat PGNSP PGUID 12 f f t f i 2 2277 "2277 2277" _null_ array_cat - _null_ )); DESCR("concatenate two arrays"); -DATA(insert OID = 384 ( array_coerce PGNSP PGUID 12 f f t f i 1 2277 "2277" _null_ array_type_coerce - _null_ )); -DESCR("coerce array type to another array type"); +DATA(insert OID = 384 ( array_coerce PGNSP PGUID 12 f f t f s 1 2277 "2277" _null_ array_type_coerce - _null_ )); +DESCR("coerce array to another array type"); DATA(insert OID = 394 ( string_to_array PGNSP PGUID 12 f f t f i 2 1009 "25 25" _null_ text_to_array - _null_ )); DESCR("split delimited text into text[]"); DATA(insert OID = 395 ( array_to_string PGNSP PGUID 12 f f t f i 2 25 "2277 25" _null_ array_to_text - _null_ )); @@ -1587,8 +1587,8 @@ DESCR("convert int8 to text"); DATA(insert OID = 1290 ( int8 PGNSP PGUID 12 f f t f i 1 20 "25" _null_ text_int8 - _null_ )); DESCR("convert text to int8"); -DATA(insert OID = 1291 ( array_length_coerce PGNSP PGUID 12 f f t f i 3 2277 "2277 23 16" _null_ array_length_coerce - _null_ )); -DESCR("adjust any array to element typmod length"); +DATA(insert OID = 1291 ( array_length_coerce PGNSP PGUID 12 f f t f s 3 2277 "2277 23 16" _null_ array_length_coerce - _null_ )); +DESCR("adjust any array to new element typmod"); DATA(insert OID = 1292 ( tideq PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ tideq - _null_ )); DESCR("equal"); @@ -1722,6 +1722,9 @@ DESCR("convert time to interval"); DATA(insert OID = 1372 ( char_length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ bpcharlen - _null_ )); DESCR("character length"); +DATA(insert OID = 1373 ( array_type_length_coerce PGNSP PGUID 12 f f t f s 3 2277 "2277 23 16" _null_ array_type_length_coerce - _null_ )); +DESCR("coerce array to another type and adjust element typmod"); + DATA(insert OID = 1374 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ textoctetlen - _null_ )); DESCR("octet length"); DATA(insert OID = 1375 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ bpcharoctetlen - _null_ )); @@ -2298,7 +2301,7 @@ DATA(insert OID = 1681 ( length PGNSP PGUID 12 f f t f i 1 23 "1560" _null_ b DESCR("bitstring length"); DATA(insert OID = 1682 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "1560" _null_ bitoctetlength - _null_ )); DESCR("octet length"); -DATA(insert OID = 1683 ( bit PGNSP PGUID 12 f f t f i 1 1560 "23" _null_ bitfromint4 - _null_ )); +DATA(insert OID = 1683 ( bit PGNSP PGUID 12 f f t f i 2 1560 "23 23" _null_ bitfromint4 - _null_ )); DESCR("int4 to bitstring"); DATA(insert OID = 1684 ( int4 PGNSP PGUID 12 f f t f i 1 23 "1560" _null_ bittoint4 - _null_ )); DESCR("bitstring to int4"); @@ -2968,7 +2971,7 @@ DESCR("extracts text matching regular expression"); DATA(insert OID = 2074 ( substring PGNSP PGUID 14 f f t f i 3 25 "25 25 25" _null_ "select pg_catalog.substring($1, pg_catalog.similar_escape($2, $3))" - _null_ )); DESCR("extracts text matching SQL99 regular expression"); -DATA(insert OID = 2075 ( bit PGNSP PGUID 12 f f t f i 1 1560 "20" _null_ bitfromint8 - _null_ )); +DATA(insert OID = 2075 ( bit PGNSP PGUID 12 f f t f i 2 1560 "20 23" _null_ bitfromint8 - _null_ )); DESCR("int8 to bitstring"); DATA(insert OID = 2076 ( int8 PGNSP PGUID 12 f f t f i 1 20 "1560" _null_ bittoint8 - _null_ )); DESCR("bitstring to int8"); diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index 8700200b51b..c1c83d514d9 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.56 2003/11/29 22:41:09 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.57 2004/06/16 01:26:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -47,10 +47,10 @@ extern Node *coerce_to_target_type(ParseState *pstate, extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, CoercionContext ccontext); extern Node *coerce_type(ParseState *pstate, Node *node, - Oid inputTypeId, Oid targetTypeId, + Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat); extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId, - CoercionForm cformat); + CoercionForm cformat, bool hideInputCoercion); extern Node *coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName); @@ -76,6 +76,6 @@ extern Oid resolve_generic_type(Oid declared_type, extern bool find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid); -extern Oid find_typmod_coercion_function(Oid typeId, int *nargs); +extern Oid find_typmod_coercion_function(Oid typeId); #endif /* PARSE_COERCE_H */ diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 596cf79d4d3..3114aefe10b 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.47 2004/06/06 00:41:28 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.48 2004/06/16 01:26:55 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -116,7 +116,6 @@ extern Datum array_in(PG_FUNCTION_ARGS); extern Datum array_out(PG_FUNCTION_ARGS); extern Datum array_recv(PG_FUNCTION_ARGS); extern Datum array_send(PG_FUNCTION_ARGS); -extern Datum array_length_coerce(PG_FUNCTION_ARGS); extern Datum array_eq(PG_FUNCTION_ARGS); extern Datum array_ne(PG_FUNCTION_ARGS); extern Datum array_lt(PG_FUNCTION_ARGS); @@ -128,6 +127,8 @@ extern Datum array_dims(PG_FUNCTION_ARGS); extern Datum array_lower(PG_FUNCTION_ARGS); extern Datum array_upper(PG_FUNCTION_ARGS); extern Datum array_type_coerce(PG_FUNCTION_ARGS); +extern Datum array_type_length_coerce(PG_FUNCTION_ARGS); +extern Datum array_length_coerce(PG_FUNCTION_ARGS); extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraylen, int elmlen, bool elmbyval, char elmalign, |
