mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
Reimplement parsing and storage of default expressions and constraint
expressions in CREATE TABLE. There is no longer an emasculated expression syntax for these things; it's full a_expr for constraints, and b_expr for defaults (unfortunately the fact that NOT NULL is a part of the column constraint syntax causes a shift/reduce conflict if you try a_expr. Oh well --- at least parenthesized boolean expressions work now). Also, stored expression for a column default is not pre-coerced to the column type; we rely on transformInsertStatement to do that when the default is actually used. This means "f1 datetime default 'now'" behaves the way people usually expect it to. BTW, all the support code is now there to implement ALTER TABLE ADD CONSTRAINT and ALTER TABLE ADD COLUMN with a default value. I didn't actually teach ALTER TABLE to call it, but it wouldn't be much work.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: tupdesc.h,v 1.24 1999/07/16 17:07:28 momjian Exp $
|
||||
* $Id: tupdesc.h,v 1.25 1999/10/03 23:55:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -21,22 +21,20 @@
|
||||
typedef struct attrDefault
|
||||
{
|
||||
AttrNumber adnum;
|
||||
char *adbin;
|
||||
char *adsrc;
|
||||
char *adbin; /* nodeToString representation of expr */
|
||||
} AttrDefault;
|
||||
|
||||
typedef struct constrCheck
|
||||
{
|
||||
char *ccname;
|
||||
char *ccbin;
|
||||
char *ccsrc;
|
||||
char *ccbin; /* nodeToString representation of expr */
|
||||
} ConstrCheck;
|
||||
|
||||
/* This structure contains constraints of a tuple */
|
||||
typedef struct tupleConstr
|
||||
{
|
||||
AttrDefault *defval;
|
||||
ConstrCheck *check;
|
||||
AttrDefault *defval; /* array */
|
||||
ConstrCheck *check; /* array */
|
||||
uint16 num_defval;
|
||||
uint16 num_check;
|
||||
bool has_not_null;
|
||||
|
Reference in New Issue
Block a user