[vhffs-dev] [722] Removed all references to old owner_gid fields.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 722
Author:   beuss
Date:     2007-07-13 08:01:47 +0000 (Fri, 13 Jul 2007)

Log Message:
-----------
Removed all references to old owner_gid fields. Rewritten some queries removing unnecessary JOINs.

Modified Paths:
--------------
    trunk/vhffs-fs/vhffsfs.c


Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c	2007-07-12 15:28:05 UTC (rev 721)
+++ trunk/vhffs-fs/vhffsfs.c	2007-07-13 08:01:47 UTC (rev 722)
@@ -344,7 +344,7 @@
 	for(cur = group ; *cur ; cur++)
  		if(! ( (*cur >= 'a' && *cur <= 'z') || (*cur >= '0' && *cur <= '9') ) ) return NULL;
 
-	snprintf(query, 256, "SELECT g.groupname FROM vhffs_users u, vhffs_groups g, vhffs_user_group ug WHERE u.uid = %d AND g.groupname = '%s' AND u.uid = ug.uid AND g.gid = ug.gid", fuse_get_context()->uid, group);
+	snprintf(query, 256, "SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON ug.gid = g.gid WHERE ug.uid = %d AND g.groupname = '%s'", fuse_get_context()->uid, group);
 	res=vhffsfs_PGQuery(query);
 	if(!res) return NULL;
 
@@ -400,7 +400,7 @@
 	for(cur = website ; *cur ; cur++)
  		if(! ( (*cur >= 'a' && *cur <= 'z') || (*cur >= '0' && *cur <= '9') || *cur == '-' || *cur == '.') ) return NULL;
 
-	snprintf(query, 256, "SELECT servername FROM vhffs_httpd WHERE owner_gid = (SELECT gid FROM vhffs_groups WHERE groupname = '%s') AND servername = '%s'", group, website);
+	snprintf(query, 256, "SELECT servername FROM vhffs_httpd h INNER JOIN vhffs_object o ON o.object_id = h.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE g.groupname = '%s' AND servername = '%s'", group, website);
 	res=vhffsfs_PGQuery(query);
 	if(!res) return NULL;
 
@@ -439,7 +439,7 @@
 	for(cur = name ; *cur ; cur++)
  		if(! ( (*cur >= 'a' && *cur <= 'z') || (*cur >= '0' && *cur <= '9') ) ) return NULL;
 
-	snprintf(query, 256, "SELECT name FROM vhffs_repository WHERE owner_gid = (SELECT gid FROM vhffs_groups WHERE groupname = '%s') AND name = '%s'", group, name);
+	snprintf(query, 256, "SELECT name FROM vhffs_repository r INNER JOIN vhffs_object o ON o.object_id = r.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE g.groupname = '%s' AND r.name = '%s'", group, name);
 	res=vhffsfs_PGQuery(query);
 	if(!res) return NULL;
 
@@ -462,7 +462,7 @@
 	PGresult *res;
 	char **groups=NULL;
 
-	snprintf(query, 256, "SELECT g.groupname FROM vhffs_users u, vhffs_groups g, vhffs_user_group ug WHERE u.uid = %d AND u.uid = ug.uid AND g.gid = ug.gid", uid);
+	snprintf(query, 256, "SELECT g.groupname FROM vhffs_goups g INNER JOIN vhffs_user_group ug ON ug.gid = g.gid WHERE ug.uid = %d", uid);
 	res=vhffsfs_PGQuery(query);
 	if(!res) return NULL;
 
@@ -494,12 +494,12 @@
 	char **services=NULL;
 
 	// fetch websites
-	snprintf(query1, 256, "SELECT servername FROM vhffs_httpd WHERE owner_gid = %d", gid);
+	snprintf(query1, 256, "SELECT servername FROM vhffs_httpd h INNER JOIN vhffs_object o ON o.object_id = h.object_id WHERE o.owner_gid = %d", gid);
 	res1=vhffsfs_PGQuery(query1);
 	if(!res1) return NULL;
 
 	// fetch repositories
-	snprintf(query2, 256, "SELECT name FROM vhffs_repository WHERE owner_gid = %d", gid);
+	snprintf(query2, 256, "SELECT name FROM vhffs_repository r INNER JOIN vhffs_object o ON o.object_id = r.object_id WHERE o.owner_gid = %d", gid);
 	res2=vhffsfs_PGQuery(query2);
 	if(!res2) {
 		vhffsfs_PGClear(query1, res1);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/