create pg test data webdav

Sat, 16 Apr 2022 14:36:08 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 16 Apr 2022 14:36:08 +0200
branch
webdav
changeset 288
7dd45173f68a
parent 287
a171da778817
child 289
285d483db2fb

create pg test data

src/server/plugins/postgresql/test/createtestdb.sh file | annotate | diff | comparison | revisions
src/server/plugins/postgresql/test/postgresql_vfs.sql file | annotate | diff | comparison | revisions
src/server/plugins/postgresql/test/postgresql_vfs_testdata.sql file | annotate | diff | comparison | revisions
--- a/src/server/plugins/postgresql/test/createtestdb.sh	Sat Feb 19 16:34:29 2022 +0100
+++ b/src/server/plugins/postgresql/test/createtestdb.sh	Sat Apr 16 14:36:08 2022 +0200
@@ -41,6 +41,23 @@
 fi
 echo "success"
 
+echo "## create test data"
+psql -h $TESTDB_ABS/run -d testdb -f postgresql_vfs.sql
+if [ $? -ne 0 ]; then
+	echo "## create test data (1) failed"
+	echo "## stop database"
+	pg_ctl -D $TESTDB_ABS stop
+	exit 1
+fi
+psql -h $TESTDB_ABS/run -d testdb -f postgresql_vfs_testdata.sql
+if [ $? -ne 0 ]; then
+	echo "## create test data (2) failed"
+	echo "## stop database"
+	pg_ctl -D $TESTDB_ABS stop
+	exit 1
+fi
+echo "success"
+
 echo "## stop database"
 pg_ctl -D $TESTDB_ABS stop
 exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/plugins/postgresql/test/postgresql_vfs.sql	Sat Apr 16 14:36:08 2022 +0200
@@ -0,0 +1,16 @@
+
+create table Resource (
+    resource_id       serial    primary key,
+    parent_id         int       references Resource(resource_id),
+    nodename          text      not null,
+    iscollection      boolean   not null default false,
+	
+    lastmodified      timestamp not null default current_date,
+    creationdate      timestamp not null default current_date,
+    contentlength     bigint    not null default 0,
+
+    resoid            oid,
+    
+    unique(parent_id, nodename)
+);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/plugins/postgresql/test/postgresql_vfs_testdata.sql	Sat Apr 16 14:36:08 2022 +0200
@@ -0,0 +1,29 @@
+
+do $$
+declare
+    res_id int;
+begin
+    insert into Resource (nodename, iscollection) values ('', true);
+    res_id := lastval();
+   
+    insert into Resource(parent_id,  nodename, resoid) values
+    (res_id, 'file1.txt', (select lo_create(0))),
+    (res_id, 'file2.txt', (select lo_create(0))),
+    (res_id, 'file3.txt', (select lo_create(0))),
+    (res_id, 'file4.txt', (select lo_create(0)));
+    
+    insert into Resource(parent_id,  nodename, iscollection) values
+    (res_id, 'dir1', true);
+    res_id := lastval();
+    
+    insert into Resource(parent_id,  nodename, iscollection) values
+    (res_id, 'dir2', true);
+    res_id := lastval();
+    
+    insert into Resource(parent_id,  nodename, resoid) values
+    (res_id, 'd1file1.txt', (select lo_create(0))),
+    (res_id, 'd2file1.txt', (select lo_create(0))),
+    (res_id, 'd2file2.txt', (select lo_create(0)));
+
+end $$;
+

mercurial