From b17b7fae8c1418f924915348afaa2250d1360bc4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 29 Oct 2007 19:40:40 +0000 Subject: Remove the hack in the grammar that "optimized away" DEFAULT NULL clauses. Instead put in a test to drop a NULL default at the last moment before storing the catalog entry. This changes the behavior in a couple of ways: * Specifying DEFAULT NULL when creating an inheritance child table will successfully suppress inheritance of any default expression from the parent's column, where formerly it failed to do so. * Specifying DEFAULT NULL for a column of a domain type will correctly override any default belonging to the domain; likewise for a sub-domain. The latter change happens because by the time the clause is checked, it won't be a simple null Const but a CoerceToDomain expression. Personally I think this should be back-patched, but there doesn't seem to be consensus for that on pgsql-hackers, so refraining. --- src/backend/parser/parse_expr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/backend/parser/parse_expr.c') diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 754e18d687c..86fddc4a7a6 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.221 2007/06/23 22:12:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.222 2007/10/29 19:40:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -606,6 +606,21 @@ transformParamRef(ParseState *pstate, ParamRef *pref) return (Node *) param; } +/* Test whether an a_expr is a plain NULL constant or not */ +static bool +exprIsNullConstant(Node *arg) +{ + if (arg && IsA(arg, A_Const)) + { + A_Const *con = (A_Const *) arg; + + if (con->val.type == T_Null && + con->typename == NULL) + return true; + } + return false; +} + static Node * transformAExprOp(ParseState *pstate, A_Expr *a) { -- cgit v1.2.3