Fossil SCM

Refactor how the IF NOT EXISTS check is performed on the repository.admin_log table, per request from drh.

stephan 2023-01-26 01:46 trunk
Commit 2da6010b7cdd12aeccaf5fea268a36d3a788b7505739642ae544536903b3c950
1 file changed +12 -10
+12 -10
--- src/db.c
+++ src/db.c
@@ -4917,20 +4917,22 @@
49174917
** Make sure the adminlog table exists. Create it if it does not
49184918
*/
49194919
void create_admin_log_table(void){
49204920
static int once = 0;
49214921
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
+ }
49324934
}
49334935
49344936
/*
49354937
** Write a message into the admin_event table, if admin logging is
49364938
** enabled via the admin-log configuration option.
49374939
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button