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
defb10a4
Commit
defb10a4
authored
Oct 12, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEFAULT is handled by analyze.c now.
parent
c927f80f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
8 deletions
+87
-8
src/backend/executor/execMain.c
src/backend/executor/execMain.c
+5
-1
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+82
-7
No files found.
src/backend/executor/execMain.c
View file @
defb10a4
...
...
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.2
6 1997/09/18 20:20:29 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.2
7 1997/10/12 07:09:02 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1245,6 +1245,7 @@ ExecReplace(TupleTableSlot *slot,
ExecARUpdateTriggers
(
resultRelationDesc
,
tupleid
,
tuple
);
}
#if 0
static HeapTuple
ExecAttrDefault(Relation rel, HeapTuple tuple)
{
...
...
@@ -1309,6 +1310,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
return (newtuple);
}
#endif
static
char
*
ExecRelCheck
(
Relation
rel
,
HeapTuple
tuple
)
...
...
@@ -1375,8 +1377,10 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
Assert
(
rel
->
rd_att
->
constr
);
#if 0
if (rel->rd_att->constr->num_defval > 0)
newtuple = tuple = ExecAttrDefault(rel, tuple);
#endif
if
(
rel
->
rd_att
->
constr
->
has_not_null
)
{
...
...
src/backend/parser/analyze.c
View file @
defb10a4
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.4
4 1997/09/18 20:20:58 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.4
5 1997/10/12 07:09:20 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -303,6 +303,7 @@ static Query *
transformInsertStmt
(
ParseState
*
pstate
,
AppendStmt
*
stmt
)
{
Query
*
qry
=
makeNode
(
Query
);
/* make a new query tree */
List
*
icolumns
;
qry
->
commandType
=
CMD_INSERT
;
pstate
->
p_is_insert
=
true
;
...
...
@@ -313,10 +314,74 @@ transformInsertStmt(ParseState *pstate, AppendStmt *stmt)
qry
->
uniqueFlag
=
NULL
;
/* fix the target list */
pstate
->
p_insert_columns
=
makeTargetNames
(
pstate
,
stmt
->
cols
);
icolumns
=
pstate
->
p_insert_columns
=
makeTargetNames
(
pstate
,
stmt
->
cols
);
qry
->
targetList
=
transformTargetList
(
pstate
,
stmt
->
targetList
);
/* DEFAULT handling */
if
(
length
(
qry
->
targetList
)
<
pstate
->
p_target_relation
->
rd_att
->
natts
&&
pstate
->
p_target_relation
->
rd_att
->
constr
&&
pstate
->
p_target_relation
->
rd_att
->
constr
->
num_defval
>
0
)
{
AttributeTupleForm
*
att
=
pstate
->
p_target_relation
->
rd_att
->
attrs
;
AttrDefault
*
defval
=
pstate
->
p_target_relation
->
rd_att
->
constr
->
defval
;
int
ndef
=
pstate
->
p_target_relation
->
rd_att
->
constr
->
num_defval
;
/*
* if stmt->cols == NIL then makeTargetNames returns list of all
* attrs: have to shorter icolumns list...
*/
if
(
stmt
->
cols
==
NIL
)
{
List
*
extrl
;
int
i
=
length
(
qry
->
targetList
);
foreach
(
extrl
,
icolumns
)
{
if
(
--
i
<=
0
)
break
;
}
freeList
(
lnext
(
extrl
));
lnext
(
extrl
)
=
NIL
;
}
while
(
ndef
--
>
0
)
{
List
*
tl
;
Ident
*
id
;
TargetEntry
*
te
;
foreach
(
tl
,
icolumns
)
{
id
=
(
Ident
*
)
lfirst
(
tl
);
if
(
!
namestrcmp
(
&
(
att
[
defval
[
ndef
].
adnum
-
1
]
->
attname
),
id
->
name
))
break
;
}
if
(
tl
!=
NIL
)
/* something given for this attr */
continue
;
/*
* Nothing given for this attr with DEFAULT expr, so
* add new TargetEntry to qry->targetList.
* Note, that we set resno to defval[ndef].adnum:
* it's what transformTargetList()->make_targetlist_expr()
* does for INSERT ... SELECT. But for INSERT ... VALUES
* pstate->p_last_resno is used. It doesn't matter for
* "normal" using (planner creates proper target list
* in preptlist.c), but may break RULEs in some way.
* It seems better to create proper target list here...
*/
te
=
makeNode
(
TargetEntry
);
te
->
resdom
=
makeResdom
(
defval
[
ndef
].
adnum
,
att
[
defval
[
ndef
].
adnum
-
1
]
->
atttypid
,
att
[
defval
[
ndef
].
adnum
-
1
]
->
attlen
,
pstrdup
(
nameout
(
&
(
att
[
defval
[
ndef
].
adnum
-
1
]
->
attname
))),
0
,
0
,
0
);
te
->
fjoin
=
NULL
;
te
->
expr
=
(
Node
*
)
stringToNode
(
defval
[
ndef
].
adbin
);
qry
->
targetList
=
lappend
(
qry
->
targetList
,
te
);
}
}
/* fix where clause */
qry
->
qual
=
transformWhereClause
(
pstate
,
stmt
->
whereClause
);
...
...
@@ -1098,10 +1163,20 @@ makeTargetNames(ParseState *pstate, List *cols)
}
}
else
{
foreach
(
tl
,
cols
)
/* elog on failure */
varattno
(
pstate
->
p_target_relation
,
((
Ident
*
)
lfirst
(
tl
))
->
name
);
{
List
*
nxt
;
char
*
name
=
((
Ident
*
)
lfirst
(
tl
))
->
name
;
/* elog on failure */
varattno
(
pstate
->
p_target_relation
,
name
);
foreach
(
nxt
,
lnext
(
tl
))
if
(
!
strcmp
(
name
,
((
Ident
*
)
lfirst
(
nxt
))
->
name
))
elog
(
WARN
,
"Attribute %s should be specified only once"
,
name
);
}
}
return
cols
;
}
...
...
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