@@ -1629,7 +1629,7 @@ CREATE POLICY account_managers ON accounts TO managers
1629
1629
1630
1630
<programlisting>
1631
1631
CREATE POLICY user_policy ON users
1632
- USING (user = current_user);
1632
+ USING (user_name = current_user);
1633
1633
</programlisting>
1634
1634
1635
1635
<para>
@@ -1642,7 +1642,7 @@ CREATE POLICY user_policy ON users
1642
1642
<programlisting>
1643
1643
CREATE POLICY user_policy ON users
1644
1644
USING (true)
1645
- WITH CHECK (user = current_user);
1645
+ WITH CHECK (user_name = current_user);
1646
1646
</programlisting>
1647
1647
1648
1648
<para>
@@ -1662,7 +1662,7 @@ CREATE POLICY user_policy ON users
1662
1662
<programlisting>
1663
1663
-- Simple passwd-file based example
1664
1664
CREATE TABLE passwd (
1665
- username text UNIQUE NOT NULL,
1665
+ user_name text UNIQUE NOT NULL,
1666
1666
pwhash text,
1667
1667
uid int PRIMARY KEY,
1668
1668
gid int NOT NULL,
@@ -1696,17 +1696,17 @@ CREATE POLICY all_view ON passwd FOR SELECT USING (true);
1696
1696
-- Normal users can update their own records, but
1697
1697
-- limit which shells a normal user is allowed to set
1698
1698
CREATE POLICY user_mod ON passwd FOR UPDATE
1699
- USING (current_user = username )
1699
+ USING (current_user = user_name )
1700
1700
WITH CHECK (
1701
- current_user = username AND
1701
+ current_user = user_name AND
1702
1702
shell IN ('/bin/bash','/bin/sh','/bin/dash','/bin/zsh','/bin/tcsh')
1703
1703
);
1704
1704
1705
1705
-- Allow admin all normal rights
1706
1706
GRANT SELECT, INSERT, UPDATE, DELETE ON passwd TO admin;
1707
1707
-- Users only get select access on public columns
1708
1708
GRANT 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)
1710
1710
ON passwd TO public;
1711
1711
-- Allow users to update certain columns
1712
1712
GRANT UPDATE
@@ -1725,38 +1725,38 @@ GRANT UPDATE
1725
1725
postgres=> set role admin;
1726
1726
SET
1727
1727
postgres=> 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
1733
1733
(3 rows)
1734
1734
1735
1735
-- Test what Alice is able to do
1736
1736
postgres=> set role alice;
1737
1737
SET
1738
1738
postgres=> table passwd;
1739
1739
ERROR: permission denied for relation passwd
1740
- postgres=> select username ,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=> select user_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
1746
1746
(3 rows)
1747
1747
1748
- postgres=> update passwd set username = 'joe';
1748
+ postgres=> update passwd set user_name = 'joe';
1749
1749
ERROR: permission denied for relation passwd
1750
1750
-- Alice is allowed to change her own real_name, but no others
1751
1751
postgres=> update passwd set real_name = 'Alice Doe';
1752
1752
UPDATE 1
1753
- postgres=> update passwd set real_name = 'John Doe' where username = 'admin';
1753
+ postgres=> update passwd set real_name = 'John Doe' where user_name = 'admin';
1754
1754
UPDATE 0
1755
1755
postgres=> update passwd set shell = '/bin/xx';
1756
1756
ERROR: new row violates WITH CHECK OPTION for "passwd"
1757
1757
postgres=> delete from passwd;
1758
1758
ERROR: permission denied for relation passwd
1759
- postgres=> insert into passwd (username ) values ('xxx');
1759
+ postgres=> insert into passwd (user_name ) values ('xxx');
1760
1760
ERROR: permission denied for relation passwd
1761
1761
-- Alice can change her own password; RLS silently prevents updating other rows
1762
1762
postgres=> update passwd set pwhash = 'abc';
@@ -2055,7 +2055,7 @@ DROP SCHEMA myschema CASCADE;
2055
2055
(since this is one of the ways to restrict the activities of your
2056
2056
users to well-defined namespaces). The syntax for that is:
2057
2057
<programlisting>
2058
- CREATE SCHEMA <replaceable>schemaname </replaceable> AUTHORIZATION <replaceable>username </replaceable>;
2058
+ CREATE SCHEMA <replaceable>schema_name </replaceable> AUTHORIZATION <replaceable>user_name </replaceable>;
2059
2059
</programlisting>
2060
2060
You can even omit the schema name, in which case the schema name
2061
2061
will be the same as the user name. See <xref
@@ -2344,7 +2344,7 @@ REVOKE CREATE ON SCHEMA public FROM PUBLIC;
2344
2344
implements only the basic schema support specified in the
2345
2345
standard. Therefore, many users consider qualified names to
2346
2346
really consist of
2347
- <literal><replaceable>username </>.<replaceable>tablename </></literal>.
2347
+ <literal><replaceable>user_name </>.<replaceable>table_name </></literal>.
2348
2348
This is how <productname>PostgreSQL</productname> will effectively
2349
2349
behave if you create a per-user schema for every user.
2350
2350
</para>
0 commit comments