*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.231 2007/08/21 01:11:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.232 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (!defval && GetDomainConstraints(typeOid) != NIL)
{
- Oid basetype = getBaseType(typeOid);
+ Oid baseTypeId;
+ int32 baseTypeMod;
- defval = (Expr *) makeNullConst(basetype);
+ baseTypeMod = typmod;
+ baseTypeId = getBaseTypeAndTypmod(typeOid, &baseTypeMod);
+ defval = (Expr *) makeNullConst(baseTypeId, baseTypeMod);
defval = (Expr *) coerce_to_target_type(NULL,
(Node *) defval,
- basetype,
+ baseTypeId,
typeOid,
typmod,
COERCION_ASSIGNMENT,
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.221 2007/08/31 18:33:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.222 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* don't really care what type of NULL it is, so
* always make an int4 NULL.
*/
- e = (Expr *) makeNullConst(INT4OID);
+ e = (Expr *) makeNullConst(INT4OID, -1);
}
estate = ExecInitExpr(e, parent);
outlist = lappend(outlist, estate);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.56 2007/06/23 22:12:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.57 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* makeNullConst -
- * creates a Const node representing a NULL of the specified type
+ * creates a Const node representing a NULL of the specified type/typmod
*
- * Note: for all current uses, OK to set typmod of the Const to -1.
+ * This is a convenience routine that just saves a lookup of the type's
+ * storage properties.
*/
Const *
-makeNullConst(Oid consttype)
+makeNullConst(Oid consttype, int32 consttypmod)
{
int16 typLen;
bool typByVal;
get_typlenbyval(consttype, &typLen, &typByVal);
return makeConst(consttype,
- -1,
+ consttypmod,
(int) typLen,
(Datum) 0,
true,
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.248 2007/09/03 00:39:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.249 2007/09/06 17:31:58 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
/* If all the arguments were constant null, the result is just null */
if (newargs == NIL)
- return (Node *) makeNullConst(coalesceexpr->coalescetype);
+ return (Node *) makeNullConst(coalesceexpr->coalescetype, -1);
newcoalesce = makeNode(CoalesceExpr);
newcoalesce->coalescetype = coalesceexpr->coalescetype;
* function is not otherwise immutable.
*/
if (funcform->proisstrict && has_null_input)
- return (Expr *) makeNullConst(result_type);
+ return (Expr *) makeNullConst(result_type, result_typmod);
/*
* Otherwise, can simplify only if all inputs are constants. (For a
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.156 2007/08/21 01:11:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.157 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* can't use atttypid here, but it doesn't really matter what type
* the Const claims to be.
*/
- newargs = lappend(newargs, makeNullConst(INT4OID));
+ newargs = lappend(newargs, makeNullConst(INT4OID, -1));
continue;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.127 2007/01/05 22:19:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.128 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* can't use atttypid here, but it doesn't really matter
* what type the Const claims to be.
*/
- *colvars = lappend(*colvars, makeNullConst(INT4OID));
+ *colvars = lappend(*colvars, makeNullConst(INT4OID, -1));
}
}
continue;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.154 2007/02/03 14:06:54 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.155 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* is not really a source value to work with. Insert a NULL
* constant as the source value.
*/
- colVar = (Node *) makeNullConst(attrtype);
+ colVar = (Node *) makeNullConst(attrtype, attrtypmod);
}
else
{
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
{
/* 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,
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.59 2007/06/23 22:12:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.60 2007/09/06 17:31:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
bool constisnull,
bool constbyval);
-extern Const *makeNullConst(Oid consttype);
+extern Const *makeNullConst(Oid consttype, int32 consttypmod);
extern Node *makeBoolConst(bool value, bool isnull);