@@ -1629,7 +1629,7 @@ CREATE POLICY account_managers ON accounts TO managers
16291629
16301630<programlisting>
16311631CREATE POLICY user_policy ON users
1632- USING (user = current_user);
1632+ USING (user_name = current_user);
16331633</programlisting>
16341634
16351635 <para>
@@ -1642,7 +1642,7 @@ CREATE POLICY user_policy ON users
16421642<programlisting>
16431643CREATE POLICY user_policy ON users
16441644 USING (true)
1645- WITH CHECK (user = current_user);
1645+ WITH CHECK (user_name = current_user);
16461646</programlisting>
16471647
16481648 <para>
@@ -1662,7 +1662,7 @@ CREATE POLICY user_policy ON users
16621662<programlisting>
16631663-- Simple passwd-file based example
16641664CREATE TABLE passwd (
1665- username text UNIQUE NOT NULL,
1665+ user_name text UNIQUE NOT NULL,
16661666 pwhash text,
16671667 uid int PRIMARY KEY,
16681668 gid int NOT NULL,
@@ -1696,17 +1696,17 @@ CREATE POLICY all_view ON passwd FOR SELECT USING (true);
16961696-- Normal users can update their own records, but
16971697-- limit which shells a normal user is allowed to set
16981698CREATE POLICY user_mod ON passwd FOR UPDATE
1699- USING (current_user =username )
1699+ USING (current_user =user_name )
17001700 WITH CHECK (
1701- current_user =username AND
1701+ current_user =user_name AND
17021702 shell IN ('/bin/bash','/bin/sh','/bin/dash','/bin/zsh','/bin/tcsh')
17031703 );
17041704
17051705-- Allow admin all normal rights
17061706GRANT SELECT, INSERT, UPDATE, DELETE ON passwd TO admin;
17071707-- Users only get select access on public columns
17081708GRANT SELECT
1709- (username , uid, gid, real_name, home_phone, extra_info, home_dir, shell)
1709+ (user_name , uid, gid, real_name, home_phone, extra_info, home_dir, shell)
17101710 ON passwd TO public;
17111711-- Allow users to update certain columns
17121712GRANT UPDATE
@@ -1725,38 +1725,38 @@ GRANT UPDATE
17251725postgres=> set role admin;
17261726SET
17271727postgres=> table passwd;
1728- username | pwhash | uid | gid | real_name | home_phone | extra_info | home_dir | shell
1729- ----------+--------+-----+-----+-----------+--------------+------------+-------------+-----------
1730- admin | xxx | 0 | 0 | Admin | 111-222-3333 | | /root | /bin/dash
1731- bob | xxx | 1 | 1 | Bob | 123-456-7890 | | /home/bob | /bin/zsh
1732- alice | xxx | 2 | 1 | Alice | 098-765-4321 | | /home/alice | /bin/zsh
1728+ user_name | pwhash | uid | gid | real_name | home_phone | extra_info | home_dir | shell
1729+ ----------- +--------+-----+-----+-----------+--------------+------------+-------------+-----------
1730+ admin | xxx | 0 | 0 | Admin | 111-222-3333 | | /root | /bin/dash
1731+ bob | xxx | 1 | 1 | Bob | 123-456-7890 | | /home/bob | /bin/zsh
1732+ alice | xxx | 2 | 1 | Alice | 098-765-4321 | | /home/alice | /bin/zsh
17331733(3 rows)
17341734
17351735-- Test what Alice is able to do
17361736postgres=> set role alice;
17371737SET
17381738postgres=> table passwd;
17391739ERROR: permission denied for relation passwd
1740- postgres=> selectusername ,real_name,home_phone,extra_info,home_dir,shell from passwd;
1741- username | real_name | home_phone | extra_info | home_dir | shell
1742- ----------+-----------+--------------+------------+-------------+-----------
1743- admin | Admin | 111-222-3333 | | /root | /bin/dash
1744- bob | Bob | 123-456-7890 | | /home/bob | /bin/zsh
1745- alice | Alice | 098-765-4321 | | /home/alice | /bin/zsh
1740+ postgres=> selectuser_name ,real_name,home_phone,extra_info,home_dir,shell from passwd;
1741+ user_name | real_name | home_phone | extra_info | home_dir | shell
1742+ ----------- +-----------+--------------+------------+-------------+-----------
1743+ admin | Admin | 111-222-3333 | | /root | /bin/dash
1744+ bob | Bob | 123-456-7890 | | /home/bob | /bin/zsh
1745+ alice | Alice | 098-765-4321 | | /home/alice | /bin/zsh
17461746(3 rows)
17471747
1748- postgres=> update passwd setusername = 'joe';
1748+ postgres=> update passwd setuser_name = 'joe';
17491749ERROR: permission denied for relation passwd
17501750-- Alice is allowed to change her own real_name, but no others
17511751postgres=> update passwd set real_name = 'Alice Doe';
17521752UPDATE 1
1753- postgres=> update passwd set real_name = 'John Doe' whereusername = 'admin';
1753+ postgres=> update passwd set real_name = 'John Doe' whereuser_name = 'admin';
17541754UPDATE 0
17551755postgres=> update passwd set shell = '/bin/xx';
17561756ERROR: new row violates WITH CHECK OPTION for "passwd"
17571757postgres=> delete from passwd;
17581758ERROR: permission denied for relation passwd
1759- postgres=> insert into passwd (username ) values ('xxx');
1759+ postgres=> insert into passwd (user_name ) values ('xxx');
17601760ERROR: permission denied for relation passwd
17611761-- Alice can change her own password; RLS silently prevents updating other rows
17621762postgres=> update passwd set pwhash = 'abc';
@@ -2055,7 +2055,7 @@ DROP SCHEMA myschema CASCADE;
20552055 (since this is one of the ways to restrict the activities of your
20562056 users to well-defined namespaces). The syntax for that is:
20572057<programlisting>
2058- CREATE SCHEMA <replaceable>schemaname </replaceable> AUTHORIZATION <replaceable>username </replaceable>;
2058+ CREATE SCHEMA <replaceable>schema_name </replaceable> AUTHORIZATION <replaceable>user_name </replaceable>;
20592059</programlisting>
20602060 You can even omit the schema name, in which case the schema name
20612061 will be the same as the user name. See <xref
@@ -2344,7 +2344,7 @@ REVOKE CREATE ON SCHEMA public FROM PUBLIC;
23442344 implements only the basic schema support specified in the
23452345 standard. Therefore, many users consider qualified names to
23462346 really consist of
2347- <literal><replaceable>username </>.<replaceable>tablename </></literal>.
2347+ <literal><replaceable>user_name </>.<replaceable>table_name </></literal>.
23482348 This is how <productname>PostgreSQL</productname> will effectively
23492349 behave if you create a per-user schema for every user.
23502350 </para>