summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTatsuo Ishii2002-07-11 07:39:28 +0000
committerTatsuo Ishii2002-07-11 07:39:28 +0000
commitfcc962566a7cf0461778c97ef713fa4855303dfe (patch)
tree507fb3d31a7cba6a6258b40ec5c9364f3ec9a3a6 /src/include
parentf2bb1cfa85eba18b185c8883a8da6077f7888ec2 (diff)
Add new CREATE CONVERSION/DROP CONVERSION command.
This is the first cut toward CREATE CONVERSION/DROP CONVERSION implementaion. The commands can now add/remove tuples to the new pg_conversion system catalog, but that's all. Still need work to make them actually working. Documentations, regression tests also need work.
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.h9
-rw-r--r--src/include/catalog/pg_conversion.h93
-rw-r--r--src/include/commands/conversioncmds.h23
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/parsenodes.h17
-rw-r--r--src/include/utils/syscache.h44
8 files changed, 168 insertions, 28 deletions
diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h
index d679b06618c..6f755c9f9dc 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.26 2002/06/20 20:29:43 momjian Exp $
+ * $Id: catname.h,v 1.27 2002/07/11 07:39:27 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,6 +20,7 @@
#define AccessMethodOperatorRelationName "pg_amop"
#define AccessMethodProcedureRelationName "pg_amproc"
#define AttributeRelationName "pg_attribute"
+#define ConversionRelationName "pg_conversion"
#define DatabaseRelationName "pg_database"
#define DescriptionRelationName "pg_description"
#define GroupRelationName "pg_group"
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index d4d04d6db96..81f52bd9b34 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.137 2002/07/02 05:46:14 momjian Exp $
+ * $Id: catversion.h,v 1.138 2002/07/11 07:39:27 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200207021
+#define CATALOG_VERSION_NO 200207111
#endif
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index bbc1b5ec995..9413e5c8586 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.67 2002/06/20 20:29:43 momjian Exp $
+ * $Id: indexing.h,v 1.68 2002/07/11 07:39:27 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,7 @@
#define Num_pg_attr_indices 2
#define Num_pg_attrdef_indices 1
#define Num_pg_class_indices 2
+#define Num_pg_conversion_indices 2
#define Num_pg_database_indices 2
#define Num_pg_description_indices 1
#define Num_pg_group_indices 2
@@ -59,6 +60,8 @@
#define AttributeRelidNumIndex "pg_attribute_relid_attnum_index"
#define ClassNameNspIndex "pg_class_relname_nsp_index"
#define ClassOidIndex "pg_class_oid_index"
+#define ConversionDefaultIndex "pg_conversion_default_index"
+#define ConversionNameNspIndex "pg_conversion_name_nsp_index"
#define DatabaseNameIndex "pg_database_datname_index"
#define DatabaseOidIndex "pg_database_oid_index"
#define DescriptionObjIndex "pg_description_o_c_o_index"
@@ -99,6 +102,7 @@ extern char *Name_pg_amproc_indices[];
extern char *Name_pg_attr_indices[];
extern char *Name_pg_attrdef_indices[];
extern char *Name_pg_class_indices[];
+extern char *Name_pg_conversion_indices[];
extern char *Name_pg_database_indices[];
extern char *Name_pg_description_indices[];
extern char *Name_pg_group_indices[];
@@ -155,6 +159,9 @@ DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_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 */
+DECLARE_INDEX(pg_conversion_default_index on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops));
+DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index on pg_conversion using btree(conname name_ops, connamespace oid_ops));
DECLARE_UNIQUE_INDEX(pg_database_datname_index on pg_database using btree(datname name_ops));
DECLARE_UNIQUE_INDEX(pg_database_oid_index on pg_database using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_description_o_c_o_index on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
new file mode 100644
index 00000000000..d4c406b8ee1
--- /dev/null
+++ b/src/include/catalog/pg_conversion.h
@@ -0,0 +1,93 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_conversion.h
+ * definition of the system "conversion" relation (pg_conversion)
+ * along with the relation's initial contents.
+ *
+ *
+ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: pg_conversion.h,v 1.1 2002/07/11 07:39:27 ishii Exp $
+ *
+ * NOTES
+ * the genbki.sh script reads this file and generates .bki
+ * information from the DATA() statements.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PG_CONVERSION_H
+#define PG_CONVERSION_H
+
+/* ----------------
+ * postgres.h contains the system type definitions and the
+ * CATALOG(), BOOTSTRAP and DATA() sugar words so this file
+ * can be read by both genbki.sh and the C compiler.
+ * ----------------
+ */
+
+/* ----------------------------------------------------------------
+ * pg_conversion definition.
+ *
+ * cpp turns this into typedef struct FormData_pg_namespace
+ *
+ * conname name of the conversion
+ * connamespace name space which the conversion belongs to
+ * conowner ower of the conversion
+ * conforencoding FOR encoding id
+ * contoencoding TO encoding id
+ * conproc OID of the conversion proc
+ * condefault TRUE is this is a default conversion
+ * ----------------------------------------------------------------
+ */
+CATALOG(pg_conversion)
+{
+ NameData conname;
+ Oid connamespace;
+ int4 conowner;
+ int4 conforencoding;
+ int4 contoencoding;
+ regproc conproc;
+ bool condefault;
+} FormData_pg_conversion;
+
+/* ----------------
+ * Form_pg_conversion corresponds to a pointer to a tuple with
+ * the format of pg_conversion relation.
+ * ----------------
+ */
+typedef FormData_pg_conversion *Form_pg_conversion;
+
+/* ----------------
+ * compiler constants for pg_conversion
+ * ----------------
+ */
+
+#define Natts_pg_conversion 7
+#define Anum_pg_conversion_conname 1
+#define Anum_pg_conversion_connamespace 2
+#define Anum_pg_conversion_conowner 3
+#define Anum_pg_conversion_conforencoding 4
+#define Anum_pg_conversion_contoencoding 5
+#define Anum_pg_conversion_conproc 6
+#define Anum_pg_conversion_condefault 7
+
+/* ----------------
+ * initial contents of pg_conversion
+ * ---------------
+ */
+
+/*
+ * prototypes for functions in pg_conversion.c
+ */
+#include "nodes/pg_list.h"
+
+extern Oid ConversionCreate(const char *conname, Oid connamespace,
+ int32 conowner,
+ int4 conforencoding, int4 contoencoding,
+ Oid conproc, bool def);
+extern void ConversionDrop(const char *conname, Oid connamespace, int32 conowner);
+extern Oid FindDefaultConversion(Oid name_space, int4 for_encoding, int4 to_encoding);
+extern Oid FindConversionByName(List *conname);
+
+#endif /* PG_CONVERSION_H */
diff --git a/src/include/commands/conversioncmds.h b/src/include/commands/conversioncmds.h
new file mode 100644
index 00000000000..fc4e5e6f51b
--- /dev/null
+++ b/src/include/commands/conversioncmds.h
@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ *
+ * conversioncmds.h
+ * prototypes for conversioncmds.c.
+ *
+ *
+ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: conversioncmds.h,v 1.1 2002/07/11 07:39:27 ishii Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef CONVERSIONCMDS_H
+#define CONVERSIONCMDS_H
+
+#include "nodes/parsenodes.h"
+
+extern void CreateConversionCommand(CreateConversionStmt *parsetree);
+extern void DropConversionCommand(List *conversion_name);
+
+#endif /* CONVERSIONCMDS_H */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 815a9ea861f..a2980a1ff20 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.109 2002/06/20 20:29:51 momjian Exp $
+ * $Id: nodes.h,v 1.110 2002/07/11 07:39:27 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -198,6 +198,7 @@ typedef enum NodeTag
T_CreateSchemaStmt,
T_AlterDatabaseSetStmt,
T_AlterUserSetStmt,
+ T_CreateConversionStmt,
T_A_Expr = 700,
T_ColumnRef,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index ce914c5cd09..19693d57b3a 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.183 2002/07/01 15:27:56 tgl Exp $
+ * $Id: parsenodes.h,v 1.184 2002/07/11 07:39:27 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1109,6 +1109,7 @@ typedef struct CreateDomainStmt
#define DROP_INDEX 4
#define DROP_TYPE 5
#define DROP_DOMAIN 6
+#define DROP_CONVERSION 7
typedef struct DropStmt
{
@@ -1505,4 +1506,18 @@ typedef struct ReindexStmt
bool all;
} ReindexStmt;
+/* ----------------------
+ * CREATE CONVERSION Statement
+ * ----------------------
+ */
+typedef struct CreateConversionStmt
+{
+ NodeTag type;
+ List *conversion_name; /* Name of the conversion */
+ char *for_encoding_name; /* source encoding name */
+ char *to_encoding_name; /* destiname encoding name */
+ List *func_name; /* qualified conversion function name */
+ bool def; /* is this a default conversion? */
+} CreateConversionStmt;
+
#endif /* PARSENODES_H */
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index 0cd6b7ae5f3..f40471d7948 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.48 2002/06/20 20:29:53 momjian Exp $
+ * $Id: syscache.h,v 1.49 2002/07/11 07:39:28 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,27 +38,27 @@
#define ATTNUM 7
#define CLAAMNAMENSP 8
#define CLAOID 9
-#define GRONAME 10
-#define GROSYSID 11
-#define INDEXRELID 12
-#define INHRELID 13
-#define LANGNAME 14
-#define LANGOID 15
-#define NAMESPACENAME 16
-#define NAMESPACEOID 17
-#define OPERNAMENSP 18
-#define OPEROID 19
-#define PROCNAMENSP 20
-#define PROCOID 21
-#define RELNAMENSP 22
-#define RELOID 23
-#define RULERELNAME 24
-#define SHADOWNAME 25
-#define SHADOWSYSID 26
-#define STATRELATT 27
-#define TYPENAMENSP 28
-#define TYPEOID 29
-
+#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
extern void InitCatalogCache(void);
extern void InitCatalogCachePhase2(void);