[1966] in Moira

home help back first fref pref prev next nref lref last post

changes to moira container table and container related queries

daemon@ATHENA.MIT.EDU (Qing Dong)
Wed Jul 10 15:29:03 2002

Message-Id: <5.1.0.14.2.20020710152253.00ac2108@hesiod>
Date: Wed, 10 Jul 2002 15:29:02 -0400
To: moiradev@mit.edu
From: Qing Dong <dongq@MIT.EDU>
Cc: jcalz@mit.edu
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed

The Pismere team needs to add a public flag to containers. It
works pretty much the same way as the public flag to lists.
Here is our proposed changes to the Moira schema and server code. Please 
let me know of any errors and problems.

Thanks.
Qing

Index: schema.sql
===================================================================
RCS file: 
\\dongq-afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/db/schema.sql,v
retrieving revision 1.28
diff -c -r1.28 schema.sql
*** schema.sql	2002/02/25 16:41:51	1.28
--- schema.sql	2002/07/03 19:43:57
***************
*** 407,412 ****
--- 407,414 ----
   (
   	name		VARCHAR(64) 	DEFAULT CHR(0)	NOT NULL,
   	cnt_id		INTEGER		DEFAULT 0	NOT NULL,
+ 	list_id		INTEGER		DEFAULT 0	NOT NULL,
+ 	publicflg	INTEGER 	DEFAULT 0	NOT NULL,
   	description	VARCHAR(255) 	DEFAULT CHR(0)	NOT NULL,
   	location	VARCHAR(64) 	DEFAULT CHR(0)	NOT NULL,
   	contact		VARCHAR(32) 	DEFAULT CHR(0)	NOT NULL,


Index: qsupport.pc
===================================================================
RCS file: 
\\dongq-afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/server/qsupport.pc,v
retrieving revision 2.41
diff -c -r2.41 qsupport.pc
*** qsupport.pc	2002/03/29 02:24:25	2.41
--- qsupport.pc	2002/07/10 16:10:16
***************
*** 1891,1897 ****
   int update_container(struct query *q, char *argv[], client *cl)
   {
     EXEC SQL BEGIN DECLARE SECTION;
!   int cnt_id, acl_id, memacl_id, who;
     char name[CONTAINERS_NAME_SIZE], newchildname[CONTAINERS_NAME_SIZE];
     char* newname, *entity, *description, *location, *contact, *acl_type, 
*memacl_type;
     EXEC SQL END DECLARE SECTION;
--- 1891,1897 ----
   int update_container(struct query *q, char *argv[], client *cl)
   {
     EXEC SQL BEGIN DECLARE SECTION;
!   int cnt_id, acl_id, memacl_id, who, flag;
     char name[CONTAINERS_NAME_SIZE], newchildname[CONTAINERS_NAME_SIZE];
     char* newname, *entity, *description, *location, *contact, *acl_type, 
*memacl_type;
     EXEC SQL END DECLARE SECTION;
***************
*** 1899,1914 ****
     int cnt, childid;
     char childname[CONTAINERS_NAME_SIZE];
     char *qual;

!   cnt_id = *(int *)argv[0];
!   newname = argv[1];
!   description = argv[2];
!   location = argv[3];
!   contact = argv[4];
!   acl_type = argv[5];
!   acl_id = *(int *)argv[6];
!   memacl_type = argv[7];
!   memacl_id = *(int *)argv[8];
     entity = cl->entity;
     who = cl->client_id;

--- 1899,1921 ----
     int cnt, childid;
     char childname[CONTAINERS_NAME_SIZE];
     char *qual;
+   int index = 0;

!   cnt_id = *(int *)argv[index++];
!   newname = argv[index++];
!
!   if (q->version >= 9)
!   {
! 	flag = *(int *)argv[index++];
!   }
!
!   description = argv[index++];
!   location = argv[index++];
!   contact = argv[index++];
!   acl_type = argv[index++];
!   acl_id = *(int *)argv[index++];
!   memacl_type = argv[index++];
!   memacl_id = *(int *)argv[index++];
     entity = cl->entity;
     who = cl->client_id;

***************
*** 1987,1998 ****
     }

     /* update the remaining fields */
!   EXEC SQL UPDATE containers
!     SET description = NVL(:description, CHR(0)), location = 
NVL(:location, CHR(0)),
!       contact = NVL(:contact, CHR(0)), acl_type = :acl_type, acl_id = 
:acl_id,
!       memacl_type = :memacl_type, memacl_id = :memacl_id,
!       modtime = SYSDATE, modby = :who, modwith = :entity
!     WHERE cnt_id = :cnt_id;

     if (dbms_errno)
       return mr_errcode;
--- 1994,2017 ----
     }

     /* update the remaining fields */
!   if (q->version >= 9)
!   {
! 	EXEC SQL UPDATE containers
! 		SET publicflg= :flag, description = NVL(:description, CHR(0)), location 
= NVL(:location, CHR(0)),
! 			contact = NVL(:contact, CHR(0)), acl_type = :acl_type, acl_id = :acl_id,
! 			memacl_type = :memacl_type, memacl_id = :memacl_id,
! 			modtime = SYSDATE, modby = :who, modwith = :entity
! 		WHERE cnt_id = :cnt_id;
!   }
!   else
!   {
!     EXEC SQL UPDATE containers
! 		SET publicflg= :flag, description = NVL(:description, CHR(0)), location 
= NVL(:location, CHR(0)),
! 			contact = NVL(:contact, CHR(0)), acl_type = :acl_type, acl_id = :acl_id,
! 			memacl_type = :memacl_type, memacl_id = :memacl_id,
! 			modtime = SYSDATE, modby = :who, modwith = :entity
! 		WHERE cnt_id = :cnt_id;
!   }

     if (dbms_errno)
       return mr_errcode;

Index: qaccess.pc
===================================================================
RCS file: 
\\dongq-afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/server/qaccess.pc,v
retrieving revision 2.26
diff -c -r2.26 qaccess.pc
*** qaccess.pc	2001/12/22 02:43:46	2.26
--- qaccess.pc	2002/07/08 19:08:11
***************
*** 669,677 ****
   int access_container(struct query *q, char *argv[], client *cl)
   {
     EXEC SQL BEGIN DECLARE SECTION;
!   int cnt_id, acl_id, memacl_id;
     char acl_type[CONTAINERS_ACL_TYPE_SIZE], 
memacl_type[CONTAINERS_ACL_TYPE_SIZE];
     char name[CONTAINERS_NAME_SIZE], *newname;
     EXEC SQL END DECLARE SECTION;
     int status;

--- 669,678 ----
   int access_container(struct query *q, char *argv[], client *cl)
   {
     EXEC SQL BEGIN DECLARE SECTION;
!   int cnt_id, acl_id, memacl_id, mach_id, machine_owner_id, flag;
     char acl_type[CONTAINERS_ACL_TYPE_SIZE], 
memacl_type[CONTAINERS_ACL_TYPE_SIZE];
     char name[CONTAINERS_NAME_SIZE], *newname;
+   char machine_owner_type[MACHINE_OWNER_TYPE_SIZE];
     EXEC SQL END DECLARE SECTION;
     int status;

***************
*** 679,688 ****

     /* if amcn or dmcn, container id is the second argument */
     if (strcmp(q->shortname, "amcn") == 0 || strcmp(q->shortname, "dmcn") 
== 0)
   	cnt_id = *(int *)argv[1];

!   EXEC SQL SELECT acl_id, acl_type, memacl_id, memacl_type, name
!     INTO :acl_id, :acl_type, :memacl_id, :memacl_type, :name
       FROM containers
       WHERE cnt_id = :cnt_id;

--- 680,692 ----

     /* if amcn or dmcn, container id is the second argument */
     if (strcmp(q->shortname, "amcn") == 0 || strcmp(q->shortname, "dmcn") 
== 0)
+   {
+ 	mach_id = *(int *)argv[0];
   	cnt_id = *(int *)argv[1];
+   }

!   EXEC SQL SELECT acl_id, acl_type, memacl_id, memacl_type, name, publicflg
!     INTO :acl_id, :acl_type, :memacl_id, :memacl_type, :name, :flag
       FROM containers
       WHERE cnt_id = :cnt_id;

***************
*** 712,718 ****

     if (find_member(memacl_type, memacl_id, cl))
       return MR_SUCCESS;
!
     /* Otherwise fail. */
     return MR_PERM;
   }
--- 716,735 ----

     if (find_member(memacl_type, memacl_id, cl))
       return MR_SUCCESS;
!
!   /* if the container is public or the query is delete, grant access if 
client
!    * is on owner list */
!   if (flag || q->type == DELETE)
!     {
! 	  EXEC SQL SELECT owner_type, owner_id INTO :machine_owner_type,
! 	    :machine_owner_id
! 	    FROM machine
! 	    WHERE mach_id = :mach_id;
!
! 	  if (sqlca.sqlerrd[2] == 1 && strcmp("NONE", machine_owner_type) &&
! 		find_member(machine_owner_type, machine_owner_id, cl))
! 	    return MR_SUCCESS;
!     }
     /* Otherwise fail. */
     return MR_PERM;
   }

Index: queries2.c
===================================================================
RCS file: 
\\dongq-afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/server/queries2.c,v
retrieving revision 2.94
diff -c -r2.94 queries2.c
*** queries2.c	2002/04/30 02:18:15	2.94
--- queries2.c	2002/07/10 16:32:45
***************
*** 3343,3349 ****
     "sid",
   };

