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 40 0a 40 e)>=1 ).@ );.@.@
11e0: 20 2d 2d 20 41 72 74 69 66 61 63 74 73 20 74 68 -- Artifacts th
11f0: 61 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 at should not be
1200: 20 70 72 6f 63 65 73 73 65 64 20 61 72 65 20 69 processed are i
1210: 64 65 6e 74 69 66 69 65 64 20 69 6e 20 74 68 65 dentified in the
1220: 0a 40 20 2d 2d 20 22 73 68 75 6e 22 20 74 61 62 .@ -- "shun" tab
1230: 6c 65 2e 20 20 41 72 74 69 66 61 63 74 73 20 74 le. Artifacts t
1240: 68 61 74 20 61 72 65 20 63 6f 6e 74 72 6f 6c 2d hat are control-
1250: 66 69 6c 65 20 66 6f 72 67 65 72 69 65 73 20 6f file forgeries o
1260: 72 0a 40 20 2d 2d 20 73 70 61 6d 20 63 61 6e 20 r.@ -- spam can
1270: 62 65 20 73 68 75 6e 6e 65 64 20 69 6e 20 6f 72 be shunned in or
1280: 64 65 72 20 74 6f 20 70 72 65 76 65 6e 74 20 74 der to prevent t
1290: 68 65 6d 20 66 72 6f 6d 20 63 6f 6e 74 61 6d 69 hem from contami
12a0: 6e 61 74 69 6e 67 0a 40 20 2d 2d 20 74 68 65 20 nating.@ -- the
12b0: 72 65 70 6f 73 69 74 6f 72 79 2e 0a 40 20 2d 2d repository..@ --
12c0: 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 .@ CREATE TABLE
12d0: 73 68 75 6e 28 75 75 69 64 20 55 4e 49 51 55 45 shun(uuid UNIQUE
12e0: 29 3b 0a 40 0a 40 20 2d 2d 20 41 6e 20 65 6e 74 );.@.@ -- An ent
12f0: 72 79 20 69 6e 20 74 68 69 73 20 74 61 62 6c 65 ry in this table
1300: 20 64 65 73 63 72 69 62 65 73 20 61 20 64 61 74 describes a dat
1310: 61 62 61 73 65 20 71 75 65 72 79 20 74 68 61 74 abase query that
1320: 20 67 65 6e 65 72 61 74 65 73 20 61 0a 40 20 2d generates a.@ -
1330: 2d 20 74 61 62 6c 65 20 6f 66 20 74 69 63 6b 65 - table of ticke
1340: 74 73 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 ts..@ --.@ CREAT
1350: 45 20 54 41 42 4c 45 20 72 65 70 6f 72 74 66 6d E TABLE reportfm
1360: 74 28 0a 40 20 20 20 20 72 6e 20 69 6e 74 65 67 t(.@ rn integ
1370: 65 72 20 70 72 69 6d 61 72 79 20 6b 65 79 2c 20 er primary key,
1380: 20 2d 2d 20 52 65 70 6f 72 74 20 6e 75 6d 62 65 -- Report numbe
1390: 72 0a 40 20 20 20 20 6f 77 6e 65 72 20 74 65 78 r.@ owner tex
13a0: 74 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t,
13b0: 2d 2d 20 4f 77 6e 65 72 20 6f 66 20 74 68 69 73 -- Owner of this
13c0: 20 72 65 70 6f 72 74 20 66 6f 72 6d 61 74 20 28 report format (
13d0: 6e 6f 74 20 75 73 65 64 29 0a 40 20 20 20 20 74 not used).@ t
13e0: 69 74 6c 65 20 74 65 78 74 2c 20 20 20 20 20 20 itle text,
13f0: 20 20 20 20 20 20 20 20 2d 2d 20 54 69 74 6c 65 -- Title
1400: 20 6f 66 20 74 68 69 73 20 72 65 70 6f 72 74 0a of this report.
1410: 40 20 20 20 20 63 6f 6c 73 20 74 65 78 74 2c 20 @ cols text,
1420: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
1430: 20 41 20 63 6f 6c 6f 72 2d 6b 65 79 20 73 70 65 A color-key spe
1440: 63 69 66 69 63 61 74 69 6f 6e 0a 40 20 20 20 20 cification.@
1450: 73 71 6c 63 6f 64 65 20 74 65 78 74 20 20 20 20 sqlcode text
1460: 20 20 20 20 20 20 20 20 20 2d 2d 20 41 6e 20 53 -- An S
1470: 51 4c 20 53 45 4c 45 43 54 20 73 74 61 74 65 6d QL SELECT statem
1480: 65 6e 74 20 66 6f 72 20 74 68 69 73 20 72 65 70 ent for this rep
1490: 6f 72 74 0a 40 20 29 3b 0a 3b 0a 0a 63 6f 6e 73 ort.@ );.;..cons
14a0: 74 20 63 68 61 72 20 7a 52 65 70 6f 73 69 74 6f t char zReposito
14b0: 72 79 53 63 68 65 6d 61 32 5b 5d 20 3d 0a 40 20 rySchema2[] =.@
14c0: 2d 2d 20 46 69 6c 65 6e 61 6d 65 73 0a 40 20 2d -- Filenames.@ -
14d0: 2d 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 -.@ CREATE TABLE
14e0: 20 66 69 6c 65 6e 61 6d 65 28 0a 40 20 20 20 66 filename(.@ f
14f0: 6e 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d nid INTEGER PRIM
1500: 41 52 59 20 4b 45 59 2c 20 20 20 20 2d 2d 20 46 ARY KEY, -- F
1510: 69 6c 65 6e 61 6d 65 20 49 44 0a 40 20 20 20 6e ilename ID.@ n
1520: 61 6d 65 20 54 45 58 54 20 55 4e 49 51 55 45 20 ame TEXT UNIQUE
1530: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4e -- N
1540: 61 6d 65 20 6f 66 20 66 69 6c 65 20 70 61 67 65 ame of file page
1550: 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 4c 69 6e .@ );.@.@ -- Lin
1560: 6b 61 67 65 73 20 62 65 74 77 65 65 6e 20 6d 61 kages between ma
1570: 6e 69 66 65 73 74 73 2c 20 66 69 6c 65 73 20 63 nifests, files c
1580: 72 65 61 74 65 64 20 62 79 20 74 68 61 74 20 6d reated by that m
1590: 61 6e 69 66 65 73 74 2c 20 61 6e 64 0a 40 20 2d anifest, and.@ -
15a0: 2d 20 74 68 65 20 6e 61 6d 65 73 20 6f 66 20 74 - the names of t
15b0: 68 6f 73 65 20 66 69 6c 65 73 2e 0a 40 20 2d 2d hose files..@ --
15c0: 0a 40 20 2d 2d 20 70 69 64 3d 3d 30 20 69 66 20 .@ -- pid==0 if
15d0: 74 68 65 20 66 69 6c 65 20 69 73 20 61 64 64 65 the file is adde
15e0: 64 20 62 79 20 63 68 65 63 6b 2d 69 6e 20 6d 69 d by check-in mi
15f0: 64 2e 0a 40 20 2d 2d 20 66 69 64 3d 3d 30 20 69 d..@ -- fid==0 i
1600: 66 20 74 68 65 20 66 69 6c 65 20 69 73 20 72 65 f the file is re
1610: 6d 6f 76 65 64 20 62 79 20 63 68 65 63 6b 2d 69 moved by check-i
1620: 6e 20 6d 69 64 2e 0a 40 20 2d 2d 0a 40 20 43 52 n mid..@ --.@ CR
1630: 45 41 54 45 20 54 41 42 4c 45 20 6d 6c 69 6e 6b EATE TABLE mlink
1640: 28 0a 40 20 20 20 6d 69 64 20 49 4e 54 45 47 45 (.@ mid INTEGE
1650: 52 20 52 45 46 45 52 45 4e 43 45 53 20 62 6c 6f R REFERENCES blo
1660: 62 2c 20 20 20 20 20 20 20 20 2d 2d 20 4d 61 6e b, -- Man
1670: 69 66 65 73 74 20 49 44 20 77 68 65 72 65 20 63 ifest ID where c
1680: 68 61 6e 67 65 20 6f 63 63 75 72 73 0a 40 20 20 hange occurs.@
1690: 20 70 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 pid INTEGER REF
16a0: 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c 20 20 20 ERENCES blob,
16b0: 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 49 44 20 -- File ID
16c0: 69 6e 20 70 61 72 65 6e 74 20 6d 61 6e 69 66 65 in parent manife
16d0: 73 74 0a 40 20 20 20 66 69 64 20 49 4e 54 45 47 st.@ fid INTEG
16e0: 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 62 6c ER REFERENCES bl
16f0: 6f 62 2c 20 20 20 20 20 20 20 20 2d 2d 20 43 68 ob, -- Ch
1700: 61 6e 67 65 64 20 66 69 6c 65 20 49 44 20 69 6e anged file ID in
1710: 20 74 68 69 73 20 6d 61 6e 69 66 65 73 74 0a 40 this manifest.@
1720: 20 20 20 66 6e 69 64 20 49 4e 54 45 47 45 52 20 fnid INTEGER
1730: 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c 65 6e REFERENCES filen
1740: 61 6d 65 20 20 20 20 2d 2d 20 4e 61 6d 65 20 6f ame -- Name o
1750: 66 20 74 68 65 20 66 69 6c 65 0a 40 20 29 3b 0a f the file.@ );.
1760: 40 20 43 52 45 41 54 45 20 49 4e 44 45 58 20 6d @ CREATE INDEX m
1770: 6c 69 6e 6b 5f 69 31 20 4f 4e 20 6d 6c 69 6e 6b link_i1 ON mlink
1780: 28 6d 69 64 29 3b 0a 40 20 43 52 45 41 54 45 20 (mid);.@ CREATE
1790: 49 4e 44 45 58 20 6d 6c 69 6e 6b 5f 69 32 20 4f INDEX mlink_i2 O
17a0: 4e 20 6d 6c 69 6e 6b 28 66 6e 69 64 29 3b 0a 40 N mlink(fnid);.@
17b0: 20 43 52 45 41 54 45 20 49 4e 44 45 58 20 6d 6c CREATE INDEX ml
17c0: 69 6e 6b 5f 69 33 20 4f 4e 20 6d 6c 69 6e 6b 28 ink_i3 ON mlink(
17d0: 66 69 64 29 3b 0a 40 20 43 52 45 41 54 45 20 49 fid);.@ CREATE I
17e0: 4e 44 45 58 20 6d 6c 69 6e 6b 5f 69 34 20 4f 4e NDEX mlink_i4 ON
17f0: 20 6d 6c 69 6e 6b 28 70 69 64 29 3b 0a 40 0a 40 mlink(pid);.@.@
1800: 20 2d 2d 20 50 61 72 65 6e 74 2f 63 68 69 6c 64 -- Parent/child
1810: 20 6c 69 6e 6b 61 67 65 73 0a 40 20 2d 2d 0a 40 linkages.@ --.@
1820: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 70 6c CREATE TABLE pl
1830: 69 6e 6b 28 0a 40 20 20 20 70 69 64 20 49 4e 54 ink(.@ pid INT
1840: 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 20 EGER REFERENCES
1850: 62 6c 6f 62 2c 20 20 20 20 2d 2d 20 50 61 72 65 blob, -- Pare
1860: 6e 74 20 6d 61 6e 69 66 65 73 74 0a 40 20 20 20 nt manifest.@
1870: 63 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 cid INTEGER REFE
1880: 52 45 4e 43 45 53 20 62 6c 6f 62 2c 20 20 20 20 RENCES blob,
1890: 2d 2d 20 43 68 69 6c 64 20 6d 61 6e 69 66 65 73 -- Child manifes
18a0: 74 0a 40 20 20 20 69 73 70 72 69 6d 20 42 4f 4f t.@ isprim BOO
18b0: 4c 45 41 4e 2c 20 20 20 20 20 20 20 20 20 20 20 LEAN,
18c0: 20 20 20 20 20 20 2d 2d 20 70 69 64 20 69 73 20 -- pid is
18d0: 74 68 65 20 70 72 69 6d 61 72 79 20 70 61 72 65 the primary pare
18e0: 6e 74 20 6f 66 20 63 69 64 0a 40 20 20 20 6d 74 nt of cid.@ mt
18f0: 69 6d 65 20 44 41 54 45 54 49 4d 45 2c 20 20 20 ime DATETIME,
1900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
1910: 20 74 68 65 20 64 61 74 65 2f 74 69 6d 65 20 73 the date/time s
1920: 74 61 6d 70 20 6f 6e 20 63 69 64 0a 40 20 20 20 tamp on cid.@
1930: 55 4e 49 51 55 45 28 70 69 64 2c 20 63 69 64 29 UNIQUE(pid, cid)
1940: 0a 40 20 29 3b 0a 40 20 43 52 45 41 54 45 20 49 .@ );.@ CREATE I
1950: 4e 44 45 58 20 70 6c 69 6e 6b 5f 69 32 20 4f 4e NDEX plink_i2 ON
1960: 20 70 6c 69 6e 6b 28 63 69 64 29 3b 0a 40 0a 40 plink(cid);.@.@
1970: 20 2d 2d 20 45 76 65 6e 74 73 20 75 73 65 64 20 -- Events used
1980: 74 6f 20 67 65 6e 65 72 61 74 65 20 61 20 74 69 to generate a ti
1990: 6d 65 6c 69 6e 65 0a 40 20 2d 2d 0a 40 20 43 52 meline.@ --.@ CR
19a0: 45 41 54 45 20 54 41 42 4c 45 20 65 76 65 6e 74 EATE TABLE event
19b0: 28 0a 40 20 20 20 74 79 70 65 20 54 45 58 54 2c (.@ type TEXT,
19c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
19d0: 20 20 20 20 20 20 2d 2d 20 54 79 70 65 20 6f 66 -- Type of
19e0: 20 65 76 65 6e 74 0a 40 20 20 20 6d 74 69 6d 65 event.@ mtime
19f0: 20 44 41 54 45 54 49 4d 45 2c 20 20 20 20 20 20 DATETIME,
1a00: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 44 61 -- Da
1a10: 74 65 20 61 6e 64 20 74 69 6d 65 20 77 68 65 6e te and time when
1a20: 20 74 68 65 20 65 76 65 6e 74 20 6f 63 63 75 72 the event occur
1a30: 73 0a 40 20 20 20 6f 62 6a 69 64 20 49 4e 54 45 s.@ objid INTE
1a40: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
1a50: 20 20 20 20 20 20 2d 2d 20 41 73 73 6f 63 69 61 -- Associa
1a60: 74 65 64 20 72 65 63 6f 72 64 20 49 44 0a 40 20 ted record ID.@
1a70: 20 20 75 69 64 20 49 4e 54 45 47 45 52 20 52 45 uid INTEGER RE
1a80: 46 45 52 45 4e 43 45 53 20 75 73 65 72 2c 20 20 FERENCES user,
1a90: 20 20 2d 2d 20 55 73 65 72 20 77 68 6f 20 63 61 -- User who ca
1aa0: 75 73 65 64 20 74 68 65 20 65 76 65 6e 74 0a 40 used the event.@
1ab0: 20 20 20 62 67 63 6f 6c 6f 72 20 54 45 58 54 2c bgcolor TEXT,
1ac0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1ad0: 20 20 20 2d 2d 20 43 6f 6c 6f 72 20 73 65 74 20 -- Color set
1ae0: 62 79 20 27 62 67 63 6f 6c 6f 72 27 20 70 72 6f by 'bgcolor' pro
1af0: 70 65 72 74 79 0a 40 20 20 20 62 72 62 67 63 6f perty.@ brbgco
1b00: 6c 6f 72 20 54 45 58 54 2c 20 20 20 20 20 20 20 lor TEXT,
1b10: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 43 6f 6c -- Col
1b20: 6f 72 20 73 65 74 20 62 79 20 27 62 72 2d 62 67 or set by 'br-bg
1b30: 63 6f 6c 6f 72 27 20 70 72 6f 70 65 72 74 79 0a color' property.
1b40: 40 20 20 20 65 75 73 65 72 20 54 45 58 54 2c 20 @ euser TEXT,
1b50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1b60: 20 20 20 20 2d 2d 20 55 73 65 72 20 73 65 74 20 -- User set
1b70: 62 79 20 27 75 73 65 72 27 20 70 72 6f 70 65 72 by 'user' proper
1b80: 74 79 0a 40 20 20 20 75 73 65 72 20 54 45 58 54 ty.@ user TEXT
1b90: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
1ba0: 20 20 20 20 20 20 20 2d 2d 20 4e 61 6d 65 20 6f -- Name o
1bb0: 66 20 74 68 65 20 75 73 65 72 0a 40 20 20 20 65 f the user.@ e
1bc0: 63 6f 6d 6d 65 6e 74 20 54 45 58 54 2c 20 20 20 comment TEXT,
1bd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
1be0: 2d 20 43 6f 6d 6d 65 6e 74 20 73 65 74 20 62 79 - Comment set by
1bf0: 20 27 63 6f 6d 6d 65 6e 74 27 20 70 72 6f 70 65 'comment' prope
1c00: 72 74 79 0a 40 20 20 20 63 6f 6d 6d 65 6e 74 20 rty.@ comment
1c10: 54 45 58 54 20 20 20 20 20 20 20 20 20 20 20 20 TEXT
1c20: 20 20 20 20 20 20 20 20 2d 2d 20 43 6f 6d 6d 65 -- Comme
1c30: 6e 74 20 64 65 73 63 72 69 62 69 6e 67 20 74 68 nt describing th
1c40: 65 20 65 76 65 6e 74 0a 40 20 29 3b 0a 40 20 43 e event.@ );.@ C
1c50: 52 45 41 54 45 20 49 4e 44 45 58 20 65 76 65 6e REATE INDEX even
1c60: 74 5f 69 31 20 4f 4e 20 65 76 65 6e 74 28 6d 74 t_i1 ON event(mt
1c70: 69 6d 65 29 3b 0a 40 0a 40 20 2d 2d 20 41 20 72 ime);.@.@ -- A r
1c80: 65 63 6f 72 64 20 6f 66 20 70 68 61 6e 74 6f 6d ecord of phantom
1c90: 73 2e 20 20 41 20 70 68 61 6e 74 6f 6d 20 69 73 s. A phantom is
1ca0: 20 61 20 72 65 63 6f 72 64 20 66 6f 72 20 77 68 a record for wh
1cb0: 69 63 68 20 77 65 20 6b 6e 6f 77 20 74 68 65 0a ich we know the.
1cc0: 40 20 2d 2d 20 55 55 49 44 20 62 75 74 20 77 65 @ -- UUID but we
1cd0: 20 64 6f 20 6e 6f 74 20 28 79 65 74 29 20 6b 6e do not (yet) kn
1ce0: 6f 77 20 74 68 65 20 66 69 6c 65 20 63 6f 6e 74 ow the file cont
1cf0: 65 6e 74 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 ent..@ --.@ CREA
1d00: 54 45 20 54 41 42 4c 45 20 70 68 61 6e 74 6f 6d TE TABLE phantom
1d10: 28 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 (.@ rid INTEGE
1d20: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20 20 R PRIMARY KEY
1d30: 20 20 20 20 20 20 2d 2d 20 52 65 63 6f 72 64 20 -- Record
1d40: 49 44 20 6f 66 20 74 68 65 20 70 68 61 6e 74 6f ID of the phanto
1d50: 6d 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 55 6e m.@ );.@.@ -- Un
1d60: 63 6c 75 73 74 65 72 65 64 20 72 65 63 6f 72 64 clustered record
1d70: 73 2e 20 20 41 6e 20 75 6e 63 6c 75 73 74 65 72 s. An uncluster
1d80: 65 64 20 72 65 63 6f 72 64 20 69 73 20 61 20 72 ed record is a r
1d90: 65 63 6f 72 64 20 28 69 6e 63 6c 75 64 69 6e 67 ecord (including
1da0: 0a 40 20 2d 2d 20 61 20 63 6c 75 73 74 65 72 20 .@ -- a cluster
1db0: 72 65 63 6f 72 64 73 20 74 68 65 6d 73 65 6c 76 records themselv
1dc0: 65 73 29 20 74 68 61 74 20 69 73 20 6e 6f 74 20 es) that is not
1dd0: 6d 65 6e 74 69 6f 6e 65 64 20 62 79 20 73 6f 6d mentioned by som
1de0: 65 20 6f 74 68 65 72 0a 40 20 2d 2d 20 63 6c 75 e other.@ -- clu
1df0: 73 74 65 72 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 ster..@ --.@ --
1e00: 50 68 61 6e 74 6f 6d 73 20 61 72 65 20 75 73 75 Phantoms are usu
1e10: 61 6c 6c 79 20 69 6e 63 6c 75 64 65 64 20 69 6e ally included in
1e20: 20 74 68 65 20 75 6e 63 6c 75 73 74 65 72 65 64 the unclustered
1e30: 20 74 61 62 6c 65 2e 20 20 41 20 6e 65 77 20 63 table. A new c
1e40: 6c 75 73 74 65 72 0a 40 20 2d 2d 20 77 69 6c 6c luster.@ -- will
1e50: 20 6e 65 76 65 72 20 62 65 20 63 72 65 61 74 65 never be create
1e60: 64 20 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 20 d that contains
1e70: 61 20 70 68 61 6e 74 6f 6d 2e 20 20 42 75 74 20 a phantom. But
1e80: 61 6e 6f 74 68 65 72 20 72 65 70 6f 73 69 74 6f another reposito
1e90: 72 79 0a 40 20 2d 2d 20 6d 69 67 68 74 20 73 65 ry.@ -- might se
1ea0: 6e 64 20 75 73 20 61 20 63 6c 75 73 74 65 72 20 nd us a cluster
1eb0: 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 20 65 6e that contains en
1ec0: 74 72 69 65 73 20 74 68 61 74 20 61 72 65 20 70 tries that are p
1ed0: 68 61 6e 74 6f 6d 73 20 74 6f 0a 40 20 2d 2d 20 hantoms to.@ --
1ee0: 75 73 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 us..@ --.@ CREAT
1ef0: 45 20 54 41 42 4c 45 20 75 6e 63 6c 75 73 74 65 E TABLE uncluste
1f00: 72 65 64 28 0a 40 20 20 20 72 69 64 20 49 4e 54 red(.@ rid INT
1f10: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
1f20: 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65 63 6f -- Reco
1f30: 72 64 20 49 44 20 6f 66 20 74 68 65 20 75 6e 63 rd ID of the unc
1f40: 6c 75 73 74 65 72 65 64 20 66 69 6c 65 0a 40 20 lustered file.@
1f50: 29 3b 0a 40 0a 40 20 2d 2d 20 52 65 63 6f 72 64 );.@.@ -- Record
1f60: 73 20 77 68 69 63 68 20 68 61 76 65 20 6e 65 76 s which have nev
1f70: 65 72 20 62 65 65 6e 20 70 75 73 68 65 64 20 74 er been pushed t
1f80: 6f 20 61 6e 6f 74 68 65 72 20 73 65 72 76 65 72 o another server
1f90: 2e 20 20 54 68 69 73 20 69 73 0a 40 20 2d 2d 20 . This is.@ --
1fa0: 75 73 65 64 20 74 6f 20 72 65 64 75 63 65 20 70 used to reduce p
1fb0: 75 73 68 20 6f 70 65 72 61 74 69 6f 6e 73 20 74 ush operations t
1fc0: 6f 20 61 20 73 69 6e 67 6c 65 20 48 54 54 50 20 o a single HTTP
1fd0: 72 65 71 75 65 73 74 20 69 6e 20 74 68 65 0a 40 request in the.@
1fe0: 20 2d 2d 20 63 6f 6d 6d 6f 6e 20 63 61 73 65 20 -- common case
1ff0: 77 68 65 6e 20 6f 6e 65 20 72 65 70 6f 73 69 74 when one reposit
2000: 6f 72 79 20 6f 6e 6c 79 20 74 61 6c 6b 73 20 74 ory only talks t
2010: 6f 20 61 20 73 69 6e 67 6c 65 20 73 65 72 76 65 o a single serve
2020: 72 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 r..@ --.@ CREATE
2030: 20 54 41 42 4c 45 20 75 6e 73 65 6e 74 28 0a 40 TABLE unsent(.@
2040: 20 20 20 72 69 64 20 49 4e 54 45 47 45 52 20 50 rid INTEGER P
2050: 52 49 4d 41 52 59 20 4b 45 59 20 20 20 20 20 20 RIMARY KEY
2060: 20 20 20 2d 2d 20 52 65 63 6f 72 64 20 49 44 20 -- Record ID
2070: 6f 66 20 74 68 65 20 70 68 61 6e 74 6f 6d 0a 40 of the phantom.@
2080: 20 29 3b 0a 40 0a 40 20 2d 2d 20 45 61 63 68 20 );.@.@ -- Each
2090: 62 61 73 65 6c 69 6e 65 20 6f 72 20 6d 61 6e 69 baseline or mani
20a0: 66 65 73 74 20 63 61 6e 20 68 61 76 65 20 6f 6e fest can have on
20b0: 65 20 6f 72 20 6d 6f 72 65 20 74 61 67 73 2e 20 e or more tags.
20c0: 20 41 20 74 61 67 0a 40 20 2d 2d 20 69 73 20 64 A tag.@ -- is d
20d0: 65 66 69 6e 65 64 20 62 79 20 61 20 72 6f 77 20 efined by a row
20e0: 69 6e 20 74 68 65 20 6e 65 78 74 20 74 61 62 6c in the next tabl
20f0: 65 2e 0a 40 20 2d 2d 20 0a 40 20 2d 2d 20 57 69 e..@ -- .@ -- Wi
2100: 6b 69 20 70 61 67 65 73 20 61 72 65 20 74 61 67 ki pages are tag
2110: 67 65 64 20 77 69 74 68 20 22 77 69 6b 69 2d 4e ged with "wiki-N
2120: 41 4d 45 22 20 77 68 65 72 65 20 4e 41 4d 45 20 AME" where NAME
2130: 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 0a 40 is the name of.@
2140: 20 2d 2d 20 74 68 65 20 77 69 6b 69 20 70 61 67 -- the wiki pag
2150: 65 2e 20 20 54 69 63 6b 65 74 73 20 63 68 61 6e e. Tickets chan
2160: 67 65 73 20 61 72 65 20 74 61 67 67 65 64 20 77 ges are tagged w
2170: 69 74 68 20 22 74 69 63 6b 65 74 2d 55 55 49 44 ith "ticket-UUID
2180: 22 20 77 68 65 72 65 20 0a 40 20 2d 2d 20 55 55 " where .@ -- UU
2190: 49 44 20 69 73 20 74 68 65 20 69 6e 64 65 6e 74 ID is the indent
21a0: 69 66 69 65 72 20 6f 66 20 74 68 65 20 74 69 63 ifier of the tic
21b0: 6b 65 74 2e 20 20 54 61 67 73 20 75 73 65 64 20 ket. Tags used
21c0: 74 6f 20 61 73 73 69 67 6e 20 73 79 6d 62 6f 6c to assign symbol
21d0: 69 63 0a 40 20 2d 2d 20 6e 61 6d 65 73 20 74 6f ic.@ -- names to
21e0: 20 62 61 73 65 6c 69 6e 65 73 20 61 72 65 20 62 baselines are b
21f0: 72 61 6e 63 68 65 73 20 61 72 65 20 6f 66 20 74 ranches are of t
2200: 68 65 20 66 6f 72 6d 20 22 73 79 6d 2d 4e 41 4d he form "sym-NAM
2210: 45 22 20 77 68 65 72 65 0a 40 20 2d 2d 20 4e 41 E" where.@ -- NA
2220: 4d 45 20 69 73 20 74 68 65 20 73 79 6d 62 6f 6c ME is the symbol
2230: 69 63 20 6e 61 6d 65 2e 0a 40 20 2d 2d 0a 40 20 ic name..@ --.@
2240: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 61 67 CREATE TABLE tag
2250: 28 0a 40 20 20 20 74 61 67 69 64 20 49 4e 54 45 (.@ tagid INTE
2260: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
2270: 20 20 20 20 20 20 20 2d 2d 20 4e 75 6d 65 72 69 -- Numeri
2280: 63 20 74 61 67 20 49 44 0a 40 20 20 20 74 61 67 c tag ID.@ tag
2290: 6e 61 6d 65 20 54 45 58 54 20 55 4e 49 51 55 45 name TEXT UNIQUE
22a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
22b0: 20 54 61 67 20 6e 61 6d 65 2e 0a 40 20 29 3b 0a Tag name..@ );.
22c0: 40 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 @ INSERT INTO ta
22d0: 67 20 56 41 4c 55 45 53 28 31 2c 20 27 62 67 63 g VALUES(1, 'bgc
22e0: 6f 6c 6f 72 27 29 3b 20 20 20 20 20 20 20 20 20 olor');
22f0: 2d 2d 20 54 41 47 5f 42 47 43 4f 4c 4f 52 0a 40 -- TAG_BGCOLOR.@
2300: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 67 INSERT INTO tag
2310: 20 56 41 4c 55 45 53 28 32 2c 20 27 63 6f 6d 6d VALUES(2, 'comm
2320: 65 6e 74 27 29 3b 20 20 20 20 20 20 20 20 20 2d ent'); -
2330: 2d 20 54 41 47 5f 43 4f 4d 4d 45 4e 54 0a 40 20 - TAG_COMMENT.@
2340: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 67 20 INSERT INTO tag
2350: 56 41 4c 55 45 53 28 33 2c 20 27 75 73 65 72 27 VALUES(3, 'user'
2360: 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d ); --
2370: 20 54 41 47 5f 55 53 45 52 0a 40 20 49 4e 53 45 TAG_USER.@ INSE
2380: 52 54 20 49 4e 54 4f 20 74 61 67 20 56 41 4c 55 RT INTO tag VALU
2390: 45 53 28 34 2c 20 27 68 69 64 64 65 6e 27 29 3b ES(4, 'hidden');
23a0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 41 47 -- TAG
23b0: 5f 48 49 44 44 45 4e 0a 40 0a 40 20 2d 2d 20 41 _HIDDEN.@.@ -- A
23c0: 73 73 69 67 6e 6d 65 6e 74 73 20 6f 66 20 74 61 ssignments of ta
23d0: 67 73 20 74 6f 20 62 61 73 65 6c 69 6e 65 73 2e gs to baselines.
23e0: 20 20 4e 6f 74 65 20 74 68 61 74 20 77 65 20 61 Note that we a
23f0: 6c 6c 6f 77 20 74 61 67 73 20 74 6f 0a 40 20 2d llow tags to.@ -
2400: 2d 20 68 61 76 65 20 76 61 6c 75 65 73 20 61 73 - have values as
2410: 73 69 67 6e 65 64 20 74 6f 20 74 68 65 6d 2e 20 signed to them.
2420: 20 53 6f 20 77 65 20 61 72 65 20 6e 6f 74 20 72 So we are not r
2430: 65 61 6c 6c 79 20 64 65 61 6c 69 6e 67 20 77 69 eally dealing wi
2440: 74 68 0a 40 20 2d 2d 20 74 61 67 73 20 68 65 72 th.@ -- tags her
2450: 65 2e 20 20 54 68 65 73 65 20 61 72 65 20 72 65 e. These are re
2460: 61 6c 6c 79 20 70 72 6f 70 65 72 74 69 65 73 2e ally properties.
2470: 20 20 42 75 74 20 77 65 20 61 72 65 20 67 6f 69 But we are goi
2480: 6e 67 20 74 6f 0a 40 20 2d 2d 20 6b 65 65 70 20 ng to.@ -- keep
2490: 63 61 6c 6c 69 6e 67 20 74 68 65 6d 20 74 61 67 calling them tag
24a0: 73 20 62 65 63 61 75 73 65 20 69 6e 20 6d 61 6e s because in man
24b0: 79 20 63 61 73 65 73 20 74 68 65 20 76 61 6c 75 y cases the valu
24c0: 65 20 69 73 20 69 67 6e 6f 72 65 64 2e 0a 40 20 e is ignored..@
24d0: 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c --.@ CREATE TABL
24e0: 45 20 74 61 67 78 72 65 66 28 0a 40 20 20 20 74 E tagxref(.@ t
24f0: 61 67 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 agid INTEGER REF
2500: 45 52 45 4e 43 45 53 20 74 61 67 2c 20 20 20 2d ERENCES tag, -
2510: 2d 20 54 68 65 20 74 61 67 20 74 68 61 74 20 61 - The tag that a
2520: 64 64 65 64 20 6f 72 20 72 65 6d 6f 76 65 64 0a dded or removed.
2530: 40 20 20 20 74 61 67 74 79 70 65 20 49 4e 54 45 @ tagtype INTE
2540: 47 45 52 2c 20 20 20 20 20 20 20 20 20 20 20 20 GER,
2550: 20 20 20 20 2d 2d 20 30 3a 63 61 6e 63 65 6c 20 -- 0:cancel
2560: 20 31 3a 73 69 6e 67 6c 65 20 20 32 3a 62 72 61 1:single 2:bra
2570: 6e 63 68 0a 40 20 20 20 73 72 63 69 64 20 49 4e nch.@ srcid IN
2580: 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 TEGER REFERENCES
2590: 20 62 6c 6f 62 2c 20 20 2d 2d 20 4f 72 69 67 69 blob, -- Origi
25a0: 6e 20 6f 66 20 74 68 65 20 74 61 67 2e 20 30 20 n of the tag. 0
25b0: 66 6f 72 20 70 72 6f 70 61 67 61 74 65 64 20 74 for propagated t
25c0: 61 67 73 0a 40 20 20 20 76 61 6c 75 65 20 54 45 ags.@ value TE
25d0: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
25e0: 20 20 20 20 20 20 20 20 2d 2d 20 56 61 6c 75 65 -- Value
25f0: 20 6f 66 20 74 68 65 20 74 61 67 2e 20 20 4d 69 of the tag. Mi
2600: 67 68 74 20 62 65 20 4e 55 4c 4c 2e 0a 40 20 20 ght be NULL..@
2610: 20 6d 74 69 6d 65 20 54 49 4d 45 53 54 41 4d 50 mtime TIMESTAMP
2620: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
2630: 20 2d 2d 20 54 69 6d 65 20 6f 66 20 61 64 64 69 -- Time of addi
2640: 74 69 6f 6e 20 6f 72 20 72 65 6d 6f 76 61 6c 0a tion or removal.
2650: 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 52 20 @ rid INTEGER
2660: 52 45 46 45 52 45 4e 43 45 20 62 6c 6f 62 2c 20 REFERENCE blob,
2670: 20 20 20 20 2d 2d 20 42 61 73 65 6c 69 6e 65 20 -- Baseline
2680: 74 68 61 74 20 74 61 67 20 61 64 64 65 64 2f 72 that tag added/r
2690: 65 6d 6f 76 65 64 20 66 72 6f 6d 0a 40 20 20 20 emoved from.@
26a0: 55 4e 49 51 55 45 28 72 69 64 2c 20 74 61 67 69 UNIQUE(rid, tagi
26b0: 64 29 0a 40 20 29 3b 0a 40 20 43 52 45 41 54 45 d).@ );.@ CREATE
26c0: 20 49 4e 44 45 58 20 74 61 67 78 72 65 66 5f 69 INDEX tagxref_i
26d0: 31 20 4f 4e 20 74 61 67 78 72 65 66 28 74 61 67 1 ON tagxref(tag
26e0: 69 64 2c 20 6d 74 69 6d 65 29 3b 0a 3b 0a 0a 2f id, mtime);.;../
26f0: 2a 0a 2a 2a 20 50 72 65 64 65 66 69 6e 65 64 20 *.** Predefined
2700: 74 61 67 69 64 20 76 61 6c 75 65 73 0a 2a 2f 0a tagid values.*/.
2710: 23 69 66 20 49 4e 54 45 52 46 41 43 45 0a 23 20 #if INTERFACE.#
2720: 64 65 66 69 6e 65 20 54 41 47 5f 42 47 43 4f 4c define TAG_BGCOL
2730: 4f 52 20 20 20 20 31 0a 23 20 64 65 66 69 6e 65 OR 1.# define
2740: 20 54 41 47 5f 43 4f 4d 4d 45 4e 54 20 20 20 20 TAG_COMMENT
2750: 32 0a 23 20 64 65 66 69 6e 65 20 54 41 47 5f 55 2.# define TAG_U
2760: 53 45 52 20 20 20 20 20 20 20 33 0a 23 20 64 65 SER 3.# de
2770: 66 69 6e 65 20 54 41 47 5f 48 49 44 44 45 4e 20 fine TAG_HIDDEN
2780: 20 20 20 20 34 0a 23 65 6e 64 69 66 0a 0a 2f 2a 4.#endif../*
2790: 0a 2a 2a 20 54 68 65 20 73 63 68 65 6d 61 20 66 .** The schema f
27a0: 6f 72 20 74 68 65 20 6c 6f 63 61 74 65 20 46 4f or the locate FO
27b0: 53 53 49 4c 20 64 61 74 61 62 61 73 65 20 66 69 SSIL database fi
27c0: 6c 65 20 66 6f 75 6e 64 20 61 74 20 74 68 65 20 le found at the
27d0: 72 6f 6f 74 0a 2a 2a 20 6f 66 20 76 65 72 79 20 root.** of very
27e0: 63 68 65 63 6b 2d 6f 75 74 2e 20 20 54 68 69 73 check-out. This
27f0: 20 64 61 74 61 62 61 73 65 20 63 6f 6e 74 61 69 database contai
2800: 6e 73 20 74 68 65 20 63 6f 6d 70 6c 65 74 65 20 ns the complete
2810: 73 74 61 74 65 20 6f 66 0a 2a 2a 20 74 68 65 20 state of.** the
2820: 63 68 65 63 6b 6f 75 74 2e 0a 2a 2f 0a 63 6f 6e checkout..*/.con
2830: 73 74 20 63 68 61 72 20 7a 4c 6f 63 61 6c 53 63 st char zLocalSc
2840: 68 65 6d 61 5b 5d 20 3d 0a 40 20 2d 2d 20 54 68 hema[] =.@ -- Th
2850: 65 20 56 56 41 52 20 74 61 62 6c 65 20 68 6f 6c e VVAR table hol
2860: 64 73 20 6d 69 73 63 65 6c 6c 61 6e 6f 75 73 20 ds miscellanous
2870: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 information abou
2880: 74 20 74 68 65 20 6c 6f 63 61 6c 20 64 61 74 61 t the local data
2890: 62 61 73 65 0a 40 20 2d 2d 20 69 6e 20 74 68 65 base.@ -- in the
28a0: 20 66 6f 72 6d 20 6f 66 20 6e 61 6d 65 2d 76 61 form of name-va
28b0: 6c 75 65 20 70 61 69 72 73 2e 20 20 54 68 69 73 lue pairs. This
28c0: 20 69 73 20 73 69 6d 69 6c 61 72 20 74 6f 20 74 is similar to t
28d0: 68 65 20 56 41 52 20 74 61 62 6c 65 0a 40 20 2d he VAR table.@ -
28e0: 2d 20 74 61 62 6c 65 20 69 6e 20 74 68 65 20 72 - table in the r
28f0: 65 70 6f 73 69 74 6f 72 79 20 65 78 63 65 70 74 epository except
2900: 20 74 68 61 74 20 74 68 69 73 20 74 61 62 6c 65 that this table
2910: 20 68 6f 6c 64 73 20 69 6e 66 6f 72 6d 61 74 69 holds informati
2920: 6f 6e 20 74 68 61 74 0a 40 20 2d 2d 20 69 73 20 on that.@ -- is
2930: 73 70 65 63 69 66 69 63 20 74 6f 20 74 68 65 20 specific to the
2940: 6c 6f 63 61 6c 20 63 68 65 63 6b 6f 75 74 2e 0a local checkout..
2950: 40 20 2d 2d 0a 40 20 2d 2d 20 49 6d 70 6f 72 74 @ --.@ -- Import
2960: 61 6e 74 20 56 61 72 69 61 62 6c 65 73 3a 0a 40 ant Variables:.@
2970: 20 2d 2d 0a 40 20 2d 2d 20 20 20 20 20 72 65 70 --.@ -- rep
2980: 6f 73 69 74 6f 72 79 20 20 20 20 20 20 20 20 46 ository F
2990: 75 6c 6c 20 70 61 74 68 6e 61 6d 65 20 6f 66 20 ull pathname of
29a0: 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 20 64 the repository d
29b0: 61 74 61 62 61 73 65 0a 40 20 2d 2d 20 20 20 20 atabase.@ --
29c0: 20 75 73 65 72 2d 69 64 20 20 20 20 20 20 20 20 user-id
29d0: 20 20 20 55 73 65 72 69 64 20 74 6f 20 75 73 65 Userid to use
29e0: 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 .@ --.@ CREATE T
29f0: 41 42 4c 45 20 76 76 61 72 28 0a 40 20 20 20 6e ABLE vvar(.@ n
2a00: 61 6d 65 20 54 45 58 54 20 50 52 49 4d 41 52 59 ame TEXT PRIMARY
2a10: 20 4b 45 59 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20 KEY NOT NULL,
2a20: 2d 2d 20 50 72 69 6d 61 72 79 20 6e 61 6d 65 20 -- Primary name
2a30: 6f 66 20 74 68 65 20 65 6e 74 72 79 0a 40 20 20 of the entry.@
2a40: 20 76 61 6c 75 65 20 43 4c 4f 42 2c 20 20 20 20 value CLOB,
2a50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a60: 20 20 2d 2d 20 43 6f 6e 74 65 6e 74 20 6f 66 20 -- Content of
2a70: 74 68 65 20 6e 61 6d 65 64 20 70 61 72 61 6d 65 the named parame
2a80: 74 65 72 0a 40 20 20 20 43 48 45 43 4b 28 20 74 ter.@ CHECK( t
2a90: 79 70 65 6f 66 28 6e 61 6d 65 29 3d 27 74 65 78 ypeof(name)='tex
2aa0: 74 27 20 41 4e 44 20 6c 65 6e 67 74 68 28 6e 61 t' AND length(na
2ab0: 6d 65 29 3e 3d 31 20 29 0a 40 20 29 3b 0a 40 0a me)>=1 ).@ );.@.
2ac0: 40 20 2d 2d 20 45 61 63 68 20 65 6e 74 72 79 20 @ -- Each entry
2ad0: 69 6e 20 74 68 65 20 76 66 69 6c 65 20 74 61 62 in the vfile tab
2ae0: 6c 65 20 72 65 70 72 65 73 65 6e 74 73 20 61 20 le represents a
2af0: 73 69 6e 67 6c 65 20 66 69 6c 65 20 6f 72 20 66 single file or f
2b00: 6f 6c 64 65 72 0a 40 20 2d 2d 20 74 68 61 74 20 older.@ -- that
2b10: 69 73 20 70 61 72 74 20 6f 66 20 61 20 76 65 72 is part of a ver
2b20: 73 69 6f 6e 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 sion..@ --.@ --
2b30: 54 68 65 20 66 69 6c 65 2e 72 69 64 20 66 69 65 The file.rid fie
2b40: 6c 64 20 69 73 20 30 20 66 6f 72 20 66 69 6c 65 ld is 0 for file
2b50: 73 20 6f 72 20 66 6f 6c 64 65 72 73 20 74 68 61 s or folders tha
2b60: 74 20 68 61 76 65 20 62 65 65 6e 0a 40 20 2d 2d t have been.@ --
2b70: 20 61 64 64 65 64 20 62 75 74 20 6e 6f 74 20 79 added but not y
2b80: 65 74 20 63 6f 6d 6d 69 74 74 65 64 2e 0a 40 20 et committed..@
2b90: 2d 2d 0a 40 20 2d 2d 20 56 66 69 6c 65 2e 63 68 --.@ -- Vfile.ch
2ba0: 6e 67 65 64 20 69 73 20 30 20 66 6f 72 20 75 6e nged is 0 for un
2bb0: 6d 6f 64 69 66 69 65 64 20 66 69 6c 65 73 2c 20 modified files,
2bc0: 31 20 66 6f 72 20 66 69 6c 65 73 20 74 68 61 74 1 for files that
2bd0: 20 68 61 76 65 0a 40 20 2d 2d 20 62 65 65 6e 20 have.@ -- been
2be0: 65 64 69 74 65 64 20 6f 72 20 77 68 69 63 68 20 edited or which
2bf0: 68 61 76 65 20 62 65 65 6e 20 73 75 62 6a 65 63 have been subjec
2c00: 74 65 64 20 74 6f 20 61 20 33 2d 77 61 79 20 6d ted to a 3-way m
2c10: 65 72 67 65 2e 20 20 0a 40 20 2d 2d 20 56 66 69 erge. .@ -- Vfi
2c20: 6c 65 2e 63 68 6e 67 65 64 20 69 73 20 32 20 69 le.chnged is 2 i
2c30: 66 20 74 68 65 20 66 69 6c 65 20 68 61 73 20 62 f the file has b
2c40: 65 65 6e 20 72 65 70 6c 61 63 65 64 20 66 72 6f een replaced fro
2c50: 6d 20 61 20 64 69 66 66 65 72 65 6e 74 0a 40 20 m a different.@
2c60: 2d 2d 20 76 65 72 73 69 6f 6e 20 62 79 20 74 68 -- version by th
2c70: 65 20 6d 65 72 67 65 20 61 6e 64 20 33 20 69 66 e merge and 3 if
2c80: 20 74 68 65 20 66 69 6c 65 20 68 61 73 20 62 65 the file has be
2c90: 65 6e 20 61 64 64 65 64 20 62 79 20 61 20 6d 65 en added by a me
2ca0: 72 67 65 2e 0a 40 20 2d 2d 20 54 68 65 20 64 69 rge..@ -- The di
2cb0: 66 66 65 72 65 6e 63 65 20 62 65 74 77 65 65 6e fference between
2cc0: 20 76 66 69 6c 65 2e 63 68 6e 67 65 64 3d 3d 32 vfile.chnged==2
2cd0: 20 61 6e 64 20 61 20 72 65 67 75 6c 61 72 20 61 and a regular a
2ce0: 64 64 20 69 73 20 74 68 61 74 0a 40 20 2d 2d 20 dd is that.@ --
2cf0: 77 69 74 68 20 76 66 69 6c 65 2e 63 68 6e 67 65 with vfile.chnge
2d00: 64 3d 3d 32 20 77 65 20 6b 6e 6f 77 20 74 68 61 d==2 we know tha
2d10: 74 20 74 68 65 20 63 75 72 72 65 6e 74 20 76 65 t the current ve
2d20: 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 66 69 6c rsion of the fil
2d30: 65 0a 40 20 2d 2d 20 69 73 20 61 6c 72 65 61 64 e.@ -- is alread
2d40: 79 20 69 6e 20 74 68 65 20 72 65 70 6f 73 69 74 y in the reposit
2d50: 6f 72 79 2e 0a 40 20 2d 2d 20 0a 40 20 2d 2d 0a ory..@ -- .@ --.
2d60: 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 76 @ CREATE TABLE v
2d70: 66 69 6c 65 28 0a 40 20 20 20 69 64 20 49 4e 54 file(.@ id INT
2d80: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
2d90: 2c 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 49 , -- I
2da0: 44 20 6f 66 20 74 68 65 20 63 68 65 63 6b 65 64 D of the checked
2db0: 20 6f 75 74 20 66 69 6c 65 0a 40 20 20 20 76 69 out file.@ vi
2dc0: 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 d INTEGER REFERE
2dd0: 4e 43 45 53 20 62 6c 6f 62 2c 20 20 20 20 20 20 NCES blob,
2de0: 2d 2d 20 54 68 65 20 62 61 73 65 6c 69 6e 65 20 -- The baseline
2df0: 74 68 69 73 20 66 69 6c 65 20 69 73 20 70 61 72 this file is par
2e00: 74 20 6f 66 2e 0a 40 20 20 20 63 68 6e 67 65 64 t of..@ chnged
2e10: 20 49 4e 54 20 44 45 46 41 55 4c 54 20 30 2c 20 INT DEFAULT 0,
2e20: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 30 -- 0
2e30: 3a 75 6e 63 68 6e 67 65 64 20 31 3a 65 64 69 74 :unchnged 1:edit
2e40: 65 64 20 32 3a 6d 2d 63 68 6e 67 20 33 3a 6d 2d ed 2:m-chng 3:m-
2e50: 61 64 64 0a 40 20 20 20 64 65 6c 65 74 65 64 20 add.@ deleted
2e60: 42 4f 4f 4c 45 41 4e 20 44 45 46 41 55 4c 54 20 BOOLEAN DEFAULT
2e70: 30 2c 20 20 20 20 20 20 20 20 2d 2d 20 54 72 75 0, -- Tru
2e80: 65 20 69 66 20 64 65 6c 65 74 65 64 20 0a 40 20 e if deleted .@
2e90: 20 20 72 69 64 20 49 4e 54 45 47 45 52 2c 20 20 rid INTEGER,
2ea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2eb0: 20 20 20 20 2d 2d 20 4f 72 69 67 69 6e 61 6c 6c -- Originall
2ec0: 79 20 66 72 6f 6d 20 74 68 69 73 20 72 65 70 6f y from this repo
2ed0: 73 69 74 6f 72 79 20 72 65 63 6f 72 64 0a 40 20 sitory record.@
2ee0: 20 20 6d 72 69 64 20 49 4e 54 45 47 45 52 2c 20 mrid INTEGER,
2ef0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2f00: 20 20 20 20 2d 2d 20 42 61 73 65 64 20 6f 6e 20 -- Based on
2f10: 74 68 69 73 20 72 65 63 6f 72 64 20 64 75 65 20 this record due
2f20: 74 6f 20 61 20 6d 65 72 67 65 0a 40 20 20 20 70 to a merge.@ p
2f30: 61 74 68 6e 61 6d 65 20 54 45 58 54 2c 20 20 20 athname TEXT,
2f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2f50: 20 2d 2d 20 46 75 6c 6c 20 70 61 74 68 6e 61 6d -- Full pathnam
2f60: 65 0a 40 20 20 20 55 4e 49 51 55 45 28 70 61 74 e.@ UNIQUE(pat
2f70: 68 6e 61 6d 65 2c 76 69 64 29 0a 40 20 29 3b 0a hname,vid).@ );.
2f80: 40 0a 40 20 2d 2d 20 54 68 69 73 20 74 61 62 6c @.@ -- This tabl
2f90: 65 20 68 6f 6c 64 73 20 61 20 72 65 63 6f 72 64 e holds a record
2fa0: 20 6f 66 20 75 6e 63 6f 6d 6d 69 74 74 65 64 20 of uncommitted
2fb0: 6d 65 72 67 65 73 20 69 6e 20 74 68 65 20 6c 6f merges in the lo
2fc0: 63 61 6c 0a 40 20 2d 2d 20 66 69 6c 65 20 74 72 cal.@ -- file tr
2fd0: 65 65 2e 20 20 49 66 20 61 20 56 46 49 4c 45 20 ee. If a VFILE
2fe0: 65 6e 74 72 79 20 77 69 74 68 20 69 64 20 68 61 entry with id ha
2ff0: 73 20 6d 65 72 67 65 64 20 77 69 74 68 20 61 6e s merged with an
3000: 6f 74 68 65 72 0a 40 20 2d 2d 20 72 65 63 6f 72 other.@ -- recor
3010: 64 2c 20 74 68 65 72 65 20 69 73 20 61 6e 20 65 d, there is an e
3020: 6e 74 72 79 20 69 6e 20 74 68 69 73 20 74 61 62 ntry in this tab
3030: 6c 65 20 77 69 74 68 20 28 69 64 2c 6d 65 72 67 le with (id,merg
3040: 65 29 20 77 68 65 72 65 0a 40 20 2d 2d 20 6d 65 e) where.@ -- me
3050: 72 67 65 20 69 73 20 74 68 65 20 52 45 43 4f 52 rge is the RECOR
3060: 44 20 74 61 62 6c 65 20 65 6e 74 72 79 20 74 68 D table entry th
3070: 61 74 20 74 68 65 20 66 69 6c 65 20 6d 65 72 67 at the file merg
3080: 65 64 20 61 67 61 69 6e 73 74 2e 0a 40 20 2d 2d ed against..@ --
3090: 20 41 6e 20 69 64 20 6f 66 20 30 20 68 65 72 65 An id of 0 here
30a0: 20 6d 65 61 6e 73 20 74 68 65 20 76 65 72 73 69 means the versi
30b0: 6f 6e 20 72 65 63 6f 72 64 20 69 74 73 65 6c 66 on record itself
30c0: 2e 0a 40 0a 40 20 43 52 45 41 54 45 20 54 41 42 ..@.@ CREATE TAB
30d0: 4c 45 20 76 6d 65 72 67 65 28 0a 40 20 20 20 69 LE vmerge(.@ i
30e0: 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 d INTEGER REFERE
30f0: 4e 43 45 53 20 76 66 69 6c 65 2c 20 20 20 20 20 NCES vfile,
3100: 20 2d 2d 20 56 46 49 4c 45 20 65 6e 74 72 79 20 -- VFILE entry
3110: 74 68 61 74 20 68 61 73 20 62 65 65 6e 20 6d 65 that has been me
3120: 72 67 65 64 0a 40 20 20 20 6d 65 72 67 65 20 49 rged.@ merge I
3130: 4e 54 45 47 45 52 2c 20 20 20 20 20 20 20 20 20 NTEGER,
3140: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4d 65 -- Me
3150: 72 67 65 64 20 77 69 74 68 20 74 68 69 73 20 72 rged with this r
3160: 65 63 6f 72 64 0a 40 20 20 20 55 4e 49 51 55 45 ecord.@ UNIQUE
3170: 28 69 64 2c 20 6d 65 72 67 65 29 0a 40 20 29 3b (id, merge).@ );
3180: 0a 40 20 20 20 0a 3b 0a .@ .;.