mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Add DOMAIN support. Includes manual pages and regression tests, from
Rod Taylor.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.48 2002/03/07 16:35:35 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.49 2002/03/19 02:18:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -355,8 +355,6 @@ build_column_default(Relation rel, int attrno)
|
||||
Form_pg_attribute att_tup = rd_att->attrs[attrno - 1];
|
||||
Oid atttype = att_tup->atttypid;
|
||||
int32 atttypmod = att_tup->atttypmod;
|
||||
bool hasdefault;
|
||||
Datum typedefault;
|
||||
int16 typlen;
|
||||
bool typbyval;
|
||||
Node *expr;
|
||||
@@ -392,7 +390,7 @@ build_column_default(Relation rel, int attrno)
|
||||
if (type_id != atttype)
|
||||
{
|
||||
expr = CoerceTargetExpr(NULL, expr, type_id,
|
||||
atttype, atttypmod);
|
||||
getBaseType(atttype), atttypmod);
|
||||
|
||||
/*
|
||||
* This really shouldn't fail; should have checked the
|
||||
@@ -430,41 +428,53 @@ build_column_default(Relation rel, int attrno)
|
||||
* element type is, and the element type's default is irrelevant
|
||||
* too.
|
||||
*/
|
||||
hasdefault = false;
|
||||
typedefault = (Datum) 0;
|
||||
typlen = sizeof(Oid);
|
||||
typbyval = true;
|
||||
|
||||
expr = (Node *) makeConst(atttype,
|
||||
typlen,
|
||||
(Datum) 0,
|
||||
true,
|
||||
typbyval,
|
||||
false, /* not a set */
|
||||
false);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _DROP_COLUMN_HACK__
|
||||
if (COLUMN_IS_DROPPED(att_tup))
|
||||
{
|
||||
hasdefault = false;
|
||||
typedefault = (Datum) 0;
|
||||
|
||||
expr = (Node *) makeConst(atttype,
|
||||
typlen,
|
||||
(Datum) 0,
|
||||
true,
|
||||
typbyval,
|
||||
false, /* not a set */
|
||||
false);
|
||||
}
|
||||
else
|
||||
#endif /* _DROP_COLUMN_HACK__ */
|
||||
hasdefault = get_typdefault(atttype, &typedefault);
|
||||
expr = get_typdefault(atttype, atttypmod);
|
||||
|
||||
if (expr == NULL) {
|
||||
expr = (Node *) makeConst(atttype,
|
||||
typlen,
|
||||
(Datum) 0,
|
||||
true,
|
||||
typbyval,
|
||||
false, /* not a set */
|
||||
false);
|
||||
}
|
||||
get_typlenbyval(atttype, &typlen, &typbyval);
|
||||
}
|
||||
|
||||
expr = (Node *) makeConst(atttype,
|
||||
typlen,
|
||||
typedefault,
|
||||
!hasdefault,
|
||||
typbyval,
|
||||
false, /* not a set */
|
||||
false);
|
||||
|
||||
/*
|
||||
* If the column is a fixed-length type, it may need a length coercion
|
||||
* as well as a type coercion. But NULLs don't need that.
|
||||
* as well as a type coercion, as well as direction to the final type.
|
||||
*/
|
||||
if (hasdefault)
|
||||
expr = coerce_type_typmod(NULL, expr,
|
||||
atttype, atttypmod);
|
||||
expr = coerce_type_typmod(NULL, expr,
|
||||
atttype, atttypmod);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user