]> andersk Git - moira.git/blobdiff - server/qrtn.qc
Fix for new type of make config
[moira.git] / server / qrtn.qc
index c7849e304bcc3dade9f51e7c8159d87656cd1162..3d432483dab3d235cbd3264d222a1ac594f2d410 100644 (file)
@@ -4,6 +4,8 @@
  *     $Header$
  *
  *     Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  * 
  */
 
@@ -11,6 +13,7 @@
 static char *rcsid_qrtn_qc = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include "query.h"
 #include "sms_server.h"
 
@@ -22,6 +25,7 @@ extern FILE *journal;
 
 #define INGRES_BAD_INT 4111
 #define INGRES_BAD_DATE 4302
+#define INGRES_DEADLOCK 4700
 
 /*
  * ingerr: (supposedly) called when Ingres indicates an error.
@@ -41,11 +45,14 @@ static int ingerr(num)
     case INGRES_BAD_DATE:
        ingres_errno = SMS_DATE;
        break;
+    case INGRES_DEADLOCK:
+       com_err(whoami, 0, "INGRES deadlock detected");
+       ingres_errno = SMS_DEADLOCK;
+       break;
     default:
        ingres_errno = SMS_INGRES_ERR;
        com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
-       sprintf(buf, "Ingres error %d", *num);
-       send_zgram("ingres_error", buf);
+       critical_alert("SMS", "SMS server encountered INGRES ERROR %d", *num);
        return (*num);
     }
     return (0);
@@ -66,6 +73,7 @@ int sms_open_database()
        
     /* open the database */
 ##  ingres sms
+##  set lockmode session where readlock = exclusive
     return ingres_errno;
 }
 
@@ -133,8 +141,10 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
     if (q == (struct query *)0) return(SMS_NO_HANDLE);
     v = q->validate;
 
-    if (q->type != RETRIEVE)
+    if (q->type != RETRIEVE) {
+##     set lockmode session where readlock = exclusive
 ##      begin transaction
+    }
 
     /* setup argument vector, verify access and arguments */
     if ((status = sms_verify_query(cl, q, argc, argv_ro)) != SMS_SUCCESS)
@@ -188,9 +198,6 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
                status = do_retrieve(q, pqual, psort, action, actarg);
            }
            if (status != SMS_SUCCESS) break;
-           table = q->rtable;
-##          repeat replace tblstats (retrieves = tblstats.retrieves + 1)
-##                 where tblstats.#table = @table
        } else {
            status = (*v->post_rtn)(q, Argv, cl, action, actarg);
        }
@@ -211,9 +218,11 @@ sms_process_query(cl, name, argc, argv_ro, action, actarg)
            status = do_update(q, &Argv[q->argc], qual, action, actarg);
            if (status != SMS_SUCCESS) break;
            table = q->rtable;
-##         repeat replace tblstats (updates = tblstats.updates + 1,
-##                                  modtime = "now")
-##             where tblstats.#table = @table
+           if (strcmp(q->shortname, "sshi") && strcmp(q->shortname, "ssif")) {
+##             repeat replace tblstats (updates = tblstats.updates + 1,
+##                                      modtime = "now")
+##                 where tblstats.#table = @table
+           }
        }
 
        /* execute followup routine (if any) */
@@ -286,6 +295,7 @@ out:
     if (q->type != RETRIEVE) {
         if (status == SMS_SUCCESS) {
 ##          end transaction    /* commit to this */
+##         set lockmode session where readlock = system
            if (journal) {
                char buf[1024], *bp;
                int i;
@@ -305,7 +315,9 @@ out:
                fflush(journal);
            }
        } else {
-##          abort              /* it never happened */
+           if (status != SMS_DEADLOCK) {
+##             abort           /* it never happened */
+           }
        }
     }
 
@@ -402,6 +414,8 @@ sms_verify_query(cl, q, argc, argv_ro)
     register int privileged = 0;
 
     /* copy the arguments into a local argv that we can modify */
+    if (argc >= QMAXARGS)
+      return(SMS_ARGS);
     for (i = 0; i < argc; i++) {
        if (strlen(argv_ro[i]) < ARGLEN)
            strcpy(Argv[i], argv_ro[i]);
@@ -530,6 +544,10 @@ get_client(cl, client_type, client_id)
     int child;
     struct save_queue *sq_create();
 
+    if (!strcmp(strtrim(list_type), strtrim(member_type)) &&
+       list_id == member_id)
+       return(1);
+
     /* see if client is a direct member of list */
 ##  repeat retrieve (exists = any(m.#member_id where 
 ##                               m.#list_id = @list_id and
@@ -669,7 +687,7 @@ do_update(q, argv, qual, action, actarg)
 ##  where cqual
 
 ##  inquire_equel (errorno = "errorno")
-    if (errorno == 4111)
+    if (errorno == INGRES_BAD_INT)
        return(SMS_INTEGER);
     else if (errorno != 0)
        return(SMS_INGRES_ERR);
@@ -800,16 +818,3 @@ sanity_check_queries()
        exit(1);
     }
 }
-
-
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
-
This page took 0.041546 seconds and 4 git commands to generate.