mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Code review for domain-constraints patch. Use a new ConstraintTest node
type for runtime constraint checks, instead of misusing the parse-time Constraint node for the purpose. Fix some damage introduced into type coercion logic; in particular ensure that a coerced expression tree will read out the correct result type when inspected (patch had broken some RelabelType cases). Enforce domain NOT NULL constraints against columns that are omitted from an INSERT.
This commit is contained in:
@@ -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.203 2002/08/30 19:23:20 tgl Exp $
|
||||
* $Id: parsenodes.h,v 1.204 2002/08/31 22:10:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -233,14 +233,13 @@ typedef struct NullTest
|
||||
NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
|
||||
} NullTest;
|
||||
|
||||
/* ----------------
|
||||
/*
|
||||
* BooleanTest
|
||||
*
|
||||
* BooleanTest represents the operation of determining whether a boolean
|
||||
* is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
|
||||
* are supported. Note that a NULL input does *not* cause a NULL result.
|
||||
* The appropriate test is performed and returned as a boolean Datum.
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
typedef enum BoolTestType
|
||||
@@ -255,6 +254,29 @@ typedef struct BooleanTest
|
||||
BoolTestType booltesttype; /* test type */
|
||||
} BooleanTest;
|
||||
|
||||
/*
|
||||
* ConstraintTest
|
||||
*
|
||||
* ConstraintTest represents the operation of testing a value to see whether
|
||||
* it meets a constraint. If so, the input value is returned as the result;
|
||||
* if not, an error is raised.
|
||||
*/
|
||||
|
||||
typedef enum ConstraintTestType
|
||||
{
|
||||
CONSTR_TEST_NOTNULL,
|
||||
CONSTR_TEST_CHECK
|
||||
} ConstraintTestType;
|
||||
|
||||
typedef struct ConstraintTest
|
||||
{
|
||||
NodeTag type;
|
||||
Node *arg; /* input expression */
|
||||
ConstraintTestType testtype; /* test type */
|
||||
char *name; /* name of constraint (for error msgs) */
|
||||
Node *check_expr; /* for CHECK test, a boolean expression */
|
||||
} ConstraintTest;
|
||||
|
||||
/*
|
||||
* ColumnDef - column definition (used in various creates)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user