summaryrefslogtreecommitdiff
path: root/schema.sql
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-04-13 16:42:51 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-04-13 16:42:51 +0200
commit6035662c8cfc75156a14cf2b8a85a73f7905a954 (patch)
tree3126b7058a566a3a99b5ef98d8a9efb4e932d93a /schema.sql
parentd3e3ad5b428ed46aff71ee0b0e05902cd6ab9678 (diff)
downloadpgfuse-6035662c8cfc75156a14cf2b8a85a73f7905a954.tar.gz
pgfuse-6035662c8cfc75156a14cf2b8a85a73f7905a954.tar.bz2
replace isdir with mode (in database and in code)
Diffstat (limited to 'schema.sql')
-rw-r--r--schema.sql13
1 files changed, 9 insertions, 4 deletions
diff --git a/schema.sql b/schema.sql
index d48c890..9affe44 100644
--- a/schema.sql
+++ b/schema.sql
@@ -3,7 +3,6 @@ CREATE TABLE dir (
parent_id INTEGER REFERENCES dir( id ),
name TEXT,
path TEXT,
- isdir BOOL,
UNIQUE( name, parent_id ),
UNIQUE( path ),
mode INTEGER NOT NULL DEFAULT 0,
@@ -28,17 +27,23 @@ CREATE INDEX data_id_idx ON data( id );
-- directory listings
CREATE INDEX dir_parent_id_idx ON dir( parent_id );
+-- 16384 == S_IFDIR (S_IFDIR)
+-- TODO: should be created by the program after checking the OS
+-- it is running on (for full POSIX compatibility)
+
-- make sure file entries always get a data
-- section in the separate table
CREATE OR REPLACE RULE "dir_insert" AS ON
- INSERT TO dir WHERE NEW.isdir = false
+ INSERT TO dir WHERE NEW.mode & 16384 = 0
DO ALSO INSERT INTO data( id )
VALUES ( currval( 'dir_id_seq' ) );
-- garbage collect deleted file entries
CREATE OR REPLACE RULE "dir_remove" AS ON
- DELETE TO dir WHERE OLD.isdir = false
+ DELETE TO dir WHERE OLD.mode & 16384 = 0
DO ALSO DELETE FROM data WHERE id=OLD.id;
-- self-referencing anchor for root directory
-INSERT INTO dir values( 0, 0, '/', '/', true );
+-- 16895 = S_IFDIR and 0777 permissions
+-- TODO: should be done from outside, see note above
+INSERT INTO dir values( 0, 0, '/', '/', 16895 );