1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-15 02:22:24 +03:00

Apply fixes for problems with dropped columns whose types have also been

dropped.  The simplest fix for INSERT/UPDATE cases turns out to be for
preptlist.c to insert NULLs of a known-good type (I used INT4) rather
than making them match the deleted column's type.  Since the representation
of NULL is actually datatype-independent, this should work fine.
I also re-reverted the patch to disable the use_physical_tlist optimization
in the presence of dropped columns.  It still doesn't look worth the
trouble to be smarter, if there are no other bugs to fix.
Added a regression test to catch future problems in this area.
This commit is contained in:
Tom Lane
2003-05-12 00:17:03 +00:00
parent a7c50cd92b
commit d97c9b3662
6 changed files with 167 additions and 27 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.81 2003/05/11 20:25:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.82 2003/05/12 00:17:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,8 +62,15 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
relation = heap_open(relationObjectId, AccessShareLock);
/*
* Make list of physical Vars. Note we do NOT ignore dropped columns;
* the intent is to model the physical tuples of the relation.
* Make list of physical Vars. But if there are any dropped columns,
* punt and set varlist to NIL. (XXX Ideally we would like to include
* dropped columns so that the varlist models the physical tuples
* of the relation. However this creates problems for ExecTypeFromTL,
* which may be asked to build a tupdesc for a tlist that includes vars
* of no-longer-existent types. In theory we could dig out the required
* info from the pg_attribute entries of the relation, but that data is
* not readily available to ExecTypeFromTL. For now, punt and don't
* apply the physical-tlist optimization when there are dropped cols.)
*/
numattrs = RelationGetNumberOfAttributes(relation);
@@ -71,6 +78,13 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
{
Form_pg_attribute att_tup = relation->rd_att->attrs[attrno - 1];
if (att_tup->attisdropped)
{
/* found a dropped col, so punt */
varlist = NIL;
break;
}
varlist = lappend(varlist,
makeVar(varno,
attrno,