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
a01b085c
Commit
a01b085c
authored
Dec 29, 1997
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup of UNION ALL fix. Manual page updates.
parent
4ce24c8a
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
277 additions
and
259 deletions
+277
-259
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/planner.c
+5
-9
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/prep/prepunion.c
+223
-159
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+4
-71
src/backend/parser/parse_clause.c
src/backend/parser/parse_clause.c
+27
-1
src/bin/psql/psqlHelp.h
src/bin/psql/psqlHelp.h
+7
-2
src/include/optimizer/prep.h
src/include/optimizer/prep.h
+4
-12
src/include/parser/parse_clause.h
src/include/parser/parse_clause.h
+2
-1
src/man/select.l
src/man/select.l
+5
-4
No files found.
src/backend/optimizer/plan/planner.c
View file @
a01b085c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.1
7 1997/12/27 06:41:07
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.1
8 1997/12/29 01:12:45
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -76,14 +76,12 @@ planner(Query *parse)
...
@@ -76,14 +76,12 @@ planner(Query *parse)
Plan
*
result_plan
=
(
Plan
*
)
NULL
;
Plan
*
result_plan
=
(
Plan
*
)
NULL
;
List
*
primary_qual
;
List
*
primary_qual
;
int
rt_index
;
Index
rt_index
;
if
(
parse
->
unionClause
)
if
(
parse
->
unionClause
)
{
{
result_plan
=
(
Plan
*
)
plan_union_queries
(
0
,
/* none */
result_plan
=
(
Plan
*
)
plan_union_queries
(
parse
);
parse
,
UNION_FLAG
);
/* XXX do we need to do this? bjm 12/19/97 */
/* XXX do we need to do this? bjm 12/19/97 */
tlist
=
preprocess_targetlist
(
tlist
,
tlist
=
preprocess_targetlist
(
tlist
,
parse
->
commandType
,
parse
->
commandType
,
...
@@ -91,11 +89,9 @@ planner(Query *parse)
...
@@ -91,11 +89,9 @@ planner(Query *parse)
parse
->
rtable
);
parse
->
rtable
);
}
}
else
if
((
rt_index
=
else
if
((
rt_index
=
first_
matching_rt_entry
(
rangetable
,
INHERITS_FLAG
))
!=
-
1
)
first_
inherit_rt_entry
(
rangetable
))
!=
-
1
)
{
{
result_plan
=
(
Plan
*
)
plan_union_queries
((
Index
)
rt_index
,
result_plan
=
(
Plan
*
)
plan_inherit_queries
(
parse
,
rt_index
);
parse
,
INHERITS_FLAG
);
/* XXX do we need to do this? bjm 12/19/97 */
/* XXX do we need to do this? bjm 12/19/97 */
tlist
=
preprocess_targetlist
(
tlist
,
tlist
=
preprocess_targetlist
(
tlist
,
parse
->
commandType
,
parse
->
commandType
,
...
...
src/backend/optimizer/prep/prepunion.c
View file @
a01b085c
This diff is collapsed.
Click to expand it.
src/backend/parser/analyze.c
View file @
a01b085c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.5
7 1997/12/27 06:41:26
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.5
8 1997/12/29 01:12:55
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -840,77 +840,10 @@ transformSelectStmt(ParseState *pstate, RetrieveStmt *stmt)
...
@@ -840,77 +840,10 @@ transformSelectStmt(ParseState *pstate, RetrieveStmt *stmt)
finalizeAggregates
(
pstate
,
qry
);
finalizeAggregates
(
pstate
,
qry
);
qry
->
unionall
=
stmt
->
unionall
;
/* in child, so unionClause may be false */
qry
->
unionall
=
stmt
->
unionall
;
/* in child, so unionClause may be false */
qry
->
unionClause
=
transformUnionClause
(
stmt
->
unionClause
,
qry
->
targetList
);
if
(
stmt
->
unionClause
)
if
(
qry
->
unionClause
&&
stmt
->
sortClause
)
{
elog
(
WARN
,
"You can not use ORDER BY with UNION"
,
NULL
);
List
*
ulist
=
NIL
;
QueryTreeList
*
qlist
;
int
i
,
last_union
=
-
1
;
bool
union_all_found
=
false
,
union_found
=
false
;
qlist
=
parse_analyze
(
stmt
->
unionClause
);
/*
* Do we need to split up our unions because we have UNION
* and UNION ALL?
*/
for
(
i
=
0
;
i
<
qlist
->
len
;
i
++
)
{
if
(
qlist
->
qtrees
[
i
]
->
unionall
)
union_all_found
=
true
;
else
{
union_found
=
true
;
last_union
=
i
;
}
}
/* A trailing UNION negates the affect of earlier UNION ALLs */
if
(
!
union_all_found
||
!
union_found
||
/* last entry is a UNION */
!
qlist
->
qtrees
[
qlist
->
len
-
1
]
->
unionall
)
{
for
(
i
=
0
;
i
<
qlist
->
len
;
i
++
)
ulist
=
lappend
(
ulist
,
qlist
->
qtrees
[
i
]);
qry
->
unionClause
=
ulist
;
}
else
{
List
*
union_list
=
NIL
;
Query
*
hold_qry
;
/*
* We have mixed unions and non-unions, so we concentrate on
* the last UNION in the list.
*/
for
(
i
=
0
;
i
<=
last_union
;
i
++
)
{
qlist
->
qtrees
[
i
]
->
unionall
=
false
;
/*make queries consistent*/
union_list
=
lappend
(
union_list
,
qlist
->
qtrees
[
i
]);
}
/*
* Make the first UNION ALL after the last UNION our new
* top query
*/
hold_qry
=
qry
;
qry
=
qlist
->
qtrees
[
last_union
+
1
];
qry
->
unionClause
=
lcons
(
hold_qry
,
NIL
);
/* UNION queries */
hold_qry
->
unionall
=
true
;
/* UNION ALL this into other queries */
hold_qry
->
unionClause
=
union_list
;
/*
* The first UNION ALL after the last UNION is our anchor,
* we skip it.
*/
for
(
i
=
last_union
+
2
;
i
<
qlist
->
len
;
i
++
)
/* all queries are UNION ALL */
qry
->
unionClause
=
lappend
(
qry
->
unionClause
,
qlist
->
qtrees
[
i
]);
}
}
else
qry
->
unionClause
=
NULL
;
return
(
Query
*
)
qry
;
return
(
Query
*
)
qry
;
}
}
...
...
src/backend/parser/parse_clause.c
View file @
a01b085c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.
3 1997/11/26 03:42:39
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.
4 1997/12/29 01:12:58
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "postgres.h"
#include "postgres.h"
#include "access/heapam.h"
#include "access/heapam.h"
#include "catalog/pg_type.h"
#include "catalog/pg_type.h"
#include "parser/analyze.h"
#include "parser/parse_clause.h"
#include "parser/parse_clause.h"
#include "parser/parse_expr.h"
#include "parser/parse_expr.h"
#include "parser/parse_node.h"
#include "parser/parse_node.h"
...
@@ -371,3 +372,28 @@ transformSortClause(ParseState *pstate,
...
@@ -371,3 +372,28 @@ transformSortClause(ParseState *pstate,
return
sortlist
;
return
sortlist
;
}
}
/*
* transformUnionClause -
* transform a Union clause
*
*/
List
*
transformUnionClause
(
List
*
unionClause
,
List
*
targetlist
)
{
List
*
union_list
=
NIL
;
QueryTreeList
*
qlist
;
int
i
;
TargetEntry
if
(
unionClause
)
{
qlist
=
parse_analyze
(
unionClause
);
for
(
i
=
0
;
i
<
qlist
->
len
;
i
++
)
union_list
=
lappend
(
union_list
,
qlist
->
qtrees
[
i
]);
/* we need to check return types are consistent here */
return
union_list
;
}
else
return
NIL
;
}
src/bin/psql/psqlHelp.h
View file @
a01b085c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: psqlHelp.h,v 1.3
4 1997/12/04 00:27:37 scrappy
Exp $
* $Id: psqlHelp.h,v 1.3
5 1997/12/29 01:13:16 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -179,7 +179,12 @@ static struct _helpStruct QL_HELP[] = {
...
@@ -179,7 +179,12 @@ static struct _helpStruct QL_HELP[] = {
"rollback [transaction|work]"
},
"rollback [transaction|work]"
},
{
"select"
,
{
"select"
,
"retrieve tuples"
,
"retrieve tuples"
,
"select [distinct on <attr>] <expr1> [as <attr1>], ... <exprN> [as <attrN>]
\n\t
[into table <class_name>] [from <from_list>]
\n\t
[where <qual>]
\n\t
[order by <attr1>
\n\t\t
[using <op1>],..<attrN> [[using <opN>] | ASC | DESC]];"
},
"select [distinct on <attr>] <expr1> [as <attr1>], ... <exprN> [as <attrN>]
\n
\
\t
[into table <class_name>]
\n
\
\t
[from <from_list>]
\n
\
\t
[where <qual>]
\n
\
\t
[order by <attr1> [ASC | DESC] [using <op1>], ... <attrN> ]
\n
\
\t
[union [all] select ...];"
},
{
"set"
,
{
"set"
,
"set run-time environment"
,
"set run-time environment"
,
"set DateStyle to {'ISO' | 'SQL' | 'Postgres' | 'European' | 'US' | 'NonEuropean'}
\n
set GEQO to {'ON[=#]' | 'OFF'}
\n
set R_PLANS to {'ON' | 'OFF'}"
},
"set DateStyle to {'ISO' | 'SQL' | 'Postgres' | 'European' | 'US' | 'NonEuropean'}
\n
set GEQO to {'ON[=#]' | 'OFF'}
\n
set R_PLANS to {'ON' | 'OFF'}"
},
...
...
src/include/optimizer/prep.h
View file @
a01b085c
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: prep.h,v 1.1
0 1997/12/24 06:06:58
momjian Exp $
* $Id: prep.h,v 1.1
1 1997/12/29 01:13:23
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -27,18 +27,10 @@ extern List *cnfify(Expr *qual, bool removeAndFlag);
...
@@ -27,18 +27,10 @@ extern List *cnfify(Expr *qual, bool removeAndFlag);
extern
List
*
preprocess_targetlist
(
List
*
tlist
,
int
command_type
,
extern
List
*
preprocess_targetlist
(
List
*
tlist
,
int
command_type
,
Index
result_relation
,
List
*
range_table
);
Index
result_relation
,
List
*
range_table
);
/*
* prototypes for prepunion.h
*/
typedef
enum
UnionFlag
{
INHERITS_FLAG
,
UNION_FLAG
,
VERSION_FLAG
}
UnionFlag
;
extern
List
*
find_all_inheritors
(
List
*
unexamined_relids
,
extern
List
*
find_all_inheritors
(
List
*
unexamined_relids
,
List
*
examined_relids
);
List
*
examined_relids
);
extern
int
first_
matching_rt_entry
(
List
*
rangetable
,
UnionFlag
flag
);
extern
int
first_
inherit_rt_entry
(
List
*
rangetable
);
extern
Append
*
plan_union_queries
(
Index
rt_index
,
Query
*
parse
,
extern
Append
*
plan_union_queries
(
Query
*
parse
);
UnionFlag
flag
);
extern
Append
*
plan_inherit_queries
(
Query
*
parse
,
Index
rt_index
);
#endif
/* PREP_H */
#endif
/* PREP_H */
src/include/parser/parse_clause.h
View file @
a01b085c
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: parse_clause.h,v 1.
3 1997/11/26 03:43:09
momjian Exp $
* $Id: parse_clause.h,v 1.
4 1997/12/29 01:13:28
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -26,6 +26,7 @@ extern List *transformGroupClause(ParseState *pstate, List *grouplist,
...
@@ -26,6 +26,7 @@ extern List *transformGroupClause(ParseState *pstate, List *grouplist,
extern
List
*
transformSortClause
(
ParseState
*
pstate
,
extern
List
*
transformSortClause
(
ParseState
*
pstate
,
List
*
orderlist
,
List
*
targetlist
,
List
*
orderlist
,
List
*
targetlist
,
char
*
uniqueFlag
);
char
*
uniqueFlag
);
extern
List
*
transformUnionClause
(
List
*
unionClause
,
List
*
targetlist
);
#endif
/* PARSE_CLAUSE_H */
#endif
/* PARSE_CLAUSE_H */
src/man/select.l
View file @
a01b085c
.\" This is -*-nroff-*-
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/select.l,v 1.
2 1996/12/11 00:28:09
momjian Exp $
.\" $Header: /cvsroot/pgsql/src/man/Attic/select.l,v 1.
3 1997/12/29 01:13:37
momjian Exp $
.TH SELECT SQL 11/05/95 PostgreSQL PostgreSQL
.TH SELECT SQL 11/05/95 PostgreSQL PostgreSQL
.SH NAME
.SH NAME
select \(em retrieve instances from a class
select \(em retrieve instances from a class
...
@@ -12,9 +12,10 @@ select \(em retrieve instances from a class
...
@@ -12,9 +12,10 @@ select \(em retrieve instances from a class
[\fBinto\fR \fBtable\fR classname]
[\fBinto\fR \fBtable\fR classname]
[\fBfrom\fR from-list]
[\fBfrom\fR from-list]
[\fBwhere\fR where-clause]
[\fBwhere\fR where-clause]
[\fBgroup by\fR attr_name1 {, attr_name-i....}
[\fBgroup by\fR attr_name1 {, attr_name-i....}]
[\fBorder by\fR attr_name1
[\fBorder by\fR attr_name1 [\fBasc\fR | \fBdesc\fR] [\fBusing op1\fR] {, attr_namei...}]
[\fBusing op1\fR] {, attr_namei [\fBusing opi\fR] }
[\fBunion {all} select\fR ...]
.fi
.fi
.SH DESCRIPTION
.SH DESCRIPTION
.BR Select
.BR Select
...
...
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