Remove the hack in the grammar that "optimized away" DEFAULT NULL clauses.
Tom Lane <tgl@sss.pgh.pa.us>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/catalog/heap.c | modified | +16 −1 |
| src/backend/commands/typecmds.c | modified | +62 −26 |
| src/backend/parser/gram.y | modified | +3 −35 |
| src/backend/parser/parse_expr.c | modified | +16 −1 |
| src/backend/parser/parse_utilcmd.c | modified | +1 −2 |
| src/include/parser/gramparse.h | modified | +1 −2 |
| src/test/regress/expected/domain.out | modified | +9 −1 |
| src/test/regress/sql/domain.sql | modified | +7 −1 |