! static char *gcon_fields[] = {
     "name",
     "name", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name", "modtime", 
"modby", "modwith",
--- 3343,3349 ----
     "sid",
   };

! static char *gcon7_fields[] = {
     "name",
     "name", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name", "modtime", 
"modby", "modwith",
***************
*** 3361,3372 ****
     followup_gcon,
   };

! static char *acon_fields[] = {
     "name", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name",
   };

! static struct valobj acon_valobj[] = {
     {V_CHAR, 0, CONTAINERS_TABLE, "name"},
     {V_LEN, 1, CONTAINERS_TABLE, "description"},
     {V_CHAR, 2, CONTAINERS_TABLE, "location"},
--- 3361,3378 ----
     followup_gcon,
   };

! static char *gcon_fields[] = {
!   "name",
!   "name", "publicflg", "description", "location", "contact",
!   "ace_type", "ace_name", "memace_type", "memace_name", "modtime", 
"modby", "modwith",
! };
!
! static char *acon7_fields[] = {
     "name", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name",
   };

! static struct valobj acon7_valobj[] = {
     {V_CHAR, 0, CONTAINERS_TABLE, "name"},
     {V_LEN, 1, CONTAINERS_TABLE, "description"},
     {V_CHAR, 2, CONTAINERS_TABLE, "location"},
***************
*** 3377,3386 ****
     {V_TYPEDATA, 7, 0, 0, 0, MR_ACE},
   };

   static struct validate acon_validate =
   {
     acon_valobj,
!   8,
     "name",
     "name = '%s'",
     1,
--- 3383,3422 ----
     {V_TYPEDATA, 7, 0, 0, 0, MR_ACE},
   };

