Skip to content

Commit a397109

Browse files
committed
psql: Fix name quoting on extended statistics
Per our message style guidelines, for human consumption we quote qualified names as a whole rather than each part separately; but commits bc08520 introduced a deviation for extended statistics and a4d75c8 copied it. I don't agree with this policy applying to names shown by psql, but that's a poor reason to deviate from the practice only in two obscure corners, so make said corners use the same style as everywhere else. Backpatch to 14. The first of these is older, but I'm not sure we want to destabilize the psql output in the older branches for such a small thing. Discussion: https://postgr.es/m/20210828181618.GS26465@telsasoft.com
1 parent bfd4567 commit a397109

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/bin/psql/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,7 +2917,7 @@ describeOneTableDetails(const char *schemaname,
29172917
printfPQExpBuffer(&buf, " ");
29182918

29192919
/* statistics object name (qualified with namespace) */
2920-
appendPQExpBuffer(&buf, "\"%s\".\"%s\"",
2920+
appendPQExpBuffer(&buf, "\"%s.%s\"",
29212921
PQgetvalue(result, i, 2),
29222922
PQgetvalue(result, i, 3));
29232923

@@ -3012,7 +3012,7 @@ describeOneTableDetails(const char *schemaname,
30123012
printfPQExpBuffer(&buf, " ");
30133013

30143014
/* statistics object name (qualified with namespace) */
3015-
appendPQExpBuffer(&buf, "\"%s\".\"%s\" (",
3015+
appendPQExpBuffer(&buf, "\"%s.%s\" (",
30163016
PQgetvalue(result, i, 2),
30173017
PQgetvalue(result, i, 3));
30183018

src/test/regress/expected/create_table_like.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ Indexes:
416416
Check constraints:
417417
"ctlt1_a_check" CHECK (length(a) > 2)
418418
Statistics objects:
419-
"public"."ctlt_all_a_b_stat" ON a, b FROM ctlt_all
420-
"public"."ctlt_all_expr_stat" ON ((a || b)) FROM ctlt_all
419+
"public.ctlt_all_a_b_stat" ON a, b FROM ctlt_all
420+
"public.ctlt_all_expr_stat" ON ((a || b)) FROM ctlt_all
421421

422422
SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 'ctlt_all'::regclass ORDER BY c.relname, objsubid;
423423
relname | objsubid | description
@@ -456,8 +456,8 @@ Indexes:
456456
Check constraints:
457457
"ctlt1_a_check" CHECK (length(a) > 2)
458458
Statistics objects:
459-
"public"."pg_attrdef_a_b_stat" ON a, b FROM public.pg_attrdef
460-
"public"."pg_attrdef_expr_stat" ON ((a || b)) FROM public.pg_attrdef
459+
"public.pg_attrdef_a_b_stat" ON a, b FROM public.pg_attrdef
460+
"public.pg_attrdef_expr_stat" ON ((a || b)) FROM public.pg_attrdef
461461

462462
DROP TABLE public.pg_attrdef;
463463
-- Check that LIKE isn't confused when new table masks the old, either
@@ -478,8 +478,8 @@ Indexes:
478478
Check constraints:
479479
"ctlt1_a_check" CHECK (length(a) > 2)
480480
Statistics objects:
481-
"ctl_schema"."ctlt1_a_b_stat" ON a, b FROM ctlt1
482-
"ctl_schema"."ctlt1_expr_stat" ON ((a || b)) FROM ctlt1
481+
"ctl_schema.ctlt1_a_b_stat" ON a, b FROM ctlt1
482+
"ctl_schema.ctlt1_expr_stat" ON ((a || b)) FROM ctlt1
483483

484484
ROLLBACK;
485485
DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ctlt13_like, ctlt_all, ctla, ctlb CASCADE;

src/test/regress/expected/stats_ext.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ALTER TABLE ab1 DROP COLUMN a;
9292
b | integer | | |
9393
c | integer | | |
9494
Statistics objects:
95-
"public"."ab1_b_c_stats" ON b, c FROM ab1
95+
"public.ab1_b_c_stats" ON b, c FROM ab1
9696

9797
-- Ensure statistics are dropped when table is
9898
SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%';
@@ -124,7 +124,7 @@ ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0;
124124
a | integer | | |
125125
b | integer | | |
126126
Statistics objects:
127-
"public"."ab1_a_b_stats" ON a, b FROM ab1; STATISTICS 0
127+
"public.ab1_a_b_stats" ON a, b FROM ab1; STATISTICS 0
128128

129129
ANALYZE ab1;
130130
SELECT stxname, stxdndistinct, stxddependencies, stxdmcv
@@ -144,7 +144,7 @@ ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1;
144144
a | integer | | | | plain | |
145145
b | integer | | | | plain | |
146146
Statistics objects:
147-
"public"."ab1_a_b_stats" ON a, b FROM ab1
147+
"public.ab1_a_b_stats" ON a, b FROM ab1
148148

149149
-- partial analyze doesn't build stats either
150150
ANALYZE ab1 (a);

0 commit comments

Comments
 (0)