mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Fix ALTER TABLE / SET TYPE for irregular inheritance
If inherited tables don't have exactly the same schema, the USING clause
in an ALTER TABLE / SET DATA TYPE misbehaves when applied to the
children tables since commit 9550e8348b. Starting with that commit,
the attribute numbers in the USING expression are fixed during parse
analysis. This can lead to bogus errors being reported during
execution, such as:
ERROR: attribute 2 has wrong type
DETAIL: Table has type smallint, but query expects integer.
Since it wouldn't do to revert to the original coding, we now apply a
transformation to map the attribute numbers to the correct ones for each
child.
Reported by Justin Pryzby
Analysis by Tom Lane; patch by me.
Discussion: https://postgr.es/m/20170102225618.GA10071@telsasoft.com
This commit is contained in:
@@ -38,6 +38,10 @@ extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc,
|
||||
TupleDesc outdesc,
|
||||
const char *msg);
|
||||
|
||||
extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
|
||||
TupleDesc outdesc,
|
||||
const char *msg);
|
||||
|
||||
extern HeapTuple do_convert_tuple(HeapTuple tuple, TupleConversionMap *map);
|
||||
|
||||
extern void free_conversion_map(TupleConversionMap *map);
|
||||
|
||||
Reference in New Issue
Block a user