summaryrefslogtreecommitdiff
path: root/src/include/catalog/genbki.h
diff options
context:
space:
mode:
authorPeter Eisentraut2021-01-30 18:14:31 +0000
committerPeter Eisentraut2021-01-30 18:44:29 +0000
commitdfb75e478cacb33d277432e0df5e2f9a2a2b52d9 (patch)
treef22b9b6f1d6b5238ba2cfb23560a843d81f12821 /src/include/catalog/genbki.h
parent65330622441d7ee08f768c4326825ae903f2595a (diff)
Add primary keys and unique constraints to system catalogs
For those system catalogs that have a unique indexes, make a primary key and unique constraint, using ALTER TABLE ... PRIMARY KEY/UNIQUE USING INDEX. This can be helpful for GUI tools that look for a primary key, and it might in the future allow declaring foreign keys, for making schema diagrams. The constraint creation statements are automatically created by genbki.pl from DECLARE_UNIQUE_INDEX directives. To specify which one of the available unique indexes is the primary key, use the new directive DECLARE_UNIQUE_INDEX_PKEY instead. By convention, we usually make a catalog's OID column its primary key, if it has one. Reviewed-by: Tom Lane <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
Diffstat (limited to 'src/include/catalog/genbki.h')
-rw-r--r--src/include/catalog/genbki.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/include/catalog/genbki.h b/src/include/catalog/genbki.h
index e26bde6d09b..5d05fafb5da 100644
--- a/src/include/catalog/genbki.h
+++ b/src/include/catalog/genbki.h
@@ -55,12 +55,15 @@
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
/*
- * These lines processed by genbki.pl to create the statements
+ * These lines are processed by genbki.pl to create the statements
* the bootstrap parser will turn into DefineIndex calls.
*
- * The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX. The first two
- * arguments are the index name and OID, the rest is much like a standard
- * 'create index' SQL command.
+ * The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX or
+ * DECLARE_UNIQUE_INDEX_PKEY. ("PKEY" marks the index as being the catalog's
+ * primary key; currently this is only cosmetically different from a regular
+ * unique index. By convention, we usually make a catalog's OID column its
+ * pkey, if it has one.) The first two arguments are the index's name and
+ * OID, the rest is much like a standard 'create index' SQL command.
*
* For each index, we also provide a #define for its OID. References to
* the index in the C code should always use these #defines, not the actual
@@ -70,6 +73,7 @@
*/
#define DECLARE_INDEX(name,oid,decl) extern int no_such_variable
#define DECLARE_UNIQUE_INDEX(name,oid,decl) extern int no_such_variable
+#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,decl) extern int no_such_variable
/* The following are never defined; they are here only for documentation. */