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
07b4c48b
Commit
07b4c48b
authored
Jul 06, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken logic for pretty-printing parenthesis-suppression in UNION
et al.
parent
a21bb272
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/ruleutils.c
+28
-28
No files found.
src/backend/utils/adt/ruleutils.c
View file @
07b4c48b
...
...
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.17
4 2004/06/25 17:20:24
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.17
5 2004/07/06 04:50:21
tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
...
...
@@ -2066,6 +2066,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
TupleDesc
resultDesc
)
{
StringInfo
buf
=
context
->
buf
;
bool
need_paren
;
if
(
IsA
(
setOp
,
RangeTblRef
))
{
...
...
@@ -2074,24 +2075,37 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
Query
*
subquery
=
rte
->
subquery
;
Assert
(
subquery
!=
NULL
);
Assert
(
subquery
->
setOperations
==
NULL
);
/* Need parens if ORDER BY, FOR UPDATE, or LIMIT; see gram.y */
need_paren
=
(
subquery
->
sortClause
||
subquery
->
rowMarks
||
subquery
->
limitOffset
||
subquery
->
limitCount
);
if
(
need_paren
)
appendStringInfoChar
(
buf
,
'('
);
get_query_def
(
subquery
,
buf
,
context
->
namespaces
,
resultDesc
,
context
->
prettyFlags
,
context
->
indentLevel
);
if
(
need_paren
)
appendStringInfoChar
(
buf
,
')'
);
}
else
if
(
IsA
(
setOp
,
SetOperationStmt
))
{
SetOperationStmt
*
op
=
(
SetOperationStmt
*
)
setOp
;
bool
need_paren
;
need_paren
=
(
PRETTY_PAREN
(
context
)
?
!
IsA
(
op
->
rarg
,
RangeTblRef
)
:
true
);
if
(
!
PRETTY_PAREN
(
context
))
appendStringInfoString
(
buf
,
"(("
);
/*
* We force parens whenever nesting two SetOperationStmts.
* There are some cases in which parens are needed around a leaf
* query too, but those are more easily handled at the next level
* down (see code above).
*/
need_paren
=
!
IsA
(
op
->
larg
,
RangeTblRef
);
if
(
need_paren
)
appendStringInfoChar
(
buf
,
'('
);
get_setop_query
(
op
->
larg
,
query
,
context
,
resultDesc
);
if
(
!
PRETTY_PAREN
(
context
))
if
(
need_paren
)
appendStringInfoChar
(
buf
,
')'
);
if
(
!
PRETTY_INDENT
(
context
))
appendStringInfoChar
(
buf
,
' '
);
switch
(
op
->
op
)
...
...
@@ -2118,27 +2132,13 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context,
if
(
PRETTY_INDENT
(
context
))
appendStringInfoChar
(
buf
,
'\n'
);
if
(
PRETTY_PAREN
(
context
))
{
if
(
need_paren
)
{
appendStringInfoChar
(
buf
,
'('
);
if
(
PRETTY_INDENT
(
context
))
appendStringInfoChar
(
buf
,
'\n'
);
}
}
else
appendStringInfoChar
(
buf
,
'('
);
need_paren
=
!
IsA
(
op
->
rarg
,
RangeTblRef
);
if
(
need_paren
)
appendStringInfoChar
(
buf
,
'('
);
get_setop_query
(
op
->
rarg
,
query
,
context
,
resultDesc
);
if
(
PRETTY_PAREN
(
context
))
{
if
(
need_paren
)
appendStringInfoChar
(
buf
,
')'
);
}
else
appendStringInfoString
(
buf
,
"))"
);
if
(
need_paren
)
appendStringInfoChar
(
buf
,
')'
);
}
else
{
...
...
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