@@ -1594,17 +1594,17 @@ describeOneTableDetails(const char *schemaname,
1594
1594
else
1595
1595
appendPQExpBufferStr (& buf , "\n NULL AS attcollation" );
1596
1596
if (pset .sversion >= 100000 )
1597
- appendPQExpBufferStr (& buf , ", a.attidentity" );
1597
+ appendPQExpBufferStr (& buf , ",\n a.attidentity" );
1598
1598
else
1599
- appendPQExpBufferStr (& buf , ", ''::\" char\" AS attidentity" );
1599
+ appendPQExpBufferStr (& buf , ",\n ''::pg_catalog. char AS attidentity" );
1600
1600
if (tableinfo .relkind == RELKIND_INDEX )
1601
1601
appendPQExpBufferStr (& buf , ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef" );
1602
1602
else
1603
1603
appendPQExpBufferStr (& buf , ",\n NULL AS indexdef" );
1604
1604
if (tableinfo .relkind == RELKIND_FOREIGN_TABLE && pset .sversion >= 90200 )
1605
1605
appendPQExpBufferStr (& buf , ",\n CASE WHEN attfdwoptions IS NULL THEN '' ELSE "
1606
- " '(' || array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM "
1607
- " pg_options_to_table(attfdwoptions)), ', ') || ')' END AS attfdwoptions" );
1606
+ " '(' || pg_catalog. array_to_string(ARRAY(SELECT pg_catalog. quote_ident(option_name) || ' ' || pg_catalog. quote_literal(option_value) FROM "
1607
+ " pg_catalog. pg_options_to_table(attfdwoptions)), ', ') || ')' END AS attfdwoptions" );
1608
1608
else
1609
1609
appendPQExpBufferStr (& buf , ",\n NULL AS attfdwoptions" );
1610
1610
if (verbose )
@@ -1854,30 +1854,24 @@ describeOneTableDetails(const char *schemaname,
1854
1854
/* Make footers */
1855
1855
if (pset .sversion >= 100000 )
1856
1856
{
1857
- /* Get the partition information */
1857
+ /* Get the partition information */
1858
1858
PGresult * result ;
1859
1859
char * parent_name ;
1860
1860
char * partdef ;
1861
1861
char * partconstraintdef = NULL ;
1862
1862
1863
+ printfPQExpBuffer (& buf ,
1864
+ "SELECT inhparent::pg_catalog.regclass,\n"
1865
+ " pg_catalog.pg_get_expr(c.relpartbound, inhrelid)" );
1863
1866
/* If verbose, also request the partition constraint definition */
1864
1867
if (verbose )
1865
- printfPQExpBuffer (& buf ,
1866
- "SELECT inhparent::pg_catalog.regclass,"
1867
- " pg_get_expr(c.relpartbound, inhrelid),"
1868
- " pg_get_partition_constraintdef(inhrelid)"
1869
- " FROM pg_catalog.pg_class c"
1870
- " JOIN pg_catalog.pg_inherits"
1871
- " ON c.oid = inhrelid"
1872
- " WHERE c.oid = '%s' AND c.relispartition;" , oid );
1873
- else
1874
- printfPQExpBuffer (& buf ,
1875
- "SELECT inhparent::pg_catalog.regclass,"
1876
- " pg_get_expr(c.relpartbound, inhrelid)"
1877
- " FROM pg_catalog.pg_class c"
1878
- " JOIN pg_catalog.pg_inherits"
1879
- " ON c.oid = inhrelid"
1880
- " WHERE c.oid = '%s' AND c.relispartition;" , oid );
1868
+ appendPQExpBuffer (& buf ,
1869
+ ",\n pg_catalog.pg_get_partition_constraintdef(inhrelid)" );
1870
+ appendPQExpBuffer (& buf ,
1871
+ "\nFROM pg_catalog.pg_class c"
1872
+ " JOIN pg_catalog.pg_inherits i"
1873
+ " ON c.oid = inhrelid"
1874
+ "\nWHERE c.oid = '%s' AND c.relispartition;" , oid );
1881
1875
result = PSQLexec (buf .data );
1882
1876
if (!result )
1883
1877
goto error_return ;
@@ -2041,7 +2035,7 @@ describeOneTableDetails(const char *schemaname,
2041
2035
"\n a.attnum=d.refobjsubid)"
2042
2036
"\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
2043
2037
"\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
2044
- "\n AND d.objid=%s "
2038
+ "\n AND d.objid='%s' "
2045
2039
"\n AND d.deptype IN ('a', 'i')" ,
2046
2040
oid );
2047
2041
@@ -2285,36 +2279,26 @@ describeOneTableDetails(const char *schemaname,
2285
2279
/* print any row-level policies */
2286
2280
if (pset .sversion >= 90500 )
2287
2281
{
2282
+ printfPQExpBuffer (& buf , "SELECT pol.polname," );
2288
2283
if (pset .sversion >= 100000 )
2289
- printfPQExpBuffer (& buf ,
2290
- "SELECT pol.polname, pol.polpermissive,\n"
2291
- "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
2292
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
2293
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
2294
- "CASE pol.polcmd\n"
2295
- "WHEN 'r' THEN 'SELECT'\n"
2296
- "WHEN 'a' THEN 'INSERT'\n"
2297
- "WHEN 'w' THEN 'UPDATE'\n"
2298
- "WHEN 'd' THEN 'DELETE'\n"
2299
- "END AS cmd\n"
2300
- "FROM pg_catalog.pg_policy pol\n"
2301
- "WHERE pol.polrelid = '%s' ORDER BY 1;" ,
2302
- oid );
2284
+ appendPQExpBuffer (& buf ,
2285
+ " pol.polpermissive,\n" );
2303
2286
else
2304
- printfPQExpBuffer (& buf ,
2305
- "SELECT pol.polname, 't' as polpermissive,\n"
2306
- "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
2307
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
2308
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
2309
- "CASE pol.polcmd\n"
2310
- "WHEN 'r' THEN 'SELECT'\n"
2311
- "WHEN 'a' THEN 'INSERT'\n"
2312
- "WHEN 'w' THEN 'UPDATE'\n"
2313
- "WHEN 'd' THEN 'DELETE'\n"
2314
- "END AS cmd\n"
2315
- "FROM pg_catalog.pg_policy pol\n"
2316
- "WHERE pol.polrelid = '%s' ORDER BY 1;" ,
2317
- oid );
2287
+ appendPQExpBuffer (& buf ,
2288
+ " 't' as polpermissive,\n" );
2289
+ appendPQExpBuffer (& buf ,
2290
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
2291
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
2292
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
2293
+ " CASE pol.polcmd\n"
2294
+ " WHEN 'r' THEN 'SELECT'\n"
2295
+ " WHEN 'a' THEN 'INSERT'\n"
2296
+ " WHEN 'w' THEN 'UPDATE'\n"
2297
+ " WHEN 'd' THEN 'DELETE'\n"
2298
+ " END AS cmd\n"
2299
+ "FROM pg_catalog.pg_policy pol\n"
2300
+ "WHERE pol.polrelid = '%s' ORDER BY 1;" ,
2301
+ oid );
2318
2302
2319
2303
result = PSQLexec (buf .data );
2320
2304
if (!result )
@@ -2543,7 +2527,7 @@ describeOneTableDetails(const char *schemaname,
2543
2527
"UNION ALL\n"
2544
2528
"SELECT pubname\n"
2545
2529
"FROM pg_catalog.pg_publication p\n"
2546
- "WHERE p.puballtables AND pg_relation_is_publishable('%s')\n"
2530
+ "WHERE p.puballtables AND pg_catalog. pg_relation_is_publishable('%s')\n"
2547
2531
"ORDER BY 1;" ,
2548
2532
oid , oid );
2549
2533
@@ -2764,13 +2748,13 @@ describeOneTableDetails(const char *schemaname,
2764
2748
/* Footer information about foreign table */
2765
2749
printfPQExpBuffer (& buf ,
2766
2750
"SELECT s.srvname,\n"
2767
- " array_to_string(ARRAY(SELECT "
2768
- " quote_ident(option_name) || ' ' || "
2769
- " quote_literal(option_value) FROM "
2770
- " pg_options_to_table(ftoptions)), ', ') "
2751
+ " pg_catalog. array_to_string(ARRAY(\n "
2752
+ " SELECT pg_catalog. quote_ident(option_name)"
2753
+ " || ' ' || pg_catalog. quote_literal(option_value)\n "
2754
+ " FROM pg_catalog. pg_options_to_table(ftoptions)), ', ')\n "
2771
2755
"FROM pg_catalog.pg_foreign_table f,\n"
2772
2756
" pg_catalog.pg_foreign_server s\n"
2773
- "WHERE f.ftrelid = %s AND s.oid = f.ftserver;" ,
2757
+ "WHERE f.ftrelid = '%s' AND s.oid = f.ftserver;" ,
2774
2758
oid );
2775
2759
result = PSQLexec (buf .data );
2776
2760
if (!result )
@@ -2834,22 +2818,22 @@ describeOneTableDetails(const char *schemaname,
2834
2818
/* print child tables (with additional info if partitions) */
2835
2819
if (pset .sversion >= 100000 )
2836
2820
printfPQExpBuffer (& buf ,
2837
- "SELECT c.oid::pg_catalog.regclass, pg_get_expr(c.relpartbound, c.oid)"
2821
+ "SELECT c.oid::pg_catalog.regclass, pg_catalog. pg_get_expr(c.relpartbound, c.oid)"
2838
2822
" FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
2839
- " WHERE c.oid=i.inhrelid AND"
2840
- " i.inhparent = '%s' AND"
2841
- " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
2842
- " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;" , oid , oid );
2823
+ " WHERE c.oid=i.inhrelid AND i.inhparent = '%s'"
2824
+ " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;" , oid );
2843
2825
else if (pset .sversion >= 80300 )
2844
2826
printfPQExpBuffer (& buf ,
2845
2827
"SELECT c.oid::pg_catalog.regclass"
2846
2828
" FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
2847
- " WHERE c.oid=i.inhrelid AND"
2848
- " i.inhparent = '%s' AND"
2849
- " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
2850
- " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;" , oid , oid );
2829
+ " WHERE c.oid=i.inhrelid AND i.inhparent = '%s'"
2830
+ " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;" , oid );
2851
2831
else
2852
- printfPQExpBuffer (& buf , "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.relname;" , oid );
2832
+ printfPQExpBuffer (& buf ,
2833
+ "SELECT c.oid::pg_catalog.regclass"
2834
+ " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
2835
+ " WHERE c.oid=i.inhrelid AND i.inhparent = '%s'"
2836
+ " ORDER BY c.relname;" , oid );
2853
2837
2854
2838
result = PSQLexec (buf .data );
2855
2839
if (!result )
@@ -3234,16 +3218,16 @@ listDbRoleSettings(const char *pattern, const char *pattern2)
3234
3218
3235
3219
printfPQExpBuffer (& buf , "SELECT rolname AS \"%s\", datname AS \"%s\",\n"
3236
3220
"pg_catalog.array_to_string(setconfig, E'\\n') AS \"%s\"\n"
3237
- "FROM pg_db_role_setting AS s\n"
3238
- "LEFT JOIN pg_database ON pg_database .oid = setdatabase\n"
3239
- "LEFT JOIN pg_roles ON pg_roles .oid = setrole\n" ,
3221
+ "FROM pg_catalog. pg_db_role_setting s\n"
3222
+ "LEFT JOIN pg_catalog. pg_database d ON d .oid = setdatabase\n"
3223
+ "LEFT JOIN pg_catalog. pg_roles r ON r .oid = setrole\n" ,
3240
3224
gettext_noop ("Role" ),
3241
3225
gettext_noop ("Database" ),
3242
3226
gettext_noop ("Settings" ));
3243
3227
havewhere = processSQLNamePattern (pset .db , & buf , pattern , false, false,
3244
- NULL , "pg_roles .rolname" , NULL , NULL );
3228
+ NULL , "r .rolname" , NULL , NULL );
3245
3229
processSQLNamePattern (pset .db , & buf , pattern2 , havewhere , false,
3246
- NULL , "pg_database .datname" , NULL , NULL );
3230
+ NULL , "d .datname" , NULL , NULL );
3247
3231
appendPQExpBufferStr (& buf , "ORDER BY 1, 2;" );
3248
3232
}
3249
3233
else
@@ -3475,13 +3459,13 @@ listLanguages(const char *pattern, bool verbose, bool showSystem)
3475
3459
{
3476
3460
appendPQExpBuffer (& buf ,
3477
3461
",\n NOT l.lanispl AS \"%s\",\n"
3478
- " l.lanplcallfoid::regprocedure AS \"%s\",\n"
3479
- " l.lanvalidator::regprocedure AS \"%s\",\n " ,
3462
+ " l.lanplcallfoid::pg_catalog. regprocedure AS \"%s\",\n"
3463
+ " l.lanvalidator::pg_catalog. regprocedure AS \"%s\",\n " ,
3480
3464
gettext_noop ("Internal language" ),
3481
3465
gettext_noop ("Call handler" ),
3482
3466
gettext_noop ("Validator" ));
3483
3467
if (pset .sversion >= 90000 )
3484
- appendPQExpBuffer (& buf , "l.laninline::regprocedure AS \"%s\",\n " ,
3468
+ appendPQExpBuffer (& buf , "l.laninline::pg_catalog. regprocedure AS \"%s\",\n " ,
3485
3469
gettext_noop ("Inline handler" ));
3486
3470
printACLColumn (& buf , "l.lanacl" );
3487
3471
}
@@ -4611,10 +4595,10 @@ listForeignDataWrappers(const char *pattern, bool verbose)
4611
4595
printACLColumn (& buf , "fdwacl" );
4612
4596
appendPQExpBuffer (& buf ,
4613
4597
",\n CASE WHEN fdwoptions IS NULL THEN '' ELSE "
4614
- " '(' || array_to_string(ARRAY(SELECT "
4615
- " quote_ident(option_name) || ' ' || "
4616
- " quote_literal(option_value) FROM "
4617
- " pg_options_to_table(fdwoptions)), ', ') || ')' "
4598
+ " '(' || pg_catalog. array_to_string(ARRAY(SELECT "
4599
+ " pg_catalog. quote_ident(option_name) || ' ' || "
4600
+ " pg_catalog. quote_literal(option_value) FROM "
4601
+ " pg_catalog. pg_options_to_table(fdwoptions)), ', ') || ')' "
4618
4602
" END AS \"%s\"" ,
4619
4603
gettext_noop ("FDW options" ));
4620
4604
@@ -4692,10 +4676,10 @@ listForeignServers(const char *pattern, bool verbose)
4692
4676
" s.srvtype AS \"%s\",\n"
4693
4677
" s.srvversion AS \"%s\",\n"
4694
4678
" CASE WHEN srvoptions IS NULL THEN '' ELSE "
4695
- " '(' || array_to_string(ARRAY(SELECT "
4696
- " quote_ident(option_name) || ' ' || "
4697
- " quote_literal(option_value) FROM "
4698
- " pg_options_to_table(srvoptions)), ', ') || ')' "
4679
+ " '(' || pg_catalog. array_to_string(ARRAY(SELECT "
4680
+ " pg_catalog. quote_ident(option_name) || ' ' || "
4681
+ " pg_catalog. quote_literal(option_value) FROM "
4682
+ " pg_catalog. pg_options_to_table(srvoptions)), ', ') || ')' "
4699
4683
" END AS \"%s\",\n"
4700
4684
" d.description AS \"%s\"" ,
4701
4685
gettext_noop ("Type" ),
@@ -4710,7 +4694,7 @@ listForeignServers(const char *pattern, bool verbose)
4710
4694
4711
4695
if (verbose )
4712
4696
appendPQExpBufferStr (& buf ,
4713
- "LEFT JOIN pg_description d\n "
4697
+ "LEFT JOIN pg_catalog. pg_description d\n "
4714
4698
"ON d.classoid = s.tableoid AND d.objoid = s.oid "
4715
4699
"AND d.objsubid = 0\n" );
4716
4700
@@ -4766,10 +4750,10 @@ listUserMappings(const char *pattern, bool verbose)
4766
4750
if (verbose )
4767
4751
appendPQExpBuffer (& buf ,
4768
4752
",\n CASE WHEN umoptions IS NULL THEN '' ELSE "
4769
- " '(' || array_to_string(ARRAY(SELECT "
4770
- " quote_ident(option_name) || ' ' || "
4771
- " quote_literal(option_value) FROM "
4772
- " pg_options_to_table(umoptions)), ', ') || ')' "
4753
+ " '(' || pg_catalog. array_to_string(ARRAY(SELECT "
4754
+ " pg_catalog. quote_ident(option_name) || ' ' || "
4755
+ " pg_catalog. quote_literal(option_value) FROM "
4756
+ " pg_catalog. pg_options_to_table(umoptions)), ', ') || ')' "
4773
4757
" END AS \"%s\"" ,
4774
4758
gettext_noop ("FDW options" ));
4775
4759
@@ -4829,10 +4813,10 @@ listForeignTables(const char *pattern, bool verbose)
4829
4813
if (verbose )
4830
4814
appendPQExpBuffer (& buf ,
4831
4815
",\n CASE WHEN ftoptions IS NULL THEN '' ELSE "
4832
- " '(' || array_to_string(ARRAY(SELECT "
4833
- " quote_ident(option_name) || ' ' || "
4834
- " quote_literal(option_value) FROM "
4835
- " pg_options_to_table(ftoptions)), ', ') || ')' "
4816
+ " '(' || pg_catalog. array_to_string(ARRAY(SELECT "
4817
+ " pg_catalog. quote_ident(option_name) || ' ' || "
4818
+ " pg_catalog. quote_literal(option_value) FROM "
4819
+ " pg_catalog. pg_options_to_table(ftoptions)), ', ') || ')' "
4836
4820
" END AS \"%s\",\n"
4837
4821
" d.description AS \"%s\"" ,
4838
4822
gettext_noop ("FDW options" ),
0 commit comments