Skip to content

Commit 0a8510e

Browse files
committed
Fix failure to apply domain constraints to a NULL constant that's added to
an INSERT target list during rule rewriting. Per report from John Supplee.
1 parent 38e75d9 commit 0a8510e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backend/rewrite/rewriteManip.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.94 2005/11/23 17:21:03 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.95 2006/01/06 20:11:12 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,6 +18,7 @@
1818
#include "optimizer/clauses.h"
1919
#include "optimizer/tlist.h"
2020
#include "parser/parsetree.h"
21+
#include "parser/parse_coerce.h"
2122
#include "parser/parse_relation.h"
2223
#include "rewrite/rewriteManip.h"
2324
#include "utils/lsyscache.h"
@@ -838,7 +839,13 @@ resolve_one_var(Var *var, ResolveNew_context *context)
838839
else
839840
{
840841
/* Otherwise replace unmatched var with a null */
841-
return (Node *) makeNullConst(var->vartype);
842+
/* need coerce_to_domain in case of NOT NULL domain constraint */
843+
return coerce_to_domain((Node *) makeNullConst(var->vartype),
844+
InvalidOid,
845+
var->vartype,
846+
COERCE_IMPLICIT_CAST,
847+
false,
848+
false);
842849
}
843850
}
844851
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy