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
600c958a
Commit
600c958a
authored
Jan 11, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UNION, GROUP, DISTINCT to INSERT.
parent
d70df16a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
10 deletions
+46
-10
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+20
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+17
-6
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+6
-1
src/man/insert.l
src/man/insert.l
+3
-1
No files found.
src/backend/parser/analyze.c
View file @
600c958a
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.6
3 1998/01/10 04:29:47
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.6
4 1998/01/11 03:41:35
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -241,7 +241,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
/* set up a range table */
makeRangeTable
(
pstate
,
stmt
->
relname
,
stmt
->
fromClause
);
qry
->
uniqueFlag
=
NULL
;
qry
->
uniqueFlag
=
stmt
->
unique
;
/* fix the target list */
icolumns
=
pstate
->
p_insert_columns
=
makeTargetNames
(
pstate
,
stmt
->
cols
);
...
...
@@ -315,13 +315,31 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
/* fix where clause */
qry
->
qual
=
transformWhereClause
(
pstate
,
stmt
->
whereClause
);
/* check having clause */
if
(
stmt
->
havingClause
)
elog
(
NOTICE
,
"HAVING not yet supported; ignore clause"
,
NULL
);
/* now the range table will not change */
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
stmt
->
relname
);
qry
->
groupClause
=
transformGroupClause
(
pstate
,
stmt
->
groupClause
,
qry
->
targetList
);
/* fix order clause */
qry
->
sortClause
=
transformSortClause
(
pstate
,
NIL
,
NIL
,
qry
->
targetList
,
qry
->
uniqueFlag
);
if
(
pstate
->
p_numAgg
>
0
)
finalizeAggregates
(
pstate
,
qry
);
qry
->
unionall
=
stmt
->
unionall
;
/* in child, so unionClause may be false */
qry
->
unionClause
=
transformUnionClause
(
stmt
->
unionClause
,
qry
->
targetList
);
return
(
Query
*
)
qry
;
}
...
...
src/backend/parser/gram.y
View file @
600c958a
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.8
8 1998/01/10 04:29:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.8
9 1998/01/11 03:41:38
momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -2146,16 +2146,27 @@ InsertStmt: INSERT INTO relation_name opt_column_list insert_rest
insert_rest: VALUES '(' res_target_list2 ')'
{
$$ = makeNode(InsertStmt);
$$->unique = NULL;
$$->targetList = $3;
$$->fromClause = NIL;
$$->whereClause = NULL;
$$->whereClause = NIL;
$$->groupClause = NIL;
$$->havingClause = NIL;
$$->unionClause = NIL;
}
| SELECT res_target_list2 from_clause where_clause
| SELECT opt_unique res_target_list2
from_clause where_clause
group_clause having_clause
union_clause
{
$$ = makeNode(InsertStmt);
$$->targetList = $2;
$$->fromClause = $3;
$$->whereClause = $4;
$$->unique = $2;
$$->targetList = $3;
$$->fromClause = $4;
$$->whereClause = $5;
$$->groupClause = $6;
$$->havingClause = $7;
$$->unionClause = $8;
}
;
...
...
src/include/nodes/parsenodes.h
View file @
600c958a
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.4
2 1998/01/10 04:30:11
momjian Exp $
* $Id: parsenodes.h,v 1.4
3 1998/01/11 03:41:49
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -574,10 +574,15 @@ typedef struct InsertStmt
{
NodeTag
type
;
char
*
relname
;
/* relation to insert into */
char
*
unique
;
/* NULL, '*', or unique attribute name */
List
*
cols
;
/* names of the columns */
List
*
targetList
;
/* the target list (of ResTarget) */
List
*
fromClause
;
/* the from clause */
Node
*
whereClause
;
/* qualifications */
List
*
groupClause
;
/* group by clause */
Node
*
havingClause
;
/* having conditional-expression */
List
*
unionClause
;
/* union subselect parameters */
bool
unionall
;
/* union without unique sort */
}
InsertStmt
;
/* ----------------------
...
...
src/man/insert.l
View file @
600c958a
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/insert.l,v 1.
5 1997/09/27 03:14:19
momjian Exp $
.\" $Header: /cvsroot/pgsql/src/man/Attic/insert.l,v 1.
6 1998/01/11 03:41:57
momjian Exp $
.TH INSERT SQL 11/05/95 PostgreSQL PostgreSQL
.SH NAME
insert \(em insert tuples to a relation
...
...
@@ -11,6 +11,8 @@ insert \(em insert tuples to a relation
{\fBvalues\fR (expression1 [,expression-i] ) |
\fBselect\fR expression1 [,expression-i]
[\fBfrom\fR from-list] [\fBwhere\fR qual]
[\fBgroup by\fR attr_name1 {, attr_name-i....}]
[\fBunion {all} select\fR ...]
.fi
.SH DESCRIPTION
.BR Insert
...
...
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