aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-10-03 23:55:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-10-03 23:55:40 +0000
commiteabc714a916b772650c97b065ef27767dc5942e4 (patch)
tree9271817f0a846e303ae8d32338b1d58a5c2754d5 /src/backend/nodes/outfuncs.c
parentf29ccc827006d13be0f4bf0255b06f3c4e921709 (diff)
downloadpostgresql-eabc714a916b772650c97b065ef27767dc5942e4.tar.gz
postgresql-eabc714a916b772650c97b065ef27767dc5942e4.zip
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.
Diffstat (limited to 'src/backend/nodes/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 13e32ed54fe..6b1e560014f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: outfuncs.c,v 1.95 1999/08/31 01:28:32 tgl Exp $
+ * $Id: outfuncs.c,v 1.96 1999/10/03 23:55:29 tgl Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -124,10 +124,12 @@ _outColumnDef(StringInfo str, ColumnDef *node)
appendStringInfo(str, " COLUMNDEF :colname %s :typename ",
stringStringInfo(node->colname));
_outNode(str, node->typename);
-
- appendStringInfo(str, " :is_not_null %s :defval %s :constraints ",
+ appendStringInfo(str, " :is_not_null %s :is_sequence %s :raw_default ",
node->is_not_null ? "true" : "false",
- stringStringInfo(node->defval));
+ node->is_sequence ? "true" : "false");
+ _outNode(str, node->raw_default);
+ appendStringInfo(str, " :cooked_default %s :constraints ",
+ stringStringInfo(node->cooked_default));
_outNode(str, node->constraints);
}
@@ -1216,11 +1218,17 @@ _outConstraint(StringInfo str, Constraint *node)
break;
case CONSTR_CHECK:
- appendStringInfo(str, " CHECK %s", stringStringInfo(node->def));
+ appendStringInfo(str, " CHECK :raw ");
+ _outNode(str, node->raw_expr);
+ appendStringInfo(str, " :cooked %s ",
+ stringStringInfo(node->cooked_expr));
break;
case CONSTR_DEFAULT:
- appendStringInfo(str, " DEFAULT %s", stringStringInfo(node->def));
+ appendStringInfo(str, " DEFAULT :raw ");
+ _outNode(str, node->raw_expr);
+ appendStringInfo(str, " :cooked %s ",
+ stringStringInfo(node->cooked_expr));
break;
case CONSTR_NOTNULL:
@@ -1236,7 +1244,6 @@ _outConstraint(StringInfo str, Constraint *node)
appendStringInfo(str, "<unrecognized constraint>");
break;
}
- return;
}
static void