Fossil

Check-in [3259aa54]
Login

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

Overview
Comment:Do not create the ALIAS table as it turns out not to be needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fossil-2.0
Files: files | file ages | folders
SHA1: 3259aa5421f85fc87c248dacd1adce13adf19318
User & Date: drh 2017-03-01 15:09:48
Context
2017-03-01
15:35
Change references to "SHA1 hash" in comments and UI labels to be "artifact hash" or similar. Closed-Leaf check-in: b9a1a3b9 user: drh tags: fossil-2.0
15:09
Do not create the ALIAS table as it turns out not to be needed. check-in: 3259aa54 user: drh tags: fossil-2.0
14:55
Improvements to the way that hash name aliases are detected in the content_put_ex() routine. check-in: 53a2824e user: drh tags: fossil-2.0
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
  g.allowSymlinks = db_get_boolean("allow-symlinks",
                                   db_allow_symlinks_by_default());
  g.zAuxSchema = db_get("aux-schema","");

  /* If the ALIAS table is not present, then some on-the-fly schema
  ** updates might be required.
  */
  if( !db_table_exists("repository","alias") ){
    rebuild_schema_update_2_0();   /* Do the Fossil-2.0 schema updates */
  }
}

/*
** Flags for the db_find_and_open_repository() function.
*/
#if INTERFACE
#define OPEN_OK_NOT_FOUND    0x001      /* Do not error out if not found */







<
|
<







1487
1488
1489
1490
1491
1492
1493

1494

1495
1496
1497
1498
1499
1500
1501
  g.allowSymlinks = db_get_boolean("allow-symlinks",
                                   db_allow_symlinks_by_default());
  g.zAuxSchema = db_get("aux-schema","");

  /* If the ALIAS table is not present, then some on-the-fly schema
  ** updates might be required.
  */

  rebuild_schema_update_2_0();   /* Do the Fossil-2.0 schema updates */

}

/*
** Flags for the db_find_and_open_repository() function.
*/
#if INTERFACE
#define OPEN_OK_NOT_FOUND    0x001      /* Do not error out if not found */

Changes to src/rebuild.c.

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  /* Do the fossil-2.0 updates to the schema.  (2017-02-28)
  */
  rebuild_schema_update_2_0();
}

/*
** Update the repository schema for Fossil version 2.0.  (2017-02-28)
**   (1) Create the ALIAS table
**   (2) Change the CHECK constraint on BLOB.UUID so that the length
**       is greater than or equal to 40, not exactly equal to 40.
*/
void rebuild_schema_update_2_0(void){
  static const char zCreateAliasTable[] =
  @ -- Make sure the alias table exists.
  @ --
  @ CREATE TABLE repository.alias(
  @   hval TEXT,                      -- Hex-encoded hash value
  @   htype ANY,                      -- Type of hash.
  @   rid INTEGER REFERENCES blob,    -- Blob that this hash names
  @   PRIMARY KEY(hval,htype,rid)
  @ ) WITHOUT ROWID;
  @ CREATE INDEX repository.alias_rid ON alias(rid);
  ;
  char *z;
   
  /* If the alias table is missing, create it. */
  if( !db_table_exists("repository", "alias") ){
    db_multi_exec("%s", zCreateAliasTable/*safe-for-%s*/);
  }

  /* Make sure the CHECK constraint on the BLOB table says "length(uuid)>=40"
  ** instead of "length(uuid)==40". */
  z = db_text(0, "SELECT sql FROM repository.sqlite_master WHERE"
                 " name LIKE 'blob' AND sql LIKE '%%length(uuid)==40%%'");
  if( z ){
    /* Search for:  length(uuid)==40
    **              0123456789 12345   */
    int i;
    for(i=10; z[i]; i++){
      if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){
        z[i] = '>';







<
|



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<







138
139
140
141
142
143
144

145
146
147
148




















149

150
151
152
153
154
155
156
  /* Do the fossil-2.0 updates to the schema.  (2017-02-28)
  */
  rebuild_schema_update_2_0();
}

/*
** Update the repository schema for Fossil version 2.0.  (2017-02-28)

**   (1) Change the CHECK constraint on BLOB.UUID so that the length
**       is greater than or equal to 40, not exactly equal to 40.
*/
void rebuild_schema_update_2_0(void){




















  char *z = db_text(0, "SELECT sql FROM repository.sqlite_master WHERE name='blob'");

  if( z ){
    /* Search for:  length(uuid)==40
    **              0123456789 12345   */
    int i;
    for(i=10; z[i]; i++){
      if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){
        z[i] = '>';

Changes to src/schema.c.

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@   rcvid INTEGER PRIMARY KEY,      -- Received-From ID
@   uid INTEGER REFERENCES user,    -- User login
@   mtime DATETIME,                 -- Time of receipt.  Julian day.
@   nonce TEXT UNIQUE,              -- Nonce used for login
@   ipaddr TEXT                     -- Remote IP address.  NULL for direct.
@ );
@
@ -- The canonical name of each artifact is given by the BLOB.UUID field.
@ -- But artifacts can also have aliases.  Aliases arise, for example, when
@ -- the naming hash algorithm changes, or as a result of trying to provide
@ -- compatibility with a different VCS.
@ --
@ -- Each entry in the ALIAS table provides an alternative name by which an
@ -- artifact can be called.
@ --
@ CREATE TABLE alias(
@   hval TEXT,                      -- Hex-encoded hash value
@   htype ANY,                      -- Type of hash.
@   rid INTEGER REFERENCES blob,    -- Blob that this hash names
@   PRIMARY KEY(hval,htype,rid)
@ ) WITHOUT ROWID;
@ CREATE INDEX alias_rid ON alias(rid);
@
@ -- Information about users
@ --
@ -- The user.pw field can be either cleartext of the password, or
@ -- a SHA1 hash of the password.  If the user.pw field is exactly 40
@ -- characters long we assume it is a SHA1 hash.  Otherwise, it is
@ -- cleartext.  The sha1_shared_secret() routine computes the password
@ -- hash based on the project-code, the user login, and the cleartext







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







105
106
107
108
109
110
111
















112
113
114
115
116
117
118
@   rcvid INTEGER PRIMARY KEY,      -- Received-From ID
@   uid INTEGER REFERENCES user,    -- User login
@   mtime DATETIME,                 -- Time of receipt.  Julian day.
@   nonce TEXT UNIQUE,              -- Nonce used for login
@   ipaddr TEXT                     -- Remote IP address.  NULL for direct.
@ );
@
















@ -- Information about users
@ --
@ -- The user.pw field can be either cleartext of the password, or
@ -- a SHA1 hash of the password.  If the user.pw field is exactly 40
@ -- characters long we assume it is a SHA1 hash.  Otherwise, it is
@ -- cleartext.  The sha1_shared_secret() routine computes the password
@ -- hash based on the project-code, the user login, and the cleartext