ctdldump/ctdlload: removed tables that can be re-generated by the server.
authorArt Cancro <ajc@citadel.org>
Mon, 17 Jul 2023 21:11:18 +0000 (12:11 -0900)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Jul 2023 21:11:18 +0000 (12:11 -0900)
Added a new config key to the server that forces it to do that the next time it is run.

citadel/server/modules/upgrade/serv_upgrade.c
citadel/utils/ctdldump.c
citadel/utils/ctdlload.c

index e08c65d17c859139469fb1a983542af59f4f9ff6..b06e19d19db198a9528005f7360725bb028b022a 100644 (file)
@@ -441,6 +441,18 @@ void create_default_admin_account(void) {
 }
 
 
+void regenerate_secondary_indices(void) {
+       syslog(LOG_INFO, "regenerate_secondary_indices has been activated.");
+
+       rebuild_usersbynumber();
+       rebuild_euid_index();
+       CtdlRebuildDirectoryIndex();
+       // we also need to trigger the fulltext foo
+
+       CtdlSetConfigInt("regenerate_secondary_indices", 0);
+}
+
+
 // Based on the server version number reported by the existing database,
 // run in-place data format upgrades until everything is up to date.
 void pre_startup_upgrades(void) {
@@ -508,6 +520,13 @@ void pre_startup_upgrades(void) {
        if (oldver == 0) {
                create_default_admin_account();
        }
+
+       // Setting this key to nonzero causes the server to regenerate all data that can be derived
+       // from other tables: usersbynumber, directory, fulltext.
+       // The import utility (ctdlload) sets this key.
+       if (CtdlGetConfigInt("regenerate_secondary_indices") != 0) {
+               regenerate_secondary_indices();
+       }
 }
 
 
index 7e84a0df7e20c22f99ebe91ec40ca1071536eab9..e78be28fb5d81aab32e38a1ba5d5081b3cc1770e 100644 (file)
@@ -273,11 +273,11 @@ void export_visit(int which_cdb, DBT *in_key, DBT *in_data) {
 
 // export function for a directory record
 // (This is a secondary index -- should we just regenerate the data after import?)
-void export_dir(int which_cdb, DBT *in_key, DBT *in_data) {
-       printf("dir|");
-       fwrite(in_key->data, in_key->size, 1, stdout);
-       printf("|%s|\n", (char *)in_data->data);
-}
+// void export_dir(int which_cdb, DBT *in_key, DBT *in_data) {
+       // printf("dir|");
+       // fwrite(in_key->data, in_key->size, 1, stdout);
+       // printf("|%s|\n", (char *)in_data->data);
+// }
 
 
 // export function for a use table record
@@ -297,7 +297,7 @@ void export_bigmsg(int which_cdb, DBT *in_key, DBT *in_data) {
 
 
 // export function for EUID Index records
-void export_euidindex(int which_cdb, DBT *in_key, DBT *in_data) {
+//void export_euidindex(int which_cdb, DBT *in_key, DBT *in_data) {
 
        // The structure of an euidindex record *key* is:
        // |----room_number----|----------EUID-------------|
@@ -307,28 +307,28 @@ void export_euidindex(int which_cdb, DBT *in_key, DBT *in_data) {
        // |-----msg_number----|----room_number----|----------EUID-------------|
        //    (sizeof long)       (sizeof long)       (actual length of euid)
 
-       long msgnum, roomnum;
-       char *euid;
-
-       memcpy(&msgnum, in_data->data, sizeof(long));
-       memcpy(&roomnum, in_data->data+sizeof(long), sizeof(msgnum));
-       euid = in_data->data+(sizeof(long)*2);
+       //long msgnum, roomnum;
+       //char *euid;
 
-       printf("euidindex|%ld|%ld|%s|\n", msgnum, roomnum, euid);
-}
+       //memcpy(&msgnum, in_data->data, sizeof(long));
+       //memcpy(&roomnum, in_data->data+sizeof(long), sizeof(msgnum));
+       //euid = in_data->data+(sizeof(long)*2);
+//
+       //printf("euidindex|%ld|%ld|%s|\n", msgnum, roomnum, euid);
+//}
 
 
 // export users-by-number records
 // (This is a secondary index -- should we just regenerate the data after import?)
-void export_usersbynumber(int which_cdb, DBT *in_key, DBT *in_data) {
+//void export_usersbynumber(int which_cdb, DBT *in_key, DBT *in_data) {
 
        // key is a long
-       long usernum;
-       memcpy(&usernum, in_key->data, sizeof(usernum));
+       //long usernum;
+       //memcpy(&usernum, in_key->data, sizeof(usernum));
 
        // value is a string
-       printf("usersbynumber|%ld|%s|\n", usernum, (char *)in_data->data);
-}
+       //printf("usersbynumber|%ld|%s|\n", usernum, (char *)in_data->data);
+//}
 
 
 // export function for a config record
@@ -355,12 +355,12 @@ void (*export_functions[])(int which_cdb, DBT *in_key, DBT *in_data) = {
        export_floor,           // CDB_FLOORTAB
        export_msglist,         // CDB_MSGLISTS
        export_visit,           // CDB_VISIT
-       export_dir,             // CDB_DIRECTORY
+       zero_function,          // CDB_DIRECTORY (regenerate this on the server)
        export_usetable,        // CDB_USETABLE
        export_bigmsg,          // CDB_BIGMSGS
        zero_function,          // CDB_FULLTEXT (regenerate this on the server)
-       export_euidindex,       // CDB_EUIDINDEX
-       export_usersbynumber,   // CDB_USERSBYNUMBER
+       zero_function,          // CDB_EUIDINDEX (regenerate this on the server)
+       zero_function,          // CDB_USERSBYNUMBER (regenerate this on the server)
        zero_function,          // CDB_UNUSED1 (obsolete)
        export_config           // CDB_CONFIG
 };
@@ -505,6 +505,10 @@ int main(int argc, char **argv) {
        printf("begin|\n");
        for (i = 0; i < MAXCDB; ++i) {
                export_table(i, src_dbenv);
+               if (i == CDB_CONFIG) {
+                       printf("config|regenerate_secondary_indices|1|\n");             // Force citserver to rebuild those tables
+                       printf("config|MM_fulltext_wordbreaker|0|\n");                  // Burn the full text search index
+               }
        }
        close_dbenv(src_dbenv);
        printf("end|\n");
index 267c4db4419668dc2be5b716423f2b70f057b617..409741a920a018209ca7a913e727c1f7e6012a2b 100644 (file)
@@ -545,11 +545,8 @@ void ingest_one(char *line, DB_ENV *dst_dbenv) {
        else if (!strcasecmp(record_type, "floor"))             row_was_good = convert_floor(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "msglist"))           row_was_good = convert_msglist(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "visit"))             row_was_good = convert_visit(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "dir"))               row_was_good = convert_foo(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "use"))               row_was_good = convert_foo(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "bigmsg"))            row_was_good = convert_foo(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "euidindex"))         row_was_good = convert_foo(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "usersbynumber"))     row_was_good = convert_foo(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "config"))            row_was_good = convert_foo(line, &out_key, &out_data);
        else                                                    row_was_good = 0;