|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.139 2007/04/20 02:37:37 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.140 2007/08/21 01:11:13 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * See acl.h.
|
|
34 | 34 | #include "catalog/pg_proc.h"
|
35 | 35 | #include "catalog/pg_tablespace.h"
|
36 | 36 | #include "catalog/pg_type.h"
|
| 37 | +#include "catalog/pg_ts_config.h" |
| 38 | +#include "catalog/pg_ts_dict.h" |
37 | 39 | #include "commands/dbcommands.h"
|
38 | 40 | #include "miscadmin.h"
|
39 | 41 | #include "parser/parse_func.h"
|
@@ -1416,7 +1418,11 @@ static const char *const no_priv_msg[MAX_ACL_KIND] =
|
1416 | 1418 | /* ACL_KIND_CONVERSION */
|
1417 | 1419 | gettext_noop("permission denied for conversion %s"),
|
1418 | 1420 | /* ACL_KIND_TABLESPACE */
|
1419 |
| - gettext_noop("permission denied for tablespace %s") |
| 1421 | + gettext_noop("permission denied for tablespace %s"), |
| 1422 | + /* ACL_KIND_TSDICTIONARY */ |
| 1423 | + gettext_noop("permission denied for text search dictionary %s"), |
| 1424 | + /* ACL_KIND_TSCONFIGURATION */ |
| 1425 | + gettext_noop("permission denied for text search configuration %s") |
1420 | 1426 | };
|
1421 | 1427 |
|
1422 | 1428 | static const char *const not_owner_msg[MAX_ACL_KIND] =
|
@@ -1444,7 +1450,11 @@ static const char *const not_owner_msg[MAX_ACL_KIND] =
|
1444 | 1450 | /* ACL_KIND_CONVERSION */
|
1445 | 1451 | gettext_noop("must be owner of conversion %s"),
|
1446 | 1452 | /* ACL_KIND_TABLESPACE */
|
1447 |
| - gettext_noop("must be owner of tablespace %s") |
| 1453 | + gettext_noop("must be owner of tablespace %s"), |
| 1454 | + /* ACL_KIND_TSDICTIONARY */ |
| 1455 | + gettext_noop("must be owner of text search dictionary %s"), |
| 1456 | + /* ACL_KIND_TSCONFIGURATION */ |
| 1457 | + gettext_noop("must be owner of text search configuration %s") |
1448 | 1458 | };
|
1449 | 1459 |
|
1450 | 1460 |
|
@@ -2297,6 +2307,65 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
|
2297 | 2307 | return has_privs_of_role(roleid, ownerId);
|
2298 | 2308 | }
|
2299 | 2309 |
|
| 2310 | +/* |
| 2311 | + * Ownership check for a text search dictionary (specified by OID). |
| 2312 | + */ |
| 2313 | +bool |
| 2314 | +pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid) |
| 2315 | +{ |
| 2316 | + HeapTuple tuple; |
| 2317 | + Oid ownerId; |
| 2318 | + |
| 2319 | + /* Superusers bypass all permission checking. */ |
| 2320 | + if (superuser_arg(roleid)) |
| 2321 | + return true; |
| 2322 | + |
| 2323 | + tuple = SearchSysCache(TSDICTOID, |
| 2324 | + ObjectIdGetDatum(dict_oid), |
| 2325 | + 0, 0, 0); |
| 2326 | + if (!HeapTupleIsValid(tuple)) |
| 2327 | + ereport(ERROR, |
| 2328 | + (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 2329 | + errmsg("text search dictionary with OID %u does not exist", |
| 2330 | + dict_oid))); |
| 2331 | + |
| 2332 | + ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner; |
| 2333 | + |
| 2334 | + ReleaseSysCache(tuple); |
| 2335 | + |
| 2336 | + return has_privs_of_role(roleid, ownerId); |
| 2337 | +} |
| 2338 | + |
| 2339 | +/* |
| 2340 | + * Ownership check for a text search configuration (specified by OID). |
| 2341 | + */ |
| 2342 | +bool |
| 2343 | +pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid) |
| 2344 | +{ |
| 2345 | + HeapTuple tuple; |
| 2346 | + Oid ownerId; |
| 2347 | + |
| 2348 | + /* Superusers bypass all permission checking. */ |
| 2349 | + if (superuser_arg(roleid)) |
| 2350 | + return true; |
| 2351 | + |
| 2352 | + tuple = SearchSysCache(TSCONFIGOID, |
| 2353 | + ObjectIdGetDatum(cfg_oid), |
| 2354 | + 0, 0, 0); |
| 2355 | + if (!HeapTupleIsValid(tuple)) |
| 2356 | + ereport(ERROR, |
| 2357 | + (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 2358 | + errmsg("text search configuration with OID %u does not exist", |
| 2359 | + cfg_oid))); |
| 2360 | + |
| 2361 | + ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner; |
| 2362 | + |
| 2363 | + ReleaseSysCache(tuple); |
| 2364 | + |
| 2365 | + return has_privs_of_role(roleid, ownerId); |
| 2366 | +} |
| 2367 | + |
| 2368 | + |
2300 | 2369 | /*
|
2301 | 2370 | * Ownership check for a database (specified by OID).
|
2302 | 2371 | */
|
|
0 commit comments