psql: Fix name quoting on extended statistics
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 30 Aug 2021 18:01:29 +0000 (14:01 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 30 Aug 2021 18:01:29 +0000 (14:01 -0400)
Per our message style guidelines, for human consumption we quote
qualified names as a whole rather than each part separately; but commits
bc085205c8a4 introduced a deviation for extended statistics and
a4d75c86bf15 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

src/bin/psql/describe.c
src/test/regress/expected/create_table_like.out
src/test/regress/expected/stats_ext.out

index 30fb17123e47008f3b9d1be1dd9aa5d6d4991d6a..90ff649be7245c8b2d22efcc53bddc37af7d63d0 100644 (file)
@@ -2917,7 +2917,7 @@ describeOneTableDetails(const char *schemaname,
                    printfPQExpBuffer(&buf, "    ");
 
                    /* statistics object name (qualified with namespace) */
-                   appendPQExpBuffer(&buf, "\"%s\".\"%s\"",
+                   appendPQExpBuffer(&buf, "\"%s.%s\"",
                                      PQgetvalue(result, i, 2),
                                      PQgetvalue(result, i, 3));
 
@@ -3012,7 +3012,7 @@ describeOneTableDetails(const char *schemaname,
                    printfPQExpBuffer(&buf, "    ");
 
                    /* statistics object name (qualified with namespace) */
-                   appendPQExpBuffer(&buf, "\"%s\".\"%s\" (",
+                   appendPQExpBuffer(&buf, "\"%s.%s\" (",
                                      PQgetvalue(result, i, 2),
                                      PQgetvalue(result, i, 3));
 
index 7ad5fafe9368857e89edaa1ce2f31210ceae1830..6072de3e30a94c046e47cde44b63a3efe0867f6e 100644 (file)
@@ -416,8 +416,8 @@ Indexes:
 Check constraints:
     "ctlt1_a_check" CHECK (length(a) > 2)
 Statistics objects:
-    "public"."ctlt_all_a_b_stat" ON a, b FROM ctlt_all
-    "public"."ctlt_all_expr_stat" ON ((a || b)) FROM ctlt_all
+    "public.ctlt_all_a_b_stat" ON a, b FROM ctlt_all
+    "public.ctlt_all_expr_stat" ON ((a || b)) FROM ctlt_all
 
 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;
     relname     | objsubid | description 
@@ -456,8 +456,8 @@ Indexes:
 Check constraints:
     "ctlt1_a_check" CHECK (length(a) > 2)
 Statistics objects:
-    "public"."pg_attrdef_a_b_stat" ON a, b FROM public.pg_attrdef
-    "public"."pg_attrdef_expr_stat" ON ((a || b)) FROM public.pg_attrdef
+    "public.pg_attrdef_a_b_stat" ON a, b FROM public.pg_attrdef
+    "public.pg_attrdef_expr_stat" ON ((a || b)) FROM public.pg_attrdef
 
 DROP TABLE public.pg_attrdef;
 -- Check that LIKE isn't confused when new table masks the old, either
@@ -478,8 +478,8 @@ Indexes:
 Check constraints:
     "ctlt1_a_check" CHECK (length(a) > 2)
 Statistics objects:
-    "ctl_schema"."ctlt1_a_b_stat" ON a, b FROM ctlt1
-    "ctl_schema"."ctlt1_expr_stat" ON ((a || b)) FROM ctlt1
+    "ctl_schema.ctlt1_a_b_stat" ON a, b FROM ctlt1
+    "ctl_schema.ctlt1_expr_stat" ON ((a || b)) FROM ctlt1
 
 ROLLBACK;
 DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ctlt13_like, ctlt_all, ctla, ctlb CASCADE;
index 7fb54de53d6801e3ff157e3f24918f52708837b9..a7955e0739aadd2f4083e39a0185bb4bc487f1df 100644 (file)
@@ -92,7 +92,7 @@ ALTER TABLE ab1 DROP COLUMN a;
  b      | integer |           |          | 
  c      | integer |           |          | 
 Statistics objects:
-    "public"."ab1_b_c_stats" ON b, c FROM ab1
+    "public.ab1_b_c_stats" ON b, c FROM ab1
 
 -- Ensure statistics are dropped when table is
 SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%';
@@ -124,7 +124,7 @@ ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0;
  a      | integer |           |          | 
  b      | integer |           |          | 
 Statistics objects:
-    "public"."ab1_a_b_stats" ON a, b FROM ab1; STATISTICS 0
+    "public.ab1_a_b_stats" ON a, b FROM ab1; STATISTICS 0
 
 ANALYZE ab1;
 SELECT stxname, stxdndistinct, stxddependencies, stxdmcv
@@ -144,7 +144,7 @@ ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1;
  a      | integer |           |          |         | plain   |              | 
  b      | integer |           |          |         | plain   |              | 
 Statistics objects:
-    "public"."ab1_a_b_stats" ON a, b FROM ab1
+    "public.ab1_a_b_stats" ON a, b FROM ab1
 
 -- partial analyze doesn't build stats either
 ANALYZE ab1 (a);