Fossil SCM
Refactor how the IF NOT EXISTS check is performed on the repository.admin_log table, per request from drh.
Commit
2da6010b7cdd12aeccaf5fea268a36d3a788b7505739642ae544536903b3c950
Parent
46ddf0e80b94f21…
1 file changed
+12
-10
M
src/db.c
+12
-10
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -4917,20 +4917,22 @@ | ||
| 4917 | 4917 | ** Make sure the adminlog table exists. Create it if it does not |
| 4918 | 4918 | */ |
| 4919 | 4919 | void create_admin_log_table(void){ |
| 4920 | 4920 | static int once = 0; |
| 4921 | 4921 | if( once ) return; |
| 4922 | - once = 1; | |
| 4923 | - db_multi_exec( | |
| 4924 | - "CREATE TABLE IF NOT EXISTS repository.admin_log(\n" | |
| 4925 | - " id INTEGER PRIMARY KEY,\n" | |
| 4926 | - " time INTEGER, -- Seconds since 1970\n" | |
| 4927 | - " page TEXT, -- path of page\n" | |
| 4928 | - " who TEXT, -- User who made the change\n" | |
| 4929 | - " what TEXT -- What changed\n" | |
| 4930 | - ")" | |
| 4931 | - ); | |
| 4922 | + if( !db_table_exists("repository","admin_log") ){ | |
| 4923 | + once = 1; | |
| 4924 | + db_multi_exec( | |
| 4925 | + "CREATE TABLE repository.admin_log(\n" | |
| 4926 | + " id INTEGER PRIMARY KEY,\n" | |
| 4927 | + " time INTEGER, -- Seconds since 1970\n" | |
| 4928 | + " page TEXT, -- path of page\n" | |
| 4929 | + " who TEXT, -- User who made the change\n" | |
| 4930 | + " what TEXT -- What changed\n" | |
| 4931 | + ")" | |
| 4932 | + ); | |
| 4933 | + } | |
| 4932 | 4934 | } |
| 4933 | 4935 | |
| 4934 | 4936 | /* |
| 4935 | 4937 | ** Write a message into the admin_event table, if admin logging is |
| 4936 | 4938 | ** enabled via the admin-log configuration option. |
| 4937 | 4939 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -4917,20 +4917,22 @@ | |
| 4917 | ** Make sure the adminlog table exists. Create it if it does not |
| 4918 | */ |
| 4919 | void create_admin_log_table(void){ |
| 4920 | static int once = 0; |
| 4921 | if( once ) return; |
| 4922 | once = 1; |
| 4923 | db_multi_exec( |
| 4924 | "CREATE TABLE IF NOT EXISTS repository.admin_log(\n" |
| 4925 | " id INTEGER PRIMARY KEY,\n" |
| 4926 | " time INTEGER, -- Seconds since 1970\n" |
| 4927 | " page TEXT, -- path of page\n" |
| 4928 | " who TEXT, -- User who made the change\n" |
| 4929 | " what TEXT -- What changed\n" |
| 4930 | ")" |
| 4931 | ); |
| 4932 | } |
| 4933 | |
| 4934 | /* |
| 4935 | ** Write a message into the admin_event table, if admin logging is |
| 4936 | ** enabled via the admin-log configuration option. |
| 4937 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -4917,20 +4917,22 @@ | |
| 4917 | ** Make sure the adminlog table exists. Create it if it does not |
| 4918 | */ |
| 4919 | void create_admin_log_table(void){ |
| 4920 | static int once = 0; |
| 4921 | if( once ) return; |
| 4922 | if( !db_table_exists("repository","admin_log") ){ |
| 4923 | once = 1; |
| 4924 | db_multi_exec( |
| 4925 | "CREATE TABLE repository.admin_log(\n" |
| 4926 | " id INTEGER PRIMARY KEY,\n" |
| 4927 | " time INTEGER, -- Seconds since 1970\n" |
| 4928 | " page TEXT, -- path of page\n" |
| 4929 | " who TEXT, -- User who made the change\n" |
| 4930 | " what TEXT -- What changed\n" |
| 4931 | ")" |
| 4932 | ); |
| 4933 | } |
| 4934 | } |
| 4935 | |
| 4936 | /* |
| 4937 | ** Write a message into the admin_event table, if admin logging is |
| 4938 | ** enabled via the admin-log configuration option. |
| 4939 |