Fossil

Diff
Login

Differences From Artifact [d9477cc369]:

To Artifact [4bbb50a88a]:


734
735
736
737
738
739
740



















741
742
743
744
745
746
747
  }else{
    g.dbConfig = openDatabase(zDbName);
  }
  g.configOpen = 1;
  free(zDbName);
}




















/*
** If zDbName is a valid local database file, open it and return
** true.  If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
  i64 lsize;
  int rc;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
  }else{
    g.dbConfig = openDatabase(zDbName);
  }
  g.configOpen = 1;
  free(zDbName);
}


/*
 * * Returns TRUE if zTable exists in the local database.
 */
static int db_local_table_exists(const char *zTable){
  return db_exists("SELECT 1 FROM %s.sqlite_master"
                   " WHERE name=='%s'",
                   db_name("localdb"), zTable);
}

/*
** Returns TRUE if zColumn exists in zTable in the local database.
*/
static int db_local_column_exists(const char *zTable, const char *zColumn){
  return db_exists("SELECT 1 FROM %s.sqlite_master"
                   " WHERE name=='%s' AND sql GLOB '* %s *'",
                   db_name("localdb"), zTable, zColumn);
}

/*
** If zDbName is a valid local database file, open it and return
** true.  If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
  i64 lsize;
  int rc;
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773

774
775


776


777
778



779
780
781
782
783
784
785
  db_open_config(0);
  db_open_repository(0);

  /* If the "isexe" column is missing from the vfile table, then
  ** add it now.   This code added on 2010-03-06.  After all users have
  ** upgraded, this code can be safely deleted. 
  */
  rc = db_exists("SELECT 1 FROM %s.sqlite_master"
                 " WHERE name=='vfile' AND sql GLOB '* isexe *'",
                 db_name("localdb"));
  if( rc==0 ){
    db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
  }

  /* If the "islink" column is missing from the vfile table, then
  ** add it now.   This code added on 2011-01-17.  After all users have
  ** upgraded, this code can be safely deleted. 
  */
  rc = db_exists("SELECT 1 FROM %s.sqlite_master"

                 " WHERE name=='vfile' AND sql GLOB '* islink *'",
                 db_name("localdb"));


  if( rc==0 ){


    db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
  }




  return 1;
}

/*
** Locate the root directory of the local repository tree.  The root
** directory is found by searching for a file named "_FOSSIL_" or ".fos"







|
<
<
<

|
|
<
|
|

|
>
|
|
>
>
|
>
>
|
|
>
>
>







774
775
776
777
778
779
780
781



782
783
784

785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
  db_open_config(0);
  db_open_repository(0);

  /* If the "isexe" column is missing from the vfile table, then
  ** add it now.   This code added on 2010-03-06.  After all users have
  ** upgraded, this code can be safely deleted. 
  */
  if( !db_local_column_exists("vfile", "isexe") )



    db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");

  /* If "islink"/"isLink" columns are missing from tables, then

  ** add them now.   This code added on 2011-01-17 and 2011-08-27.
  ** After all users have upgraded, this code can be safely deleted. 
  */
  if( !db_local_column_exists("vfile", "islink") )
    db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
  
  if( db_local_table_exists("stashfile") && 
      !db_local_column_exists("stashfile", "isLink") )
    db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");

  if( db_local_table_exists("undo") &&
      !db_local_column_exists("undo", "isLink") )
    db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
  
  if( db_local_table_exists("undo_vfile") && 
      !db_local_column_exists("undo_vfile", "islink") )
    db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");

  return 1;
}

/*
** Locate the root directory of the local repository tree.  The root
** directory is found by searching for a file named "_FOSSIL_" or ".fos"