0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20 /*.** Copyright
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68 (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54 ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20 te it and/or.**
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20 modify it under
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76 lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65 ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 tributed in the
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20 l be useful,.**
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 but WITHOUT ANY
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20 RPOSE. See the
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50 GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 d have received
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72 g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69 ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65 te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 ation, Inc., 59
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53 Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73 uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31 ton, MA 02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20 307, USA..**.**
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20 nformation:.**
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68 * http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0360: 0a 2a 2a 20 0a 2a 2a 20 54 68 69 73 20 66 69 6c .** .** This fil
0370: 65 20 63 6f 6e 74 61 69 6e 73 20 73 74 72 69 6e e contains strin
0380: 67 20 63 6f 6e 73 74 61 6e 74 73 20 74 68 61 74 g constants that
0390: 20 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 20 64 implement the d
03a0: 61 74 61 62 61 73 65 20 73 63 68 65 6d 61 2e 0a atabase schema..
03b0: 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 22 63 6f 6e */.#include "con
03c0: 66 69 67 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 fig.h".#include
03d0: 22 73 63 68 65 6d 61 2e 68 22 0a 0a 2f 2a 0a 2a "schema.h"../*.*
03e0: 2a 20 54 68 65 20 64 61 74 61 62 61 73 65 20 73 * The database s
03f0: 63 68 65 6d 61 20 66 6f 72 20 74 68 65 20 7e 2f chema for the ~/
0400: 2e 66 6f 73 73 69 6c 20 63 6f 6e 66 69 67 75 72 .fossil configur
0410: 61 74 69 6f 6e 20 64 61 74 61 62 61 73 65 2e 0a ation database..
0420: 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 7a 43 */.const char zC
0430: 6f 6e 66 69 67 53 63 68 65 6d 61 5b 5d 20 3d 20 onfigSchema[] =
0440: 0a 40 20 2d 2d 20 54 68 69 73 20 66 69 6c 65 20 .@ -- This file
0450: 63 6f 6e 74 61 69 6e 73 20 74 68 65 20 73 63 68 contains the sch
0460: 65 6d 61 20 66 6f 72 20 74 68 65 20 64 61 74 61 ema for the data
0470: 62 61 73 65 20 74 68 61 74 20 69 73 20 6b 65 70 base that is kep
0480: 74 20 69 6e 20 74 68 65 0a 40 20 2d 2d 20 7e 2f t in the.@ -- ~/
0490: 2e 66 6f 73 73 69 6c 20 66 69 6c 65 20 61 6e 64 .fossil file and
04a0: 20 74 68 61 74 20 73 74 6f 72 65 73 20 69 6e 66 that stores inf
04b0: 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 74 ormation about t
04c0: 68 65 20 75 73 65 72 73 20 73 65 74 75 70 2e 0a he users setup..
04d0: 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 @ --.@ CREATE TA
04e0: 42 4c 45 20 67 6c 6f 62 61 6c 5f 63 6f 6e 66 69 BLE global_confi
04f0: 67 28 0a 40 20 20 20 6e 61 6d 65 20 54 45 58 54 g(.@ name TEXT
0500: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a 40 20 PRIMARY KEY,.@
0510: 20 20 76 61 6c 75 65 20 54 45 58 54 0a 40 20 29 value TEXT.@ )
0520: 3b 0a 3b 0a 0a 23 69 66 20 49 4e 54 45 52 46 41 ;.;..#if INTERFA
0530: 43 45 0a 2f 2a 0a 2a 2a 20 54 68 65 20 63 6f 6e CE./*.** The con
0540: 74 65 6e 74 20 74 61 62 6c 65 73 20 68 61 76 65 tent tables have
0550: 20 61 20 63 6f 6e 74 65 6e 74 20 76 65 72 73 69 a content versi
0560: 6f 6e 20 6e 75 6d 62 65 72 20 77 68 69 63 68 20 on number which
0570: 72 61 72 65 6c 79 0a 2a 2a 20 63 68 61 6e 67 65 rarely.** change
0580: 73 2e 20 20 54 68 65 20 61 75 78 20 74 61 62 6c s. The aux tabl
0590: 65 73 20 68 61 76 65 20 61 6e 20 61 72 62 69 74 es have an arbit
05a0: 72 61 72 79 20 76 65 72 73 69 6f 6e 20 6e 75 6d rary version num
05b0: 62 65 72 20 28 74 79 70 69 63 61 6c 6c 79 0a 2a ber (typically.*
05c0: 2a 20 61 20 64 61 74 65 29 20 77 68 69 63 68 20 * a date) which
05d0: 63 61 6e 20 63 68 61 6e 67 65 20 66 72 65 71 75 can change frequ
05e0: 65 6e 74 6c 79 2e 20 20 57 68 65 6e 20 74 68 65 ently. When the
05f0: 20 63 6f 6e 74 65 6e 74 20 73 63 68 65 6d 61 20 content schema
0600: 63 68 61 6e 67 65 73 2c 0a 2a 2a 20 77 65 20 68 changes,.** we h
0610: 61 76 65 20 74 6f 20 65 78 65 63 75 74 65 20 73 ave to execute s
0620: 70 65 63 69 61 6c 20 70 72 6f 63 65 64 75 72 65 pecial procedure
0630: 73 20 74 6f 20 75 70 64 61 74 65 20 74 68 65 20 s to update the
0640: 73 63 68 65 6d 61 2e 20 20 57 68 65 6e 0a 2a 2a schema. When.**
0650: 20 74 68 65 20 61 75 78 20 73 63 68 65 6d 61 20 the aux schema
0660: 63 68 61 6e 67 65 73 2c 20 61 6c 6c 20 77 65 20 changes, all we
0670: 6e 65 65 64 20 74 6f 20 64 6f 20 69 73 20 72 65 need to do is re
0680: 62 75 69 6c 64 20 74 68 65 20 64 61 74 61 62 61 build the databa
0690: 73 65 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 43 se..*/.#define C
06a0: 4f 4e 54 45 4e 54 5f 53 43 48 45 4d 41 20 20 22 ONTENT_SCHEMA "
06b0: 31 22 0a 23 64 65 66 69 6e 65 20 41 55 58 5f 53 1".#define AUX_S
06c0: 43 48 45 4d 41 20 20 20 20 20 20 22 32 30 30 36 CHEMA "2006
06d0: 2d 31 32 2d 32 33 22 0a 0a 23 65 6e 64 69 66 20 -12-23"..#endif
06e0: 2f 2a 20 49 4e 54 45 52 46 41 43 45 20 2a 2f 0a /* INTERFACE */.
06f0: 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 73 63 68 65 ../*.** The sche
0700: 6d 61 20 66 6f 72 20 61 20 72 65 70 6f 73 69 74 ma for a reposit
0710: 6f 72 79 20 64 61 74 61 62 61 73 65 2e 20 20 0a ory database. .
0720: 2a 2a 0a 2a 2a 20 53 63 68 65 6d 61 31 5b 5d 20 **.** Schema1[]
0730: 63 6f 6e 74 61 69 6e 73 20 70 61 72 74 73 20 6f contains parts o
0740: 66 20 74 68 65 20 73 63 68 65 6d 61 20 74 68 61 f the schema tha
0750: 74 20 61 72 65 20 66 69 78 65 64 20 61 6e 64 20 t are fixed and
0760: 75 6e 63 68 61 6e 67 69 6e 67 0a 2a 2a 20 61 63 unchanging.** ac
0770: 72 6f 73 73 20 76 65 72 73 69 6f 6e 73 2e 20 20 ross versions.
0780: 53 63 68 65 6d 61 32 5b 5d 20 63 6f 6e 74 61 69 Schema2[] contai
0790: 6e 73 20 70 61 72 74 73 20 6f 66 20 74 68 65 20 ns parts of the
07a0: 73 63 68 65 6d 61 20 74 68 61 74 20 63 61 6e 0a schema that can.
07b0: 2a 2a 20 63 68 61 6e 67 65 20 66 72 6f 6d 20 6f ** change from o
07c0: 6e 65 20 76 65 72 73 69 6f 6e 20 74 6f 20 74 68 ne version to th
07d0: 65 20 6e 65 78 74 2e 20 20 54 68 65 20 69 6e 66 e next. The inf
07e0: 6f 72 6d 61 74 69 6f 6e 20 69 6e 20 53 63 68 65 ormation in Sche
07f0: 6d 61 32 5b 5d 0a 2a 2a 20 63 61 6e 20 62 65 20 ma2[].** can be
0800: 72 65 63 6f 6e 73 74 72 75 63 74 65 64 20 66 72 reconstructed fr
0810: 6f 6d 20 74 68 65 20 69 6e 66 6f 72 6d 61 74 69 om the informati
0820: 6f 6e 20 69 6e 20 53 63 68 65 6d 61 31 5b 5d 2e on in Schema1[].
0830: 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 7a .*/.const char z
0840: 52 65 70 6f 73 69 74 6f 72 79 53 63 68 65 6d 61 RepositorySchema
0850: 31 5b 5d 20 3d 20 0a 40 20 2d 2d 20 54 68 65 20 1[] = .@ -- The
0860: 42 4c 4f 42 20 61 6e 64 20 44 45 4c 54 41 20 74 BLOB and DELTA t
0870: 61 62 6c 65 73 20 63 6f 6e 74 61 69 6e 20 61 6c ables contain al
0880: 6c 20 72 65 63 6f 72 64 73 20 68 65 6c 64 20 69 l records held i
0890: 6e 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 n the repository
08a0: 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 54 68 65 20 ..@ --.@ -- The
08b0: 42 4c 4f 42 2e 43 4f 4e 54 45 4e 54 20 63 6f 6c BLOB.CONTENT col
08c0: 75 6d 6e 20 69 73 20 61 6c 77 61 79 73 20 63 6f umn is always co
08d0: 6d 70 72 65 73 73 65 64 20 75 73 69 6e 67 20 6c mpressed using l
08e0: 69 62 7a 2e 20 20 54 68 69 73 0a 40 20 2d 2d 20 ibz. This.@ --
08f0: 63 6f 6c 75 6d 6e 20 6d 69 67 68 74 20 68 6f 6c column might hol
0900: 64 20 74 68 65 20 66 75 6c 6c 20 74 65 78 74 20 d the full text
0910: 6f 66 20 74 68 65 20 72 65 63 6f 72 64 20 6f 72 of the record or
0920: 20 69 74 20 6d 69 67 68 74 20 68 6f 6c 64 0a 40 it might hold.@
0930: 20 2d 2d 20 61 20 64 65 6c 74 61 20 74 68 61 74 -- a delta that
0940: 20 69 73 20 61 62 6c 65 20 74 6f 20 72 65 63 6f is able to reco
0950: 6e 73 74 72 75 63 74 20 74 68 65 20 72 65 63 6f nstruct the reco
0960: 72 64 20 66 72 6f 6d 20 73 6f 6d 65 20 6f 74 68 rd from some oth
0970: 65 72 0a 40 20 2d 2d 20 72 65 63 6f 72 64 2e 20 er.@ -- record.
0980: 20 49 66 20 42 4c 4f 42 2e 43 4f 4e 54 45 4e 54 If BLOB.CONTENT
0990: 20 68 6f 6c 64 73 20 61 20 64 65 6c 74 61 2c 20 holds a delta,
09a0: 74 68 65 6e 20 61 20 44 45 4c 54 41 20 74 61 62 then a DELTA tab
09b0: 6c 65 20 65 6e 74 72 79 0a 40 20 2d 2d 20 77 69 le entry.@ -- wi
09c0: 6c 6c 20 65 78 69 73 74 20 66 6f 72 20 74 68 65 ll exist for the
09d0: 20 72 65 63 6f 72 64 20 61 6e 64 20 74 68 61 74 record and that
09e0: 20 65 6e 74 72 79 20 77 69 6c 6c 20 70 6f 69 6e entry will poin
09f0: 74 20 74 6f 20 61 6e 6f 74 68 65 72 0a 40 20 2d t to another.@ -
0a00: 2d 20 65 6e 74 72 79 20 74 68 61 74 20 68 6f 6c - entry that hol
0a10: 64 73 20 74 68 65 20 73 6f 75 72 63 65 20 6f 66 ds the source of
0a20: 20 74 68 65 20 64 65 6c 74 61 2e 20 20 44 65 6c the delta. Del
0a30: 74 61 73 20 63 61 6e 20 62 65 20 63 68 61 69 6e tas can be chain
0a40: 65 64 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 ed..@ --.@ CREAT
0a50: 45 20 54 41 42 4c 45 20 62 6c 6f 62 28 0a 40 20 E TABLE blob(.@
0a60: 20 20 72 69 64 20 49 4e 54 45 47 45 52 20 50 52 rid INTEGER PR
0a70: 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 20 20 IMARY KEY,
0a80: 20 20 2d 2d 20 52 65 63 6f 72 64 20 49 44 0a 40 -- Record ID.@
0a90: 20 20 20 72 63 76 69 64 20 49 4e 54 45 47 45 52 rcvid INTEGER
0aa0: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
0ab0: 20 20 20 2d 2d 20 4f 72 69 67 69 6e 20 6f 66 20 -- Origin of
0ac0: 74 68 69 73 20 72 65 63 6f 72 64 0a 40 20 20 20 this record.@
0ad0: 73 69 7a 65 20 49 4e 54 45 47 45 52 2c 20 20 20 size INTEGER,
0ae0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0af0: 2d 2d 20 53 69 7a 65 20 6f 66 20 63 6f 6e 74 65 -- Size of conte
0b00: 6e 74 2e 20 2d 31 20 66 6f 72 20 61 20 70 68 61 nt. -1 for a pha
0b10: 6e 74 6f 6d 2e 0a 40 20 20 20 75 75 69 64 20 54 ntom..@ uuid T
0b20: 45 58 54 20 55 4e 49 51 55 45 2c 20 20 20 20 20 EXT UNIQUE,
0b30: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 48 41 -- SHA
0b40: 31 20 68 61 73 68 20 6f 66 20 74 68 65 20 63 6f 1 hash of the co
0b50: 6e 74 65 6e 74 0a 40 20 20 20 63 6f 6e 74 65 6e ntent.@ conten
0b60: 74 20 42 4c 4f 42 20 20 20 20 20 20 20 20 20 20 t BLOB
0b70: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 43 6f 6d -- Com
0b80: 70 72 65 73 73 65 64 20 63 6f 6e 74 65 6e 74 20 pressed content
0b90: 6f 66 20 74 68 69 73 20 72 65 63 6f 72 64 0a 40 of this record.@
0ba0: 20 29 3b 0a 40 20 43 52 45 41 54 45 20 54 41 42 );.@ CREATE TAB
0bb0: 4c 45 20 64 65 6c 74 61 28 0a 40 20 20 20 72 69 LE delta(.@ ri
0bc0: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
0bd0: 59 20 4b 45 59 2c 20 20 20 20 20 20 20 20 20 20 Y KEY,
0be0: 20 20 20 20 20 20 20 2d 2d 20 52 65 63 6f 72 64 -- Record
0bf0: 20 49 44 0a 40 20 20 20 73 72 63 69 64 20 49 4e ID.@ srcid IN
0c00: 54 45 47 45 52 20 4e 4f 54 20 4e 55 4c 4c 20 52 TEGER NOT NULL R
0c10: 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 20 20 EFERENCES blob
0c20: 20 2d 2d 20 52 65 63 6f 72 64 20 68 6f 6c 64 69 -- Record holdi
0c30: 6e 67 20 73 6f 75 72 63 65 20 64 6f 63 75 6d 65 ng source docume
0c40: 6e 74 0a 40 20 29 3b 0a 40 20 43 52 45 41 54 45 nt.@ );.@ CREATE
0c50: 20 49 4e 44 45 58 20 64 65 6c 74 61 5f 69 31 20 INDEX delta_i1
0c60: 4f 4e 20 64 65 6c 74 61 28 73 72 63 69 64 29 3b ON delta(srcid);
0c70: 0a 40 0a 40 20 2d 2d 20 57 68 65 6e 65 76 65 72 .@.@ -- Whenever
0c80: 20 6e 65 77 20 62 6c 6f 62 73 20 61 72 65 20 72 new blobs are r
0c90: 65 63 65 69 76 65 64 20 69 6e 74 6f 20 74 68 65 eceived into the
0ca0: 20 72 65 70 6f 73 69 74 6f 72 79 2c 20 61 6e 20 repository, an
0cb0: 65 6e 74 72 79 0a 40 20 2d 2d 20 69 6e 20 74 68 entry.@ -- in th
0cc0: 69 73 20 74 61 62 6c 65 20 72 65 63 6f 72 64 73 is table records
0cd0: 20 74 68 65 20 73 6f 75 72 63 65 20 6f 66 20 74 the source of t
0ce0: 68 65 20 62 6c 6f 62 2e 0a 40 20 2d 2d 0a 40 20 he blob..@ --.@
0cf0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 63 76 CREATE TABLE rcv
0d00: 66 72 6f 6d 28 0a 40 20 20 20 72 63 76 69 64 20 from(.@ rcvid
0d10: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 INTEGER PRIMARY
0d20: 4b 45 59 2c 20 20 20 20 20 20 2d 2d 20 52 65 63 KEY, -- Rec
0d30: 65 69 76 65 64 2d 46 72 6f 6d 20 49 44 0a 40 20 eived-From ID.@
0d40: 20 20 75 69 64 20 49 4e 54 45 47 45 52 20 52 45 uid INTEGER RE
0d50: 46 45 52 45 4e 43 45 53 20 75 73 65 72 2c 20 20 FERENCES user,
0d60: 20 20 2d 2d 20 55 73 65 72 20 6c 6f 67 69 6e 0a -- User login.
0d70: 40 20 20 20 6d 74 69 6d 65 20 44 41 54 45 54 49 @ mtime DATETI
0d80: 4d 45 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 ME,
0d90: 20 20 20 20 2d 2d 20 54 69 6d 65 20 6f 72 20 72 -- Time or r
0da0: 65 63 65 69 70 74 0a 40 20 20 20 6e 6f 6e 63 65 eceipt.@ nonce
0db0: 20 54 45 58 54 20 55 4e 49 51 55 45 2c 20 20 20 TEXT UNIQUE,
0dc0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4e 6f -- No
0dd0: 6e 63 65 20 75 73 65 64 20 66 6f 72 20 6c 6f 67 nce used for log
0de0: 69 6e 0a 40 20 20 20 69 70 61 64 64 72 20 54 45 in.@ ipaddr TE
0df0: 58 54 20 20 20 20 20 20 20 20 20 20 20 20 20 20 XT
0e00: 20 20 20 20 20 20 20 2d 2d 20 52 65 6d 6f 74 65 -- Remote
0e10: 20 49 50 20 61 64 64 72 65 73 73 2e 20 20 4e 55 IP address. NU
0e20: 4c 4c 20 66 6f 72 20 64 69 72 65 63 74 2e 0a 40 LL for direct..@
0e30: 20 29 3b 0a 40 0a 40 20 2d 2d 20 49 6e 66 6f 72 );.@.@ -- Infor
0e40: 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 75 73 65 mation about use
0e50: 72 73 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 rs.@ --.@ CREATE
0e60: 20 54 41 42 4c 45 20 75 73 65 72 28 0a 40 20 20 TABLE user(.@
0e70: 20 75 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 uid INTEGER PRI
0e80: 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 20 20 20 MARY KEY,
0e90: 20 2d 2d 20 55 73 65 72 20 49 44 0a 40 20 20 20 -- User ID.@
0ea0: 6c 6f 67 69 6e 20 54 45 58 54 2c 20 20 20 20 20 login TEXT,
0eb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0ec0: 2d 2d 20 6c 6f 67 69 6e 20 6e 61 6d 65 20 6f 66 -- login name of
0ed0: 20 74 68 65 20 75 73 65 72 0a 40 20 20 20 70 77 the user.@ pw
0ee0: 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 20 TEXT,
0ef0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
0f00: 20 70 61 73 73 77 6f 72 64 0a 40 20 20 20 63 61 password.@ ca
0f10: 70 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 p TEXT,
0f20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
0f30: 20 43 61 70 61 62 69 6c 69 74 69 65 73 20 6f 66 Capabilities of
0f40: 20 74 68 69 73 20 75 73 65 72 0a 40 20 20 20 63 this user.@ c
0f50: 6f 6f 6b 69 65 20 54 45 58 54 2c 20 20 20 20 20 ookie TEXT,
0f60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
0f70: 2d 20 57 57 57 20 6c 6f 67 69 6e 20 63 6f 6f 6b - WWW login cook
0f80: 69 65 0a 40 20 20 20 69 70 61 64 64 72 20 54 45 ie.@ ipaddr TE
0f90: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
0fa0: 20 20 20 20 20 20 20 2d 2d 20 49 50 20 61 64 64 -- IP add
0fb0: 72 65 73 73 20 66 6f 72 20 77 68 69 63 68 20 63 ress for which c
0fc0: 6f 6f 6b 69 65 20 69 73 20 76 61 6c 69 64 0a 40 ookie is valid.@
0fd0: 20 20 20 63 65 78 70 69 72 65 20 44 41 54 45 54 cexpire DATET
0fe0: 49 4d 45 2c 20 20 20 20 20 20 20 20 20 20 20 20 IME,
0ff0: 20 20 20 2d 2d 20 54 69 6d 65 20 77 68 65 6e 20 -- Time when
1000: 63 6f 6f 6b 69 65 20 65 78 70 69 72 65 73 0a 40 cookie expires.@
1010: 20 20 20 69 6e 66 6f 20 54 45 58 54 2c 20 20 20 info TEXT,
1020: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1030: 20 20 20 2d 2d 20 63 6f 6e 74 61 63 74 20 69 6e -- contact in
1040: 66 6f 72 6d 61 74 69 6f 6e 0a 40 20 20 20 70 68 formation.@ ph
1050: 6f 74 6f 20 42 4c 4f 42 20 20 20 20 20 20 20 20 oto BLOB
1060: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
1070: 20 4a 50 45 47 20 69 6d 61 67 65 20 6f 66 20 74 JPEG image of t
1080: 68 69 73 20 75 73 65 72 0a 40 20 29 3b 0a 40 0a his user.@ );.@.
1090: 40 20 2d 2d 20 54 68 65 20 56 41 52 20 74 61 62 @ -- The VAR tab
10a0: 6c 65 20 68 6f 6c 64 73 20 6d 69 73 63 65 6c 6c le holds miscell
10b0: 61 6e 6f 75 73 20 69 6e 66 6f 72 6d 61 74 69 6f anous informatio
10c0: 6e 20 61 62 6f 75 74 20 74 68 65 20 72 65 70 6f n about the repo
10d0: 73 69 74 6f 72 79 2e 0a 40 20 2d 2d 20 69 6e 20 sitory..@ -- in
10e0: 74 68 65 20 66 6f 72 6d 20 6f 66 20 6e 61 6d 65 the form of name
10f0: 2d 76 61 6c 75 65 20 70 61 69 72 73 2e 0a 40 20 -value pairs..@
1100: 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c --.@ CREATE TABL
1110: 45 20 63 6f 6e 66 69 67 28 0a 40 20 20 20 6e 61 E config(.@ na
1120: 6d 65 20 54 45 58 54 20 50 52 49 4d 41 52 59 20 me TEXT PRIMARY
1130: 4b 45 59 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20 2d KEY NOT NULL, -
1140: 2d 20 50 72 69 6d 61 72 79 20 6e 61 6d 65 20 6f - Primary name o
1150: 66 20 74 68 65 20 65 6e 74 72 79 0a 40 20 20 20 f the entry.@
1160: 76 61 6c 75 65 20 43 4c 4f 42 2c 20 20 20 20 20 value CLOB,
1170: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1180: 20 2d 2d 20 43 6f 6e 74 65 6e 74 20 6f 66 20 74 -- Content of t
1190: 68 65 20 6e 61 6d 65 64 20 70 61 72 61 6d 65 74 he named paramet
11a0: 65 72 0a 40 20 20 20 43 48 45 43 4b 28 20 74 79 er.@ CHECK( ty
11b0: 70 65 6f 66 28 6e 61 6d 65 29 3d 27 74 65 78 74 peof(name)='text
11c0: 27 20 41 4e 44 20 6c 65 6e 67 74 68 28 6e 61 6d ' AND length(nam
11d0: 65 29 3e 3d 31 20 29 0a 40 20 29 3b 0a 3b 0a 63 e)>=1 ).@ );.;.c
11e0: 6f 6e 73 74 20 63 68 61 72 20 7a 52 65 70 6f 73 onst char zRepos
11f0: 69 74 6f 72 79 53 63 68 65 6d 61 32 5b 5d 20 3d itorySchema2[] =
1200: 0a 40 20 2d 2d 20 46 69 6c 65 6e 61 6d 65 73 0a .@ -- Filenames.
1210: 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 @ --.@ CREATE TA
1220: 42 4c 45 20 66 69 6c 65 6e 61 6d 65 28 0a 40 20 BLE filename(.@
1230: 20 20 66 6e 69 64 20 49 4e 54 45 47 45 52 20 50 fnid INTEGER P
1240: 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 2d RIMARY KEY, -
1250: 2d 20 46 69 6c 65 6e 61 6d 65 20 49 44 0a 40 20 - Filename ID.@
1260: 20 20 6e 61 6d 65 20 54 45 58 54 20 55 4e 49 51 name TEXT UNIQ
1270: 55 45 20 20 20 20 20 20 20 20 20 20 20 20 20 2d UE -
1280: 2d 20 4e 61 6d 65 20 6f 66 20 66 69 6c 65 20 70 - Name of file p
1290: 61 67 65 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 age.@ );.@.@ --
12a0: 4c 69 6e 6b 61 67 65 73 20 62 65 74 77 65 65 6e Linkages between
12b0: 20 6d 61 6e 69 66 65 73 74 73 2c 20 66 69 6c 65 manifests, file
12c0: 73 20 63 72 65 61 74 65 64 20 62 79 20 74 68 61 s created by tha
12d0: 74 20 6d 61 6e 69 66 65 73 74 2c 20 61 6e 64 0a t manifest, and.
12e0: 40 20 2d 2d 20 74 68 65 20 6e 61 6d 65 73 20 6f @ -- the names o
12f0: 66 20 74 68 6f 73 65 20 66 69 6c 65 73 2e 0a 40 f those files..@
1300: 20 2d 2d 0a 40 20 2d 2d 20 70 69 64 3d 3d 30 20 --.@ -- pid==0
1310: 69 66 20 74 68 65 20 66 69 6c 65 20 69 73 20 61 if the file is a
1320: 64 64 65 64 20 62 79 20 63 68 65 63 6b 2d 69 6e dded by check-in
1330: 20 6d 69 64 2e 0a 40 20 2d 2d 20 66 69 64 3d 3d mid..@ -- fid==
1340: 30 20 69 66 20 74 68 65 20 66 69 6c 65 20 69 73 0 if the file is
1350: 20 72 65 6d 6f 76 65 64 20 62 79 20 63 68 65 63 removed by chec
1360: 6b 2d 69 6e 20 6d 69 64 2e 0a 40 20 2d 2d 0a 40 k-in mid..@ --.@
1370: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 6d 6c CREATE TABLE ml
1380: 69 6e 6b 28 0a 40 20 20 20 6d 69 64 20 49 4e 54 ink(.@ mid INT
1390: 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 EGER REFERENCES
13a0: 62 6c 6f 62 2c 20 20 20 20 20 20 20 20 2d 2d 20 blob, --
13b0: 4d 61 6e 69 66 65 73 74 20 49 44 20 77 68 65 72 Manifest ID wher
13c0: 65 20 63 68 61 6e 67 65 20 6f 63 63 75 72 73 0a e change occurs.
13d0: 40 20 20 20 70 69 64 20 49 4e 54 45 47 45 52 20 @ pid INTEGER
13e0: 52 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c REFERENCES blob,
13f0: 20 20 20 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 -- File
1400: 49 44 20 69 6e 20 70 61 72 65 6e 74 20 6d 61 6e ID in parent man
1410: 69 66 65 73 74 0a 40 20 20 20 66 69 64 20 49 4e ifest.@ fid IN
1420: 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 TEGER REFERENCES
1430: 20 62 6c 6f 62 2c 20 20 20 20 20 20 20 20 2d 2d blob, --
1440: 20 43 68 61 6e 67 65 64 20 66 69 6c 65 20 49 44 Changed file ID
1450: 20 69 6e 20 74 68 69 73 20 6d 61 6e 69 66 65 73 in this manifes
1460: 74 0a 40 20 20 20 66 6e 69 64 20 49 4e 54 45 47 t.@ fnid INTEG
1470: 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 66 69 ER REFERENCES fi
1480: 6c 65 6e 61 6d 65 20 20 20 20 2d 2d 20 4e 61 6d lename -- Nam
1490: 65 20 6f 66 20 74 68 65 20 66 69 6c 65 0a 40 20 e of the file.@
14a0: 29 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 45 );.@ CREATE INDE
14b0: 58 20 6d 6c 69 6e 6b 5f 69 31 20 4f 4e 20 6d 6c X mlink_i1 ON ml
14c0: 69 6e 6b 28 6d 69 64 29 3b 0a 40 20 43 52 45 41 ink(mid);.@ CREA
14d0: 54 45 20 49 4e 44 45 58 20 6d 6c 69 6e 6b 5f 69 TE INDEX mlink_i
14e0: 32 20 4f 4e 20 6d 6c 69 6e 6b 28 66 6e 69 64 29 2 ON mlink(fnid)
14f0: 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 45 58 ;.@ CREATE INDEX
1500: 20 6d 6c 69 6e 6b 5f 69 33 20 4f 4e 20 6d 6c 69 mlink_i3 ON mli
1510: 6e 6b 28 66 69 64 29 3b 0a 40 20 43 52 45 41 54 nk(fid);.@ CREAT
1520: 45 20 49 4e 44 45 58 20 6d 6c 69 6e 6b 5f 69 34 E INDEX mlink_i4
1530: 20 4f 4e 20 6d 6c 69 6e 6b 28 70 69 64 29 3b 0a ON mlink(pid);.
1540: 40 0a 40 20 2d 2d 20 50 61 72 65 6e 74 2f 63 68 @.@ -- Parent/ch
1550: 69 6c 64 20 6c 69 6e 6b 61 67 65 73 0a 40 20 2d ild linkages.@ -
1560: 2d 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 -.@ CREATE TABLE
1570: 20 70 6c 69 6e 6b 28 0a 40 20 20 20 70 69 64 20 plink(.@ pid
1580: 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 INTEGER REFERENC
1590: 45 53 20 62 6c 6f 62 2c 20 20 20 20 2d 2d 20 50 ES blob, -- P
15a0: 61 72 65 6e 74 20 6d 61 6e 69 66 65 73 74 0a 40 arent manifest.@
15b0: 20 20 20 63 69 64 20 49 4e 54 45 47 45 52 20 52 cid INTEGER R
15c0: 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c 20 EFERENCES blob,
15d0: 20 20 20 2d 2d 20 43 68 69 6c 64 20 6d 61 6e 69 -- Child mani
15e0: 66 65 73 74 0a 40 20 20 20 69 73 70 72 69 6d 20 fest.@ isprim
15f0: 42 4f 4f 4c 45 41 4e 2c 20 20 20 20 20 20 20 20 BOOLEAN,
1600: 20 20 20 20 20 20 20 20 20 2d 2d 20 70 69 64 20 -- pid
1610: 69 73 20 74 68 65 20 70 72 69 6d 61 72 79 20 70 is the primary p
1620: 61 72 65 6e 74 20 6f 66 20 63 69 64 0a 40 20 20 arent of cid.@
1630: 20 6d 74 69 6d 65 20 44 41 54 45 54 49 4d 45 2c mtime DATETIME,
1640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1650: 20 2d 2d 20 74 68 65 20 64 61 74 65 2f 74 69 6d -- the date/tim
1660: 65 20 73 74 61 6d 70 20 6f 6e 20 63 69 64 0a 40 e stamp on cid.@
1670: 20 20 20 55 4e 49 51 55 45 28 70 69 64 2c 20 63 UNIQUE(pid, c
1680: 69 64 29 0a 40 20 29 3b 0a 40 20 43 52 45 41 54 id).@ );.@ CREAT
1690: 45 20 49 4e 44 45 58 20 70 6c 69 6e 6b 5f 69 32 E INDEX plink_i2
16a0: 20 4f 4e 20 70 6c 69 6e 6b 28 63 69 64 29 3b 0a ON plink(cid);.
16b0: 40 0a 40 20 2d 2d 20 45 76 65 6e 74 73 20 75 73 @.@ -- Events us
16c0: 65 64 20 74 6f 20 67 65 6e 65 72 61 74 65 20 61 ed to generate a
16d0: 20 74 69 6d 65 6c 69 6e 65 0a 40 20 2d 2d 0a 40 timeline.@ --.@
16e0: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 65 76 CREATE TABLE ev
16f0: 65 6e 74 28 0a 40 20 20 20 74 79 70 65 20 54 45 ent(.@ type TE
1700: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
1710: 20 20 20 20 20 20 20 20 20 2d 2d 20 54 79 70 65 -- Type
1720: 20 6f 66 20 65 76 65 6e 74 0a 40 20 20 20 6d 74 of event.@ mt
1730: 69 6d 65 20 44 41 54 45 54 49 4d 45 2c 20 20 20 ime DATETIME,
1740: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
1750: 20 44 61 74 65 20 61 6e 64 20 74 69 6d 65 20 77 Date and time w
1760: 68 65 6e 20 74 68 65 20 65 76 65 6e 74 20 6f 63 hen the event oc
1770: 63 75 72 73 0a 40 20 20 20 6f 62 6a 69 64 20 49 curs.@ objid I
1780: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
1790: 45 59 2c 20 20 20 20 20 20 2d 2d 20 41 73 73 6f EY, -- Asso
17a0: 63 69 61 74 65 64 20 72 65 63 6f 72 64 20 49 44 ciated record ID
17b0: 0a 40 20 20 20 75 69 64 20 49 4e 54 45 47 45 52 .@ uid INTEGER
17c0: 20 52 45 46 45 52 45 4e 43 45 53 20 75 73 65 72 REFERENCES user
17d0: 2c 20 20 20 20 2d 2d 20 55 73 65 72 20 77 68 6f , -- User who
17e0: 20 63 61 75 73 65 64 20 74 68 65 20 65 76 65 6e caused the even
17f0: 74 0a 40 20 20 20 62 67 63 6f 6c 6f 72 20 54 45 t.@ bgcolor TE
1800: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
1810: 20 20 20 20 20 20 2d 2d 20 43 6f 6c 6f 72 20 73 -- Color s
1820: 65 74 20 62 79 20 27 62 67 63 6f 6c 6f 72 27 20 et by 'bgcolor'
1830: 70 72 6f 70 65 72 74 79 0a 40 20 20 20 62 72 62 property.@ brb
1840: 67 63 6f 6c 6f 72 20 54 45 58 54 2c 20 20 20 20 gcolor TEXT,
1850: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 --
1860: 43 6f 6c 6f 72 20 73 65 74 20 62 79 20 27 62 72 Color set by 'br
1870: 2d 62 67 63 6f 6c 6f 72 27 20 70 72 6f 70 65 72 -bgcolor' proper
1880: 74 79 0a 40 20 20 20 65 75 73 65 72 20 54 45 58 ty.@ euser TEX
1890: 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 T,
18a0: 20 20 20 20 20 20 20 2d 2d 20 55 73 65 72 20 73 -- User s
18b0: 65 74 20 62 79 20 27 75 73 65 72 27 20 70 72 6f et by 'user' pro
18c0: 70 65 72 74 79 0a 40 20 20 20 75 73 65 72 20 54 perty.@ user T
18d0: 45 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 EXT,
18e0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4e 61 6d -- Nam
18f0: 65 20 6f 66 20 74 68 65 20 75 73 65 72 0a 40 20 e of the user.@
1900: 20 20 65 63 6f 6d 6d 65 6e 74 20 54 45 58 54 2c ecomment TEXT,
1910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1920: 20 20 2d 2d 20 43 6f 6d 6d 65 6e 74 20 73 65 74 -- Comment set
1930: 20 62 79 20 27 63 6f 6d 6d 65 6e 74 27 20 70 72 by 'comment' pr
1940: 6f 70 65 72 74 79 0a 40 20 20 20 63 6f 6d 6d 65 operty.@ comme
1950: 6e 74 20 54 45 58 54 20 20 20 20 20 20 20 20 20 nt TEXT
1960: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 43 6f -- Co
1970: 6d 6d 65 6e 74 20 64 65 73 63 72 69 62 69 6e 67 mment describing
1980: 20 74 68 65 20 65 76 65 6e 74 0a 40 20 29 3b 0a the event.@ );.
1990: 40 20 43 52 45 41 54 45 20 49 4e 44 45 58 20 65 @ CREATE INDEX e
19a0: 76 65 6e 74 5f 69 31 20 4f 4e 20 65 76 65 6e 74 vent_i1 ON event
19b0: 28 6d 74 69 6d 65 29 3b 0a 40 0a 40 20 2d 2d 20 (mtime);.@.@ --
19c0: 41 20 72 65 63 6f 72 64 20 6f 66 20 70 68 61 6e A record of phan
19d0: 74 6f 6d 73 2e 20 20 41 20 70 68 61 6e 74 6f 6d toms. A phantom
19e0: 20 69 73 20 61 20 72 65 63 6f 72 64 20 66 6f 72 is a record for
19f0: 20 77 68 69 63 68 20 77 65 20 6b 6e 6f 77 20 74 which we know t
1a00: 68 65 0a 40 20 2d 2d 20 55 55 49 44 20 62 75 74 he.@ -- UUID but
1a10: 20 77 65 20 64 6f 20 6e 6f 74 20 28 79 65 74 29 we do not (yet)
1a20: 20 6b 6e 6f 77 20 74 68 65 20 66 69 6c 65 20 63 know the file c
1a30: 6f 6e 74 65 6e 74 2e 0a 40 20 2d 2d 0a 40 20 43 ontent..@ --.@ C
1a40: 52 45 41 54 45 20 54 41 42 4c 45 20 70 68 61 6e REATE TABLE phan
1a50: 74 6f 6d 28 0a 40 20 20 20 72 69 64 20 49 4e 54 tom(.@ rid INT
1a60: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
1a70: 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65 63 6f -- Reco
1a80: 72 64 20 49 44 20 6f 66 20 74 68 65 20 70 68 61 rd ID of the pha
1a90: 6e 74 6f 6d 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d ntom.@ );.@.@ --
1aa0: 20 55 6e 63 6c 75 73 74 65 72 65 64 20 72 65 63 Unclustered rec
1ab0: 6f 72 64 73 2e 20 20 41 6e 20 75 6e 63 6c 75 73 ords. An unclus
1ac0: 74 65 72 65 64 20 72 65 63 6f 72 64 20 69 73 20 tered record is
1ad0: 61 20 72 65 63 6f 72 64 20 28 69 6e 63 6c 75 64 a record (includ
1ae0: 69 6e 67 0a 40 20 2d 2d 20 61 20 63 6c 75 73 74 ing.@ -- a clust
1af0: 65 72 20 72 65 63 6f 72 64 73 20 74 68 65 6d 73 er records thems
1b00: 65 6c 76 65 73 29 20 74 68 61 74 20 69 73 20 6e elves) that is n
1b10: 6f 74 20 6d 65 6e 74 69 6f 6e 65 64 20 62 79 20 ot mentioned by
1b20: 73 6f 6d 65 20 6f 74 68 65 72 0a 40 20 2d 2d 20 some other.@ --
1b30: 63 6c 75 73 74 65 72 2e 0a 40 20 2d 2d 0a 40 20 cluster..@ --.@
1b40: 2d 2d 20 50 68 61 6e 74 6f 6d 73 20 61 72 65 20 -- Phantoms are
1b50: 75 73 75 61 6c 6c 79 20 69 6e 63 6c 75 64 65 64 usually included
1b60: 20 69 6e 20 74 68 65 20 75 6e 63 6c 75 73 74 65 in the uncluste
1b70: 72 65 64 20 74 61 62 6c 65 2e 20 20 41 20 6e 65 red table. A ne
1b80: 77 20 63 6c 75 73 74 65 72 0a 40 20 2d 2d 20 77 w cluster.@ -- w
1b90: 69 6c 6c 20 6e 65 76 65 72 20 62 65 20 63 72 65 ill never be cre
1ba0: 61 74 65 64 20 74 68 61 74 20 63 6f 6e 74 61 69 ated that contai
1bb0: 6e 73 20 61 20 70 68 61 6e 74 6f 6d 2e 20 20 42 ns a phantom. B
1bc0: 75 74 20 61 6e 6f 74 68 65 72 20 72 65 70 6f 73 ut another repos
1bd0: 69 74 6f 72 79 0a 40 20 2d 2d 20 6d 69 67 68 74 itory.@ -- might
1be0: 20 73 65 6e 64 20 75 73 20 61 20 63 6c 75 73 74 send us a clust
1bf0: 65 72 20 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 er that contains
1c00: 20 65 6e 74 72 69 65 73 20 74 68 61 74 20 61 72 entries that ar
1c10: 65 20 70 68 61 6e 74 6f 6d 73 20 74 6f 0a 40 20 e phantoms to.@
1c20: 2d 2d 20 75 73 2e 0a 40 20 2d 2d 0a 40 20 43 52 -- us..@ --.@ CR
1c30: 45 41 54 45 20 54 41 42 4c 45 20 75 6e 63 6c 75 EATE TABLE unclu
1c40: 73 74 65 72 65 64 28 0a 40 20 20 20 72 69 64 20 stered(.@ rid
1c50: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 INTEGER PRIMARY
1c60: 4b 45 59 20 20 20 20 20 20 20 20 20 2d 2d 20 52 KEY -- R
1c70: 65 63 6f 72 64 20 49 44 20 6f 66 20 74 68 65 20 ecord ID of the
1c80: 75 6e 63 6c 75 73 74 65 72 65 64 20 66 69 6c 65 unclustered file
1c90: 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 52 65 63 .@ );.@.@ -- Rec
1ca0: 6f 72 64 73 20 77 68 69 63 68 20 68 61 76 65 20 ords which have
1cb0: 6e 65 76 65 72 20 62 65 65 6e 20 70 75 73 68 65 never been pushe
1cc0: 64 20 74 6f 20 61 6e 6f 74 68 65 72 20 73 65 72 d to another ser
1cd0: 76 65 72 2e 20 20 54 68 69 73 20 69 73 0a 40 20 ver. This is.@
1ce0: 2d 2d 20 75 73 65 64 20 74 6f 20 72 65 64 75 63 -- used to reduc
1cf0: 65 20 70 75 73 68 20 6f 70 65 72 61 74 69 6f 6e e push operation
1d00: 73 20 74 6f 20 61 20 73 69 6e 67 6c 65 20 48 54 s to a single HT
1d10: 54 50 20 72 65 71 75 65 73 74 20 69 6e 20 74 68 TP request in th
1d20: 65 0a 40 20 2d 2d 20 63 6f 6d 6d 6f 6e 20 63 61 e.@ -- common ca
1d30: 73 65 20 77 68 65 6e 20 6f 6e 65 20 72 65 70 6f se when one repo
1d40: 73 69 74 6f 72 79 20 6f 6e 6c 79 20 74 61 6c 6b sitory only talk
1d50: 73 20 74 6f 20 61 20 73 69 6e 67 6c 65 20 73 65 s to a single se
1d60: 72 76 65 72 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 rver..@ --.@ CRE
1d70: 41 54 45 20 54 41 42 4c 45 20 75 6e 73 65 6e 74 ATE TABLE unsent
1d80: 28 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 (.@ rid INTEGE
1d90: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20 20 R PRIMARY KEY
1da0: 20 20 20 20 20 20 2d 2d 20 52 65 63 6f 72 64 20 -- Record
1db0: 49 44 20 6f 66 20 74 68 65 20 70 68 61 6e 74 6f ID of the phanto
1dc0: 6d 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 45 61 m.@ );.@.@ -- Ea
1dd0: 63 68 20 62 61 73 65 6c 69 6e 65 20 6f 72 20 6d ch baseline or m
1de0: 61 6e 69 66 65 73 74 20 63 61 6e 20 68 61 76 65 anifest can have
1df0: 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 74 61 67 one or more tag
1e00: 73 2e 20 20 41 20 74 61 67 0a 40 20 2d 2d 20 69 s. A tag.@ -- i
1e10: 73 20 64 65 66 69 6e 65 64 20 62 79 20 61 20 72 s defined by a r
1e20: 6f 77 20 69 6e 20 74 68 65 20 6e 65 78 74 20 74 ow in the next t
1e30: 61 62 6c 65 2e 0a 40 20 2d 2d 20 0a 40 20 2d 2d able..@ -- .@ --
1e40: 20 54 61 67 73 20 74 68 61 74 20 62 65 67 69 6e Tags that begin
1e50: 20 77 69 74 68 20 22 62 72 22 20 61 75 74 6f 6d with "br" autom
1e60: 61 74 69 63 61 6c 6c 79 20 70 72 6f 70 61 67 61 atically propaga
1e70: 74 65 20 74 6f 20 64 69 72 65 63 74 0a 40 20 2d te to direct.@ -
1e80: 2d 20 63 68 69 6c 64 72 65 6e 2c 20 62 75 74 20 - children, but
1e90: 6e 6f 74 20 74 6f 20 6d 65 72 67 65 20 63 68 69 not to merge chi
1ea0: 6c 64 72 65 6e 2e 0a 40 20 2d 2d 0a 40 20 43 52 ldren..@ --.@ CR
1eb0: 45 41 54 45 20 54 41 42 4c 45 20 74 61 67 28 0a EATE TABLE tag(.
1ec0: 40 20 20 20 74 61 67 69 64 20 49 4e 54 45 47 45 @ tagid INTEGE
1ed0: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 R PRIMARY KEY,
1ee0: 20 20 20 20 20 2d 2d 20 4e 75 6d 65 72 69 63 20 -- Numeric
1ef0: 74 61 67 20 49 44 0a 40 20 20 20 74 61 67 6e 61 tag ID.@ tagna
1f00: 6d 65 20 54 45 58 54 20 55 4e 49 51 55 45 20 20 me TEXT UNIQUE
1f10: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 -- T
1f20: 61 67 20 6e 61 6d 65 2e 20 20 50 72 65 66 69 78 ag name. Prefix
1f30: 65 64 20 62 79 20 27 76 27 20 6f 72 20 27 62 27 ed by 'v' or 'b'
1f40: 0a 40 20 29 3b 0a 40 20 49 4e 53 45 52 54 20 49 .@ );.@ INSERT I
1f50: 4e 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 31 NTO tag VALUES(1
1f60: 2c 20 27 62 67 63 6f 6c 6f 72 27 29 3b 20 20 20 , 'bgcolor');
1f70: 20 20 20 20 20 20 2d 2d 20 54 41 47 5f 42 47 43 -- TAG_BGC
1f80: 4f 4c 4f 52 0a 40 20 49 4e 53 45 52 54 20 49 4e OLOR.@ INSERT IN
1f90: 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 32 2c TO tag VALUES(2,
1fa0: 20 27 62 72 2d 62 67 63 6f 6c 6f 72 27 29 3b 20 'br-bgcolor');
1fb0: 20 20 20 20 20 2d 2d 20 54 41 47 5f 42 52 5f 42 -- TAG_BR_B
1fc0: 47 43 4f 4c 4f 52 0a 40 20 49 4e 53 45 52 54 20 GCOLOR.@ INSERT
1fd0: 49 4e 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 INTO tag VALUES(
1fe0: 33 2c 20 27 63 6f 6d 6d 65 6e 74 27 29 3b 20 20 3, 'comment');
1ff0: 20 20 20 20 20 20 20 2d 2d 20 54 41 47 5f 43 4f -- TAG_CO
2000: 4d 4d 45 4e 54 0a 40 20 49 4e 53 45 52 54 20 49 MMENT.@ INSERT I
2010: 4e 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 34 NTO tag VALUES(4
2020: 2c 20 27 75 73 65 72 27 29 3b 20 20 20 20 20 20 , 'user');
2030: 20 20 20 20 20 20 2d 2d 20 54 41 47 5f 55 53 45 -- TAG_USE
2040: 52 0a 40 0a 40 20 2d 2d 20 41 73 73 69 67 6e 6d R.@.@ -- Assignm
2050: 65 6e 74 73 20 6f 66 20 74 61 67 73 20 74 6f 20 ents of tags to
2060: 62 61 73 65 6c 69 6e 65 73 2e 20 20 4e 6f 74 65 baselines. Note
2070: 20 74 68 61 74 20 77 65 20 61 6c 6c 6f 77 20 74 that we allow t
2080: 61 67 73 20 74 6f 0a 40 20 2d 2d 20 68 61 76 65 ags to.@ -- have
2090: 20 76 61 6c 75 65 73 20 61 73 73 69 67 6e 65 64 values assigned
20a0: 20 74 6f 20 74 68 65 6d 2e 20 20 53 6f 20 77 65 to them. So we
20b0: 20 61 72 65 20 6e 6f 74 20 72 65 61 6c 6c 79 20 are not really
20c0: 64 65 61 6c 69 6e 67 20 77 69 74 68 0a 40 20 2d dealing with.@ -
20d0: 2d 20 74 61 67 73 20 68 65 72 65 2e 20 20 54 68 - tags here. Th
20e0: 65 73 65 20 61 72 65 20 72 65 61 6c 6c 79 20 70 ese are really p
20f0: 72 6f 70 65 72 74 69 65 73 2e 20 20 42 75 74 20 roperties. But
2100: 77 65 20 61 72 65 20 67 6f 69 6e 67 20 74 6f 0a we are going to.
2110: 40 20 2d 2d 20 6b 65 65 70 20 63 61 6c 6c 69 6e @ -- keep callin
2120: 67 20 74 68 65 6d 20 74 61 67 73 20 62 65 63 61 g them tags beca
2130: 75 73 65 20 69 6e 20 6d 61 6e 79 20 63 61 73 65 use in many case
2140: 73 20 74 68 65 20 76 61 6c 75 65 20 69 73 20 69 s the value is i
2150: 67 6e 6f 72 65 64 2e 0a 40 20 2d 2d 0a 40 20 43 gnored..@ --.@ C
2160: 52 45 41 54 45 20 54 41 42 4c 45 20 74 61 67 78 REATE TABLE tagx
2170: 72 65 66 28 0a 40 20 20 20 74 61 67 69 64 20 49 ref(.@ tagid I
2180: 4e 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 NTEGER REFERENCE
2190: 53 20 74 61 67 2c 20 20 20 2d 2d 20 54 68 65 20 S tag, -- The
21a0: 74 61 67 20 74 68 61 74 20 61 64 64 65 64 20 6f tag that added o
21b0: 72 20 72 65 6d 6f 76 65 64 0a 40 20 20 20 61 64 r removed.@ ad
21c0: 64 46 6c 61 67 20 42 4f 4f 4c 45 41 4e 2c 20 20 dFlag BOOLEAN,
21d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
21e0: 20 54 72 75 65 20 74 6f 20 61 64 64 20 74 68 65 True to add the
21f0: 20 74 61 67 2c 20 46 61 6c 73 65 20 74 6f 20 72 tag, False to r
2200: 65 6d 6f 76 65 0a 40 20 20 20 73 72 63 69 64 20 emove.@ srcid
2210: 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 INTEGER REFERENC
2220: 45 53 20 62 6c 6f 62 2c 20 20 2d 2d 20 4f 72 69 ES blob, -- Ori
2230: 67 69 6e 20 6f 66 20 74 68 65 20 74 61 67 2e 20 gin of the tag.
2240: 30 20 66 6f 72 20 70 72 6f 70 61 67 61 74 65 64 0 for propagated
2250: 20 74 61 67 73 0a 40 20 20 20 76 61 6c 75 65 20 tags.@ value
2260: 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 TEXT,
2270: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 56 61 6c -- Val
2280: 75 65 20 6f 66 20 74 68 65 20 74 61 67 2e 20 20 ue of the tag.
2290: 4d 69 67 68 74 20 62 65 20 4e 55 4c 4c 2e 0a 40 Might be NULL..@
22a0: 20 20 20 6d 74 69 6d 65 20 54 49 4d 45 53 54 41 mtime TIMESTA
22b0: 4d 50 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 MP,
22c0: 20 20 20 2d 2d 20 54 69 6d 65 20 6f 66 20 61 64 -- Time of ad
22d0: 64 69 74 69 6f 6e 20 6f 72 20 72 65 6d 6f 76 61 dition or remova
22e0: 6c 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 l.@ rid INTEGE
22f0: 52 20 52 45 46 45 52 45 4e 43 45 20 62 6c 6f 62 R REFERENCE blob
2300: 2c 20 20 20 20 20 2d 2d 20 42 61 73 65 6c 69 6e , -- Baselin
2310: 65 20 74 68 61 74 20 74 61 67 20 61 64 64 65 64 e that tag added
2320: 2f 72 65 6d 6f 76 65 64 20 66 72 6f 6d 0a 40 20 /removed from.@
2330: 20 20 55 4e 49 51 55 45 28 72 69 64 2c 20 74 61 UNIQUE(rid, ta
2340: 67 69 64 29 0a 40 20 29 3b 0a 40 20 43 52 45 41 gid).@ );.@ CREA
2350: 54 45 20 49 4e 44 45 58 20 74 61 67 78 72 65 66 TE INDEX tagxref
2360: 5f 69 31 20 4f 4e 20 74 61 67 78 72 65 66 28 74 _i1 ON tagxref(t
2370: 61 67 69 64 29 3b 0a 3b 0a 0a 2f 2a 0a 2a 2a 20 agid);.;../*.**
2380: 50 72 65 64 65 66 69 6e 65 64 20 74 61 67 69 64 Predefined tagid
2390: 20 76 61 6c 75 65 73 0a 2a 2f 0a 23 69 66 20 49 values.*/.#if I
23a0: 4e 54 45 52 46 41 43 45 0a 23 20 64 65 66 69 6e NTERFACE.# defin
23b0: 65 20 54 41 47 5f 42 47 43 4f 4c 4f 52 20 20 20 e TAG_BGCOLOR
23c0: 20 31 0a 23 20 64 65 66 69 6e 65 20 54 41 47 5f 1.# define TAG_
23d0: 42 52 5f 42 47 43 4f 4c 4f 52 20 32 0a 23 20 64 BR_BGCOLOR 2.# d
23e0: 65 66 69 6e 65 20 54 41 47 5f 43 4f 4d 4d 45 4e efine TAG_COMMEN
23f0: 54 20 20 20 20 33 0a 23 20 64 65 66 69 6e 65 20 T 3.# define
2400: 54 41 47 5f 55 53 45 52 20 20 20 20 20 20 20 34 TAG_USER 4
2410: 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 54 .#endif../*.** T
2420: 68 65 20 73 63 68 65 6d 61 20 66 6f 72 20 74 68 he schema for th
2430: 65 20 6c 6f 63 61 74 65 20 46 4f 53 53 49 4c 20 e locate FOSSIL
2440: 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 66 6f database file fo
2450: 75 6e 64 20 61 74 20 74 68 65 20 72 6f 6f 74 0a und at the root.
2460: 2a 2a 20 6f 66 20 76 65 72 79 20 63 68 65 63 6b ** of very check
2470: 2d 6f 75 74 2e 20 20 54 68 69 73 20 64 61 74 61 -out. This data
2480: 62 61 73 65 20 63 6f 6e 74 61 69 6e 73 20 74 68 base contains th
2490: 65 20 63 6f 6d 70 6c 65 74 65 20 73 74 61 74 65 e complete state
24a0: 20 6f 66 0a 2a 2a 20 74 68 65 20 63 68 65 63 6b of.** the check
24b0: 6f 75 74 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 out..*/.const ch
24c0: 61 72 20 7a 4c 6f 63 61 6c 53 63 68 65 6d 61 5b ar zLocalSchema[
24d0: 5d 20 3d 0a 40 20 2d 2d 20 54 68 65 20 56 56 41 ] =.@ -- The VVA
24e0: 52 20 74 61 62 6c 65 20 68 6f 6c 64 73 20 6d 69 R table holds mi
24f0: 73 63 65 6c 6c 61 6e 6f 75 73 20 69 6e 66 6f 72 scellanous infor
2500: 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 74 68 65 mation about the
2510: 20 6c 6f 63 61 6c 20 64 61 74 61 62 61 73 65 0a local database.
2520: 40 20 2d 2d 20 69 6e 20 74 68 65 20 66 6f 72 6d @ -- in the form
2530: 20 6f 66 20 6e 61 6d 65 2d 76 61 6c 75 65 20 70 of name-value p
2540: 61 69 72 73 2e 20 20 54 68 69 73 20 69 73 20 73 airs. This is s
2550: 69 6d 69 6c 61 72 20 74 6f 20 74 68 65 20 56 41 imilar to the VA
2560: 52 20 74 61 62 6c 65 0a 40 20 2d 2d 20 74 61 62 R table.@ -- tab
2570: 6c 65 20 69 6e 20 74 68 65 20 72 65 70 6f 73 69 le in the reposi
2580: 74 6f 72 79 20 65 78 63 65 70 74 20 74 68 61 74 tory except that
2590: 20 74 68 69 73 20 74 61 62 6c 65 20 68 6f 6c 64 this table hold
25a0: 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 74 68 s information th
25b0: 61 74 0a 40 20 2d 2d 20 69 73 20 73 70 65 63 69 at.@ -- is speci
25c0: 66 69 63 20 74 6f 20 74 68 65 20 6c 6f 63 61 6c fic to the local
25d0: 20 63 68 65 63 6b 6f 75 74 2e 0a 40 20 2d 2d 0a checkout..@ --.
25e0: 40 20 2d 2d 20 49 6d 70 6f 72 74 61 6e 74 20 56 @ -- Important V
25f0: 61 72 69 61 62 6c 65 73 3a 0a 40 20 2d 2d 0a 40 ariables:.@ --.@
2600: 20 2d 2d 20 20 20 20 20 72 65 70 6f 73 69 74 6f -- reposito
2610: 72 79 20 20 20 20 20 20 20 20 46 75 6c 6c 20 70 ry Full p
2620: 61 74 68 6e 61 6d 65 20 6f 66 20 74 68 65 20 72 athname of the r
2630: 65 70 6f 73 69 74 6f 72 79 20 64 61 74 61 62 61 epository databa
2640: 73 65 0a 40 20 2d 2d 20 20 20 20 20 75 73 65 72 se.@ -- user
2650: 2d 69 64 20 20 20 20 20 20 20 20 20 20 20 55 73 -id Us
2660: 65 72 69 64 20 74 6f 20 75 73 65 0a 40 20 2d 2d erid to use.@ --
2670: 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 .@ CREATE TABLE
2680: 76 76 61 72 28 0a 40 20 20 20 6e 61 6d 65 20 54 vvar(.@ name T
2690: 45 58 54 20 50 52 49 4d 41 52 59 20 4b 45 59 20 EXT PRIMARY KEY
26a0: 4e 4f 54 20 4e 55 4c 4c 2c 20 20 2d 2d 20 50 72 NOT NULL, -- Pr
26b0: 69 6d 61 72 79 20 6e 61 6d 65 20 6f 66 20 74 68 imary name of th
26c0: 65 20 65 6e 74 72 79 0a 40 20 20 20 76 61 6c 75 e entry.@ valu
26d0: 65 20 43 4c 4f 42 2c 20 20 20 20 20 20 20 20 20 e CLOB,
26e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 --
26f0: 43 6f 6e 74 65 6e 74 20 6f 66 20 74 68 65 20 6e Content of the n
2700: 61 6d 65 64 20 70 61 72 61 6d 65 74 65 72 0a 40 amed parameter.@
2710: 20 20 20 43 48 45 43 4b 28 20 74 79 70 65 6f 66 CHECK( typeof
2720: 28 6e 61 6d 65 29 3d 27 74 65 78 74 27 20 41 4e (name)='text' AN
2730: 44 20 6c 65 6e 67 74 68 28 6e 61 6d 65 29 3e 3d D length(name)>=
2740: 31 20 29 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 1 ).@ );.@.@ --
2750: 45 61 63 68 20 65 6e 74 72 79 20 69 6e 20 74 68 Each entry in th
2760: 65 20 76 66 69 6c 65 20 74 61 62 6c 65 20 72 65 e vfile table re
2770: 70 72 65 73 65 6e 74 73 20 61 20 73 69 6e 67 6c presents a singl
2780: 65 20 66 69 6c 65 20 6f 72 20 66 6f 6c 64 65 72 e file or folder
2790: 0a 40 20 2d 2d 20 74 68 61 74 20 69 73 20 70 61 .@ -- that is pa
27a0: 72 74 20 6f 66 20 61 20 76 65 72 73 69 6f 6e 2e rt of a version.
27b0: 0a 40 20 2d 2d 0a 40 20 2d 2d 20 54 68 65 20 66 .@ --.@ -- The f
27c0: 69 6c 65 2e 72 69 64 20 66 69 65 6c 64 20 69 73 ile.rid field is
27d0: 20 30 20 66 6f 72 20 66 69 6c 65 73 20 6f 72 20 0 for files or
27e0: 66 6f 6c 64 65 72 73 20 74 68 61 74 20 68 61 76 folders that hav
27f0: 65 20 62 65 65 6e 0a 40 20 2d 2d 20 61 64 64 65 e been.@ -- adde
2800: 64 20 62 75 74 20 6e 6f 74 20 79 65 74 20 63 6f d but not yet co
2810: 6d 6d 69 74 74 65 64 2e 0a 40 20 2d 2d 0a 40 20 mmitted..@ --.@
2820: 2d 2d 20 56 66 69 6c 65 2e 63 68 6e 67 65 64 20 -- Vfile.chnged
2830: 69 73 20 30 20 66 6f 72 20 75 6e 6d 6f 64 69 66 is 0 for unmodif
2840: 69 65 64 20 66 69 6c 65 73 2c 20 31 20 66 6f 72 ied files, 1 for
2850: 20 66 69 6c 65 73 20 74 68 61 74 20 68 61 76 65 files that have
2860: 0a 40 20 2d 2d 20 62 65 65 6e 20 65 64 69 74 65 .@ -- been edite
2870: 64 20 6f 72 20 77 68 69 63 68 20 68 61 76 65 20 d or which have
2880: 62 65 65 6e 20 73 75 62 6a 65 63 74 65 64 20 74 been subjected t
2890: 6f 20 61 20 33 2d 77 61 79 20 6d 65 72 67 65 2e o a 3-way merge.
28a0: 20 20 0a 40 20 2d 2d 20 56 66 69 6c 65 2e 63 68 .@ -- Vfile.ch
28b0: 6e 67 65 64 20 69 73 20 32 20 69 66 20 74 68 65 nged is 2 if the
28c0: 20 66 69 6c 65 20 68 61 73 20 62 65 65 6e 20 72 file has been r
28d0: 65 70 6c 61 63 65 64 20 66 72 6f 6d 20 61 20 64 eplaced from a d
28e0: 69 66 66 65 72 65 6e 74 0a 40 20 2d 2d 20 76 65 ifferent.@ -- ve
28f0: 72 73 69 6f 6e 20 62 79 20 74 68 65 20 6d 65 72 rsion by the mer
2900: 67 65 20 61 6e 64 20 33 20 69 66 20 74 68 65 20 ge and 3 if the
2910: 66 69 6c 65 20 68 61 73 20 62 65 65 6e 20 61 64 file has been ad
2920: 64 65 64 20 62 79 20 61 20 6d 65 72 67 65 2e 0a ded by a merge..
2930: 40 20 2d 2d 20 54 68 65 20 64 69 66 66 65 72 65 @ -- The differe
2940: 6e 63 65 20 62 65 74 77 65 65 6e 20 76 66 69 6c nce between vfil
2950: 65 2e 63 68 6e 67 65 64 3d 3d 32 20 61 6e 64 20 e.chnged==2 and
2960: 61 20 72 65 67 75 6c 61 72 20 61 64 64 20 69 73 a regular add is
2970: 20 74 68 61 74 0a 40 20 2d 2d 20 77 69 74 68 20 that.@ -- with
2980: 76 66 69 6c 65 2e 63 68 6e 67 65 64 3d 3d 32 20 vfile.chnged==2
2990: 77 65 20 6b 6e 6f 77 20 74 68 61 74 20 74 68 65 we know that the
29a0: 20 63 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e current version
29b0: 20 6f 66 20 74 68 65 20 66 69 6c 65 0a 40 20 2d of the file.@ -
29c0: 2d 20 69 73 20 61 6c 72 65 61 64 79 20 69 6e 20 - is already in
29d0: 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a the repository..
29e0: 40 20 2d 2d 20 0a 40 20 2d 2d 0a 40 20 43 52 45 @ -- .@ --.@ CRE
29f0: 41 54 45 20 54 41 42 4c 45 20 76 66 69 6c 65 28 ATE TABLE vfile(
2a00: 0a 40 20 20 20 69 64 20 49 4e 54 45 47 45 52 20 .@ id INTEGER
2a10: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 PRIMARY KEY,
2a20: 20 20 20 20 20 20 20 2d 2d 20 49 44 20 6f 66 20 -- ID of
2a30: 74 68 65 20 63 68 65 63 6b 65 64 20 6f 75 74 20 the checked out
2a40: 66 69 6c 65 0a 40 20 20 20 76 69 64 20 49 4e 54 file.@ vid INT
2a50: 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 EGER REFERENCES
2a60: 62 6c 6f 62 2c 20 20 20 20 20 20 2d 2d 20 54 68 blob, -- Th
2a70: 65 20 76 65 72 73 69 6f 6e 20 74 68 69 73 20 66 e version this f
2a80: 69 6c 65 20 69 73 20 70 61 72 74 20 6f 66 2e 0a ile is part of..
2a90: 40 20 20 20 63 68 6e 67 65 64 20 49 4e 54 20 44 @ chnged INT D
2aa0: 45 46 41 55 4c 54 20 30 2c 20 20 20 20 20 20 20 EFAULT 0,
2ab0: 20 20 20 20 20 20 2d 2d 20 30 3a 75 6e 63 68 6e -- 0:unchn
2ac0: 67 65 64 20 31 3a 65 64 69 74 65 64 20 32 3a 6d ged 1:edited 2:m
2ad0: 2d 63 68 6e 67 20 33 3a 6d 2d 61 64 64 0a 40 20 -chng 3:m-add.@
2ae0: 20 20 64 65 6c 65 74 65 64 20 42 4f 4f 4c 45 41 deleted BOOLEA
2af0: 4e 20 44 45 46 41 55 4c 54 20 30 2c 20 20 20 20 N DEFAULT 0,
2b00: 20 20 20 20 2d 2d 20 54 72 75 65 20 69 66 20 64 -- True if d
2b10: 65 6c 65 74 65 64 20 0a 40 20 20 20 72 69 64 20 eleted .@ rid
2b20: 49 4e 54 45 47 45 52 2c 20 20 20 20 20 20 20 20 INTEGER,
2b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
2b40: 20 4f 72 69 67 69 6e 61 6c 6c 79 20 66 72 6f 6d Originally from
2b50: 20 74 68 69 73 20 72 65 70 6f 73 69 74 6f 72 79 this repository
2b60: 20 72 65 63 6f 72 64 0a 40 20 20 20 6d 72 69 64 record.@ mrid
2b70: 20 49 4e 54 45 47 45 52 2c 20 20 20 20 20 20 20 INTEGER,
2b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
2b90: 20 42 61 73 65 64 20 6f 6e 20 74 68 69 73 20 72 Based on this r
2ba0: 65 63 6f 72 64 20 64 75 65 20 74 6f 20 61 20 6d ecord due to a m
2bb0: 65 72 67 65 0a 40 20 20 20 70 61 74 68 6e 61 6d erge.@ pathnam
2bc0: 65 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 e TEXT,
2bd0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 46 75 -- Fu
2be0: 6c 6c 20 70 61 74 68 6e 61 6d 65 0a 40 20 20 20 ll pathname.@
2bf0: 55 4e 49 51 55 45 28 70 61 74 68 6e 61 6d 65 2c UNIQUE(pathname,
2c00: 76 69 64 29 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d vid).@ );.@.@ --
2c10: 20 54 68 69 73 20 74 61 62 6c 65 20 68 6f 6c 64 This table hold
2c20: 73 20 61 20 72 65 63 6f 72 64 20 6f 66 20 75 6e s a record of un
2c30: 63 6f 6d 6d 69 74 74 65 64 20 6d 65 72 67 65 73 committed merges
2c40: 20 69 6e 20 74 68 65 20 6c 6f 63 61 6c 0a 40 20 in the local.@
2c50: 2d 2d 20 66 69 6c 65 20 74 72 65 65 2e 20 20 49 -- file tree. I
2c60: 66 20 61 20 56 46 49 4c 45 20 65 6e 74 72 79 20 f a VFILE entry
2c70: 77 69 74 68 20 69 64 20 68 61 73 20 6d 65 72 67 with id has merg
2c80: 65 64 20 77 69 74 68 20 61 6e 6f 74 68 65 72 0a ed with another.
2c90: 40 20 2d 2d 20 72 65 63 6f 72 64 2c 20 74 68 65 @ -- record, the
2ca0: 72 65 20 69 73 20 61 6e 20 65 6e 74 72 79 20 69 re is an entry i
2cb0: 6e 20 74 68 69 73 20 74 61 62 6c 65 20 77 69 74 n this table wit
2cc0: 68 20 28 69 64 2c 6d 65 72 67 65 29 20 77 68 65 h (id,merge) whe
2cd0: 72 65 0a 40 20 2d 2d 20 6d 65 72 67 65 20 69 73 re.@ -- merge is
2ce0: 20 74 68 65 20 52 45 43 4f 52 44 20 74 61 62 6c the RECORD tabl
2cf0: 65 20 65 6e 74 72 79 20 74 68 61 74 20 74 68 65 e entry that the
2d00: 20 66 69 6c 65 20 6d 65 72 67 65 64 20 61 67 61 file merged aga
2d10: 69 6e 73 74 2e 0a 40 20 2d 2d 20 41 6e 20 69 64 inst..@ -- An id
2d20: 20 6f 66 20 30 20 68 65 72 65 20 6d 65 61 6e 73 of 0 here means
2d30: 20 74 68 65 20 76 65 72 73 69 6f 6e 20 72 65 63 the version rec
2d40: 6f 72 64 20 69 74 73 65 6c 66 2e 0a 40 0a 40 20 ord itself..@.@
2d50: 43 52 45 41 54 45 20 54 41 42 4c 45 20 76 6d 65 CREATE TABLE vme
2d60: 72 67 65 28 0a 40 20 20 20 69 64 20 49 4e 54 45 rge(.@ id INTE
2d70: 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 76 GER REFERENCES v
2d80: 66 69 6c 65 2c 20 20 20 20 20 20 2d 2d 20 56 46 file, -- VF
2d90: 49 4c 45 20 65 6e 74 72 79 20 74 68 61 74 20 68 ILE entry that h
2da0: 61 73 20 62 65 65 6e 20 6d 65 72 67 65 64 0a 40 as been merged.@
2db0: 20 20 20 6d 65 72 67 65 20 49 4e 54 45 47 45 52 merge INTEGER
2dc0: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
2dd0: 20 20 20 20 20 2d 2d 20 4d 65 72 67 65 64 20 77 -- Merged w
2de0: 69 74 68 20 74 68 69 73 20 72 65 63 6f 72 64 0a ith this record.
2df0: 40 20 20 20 55 4e 49 51 55 45 28 69 64 2c 20 6d @ UNIQUE(id, m
2e00: 65 72 67 65 29 0a 40 20 29 3b 0a 40 20 20 20 0a erge).@ );.@ .
2e10: 3b 0a 0a 63 6f 6e 73 74 20 63 68 61 72 20 7a 53 ;..const char zS
2e20: 65 72 76 65 72 54 65 6d 70 53 63 68 65 6d 61 5b erverTempSchema[
2e30: 5d 20 3d 0a 40 20 2d 2d 20 41 20 63 6f 70 79 20 ] =.@ -- A copy
2e40: 6f 66 20 74 68 65 20 76 66 69 6c 65 20 74 61 62 of the vfile tab
2e50: 6c 65 20 73 63 68 65 6d 61 20 75 73 65 64 20 62 le schema used b
2e60: 79 20 74 68 65 20 57 57 57 20 73 65 72 76 65 72 y the WWW server
2e70: 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 .@ --.@ CREATE T
2e80: 45 4d 50 20 54 41 42 4c 45 20 76 66 69 6c 65 28 EMP TABLE vfile(
2e90: 0a 40 20 20 20 69 64 20 49 4e 54 45 47 45 52 20 .@ id INTEGER
2ea0: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 PRIMARY KEY,
2eb0: 20 20 20 20 20 20 20 2d 2d 20 49 44 20 6f 66 20 -- ID of
2ec0: 74 68 65 20 63 68 65 63 6b 65 64 20 6f 75 74 20 the checked out
2ed0: 66 69 6c 65 0a 40 20 20 20 76 69 64 20 49 4e 54 file.@ vid INT
2ee0: 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 EGER REFERENCES
2ef0: 72 65 63 6f 72 64 2c 20 20 20 20 2d 2d 20 54 68 record, -- Th
2f00: 65 20 76 65 72 73 69 6f 6e 20 74 68 69 73 20 66 e version this f
2f10: 69 6c 65 20 69 73 20 70 61 72 74 20 6f 66 2e 0a ile is part of..
2f20: 40 20 20 20 63 68 6e 67 65 64 20 49 4e 54 20 44 @ chnged INT D
2f30: 45 46 41 55 4c 54 20 30 2c 20 20 20 20 20 20 20 EFAULT 0,
2f40: 20 20 20 20 20 20 2d 2d 20 30 3a 75 6e 63 68 6e -- 0:unchn
2f50: 67 65 64 20 31 3a 65 64 69 74 65 64 20 32 3a 6d ged 1:edited 2:m
2f60: 2d 63 68 6e 67 20 33 3a 6d 2d 61 64 64 0a 40 20 -chng 3:m-add.@
2f70: 20 20 64 65 6c 65 74 65 64 20 42 4f 4f 4c 45 41 deleted BOOLEA
2f80: 4e 20 44 45 46 41 55 4c 54 20 30 2c 20 20 20 20 N DEFAULT 0,
2f90: 20 20 20 20 2d 2d 20 54 72 75 65 20 69 66 20 64 -- True if d
2fa0: 65 6c 65 74 65 64 20 0a 40 20 20 20 72 69 64 20 eleted .@ rid
2fb0: 49 4e 54 45 47 45 52 2c 20 20 20 20 20 20 20 20 INTEGER,
2fc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
2fd0: 20 4f 72 69 67 69 6e 61 6c 6c 79 20 66 72 6f 6d Originally from
2fe0: 20 74 68 69 73 20 72 65 70 6f 73 69 74 6f 72 79 this repository
2ff0: 20 72 65 63 6f 72 64 0a 40 20 20 20 6d 72 69 64 record.@ mrid
3000: 20 49 4e 54 45 47 45 52 2c 20 20 20 20 20 20 20 INTEGER,
3010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
3020: 20 42 61 73 65 64 20 6f 6e 20 74 68 69 73 20 72 Based on this r
3030: 65 63 6f 72 64 20 64 75 65 20 74 6f 20 61 20 6d ecord due to a m
3040: 65 72 67 65 0a 40 20 20 20 70 61 74 68 6e 61 6d erge.@ pathnam
3050: 65 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 e TEXT,
3060: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 46 75 -- Fu
3070: 6c 6c 20 70 61 74 68 6e 61 6d 65 0a 40 20 20 20 ll pathname.@
3080: 55 4e 49 51 55 45 28 70 61 74 68 6e 61 6d 65 2c UNIQUE(pathname,
3090: 76 69 64 29 0a 40 20 29 3b 0a 3b 0a vid).@ );.;.