+ static struct validate acon7_validate =
+ {
+   acon7_valobj,
+   8,
+   "name",
+   "name = '%s'",
+   1,
+   "cnt_id",
+   0,
+   prefetch_value,
+   set_modtime,
+ };
+
+ static char *acon_fields[] = {
+   "name", "publicflg", "description", "location", "contact",
+   "ace_type", "ace_name", "memace_type", "memace_name",
+ };
+
+ static struct valobj acon_valobj[] = {
+   {V_CHAR, 0, CONTAINERS_TABLE, "name"},
+   {V_NUM, 1},
+   {V_LEN, 2, CONTAINERS_TABLE, "description"},
+   {V_CHAR, 3, CONTAINERS_TABLE, "location"},
+   {V_CHAR, 4, CONTAINERS_TABLE, "contact"},
+   {V_TYPE, 5, 0, "ace_type", 0, MR_ACE},
+   {V_TYPEDATA, 6, 0, 0, 0, MR_ACE},
+   {V_TYPE, 7, 0, "ace_type", 0, MR_ACE},
+   {V_TYPEDATA, 8, 0, 0, 0, MR_ACE},
+ };
+
   static struct validate acon_validate =
   {
     acon_valobj,
!   9,
     "name",
     "name = '%s'",
     1,
***************
*** 3390,3402 ****
     set_modtime,
   };

! static char *ucon_fields[] = {
     "name",
     "newname", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name",
   };

! static struct valobj ucon_valobj[] = {
     {V_ID, 0, CONTAINERS_TABLE, "name", "cnt_id", MR_CONTAINER},
     {V_RENAME, 1, CONTAINERS_TABLE, "name", "cnt_id", MR_NOT_UNIQUE},
     {V_LEN, 2, CONTAINERS_TABLE, "description"},
--- 3426,3438 ----
     set_modtime,
   };

! static char *ucon7_fields[] = {
     "name",
     "newname", "description", "location", "contact",
     "ace_type", "ace_name", "memace_type", "memace_name",
   };

! static struct valobj ucon7_valobj[] = {
     {V_ID, 0, CONTAINERS_TABLE, "name", "cnt_id", MR_CONTAINER},
     {V_RENAME, 1, CONTAINERS_TABLE, "name", "cnt_id", MR_NOT_UNIQUE},
     {V_LEN, 2, CONTAINERS_TABLE, "description"},
***************
*** 3408,3414 ****
     {V_TYPEDATA, 8, 0, 0, 0, MR_ACE},
   };

! static struct validate ucon_validate =
   {
     ucon_valobj,
     9,
--- 3444,3450 ----
     {V_TYPEDATA, 8, 0, 0, 0, MR_ACE},
   };

! static struct validate ucon7_validate =
   {
     ucon_valobj,
     9,
***************
*** 3421,3426 ****
--- 3457,3494 ----
     update_container,
   };

+ static char *ucon_fields[] = {
+   "name",
+   "newname", "publicflg", "description", "location", "contact",
+   "ace_type", "ace_name", "memace_type", "memace_name",
+ };
+
+ static struct valobj ucon_valobj[] = {
+   {V_ID, 0, CONTAINERS_TABLE, "name", "cnt_id", MR_CONTAINER},
+   {V_RENAME, 1, CONTAINERS_TABLE, "name", "cnt_id", MR_NOT_UNIQUE},
+   {V_NUM, 2},
+   {V_LEN, 3, CONTAINERS_TABLE, "description"},
+   {V_CHAR, 4, CONTAINERS_TABLE, "location"},
+   {V_CHAR, 5, CONTAINERS_TABLE, "contact"},
+   {V_TYPE, 6, 0, "ace_type", 0, MR_ACE},
+   {V_TYPEDATA, 7, 0, 0, 0, MR_ACE},
+   {V_TYPE, 8, 0, "ace_type", 0, MR_ACE},
+   {V_TYPEDATA, 9, 0, 0, 0, MR_ACE},
+ };
+
+ static struct validate ucon_validate =
+ {
+   ucon_valobj,
+   10,
+   0,
+   0,
+   0,
+   0,
+   access_container,
+   0,
+   update_container,
+ };
+
   static char *dcon_fields[] = {
     "name",
   };
***************
*** 6985,6991 ****
       "c",
       CONTAINERS_TABLE,
       "name, description, location, contact, acl_type, acl_id, 
memacl_type, memacl_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, 
modwith FROM containers",
!     gcon_fields,
       11,
       "name LIKE '%s' AND cnt_id != 0",
       1,
--- 7053,7059 ----
       "c",
       CONTAINERS_TABLE,
       "name, description, location, contact, acl_type, acl_id, 
memacl_type, memacl_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, 
modwith FROM containers",
!     gcon7_fields,
       11,
       "name LIKE '%s' AND cnt_id != 0",
       1,
***************
*** 6994,6999 ****
--- 7062,7084 ----
     },

     {
+     /* Q_GCON - GET_CONTAINER, v9 */
+     "get_container",
+     "gcon",
+     9,
+     RETRIEVE,
+     "c",
+     CONTAINERS_TABLE,
+     "name, publicflg, description, location, contact, acl_type, acl_id, 
memacl_type, memacl_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, 
modwith FROM containers",
+     gcon_fields,
+     12,
+     "name LIKE '%s' AND cnt_id != 0",
+     1,
+     NULL,
+     &gcon_validate,
+   },
+
+   {
       /* Q_ACON - ADD_CONTAINER, v7 */ /* uses prefetch_value() for cnt_id */
       "add_container",
       "acon",
***************
*** 7002,7012 ****
       "c",
       CONTAINERS_TABLE,
       "INTO containers (name, description, location, contact, acl_type, 
acl_id, memacl_type, memacl_id, cnt_id) VALUES ('%s', NVL('%s', CHR(0)), 
NVL('%s', CHR(0)), NVL('%s', CHR(0)), '%s', %d, '%s', %d, %s)",
!     acon_fields,
       8,
       0,
       0,
       NULL,
       &acon_validate,
     },

--- 7087,7114 ----
       "c",
       CONTAINERS_TABLE,
       "INTO containers (name, description, location, contact, acl_type, 
acl_id, memacl_type, memacl_id, cnt_id) VALUES ('%s', NVL('%s', CHR(0)), 
NVL('%s', CHR(0)), NVL('%s', CHR(0)), '%s', %d, '%s', %d, %s)",
!     acon7_fields,
       8,
       0,
       0,
       NULL,
+     &acon7_validate,
+   },
+
+   {
+     /* Q_ACON - ADD_CONTAINER, v9 */ /* uses prefetch_value() for cnt_id */
+     "add_container",
+     "acon",
+     9,
+     APPEND,
+     "c",
+     CONTAINERS_TABLE,
+     "INTO containers (name, publicflg, description, location, contact, 
acl_type, acl_id, memacl_type, memacl_id, cnt_id) VALUES ('%s', NVL('%s', 
CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), '%s', %d, '%s', %d, %s)",
+     acon_fields,
+     9,
+     0,
+     0,
+     NULL,
       &acon_validate,
     },

***************
*** 7019,7026 ****
       0,
       CONTAINERS_TABLE,
       0,
!     ucon_fields,
       8,
       0,
       1,
       NULL,
--- 7121,7145 ----
       0,
       CONTAINERS_TABLE,
       0,
!     ucon7_fields,
       8,
+     0,
+     1,
+     NULL,
+     &ucon7_validate,
+   },
+
+   {
+     /* Q_UCON - UPDATE_CONTAINER, v9 */
+     "update_container",
+     "ucon",
+     9,
+     UPDATE,
+     0,
+     CONTAINERS_TABLE,
+     0,
+     ucon_fields,
+     9,
       0,
       1,
       NULL,


home help back first fref pref prev next nref lref last post