Commit 2498d829 authored by Tom Lane's avatar Tom Lane

Clean up some stray remaining references to pg_shadow, pg_user, pg_group.

parent f590ed12
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.32 2005/05/29 03:32:18 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.33 2005/08/15 02:40:20 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -33,17 +33,16 @@ PostgreSQL documentation ...@@ -33,17 +33,16 @@ PostgreSQL documentation
<para> <para>
<application>dropuser</application> removes an existing <application>dropuser</application> removes an existing
<productname>PostgreSQL</productname> user <productname>PostgreSQL</productname> user.
<emphasis>and</emphasis> the databases which that user owned. Only superusers and users with the <literal>CREATEROLE</> privilege can
Only superusers (users with <literal>usesuper</literal> set in remove <productname>PostgreSQL</productname> users. (To remove a
the <literal>pg_shadow</literal> table) can destroy superuser, you must yourself be a superuser.)
<productname>PostgreSQL</productname> users.
</para> </para>
<para> <para>
<application>dropuser</application> is a wrapper around the <application>dropuser</application> is a wrapper around the
<acronym>SQL</acronym> command <xref linkend="SQL-DROPUSER" <acronym>SQL</acronym> command <xref linkend="SQL-DROPROLE"
endterm="SQL-DROPUSER-title">. endterm="SQL-DROPROLE-title">.
There is no effective difference between dropping users via There is no effective difference between dropping users via
this utility and via other methods for accessing the server. this utility and via other methods for accessing the server.
</para> </para>
...@@ -62,8 +61,8 @@ PostgreSQL documentation ...@@ -62,8 +61,8 @@ PostgreSQL documentation
<term><replaceable class="parameter">username</replaceable></term> <term><replaceable class="parameter">username</replaceable></term>
<listitem> <listitem>
<para> <para>
Specifies the name of the <productname>PostgreSQL</productname> user to be removed. Specifies the name of the <productname>PostgreSQL</productname> user to be removed.
You will be prompted for a name if none is specified on the command line. You will be prompted for a name if none is specified on the command line.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -74,7 +73,7 @@ PostgreSQL documentation ...@@ -74,7 +73,7 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
Echo the commands that <application>dropuser</application> generates Echo the commands that <application>dropuser</application> generates
and sends to the server. and sends to the server.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -111,10 +110,10 @@ PostgreSQL documentation ...@@ -111,10 +110,10 @@ PostgreSQL documentation
<term><option>--host <replaceable class="parameter">host</replaceable></></term> <term><option>--host <replaceable class="parameter">host</replaceable></></term>
<listitem> <listitem>
<para> <para>
Specifies the host name of the machine on which the Specifies the host name of the machine on which the
server server
is running. If the value begins with a slash, it is used is running. If the value begins with a slash, it is used
as the directory for the Unix domain socket. as the directory for the Unix domain socket.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -124,9 +123,9 @@ PostgreSQL documentation ...@@ -124,9 +123,9 @@ PostgreSQL documentation
<term><option>--port <replaceable class="parameter">port</replaceable></></term> <term><option>--port <replaceable class="parameter">port</replaceable></></term>
<listitem> <listitem>
<para> <para>
Specifies the TCP port or local Unix domain socket file Specifies the TCP port or local Unix domain socket file
extension on which the server extension on which the server
is listening for connections. is listening for connections.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -179,8 +178,8 @@ PostgreSQL documentation ...@@ -179,8 +178,8 @@ PostgreSQL documentation
<title>Diagnostics</title> <title>Diagnostics</title>
<para> <para>
In case of difficulty, see <xref linkend="SQL-DROPUSER" In case of difficulty, see <xref linkend="SQL-DROPROLE"
endterm="sql-dropuser-title"> and <xref linkend="APP-PSQL"> for endterm="sql-droprole-title"> and <xref linkend="APP-PSQL"> for
discussions of potential problems and error messages. discussions of potential problems and error messages.
The database server must be running at the The database server must be running at the
targeted host. Also, any default connection settings and environment targeted host. Also, any default connection settings and environment
...@@ -199,7 +198,7 @@ PostgreSQL documentation ...@@ -199,7 +198,7 @@ PostgreSQL documentation
server: server:
<screen> <screen>
<prompt>$ </prompt><userinput>dropuser joe</userinput> <prompt>$ </prompt><userinput>dropuser joe</userinput>
<computeroutput>DROP USER</computeroutput> <computeroutput>DROP ROLE</computeroutput>
</screen> </screen>
</para> </para>
...@@ -209,10 +208,10 @@ PostgreSQL documentation ...@@ -209,10 +208,10 @@ PostgreSQL documentation
command: command:
<screen> <screen>
<prompt>$ </prompt><userinput>dropuser -p 5000 -h eden -i -e joe</userinput> <prompt>$ </prompt><userinput>dropuser -p 5000 -h eden -i -e joe</userinput>
<computeroutput>User "joe" and any owned databases will be permanently deleted. <computeroutput>Role "joe" will be permanently removed.
Are you sure? (y/n) </computeroutput><userinput>y</userinput> Are you sure? (y/n) </computeroutput><userinput>y</userinput>
<computeroutput>DROP USER "joe" <computeroutput>DROP ROLE "joe"
DROP USER</computeroutput> DROP ROLE</computeroutput>
</screen> </screen>
</para> </para>
</refsect1> </refsect1>
...@@ -223,7 +222,7 @@ DROP USER</computeroutput> ...@@ -223,7 +222,7 @@ DROP USER</computeroutput>
<simplelist type="inline"> <simplelist type="inline">
<member><xref linkend="app-createuser"></member> <member><xref linkend="app-createuser"></member>
<member><xref linkend="sql-dropuser" endterm="sql-dropuser-title"></member> <member><xref linkend="sql-droprole" endterm="sql-droprole-title"></member>
<member>Environment Variables (<xref linkend="libpq-envars">)</member> <member>Environment Variables (<xref linkend="libpq-envars">)</member>
</simplelist> </simplelist>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/reindex.sgml,v 1.27 2005/06/22 21:14:28 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/reindex.sgml,v 1.28 2005/08/15 02:40:20 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -176,9 +176,10 @@ REINDEX { INDEX | TABLE | DATABASE | SYSTEM } <replaceable class="PARAMETER">nam ...@@ -176,9 +176,10 @@ REINDEX { INDEX | TABLE | DATABASE | SYSTEM } <replaceable class="PARAMETER">nam
<para> <para>
If corruption is suspected in the indexes of any of the shared If corruption is suspected in the indexes of any of the shared
system catalogs (<structname>pg_database</structname>, system catalogs (<structname>pg_authid</structname>,
<structname>pg_group</structname>, <structname>pg_auth_members</structname>,
<structname>pg_shadow</structname>, or <structname>pg_database</structname>,
<structname>pg_shdepend</structname>, or
<structname>pg_tablespace</structname>), then a standalone server <structname>pg_tablespace</structname>), then a standalone server
must be used to repair it. <command>REINDEX</> will not process must be used to repair it. <command>REINDEX</> will not process
shared catalogs in multiuser mode. shared catalogs in multiuser mode.
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.28 2005/03/30 02:08:39 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.29 2005/08/15 02:40:23 tgl Exp $
--> -->
<sect1 id="xaggr"> <sect1 id="xaggr">
...@@ -141,22 +141,22 @@ CREATE AGGREGATE array_accum ( ...@@ -141,22 +141,22 @@ CREATE AGGREGATE array_accum (
<programlisting> <programlisting>
SELECT attrelid::regclass, array_accum(attname) SELECT attrelid::regclass, array_accum(attname)
FROM pg_attribute FROM pg_attribute
WHERE attnum &gt; 0 AND attrelid = 'pg_user'::regclass WHERE attnum &gt; 0 AND attrelid = 'pg_tablespace'::regclass
GROUP BY attrelid; GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
----------+----------------------------------------------------------------------------- ---------------+---------------------------------------
pg_user | {usename,usesysid,usecreatedb,usesuper,usecatupd,passwd,valuntil,useconfig} pg_tablespace | {spcname,spcowner,spclocation,spcacl}
(1 row) (1 row)
SELECT attrelid::regclass, array_accum(atttypid) SELECT attrelid::regclass, array_accum(atttypid)
FROM pg_attribute FROM pg_attribute
WHERE attnum &gt; 0 AND attrelid = 'pg_user'::regclass WHERE attnum &gt; 0 AND attrelid = 'pg_tablespace'::regclass
GROUP BY attrelid; GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
----------+------------------------------ ---------------+-----------------
pg_user | {19,23,16,16,16,25,702,1009} pg_tablespace | {19,26,25,1034}
(1 row) (1 row)
</programlisting> </programlisting>
</para> </para>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.64 2005/06/29 22:51:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.65 2005/08/15 02:40:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,7 +57,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) ...@@ -57,7 +57,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
if (shadow_pass == NULL || *shadow_pass == '\0') if (shadow_pass == NULL || *shadow_pass == '\0')
return STATUS_ERROR; return STATUS_ERROR;
/* We can't do crypt with pg_shadow MD5 passwords */ /* We can't do crypt with MD5 passwords */
if (isMD5(shadow_pass) && port->auth_method == uaCrypt) if (isMD5(shadow_pass) && port->auth_method == uaCrypt)
{ {
ereport(LOG, ereport(LOG,
...@@ -75,7 +75,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) ...@@ -75,7 +75,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
crypt_pwd = palloc(MD5_PASSWD_LEN + 1); crypt_pwd = palloc(MD5_PASSWD_LEN + 1);
if (isMD5(shadow_pass)) if (isMD5(shadow_pass))
{ {
/* pg_shadow already encrypted, only do salt */ /* stored password already encrypted, only do salt */
if (!EncryptMD5(shadow_pass + strlen("md5"), if (!EncryptMD5(shadow_pass + strlen("md5"),
(char *) port->md5Salt, (char *) port->md5Salt,
sizeof(port->md5Salt), crypt_pwd)) sizeof(port->md5Salt), crypt_pwd))
...@@ -86,7 +86,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) ...@@ -86,7 +86,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
} }
else else
{ {
/* pg_shadow plain, double-encrypt */ /* stored password is plain, double-encrypt */
char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1); char *crypt_pwd2 = palloc(MD5_PASSWD_LEN + 1);
if (!EncryptMD5(shadow_pass, if (!EncryptMD5(shadow_pass,
...@@ -121,10 +121,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) ...@@ -121,10 +121,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
default: default:
if (isMD5(shadow_pass)) if (isMD5(shadow_pass))
{ {
/* /* Encrypt user-supplied password to match stored MD5 */
* Encrypt user-supplied password to match MD5 in
* pg_shadow
*/
crypt_client_pass = palloc(MD5_PASSWD_LEN + 1); crypt_client_pass = palloc(MD5_PASSWD_LEN + 1);
if (!EncryptMD5(client_pass, if (!EncryptMD5(client_pass,
port->user_name, port->user_name,
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an # "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket. # SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
# #
# DATABASE can be "all", "sameuser", "samegroup", a database name, or # DATABASE can be "all", "sameuser", "samerole", a database name, or
# a comma-separated list thereof. # a comma-separated list thereof.
# #
# USER can be "all", a user name, a group name prefixed with "+", or # USER can be "all", a user name, a group name prefixed with "+", or
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
# #
# Database and user names containing spaces, commas, quotes and other special # Database and user names containing spaces, commas, quotes and other special
# characters must be quoted. Quoting one of the keywords "all", "sameuser" or # characters must be quoted. Quoting one of the keywords "all", "sameuser" or
# "samegroup" makes the name lose its special character, and just match a # "samerole" makes the name lose its special character, and just match a
# database or username with that name. # database or username with that name.
# #
# This file is read on server startup and when the postmaster receives # This file is read on server startup and when the postmaster receives
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* All code should use either of these two functions to find out * All code should use either of these two functions to find out
* whether a given user is a superuser, rather than examining * whether a given user is a superuser, rather than examining
* pg_shadow.usesuper directly, so that the escape hatch built in for * pg_authid.rolsuper directly, so that the escape hatch built in for
* the single-user case works. * the single-user case works.
* *
* *
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/superuser.c,v 1.32 2005/06/28 05:09:02 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/superuser.c,v 1.33 2005/08/15 02:40:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.14 2005/06/21 04:02:33 tgl Exp $ * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.15 2005/08/15 02:40:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -101,20 +101,20 @@ main(int argc, char *argv[]) ...@@ -101,20 +101,20 @@ main(int argc, char *argv[])
} }
if (dropuser == NULL) if (dropuser == NULL)
dropuser = simple_prompt("Enter name of user to drop: ", 128, true); dropuser = simple_prompt("Enter name of role to drop: ", 128, true);
if (interactive) if (interactive)
{ {
char *reply; char *reply;
printf(_("User \"%s\" will be permanently removed.\n"), dropuser); printf(_("Role \"%s\" will be permanently removed.\n"), dropuser);
reply = simple_prompt("Are you sure? (y/n) ", 1, true); reply = simple_prompt("Are you sure? (y/n) ", 1, true);
if (check_yesno_response(reply) != 1) if (check_yesno_response(reply) != 1)
exit(0); exit(0);
} }
initPQExpBuffer(&sql); initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "DROP USER %s;\n", fmtId(dropuser)); appendPQExpBuffer(&sql, "DROP ROLE %s;\n", fmtId(dropuser));
conn = connectDatabase("postgres", host, port, username, password, progname); conn = connectDatabase("postgres", host, port, username, password, progname);
...@@ -124,7 +124,7 @@ main(int argc, char *argv[]) ...@@ -124,7 +124,7 @@ main(int argc, char *argv[])
if (PQresultStatus(result) != PGRES_COMMAND_OK) if (PQresultStatus(result) != PGRES_COMMAND_OK)
{ {
fprintf(stderr, _("%s: removal of user \"%s\" failed: %s"), fprintf(stderr, _("%s: removal of role \"%s\" failed: %s"),
progname, dropuser, PQerrorMessage(conn)); progname, dropuser, PQerrorMessage(conn));
PQfinish(conn); PQfinish(conn);
exit(1); exit(1);
...@@ -133,7 +133,7 @@ main(int argc, char *argv[]) ...@@ -133,7 +133,7 @@ main(int argc, char *argv[])
PQfinish(conn); PQfinish(conn);
if (!quiet) if (!quiet)
{ {
puts("DROP USER"); puts("DROP ROLE");
fflush(stdout); fflush(stdout);
} }
exit(0); exit(0);
......
...@@ -306,15 +306,15 @@ select has_table_privilege(current_user,'pg_authid','insert'); ...@@ -306,15 +306,15 @@ select has_table_privilege(current_user,'pg_authid','insert');
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'pg_authid','update') select has_table_privilege(t2.oid,'pg_authid','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'pg_authid','delete') select has_table_privilege(t2.oid,'pg_authid','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
...@@ -334,17 +334,17 @@ from (select oid from pg_class where relname = 'pg_authid') as t1; ...@@ -334,17 +334,17 @@ from (select oid from pg_class where relname = 'pg_authid') as t1;
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'pg_authid') as t1, from (select oid from pg_class where relname = 'pg_authid') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'pg_authid') as t1, from (select oid from pg_class where relname = 'pg_authid') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
...@@ -390,15 +390,15 @@ select has_table_privilege(current_user,'pg_class','insert'); ...@@ -390,15 +390,15 @@ select has_table_privilege(current_user,'pg_class','insert');
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'pg_class','update') select has_table_privilege(t2.oid,'pg_class','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'pg_class','delete') select has_table_privilege(t2.oid,'pg_class','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
...@@ -418,17 +418,17 @@ from (select oid from pg_class where relname = 'pg_class') as t1; ...@@ -418,17 +418,17 @@ from (select oid from pg_class where relname = 'pg_class') as t1;
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'pg_class') as t1, from (select oid from pg_class where relname = 'pg_class') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'pg_class') as t1, from (select oid from pg_class where relname = 'pg_class') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
...@@ -472,15 +472,15 @@ select has_table_privilege(current_user,'atest1','insert'); ...@@ -472,15 +472,15 @@ select has_table_privilege(current_user,'atest1','insert');
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'atest1','update') select has_table_privilege(t2.oid,'atest1','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,'atest1','delete') select has_table_privilege(t2.oid,'atest1','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
...@@ -500,17 +500,17 @@ from (select oid from pg_class where relname = 'atest1') as t1; ...@@ -500,17 +500,17 @@ from (select oid from pg_class where relname = 'atest1') as t1;
f f
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'atest1') as t1, from (select oid from pg_class where relname = 'atest1') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
t t
(1 row) (1 row)
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'atest1') as t1, from (select oid from pg_class where relname = 'atest1') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
has_table_privilege has_table_privilege
--------------------- ---------------------
f f
......
...@@ -205,22 +205,22 @@ select has_table_privilege(1,'rule'); ...@@ -205,22 +205,22 @@ select has_table_privilege(1,'rule');
select has_table_privilege(current_user,'pg_authid','select'); select has_table_privilege(current_user,'pg_authid','select');
select has_table_privilege(current_user,'pg_authid','insert'); select has_table_privilege(current_user,'pg_authid','insert');
select has_table_privilege(t2.usesysid,'pg_authid','update') select has_table_privilege(t2.oid,'pg_authid','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,'pg_authid','delete') select has_table_privilege(t2.oid,'pg_authid','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(current_user,t1.oid,'rule') select has_table_privilege(current_user,t1.oid,'rule')
from (select oid from pg_class where relname = 'pg_authid') as t1; from (select oid from pg_class where relname = 'pg_authid') as t1;
select has_table_privilege(current_user,t1.oid,'references') select has_table_privilege(current_user,t1.oid,'references')
from (select oid from pg_class where relname = 'pg_authid') as t1; from (select oid from pg_class where relname = 'pg_authid') as t1;
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'pg_authid') as t1, from (select oid from pg_class where relname = 'pg_authid') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'pg_authid') as t1, from (select oid from pg_class where relname = 'pg_authid') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege('pg_authid','update'); select has_table_privilege('pg_authid','update');
select has_table_privilege('pg_authid','delete'); select has_table_privilege('pg_authid','delete');
...@@ -236,22 +236,22 @@ SET SESSION AUTHORIZATION regressuser3; ...@@ -236,22 +236,22 @@ SET SESSION AUTHORIZATION regressuser3;
select has_table_privilege(current_user,'pg_class','select'); select has_table_privilege(current_user,'pg_class','select');
select has_table_privilege(current_user,'pg_class','insert'); select has_table_privilege(current_user,'pg_class','insert');
select has_table_privilege(t2.usesysid,'pg_class','update') select has_table_privilege(t2.oid,'pg_class','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,'pg_class','delete') select has_table_privilege(t2.oid,'pg_class','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(current_user,t1.oid,'rule') select has_table_privilege(current_user,t1.oid,'rule')
from (select oid from pg_class where relname = 'pg_class') as t1; from (select oid from pg_class where relname = 'pg_class') as t1;
select has_table_privilege(current_user,t1.oid,'references') select has_table_privilege(current_user,t1.oid,'references')
from (select oid from pg_class where relname = 'pg_class') as t1; from (select oid from pg_class where relname = 'pg_class') as t1;
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'pg_class') as t1, from (select oid from pg_class where relname = 'pg_class') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'pg_class') as t1, from (select oid from pg_class where relname = 'pg_class') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege('pg_class','update'); select has_table_privilege('pg_class','update');
select has_table_privilege('pg_class','delete'); select has_table_privilege('pg_class','delete');
...@@ -264,22 +264,22 @@ from (select oid from pg_class where relname = 'pg_class') as t1; ...@@ -264,22 +264,22 @@ from (select oid from pg_class where relname = 'pg_class') as t1;
select has_table_privilege(current_user,'atest1','select'); select has_table_privilege(current_user,'atest1','select');
select has_table_privilege(current_user,'atest1','insert'); select has_table_privilege(current_user,'atest1','insert');
select has_table_privilege(t2.usesysid,'atest1','update') select has_table_privilege(t2.oid,'atest1','update')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,'atest1','delete') select has_table_privilege(t2.oid,'atest1','delete')
from (select usesysid from pg_user where usename = current_user) as t2; from (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(current_user,t1.oid,'rule') select has_table_privilege(current_user,t1.oid,'rule')
from (select oid from pg_class where relname = 'atest1') as t1; from (select oid from pg_class where relname = 'atest1') as t1;
select has_table_privilege(current_user,t1.oid,'references') select has_table_privilege(current_user,t1.oid,'references')
from (select oid from pg_class where relname = 'atest1') as t1; from (select oid from pg_class where relname = 'atest1') as t1;
select has_table_privilege(t2.usesysid,t1.oid,'select') select has_table_privilege(t2.oid,t1.oid,'select')
from (select oid from pg_class where relname = 'atest1') as t1, from (select oid from pg_class where relname = 'atest1') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege(t2.usesysid,t1.oid,'insert') select has_table_privilege(t2.oid,t1.oid,'insert')
from (select oid from pg_class where relname = 'atest1') as t1, from (select oid from pg_class where relname = 'atest1') as t1,
(select usesysid from pg_user where usename = current_user) as t2; (select oid from pg_roles where rolname = current_user) as t2;
select has_table_privilege('atest1','update'); select has_table_privilege('atest1','update');
select has_table_privilege('atest1','delete'); select has_table_privilege('atest1','delete');
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
-- Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group -- Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
-- Portions Copyright (c) 1994, Regents of the University of California -- Portions Copyright (c) 1994, Regents of the University of California
-- --
-- $PostgreSQL: pgsql/src/tutorial/syscat.source,v 1.14 2004/12/31 22:04:05 pgsql Exp $ -- $PostgreSQL: pgsql/src/tutorial/syscat.source,v 1.15 2005/08/15 02:40:36 tgl Exp $
-- --
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
...@@ -18,13 +18,12 @@ ...@@ -18,13 +18,12 @@
SET SEARCH_PATH TO pg_catalog; SET SEARCH_PATH TO pg_catalog;
-- --
-- lists the name of all database adminstrators and the name of their -- lists the names of all database owners and the name of their database(s)
-- database(s)
-- --
SELECT usename, datname SELECT rolname, datname
FROM pg_user, pg_database FROM pg_roles, pg_database
WHERE usesysid = datdba WHERE pg_roles.oid = datdba
ORDER BY usename, datname; ORDER BY rolname, datname;
-- --
-- lists all user-defined classes -- lists all user-defined classes
...@@ -81,15 +80,15 @@ SELECT n.nspname, c.relname, a.attname, format_type(t.oid, null) as typname ...@@ -81,15 +80,15 @@ SELECT n.nspname, c.relname, a.attname, format_type(t.oid, null) as typname
-- --
-- lists all user-defined base types (not including array types) -- lists all user-defined base types (not including array types)
-- --
SELECT n.nspname, u.usename, format_type(t.oid, null) as typname SELECT n.nspname, r.rolname, format_type(t.oid, null) as typname
FROM pg_type t, pg_user u, pg_namespace n FROM pg_type t, pg_roles r, pg_namespace n
WHERE u.usesysid = t.typowner WHERE r.oid = t.typowner
and t.typnamespace = n.oid and t.typnamespace = n.oid
and t.typrelid = '0'::oid -- no complex types and t.typrelid = 0 -- no complex types
and t.typelem = '0'::oid -- no arrays and t.typelem = 0 -- no arrays
and n.nspname not like 'pg\\_%' -- no catalogs and n.nspname not like 'pg\\_%' -- no built-in types
and n.nspname != 'information_schema' -- no information_schema and n.nspname != 'information_schema' -- no information_schema
ORDER BY nspname, usename, typname; ORDER BY nspname, rolname, typname;
-- --
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment