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

Commitcaad70c

Browse files
committed
Docs: assorted minor cleanups.
Standardize on "user_name" for a field name in related examples inddl.sgml; before we had variously "user_name", "username", and "user".The last is flat wrong because it conflicts with a reserved word.Be consistent about entry capitalization in a table in func.sgml.Fix a typo in pgtrgm.sgml.Back-patch to 9.6 and 9.5 as relevant.Alexander Law
1 parent75684fc commitcaad70c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ CREATE POLICY account_managers ON accounts TO managers
16291629

16301630
<programlisting>
16311631
CREATE 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>
16431643
CREATE 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
16641664
CREATE 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
16981698
CREATE 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
17061706
GRANT SELECT, INSERT, UPDATE, DELETE ON passwd TO admin;
17071707
-- Users only get select access on public columns
17081708
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)
17101710
ON passwd TO public;
17111711
-- Allow users to update certain columns
17121712
GRANT UPDATE
@@ -1725,38 +1725,38 @@ GRANT UPDATE
17251725
postgres=&gt; set role admin;
17261726
SET
17271727
postgres=&gt; 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
17361736
postgres=&gt; set role alice;
17371737
SET
17381738
postgres=&gt; table passwd;
17391739
ERROR: permission denied for relation passwd
1740-
postgres=&gt; 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=&gt; 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=&gt; update passwd setusername = 'joe';
1748+
postgres=&gt; update passwd setuser_name = 'joe';
17491749
ERROR: permission denied for relation passwd
17501750
-- Alice is allowed to change her own real_name, but no others
17511751
postgres=&gt; update passwd set real_name = 'Alice Doe';
17521752
UPDATE 1
1753-
postgres=&gt; update passwd set real_name = 'John Doe' whereusername = 'admin';
1753+
postgres=&gt; update passwd set real_name = 'John Doe' whereuser_name = 'admin';
17541754
UPDATE 0
17551755
postgres=&gt; update passwd set shell = '/bin/xx';
17561756
ERROR: new row violates WITH CHECK OPTION for "passwd"
17571757
postgres=&gt; delete from passwd;
17581758
ERROR: permission denied for relation passwd
1759-
postgres=&gt; insert into passwd (username) values ('xxx');
1759+
postgres=&gt; insert into passwd (user_name) values ('xxx');
17601760
ERROR: permission denied for relation passwd
17611761
-- Alice can change her own password; RLS silently prevents updating other rows
17621762
postgres=&gt; 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>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp