Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5b5f0d

Browse files
author
Thomas G. Lockhart
committed
Use the new implicit type coersion techniques for matching up types
between columns and DEFAULT clauses.
1 parent3f1c32e commitb5b5f0d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎src/backend/catalog/heap.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.64.2.2 1998/11/17 14:42:52 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.64.2.3 1998/12/14 00:13:26 thomas Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*heap_create()- Create an uncataloged heap relation
@@ -1434,6 +1434,7 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef)
14341434
TargetEntry*te;
14351435
Resdom*resdom;
14361436
Node*expr;
1437+
Oidtype;
14371438
char*adbin;
14381439
MemoryContextoldcxt;
14391440
Relationadrel;
@@ -1460,7 +1461,9 @@ start:;
14601461
te= (TargetEntry*)lfirst(query->targetList);
14611462
resdom=te->resdom;
14621463
expr=te->expr;
1464+
type=exprType(expr);
14631465

1466+
#if0
14641467
if (IsA(expr,Const))
14651468
{
14661469
if (((Const*)expr)->consttype!=atp->atttypid)
@@ -1474,6 +1477,26 @@ start:;
14741477
elseif ((exprType(expr)!=atp->atttypid)
14751478
&& !IS_BINARY_COMPATIBLE(exprType(expr),atp->atttypid))
14761479
elog(ERROR,"DEFAULT: type mismatched");
1480+
#endif
1481+
1482+
if (type!=atp->atttypid)
1483+
{
1484+
if (IS_BINARY_COMPATIBLE(type,atp->atttypid))
1485+
;/* use without change */
1486+
elseif (can_coerce_type(1,&(type),&(atp->atttypid)))
1487+
expr=coerce_type(NULL, (Node*)expr,type,atp->atttypid);
1488+
elseif (IsA(expr,Const))
1489+
{
1490+
if (*cast!=0)
1491+
elog(ERROR,"DEFAULT clause const type '%s' mismatched with column type '%s'",
1492+
typeidTypeName(type),typeidTypeName(atp->atttypid));
1493+
sprintf(cast,":: %s",typeidTypeName(atp->atttypid));
1494+
gotostart;
1495+
}
1496+
else
1497+
elog(ERROR,"DEFAULT clause type '%s' mismatched with column type '%s'",
1498+
typeidTypeName(type),typeidTypeName(atp->atttypid));
1499+
}
14771500

14781501
adbin=nodeToString(expr);
14791502
oldcxt=MemoryContextSwitchTo((MemoryContext)CacheCxt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp