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

Commit84ccf72

Browse files
committed
Fix up tab completion for ROLEs and add some more completion logic for
other stuff; change \du and \dg to be role-aware (Stefan Kaltenbrunner).Also make tab completion fetch the list of GUC variables from pg_settingsinstead of having a hard-wired copy of the list (Tom Lane).
1 parentf60d176 commit84ccf72

File tree

5 files changed

+200
-245
lines changed

5 files changed

+200
-245
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.148 2005/07/18 20:57:52 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.149 2005/08/14 18:49:29 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -963,9 +963,10 @@ testdb=&gt;
963963
<term><literal>\dg [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
964964
<listitem>
965965
<para>
966-
Lists all databasegroups. If <replaceable
966+
Lists all databaseroles. If <replaceable
967967
class="parameter">pattern</replaceable> is specified, only
968-
those groups whose names match the pattern are listed.
968+
those roles whose names match the pattern are listed.
969+
(This command is now effectively the same as <literal>\du</>.)
969970
</para>
970971
</listitem>
971972
</varlistentry>
@@ -1073,7 +1074,7 @@ testdb=&gt;
10731074
<term><literal>\du [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
10741075
<listitem>
10751076
<para>
1076-
Lists all databaseusers or only those that match <replaceable
1077+
Lists all databaseroles, or only those that match <replaceable
10771078
class="parameter">pattern</replaceable>.
10781079
</para>
10791080
</listitem>

‎src/bin/psql/command.c

Lines changed: 4 additions & 3 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/command.c,v 1.151 2005/07/25 17:17:41 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.152 2005/08/14 18:49:30 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -338,7 +338,8 @@ exec_command(const char *cmd,
338338
success=describeFunctions(pattern,show_verbose);
339339
break;
340340
case'g':
341-
success=describeGroups(pattern);
341+
/* no longer distinct from \du */
342+
success=describeRoles(pattern);
342343
break;
343344
case'l':
344345
success=do_lo_list();
@@ -363,7 +364,7 @@ exec_command(const char *cmd,
363364
success=listTables(&cmd[1],pattern,show_verbose);
364365
break;
365366
case'u':
366-
success=describeUsers(pattern);
367+
success=describeRoles(pattern);
367368
break;
368369

369370
default:

‎src/bin/psql/describe.c

Lines changed: 21 additions & 59 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.122 2005/07/18 19:09:09 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.123 2005/08/14 18:49:30 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -1377,12 +1377,12 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers,
13771377
}
13781378

13791379
/*
1380-
* \du
1380+
* \du or \dg
13811381
*
1382-
* Describesusers. Any schema portion of the pattern is ignored.
1382+
* Describesroles. Any schema portion of the pattern is ignored.
13831383
*/
13841384
bool
1385-
describeUsers(constchar*pattern)
1385+
describeRoles(constchar*pattern)
13861386
{
13871387
PQExpBufferDatabuf;
13881388
PGresult*res;
@@ -1391,62 +1391,24 @@ describeUsers(const char *pattern)
13911391
initPQExpBuffer(&buf);
13921392

13931393
printfPQExpBuffer(&buf,
1394-
"SELECT u.usename AS \"%s\",\n"
1395-
" u.usesysid AS \"%s\",\n"
1396-
" CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('%s' AS pg_catalog.text)\n"
1397-
" WHEN u.usesuper THEN CAST('%s' AS pg_catalog.text)\n"
1398-
" WHEN u.usecreatedb THEN CAST('%s' AS pg_catalog.text)\n"
1399-
" ELSE CAST('' AS pg_catalog.text)\n"
1400-
" END AS \"%s\",\n"
1401-
" ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as \"%s\"\n"
1402-
"FROM pg_catalog.pg_user u\n",
1403-
_("User name"),_("User ID"),
1404-
_("superuser, create database"),
1405-
_("superuser"),_("create database"),
1406-
_("Attributes"),_("Groups"));
1407-
1408-
processNamePattern(&buf,pattern, false, false,
1409-
NULL,"u.usename",NULL,NULL);
1410-
1411-
appendPQExpBuffer(&buf,"ORDER BY 1;");
1412-
1413-
res=PSQLexec(buf.data, false);
1414-
termPQExpBuffer(&buf);
1415-
if (!res)
1416-
return false;
1417-
1418-
myopt.nullPrint=NULL;
1419-
myopt.title=_("List of users");
1420-
1421-
printQuery(res,&myopt,pset.queryFout,pset.logfile);
1422-
1423-
PQclear(res);
1424-
return true;
1425-
}
1426-
1427-
1428-
/*
1429-
* \dg
1430-
*
1431-
* Describes groups.
1432-
*/
1433-
bool
1434-
describeGroups(constchar*pattern)
1435-
{
1436-
PQExpBufferDatabuf;
1437-
PGresult*res;
1438-
printQueryOptmyopt=pset.popt;
1439-
1440-
initPQExpBuffer(&buf);
1441-
1442-
printfPQExpBuffer(&buf,
1443-
"SELECT g.groname AS \"%s\",\n"
1444-
" g.grosysid AS \"%s\"\n"
1445-
"FROM pg_catalog.pg_group g\n",
1446-
_("Group name"),_("Group ID"));
1394+
"SELECT r.rolname AS \"%s\",\n"
1395+
" CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS \"%s\",\n"
1396+
" CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS \"%s\",\n"
1397+
" CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS \"%s\",\n"
1398+
" CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n"
1399+
" ELSE CAST(r.rolconnlimit AS pg_catalog.text)\n"
1400+
" END AS \"%s\", \n"
1401+
" ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as \"%s\"\n"
1402+
"FROM pg_catalog.pg_roles r\n",
1403+
_("Role name"),
1404+
_("yes"),_("no"),_("Superuser"),
1405+
_("yes"),_("no"),_("Create role"),
1406+
_("yes"),_("no"),_("Create DB"),
1407+
_("no limit"),_("Connections"),
1408+
_("Member of"));
14471409

14481410
processNamePattern(&buf,pattern, false, false,
1449-
NULL,"g.groname",NULL,NULL);
1411+
NULL,"r.rolname",NULL,NULL);
14501412

14511413
appendPQExpBuffer(&buf,"ORDER BY 1;");
14521414

@@ -1456,7 +1418,7 @@ describeGroups(const char *pattern)
14561418
return false;
14571419

14581420
myopt.nullPrint=NULL;
1459-
myopt.title=_("List ofgroups");
1421+
myopt.title=_("List ofroles");
14601422

14611423
printQuery(res,&myopt,pset.queryFout,pset.logfile);
14621424

‎src/bin/psql/describe.h

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,57 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.28 2005/01/01 05:43:08 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.h,v 1.29 2005/08/14 18:49:30 tgl Exp $
77
*/
88
#ifndefDESCRIBE_H
99
#defineDESCRIBE_H
1010

1111
#include"settings.h"
1212

1313
/* \da */
14-
booldescribeAggregates(constchar*pattern,boolverbose);
14+
externbooldescribeAggregates(constchar*pattern,boolverbose);
1515

1616
/* \db */
17-
booldescribeTablespaces(constchar*pattern,boolverbose);
17+
externbooldescribeTablespaces(constchar*pattern,boolverbose);
1818

1919
/* \df */
20-
booldescribeFunctions(constchar*pattern,boolverbose);
20+
externbooldescribeFunctions(constchar*pattern,boolverbose);
2121

2222
/* \dT */
23-
booldescribeTypes(constchar*pattern,boolverbose);
23+
externbooldescribeTypes(constchar*pattern,boolverbose);
2424

2525
/* \do */
26-
booldescribeOperators(constchar*pattern);
26+
externbooldescribeOperators(constchar*pattern);
2727

28-
/* \du */
29-
booldescribeUsers(constchar*pattern);
30-
31-
/* \dg */
32-
booldescribeGroups(constchar*pattern);
28+
/* \du, \dg */
29+
externbooldescribeRoles(constchar*pattern);
3330

3431
/* \z (or \dp) */
35-
boolpermissionsList(constchar*pattern);
32+
externboolpermissionsList(constchar*pattern);
3633

3734
/* \dd */
38-
boolobjectDescription(constchar*pattern);
35+
externboolobjectDescription(constchar*pattern);
3936

4037
/* \d foo */
41-
booldescribeTableDetails(constchar*pattern,boolverbose);
38+
externbooldescribeTableDetails(constchar*pattern,boolverbose);
4239

4340
/* \l */
44-
boollistAllDbs(boolverbose);
41+
externboollistAllDbs(boolverbose);
4542

4643
/* \dt, \di, \ds, \dS, etc. */
47-
boollistTables(constchar*tabtypes,constchar*pattern,boolverbose);
44+
externboollistTables(constchar*tabtypes,constchar*pattern,boolverbose);
4845

4946
/* \dD */
50-
boollistDomains(constchar*pattern);
47+
externboollistDomains(constchar*pattern);
5148

5249
/* \dc */
53-
boollistConversions(constchar*pattern);
50+
externboollistConversions(constchar*pattern);
5451

5552
/* \dC */
56-
boollistCasts(constchar*pattern);
53+
externboollistCasts(constchar*pattern);
5754

5855
/* \dn */
59-
boollistSchemas(constchar*pattern,boolverbose);
56+
externboollistSchemas(constchar*pattern,boolverbose);
6057

6158

6259
#endif/* DESCRIBE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp