mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Make eval_const_expressions() preserve typmod when simplifying something like
null::char(3) to a simple Const node. (It already worked for non-null values, but not when we skipped evaluation of a strict coercion function.) This prevents loss of typmod knowledge in situations such as exhibited in bug #3598. Unfortunately there seems no good way to fix that bug in 8.1 and 8.2, because they simply don't carry a typmod for a plain Const node. In passing I made all the other callers of makeNullConst supply "real" typmod values too, though I think it probably doesn't matter anywhere else.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.173 2007/03/19 23:38:29 wieck Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.174 2007/09/06 17:31:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -193,7 +193,7 @@ AcquireRewriteLocks(Query *parsetree)
|
||||
* now-dropped type OID, but it doesn't really
|
||||
* matter what type the Const claims to be.
|
||||
*/
|
||||
aliasvar = (Var *) makeNullConst(INT4OID);
|
||||
aliasvar = (Var *) makeNullConst(INT4OID, -1);
|
||||
}
|
||||
}
|
||||
newaliasvars = lappend(newaliasvars, aliasvar);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.104 2007/06/11 01:16:25 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.105 2007/09/06 17:31:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -896,7 +896,8 @@ resolve_one_var(Var *var, ResolveNew_context *context)
|
||||
{
|
||||
/* Otherwise replace unmatched var with a null */
|
||||
/* need coerce_to_domain in case of NOT NULL domain constraint */
|
||||
return coerce_to_domain((Node *) makeNullConst(var->vartype),
|
||||
return coerce_to_domain((Node *) makeNullConst(var->vartype,
|
||||
var->vartypmod),
|
||||
InvalidOid, -1,
|
||||
var->vartype,
|
||||
COERCE_IMPLICIT_CAST,
|
||||
|
Reference in New Issue
Block a user