summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-09-18 21:35:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-09-18 21:35:25 +0000
commitb26dfb95222fddd25322bdddf3a5a58d3392d8b1 (patch)
tree757cf0bafab985d38a5c84d3afebe5edd34c4f27 /src/include
parentcc70ba2e4daa78ba99619770e19beb06de3dfd1c (diff)
downloadpostgresql-b26dfb95222fddd25322bdddf3a5a58d3392d8b1.tar.gz
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in operator/function resolution. Introduce a well-defined promotion hierarchy for numeric datatypes (int2->int4->int8->numeric->float4->float8). Change make_const to initially label numeric literals as int4, int8, or numeric (never float8 anymore). Explicitly mark Func and RelabelType nodes to indicate whether they came from a function call, explicit cast, or implicit cast; use this to do reverse-listing more accurately and without so many heuristics. Explicit casts to char, varchar, bit, varbit will truncate or pad without raising an error (the pre-7.2 behavior), while assigning to a column without any explicit cast will still raise an error for wrong-length data like 7.3. This more nearly follows the SQL spec than 7.2 behavior (we should be reporting a 'completion condition' in the explicit-cast cases, but we have no mechanism for that, so just do silent truncation). Fix some problems with enforcement of typmod for array elements; it didn't work at all in 'UPDATE ... SET array[n] = foo', for example. Provide a generalized array_length_coerce() function to replace the specialized per-array-type functions that used to be needed (and were missing for NUMERIC as well as all the datetime types). Add missing conversions int8<->float4, text<->numeric, oid<->int8. initdb forced.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_cast.h422
-rw-r--r--src/include/catalog/pg_operator.h24
-rw-r--r--src/include/catalog/pg_proc.h69
-rw-r--r--src/include/nodes/makefuncs.h6
-rw-r--r--src/include/nodes/parsenodes.h4
-rw-r--r--src/include/nodes/primnodes.h28
-rw-r--r--src/include/parser/parse_coerce.h32
-rw-r--r--src/include/parser/parse_node.h3
-rw-r--r--src/include/parser/parse_target.h8
-rw-r--r--src/include/utils/array.h3
-rw-r--r--src/include/utils/builtins.h6
-rw-r--r--src/include/utils/int8.h10
-rw-r--r--src/include/utils/lsyscache.h3
-rw-r--r--src/include/utils/varbit.h4
15 files changed, 349 insertions, 277 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 817ef79bca..21a7732c5f 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.158 2002/09/02 06:24:15 momjian Exp $
+ * $Id: catversion.h,v 1.159 2002/09/18 21:35:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200209021
+#define CATALOG_VERSION_NO 200209181
#endif
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 31763358d1..48ff930baf 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -7,7 +7,7 @@
*
* Copyright (c) 2002, PostgreSQL Global Development Group
*
- * $Id: pg_cast.h,v 1.3 2002/09/04 20:31:37 momjian Exp $
+ * $Id: pg_cast.h,v 1.4 2002/09/18 21:35:23 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -22,17 +22,38 @@ CATALOG(pg_cast)
{
Oid castsource; /* source datatype for cast */
Oid casttarget; /* destination datatype for cast */
- Oid castfunc; /* 0 = binary compatible */
- bool castimplicit; /* allow implicit casting? */
+ Oid castfunc; /* cast function; 0 = binary coercible */
+ char castcontext; /* contexts in which cast can be used */
} FormData_pg_cast;
typedef FormData_pg_cast *Form_pg_cast;
+/*
+ * The allowable values for pg_cast.castcontext are specified by this enum.
+ * Since castcontext is stored as a "char", we use ASCII codes for human
+ * convenience in reading the table. Note that internally to the backend,
+ * these values are converted to the CoercionContext enum (see primnodes.h),
+ * which is defined to sort in a convenient order; the ASCII codes don't
+ * have to sort in any special order.
+ */
+
+typedef enum CoercionCodes
+{
+ COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */
+ COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */
+ COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */
+} CoercionCodes;
+
+
+/* ----------------
+ * compiler constants for pg_cast
+ * ----------------
+ */
#define Natts_pg_cast 4
#define Anum_pg_cast_castsource 1
#define Anum_pg_cast_casttarget 2
#define Anum_pg_cast_castfunc 3
-#define Anum_pg_cast_castimplicit 4
+#define Anum_pg_cast_castcontext 4
/* ----------------
* initial contents of pg_cast
@@ -40,197 +61,216 @@ typedef FormData_pg_cast *Form_pg_cast;
*/
/*
- * binary compatible casts
+ * Numeric category: implicit casts are allowed in the direction
+ * int2->int4->int8->numeric->float4->float8, while casts in the
+ * reverse direction are assignment-only.
*/
-DATA(insert ( 25 1042 0 t ));
-DATA(insert ( 25 1043 0 t ));
-DATA(insert ( 1042 25 0 t ));
-DATA(insert ( 1042 1043 0 t ));
-DATA(insert ( 1043 25 0 t ));
-DATA(insert ( 1043 1042 0 t ));
-
-DATA(insert ( 23 24 0 t ));
-DATA(insert ( 23 26 0 t ));
-DATA(insert ( 23 2202 0 t ));
-DATA(insert ( 23 2203 0 t ));
-DATA(insert ( 23 2204 0 t ));
-DATA(insert ( 23 2205 0 t ));
-DATA(insert ( 23 2206 0 t ));
-DATA(insert ( 24 23 0 t ));
-DATA(insert ( 24 26 0 t ));
-DATA(insert ( 24 2202 0 t ));
-DATA(insert ( 24 2203 0 t ));
-DATA(insert ( 24 2204 0 t ));
-DATA(insert ( 24 2205 0 t ));
-DATA(insert ( 24 2206 0 t ));
-DATA(insert ( 26 23 0 t ));
-DATA(insert ( 26 24 0 t ));
-DATA(insert ( 26 2202 0 t ));
-DATA(insert ( 26 2203 0 t ));
-DATA(insert ( 26 2204 0 t ));
-DATA(insert ( 26 2205 0 t ));
-DATA(insert ( 26 2206 0 t ));
-DATA(insert ( 2202 23 0 t ));
-DATA(insert ( 2202 24 0 t ));
-DATA(insert ( 2202 26 0 t ));
-DATA(insert ( 2202 2203 0 t ));
-DATA(insert ( 2202 2204 0 t ));
-DATA(insert ( 2202 2205 0 t ));
-DATA(insert ( 2202 2206 0 t ));
-DATA(insert ( 2203 23 0 t ));
-DATA(insert ( 2203 24 0 t ));
-DATA(insert ( 2203 26 0 t ));
-DATA(insert ( 2203 2202 0 t ));
-DATA(insert ( 2203 2204 0 t ));
-DATA(insert ( 2203 2205 0 t ));
-DATA(insert ( 2203 2206 0 t ));
-DATA(insert ( 2204 23 0 t ));
-DATA(insert ( 2204 24 0 t ));
-DATA(insert ( 2204 26 0 t ));
-DATA(insert ( 2204 2202 0 t ));
-DATA(insert ( 2204 2203 0 t ));
-DATA(insert ( 2204 2205 0 t ));
-DATA(insert ( 2204 2206 0 t ));
-DATA(insert ( 2205 23 0 t ));
-DATA(insert ( 2205 24 0 t ));
-DATA(insert ( 2205 26 0 t ));
-DATA(insert ( 2205 2202 0 t ));
-DATA(insert ( 2205 2203 0 t ));
-DATA(insert ( 2205 2204 0 t ));
-DATA(insert ( 2205 2206 0 t ));
-DATA(insert ( 2206 23 0 t ));
-DATA(insert ( 2206 24 0 t ));
-DATA(insert ( 2206 26 0 t ));
-DATA(insert ( 2206 2202 0 t ));
-DATA(insert ( 2206 2203 0 t ));
-DATA(insert ( 2206 2204 0 t ));
-DATA(insert ( 2206 2205 0 t ));
-
-DATA(insert ( 23 702 0 t ));
-DATA(insert ( 702 23 0 t ));
-
-DATA(insert ( 23 703 0 t ));
-DATA(insert ( 703 23 0 t ));
-
-DATA(insert ( 650 869 0 t ));
-DATA(insert ( 869 650 0 t ));
-
-DATA(insert ( 1560 1562 0 t ));
-DATA(insert ( 1562 1560 0 t ));
+DATA(insert ( 20 21 714 a ));
+DATA(insert ( 20 23 480 a ));
+DATA(insert ( 20 700 652 i ));
+DATA(insert ( 20 701 482 i ));
+DATA(insert ( 20 1700 1781 i ));
+DATA(insert ( 21 20 754 i ));
+DATA(insert ( 21 23 313 i ));
+DATA(insert ( 21 700 236 i ));
+DATA(insert ( 21 701 235 i ));
+DATA(insert ( 21 1700 1782 i ));
+DATA(insert ( 23 20 481 i ));
+DATA(insert ( 23 21 314 a ));
+DATA(insert ( 23 700 318 i ));
+DATA(insert ( 23 701 316 i ));
+DATA(insert ( 23 1700 1740 i ));
+DATA(insert ( 700 20 653 a ));
+DATA(insert ( 700 21 238 a ));
+DATA(insert ( 700 23 319 a ));
+DATA(insert ( 700 701 311 i ));
+DATA(insert ( 700 1700 1742 a ));
+DATA(insert ( 701 20 483 a ));
+DATA(insert ( 701 21 237 a ));
+DATA(insert ( 701 23 317 a ));
+DATA(insert ( 701 700 312 a ));
+DATA(insert ( 701 1700 1743 a ));
+DATA(insert ( 1700 20 1779 a ));
+DATA(insert ( 1700 21 1783 a ));
+DATA(insert ( 1700 23 1744 a ));
+DATA(insert ( 1700 700 1745 i ));
+DATA(insert ( 1700 701 1746 i ));
/*
- * regular casts through a function
- *
- * This list can be obtained from the following query as long as the
- * naming convention of the cast functions remains the same:
+ * OID category: allow implicit conversion from any integral type (including
+ * int8, to support OID literals > 2G) to OID, as well as assignment coercion
+ * from OID to int4 or int8. Similarly for each OID-alias type. Also allow
+ * implicit coercions between OID and each OID-alias type, as well as
+ * regproc<->regprocedure and regoper<->regoperator. (Other coercions
+ * between alias types must pass through OID.)
+ */
+DATA(insert ( 20 26 1287 i ));
+DATA(insert ( 21 26 313 i ));
+DATA(insert ( 23 26 0 i ));
+DATA(insert ( 26 20 1288 a ));
+DATA(insert ( 26 23 0 a ));
+DATA(insert ( 26 24 0 i ));
+DATA(insert ( 24 26 0 i ));
+DATA(insert ( 20 24 1287 i ));
+DATA(insert ( 21 24 313 i ));
+DATA(insert ( 23 24 0 i ));
+DATA(insert ( 24 20 1288 a ));
+DATA(insert ( 24 23 0 a ));
+DATA(insert ( 24 2202 0 i ));
+DATA(insert ( 2202 24 0 i ));
+DATA(insert ( 26 2202 0 i ));
+DATA(insert ( 2202 26 0 i ));
+DATA(insert ( 20 2202 1287 i ));
+DATA(insert ( 21 2202 313 i ));
+DATA(insert ( 23 2202 0 i ));
+DATA(insert ( 2202 20 1288 a ));
+DATA(insert ( 2202 23 0 a ));
+DATA(insert ( 26 2203 0 i ));
+DATA(insert ( 2203 26 0 i ));
+DATA(insert ( 20 2203 1287 i ));
+DATA(insert ( 21 2203 313 i ));
+DATA(insert ( 23 2203 0 i ));
+DATA(insert ( 2203 20 1288 a ));
+DATA(insert ( 2203 23 0 a ));
+DATA(insert ( 2203 2204 0 i ));
+DATA(insert ( 2204 2203 0 i ));
+DATA(insert ( 26 2204 0 i ));
+DATA(insert ( 2204 26 0 i ));
+DATA(insert ( 20 2204 1287 i ));
+DATA(insert ( 21 2204 313 i ));
+DATA(insert ( 23 2204 0 i ));
+DATA(insert ( 2204 20 1288 a ));
+DATA(insert ( 2204 23 0 a ));
+DATA(insert ( 26 2205 0 i ));
+DATA(insert ( 2205 26 0 i ));
+DATA(insert ( 20 2205 1287 i ));
+DATA(insert ( 21 2205 313 i ));
+DATA(insert ( 23 2205 0 i ));
+DATA(insert ( 2205 20 1288 a ));
+DATA(insert ( 2205 23 0 a ));
+DATA(insert ( 26 2206 0 i ));
+DATA(insert ( 2206 26 0 i ));
+DATA(insert ( 20 2206 1287 i ));
+DATA(insert ( 21 2206 313 i ));
+DATA(insert ( 23 2206 0 i ));
+DATA(insert ( 2206 20 1288 a ));
+DATA(insert ( 2206 23 0 a ));
+
+/*
+ * String category: this needs to be tightened up
+ */
+DATA(insert ( 25 1042 0 i ));
+DATA(insert ( 25 1043 0 i ));
+DATA(insert ( 1042 25 0 i ));
+DATA(insert ( 1042 1043 0 i ));
+DATA(insert ( 1043 25 0 i ));
+DATA(insert ( 1043 1042 0 i ));
+DATA(insert ( 18 25 946 i ));
+DATA(insert ( 18 1042 860 i ));
+DATA(insert ( 19 25 406 i ));
+DATA(insert ( 19 1042 408 i ));
+DATA(insert ( 19 1043 1401 i ));
+DATA(insert ( 25 18 944 a ));
+DATA(insert ( 25 19 407 i ));
+DATA(insert ( 1042 19 409 i ));
+DATA(insert ( 1043 19 1400 i ));
+
+/*
+ * Datetime category
+ */
+DATA(insert ( 702 1082 1179 a ));
+DATA(insert ( 702 1083 1364 a ));
+DATA(insert ( 702 1114 2023 i ));
+DATA(insert ( 702 1184 1173 i ));
+DATA(insert ( 703 1186 1177 i ));
+DATA(insert ( 1082 1114 2024 i ));
+DATA(insert ( 1082 1184 1174 i ));
+DATA(insert ( 1083 1186 1370 i ));
+DATA(insert ( 1083 1266 2047 i ));
+DATA(insert ( 1114 702 2030 a ));
+DATA(insert ( 1114 1082 2029 a ));
+DATA(insert ( 1114 1083 1316 a ));
+DATA(insert ( 1114 1184 2028 i ));
+DATA(insert ( 1184 702 1180 a ));
+DATA(insert ( 1184 1082 1178 a ));
+DATA(insert ( 1184 1083 2019 a ));
+DATA(insert ( 1184 1114 2027 a ));
+DATA(insert ( 1184 1266 1388 a ));
+DATA(insert ( 1186 703 1194 a ));
+DATA(insert ( 1186 1083 1419 a ));
+DATA(insert ( 1266 1083 2046 a ));
+/* Cross-category casts between int4 and abstime, reltime */
+DATA(insert ( 23 702 0 e ));
+DATA(insert ( 702 23 0 e ));
+DATA(insert ( 23 703 0 e ));
+DATA(insert ( 703 23 0 e ));
+
+/*
+ * Geometric category
+ */
+DATA(insert ( 601 600 1532 e ));
+DATA(insert ( 602 600 1533 e ));
+DATA(insert ( 602 604 1449 a ));
+DATA(insert ( 603 600 1534 e ));
+DATA(insert ( 603 601 1541 e ));
+DATA(insert ( 603 604 1448 a ));
+DATA(insert ( 603 718 1479 e ));
+DATA(insert ( 604 600 1540 e ));
+DATA(insert ( 604 602 1447 a ));
+DATA(insert ( 604 603 1446 e ));
+DATA(insert ( 604 718 1474 e ));
+DATA(insert ( 718 600 1416 e ));
+DATA(insert ( 718 603 1480 e ));
+DATA(insert ( 718 604 1544 e ));
+
+/*
+ * INET category
+ */
+DATA(insert ( 650 869 0 i ));
+DATA(insert ( 869 650 0 i ));
+
+/*
+ * BitString category
+ */
+DATA(insert ( 1560 1562 0 i ));
+DATA(insert ( 1562 1560 0 i ));
+
+/*
+ * Cross-category casts to and from TEXT
*
- * select p.proargtypes[0] as source, p.prorettype as target, p.oid as func,
- * p.proimplicit as implicit
- * from pg_proc p, pg_type t where p.pronargs=1 and p.proname = t.typname
- * and p.prorettype = t.oid order by 1, 2;
+ * For historical reasons, most casts to TEXT are implicit. This is BAD
+ * and should be reined in.
*/
-DATA(insert ( 18 25 946 t ));
-DATA(insert ( 18 1042 860 t ));
-DATA(insert ( 19 25 406 t ));
-DATA(insert ( 19 1042 408 t ));
-DATA(insert ( 19 1043 1401 t ));
-DATA(insert ( 20 21 714 t ));
-DATA(insert ( 20 23 480 t ));
-DATA(insert ( 20 25 1288 t ));
-DATA(insert ( 20 701 482 t ));
-DATA(insert ( 20 1043 1623 f ));
-DATA(insert ( 20 1700 1781 t ));
-DATA(insert ( 21 20 754 t ));
-DATA(insert ( 21 23 313 t ));
-DATA(insert ( 21 25 113 t ));
-DATA(insert ( 21 700 236 t ));
-DATA(insert ( 21 701 235 t ));
-DATA(insert ( 21 1700 1782 t ));
-DATA(insert ( 23 20 481 t ));
-DATA(insert ( 23 21 314 t ));
-DATA(insert ( 23 25 112 t ));
-DATA(insert ( 23 700 318 t ));
-DATA(insert ( 23 701 316 t ));
-DATA(insert ( 23 1043 1619 f ));
-DATA(insert ( 23 1700 1740 t ));
-DATA(insert ( 25 18 944 t ));
-DATA(insert ( 25 19 407 t ));
-DATA(insert ( 25 20 1289 f ));
-DATA(insert ( 25 21 818 f ));
-DATA(insert ( 25 23 819 f ));
-DATA(insert ( 25 26 817 f ));
-DATA(insert ( 25 650 1714 f ));
-DATA(insert ( 25 700 839 f ));
-DATA(insert ( 25 701 838 f ));
-DATA(insert ( 25 829 767 f ));
-DATA(insert ( 25 869 1713 f ));
-DATA(insert ( 25 1082 748 f ));
-DATA(insert ( 25 1083 837 f ));
-DATA(insert ( 25 1114 2022 f ));
-DATA(insert ( 25 1184 1191 f ));
-DATA(insert ( 25 1186 1263 f ));
-DATA(insert ( 25 1266 938 f ));
-DATA(insert ( 26 25 114 t ));
-DATA(insert ( 601 600 1532 f ));
-DATA(insert ( 602 600 1533 f ));
-DATA(insert ( 602 604 1449 f ));
-DATA(insert ( 603 600 1534 f ));
-DATA(insert ( 603 601 1541 f ));
-DATA(insert ( 603 604 1448 f ));
-DATA(insert ( 603 718 1479 f ));
-DATA(insert ( 604 600 1540 f ));
-DATA(insert ( 604 602 1447 f ));
-DATA(insert ( 604 603 1446 f ));
-DATA(insert ( 604 718 1474 f ));
-DATA(insert ( 700 21 238 f ));
-DATA(insert ( 700 23 319 f ));
-DATA(insert ( 700 25 841 t ));
-DATA(insert ( 700 701 311 t ));
-DATA(insert ( 700 1700 1742 t ));
-DATA(insert ( 701 20 483 t ));
-DATA(insert ( 701 21 237 f ));
-DATA(insert ( 701 23 317 f ));
-DATA(insert ( 701 25 840 t ));
-DATA(insert ( 701 700 312 t ));
-DATA(insert ( 701 1700 1743 t ));
-DATA(insert ( 702 1082 1179 f ));
-DATA(insert ( 702 1083 1364 f ));
-DATA(insert ( 702 1114 2023 t ));
-DATA(insert ( 702 1184 1173 t ));
-DATA(insert ( 703 1186 1177 t ));
-DATA(insert ( 718 600 1416 f ));
-DATA(insert ( 718 603 1480 f ));
-DATA(insert ( 718 604 1544 f ));
-DATA(insert ( 829 25 752 f ));
-DATA(insert ( 869 25 730 f ));
-DATA(insert ( 1042 19 409 t ));
-DATA(insert ( 1043 19 1400 t ));
-DATA(insert ( 1082 25 749 t ));
-DATA(insert ( 1082 1114 2024 t ));
-DATA(insert ( 1082 1184 1174 t ));
-DATA(insert ( 1083 25 948 t ));
-DATA(insert ( 1083 1186 1370 t ));
-DATA(insert ( 1083 1266 2047 t ));
-DATA(insert ( 1114 25 2034 t ));
-DATA(insert ( 1114 702 2030 f ));
-DATA(insert ( 1114 1082 2029 f ));
-DATA(insert ( 1114 1083 1316 f ));
-DATA(insert ( 1114 1184 2028 t ));
-DATA(insert ( 1184 25 1192 t ));
-DATA(insert ( 1184 702 1180 f ));
-DATA(insert ( 1184 1082 1178 f ));
-DATA(insert ( 1184 1083 2019 f ));
-DATA(insert ( 1184 1114 2027 t ));
-DATA(insert ( 1184 1266 1388 f ));
-DATA(insert ( 1186 25 1193 t ));
-DATA(insert ( 1186 703 1194 f ));
-DATA(insert ( 1186 1083 1419 f ));
-DATA(insert ( 1266 25 939 t ));
-DATA(insert ( 1266 1083 2046 t ));
-DATA(insert ( 1700 20 1779 f ));
-DATA(insert ( 1700 21 1783 f ));
-DATA(insert ( 1700 23 1744 f ));
-DATA(insert ( 1700 700 1745 f ));
-DATA(insert ( 1700 701 1746 f ));
+DATA(insert ( 20 25 1289 i ));
+DATA(insert ( 25 20 1290 e ));
+DATA(insert ( 21 25 113 i ));
+DATA(insert ( 25 21 818 e ));
+DATA(insert ( 23 25 112 i ));
+DATA(insert ( 25 23 819 e ));
+DATA(insert ( 26 25 114 i ));
+DATA(insert ( 25 26 817 e ));
+DATA(insert ( 25 650 1714 e ));
+DATA(insert ( 700 25 841 i ));
+DATA(insert ( 25 700 839 e ));
+DATA(insert ( 701 25 840 i ));
+DATA(insert ( 25 701 838 e ));
+DATA(insert ( 829 25 752 e ));
+DATA(insert ( 25 829 767 e ));
+DATA(insert ( 869 25 730 e ));
+DATA(insert ( 25 869 1713 e ));
+DATA(insert ( 1082 25 749 i ));
+DATA(insert ( 25 1082 748 e ));
+DATA(insert ( 1083 25 948 i ));
+DATA(insert ( 25 1083 837 e ));
+DATA(insert ( 1114 25 2034 i ));
+DATA(insert ( 25 1114 2022 e ));
+DATA(insert ( 1184 25 1192 i ));
+DATA(insert ( 25 1184 1191 e ));
+DATA(insert ( 1186 25 1193 i ));
+DATA(insert ( 25 1186 1263 e ));
+DATA(insert ( 1266 25 939 i ));
+DATA(insert ( 25 1266 938 e ));
+DATA(insert ( 1700 25 1688 i ));
+DATA(insert ( 25 1700 1686 e ));
#endif /* PG_CAST_H */
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index c770150f73..c97003cf43 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_operator.h,v 1.109 2002/09/04 20:31:37 momjian Exp $
+ * $Id: pg_operator.h,v 1.110 2002/09/18 21:35:23 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -526,10 +526,6 @@ DATA(insert OID = 1133 ( ">" PGNSP PGUID b f 701 700 16 1122 1134 0 0 0 0 f
DATA(insert OID = 1134 ( "<=" PGNSP PGUID b f 701 700 16 1125 1133 0 0 0 0 float84le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1135 ( ">=" PGNSP PGUID b f 701 700 16 1124 1132 0 0 0 0 float84ge scalargtsel scalargtjoinsel ));
-/* int4 vs oid equality --- use oid (unsigned) comparison */
-DATA(insert OID = 1136 ( "=" PGNSP PGUID b t 23 26 16 1137 1656 0 0 0 0 oideq eqsel eqjoinsel ));
-DATA(insert OID = 1137 ( "=" PGNSP PGUID b t 26 23 16 1136 1661 0 0 0 0 oideq eqsel eqjoinsel ));
-
DATA(insert OID = 1158 ( "!" PGNSP PGUID r f 21 0 23 0 0 0 0 0 0 int2fac - - ));
DATA(insert OID = 1175 ( "!!" PGNSP PGUID l f 0 21 23 0 0 0 0 0 0 int2fac - - ));
@@ -723,17 +719,13 @@ DATA(insert OID = 1631 ( "~~*" PGNSP PGUID b f 1043 25 16 0 1632 0 0 0 0 tex
#define OID_VARCHAR_ICLIKE_OP 1631
DATA(insert OID = 1632 ( "!~~*" PGNSP PGUID b f 1043 25 16 0 1631 0 0 0 0 texticnlike icnlikesel icnlikejoinsel ));
-/* int4 vs oid comparisons --- use oid (unsigned) comparison */
-DATA(insert OID = 1656 ( "<>" PGNSP PGUID b f 23 26 16 1661 1136 0 0 0 0 oidne neqsel neqjoinsel ));
-DATA(insert OID = 1657 ( "<" PGNSP PGUID b f 23 26 16 1663 1660 0 0 0 0 oidlt scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1658 ( ">" PGNSP PGUID b f 23 26 16 1662 1659 0 0 0 0 oidgt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1659 ( "<=" PGNSP PGUID b f 23 26 16 1665 1658 0 0 0 0 oidle scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1660 ( ">=" PGNSP PGUID b f 23 26 16 1664 1657 0 0 0 0 oidge scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1661 ( "<>" PGNSP PGUID b f 26 23 16 1656 1137 0 0 0 0 oidne neqsel neqjoinsel ));
-DATA(insert OID = 1662 ( "<" PGNSP PGUID b f 26 23 16 1658 1665 0 0 0 0 oidlt scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1663 ( ">" PGNSP PGUID b f 26 23 16 1657 1664 0 0 0 0 oidgt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 1664 ( "<=" PGNSP PGUID b f 26 23 16 1660 1663 0 0 0 0 oidle scalarltsel scalarltjoinsel ));
-DATA(insert OID = 1665 ( ">=" PGNSP PGUID b f 26 23 16 1659 1662 0 0 0 0 oidge scalargtsel scalargtjoinsel ));
+/* regproc comparisons --- use oid (unsigned) comparison */
+DATA(insert OID = 1656 ( "=" PGNSP PGUID b t 24 24 16 1656 1657 1658 1658 1658 1659 oideq eqsel eqjoinsel ));
+DATA(insert OID = 1657 ( "<>" PGNSP PGUID b f 24 24 16 1657 1656 0 0 0 0 oidne neqsel neqjoinsel ));
+DATA(insert OID = 1658 ( "<" PGNSP PGUID b f 24 24 16 1659 1661 0 0 0 0 oidlt scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1659 ( ">" PGNSP PGUID b f 24 24 16 1658 1660 0 0 0 0 oidgt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 1660 ( "<=" PGNSP PGUID b f 24 24 16 1661 1659 0 0 0 0 oidle scalarltsel scalarltjoinsel ));
+DATA(insert OID = 1661 ( ">=" PGNSP PGUID b f 24 24 16 1660 1658 0 0 0 0 oidge scalargtsel scalargtjoinsel ));
/* NUMERIC type - OID's 1700-1799 */
DATA(insert OID = 1751 ( "-" PGNSP PGUID l f 0 1700 1700 0 0 0 0 0 0 numeric_uminus - - ));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index ff2200d2cc..eb44f283b9 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.271 2002/09/12 00:21:24 momjian Exp $
+ * $Id: pg_proc.h,v 1.272 2002/09/18 21:35:23 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -886,15 +886,20 @@ DESCR("convert int8 to float8");
DATA(insert OID = 483 ( int8 PGNSP PGUID 12 f f t f i 1 20 "701" dtoi8 - _null_ ));
DESCR("convert float8 to int8");
+/* OIDS 500 - 599 */
+
+/* OIDS 600 - 699 */
+
+DATA(insert OID = 652 ( float4 PGNSP PGUID 12 f f t f i 1 700 "20" i8tof - _null_ ));
+DESCR("convert int8 to float4");
+DATA(insert OID = 653 ( int8 PGNSP PGUID 12 f f t f i 1 20 "700" ftoi8 - _null_ ));
+DESCR("convert float4 to int8");
+
DATA(insert OID = 714 ( int2 PGNSP PGUID 12 f f t f i 1 21 "20" int82 - _null_ ));
DESCR("convert int8 to int2");
DATA(insert OID = 754 ( int8 PGNSP PGUID 12 f f t f i 1 20 "21" int28 - _null_ ));
DESCR("convert int2 to int8");
-/* OIDS 500 - 599 */
-
-/* OIDS 600 - 699 */
-
DATA(insert OID = 1285 ( int4notin PGNSP PGUID 12 f f t f s 2 16 "23 25" int4notin - _null_ ));
DESCR("not in");
DATA(insert OID = 1286 ( oidnotin PGNSP PGUID 12 f f t f s 2 16 "26 25" oidnotin - _null_ ));
@@ -910,9 +915,9 @@ DESCR("greater-than-or-equal");
DATA(insert OID = 659 ( namene PGNSP PGUID 12 f f t f i 2 16 "19 19" namene - _null_ ));
DESCR("not equal");
-DATA(insert OID = 668 ( bpchar PGNSP PGUID 12 f f t f i 2 1042 "1042 23" bpchar - _null_ ));
+DATA(insert OID = 668 ( bpchar PGNSP PGUID 12 f f t f i 3 1042 "1042 23 16" bpchar - _null_ ));
DESCR("adjust char() to typmod length");
-DATA(insert OID = 669 ( varchar PGNSP PGUID 12 f f t f i 2 1043 "1043 23" varchar - _null_ ));
+DATA(insert OID = 669 ( varchar PGNSP PGUID 12 f f t f i 3 1043 "1043 23 16" varchar - _null_ ));
DESCR("adjust varchar() to typmod length");
DATA(insert OID = 676 ( mktinterval PGNSP PGUID 12 f f t f i 2 704 "702 702" mktinterval - _null_ ));
@@ -1374,7 +1379,7 @@ DATA(insert OID = 1141 ( date_pli PGNSP PGUID 12 f f t f i 2 1082 "1082 23"
DESCR("add");
DATA(insert OID = 1142 ( date_mii PGNSP PGUID 12 f f t f i 2 1082 "1082 23" date_mii - _null_ ));
DESCR("subtract");
-DATA(insert OID = 1143 ( time_in PGNSP PGUID 12 f f t f s 1 1083 "2275" time_in - _null_ ));
+DATA(insert OID = 1143 ( time_in PGNSP PGUID 12 f f t f s 3 1083 "2275 26 23" time_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1144 ( time_out PGNSP PGUID 12 f f t f i 1 2275 "1083" time_out - _null_ ));
DESCR("(internal)");
@@ -1390,7 +1395,7 @@ DESCR("multiply");
DATA(insert OID = 1149 ( circle_div_pt PGNSP PGUID 12 f f t f i 2 718 "718 600" circle_div_pt - _null_ ));
DESCR("divide");
-DATA(insert OID = 1150 ( timestamptz_in PGNSP PGUID 12 f f t f s 1 1184 "2275" timestamptz_in - _null_ ));
+DATA(insert OID = 1150 ( timestamptz_in PGNSP PGUID 12 f f t f s 3 1184 "2275 26 23" timestamptz_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1151 ( timestamptz_out PGNSP PGUID 12 f f t f s 1 2275 "1184" timestamptz_out - _null_ ));
DESCR("(internal)");
@@ -1409,7 +1414,7 @@ DESCR("greater-than");
DATA(insert OID = 1159 ( timezone PGNSP PGUID 12 f f t f s 2 1114 "25 1184" timestamptz_zone - _null_ ));
DESCR("timestamp at a specified time zone");
-DATA(insert OID = 1160 ( interval_in PGNSP PGUID 12 f f t f s 1 1186 "2275" interval_in - _null_ ));
+DATA(insert OID = 1160 ( interval_in PGNSP PGUID 12 f f t f s 3 1186 "2275 26 23" interval_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1161 ( interval_out PGNSP PGUID 12 f f t f i 1 2275 "1186" interval_out - _null_ ));
DESCR("(internal)");
@@ -1539,15 +1544,18 @@ DESCR("multiply");
DATA(insert OID = 1281 ( int48div PGNSP PGUID 12 f f t f i 2 20 "23 20" int48div - _null_ ));
DESCR("divide");
-DATA(insert OID = 1288 ( text PGNSP PGUID 12 f f t f i 1 25 "20" int8_text - _null_ ));
+DATA(insert OID = 1287 ( oid PGNSP PGUID 12 f f t f i 1 26 "20" i8tooid - _null_ ));
+DESCR("convert int8 to oid");
+DATA(insert OID = 1288 ( int8 PGNSP PGUID 12 f f t f i 1 20 "26" oidtoi8 - _null_ ));
+DESCR("convert oid to int8");
+
+DATA(insert OID = 1289 ( text PGNSP PGUID 12 f f t f i 1 25 "20" int8_text - _null_ ));
DESCR("convert int8 to text");
-DATA(insert OID = 1289 ( int8 PGNSP PGUID 12 f f t f i 1 20 "25" text_int8 - _null_ ));
+DATA(insert OID = 1290 ( int8 PGNSP PGUID 12 f f t f i 1 20 "25" text_int8 - _null_ ));
DESCR("convert text to int8");
-DATA(insert OID = 1290 ( _bpchar PGNSP PGUID 12 f f t f i 2 1014 "1014 23" _bpchar - _null_ ));
-DESCR("adjust char()[] to typmod length");
-DATA(insert OID = 1291 ( _varchar PGNSP PGUID 12 f f t f i 2 1015 "1015 23" _varchar - _null_ ));
-DESCR("adjust varchar()[] to typmod length");
+DATA(insert OID = 1291 ( array_length_coerce PGNSP PGUID 12 f f t f i 3 2277 "2277 23 16" array_length_coerce - _null_ ));
+DESCR("adjust any array to element typmod length");
DATA(insert OID = 1292 ( tideq PGNSP PGUID 12 f f t f i 2 16 "27 27" tideq - _null_ ));
DESCR("equal");
@@ -1594,7 +1602,7 @@ DESCR("SQL92 interval comparison");
DATA(insert OID = 1311 ( overlaps PGNSP PGUID 14 f f f f i 4 16 "1083 1186 1083 1083" "select ($1, ($1 + $2)) overlaps ($3, $4)" - _null_ ));
DESCR("SQL92 interval comparison");
-DATA(insert OID = 1312 ( timestamp_in PGNSP PGUID 12 f f t f s 1 1114 "2275" timestamp_in - _null_ ));
+DATA(insert OID = 1312 ( timestamp_in PGNSP PGUID 12 f f t f s 3 1114 "2275 26 23" timestamp_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1313 ( timestamp_out PGNSP PGUID 12 f f t f s 1 2275 "1114" timestamp_out - _null_ ));
DESCR("(internal)");
@@ -1644,7 +1652,7 @@ DATA(insert OID = 1349 ( oidvectortypes PGNSP PGUID 12 f f t f s 1 25 "30" oi
DESCR("print type names of oidvector field");
-DATA(insert OID = 1350 ( timetz_in PGNSP PGUID 12 f f t f s 1 1266 "2275" timetz_in - _null_ ));
+DATA(insert OID = 1350 ( timetz_in PGNSP PGUID 12 f f t f s 3 1266 "2275 26 23" timetz_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1351 ( timetz_out PGNSP PGUID 12 f f t f i 1 2275 "1266" timetz_out - _null_ ));
DESCR("(internal)");
@@ -1983,7 +1991,7 @@ DESCR("# points in path");
DATA(insert OID = 1556 ( npoints PGNSP PGUID 12 f f t f i 1 23 "604" poly_npoints - _null_ ));
DESCR("number of points in polygon");
-DATA(insert OID = 1564 ( bit_in PGNSP PGUID 12 f f t f i 1 1560 "2275" bit_in - _null_ ));
+DATA(insert OID = 1564 ( bit_in PGNSP PGUID 12 f f t f i 3 1560 "2275 26 23" bit_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1565 ( bit_out PGNSP PGUID 12 f f t f i 1 2275 "1560" bit_out - _null_ ));
DESCR("(internal)");
@@ -2008,7 +2016,7 @@ DESCR("set sequence value");
DATA(insert OID = 1765 ( setval PGNSP PGUID 12 f f t f v 3 20 "25 20 16" setval_and_iscalled - _null_ ));
DESCR("set sequence value and iscalled status");
-DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 f f t f i 1 1562 "2275" varbit_in - _null_ ));
+DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 f f t f i 3 1562 "2275 26 23" varbit_in - _null_ ));
DESCR("(internal)");
DATA(insert OID = 1580 ( varbit_out PGNSP PGUID 12 f f t f i 1 2275 "1562" varbit_out - _null_ ));
DESCR("(internal)");
@@ -2060,8 +2068,6 @@ DESCR("PI");
DATA(insert OID = 1618 ( interval_mul PGNSP PGUID 12 f f t f i 2 1186 "1186 701" interval_mul - _null_ ));
DESCR("multiply interval");
-DATA(insert OID = 1619 ( varchar PGNSP PGUID 12 f f t f i 1 1043 "23" int4_text - _null_ ));
-DESCR("convert int4 to varchar");
DATA(insert OID = 1620 ( ascii PGNSP PGUID 12 f f t f i 1 23 "25" ascii - _null_ ));
DESCR("convert first char to int4");
@@ -2070,8 +2076,6 @@ DESCR("convert int4 to char");
DATA(insert OID = 1622 ( repeat PGNSP PGUID 12 f f t f i 2 25 "25 23" repeat - _null_ ));
DESCR("replicate string int4 times");
-DATA(insert OID = 1623 ( varchar PGNSP PGUID 12 f f t f i 1 1043 "20" int8_text - _null_ ));
-DESCR("convert int8 to varchar");
DATA(insert OID = 1624 ( mul_d_interval PGNSP PGUID 12 f f t f i 2 1186 "701 1186" mul_d_interval - _null_ ));
DATA(insert OID = 1633 ( texticlike PGNSP PGUID 12 f f t f i 2 16 "25 25" texticlike - _null_ ));
@@ -2133,9 +2137,9 @@ DESCR("replace all occurrences of old_substr with new_substr in string");
DATA(insert OID = 2088 ( split_part PGNSP PGUID 12 f f t f i 3 25 "25 25 23" split_text - _null_ ));
DESCR("split string by field_sep and return field_num");
DATA(insert OID = 2089 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "23" to_hex32 - _null_ ));
-DESCR("convert int32 number to hex");
+DESCR("convert int4 number to hex");
DATA(insert OID = 2090 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "20" to_hex64 - _null_ ));
-DESCR("convert int64 number to hex");
+DESCR("convert int8 number to hex");
/* for character set encoding support */
@@ -2250,14 +2254,10 @@ DESCR("int4 to bitstring");
DATA(insert OID = 1684 ( int4 PGNSP PGUID 12 f f t f i 1 23 "1560" bittoint4 - _null_ ));
DESCR("bitstring to int4");
-DATA(insert OID = 1685 ( bit PGNSP PGUID 12 f f t f i 2 1560 "1560 23" bit - _null_ ));
+DATA(insert OID = 1685 ( bit PGNSP PGUID 12 f f t f i 3 1560 "1560 23 16" bit - _null_ ));
DESCR("adjust bit() to typmod length");
-DATA(insert OID = 1686 ( _bit PGNSP PGUID 12 f f t f i 2 1561 "1561 23" _bit - _null_ ));
-DESCR("adjust bit()[] to typmod length");
-DATA(insert OID = 1687 ( varbit PGNSP PGUID 12 f f t f i 2 1562 "1562 23" varbit - _null_ ));
+DATA(insert OID = 1687 ( varbit PGNSP PGUID 12 f f t f i 3 1562 "1562 23 16" varbit - _null_ ));
DESCR("adjust varbit() to typmod length");
-DATA(insert OID = 1688 ( _varbit PGNSP PGUID 12 f f t f i 2 1563 "1563 23" _varbit - _null_ ));
-DESCR("adjust varbit()[] to typmod length");
DATA(insert OID = 1698 ( position PGNSP PGUID 12 f f t f i 2 23 "1560 1560" bitposition - _null_ ));
DESCR("return position of sub-bitstring");
@@ -2351,6 +2351,11 @@ DESCR("text to cidr");
DATA(insert OID = 1715 ( set_masklen PGNSP PGUID 12 f f t f i 2 869 "869 23" inet_set_masklen - _null_ ));
DESCR("change the netmask of an inet");
+DATA(insert OID = 1686 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "25" text_numeric - _null_ ));
+DESCR("(internal)");
+DATA(insert OID = 1688 ( text PGNSP PGUID 12 f f t f i 1 25 "1700" numeric_text - _null_ ));
+DESCR("(internal)");
+
DATA(insert OID = 1690 ( time_mi_time PGNSP PGUID 12 f f t f i 2 1186 "1083 1083" time_mi_time - _null_ ));
DESCR("minus");
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index f4e69d3d15..e7c9c29413 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: makefuncs.h,v 1.40 2002/09/04 20:31:43 momjian Exp $
+ * $Id: makefuncs.h,v 1.41 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,6 +16,7 @@
#include "nodes/parsenodes.h"
+
extern A_Expr *makeA_Expr(int oper, List *name, Node *lexpr, Node *rexpr);
extern A_Expr *makeSimpleA_Expr(int oper, const char *name,
@@ -52,7 +53,8 @@ extern Const *makeNullConst(Oid consttype);
extern Alias *makeAlias(const char *aliasname, List *colnames);
-extern RelabelType *makeRelabelType(Node *arg, Oid rtype, int32 rtypmod);
+extern RelabelType *makeRelabelType(Node *arg, Oid rtype, int32 rtypmod,
+ CoercionForm rformat);
extern RangeVar *makeRangeVar(char *schemaname, char *relname);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 0f703e27ec..56e3922ea9 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.206 2002/09/04 20:31:43 momjian Exp $
+ * $Id: parsenodes.h,v 1.207 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1632,7 +1632,7 @@ typedef struct CreateCastStmt
TypeName *sourcetype;
TypeName *targettype;
FuncWithArgs *func;
- bool implicit;
+ CoercionContext context;
} CreateCastStmt;
/* ----------------------
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 111ed7f8ce..1d7c5115b6 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: primnodes.h,v 1.67 2002/09/04 20:31:44 momjian Exp $
+ * $Id: primnodes.h,v 1.68 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -140,6 +140,30 @@ typedef struct RangeVar
*/
/*
+ * CoercionContext - distinguishes the allowed set of type casts
+ *
+ * NB: ordering of the alternatives is significant; later (larger) values
+ * allow more casts than earlier ones.
+ */
+typedef enum CoercionContext
+{
+ COERCION_IMPLICIT, /* coercion in context of expression */
+ COERCION_ASSIGNMENT, /* coercion in context of assignment */
+ COERCION_EXPLICIT /* explicit cast operation */
+} CoercionContext;
+
+/*
+ * CoercionForm - information showing how to display a function-call node
+ */
+typedef enum CoercionForm
+{
+ COERCE_EXPLICIT_CALL, /* display as a function call */
+ COERCE_EXPLICIT_CAST, /* display as an explicit cast */
+ COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
+ COERCE_DONTCARE /* special case for pathkeys */
+} CoercionForm;
+
+/*
* Expr
*/
typedef enum OpType
@@ -194,6 +218,7 @@ typedef struct Func
Oid funcid; /* PG_PROC OID of the function */
Oid funcresulttype; /* PG_TYPE OID of result value */
bool funcretset; /* true if function returns set */
+ CoercionForm funcformat; /* how to display this function call */
FunctionCachePtr func_fcache; /* runtime state, or NULL */
} Func;
@@ -460,6 +485,7 @@ typedef struct RelabelType
Node *arg; /* input expression */
Oid resulttype; /* output type of coercion expression */
int32 resulttypmod; /* output typmod (usually -1) */
+ CoercionForm relabelformat; /* how to display this node */
} RelabelType;
diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h
index 152ade0e9b..61a63cafeb 100644
--- a/src/include/parser/parse_coerce.h
+++ b/src/include/parser/parse_coerce.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* parse_coerce.h
- *
* Routines for type coercion.
*
+ *
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_coerce.h,v 1.46 2002/09/04 20:31:45 momjian Exp $
+ * $Id: parse_coerce.h,v 1.47 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,29 +29,31 @@ typedef enum CATEGORY
TIMESPAN_TYPE,
GEOMETRIC_TYPE,
NETWORK_TYPE,
- USER_TYPE,
- MIXED_TYPE
+ USER_TYPE
} CATEGORY;
-extern bool IsBinaryCompatible(Oid type1, Oid type2);
+extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
extern bool IsPreferredType(CATEGORY category, Oid type);
extern CATEGORY TypeCategory(Oid type);
-extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids,
- bool isExplicit);
-extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
- Oid targetTypeId, int32 atttypmod, bool isExplicit);
-extern Node *coerce_type_typmod(ParseState *pstate, Node *node,
- Oid targetTypeId, int32 atttypmod);
-extern Node *coerce_type_constraints(ParseState *pstate, Node *arg,
- Oid typeId, bool applyTypmod);
+extern Node *coerce_to_target_type(Node *expr, Oid exprtype,
+ Oid targettype, int32 targettypmod,
+ CoercionContext ccontext,
+ CoercionForm cformat);
+extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
+ CoercionContext ccontext);
+extern Node *coerce_type(Node *node, Oid inputTypeId, Oid targetTypeId,
+ CoercionContext ccontext, CoercionForm cformat);
+extern Node *coerce_type_constraints(Node *arg, Oid typeId,
+ CoercionForm cformat);
extern Node *coerce_to_boolean(Node *node, const char *constructName);
extern Oid select_common_type(List *typeids, const char *context);
-extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
- Oid targetTypeId,
+extern Node *coerce_to_common_type(Node *node, Oid targetTypeId,
const char *context);
+extern Oid find_typmod_coercion_function(Oid typeId, int *nargs);
+
#endif /* PARSE_COERCE_H */
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index 8fac035fcc..beb16e2cc8 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_node.h,v 1.31 2002/06/20 20:29:51 momjian Exp $
+ * $Id: parse_node.h,v 1.32 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,6 +57,7 @@ extern Var *make_var(ParseState *pstate, RangeTblEntry *rte, int attrno);
extern ArrayRef *transformArraySubscripts(ParseState *pstate,
Node *arrayBase,
Oid arrayType,
+ int32 arrayTypMod,
List *indirection,
bool forceSlice,
Node *assignFrom);
diff --git a/src/include/parser/parse_target.h b/src/include/parser/parse_target.h
index acca0f0569..b8c495484b 100644
--- a/src/include/parser/parse_target.h
+++ b/src/include/parser/parse_target.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* parse_target.h
- *
+ * handle target lists
*
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_target.h,v 1.26 2002/09/04 20:31:45 momjian Exp $
+ * $Id: parse_target.h,v 1.27 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,6 +16,7 @@
#include "parser/parse_node.h"
+
extern List *transformTargetList(ParseState *pstate, List *targetlist);
extern TargetEntry *transformTargetEntry(ParseState *pstate,
Node *node, Node *expr,
@@ -23,9 +24,6 @@ extern TargetEntry *transformTargetEntry(ParseState *pstate,
extern void updateTargetListEntry(ParseState *pstate, TargetEntry *tle,
char *colname, int attrno,
List *indirection);
-extern Node *CoerceTargetExpr(ParseState *pstate, Node *expr,
- Oid type_id, Oid attrtype, int32 attrtypmod,
- bool isExplicit);
extern List *checkInsertTargets(ParseState *pstate, List *cols,
List **attrnos);
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index 5c1276467c..639d9dc315 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: array.h,v 1.34 2002/09/04 20:31:45 momjian Exp $
+ * $Id: array.h,v 1.35 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -82,6 +82,7 @@ typedef struct
*/
extern Datum array_in(PG_FUNCTION_ARGS);
extern Datum array_out(PG_FUNCTION_ARGS);
+extern Datum array_length_coerce(PG_FUNCTION_ARGS);
extern Datum array_eq(PG_FUNCTION_ARGS);
extern Datum array_dims(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index e97982215d..d9f611bcfd 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.199 2002/09/04 20:31:45 momjian Exp $
+ * $Id: builtins.h,v 1.200 2002/09/18 21:35:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -422,7 +422,6 @@ extern Datum currtid_byrelname(PG_FUNCTION_ARGS);
extern Datum bpcharin(PG_FUNCTION_ARGS);
extern Datum bpcharout(PG_FUNCTION_ARGS);
extern Datum bpchar(PG_FUNCTION_ARGS);
-extern Datum _bpchar(PG_FUNCTION_ARGS);
extern Datum char_bpchar(PG_FUNCTION_ARGS);
extern Datum name_bpchar(PG_FUNCTION_ARGS);
extern Datum bpchar_name(PG_FUNCTION_ARGS);
@@ -440,7 +439,6 @@ extern Datum hashbpchar(PG_FUNCTION_ARGS);
extern Datum varcharin(PG_FUNCTION_ARGS);
extern Datum varcharout(PG_FUNCTION_ARGS);
extern Datum varchar(PG_FUNCTION_ARGS);
-extern Datum _varchar(PG_FUNCTION_ARGS);
extern Datum varchareq(PG_FUNCTION_ARGS);
extern Datum varcharne(PG_FUNCTION_ARGS);
extern Datum varcharlt(PG_FUNCTION_ARGS);
@@ -633,6 +631,8 @@ extern Datum numeric_float8(PG_FUNCTION_ARGS);
extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
extern Datum float4_numeric(PG_FUNCTION_ARGS);
extern Datum numeric_float4(PG_FUNCTION_ARGS);
+extern Datum text_numeric(PG_FUNCTION_ARGS);
+extern Datum numeric_text(PG_FUNCTION_ARGS);
extern Datum numeric_accum(PG_FUNCTION_ARGS);
extern Datum int2_accum(PG_FUNCTION_ARGS);
extern Datum int4_accum(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/int8.h b/src/include/utils/int8.h
index 4ffa3bca50..f8b337e3c0 100644
--- a/src/include/utils/int8.h
+++ b/src/include/utils/int8.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: int8.h,v 1.34 2002/06/20 20:29:53 momjian Exp $
+ * $Id: int8.h,v 1.35 2002/09/18 21:35:25 tgl Exp $
*
* NOTES
* These data types are supported on all 64-bit architectures, and may
@@ -29,6 +29,8 @@
#define INT64_FORMAT "%ld"
#endif
+extern bool scanint8(const char *str, bool errorOK, int64 *result);
+
extern Datum int8in(PG_FUNCTION_ARGS);
extern Datum int8out(PG_FUNCTION_ARGS);
@@ -106,6 +108,12 @@ extern Datum int82(PG_FUNCTION_ARGS);
extern Datum i8tod(PG_FUNCTION_ARGS);
extern Datum dtoi8(PG_FUNCTION_ARGS);
+extern Datum i8tof(PG_FUNCTION_ARGS);
+extern Datum ftoi8(PG_FUNCTION_ARGS);
+
+extern Datum i8tooid(PG_FUNCTION_ARGS);
+extern Datum oidtoi8(PG_FUNCTION_ARGS);
+
extern Datum int8_text(PG_FUNCTION_ARGS);
extern Datum text_int8(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index 029fdcdc86..5dee7bc0cb 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lsyscache.h,v 1.62 2002/09/04 20:31:45 momjian Exp $
+ * $Id: lsyscache.h,v 1.63 2002/09/18 21:35:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,6 @@ extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem);
extern bool getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
bool *typIsVarlena);
extern Oid getBaseType(Oid typid);
-extern int32 getBaseTypeMod(Oid typid, int32 typmod);
extern int32 get_typavgwidth(Oid typid, int32 typmod);
extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
extern bool get_attstatsslot(HeapTuple statstuple,
diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h
index 8dff3166d5..9e5505624b 100644
--- a/src/include/utils/varbit.h
+++ b/src/include/utils/varbit.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: varbit.h,v 1.15 2002/08/04 06:33:56 thomas Exp $
+ * $Id: varbit.h,v 1.16 2002/09/18 21:35:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,9 +66,7 @@ extern Datum bit_out(PG_FUNCTION_ARGS);
extern Datum varbit_in(PG_FUNCTION_ARGS);
extern Datum varbit_out(PG_FUNCTION_ARGS);
extern Datum bit(PG_FUNCTION_ARGS);
-extern Datum _bit(PG_FUNCTION_ARGS);
extern Datum varbit(PG_FUNCTION_ARGS);
-extern Datum _varbit(PG_FUNCTION_ARGS);
extern Datum biteq(PG_FUNCTION_ARGS);
extern Datum bitne(PG_FUNCTION_ARGS);
extern Datum bitlt(PG_FUNCTION_ARGS);