]> andersk Git - moira.git/commitdiff
Check `strings_id' in the numvalues table at startup. A server crash
authordanw <danw>
Thu, 3 Jul 1997 07:52:31 +0000 (07:52 +0000)
committerdanw <danw>
Thu, 3 Jul 1997 07:52:31 +0000 (07:52 +0000)
in the right place could leave it pointing to an already-filled part
of the table, which makes the server unable to add new strings to the
db until it's fixed. (See [687]-[690] in moira-admin.)

server/qvalidate.pc

index 91f1f12c53f37c3414ff049d5d402ca4932d4bee..3ed00cd04ecf7eebc364b594ff05cc323de3522b 100644 (file)
@@ -533,10 +533,25 @@ int readlock_table(vo)
                            */
 }
 
-/* Check the database at startup time. NOT! */
+/* Check the database at startup time. */
 
 void sanity_check_database(void)
 {
+    EXEC SQL BEGIN DECLARE SECTION;
+    int oid, id;
+    EXEC SQL END DECLARE SECTION;
+
+    /* Sometimes a crash can leave strings_id in numvalues in an
+       incorrect state. Check for that and fix it. */
+
+    EXEC SQL SELECT value INTO :oid FROM numvalues WHERE name='strings_id';
+
+    for (id=oid+1; sqlca.sqlcode==0; id++)
+       EXEC SQL SELECT string_id INTO :id FROM strings
+           WHERE string_id=:id;
+
+    if (id!=oid+1)
+       EXEC SQL UPDATE numvalues SET value=:id-1 WHERE name='strings_id';
 }
 
 
This page took 0.417569 seconds and 5 git commands to generate.