Commit 58c909bb authored by Bruce Momjian's avatar Bruce Momjian

OK -- here's take #5.

It "make"s and "make check"s clean against current cvs tip.

There are now both Text and Name variants, and the regression test support
is rolled into the patch. Note that to be complete wrt Name based variants,
there are now 12 user visible versions of has_table_privilege:

has_table_privilege(Text usename, Text relname, Text priv_type)
has_table_privilege(Text usename, Name relname, Text priv_type)
has_table_privilege(Name usename, Text relname, Text priv_type)
has_table_privilege(Name usename, Name relname, Text priv_type)
has_table_privilege(Text relname, Text priv_type) /* assumes current_user */
has_table_privilege(Name relname, Text priv_type) /* assumes current_user */
has_table_privilege(Text usename, Oid reloid, Text priv_type)
has_table_privilege(Name usename, Oid reloid, Text priv_type)
has_table_privilege(Oid reloid, Text priv_type)  /* assumes current_user */
has_table_privilege(Oid usesysid, Text relname, Text priv_type)
has_table_privilege(Oid usesysid, Name relname, Text priv_type)
has_table_privilege(Oid usesysid, Oid reloid, Text priv_type)

For the Text based inputs, a new internal function, get_Name is used
(shamelessly copied from get_seq_name in sequence.c) to downcase if not
quoted, or remove quotes if quoted, and truncate. I also added a few test
cases for the downcasing, quote removal, and Name based variants to the
regression test.

Joe Conway
parent 13a52c1f
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_proc.h,v 1.189 2001/06/07 00:09:30 momjian Exp $ * $Id: pg_proc.h,v 1.190 2001/06/12 15:58:34 momjian Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
...@@ -2627,6 +2627,35 @@ DESCR("unary plus"); ...@@ -2627,6 +2627,35 @@ DESCR("unary plus");
DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - )); DATA(insert OID = 1915 ( numeric_uplus PGUID 12 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_uplus - ));
DESCR("unary plus"); DESCR("unary plus");
DATA(insert OID = 1920 ( has_table_privilege PGUID 12 f t f t 3 f 16 "25 25 25" 100 0 0 100 has_table_privilege_tname_tname - ));
DESCR("user privilege on relation by text username, text relname");
DATA(insert OID = 1921 ( has_table_privilege PGUID 12 f t f t 3 f 16 "25 19 25" 100 0 0 100 has_table_privilege_tname_name - ));
DESCR("user privilege on relation by text username, name relname");
DATA(insert OID = 1922 ( has_table_privilege PGUID 12 f t f t 3 f 16 "19 25 25" 100 0 0 100 has_table_privilege_name_tname - ));
DESCR("user privilege on relation by name username, text relname");
DATA(insert OID = 1923 ( has_table_privilege PGUID 12 f t f t 3 f 16 "19 19 25" 100 0 0 100 has_table_privilege_name_name - ));
DESCR("user privilege on relation by name username, name relname");
DATA(insert OID = 1924 ( has_table_privilege PGUID 12 f t f t 2 f 16 "25 25" 100 0 0 100 has_table_privilege_tname - ));
DESCR("current user privilege on relation by text relname");
DATA(insert OID = 1925 ( has_table_privilege PGUID 12 f t f t 2 f 16 "19 25" 100 0 0 100 has_table_privilege_name - ));
DESCR("current user privilege on relation by name relname");
DATA(insert OID = 1926 ( has_table_privilege PGUID 12 f t f t 3 f 16 "25 26 25" 100 0 0 100 has_table_privilege_tname_id - ));
DESCR("user privilege on relation by text username, rel oid");
DATA(insert OID = 1927 ( has_table_privilege PGUID 12 f t f t 3 f 16 "19 26 25" 100 0 0 100 has_table_privilege_name_id - ));
DESCR("user privilege on relation by text username, rel oid");
DATA(insert OID = 1928 ( has_table_privilege PGUID 12 f t f t 2 f 16 "26 25" 100 0 0 100 has_table_privilege_id - ));
DESCR("current user privilege on relation by rel oid");
DATA(insert OID = 1929 ( has_table_privilege PGUID 12 f t f t 3 f 16 "26 25 25" 100 0 0 100 has_table_privilege_id_tname - ));
DESCR("user privilege on relation by usesysid, relname");
DATA(insert OID = 1930 ( has_table_privilege PGUID 12 f t f t 3 f 16 "26 19 25" 100 0 0 100 has_table_privilege_id_name - ));
DESCR("user privilege on relation by usesysid, relname");
DATA(insert OID = 1931 ( has_table_privilege PGUID 12 f t f t 3 f 16 "26 26 25" 100 0 0 100 has_table_privilege_id_id - ));
DESCR("user privilege on relation by usesysid, rel oid");
/* /*
* prototypes for functions pg_proc.c * prototypes for functions pg_proc.c
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: acl.h,v 1.34 2001/06/09 23:21:55 petere Exp $ * $Id: acl.h,v 1.35 2001/06/12 15:58:34 momjian Exp $
* *
* NOTES * NOTES
* For backward-compatibility purposes we have to allow there * For backward-compatibility purposes we have to allow there
...@@ -191,6 +191,22 @@ extern Datum aclcontains(PG_FUNCTION_ARGS); ...@@ -191,6 +191,22 @@ extern Datum aclcontains(PG_FUNCTION_ARGS);
extern const char *aclparse(const char *s, AclItem *aip, unsigned *modechg); extern const char *aclparse(const char *s, AclItem *aip, unsigned *modechg);
extern char *makeAclString(const char *privileges, const char *grantee, char grant_or_revoke); extern char *makeAclString(const char *privileges, const char *grantee, char grant_or_revoke);
extern Datum has_table_privilege_tname_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_id(PG_FUNCTION_ARGS);
/* /*
* prototypes for functions in aclchk.c * prototypes for functions in aclchk.c
*/ */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: builtins.h,v 1.150 2001/06/09 22:16:17 tgl Exp $ * $Id: builtins.h,v 1.151 2001/06/12 15:58:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -22,6 +22,24 @@ ...@@ -22,6 +22,24 @@
/* /*
* Defined in adt/ * Defined in adt/
*/ */
/* acl.c */
extern Datum has_table_privilege_tname_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_tname_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_name_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_tname(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_name(PG_FUNCTION_ARGS);
extern Datum has_table_privilege_id_id(PG_FUNCTION_ARGS);
/* bool.c */ /* bool.c */
extern Datum boolin(PG_FUNCTION_ARGS); extern Datum boolin(PG_FUNCTION_ARGS);
extern Datum boolout(PG_FUNCTION_ARGS); extern Datum boolout(PG_FUNCTION_ARGS);
......
...@@ -62,6 +62,7 @@ ignore: random ...@@ -62,6 +62,7 @@ ignore: random
test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index
test: privileges test: privileges
test: has_table_priv
test: misc test: misc
# ---------- # ----------
......
# $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.4 2001/05/27 09:59:30 petere Exp $ # $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.5 2001/06/12 15:58:34 momjian Exp $
# This should probably be in an order similar to parallel_schedule. # This should probably be in an order similar to parallel_schedule.
test: boolean test: boolean
test: char test: char
...@@ -69,6 +69,7 @@ test: arrays ...@@ -69,6 +69,7 @@ test: arrays
test: btree_index test: btree_index
test: hash_index test: hash_index
test: privileges test: privileges
test: has_table_priv
test: misc test: misc
test: select_views test: select_views
test: alter_table test: alter_table
......
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