Fossil SCM

Add islink column to stashfile, undo, undo_vfile tables if needed.

dmitry 2011-08-27 01:07 symlinks
Commit 44e673f5e992c6793b9816f11ed8bc1ca6296a63
1 file changed +36 -13
+36 -13
--- src/db.c
+++ src/db.c
@@ -736,10 +736,29 @@
736736
}
737737
g.configOpen = 1;
738738
free(zDbName);
739739
}
740740
741
+
742
+/*
743
+ * * Returns TRUE if zTable exists in the local database.
744
+ */
745
+static int db_local_table_exists(const char *zTable){
746
+ return db_exists("SELECT 1 FROM %s.sqlite_master"
747
+ " WHERE name=='%s'",
748
+ db_name("localdb"), zTable);
749
+}
750
+
751
+/*
752
+** Returns TRUE if zColumn exists in zTable in the local database.
753
+*/
754
+static int db_local_column_exists(const char *zTable, const char *zColumn){
755
+ return db_exists("SELECT 1 FROM %s.sqlite_master"
756
+ " WHERE name=='%s' AND sql GLOB '* %s *'",
757
+ db_name("localdb"), zTable, zColumn);
758
+}
759
+
741760
/*
742761
** If zDbName is a valid local database file, open it and return
743762
** true. If it is not a valid local database file, return 0.
744763
*/
745764
static int isValidLocalDb(const char *zDbName){
@@ -757,27 +776,31 @@
757776
758777
/* If the "isexe" column is missing from the vfile table, then
759778
** add it now. This code added on 2010-03-06. After all users have
760779
** upgraded, this code can be safely deleted.
761780
*/
762
- rc = db_exists("SELECT 1 FROM %s.sqlite_master"
763
- " WHERE name=='vfile' AND sql GLOB '* isexe *'",
764
- db_name("localdb"));
765
- if( rc==0 ){
781
+ if( !db_local_column_exists("vfile", "isexe") )
766782
db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
767
- }
768783
769
- /* If the "islink" column is missing from the vfile table, then
770
- ** add it now. This code added on 2011-01-17. After all users have
771
- ** upgraded, this code can be safely deleted.
784
+ /* If "islink"/"isLink" columns are missing from tables, then
785
+ ** add them now. This code added on 2011-01-17 and 2011-08-27.
786
+ ** After all users have upgraded, this code can be safely deleted.
772787
*/
773
- rc = db_exists("SELECT 1 FROM %s.sqlite_master"
774
- " WHERE name=='vfile' AND sql GLOB '* islink *'",
775
- db_name("localdb"));
776
- if( rc==0 ){
788
+ if( !db_local_column_exists("vfile", "islink") )
777789
db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
778
- }
790
+
791
+ if( db_local_table_exists("stashfile") &&
792
+ !db_local_column_exists("stashfile", "isLink") )
793
+ db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
794
+
795
+ if( db_local_table_exists("undo") &&
796
+ !db_local_column_exists("undo", "isLink") )
797
+ db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
798
+
799
+ if( db_local_table_exists("undo_vfile") &&
800
+ !db_local_column_exists("undo_vfile", "islink") )
801
+ db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
779802
780803
return 1;
781804
}
782805
783806
/*
784807
--- src/db.c
+++ src/db.c
@@ -736,10 +736,29 @@
736 }
737 g.configOpen = 1;
738 free(zDbName);
739 }
740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741 /*
742 ** If zDbName is a valid local database file, open it and return
743 ** true. If it is not a valid local database file, return 0.
744 */
745 static int isValidLocalDb(const char *zDbName){
@@ -757,27 +776,31 @@
757
758 /* If the "isexe" column is missing from the vfile table, then
759 ** add it now. This code added on 2010-03-06. After all users have
760 ** upgraded, this code can be safely deleted.
761 */
762 rc = db_exists("SELECT 1 FROM %s.sqlite_master"
763 " WHERE name=='vfile' AND sql GLOB '* isexe *'",
764 db_name("localdb"));
765 if( rc==0 ){
766 db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
767 }
768
769 /* If the "islink" column is missing from the vfile table, then
770 ** add it now. This code added on 2011-01-17. After all users have
771 ** upgraded, this code can be safely deleted.
772 */
773 rc = db_exists("SELECT 1 FROM %s.sqlite_master"
774 " WHERE name=='vfile' AND sql GLOB '* islink *'",
775 db_name("localdb"));
776 if( rc==0 ){
777 db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
778 }
 
 
 
 
 
 
 
 
 
 
 
779
780 return 1;
781 }
782
783 /*
784
--- src/db.c
+++ src/db.c
@@ -736,10 +736,29 @@
736 }
737 g.configOpen = 1;
738 free(zDbName);
739 }
740
741
742 /*
743 * * Returns TRUE if zTable exists in the local database.
744 */
745 static int db_local_table_exists(const char *zTable){
746 return db_exists("SELECT 1 FROM %s.sqlite_master"
747 " WHERE name=='%s'",
748 db_name("localdb"), zTable);
749 }
750
751 /*
752 ** Returns TRUE if zColumn exists in zTable in the local database.
753 */
754 static int db_local_column_exists(const char *zTable, const char *zColumn){
755 return db_exists("SELECT 1 FROM %s.sqlite_master"
756 " WHERE name=='%s' AND sql GLOB '* %s *'",
757 db_name("localdb"), zTable, zColumn);
758 }
759
760 /*
761 ** If zDbName is a valid local database file, open it and return
762 ** true. If it is not a valid local database file, return 0.
763 */
764 static int isValidLocalDb(const char *zDbName){
@@ -757,27 +776,31 @@
776
777 /* If the "isexe" column is missing from the vfile table, then
778 ** add it now. This code added on 2010-03-06. After all users have
779 ** upgraded, this code can be safely deleted.
780 */
781 if( !db_local_column_exists("vfile", "isexe") )
 
 
 
782 db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
 
783
784 /* If "islink"/"isLink" columns are missing from tables, then
785 ** add them now. This code added on 2011-01-17 and 2011-08-27.
786 ** After all users have upgraded, this code can be safely deleted.
787 */
788 if( !db_local_column_exists("vfile", "islink") )
 
 
 
789 db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
790
791 if( db_local_table_exists("stashfile") &&
792 !db_local_column_exists("stashfile", "isLink") )
793 db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
794
795 if( db_local_table_exists("undo") &&
796 !db_local_column_exists("undo", "isLink") )
797 db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
798
799 if( db_local_table_exists("undo_vfile") &&
800 !db_local_column_exists("undo_vfile", "islink") )
801 db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
802
803 return 1;
804 }
805
806 /*
807

Keyboard Shortcuts

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