Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite36de18

Browse files
committed
Fix psql's \d commands to use pg_roles instead of pg_user, so that
they don't miss owners that are NOLOGIN.
1 parent84ccf72 commite36de18

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

‎src/bin/psql/describe.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.123 2005/08/1418:49:30 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.124 2005/08/1419:20:45 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -177,7 +177,7 @@ describeFunctions(const char *pattern, bool verbose)
177177

178178
if (verbose)
179179
appendPQExpBuffer(&buf,
180-
",\nu.usename as \"%s\",\n"
180+
",\nr.rolname as \"%s\",\n"
181181
" l.lanname as \"%s\",\n"
182182
" p.prosrc as \"%s\",\n"
183183
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
@@ -193,7 +193,7 @@ describeFunctions(const char *pattern, bool verbose)
193193
"\nFROM pg_catalog.pg_proc p"
194194
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace"
195195
"\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang"
196-
"\n LEFT JOIN pg_catalog.pg_user u ONu.usesysid = p.proowner\n");
196+
"\n LEFT JOIN pg_catalog.pg_roles r ONr.oid = p.proowner\n");
197197

198198
/*
199199
* we skip in/out funcs by excluding functions that take or return
@@ -357,7 +357,7 @@ listAllDbs(bool verbose)
357357

358358
printfPQExpBuffer(&buf,
359359
"SELECT d.datname as \"%s\",\n"
360-
"u.usename as \"%s\"",
360+
"r.rolname as \"%s\"",
361361
_("Name"),_("Owner"));
362362
appendPQExpBuffer(&buf,
363363
",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
@@ -368,7 +368,7 @@ listAllDbs(bool verbose)
368368
_("Description"));
369369
appendPQExpBuffer(&buf,
370370
"\nFROM pg_catalog.pg_database d"
371-
"\n LEFT JOIN pg_catalog.pg_user u ON d.datdba =u.usesysid\n"
371+
"\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba =r.oid\n"
372372
"ORDER BY 1;");
373373

374374
res=PSQLexec(buf.data, false);
@@ -1462,7 +1462,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
14621462
"SELECT n.nspname as \"%s\",\n"
14631463
" c.relname as \"%s\",\n"
14641464
" CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' WHEN 's' THEN '%s' END as \"%s\",\n"
1465-
"u.usename as \"%s\"",
1465+
"r.rolname as \"%s\"",
14661466
_("Schema"),_("Name"),
14671467
_("table"),_("view"),_("index"),_("sequence"),
14681468
_("special"),_("Type"),_("Owner"));
@@ -1477,20 +1477,16 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
14771477
",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
14781478
_("Description"));
14791479

1480+
appendPQExpBuffer(&buf,
1481+
"\nFROM pg_catalog.pg_class c"
1482+
"\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner"
1483+
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
14801484
if (showIndexes)
14811485
appendPQExpBuffer(&buf,
1482-
"\nFROM pg_catalog.pg_class c"
1483-
"\n JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
1484-
"\n JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid"
1485-
"\n LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner"
1486-
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
1487-
else
1488-
appendPQExpBuffer(&buf,
1489-
"\nFROM pg_catalog.pg_class c"
1490-
"\n LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner"
1491-
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
1486+
"\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
1487+
"\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid");
14921488

1493-
appendPQExpBuffer(&buf,"WHERE c.relkind IN (");
1489+
appendPQExpBuffer(&buf,"\nWHERE c.relkind IN (");
14941490
if (showTables)
14951491
appendPQExpBuffer(&buf,"'r',");
14961492
if (showViews)
@@ -1716,7 +1712,7 @@ listSchemas(const char *pattern, bool verbose)
17161712
initPQExpBuffer(&buf);
17171713
printfPQExpBuffer(&buf,
17181714
"SELECT n.nspname AS \"%s\",\n"
1719-
"u.usename AS \"%s\"",
1715+
"r.rolname AS \"%s\"",
17201716
_("Name"),_("Owner"));
17211717

17221718
if (verbose)
@@ -1726,8 +1722,8 @@ listSchemas(const char *pattern, bool verbose)
17261722
_("Access privileges"),_("Description"));
17271723

17281724
appendPQExpBuffer(&buf,
1729-
"\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
1730-
" ON n.nspowner=u.usesysid\n"
1725+
"\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_roles r\n"
1726+
" ON n.nspowner=r.oid\n"
17311727
"WHERE(n.nspname !~ '^pg_temp_' OR\n"
17321728
" n.nspname = (pg_catalog.current_schemas(true))[1])\n");/* temp schema is first */
17331729

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp