Fix minor nbtree page deletion buffer lock issue.
[pgsql.git] / contrib / adminpack / sql / adminpack.sql
blob918d0bdc65ee988ded7757b1a25cacbf387feb5e
1 CREATE EXTENSION adminpack;
3 -- create new file
4 SELECT pg_file_write('test_file1', 'test1', false);
5 SELECT pg_read_file('test_file1');
7 -- append
8 SELECT pg_file_write('test_file1', 'test1', true);
9 SELECT pg_read_file('test_file1');
11 -- error, already exists
12 SELECT pg_file_write('test_file1', 'test1', false);
13 SELECT pg_read_file('test_file1');
15 -- disallowed file paths for non-superusers and users who are
16 -- not members of pg_write_server_files
17 CREATE ROLE regress_user1;
19 GRANT pg_read_all_settings TO regress_user1;
20 GRANT EXECUTE ON FUNCTION pg_file_write(text,text,bool) TO regress_user1;
22 SET ROLE regress_user1;
23 SELECT pg_file_write('../test_file0', 'test0', false);
24 SELECT pg_file_write('/tmp/test_file0', 'test0', false);
25 SELECT pg_file_write(current_setting('data_directory') || '/test_file4', 'test4', false);
26 SELECT pg_file_write(current_setting('data_directory') || '/../test_file4', 'test4', false);
27 RESET ROLE;
28 REVOKE EXECUTE ON FUNCTION pg_file_write(text,text,bool) FROM regress_user1;
29 REVOKE pg_read_all_settings FROM regress_user1;
30 DROP ROLE regress_user1;
32 -- sync
33 SELECT pg_file_sync('test_file1'); -- sync file
34 SELECT pg_file_sync('pg_stat'); -- sync directory
35 SELECT pg_file_sync('test_file2'); -- not there
37 -- rename file
38 SELECT pg_file_rename('test_file1', 'test_file2');
39 SELECT pg_read_file('test_file1');  -- not there
40 SELECT pg_read_file('test_file2');
42 -- error
43 SELECT pg_file_rename('test_file1', 'test_file2');
45 -- rename file and archive
46 SELECT pg_file_write('test_file3', 'test3', false);
47 SELECT pg_file_rename('test_file2', 'test_file3', 'test_file3_archive');
48 SELECT pg_read_file('test_file2');  -- not there
49 SELECT pg_read_file('test_file3');
50 SELECT pg_read_file('test_file3_archive');
53 -- unlink
54 SELECT pg_file_unlink('test_file1');  -- does not exist
55 SELECT pg_file_unlink('test_file2');  -- does not exist
56 SELECT pg_file_unlink('test_file3');
57 SELECT pg_file_unlink('test_file3_archive');
58 SELECT pg_file_unlink('test_file4');
61 -- superuser checks
62 CREATE USER regress_user1;
63 SET ROLE regress_user1;
65 SELECT pg_file_write('test_file0', 'test0', false);
66 SELECT pg_file_sync('test_file0');
67 SELECT pg_file_rename('test_file0', 'test_file0');
68 SELECT pg_file_unlink('test_file0');
69 SELECT pg_logdir_ls();
71 RESET ROLE;
72 DROP USER regress_user1;
75 -- no further tests for pg_logdir_ls() because it depends on the
76 -- server's logging setup