Re: ALTER TABLE ADD COLUMN fast default
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>,
Andres Freund <andres@anarazel.de>,
David Rowley <david.rowley@2ndquadrant.com>,
Thomas Munro <thomas.munro@enterprisedb.com>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-04-04T02:09:51Z
Lists: pgsql-hackers
Andrew Gierth <andrew@tao11.riddles.org.uk> writes: > I just got through diagnosing a SEGV crash with someone on IRC, and the > cause turned out to be exactly this - a table had (for some reason we > could not determine within the available resources) lost its pg_attrdef > record for the one column it had with a default (which was a serial > column, so none of the fast-default code is actually implicated). Any > attempt to alter the table resulted in a crash in equalTupleDesc on this > line: > if (strcmp(defval1->adbin, defval2->adbin) != 0) > due to trying to compare adbin values which were NULL pointers. Ouch. > Does equalTupleDesc need to be more defensive about this, or does the > above check need to be reinstated? Looking around at the other touches of AttrDefault.adbin in the backend (of which there are not that many), some of them are prepared for it to be NULL and some are not. I don't immediately have a strong opinion whether that should be an allowed state; but if it is not allowed then it's not okay for AttrDefaultFetch to leave such a state behind. Alternatively, if it is allowed then equalTupleDesc is in the wrong. We should choose one definition and make all the relevant code match it. regards, tom lane
Commits
-
Clean up treatment of missing default and CHECK-constraint records.
- 091e22b2e673 14.0 landed
-
Fast ALTER TABLE ADD COLUMN with a non-NULL default
- 16828d5c0273 11.0 landed
-
Fix application of identity values in some cases
- 533c5d8bddf0 11.0 cited