summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2002-07-18 23:11:32 +0000
committerPeter Eisentraut2002-07-18 23:11:32 +0000
commit97377048b460823a300b1d414203c5f09c8efc1b (patch)
tree7c567e9728b214a10604afa1aa923d02a683156e /src/include
parenta345ac8842089cbca1678d5b28773a827937693f (diff)
pg_cast table, and standards-compliant CREATE/DROP CAST commands, plus
extension to create binary compatible casts. Includes dependency tracking as well. pg_proc.proimplicit is now defunct, but will be removed in a separate commit. pg_dump provides a migration path from the previous scheme to declare casts. Dumping binary compatible casts is currently impossible, though.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catname.h3
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/indexing.h6
-rw-r--r--src/include/catalog/pg_cast.h225
-rw-r--r--src/include/catalog/pg_proc.h5
-rw-r--r--src/include/commands/defrem.h5
-rw-r--r--src/include/nodes/nodes.h4
-rw-r--r--src/include/nodes/parsenodes.h28
-rw-r--r--src/include/utils/syscache.h49
9 files changed, 295 insertions, 34 deletions
diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h
index 0e452a9ca3..dc1fedae9e 100644
--- a/src/include/catalog/catname.h
+++ b/src/include/catalog/catname.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: catname.h,v 1.28 2002/07/12 18:43:19 tgl Exp $
+ * $Id: catname.h,v 1.29 2002/07/18 23:11:30 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,6 +20,7 @@
#define AccessMethodOperatorRelationName "pg_amop"
#define AccessMethodProcedureRelationName "pg_amproc"
#define AttributeRelationName "pg_attribute"
+#define CastRelationName "pg_cast"
#define ConstraintRelationName "pg_constraint"
#define ConversionRelationName "pg_conversion"
#define DatabaseRelationName "pg_database"
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 5fd581b254..077da864a4 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.140 2002/07/15 16:33:31 tgl Exp $
+ * $Id: catversion.h,v 1.141 2002/07/18 23:11:30 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200207141
+#define CATALOG_VERSION_NO 200207191
#endif
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 91e3593447..777a4031dd 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.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: indexing.h,v 1.70 2002/07/15 16:33:31 tgl Exp $
+ * $Id: indexing.h,v 1.71 2002/07/18 23:11:30 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,6 +26,7 @@
#define Num_pg_amproc_indices 1
#define Num_pg_attr_indices 2
#define Num_pg_attrdef_indices 2
+#define Num_pg_cast_indices 1
#define Num_pg_class_indices 2
#define Num_pg_constraint_indices 3
#define Num_pg_conversion_indices 3
@@ -60,6 +61,7 @@
#define AttrDefaultOidIndex "pg_attrdef_oid_index"
#define AttributeRelidNameIndex "pg_attribute_relid_attnam_index"
#define AttributeRelidNumIndex "pg_attribute_relid_attnum_index"
+#define CastSourceTargetIndex "pg_cast_source_target_index"
#define ClassNameNspIndex "pg_class_relname_nsp_index"
#define ClassOidIndex "pg_class_oid_index"
#define ConstraintNameNspIndex "pg_constraint_conname_nsp_index"
@@ -108,6 +110,7 @@ extern char *Name_pg_amop_indices[];
extern char *Name_pg_amproc_indices[];
extern char *Name_pg_attr_indices[];
extern char *Name_pg_attrdef_indices[];
+extern char *Name_pg_cast_indices[];
extern char *Name_pg_class_indices[];
extern char *Name_pg_constraint_indices[];
extern char *Name_pg_conversion_indices[];
@@ -166,6 +169,7 @@ DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index on pg_attrdef using btree(ad
DECLARE_UNIQUE_INDEX(pg_attrdef_oid_index on pg_attrdef using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops));
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
+DECLARE_UNIQUE_INDEX(pg_cast_source_target_index on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
DECLARE_UNIQUE_INDEX(pg_class_oid_index on pg_class using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index on pg_class using btree(relname name_ops, relnamespace oid_ops));
/* This following index is not used for a cache and is not unique */
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
new file mode 100644
index 0000000000..4e042a396e
--- /dev/null
+++ b/src/include/catalog/pg_cast.h
@@ -0,0 +1,225 @@
+/*-------------------------------------------------------------------------
+ *
+ * $Header: /cvsroot/pgsql/src/include/catalog/pg_cast.h,v 1.1 2002/07/18 23:11:30 petere Exp $
+ *
+ * Copyright (c) 2002, PostgreSQL Global Development Group
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PG_CAST_H
+#define PG_CAST_H
+
+CATALOG(pg_cast)
+{
+ Oid castsource;
+ Oid casttarget;
+ Oid castfunc; /* 0 = binary compatible */
+ bool castimplicit;
+} FormData_pg_cast;
+
+typedef FormData_pg_cast *Form_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
+
+/* ----------------
+ * initial contents of pg_cast
+ * ----------------
+ */
+
+/*
+ * binary compatible casts
+ */
+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 ));
+
+/*
+ * 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:
+ *
+ * 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;
+ */
+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 ));
+/*xDATA(insert ( 23 703 1200 f ));*/
+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 f ));
+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 f ));
+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 ));
+
+#endif /* PG_CAST_H */
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 0bb719a55a..c84ac13a95 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.243 2002/06/20 20:29:44 momjian Exp $
+ * $Id: pg_proc.h,v 1.244 2002/07/18 23:11:30 petere Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -45,7 +45,7 @@ CATALOG(pg_proc) BOOTSTRAP
Oid prolang; /* OID of pg_language entry */
bool proisagg; /* is it an aggregate? */
bool prosecdef; /* security definer */
- bool proimplicit; /* can be invoked as implicit coercion? */
+ bool proimplicit; /* unused */
bool proisstrict; /* strict with respect to NULLs? */
bool proretset; /* returns a set? */
char provolatile; /* see PROVOLATILE_ categories below */
@@ -3007,7 +3007,6 @@ extern Oid ProcedureCreate(const char *procedureName,
const char *probin,
bool isAgg,
bool security_definer,
- bool isImplicit,
bool isStrict,
char volatility,
int32 byte_pct,
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 169ec3f3df..707ba1d1b8 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.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: defrem.h,v 1.41 2002/07/12 18:43:19 tgl Exp $
+ * $Id: defrem.h,v 1.42 2002/07/18 23:11:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,6 +42,9 @@ extern void ReindexDatabase(const char *databaseName, bool force, bool all);
extern void CreateFunction(CreateFunctionStmt *stmt);
extern void RemoveFunction(RemoveFuncStmt *stmt);
extern void RemoveFunctionById(Oid funcOid);
+extern void CreateCast(CreateCastStmt *stmt);
+extern void DropCast(DropCastStmt *stmt);
+extern void DropCastById(Oid castOid);
extern void DefineOperator(List *names, List *parameters);
extern void RemoveOperator(RemoveOperStmt *stmt);
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 308bf95877..3583315a27 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.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: nodes.h,v 1.112 2002/07/18 17:14:20 momjian Exp $
+ * $Id: nodes.h,v 1.113 2002/07/18 23:11:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -199,6 +199,8 @@ typedef enum NodeTag
T_AlterDatabaseSetStmt,
T_AlterUserSetStmt,
T_CreateConversionStmt,
+ T_CreateCastStmt,
+ T_DropCastStmt,
T_A_Expr = 700,
T_ColumnRef,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index b2e42ab716..e4c6b625d1 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.192 2002/07/18 17:14:20 momjian Exp $
+ * $Id: parsenodes.h,v 1.193 2002/07/18 23:11:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1555,4 +1555,30 @@ typedef struct CreateConversionStmt
bool def; /* is this a default conversion? */
} CreateConversionStmt;
+/* ----------------------
+ * CREATE CAST Statement
+ * ----------------------
+ */
+typedef struct CreateCastStmt
+{
+ NodeTag type;
+ TypeName *sourcetype;
+ TypeName *targettype;
+ FuncWithArgs *func;
+ bool implicit;
+} CreateCastStmt;
+
+/* ----------------------
+ * DROP CAST Statement
+ * ----------------------
+ */
+typedef struct DropCastStmt
+{
+ NodeTag type;
+ TypeName *sourcetype;
+ TypeName *targettype;
+ DropBehavior behavior;
+} DropCastStmt;
+
+
#endif /* PARSENODES_H */
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index f40471d794..5d964bb566 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: syscache.h,v 1.49 2002/07/11 07:39:28 ishii Exp $
+ * $Id: syscache.h,v 1.50 2002/07/18 23:11:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,29 +36,30 @@
#define AMPROCNUM 5
#define ATTNAME 6
#define ATTNUM 7
-#define CLAAMNAMENSP 8
-#define CLAOID 9
-#define CONNAMESP 10
-#define GRONAME 11
-#define GROSYSID 12
-#define INDEXRELID 13
-#define INHRELID 14
-#define LANGNAME 15
-#define LANGOID 16
-#define NAMESPACENAME 17
-#define NAMESPACEOID 18
-#define OPERNAMENSP 19
-#define OPEROID 20
-#define PROCNAMENSP 21
-#define PROCOID 22
-#define RELNAMENSP 23
-#define RELOID 24
-#define RULERELNAME 25
-#define SHADOWNAME 26
-#define SHADOWSYSID 27
-#define STATRELATT 28
-#define TYPENAMENSP 29
-#define TYPEOID 30
+#define CASTSOURCETARGET 8
+#define CLAAMNAMENSP 9
+#define CLAOID 10
+#define CONNAMESP 11
+#define GRONAME 12
+#define GROSYSID 13
+#define INDEXRELID 14
+#define INHRELID 15
+#define LANGNAME 16
+#define LANGOID 17
+#define NAMESPACENAME 18
+#define NAMESPACEOID 19
+#define OPERNAMENSP 20
+#define OPEROID 21
+#define PROCNAMENSP 22
+#define PROCOID 23
+#define RELNAMENSP 24
+#define RELOID 25
+#define RULERELNAME 26
+#define SHADOWNAME 27
+#define SHADOWSYSID 28
+#define STATRELATT 29
+#define TYPENAMENSP 30
+#define TYPEOID 31
extern void InitCatalogCache(void);
extern void InitCatalogCachePhase2(void);