summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2024-02-22 06:07:12 +0000
committerPeter Eisentraut2024-02-22 06:07:12 +0000
commitfbc93b8b5f59cfb23c22a26a46ca7bcc826be442 (patch)
treeafd31cd4181910e432be584c5cea8b19a72430b9 /src/include
parent801792e528d6cb5eeb3a70f5ceb10b15bf92f0c7 (diff)
Remove custom Constraint node read/write implementations
This is part of an effort to reduce the number of special cases in the automatically generated node support functions. Allegedly, only certain fields of the Constraint node are valid based on contype. But this has historically not been kept up to date in the read/write functions. The Constraint node is only used for debugging DDL statements, so there are no strong requirements for its output, and there is no enforcement for its correctness. (There was no read support before a6bc3301925.) Commits e7a552f303c and abf46ad9c7b are examples of where omissions were fixed. This patch just removes the custom read/write implementations for the Constraint node type. Now we just output all the fields, which is a bit more than before, but at least we don't have to maintain these functions anymore. Also, we lose the string representation of the contype field, but for this marginal use case that seems tolerable. This patch also changes the documentation of the Constraint struct to put less emphasis on grouping fields by constraint type but rather document for each field how it's used. Reviewed-by: Paul Jungwirth <pj@illuminatedcomputing.com> Discussion: https://www.postgresql.org/message-id/flat/4b27fc50-8cd6-46f5-ab20-88dbaadca645@eisentraut.org
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/parsenodes.h38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 476d55dd240..baa6a97c7e2 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2566,44 +2566,34 @@ typedef enum ConstrType /* types of constraints */
typedef struct Constraint
{
- pg_node_attr(custom_read_write)
-
NodeTag type;
ConstrType contype; /* see above */
-
- /* Fields used for most/all constraint types: */
char *conname; /* Constraint name, or NULL if unnamed */
bool deferrable; /* DEFERRABLE? */
bool initdeferred; /* INITIALLY DEFERRED? */
- int location; /* token location, or -1 if unknown */
-
- /* Fields used for constraints with expressions (CHECK and DEFAULT): */
+ bool skip_validation; /* skip validation of existing rows? */
+ bool initially_valid; /* mark the new constraint as valid? */
bool is_no_inherit; /* is constraint non-inheritable? */
- Node *raw_expr; /* expr, as untransformed parse tree */
- char *cooked_expr; /* expr, as nodeToString representation */
+ Node *raw_expr; /* CHECK or DEFAULT expression, as
+ * untransformed parse tree */
+ char *cooked_expr; /* CHECK or DEFAULT expression, as
+ * nodeToString representation */
char generated_when; /* ALWAYS or BY DEFAULT */
-
- /* Fields used for "raw" NOT NULL constraints: */
- int inhcount; /* initial inheritance count to apply */
-
- /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
+ int inhcount; /* initial inheritance count to apply, for
+ * "raw" NOT NULL constraints */
bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
List *keys; /* String nodes naming referenced key
- * column(s); also used for NOT NULL */
+ * column(s); for UNIQUE/PK/NOT NULL */
bool without_overlaps; /* WITHOUT OVERLAPS specified */
List *including; /* String nodes naming referenced nonkey
- * column(s) */
-
- /* Fields used for EXCLUSION constraints: */
- List *exclusions; /* list of (IndexElem, operator name) pairs */
-
- /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */
+ * column(s); for UNIQUE/PK */
+ List *exclusions; /* list of (IndexElem, operator name) pairs;
+ * for exclusion constraints */
List *options; /* options from WITH clause */
char *indexname; /* existing index to use; otherwise NULL */
char *indexspace; /* index tablespace; NULL for default */
bool reset_default_tblspc; /* reset default_tablespace prior to
* creating the index */
- /* These could be, but currently are not, used for UNIQUE/PKEY: */
char *access_method; /* index access method; NULL for default */
Node *where_clause; /* partial index predicate */
@@ -2619,9 +2609,7 @@ typedef struct Constraint
Oid old_pktable_oid; /* pg_constraint.confrelid of my former
* self */
- /* Fields used for constraints that allow a NOT VALID specification */
- bool skip_validation; /* skip validation of existing rows? */
- bool initially_valid; /* mark the new constraint as valid? */
+ int location; /* token location, or -1 if unknown */
} Constraint;
/* ----------------------