Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1a8790f7
Commit
1a8790f7
authored
Dec 13, 1998
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new implicit type coersion techniques for matching up types
between columns and DEFAULT clauses.
parent
23cebf11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+24
-1
No files found.
src/backend/catalog/heap.c
View file @
1a8790f7
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.6
7 1998/11/27 19:51:48 vadim
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.6
8 1998/12/13 23:50:58 thomas
Exp $
*
* INTERFACE ROUTINES
* heap_create() - Create an uncataloged heap relation
...
...
@@ -1434,6 +1434,7 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef)
TargetEntry
*
te
;
Resdom
*
resdom
;
Node
*
expr
;
Oid
type
;
char
*
adbin
;
MemoryContext
oldcxt
;
Relation
adrel
;
...
...
@@ -1460,7 +1461,9 @@ start:;
te
=
(
TargetEntry
*
)
lfirst
(
query
->
targetList
);
resdom
=
te
->
resdom
;
expr
=
te
->
expr
;
type
=
exprType
(
expr
);
#if 0
if (IsA(expr, Const))
{
if (((Const *) expr)->consttype != atp->atttypid)
...
...
@@ -1474,6 +1477,26 @@ start:;
else if ((exprType(expr) != atp->atttypid)
&& !IS_BINARY_COMPATIBLE(exprType(expr), atp->atttypid))
elog(ERROR, "DEFAULT: type mismatched");
#endif
if
(
type
!=
atp
->
atttypid
)
{
if
(
IS_BINARY_COMPATIBLE
(
type
,
atp
->
atttypid
))
;
/* use without change */
else
if
(
can_coerce_type
(
1
,
&
(
type
),
&
(
atp
->
atttypid
)))
expr
=
coerce_type
(
NULL
,
(
Node
*
)
expr
,
type
,
atp
->
atttypid
);
else
if
(
IsA
(
expr
,
Const
))
{
if
(
*
cast
!=
0
)
elog
(
ERROR
,
"DEFAULT clause const type '%s' mismatched with column type '%s'"
,
typeidTypeName
(
type
),
typeidTypeName
(
atp
->
atttypid
));
sprintf
(
cast
,
":: %s"
,
typeidTypeName
(
atp
->
atttypid
));
goto
start
;
}
else
elog
(
ERROR
,
"DEFAULT clause type '%s' mismatched with column type '%s'"
,
typeidTypeName
(
type
),
typeidTypeName
(
atp
->
atttypid
));
}
adbin
=
nodeToString
(
expr
);
oldcxt
=
MemoryContextSwitchTo
((
MemoryContext
)
CacheCxt
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment