Fossil SCM
Factor out the ALTER TABLE statements that add the JX column to the USER and REPORTFMT tables into separate subroutines.
Commit
8f6d7dacbbfeb165b37efa6eb169e8e6c7116abbd9cfb2e7fc3d281ef08d01ed
Parent
b7ac178c4f27d2e…
3 files changed
+4
-9
+13
+13
+4
-9
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -447,19 +447,14 @@ | ||
| 447 | 447 | blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); |
| 448 | 448 | } |
| 449 | 449 | db_protect_only(PROTECT_SENSITIVE); |
| 450 | 450 | |
| 451 | 451 | /* Make sure tables have the "jx" column */ |
| 452 | - if( strcmp(&zName[1],"user")==0 | |
| 453 | - && db_table_has_column("repository","user","jx")==0 | |
| 454 | - ){ | |
| 455 | - db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT"); | |
| 456 | - }else | |
| 457 | - if( strcmp(&zName[1],"reportfmt")==0 | |
| 458 | - && db_table_has_column("repository","reportfmt","jx")==0 | |
| 459 | - ){ | |
| 460 | - db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT"); | |
| 452 | + if( strcmp(&zName[1],"user")==0 ){ | |
| 453 | + user_update_user_table(); | |
| 454 | + }else if( strcmp(&zName[1],"reportfmt")==0 ){ | |
| 455 | + report_update_reportfmt_table(); | |
| 461 | 456 | } |
| 462 | 457 | |
| 463 | 458 | db_multi_exec("%s)", blob_sql_text(&sql)); |
| 464 | 459 | |
| 465 | 460 | if( db_changes()==0 ){ |
| 466 | 461 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -447,19 +447,14 @@ | |
| 447 | blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); |
| 448 | } |
| 449 | db_protect_only(PROTECT_SENSITIVE); |
| 450 | |
| 451 | /* Make sure tables have the "jx" column */ |
| 452 | if( strcmp(&zName[1],"user")==0 |
| 453 | && db_table_has_column("repository","user","jx")==0 |
| 454 | ){ |
| 455 | db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT"); |
| 456 | }else |
| 457 | if( strcmp(&zName[1],"reportfmt")==0 |
| 458 | && db_table_has_column("repository","reportfmt","jx")==0 |
| 459 | ){ |
| 460 | db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT"); |
| 461 | } |
| 462 | |
| 463 | db_multi_exec("%s)", blob_sql_text(&sql)); |
| 464 | |
| 465 | if( db_changes()==0 ){ |
| 466 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -447,19 +447,14 @@ | |
| 447 | blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); |
| 448 | } |
| 449 | db_protect_only(PROTECT_SENSITIVE); |
| 450 | |
| 451 | /* Make sure tables have the "jx" column */ |
| 452 | if( strcmp(&zName[1],"user")==0 ){ |
| 453 | user_update_user_table(); |
| 454 | }else if( strcmp(&zName[1],"reportfmt")==0 ){ |
| 455 | report_update_reportfmt_table(); |
| 456 | } |
| 457 | |
| 458 | db_multi_exec("%s)", blob_sql_text(&sql)); |
| 459 | |
| 460 | if( db_changes()==0 ){ |
| 461 |
+13
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -253,10 +253,23 @@ | ||
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | return rc; |
| 257 | 257 | } |
| 258 | + | |
| 259 | +/* | |
| 260 | +** Make sure the reportfmt table is up-to-date. It should contain | |
| 261 | +** the "jx" column (as of version 2.21). If it does not, add it. | |
| 262 | +** | |
| 263 | +** The "jx" column is intended to hold a JSON object containing optional | |
| 264 | +** key-value pairs. | |
| 265 | +*/ | |
| 266 | +void report_update_reportfmt_table(void){ | |
| 267 | + if( db_table_has_column("repository","reportfmt","jx")==0 ){ | |
| 268 | + db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT;"); | |
| 269 | + } | |
| 270 | +} | |
| 258 | 271 | |
| 259 | 272 | /* |
| 260 | 273 | ** Activate the ticket report query authorizer. Must be followed by an |
| 261 | 274 | ** eventual call to report_unrestrict_sql(). |
| 262 | 275 | */ |
| 263 | 276 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -253,10 +253,23 @@ | |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | return rc; |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | ** Activate the ticket report query authorizer. Must be followed by an |
| 261 | ** eventual call to report_unrestrict_sql(). |
| 262 | */ |
| 263 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -253,10 +253,23 @@ | |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | return rc; |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | ** Make sure the reportfmt table is up-to-date. It should contain |
| 261 | ** the "jx" column (as of version 2.21). If it does not, add it. |
| 262 | ** |
| 263 | ** The "jx" column is intended to hold a JSON object containing optional |
| 264 | ** key-value pairs. |
| 265 | */ |
| 266 | void report_update_reportfmt_table(void){ |
| 267 | if( db_table_has_column("repository","reportfmt","jx")==0 ){ |
| 268 | db_multi_exec("ALTER TABLE repository.reportfmt ADD COLUMN jx TEXT;"); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /* |
| 273 | ** Activate the ticket report query authorizer. Must be followed by an |
| 274 | ** eventual call to report_unrestrict_sql(). |
| 275 | */ |
| 276 |
+13
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -573,10 +573,23 @@ | ||
| 573 | 573 | user_select(); |
| 574 | 574 | fossil_print("Final g.zLogin: %s\n", g.zLogin); |
| 575 | 575 | fossil_print("Final g.userUid: %d\n", g.userUid); |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | + | |
| 579 | +/* | |
| 580 | +** Make sure the USER table is up-to-date. It should contain | |
| 581 | +** the "JX" column (as of version 2.21). If it does not, add it. | |
| 582 | +** | |
| 583 | +** The "JX" column is intended to hold a JSON object containing optional | |
| 584 | +** key-value pairs. | |
| 585 | +*/ | |
| 586 | +void user_update_user_table(void){ | |
| 587 | + if( db_table_has_column("repository","user","jx")==0 ){ | |
| 588 | + db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT;"); | |
| 589 | + } | |
| 590 | +} | |
| 578 | 591 | |
| 579 | 592 | /* |
| 580 | 593 | ** COMMAND: test-hash-passwords |
| 581 | 594 | ** |
| 582 | 595 | ** Usage: %fossil test-hash-passwords REPOSITORY |
| 583 | 596 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -573,10 +573,23 @@ | |
| 573 | user_select(); |
| 574 | fossil_print("Final g.zLogin: %s\n", g.zLogin); |
| 575 | fossil_print("Final g.userUid: %d\n", g.userUid); |
| 576 | } |
| 577 | |
| 578 | |
| 579 | /* |
| 580 | ** COMMAND: test-hash-passwords |
| 581 | ** |
| 582 | ** Usage: %fossil test-hash-passwords REPOSITORY |
| 583 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -573,10 +573,23 @@ | |
| 573 | user_select(); |
| 574 | fossil_print("Final g.zLogin: %s\n", g.zLogin); |
| 575 | fossil_print("Final g.userUid: %d\n", g.userUid); |
| 576 | } |
| 577 | |
| 578 | |
| 579 | /* |
| 580 | ** Make sure the USER table is up-to-date. It should contain |
| 581 | ** the "JX" column (as of version 2.21). If it does not, add it. |
| 582 | ** |
| 583 | ** The "JX" column is intended to hold a JSON object containing optional |
| 584 | ** key-value pairs. |
| 585 | */ |
| 586 | void user_update_user_table(void){ |
| 587 | if( db_table_has_column("repository","user","jx")==0 ){ |
| 588 | db_multi_exec("ALTER TABLE repository.user ADD COLUMN jx TEXT;"); |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | /* |
| 593 | ** COMMAND: test-hash-passwords |
| 594 | ** |
| 595 | ** Usage: %fossil test-hash-passwords REPOSITORY |
| 596 |