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

Commit5ec1341

Browse files
committed
Use plurals (TABLES, FUNCTIONS, etc) in ALTER DEFAULT PRIVILEGES. We have
the keywords as a consequence of the GRANT ALL patch, so we might as welluse them and make the ALTER commands read more naturally.
1 parent11ca04b commit5ec1341

File tree

6 files changed

+44
-39
lines changed

6 files changed

+44
-39
lines changed

‎doc/src/sgml/ref/alter_default_privileges.sgml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_default_privileges.sgml,v 1.1 2009/10/05 19:24:33 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_default_privileges.sgml,v 1.2 2009/10/12 23:41:43 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -30,35 +30,35 @@ ALTER DEFAULT PRIVILEGES
3030

3131
GRANT { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
3232
[,...] | ALL [ PRIVILEGES ] }
33-
ONTABLE
33+
ONTABLES
3434
TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
3535

3636
GRANT { { USAGE | SELECT | UPDATE }
3737
[,...] | ALL [ PRIVILEGES ] }
38-
ONSEQUENCE
38+
ONSEQUENCES
3939
TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
4040

4141
GRANT { EXECUTE | ALL [ PRIVILEGES ] }
42-
ONFUNCTION
42+
ONFUNCTIONS
4343
TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
4444

4545
REVOKE [ GRANT OPTION FOR ]
4646
{ { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
4747
[,...] | ALL [ PRIVILEGES ] }
48-
ONTABLE
48+
ONTABLES
4949
FROM { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...]
5050
[ CASCADE | RESTRICT ]
5151

5252
REVOKE [ GRANT OPTION FOR ]
5353
{ { USAGE | SELECT | UPDATE }
5454
[,...] | ALL [ PRIVILEGES ] }
55-
ONSEQUENCE
55+
ONSEQUENCES
5656
FROM { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...]
5757
[ CASCADE | RESTRICT ]
5858

5959
REVOKE [ GRANT OPTION FOR ]
6060
{ EXECUTE | ALL [ PRIVILEGES ] }
61-
ONFUNCTION
61+
ONFUNCTIONS
6262
FROM { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...]
6363
[ CASCADE | RESTRICT ]
6464
</synopsis>
@@ -165,8 +165,8 @@ REVOKE [ GRANT OPTION FOR ]
165165
role <literal>webuser</> to INSERT into them too:
166166

167167
<programlisting>
168-
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ONTABLE TO PUBLIC;
169-
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT INSERT ONTABLE TO webuser;
168+
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ONTABLES TO PUBLIC;
169+
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT INSERT ONTABLES TO webuser;
170170
</programlisting>
171171
</para>
172172

@@ -175,8 +175,8 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT INSERT ON TABLE TO webuser;
175175
more permissions than normal:
176176

177177
<programlisting>
178-
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE SELECT ONTABLE FROM PUBLIC;
179-
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE INSERT ONTABLE FROM webuser;
178+
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE SELECT ONTABLES FROM PUBLIC;
179+
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE INSERT ONTABLES FROM webuser;
180180
</programlisting>
181181
</para>
182182

@@ -185,7 +185,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE INSERT ON TABLE FROM webuser;
185185
for all functions subsequently created by role <literal>admin</>:
186186

187187
<programlisting>
188-
ALTER DEFAULT PRIVILEGES FOR ROLE admin REVOKE EXECUTE ONFUNCTION FROM PUBLIC;
188+
ALTER DEFAULT PRIVILEGES FOR ROLE admin REVOKE EXECUTE ONFUNCTIONS FROM PUBLIC;
189189
</programlisting>
190190
</para>
191191
</refsect1>

‎src/backend/parser/gram.y

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.684 2009/10/1220:39:41 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.685 2009/10/1223:41:43 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -4676,8 +4676,8 @@ DefACLOption:
46764676
;
46774677

46784678
/*
4679-
* This should match GRANT/REVOKE, except that target objects are missing
4680-
* and we only allow a subset of object types.
4679+
* This should match GRANT/REVOKE, except thatindividualtarget objects
4680+
*are not mentionedand we only allow a subset of object types.
46814681
*/
46824682
DefACLAction:
46834683
GRANT privileges ON defacl_privilege_target TO grantee_list
@@ -4724,9 +4724,9 @@ DefACLAction:
47244724
;
47254725

47264726
defacl_privilege_target:
4727-
TABLE{$$ = ACL_OBJECT_RELATION; }
4728-
|FUNCTION{$$ = ACL_OBJECT_FUNCTION; }
4729-
|SEQUENCE{$$ = ACL_OBJECT_SEQUENCE; }
4727+
TABLES{$$ = ACL_OBJECT_RELATION; }
4728+
|FUNCTIONS{$$ = ACL_OBJECT_FUNCTION; }
4729+
|SEQUENCES{$$ = ACL_OBJECT_SEQUENCE; }
47304730
;
47314731

47324732

‎src/bin/pg_dump/dumputils.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.50 2009/10/07 22:14:24 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.51 2009/10/12 23:41:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -689,7 +689,7 @@ buildACLCommands(const char *name, const char *subname,
689689
/*
690690
* Build ALTER DEFAULT PRIVILEGES command(s) for single pg_default_acl entry.
691691
*
692-
*type: the object type (as seen in GRANT command)
692+
*type: the object type (TABLES, FUNCTIONS, etc)
693693
*nspname: schema name, or NULL for global default privileges
694694
*acls: the ACL string fetched from the database
695695
*owner: username of privileges owner (will be passed through fmtId)
@@ -803,11 +803,13 @@ do { \
803803
resetPQExpBuffer(privs);
804804
resetPQExpBuffer(privswgo);
805805

806-
if (strcmp(type,"TABLE")==0||strcmp(type,"SEQUENCE")==0)
806+
if (strcmp(type,"TABLE")==0||strcmp(type,"SEQUENCE")==0||
807+
strcmp(type,"TABLES")==0||strcmp(type,"SEQUENCES")==0)
807808
{
808809
CONVERT_PRIV('r',"SELECT");
809810

810-
if (strcmp(type,"SEQUENCE")==0)
811+
if (strcmp(type,"SEQUENCE")==0||
812+
strcmp(type,"SEQUENCES")==0)
811813
/* sequence only */
812814
CONVERT_PRIV('U',"USAGE");
813815
else
@@ -830,13 +832,16 @@ do { \
830832
}
831833

832834
/* UPDATE */
833-
if (remoteVersion >=70200||strcmp(type,"SEQUENCE")==0)
835+
if (remoteVersion >=70200||
836+
strcmp(type,"SEQUENCE")==0||
837+
strcmp(type,"SEQUENCES")==0)
834838
CONVERT_PRIV('w',"UPDATE");
835839
else
836840
/* 7.0 and 7.1 have a simpler worldview */
837841
CONVERT_PRIV('w',"UPDATE,DELETE");
838842
}
839-
elseif (strcmp(type,"FUNCTION")==0)
843+
elseif (strcmp(type,"FUNCTION")==0||
844+
strcmp(type,"FUNCTIONS")==0)
840845
CONVERT_PRIV('X',"EXECUTE");
841846
elseif (strcmp(type,"LANGUAGE")==0)
842847
CONVERT_PRIV('U',"USAGE");

‎src/bin/pg_dump/pg_dump.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.550 2009/10/09 21:02:56 petere Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.551 2009/10/12 23:41:43 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -9944,13 +9944,13 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
99449944
switch (daclinfo->defaclobjtype)
99459945
{
99469946
caseDEFACLOBJ_RELATION:
9947-
type="TABLE";
9947+
type="TABLES";
99489948
break;
99499949
caseDEFACLOBJ_SEQUENCE:
9950-
type="SEQUENCE";
9950+
type="SEQUENCES";
99519951
break;
99529952
caseDEFACLOBJ_FUNCTION:
9953-
type="FUNCTION";
9953+
type="FUNCTIONS";
99549954
break;
99559955
default:
99569956
/* shouldn't get here */
@@ -9960,7 +9960,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
99609960
type="";/* keep compiler quiet */
99619961
}
99629962

9963-
appendPQExpBuffer(tag,"DEFAULT%s PRIVILEGES",type);
9963+
appendPQExpBuffer(tag,"DEFAULTPRIVILEGES FOR %s",type);
99649964

99659965
/* build the actual command(s) for this tuple */
99669966
if (!buildDefaultACLCommands(type,

‎src/test/regress/expected/privileges.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no
853853
f
854854
(1 row)
855855

856-
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT SELECT ONTABLE TO public;
856+
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT SELECT ONTABLES TO public;
857857
SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- no
858858
has_table_privilege
859859
---------------------
@@ -880,7 +880,7 @@ SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no
880880
f
881881
(1 row)
882882

883-
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT INSERT ONTABLE TO regressuser1;
883+
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT INSERT ONTABLES TO regressuser1;
884884
DROP TABLE testns.acltest1;
885885
CREATE TABLE testns.acltest1 (x int);
886886
SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- yes
@@ -895,7 +895,7 @@ SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- yes
895895
t
896896
(1 row)
897897

898-
ALTER DEFAULT PRIVILEGES IN SCHEMA testns REVOKE INSERT ONTABLE FROM regressuser1;
898+
ALTER DEFAULT PRIVILEGES IN SCHEMA testns REVOKE INSERT ONTABLES FROM regressuser1;
899899
DROP TABLE testns.acltest1;
900900
CREATE TABLE testns.acltest1 (x int);
901901
SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'SELECT'); -- yes
@@ -910,7 +910,7 @@ SELECT has_table_privilege('regressuser1', 'testns.acltest1', 'INSERT'); -- no
910910
f
911911
(1 row)
912912

913-
ALTER DEFAULT PRIVILEGES FOR ROLE regressuser1 REVOKE EXECUTE ONFUNCTION FROM public;
913+
ALTER DEFAULT PRIVILEGES FOR ROLE regressuser1 REVOKE EXECUTE ONFUNCTIONS FROM public;
914914
SET ROLE regressuser1;
915915
CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
916916
SELECT has_function_privilege('regressuser2', 'testns.foo()', 'EXECUTE'); -- no
@@ -919,7 +919,7 @@ SELECT has_function_privilege('regressuser2', 'testns.foo()', 'EXECUTE'); -- no
919919
f
920920
(1 row)
921921

922-
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ONFUNCTION to public;
922+
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ONFUNCTIONS to public;
923923
DROP FUNCTION testns.foo();
924924
CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
925925
SELECT has_function_privilege('regressuser2', 'testns.foo()', 'EXECUTE'); -- yes

‎src/test/regress/sql/privileges.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ CREATE TABLE testns.acltest1 (x int);
495495
SELECT has_table_privilege('regressuser1','testns.acltest1','SELECT');-- no
496496
SELECT has_table_privilege('regressuser1','testns.acltest1','INSERT');-- no
497497

498-
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANTSELECTONTABLE TO public;
498+
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANTSELECTONTABLES TO public;
499499

500500
SELECT has_table_privilege('regressuser1','testns.acltest1','SELECT');-- no
501501
SELECT has_table_privilege('regressuser1','testns.acltest1','INSERT');-- no
@@ -506,31 +506,31 @@ CREATE TABLE testns.acltest1 (x int);
506506
SELECT has_table_privilege('regressuser1','testns.acltest1','SELECT');-- yes
507507
SELECT has_table_privilege('regressuser1','testns.acltest1','INSERT');-- no
508508

509-
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANT INSERTONTABLE TO regressuser1;
509+
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANT INSERTONTABLES TO regressuser1;
510510

511511
DROPTABLEtestns.acltest1;
512512
CREATETABLEtestns.acltest1 (xint);
513513

514514
SELECT has_table_privilege('regressuser1','testns.acltest1','SELECT');-- yes
515515
SELECT has_table_privilege('regressuser1','testns.acltest1','INSERT');-- yes
516516

517-
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsREVOKE INSERTONTABLEFROM regressuser1;
517+
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsREVOKE INSERTONTABLESFROM regressuser1;
518518

519519
DROPTABLEtestns.acltest1;
520520
CREATETABLEtestns.acltest1 (xint);
521521

522522
SELECT has_table_privilege('regressuser1','testns.acltest1','SELECT');-- yes
523523
SELECT has_table_privilege('regressuser1','testns.acltest1','INSERT');-- no
524524

525-
ALTER DEFAULT PRIVILEGES FOR ROLE regressuser1REVOKE EXECUTEONFUNCTIONFROM public;
525+
ALTER DEFAULT PRIVILEGES FOR ROLE regressuser1REVOKE EXECUTEONFUNCTIONSFROM public;
526526

527527
SET ROLE regressuser1;
528528

529529
CREATEFUNCTIONtestns.foo() RETURNSintAS'select 1' LANGUAGE sql;
530530

531531
SELECT has_function_privilege('regressuser2','testns.foo()','EXECUTE');-- no
532532

533-
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANT EXECUTEONFUNCTION to public;
533+
ALTER DEFAULT PRIVILEGESIN SCHEMA testnsGRANT EXECUTEONFUNCTIONS to public;
534534

535535
DROPFUNCTIONtestns.foo();
536536
CREATEFUNCTIONtestns.foo() RETURNSintAS'select 1' LANGUAGE sql;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp