|
6 | 6 | \getenv abs_builddir PG_ABS_BUILDDIR
|
7 | 7 | -- ensure consistent test output regardless of the default bytea format
|
8 | 8 | SET bytea_output TO escape;
|
| 9 | +-- Test ALTER LARGE OBJECT OWNER, GRANT, COMMENT |
| 10 | +CREATE ROLE regress_lo_user; |
| 11 | +SELECT lo_create(42); |
| 12 | + lo_create |
| 13 | +----------- |
| 14 | + 42 |
| 15 | +(1 row) |
| 16 | + |
| 17 | +ALTER LARGE OBJECT 42 OWNER TO regress_lo_user; |
| 18 | +GRANT SELECT ON LARGE OBJECT 42 TO public; |
| 19 | +COMMENT ON LARGE OBJECT 42 IS 'the ultimate answer'; |
| 20 | +-- Test psql's \lo_list et al (we assume no other LOs exist yet) |
| 21 | +\lo_list |
| 22 | + Large objects |
| 23 | + ID | Owner | Description |
| 24 | +----+-----------------+--------------------- |
| 25 | + 42 | regress_lo_user | the ultimate answer |
| 26 | +(1 row) |
| 27 | + |
| 28 | +\lo_list+ |
| 29 | + Large objects |
| 30 | + ID | Owner | Access privileges | Description |
| 31 | +----+-----------------+------------------------------------+--------------------- |
| 32 | + 42 | regress_lo_user | regress_lo_user=rw/regress_lo_user+| the ultimate answer |
| 33 | + | | =r/regress_lo_user | |
| 34 | +(1 row) |
| 35 | + |
| 36 | +\lo_unlink 42 |
| 37 | +\dl |
| 38 | + Large objects |
| 39 | + ID | Owner | Description |
| 40 | +----+-------+------------- |
| 41 | +(0 rows) |
| 42 | + |
9 | 43 | -- Load a file
|
10 | 44 | CREATE TABLE lotest_stash_values (loid oid, fd integer);
|
11 | 45 | -- lo_creat(mode integer) returns oid
|
12 | 46 | -- The mode arg to lo_creat is unused, some vestigal holdover from ancient times
|
13 | 47 | -- returns the large object id
|
14 | 48 | INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42);
|
15 |
| --- Test ALTER LARGE OBJECT |
16 |
| -CREATE ROLE regress_lo_user; |
17 |
| -DO $$ |
18 |
| - BEGIN |
19 |
| - EXECUTE 'ALTER LARGE OBJECT ' || (select loid from lotest_stash_values) |
20 |
| - || ' OWNER TO regress_lo_user'; |
21 |
| - END |
22 |
| -$$; |
23 |
| -SELECT |
24 |
| - rol.rolname |
25 |
| -FROM |
26 |
| - lotest_stash_values s |
27 |
| - JOIN pg_largeobject_metadata lo ON s.loid = lo.oid |
28 |
| - JOIN pg_authid rol ON lo.lomowner = rol.oid; |
29 |
| - rolname |
30 |
| ------------------ |
31 |
| - regress_lo_user |
32 |
| -(1 row) |
33 |
| - |
34 | 49 | -- NOTE: large objects require transactions
|
35 | 50 | BEGIN;
|
36 | 51 | -- lo_open(lobjId oid, mode integer) returns integer
|
|
0 commit comments