diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-31 22:39:17 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-31 22:39:17 +0000 |
| commit | 7d0c4188f1b2c5e6b158dac3acab6def10959cae (patch) | |
| tree | 599c1c4d2231c2ad78cf3c9ec43472b78abff6a9 /src/include | |
| parent | b7319d371790c6103813ab1c6ac4646ba985c9d8 (diff) | |
| download | postgresql-7d0c4188f1b2c5e6b158dac3acab6def10959cae.tar.gz | |
Make acl-related functions safe for TOAST. Mark pg_class.relacl as
compressible but not externally storable (since we're not sure about
whether creating a toast relation for pg_class would work).
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/pg_attribute.h | 21 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.h | 18 | ||||
| -rw-r--r-- | src/include/postgres.h | 6 | ||||
| -rw-r--r-- | src/include/utils/acl.h | 65 |
4 files changed, 69 insertions, 41 deletions
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 925328e2bd..0ced47b064 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.61 2000/07/03 23:10:05 wieck Exp $ + * $Id: pg_attribute.h,v 1.62 2000/07/31 22:39:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -124,15 +124,16 @@ CATALOG(pg_attribute) BOOTSTRAP char attstorage; - /* + /*---------- * attstorage tells for VARLENA attributes, what the heap access * methods can do to it if a given tuple doesn't fit into a page. - * Possible values are 'p': Value must be stored plain allways 'e': - * Value can be stored in "secondary" relation (if relation has - * rellongrelid attached) 'c': Value can be stored compressed inline - * 'x': Value can be stored compressed inline or in "secondary". - * - * Note: compressed storage + * Possible values are + * 'p': Value must be stored plain always + * 'e': Value can be stored in "secondary" relation (if relation + * has rellongrelid attached) + * 'm': Value can be stored compressed inline + * 'x': Value can be stored compressed inline or in "secondary" + *---------- */ bool attisset; @@ -439,7 +440,7 @@ DATA(insert OID = 0 ( 1249 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); { 1259, {"relhaspkey"}, 16, 0, 1, 18, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ { 1259, {"relhasrules"}, 16, 0, 1, 19, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ { 1259, {"relhassubclass"},16, 0, 1, 20, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relacl"}, 1034, 0, -1, 21, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' } +{ 1259, {"relacl"}, 1034, 0, -1, 21, 0, -1, -1, '\0', 'm', '\0', 'i', '\0', '\0' } DATA(insert OID = 0 ( 1259 relname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 reltype 26 0 4 2 0 -1 -1 t p f i f f)); @@ -461,7 +462,7 @@ DATA(insert OID = 0 ( 1259 relrefs 21 0 2 17 0 -1 -1 t p f s f f)); DATA(insert OID = 0 ( 1259 relhaspkey 16 0 1 18 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1259 relhasrules 16 0 1 19 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1259 relhassubclass 16 0 1 20 0 -1 -1 t p f c f f)); -DATA(insert OID = 0 ( 1259 relacl 1034 0 -1 21 0 -1 -1 f p f i f f)); +DATA(insert OID = 0 ( 1259 relacl 1034 0 -1 21 0 -1 -1 f m f i f f)); DATA(insert OID = 0 ( 1259 ctid 27 0 6 -1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 oid 26 0 4 -2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 xmin 28 0 4 -3 0 -1 -1 t p f i f f)); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 6b833400c0..7d06975b70 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.153 2000/07/30 22:14:01 tgl Exp $ + * $Id: pg_proc.h,v 1.154 2000/07/31 22:39:05 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -1256,16 +1256,16 @@ DATA(insert OID = 1029 ( nullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 DESCR("(internal)"); DATA(insert OID = 1030 ( nonnullvalue PGUID 12 f t t f 1 f 16 "0" 100 0 0 100 nonnullvalue - )); DESCR("(internal)"); -DATA(insert OID = 1031 ( aclitemin PGUID 11 f t f t 1 f 1033 "0" 100 0 0 100 aclitemin - )); +DATA(insert OID = 1031 ( aclitemin PGUID 12 f t f t 1 f 1033 "0" 100 0 0 100 aclitemin - )); DESCR("(internal)"); -DATA(insert OID = 1032 ( aclitemout PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 aclitemout - )); +DATA(insert OID = 1032 ( aclitemout PGUID 12 f t f t 1 f 23 "1033" 100 0 0 100 aclitemout - )); DESCR("(internal)"); -DATA(insert OID = 1035 ( aclinsert PGUID 11 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclinsert - )); -DESCR("addition"); -DATA(insert OID = 1036 ( aclremove PGUID 11 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclremove - )); -DESCR("subtract"); -DATA(insert OID = 1037 ( aclcontains PGUID 11 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - )); -DESCR("matches regex., case-sensitive"); +DATA(insert OID = 1035 ( aclinsert PGUID 12 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclinsert - )); +DESCR("add/update ACL item"); +DATA(insert OID = 1036 ( aclremove PGUID 12 f t f t 2 f 1034 "1034 1033" 100 0 0 100 aclremove - )); +DESCR("remove ACL item"); +DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - )); +DESCR("does ACL contain item?"); DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 f 23 "26" 100 0 0 100 seteval - )); DESCR(""); DATA(insert OID = 1044 ( bpcharin PGUID 12 f t t t 3 f 1042 "0 26 23" 100 0 0 100 bpcharin - )); diff --git a/src/include/postgres.h b/src/include/postgres.h index f11e28ed9f..1011d04cbb 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1995, Regents of the University of California * - * $Id: postgres.h,v 1.43 2000/07/03 23:09:56 wieck Exp $ + * $Id: postgres.h,v 1.44 2000/07/31 22:39:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,8 +46,6 @@ * ---------------------------------------------------------------- */ -typedef int4 aclitem; - #define InvalidOid ((Oid) 0) #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) @@ -57,6 +55,8 @@ typedef Oid RegProcedure; #define RegProcedureIsValid(p) OidIsValid(p) +typedef int4 aclitem; /* PHONY definition for catalog use only */ + /* ---------------------------------------------------------------- * Section 2: variable length and array types * ---------------------------------------------------------------- diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index f1f60fca4c..e8a8f3a111 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,17 +7,16 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: acl.h,v 1.25 2000/04/12 17:16:54 momjian Exp $ + * $Id: acl.h,v 1.26 2000/07/31 22:39:02 tgl Exp $ * * NOTES - * For backward-compatability purposes we have to allow there + * For backward-compatibility purposes we have to allow there * to be a null ACL in a pg_class tuple. This will be defined as * meaning "no protection" (i.e., old catalogs get old semantics). * * The AclItems in an ACL array are currently kept in sorted order. * Things will break hard if you change that without changing the * code wherever this is included. - * *------------------------------------------------------------------------- */ #ifndef ACL_H @@ -78,7 +77,7 @@ typedef struct AclItem AclMode ai_mode; /* - * This is actually type 'aclitem', and we want a fixed size for for + * This is actually type 'aclitem', and we want a fixed size for * all platforms, so we pad this with dummies. */ char dummy1, @@ -88,22 +87,30 @@ typedef struct AclItem /* Note: if the size of AclItem changes, change the aclitem typlen in pg_type.h */ + /* - * The value of the first dimension-array element. Since these arrays - * always have a lower-bound of 0, this is the same as the number of - * elements in the array. + * Definitions for convenient access to Acl (array of AclItem) and IdList + * (array of AclId). These are standard Postgres arrays, but are restricted + * to have one dimension. We also ignore the lower bound when reading, + * and set it to zero when writing. + * + * CAUTION: as of Postgres 7.1, these arrays are toastable (just like all + * other array types). Therefore, be careful to detoast them with the + * macros provided, unless you know for certain that a particular array + * can't have been toasted. Presently, we do not provide toast tables for + * pg_class or pg_group, so the entries in those tables won't have been + * stored externally --- but they could have been compressed! */ -#define ARR_DIM0(a) (((unsigned *) (((char *) a) + sizeof(ArrayType)))[0]) + /* * Acl a one-dimensional POSTGRES array of AclItem */ typedef ArrayType Acl; -#define ACL_NUM(ACL) ARR_DIM0(ACL) +#define ACL_NUM(ACL) (ARR_DIMS(ACL)[0]) #define ACL_DAT(ACL) ((AclItem *) ARR_DATA_PTR(ACL)) -#define ACL_N_SIZE(N) \ - ((unsigned) (ARR_OVERHEAD(1) + ((N) * sizeof(AclItem)))) +#define ACL_N_SIZE(N) (ARR_OVERHEAD(1) + ((N) * sizeof(AclItem))) #define ACL_SIZE(ACL) ARR_SIZE(ACL) /* @@ -111,12 +118,32 @@ typedef ArrayType Acl; */ typedef ArrayType IdList; -#define IDLIST_NUM(IDL) ARR_DIM0(IDL) +#define IDLIST_NUM(IDL) (ARR_DIMS(IDL)[0]) #define IDLIST_DAT(IDL) ((AclId *) ARR_DATA_PTR(IDL)) -#define IDLIST_N_SIZE(N) \ - ((unsigned) (ARR_OVERHEAD(1) + ((N) * sizeof(AclId)))) +#define IDLIST_N_SIZE(N) (ARR_OVERHEAD(1) + ((N) * sizeof(AclId))) #define IDLIST_SIZE(IDL) ARR_SIZE(IDL) +/* + * fmgr macros for these types + */ +#define DatumGetAclItemP(X) ((AclItem *) DatumGetPointer(X)) +#define PG_GETARG_ACLITEM_P(n) DatumGetAclItemP(PG_GETARG_DATUM(n)) +#define PG_RETURN_ACLITEM_P(x) PG_RETURN_POINTER(x) + +#define DatumGetAclP(X) ((Acl *) PG_DETOAST_DATUM(X)) +#define DatumGetAclPCopy(X) ((Acl *) PG_DETOAST_DATUM_COPY(X)) +#define PG_GETARG_ACL_P(n) DatumGetAclP(PG_GETARG_DATUM(n)) +#define PG_GETARG_ACL_P_COPY(n) DatumGetAclPCopy(PG_GETARG_DATUM(n)) +#define PG_RETURN_ACL_P(x) PG_RETURN_POINTER(x) + +#define DatumGetIdListP(X) ((IdList *) PG_DETOAST_DATUM(X)) +#define DatumGetIdListPCopy(X) ((IdList *) PG_DETOAST_DATUM_COPY(X)) +#define PG_GETARG_IDLIST_P(n) DatumGetIdListP(PG_GETARG_DATUM(n)) +#define PG_GETARG_IDLIST_P_COPY(n) DatumGetIdListPCopy(PG_GETARG_DATUM(n)) +#define PG_RETURN_IDLIST_P(x) PG_RETURN_POINTER(x) + + +/* mode indicators for I/O */ #define ACL_MODECHG_STR "+-=" /* list of valid characters */ #define ACL_MODECHG_ADD_CHR '+' #define ACL_MODECHG_DEL_CHR '-' @@ -157,11 +184,11 @@ extern ChangeACLStmt *makeAclStmt(char *privs, List *rel_list, char *grantee, * exported routines (from acl.c) */ extern Acl *makeacl(int n); -extern AclItem *aclitemin(char *s); -extern char *aclitemout(AclItem *aip); -extern Acl *aclinsert(Acl *old_acl, AclItem *mod_aip); -extern Acl *aclremove(Acl *old_acl, AclItem *mod_aip); -extern int32 aclcontains(Acl *acl, AclItem *aip); +extern Datum aclitemin(PG_FUNCTION_ARGS); +extern Datum aclitemout(PG_FUNCTION_ARGS); +extern Datum aclinsert(PG_FUNCTION_ARGS); +extern Datum aclremove(PG_FUNCTION_ARGS); +extern Datum aclcontains(PG_FUNCTION_ARGS); /* * prototypes for functions in aclchk.c |
