join-indentation-fix-1.patch
text/x-diff
Filename: join-indentation-fix-1.patch
Type: text/x-diff
Part: 0
Message:
Re: pg_dump --pretty-print-views
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/adt/ruleutils.c | 0 | 0 |
| src/test/regress/expected/create_view.out | 0 | 0 |
| src/test/regress/expected/rules.out | 0 | 0 |
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index ea7b8c5..f6bf2c3 100644
*** a/src/backend/utils/adt/ruleutils.c
--- b/src/backend/utils/adt/ruleutils.c
***************
*** 68,75 ****
/* Indent counts */
#define PRETTYINDENT_STD 8
! #define PRETTYINDENT_JOIN 13
! #define PRETTYINDENT_JOIN_ON (PRETTYINDENT_JOIN-PRETTYINDENT_STD)
#define PRETTYINDENT_VAR 4
/* Pretty flags */
--- 68,74 ----
/* Indent counts */
#define PRETTYINDENT_STD 8
! #define PRETTYINDENT_JOIN 2
#define PRETTYINDENT_VAR 4
/* Pretty flags */
*************** get_from_clause_item(Node *jtnode, Query
*** 8378,8404 ****
case JOIN_INNER:
if (j->quals)
appendContextKeyword(context, " JOIN ",
! -PRETTYINDENT_JOIN,
! PRETTYINDENT_JOIN, 2);
else
appendContextKeyword(context, " CROSS JOIN ",
! -PRETTYINDENT_JOIN,
! PRETTYINDENT_JOIN, 1);
break;
case JOIN_LEFT:
appendContextKeyword(context, " LEFT JOIN ",
! -PRETTYINDENT_JOIN,
! PRETTYINDENT_JOIN, 2);
break;
case JOIN_FULL:
appendContextKeyword(context, " FULL JOIN ",
! -PRETTYINDENT_JOIN,
! PRETTYINDENT_JOIN, 2);
break;
case JOIN_RIGHT:
appendContextKeyword(context, " RIGHT JOIN ",
! -PRETTYINDENT_JOIN,
! PRETTYINDENT_JOIN, 2);
break;
default:
elog(ERROR, "unrecognized join type: %d",
--- 8377,8408 ----
case JOIN_INNER:
if (j->quals)
appendContextKeyword(context, " JOIN ",
! -PRETTYINDENT_STD,
! PRETTYINDENT_STD,
! PRETTYINDENT_JOIN);
else
appendContextKeyword(context, " CROSS JOIN ",
! -PRETTYINDENT_STD,
! PRETTYINDENT_STD,
! PRETTYINDENT_JOIN);
break;
case JOIN_LEFT:
appendContextKeyword(context, " LEFT JOIN ",
! -PRETTYINDENT_STD,
! PRETTYINDENT_STD,
! PRETTYINDENT_JOIN);
break;
case JOIN_FULL:
appendContextKeyword(context, " FULL JOIN ",
! -PRETTYINDENT_STD,
! PRETTYINDENT_STD,
! PRETTYINDENT_JOIN);
break;
case JOIN_RIGHT:
appendContextKeyword(context, " RIGHT JOIN ",
! -PRETTYINDENT_STD,
! PRETTYINDENT_STD,
! PRETTYINDENT_JOIN);
break;
default:
elog(ERROR, "unrecognized join type: %d",
*************** get_from_clause_item(Node *jtnode, Query
*** 8411,8418 ****
if (need_paren_on_right)
appendStringInfoChar(buf, ')');
- context->indentLevel -= PRETTYINDENT_JOIN_ON;
-
if (j->usingClause)
{
ListCell *lc;
--- 8415,8420 ----
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index f6db582..3835f12 100644
*** a/src/test/regress/expected/create_view.out
--- b/src/test/regress/expected/create_view.out
*************** create table tt5 (a int, b int);
*** 1035,1084 ****
create table tt6 (c int, d int);
create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd);
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! --------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, cc, dd);
(1 row)
alter table tt5 add column c int;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! -----------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, c, cc, dd);
(1 row)
alter table tt5 add column cc int;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! -----------------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, c, cc_1, cc, dd);
(1 row)
alter table tt5 drop column c;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! --------------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, cc_1, cc, dd);
(1 row)
-- Unnamed FULL JOIN USING is lots of fun too
--- 1035,1084 ----
create table tt6 (c int, d int);
create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd);
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! ---------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, cc, dd);
(1 row)
alter table tt5 add column c int;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! ------------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, c, cc, dd);
(1 row)
alter table tt5 add column cc int;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! ------------------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, c, cc_1, cc, dd);
(1 row)
alter table tt5 drop column c;
select pg_get_viewdef('vv1', true);
! pg_get_viewdef
! ---------------------------------------------
! SELECT j.aa, +
! j.bb, +
! j.cc, +
! j.dd +
! FROM (tt5 +
! CROSS JOIN tt6) j(aa, bb, cc_1, cc, dd);
(1 row)
-- Unnamed FULL JOIN USING is lots of fun too
*************** select pg_get_viewdef('vv2', true);
*** 1105,1112 ****
tt8x.x_1 AS d, +
tt8x.z AS e +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt8 tt8x(x_1, z);
(1 row)
create view vv3 as
--- 1105,1112 ----
tt8x.x_1 AS d, +
tt8x.z AS e +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt8 tt8x(x_1, z);
(1 row)
create view vv3 as
*************** select pg_get_viewdef('vv3', true);
*** 1133,1141 ****
tt7x.y AS e, +
tt8x.z AS f +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y) +
! FULL JOIN tt8 tt8x(x_1, z) USING (x_1);
(1 row)
create view vv4 as
--- 1133,1141 ----
tt7x.y AS e, +
tt8x.z AS f +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y) +
! FULL JOIN tt8 tt8x(x_1, z) USING (x_1);
(1 row)
create view vv4 as
*************** select pg_get_viewdef('vv4', true);
*** 1164,1173 ****
tt8x.z AS f, +
tt8y.z AS g +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y) +
! FULL JOIN tt8 tt8x(x_1, z) USING (x_1) +
! FULL JOIN tt8 tt8y(x_1, z) USING (x_1);
(1 row)
alter table tt7 add column zz int;
--- 1164,1173 ----
tt8x.z AS f, +
tt8y.z AS g +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y) +
! FULL JOIN tt8 tt8x(x_1, z) USING (x_1) +
! FULL JOIN tt8 tt8y(x_1, z) USING (x_1);
(1 row)
alter table tt7 add column zz int;
*************** select pg_get_viewdef('vv2', true);
*** 1190,1197 ****
tt8x.x_1 AS d, +
tt8x.z AS e +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt8 tt8x(x_1, z, z2);
(1 row)
select pg_get_viewdef('vv3', true);
--- 1190,1197 ----
tt8x.x_1 AS d, +
tt8x.z AS e +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt8 tt8x(x_1, z, z2);
(1 row)
select pg_get_viewdef('vv3', true);
*************** select pg_get_viewdef('vv3', true);
*** 1212,1220 ****
tt7x.y AS e, +
tt8x.z AS f +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y, z) +
! FULL JOIN tt8 tt8x(x_1, z, z2) USING (x_1);
(1 row)
select pg_get_viewdef('vv4', true);
--- 1212,1220 ----
tt7x.y AS e, +
tt8x.z AS f +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y, z) +
! FULL JOIN tt8 tt8x(x_1, z, z2) USING (x_1);
(1 row)
select pg_get_viewdef('vv4', true);
*************** select pg_get_viewdef('vv4', true);
*** 1237,1246 ****
tt8x.z AS f, +
tt8y.z AS g +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y, z) +
! FULL JOIN tt8 tt8x(x_1, z, z2) USING (x_1) +
! FULL JOIN tt8 tt8y(x_1, z, z2) USING (x_1);
(1 row)
-- Implicit coercions in a JOIN USING create issues similar to FULL JOIN
--- 1237,1246 ----
tt8x.z AS f, +
tt8y.z AS g +
FROM tt7 +
! FULL JOIN tt8 USING (x), +
! tt7 tt7x(x_1, y, z) +
! FULL JOIN tt8 tt8x(x_1, z, z2) USING (x_1) +
! FULL JOIN tt8 tt8y(x_1, z, z2) USING (x_1);
(1 row)
-- Implicit coercions in a JOIN USING create issues similar to FULL JOIN
*************** select pg_get_viewdef('vv2a', true);
*** 1267,1274 ****
tt8ax.x_1 AS d, +
tt8ax.z AS e +
FROM tt7a +
! LEFT JOIN tt8a USING (x), +
! tt8a tt8ax(x_1, z);
(1 row)
--
--- 1267,1274 ----
tt8ax.x_1 AS d, +
tt8ax.z AS e +
FROM tt7a +
! LEFT JOIN tt8a USING (x), +
! tt8a tt8ax(x_1, z);
(1 row)
--
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 6c51d0d..976a7b2 100644
*** a/src/test/regress/expected/rules.out
--- b/src/test/regress/expected/rules.out
*************** pg_seclabels| ( ( (
*** 1420,1428 ****
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid))))
! JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid)))
! WHERE (l.objsubid = 0)
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1420,1428 ----
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid))))
! JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid)))
! WHERE (l.objsubid = 0)
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1437,1446 ****
l.provider,
l.label
FROM (((pg_seclabel l
! JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid))))
! JOIN pg_attribute att ON (((rel.oid = att.attrelid) AND (l.objsubid = att.attnum))))
! JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid)))
! WHERE (l.objsubid <> 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1437,1446 ----
l.provider,
l.label
FROM (((pg_seclabel l
! JOIN pg_class rel ON (((l.classoid = rel.tableoid) AND (l.objoid = rel.oid))))
! JOIN pg_attribute att ON (((rel.oid = att.attrelid) AND (l.objsubid = att.attnum))))
! JOIN pg_namespace nsp ON ((rel.relnamespace = nsp.oid)))
! WHERE (l.objsubid <> 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1459,1467 ****
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_proc pro ON (((l.classoid = pro.tableoid) AND (l.objoid = pro.oid))))
! JOIN pg_namespace nsp ON ((pro.pronamespace = nsp.oid)))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1459,1467 ----
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_proc pro ON (((l.classoid = pro.tableoid) AND (l.objoid = pro.oid))))
! JOIN pg_namespace nsp ON ((pro.pronamespace = nsp.oid)))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1478,1486 ****
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_type typ ON (((l.classoid = typ.tableoid) AND (l.objoid = typ.oid))))
! JOIN pg_namespace nsp ON ((typ.typnamespace = nsp.oid)))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1478,1486 ----
l.provider,
l.label
FROM ((pg_seclabel l
! JOIN pg_type typ ON (((l.classoid = typ.tableoid) AND (l.objoid = typ.oid))))
! JOIN pg_namespace nsp ON ((typ.typnamespace = nsp.oid)))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1491,1498 ****
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_largeobject_metadata lom ON ((l.objoid = lom.oid)))
! WHERE ((l.classoid = ('pg_largeobject'::regclass)::oid) AND (l.objsubid = 0)))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1491,1498 ----
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_largeobject_metadata lom ON ((l.objoid = lom.oid)))
! WHERE ((l.classoid = ('pg_largeobject'::regclass)::oid) AND (l.objsubid = 0)))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1503,1510 ****
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_language lan ON (((l.classoid = lan.tableoid) AND (l.objoid = lan.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1503,1510 ----
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_language lan ON (((l.classoid = lan.tableoid) AND (l.objoid = lan.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1515,1522 ****
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_namespace nsp ON (((l.classoid = nsp.tableoid) AND (l.objoid = nsp.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1515,1522 ----
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_namespace nsp ON (((l.classoid = nsp.tableoid) AND (l.objoid = nsp.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1527,1534 ****
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_event_trigger evt ON (((l.classoid = evt.tableoid) AND (l.objoid = evt.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1527,1534 ----
l.provider,
l.label
FROM (pg_seclabel l
! JOIN pg_event_trigger evt ON (((l.classoid = evt.tableoid) AND (l.objoid = evt.oid))))
! WHERE (l.objsubid = 0))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1539,1545 ****
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_database dat ON (((l.classoid = dat.tableoid) AND (l.objoid = dat.oid)))))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1539,1545 ----
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_database dat ON (((l.classoid = dat.tableoid) AND (l.objoid = dat.oid)))))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** pg_seclabels| ( ( (
*** 1550,1556 ****
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_tablespace spc ON (((l.classoid = spc.tableoid) AND (l.objoid = spc.oid)))))
UNION ALL
SELECT l.objoid,
l.classoid,
--- 1550,1556 ----
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_tablespace spc ON (((l.classoid = spc.tableoid) AND (l.objoid = spc.oid)))))
UNION ALL
SELECT l.objoid,
l.classoid,
*************** UNION ALL
*** 1561,1567 ****
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_authid rol ON (((l.classoid = rol.tableoid) AND (l.objoid = rol.oid))));
pg_settings| SELECT a.name,
a.setting,
a.unit,
--- 1561,1567 ----
l.provider,
l.label
FROM (pg_shseclabel l
! JOIN pg_authid rol ON (((l.classoid = rol.tableoid) AND (l.objoid = rol.oid))));
pg_settings| SELECT a.name,
a.setting,
a.unit,