Fossil

Check-in [44e673f5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add islink column to stashfile, undo, undo_vfile tables if needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | symlinks
Files: files | file ages | folders
SHA1: 44e673f5e992c6793b9816f11ed8bc1ca6296a63
User & Date: dmitry 2011-08-27 01:07:21
Context
2011-08-27
01:21
Reverse the order of column/table existence checking to make validation of already updated local database faster. check-in: 8c0f4bc7 user: dmitry tags: symlinks
01:07
Add islink column to stashfile, undo, undo_vfile tables if needed. check-in: 44e673f5 user: dmitry tags: symlinks
00:52
Fix SQL syntax error in undo. check-in: be956c3c user: dmitry tags: symlinks
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

734
735
736
737
738
739
740



















741
742
743
744
745
746
747
...
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
  }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;
................................................................................
  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"







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







 







|
<
<
<

|
<
<
>
|
|

<
<
<
<
>

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







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
...
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
  }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;
................................................................................
  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"