mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Fix UNION/INTERSECT/EXCEPT so that when two inputs being merged have
same data type and same typmod, we show that typmod as the output typmod, rather than generic -1. This responds to several complaints over the past few years about UNIONs unexpectedly dropping length or precision info.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.150 2006/08/02 01:59:45 joe Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.151 2006/08/10 02:36:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -813,6 +813,10 @@ recurse_pushdown_safe(Node *setOp, Query *topquery,
|
||||
* Compare tlist's datatypes against the list of set-operation result types.
|
||||
* For any items that are different, mark the appropriate element of
|
||||
* differentTypes[] to show that this column will have type conversions.
|
||||
*
|
||||
* We don't have to care about typmods here: the only allowed difference
|
||||
* between set-op input and output typmods is input is a specific typmod
|
||||
* and output is -1, and that does not require a coercion.
|
||||
*/
|
||||
static void
|
||||
compare_tlist_datatypes(List *tlist, List *colTypes,
|
||||
|
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.39 2006/07/14 14:52:21 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.40 2006/08/10 02:36:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -716,6 +716,7 @@ is_simple_union_all_recurse(Node *setOp, Query *setOpQuery, List *colTypes)
|
||||
Assert(subquery != NULL);
|
||||
|
||||
/* Leaf nodes are OK if they match the toplevel column types */
|
||||
/* We don't have to compare typmods here */
|
||||
return tlist_same_datatypes(subquery->targetList, colTypes, true);
|
||||
}
|
||||
else if (IsA(setOp, SetOperationStmt))
|
||||
|
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.132 2006/04/30 18:30:39 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.133 2006/08/10 02:36:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -152,6 +152,10 @@ plan_set_operations(PlannerInfo *root, double tuple_fraction,
|
||||
* flag: if >= 0, add a resjunk output column indicating value of flag
|
||||
* refnames_tlist: targetlist to take column names from
|
||||
* *sortClauses: receives list of SortClauses for result plan, if any
|
||||
*
|
||||
* We don't have to care about typmods here: the only allowed difference
|
||||
* between set-op input and output typmods is input is a specific typmod
|
||||
* and output is -1, and that does not require a coercion.
|
||||
*/
|
||||
static Plan *
|
||||
recurse_set_operations(Node *setOp, PlannerInfo *root,
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.72 2006/03/05 15:58:32 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.73 2006/08/10 02:36:29 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -174,6 +174,8 @@ get_sortgrouplist_exprs(List *sortClauses, List *targetList)
|
||||
*
|
||||
* Resjunk columns are ignored if junkOK is true; otherwise presence of
|
||||
* a resjunk column will always cause a 'false' result.
|
||||
*
|
||||
* Note: currently no callers care about comparing typmods.
|
||||
*/
|
||||
bool
|
||||
tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK)
|
||||
|
Reference in New Issue
Block a user