Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b28dfa6d
Commit
b28dfa6d
authored
Aug 11, 2017
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adminpack: Add test suite
Reviewed-by:
David Steele
<
david@pgmasters.net
>
parent
81276fdd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
212 additions
and
0 deletions
+212
-0
contrib/adminpack/.gitignore
contrib/adminpack/.gitignore
+4
-0
contrib/adminpack/Makefile
contrib/adminpack/Makefile
+2
-0
contrib/adminpack/expected/adminpack.out
contrib/adminpack/expected/adminpack.out
+146
-0
contrib/adminpack/sql/adminpack.sql
contrib/adminpack/sql/adminpack.sql
+60
-0
No files found.
contrib/adminpack/.gitignore
0 → 100644
View file @
b28dfa6d
# Generated subdirectories
/log/
/results/
/tmp_check/
contrib/adminpack/Makefile
View file @
b28dfa6d
...
...
@@ -8,6 +8,8 @@ EXTENSION = adminpack
DATA
=
adminpack--1.0.sql
PGFILEDESC
=
"adminpack - support functions for pgAdmin"
REGRESS
=
adminpack
ifdef
USE_PGXS
PG_CONFIG
=
pg_config
PGXS
:=
$(
shell
$(PG_CONFIG)
--pgxs
)
...
...
contrib/adminpack/expected/adminpack.out
0 → 100644
View file @
b28dfa6d
CREATE EXTENSION adminpack;
-- create new file
SELECT pg_file_write('test_file1', 'test1', false);
pg_file_write
---------------
5
(1 row)
SELECT pg_read_file('test_file1');
pg_read_file
--------------
test1
(1 row)
-- append
SELECT pg_file_write('test_file1', 'test1', true);
pg_file_write
---------------
5
(1 row)
SELECT pg_read_file('test_file1');
pg_read_file
--------------
test1test1
(1 row)
-- error, already exists
SELECT pg_file_write('test_file1', 'test1', false);
ERROR: file "test_file1" exists
SELECT pg_read_file('test_file1');
pg_read_file
--------------
test1test1
(1 row)
-- disallowed file paths
SELECT pg_file_write('../test_file0', 'test0', false);
ERROR: path must be in or below the current directory
SELECT pg_file_write('/tmp/test_file0', 'test0', false);
ERROR: absolute path not allowed
SELECT pg_file_write(current_setting('data_directory') || '/test_file4', 'test4', false);
pg_file_write
---------------
5
(1 row)
SELECT pg_file_write(current_setting('data_directory') || '/../test_file4', 'test4', false);
ERROR: reference to parent directory ("..") not allowed
-- rename file
SELECT pg_file_rename('test_file1', 'test_file2');
pg_file_rename
----------------
t
(1 row)
SELECT pg_read_file('test_file1'); -- not there
ERROR: could not stat file "test_file1": No such file or directory
SELECT pg_read_file('test_file2');
pg_read_file
--------------
test1test1
(1 row)
-- error
SELECT pg_file_rename('test_file1', 'test_file2');
WARNING: file "test_file1" is not accessible: No such file or directory
pg_file_rename
----------------
f
(1 row)
-- rename file and archive
SELECT pg_file_write('test_file3', 'test3', false);
pg_file_write
---------------
5
(1 row)
SELECT pg_file_rename('test_file2', 'test_file3', 'test_file3_archive');
pg_file_rename
----------------
t
(1 row)
SELECT pg_read_file('test_file2'); -- not there
ERROR: could not stat file "test_file2": No such file or directory
SELECT pg_read_file('test_file3');
pg_read_file
--------------
test1test1
(1 row)
SELECT pg_read_file('test_file3_archive');
pg_read_file
--------------
test3
(1 row)
-- unlink
SELECT pg_file_unlink('test_file1'); -- does not exist
pg_file_unlink
----------------
f
(1 row)
SELECT pg_file_unlink('test_file2'); -- does not exist
pg_file_unlink
----------------
f
(1 row)
SELECT pg_file_unlink('test_file3');
pg_file_unlink
----------------
t
(1 row)
SELECT pg_file_unlink('test_file3_archive');
pg_file_unlink
----------------
t
(1 row)
SELECT pg_file_unlink('test_file4');
pg_file_unlink
----------------
t
(1 row)
-- superuser checks
CREATE USER regress_user1;
SET ROLE regress_user1;
SELECT pg_file_write('test_file0', 'test0', false);
ERROR: only superuser may access generic file functions
SELECT pg_file_rename('test_file0', 'test_file0');
ERROR: only superuser may access generic file functions
CONTEXT: SQL function "pg_file_rename" statement 1
SELECT pg_file_unlink('test_file0');
ERROR: only superuser may access generic file functions
SELECT pg_logdir_ls();
ERROR: only superuser can list the log directory
RESET ROLE;
DROP USER regress_user1;
-- no further tests for pg_logdir_ls() because it depends on the
-- server's logging setup
contrib/adminpack/sql/adminpack.sql
0 → 100644
View file @
b28dfa6d
CREATE
EXTENSION
adminpack
;
-- create new file
SELECT
pg_file_write
(
'test_file1'
,
'test1'
,
false
);
SELECT
pg_read_file
(
'test_file1'
);
-- append
SELECT
pg_file_write
(
'test_file1'
,
'test1'
,
true
);
SELECT
pg_read_file
(
'test_file1'
);
-- error, already exists
SELECT
pg_file_write
(
'test_file1'
,
'test1'
,
false
);
SELECT
pg_read_file
(
'test_file1'
);
-- disallowed file paths
SELECT
pg_file_write
(
'../test_file0'
,
'test0'
,
false
);
SELECT
pg_file_write
(
'/tmp/test_file0'
,
'test0'
,
false
);
SELECT
pg_file_write
(
current_setting
(
'data_directory'
)
||
'/test_file4'
,
'test4'
,
false
);
SELECT
pg_file_write
(
current_setting
(
'data_directory'
)
||
'/../test_file4'
,
'test4'
,
false
);
-- rename file
SELECT
pg_file_rename
(
'test_file1'
,
'test_file2'
);
SELECT
pg_read_file
(
'test_file1'
);
-- not there
SELECT
pg_read_file
(
'test_file2'
);
-- error
SELECT
pg_file_rename
(
'test_file1'
,
'test_file2'
);
-- rename file and archive
SELECT
pg_file_write
(
'test_file3'
,
'test3'
,
false
);
SELECT
pg_file_rename
(
'test_file2'
,
'test_file3'
,
'test_file3_archive'
);
SELECT
pg_read_file
(
'test_file2'
);
-- not there
SELECT
pg_read_file
(
'test_file3'
);
SELECT
pg_read_file
(
'test_file3_archive'
);
-- unlink
SELECT
pg_file_unlink
(
'test_file1'
);
-- does not exist
SELECT
pg_file_unlink
(
'test_file2'
);
-- does not exist
SELECT
pg_file_unlink
(
'test_file3'
);
SELECT
pg_file_unlink
(
'test_file3_archive'
);
SELECT
pg_file_unlink
(
'test_file4'
);
-- superuser checks
CREATE
USER
regress_user1
;
SET
ROLE
regress_user1
;
SELECT
pg_file_write
(
'test_file0'
,
'test0'
,
false
);
SELECT
pg_file_rename
(
'test_file0'
,
'test_file0'
);
SELECT
pg_file_unlink
(
'test_file0'
);
SELECT
pg_logdir_ls
();
RESET
ROLE
;
DROP
USER
regress_user1
;
-- no further tests for pg_logdir_ls() because it depends on the
-- server's logging setup
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment