OSDN Git Service

Reimplement parsing and storage of default expressions and constraint
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 3 Oct 1999 23:55:40 +0000 (23:55 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 3 Oct 1999 23:55:40 +0000 (23:55 +0000)
commiteabc714a916b772650c97b065ef27767dc5942e4
tree9271817f0a846e303ae8d32338b1d58a5c2754d5
parentf29ccc827006d13be0f4bf0255b06f3c4e921709
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.
18 files changed:
src/backend/access/common/tupdesc.c
src/backend/catalog/heap.c
src/backend/commands/command.c
src/backend/commands/creatinh.c
src/backend/commands/sequence.c
src/backend/commands/view.c
src/backend/nodes/outfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/relcache.c
src/include/access/tupdesc.h
src/include/catalog/heap.h
src/include/nodes/parsenodes.h
src/include/utils/builtins.h
src/include/utils/relcache.h
src/test/regress/input/constraints.source
src/test/regress/output/constraints.source