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 20 4e 4f 54 20 4e EXT UNIQUE NOT N
0b30: 55 4c 4c 2c 20 20 20 20 20 20 2d 2d 20 53 48 41 ULL, -- 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 2c 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 20 20 43 48 45 43 4b 28 20 6c 65 6e 67 74 68 CHECK( length
0bb0: 28 75 75 69 64 29 3d 3d 34 30 20 41 4e 44 20 72 (uuid)==40 AND r
0bc0: 69 64 3e 30 20 29 0a 40 20 29 3b 0a 40 20 43 52 id>0 ).@ );.@ CR
0bd0: 45 41 54 45 20 54 41 42 4c 45 20 64 65 6c 74 61 EATE TABLE delta
0be0: 28 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 (.@ rid INTEGE
0bf0: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 R PRIMARY KEY,
0c00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
0c10: 2d 20 52 65 63 6f 72 64 20 49 44 0a 40 20 20 20 - Record ID.@
0c20: 73 72 63 69 64 20 49 4e 54 45 47 45 52 20 4e 4f srcid INTEGER NO
0c30: 54 20 4e 55 4c 4c 20 52 45 46 45 52 45 4e 43 45 T NULL REFERENCE
0c40: 53 20 62 6c 6f 62 20 20 20 2d 2d 20 52 65 63 6f S blob -- Reco
0c50: 72 64 20 68 6f 6c 64 69 6e 67 20 73 6f 75 72 63 rd holding sourc
0c60: 65 20 64 6f 63 75 6d 65 6e 74 0a 40 20 29 3b 0a e document.@ );.
0c70: 40 20 43 52 45 41 54 45 20 49 4e 44 45 58 20 64 @ CREATE INDEX d
0c80: 65 6c 74 61 5f 69 31 20 4f 4e 20 64 65 6c 74 61 elta_i1 ON delta
0c90: 28 73 72 63 69 64 29 3b 0a 40 0a 40 20 2d 2d 20 (srcid);.@.@ --
0ca0: 57 68 65 6e 65 76 65 72 20 6e 65 77 20 62 6c 6f Whenever new blo
0cb0: 62 73 20 61 72 65 20 72 65 63 65 69 76 65 64 20 bs are received
0cc0: 69 6e 74 6f 20 74 68 65 20 72 65 70 6f 73 69 74 into the reposit
0cd0: 6f 72 79 2c 20 61 6e 20 65 6e 74 72 79 0a 40 20 ory, an entry.@
0ce0: 2d 2d 20 69 6e 20 74 68 69 73 20 74 61 62 6c 65 -- in this table
0cf0: 20 72 65 63 6f 72 64 73 20 74 68 65 20 73 6f 75 records the sou
0d00: 72 63 65 20 6f 66 20 74 68 65 20 62 6c 6f 62 2e rce of the blob.
0d10: 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 .@ --.@ CREATE T
0d20: 41 42 4c 45 20 72 63 76 66 72 6f 6d 28 0a 40 20 ABLE rcvfrom(.@
0d30: 20 20 72 63 76 69 64 20 49 4e 54 45 47 45 52 20 rcvid INTEGER
0d40: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 20 PRIMARY KEY,
0d50: 20 20 2d 2d 20 52 65 63 65 69 76 65 64 2d 46 72 -- Received-Fr
0d60: 6f 6d 20 49 44 0a 40 20 20 20 75 69 64 20 49 4e om ID.@ uid IN
0d70: 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 45 53 TEGER REFERENCES
0d80: 20 75 73 65 72 2c 20 20 20 20 2d 2d 20 55 73 65 user, -- Use
0d90: 72 20 6c 6f 67 69 6e 0a 40 20 20 20 6d 74 69 6d r login.@ mtim
0da0: 65 20 44 41 54 45 54 49 4d 45 2c 20 20 20 20 20 e DATETIME,
0db0: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 -- T
0dc0: 69 6d 65 20 6f 72 20 72 65 63 65 69 70 74 0a 40 ime or receipt.@
0dd0: 20 20 20 6e 6f 6e 63 65 20 54 45 58 54 20 55 4e nonce TEXT UN
0de0: 49 51 55 45 2c 20 20 20 20 20 20 20 20 20 20 20 IQUE,
0df0: 20 20 20 2d 2d 20 4e 6f 6e 63 65 20 75 73 65 64 -- Nonce used
0e00: 20 66 6f 72 20 6c 6f 67 69 6e 0a 40 20 20 20 69 for login.@ i
0e10: 70 61 64 64 72 20 54 45 58 54 20 20 20 20 20 20 paddr TEXT
0e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
0e30: 2d 20 52 65 6d 6f 74 65 20 49 50 20 61 64 64 72 - Remote IP addr
0e40: 65 73 73 2e 20 20 4e 55 4c 4c 20 66 6f 72 20 64 ess. NULL for d
0e50: 69 72 65 63 74 2e 0a 40 20 29 3b 0a 40 0a 40 20 irect..@ );.@.@
0e60: 2d 2d 20 49 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 -- Information a
0e70: 62 6f 75 74 20 75 73 65 72 73 0a 40 20 2d 2d 0a bout users.@ --.
0e80: 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 75 @ CREATE TABLE u
0e90: 73 65 72 28 0a 40 20 20 20 75 69 64 20 49 4e 54 ser(.@ uid INT
0ea0: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
0eb0: 2c 20 20 20 20 20 20 20 20 2d 2d 20 55 73 65 72 , -- User
0ec0: 20 49 44 0a 40 20 20 20 6c 6f 67 69 6e 20 54 45 ID.@ login TE
0ed0: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
0ee0: 20 20 20 20 20 20 20 20 2d 2d 20 6c 6f 67 69 6e -- login
0ef0: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 75 73 65 name of the use
0f00: 72 0a 40 20 20 20 70 77 20 54 45 58 54 2c 20 20 r.@ pw TEXT,
0f10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f20: 20 20 20 20 20 20 2d 2d 20 70 61 73 73 77 6f 72 -- passwor
0f30: 64 0a 40 20 20 20 63 61 70 20 54 45 58 54 2c 20 d.@ cap TEXT,
0f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f50: 20 20 20 20 20 20 2d 2d 20 43 61 70 61 62 69 6c -- Capabil
0f60: 69 74 69 65 73 20 6f 66 20 74 68 69 73 20 75 73 ities of this us
0f70: 65 72 0a 40 20 20 20 63 6f 6f 6b 69 65 20 54 45 er.@ cookie TE
0f80: 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 XT,
0f90: 20 20 20 20 20 20 20 2d 2d 20 57 57 57 20 6c 6f -- WWW lo
0fa0: 67 69 6e 20 63 6f 6f 6b 69 65 0a 40 20 20 20 69 gin cookie.@ i
0fb0: 70 61 64 64 72 20 54 45 58 54 2c 20 20 20 20 20 paddr TEXT,
0fc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
0fd0: 2d 20 49 50 20 61 64 64 72 65 73 73 20 66 6f 72 - IP address for
0fe0: 20 77 68 69 63 68 20 63 6f 6f 6b 69 65 20 69 73 which cookie is
0ff0: 20 76 61 6c 69 64 0a 40 20 20 20 63 65 78 70 69 valid.@ cexpi
1000: 72 65 20 44 41 54 45 54 49 4d 45 2c 20 20 20 20 re DATETIME,
1010: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 69 -- Ti
1020: 6d 65 20 77 68 65 6e 20 63 6f 6f 6b 69 65 20 65 me when cookie e
1030: 78 70 69 72 65 73 0a 40 20 20 20 69 6e 66 6f 20 xpires.@ info
1040: 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 20 20 TEXT,
1050: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 63 6f -- co
1060: 6e 74 61 63 74 20 69 6e 66 6f 72 6d 61 74 69 6f ntact informatio
1070: 6e 0a 40 20 20 20 70 68 6f 74 6f 20 42 4c 4f 42 n.@ photo BLOB
1080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1090: 20 20 20 20 20 20 2d 2d 20 4a 50 45 47 20 69 6d -- JPEG im
10a0: 61 67 65 20 6f 66 20 74 68 69 73 20 75 73 65 72 age of this user
10b0: 0a 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 54 68 65 .@ );.@.@ -- The
10c0: 20 56 41 52 20 74 61 62 6c 65 20 68 6f 6c 64 73 VAR table holds
10d0: 20 6d 69 73 63 65 6c 6c 61 6e 6f 75 73 20 69 6e miscellanous in
10e0: 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 formation about
10f0: 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a the repository..
1100: 40 20 2d 2d 20 69 6e 20 74 68 65 20 66 6f 72 6d @ -- in the form
1110: 20 6f 66 20 6e 61 6d 65 2d 76 61 6c 75 65 20 70 of name-value p
1120: 61 69 72 73 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 airs..@ --.@ CRE
1130: 41 54 45 20 54 41 42 4c 45 20 63 6f 6e 66 69 67 ATE TABLE config
1140: 28 0a 40 20 20 20 6e 61 6d 65 20 54 45 58 54 20 (.@ name TEXT
1150: 50 52 49 4d 41 52 59 20 4b 45 59 20 4e 4f 54 20 PRIMARY KEY NOT
1160: 4e 55 4c 4c 2c 20 20 2d 2d 20 50 72 69 6d 61 72 NULL, -- Primar
1170: 79 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 65 6e y name of the en
1180: 74 72 79 0a 40 20 20 20 76 61 6c 75 65 20 43 4c try.@ value CL
1190: 4f 42 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 OB,
11a0: 20 20 20 20 20 20 20 20 20 2d 2d 20 43 6f 6e 74 -- Cont
11b0: 65 6e 74 20 6f 66 20 74 68 65 20 6e 61 6d 65 64 ent of the named
11c0: 20 70 61 72 61 6d 65 74 65 72 0a 40 20 20 20 43 parameter.@ C
11d0: 48 45 43 4b 28 20 74 79 70 65 6f 66 28 6e 61 6d HECK( typeof(nam
11e0: 65 29 3d 27 74 65 78 74 27 20 41 4e 44 20 6c 65 e)='text' AND le
11f0: 6e 67 74 68 28 6e 61 6d 65 29 3e 3d 31 20 29 0a ngth(name)>=1 ).
1200: 40 20 29 3b 0a 40 0a 40 20 2d 2d 20 41 72 74 69 @ );.@.@ -- Arti
1210: 66 61 63 74 73 20 74 68 61 74 20 73 68 6f 75 6c facts that shoul
1220: 64 20 6e 6f 74 20 62 65 20 70 72 6f 63 65 73 73 d not be process
1230: 65 64 20 61 72 65 20 69 64 65 6e 74 69 66 69 65 ed are identifie
1240: 64 20 69 6e 20 74 68 65 0a 40 20 2d 2d 20 22 73 d in the.@ -- "s
1250: 68 75 6e 22 20 74 61 62 6c 65 2e 20 20 41 72 74 hun" table. Art
1260: 69 66 61 63 74 73 20 74 68 61 74 20 61 72 65 20 ifacts that are
1270: 63 6f 6e 74 72 6f 6c 2d 66 69 6c 65 20 66 6f 72 control-file for
1280: 67 65 72 69 65 73 20 6f 72 0a 40 20 2d 2d 20 73 geries or.@ -- s
1290: 70 61 6d 20 6f 72 20 61 72 74 69 66 61 63 74 73 pam or artifacts
12a0: 20 77 68 6f 73 65 20 63 6f 6e 74 65 6e 74 73 20 whose contents
12b0: 76 69 6f 6c 61 74 65 20 61 64 6d 69 6e 69 73 74 violate administ
12c0: 72 61 74 69 76 65 20 70 6f 6c 69 63 79 0a 40 20 rative policy.@
12d0: 2d 2d 20 63 61 6e 20 62 65 20 73 68 75 6e 6e 65 -- can be shunne
12e0: 64 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 70 72 d in order to pr
12f0: 65 76 65 6e 74 20 74 68 65 6d 20 66 72 6f 6d 20 event them from
1300: 63 6f 6e 74 61 6d 69 6e 61 74 69 6e 67 0a 40 20 contaminating.@
1310: 2d 2d 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 -- the repositor
1320: 79 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 53 68 75 y..@ --.@ -- Shu
1330: 6e 6e 65 64 20 61 72 74 69 66 61 63 74 73 20 64 nned artifacts d
1340: 6f 20 6e 6f 74 20 65 78 69 73 74 20 69 6e 20 74 o not exist in t
1350: 68 65 20 62 6c 6f 62 20 74 61 62 6c 65 2e 20 20 he blob table.
1360: 48 65 6e 63 65 20 74 68 65 79 0a 40 20 2d 2d 20 Hence they.@ --
1370: 68 61 76 65 20 6e 6f 74 20 61 72 74 69 66 61 63 have not artifac
1380: 74 20 49 44 20 28 72 69 64 29 20 61 6e 64 20 77 t ID (rid) and w
1390: 65 20 74 68 75 73 20 6d 75 73 74 20 73 74 6f 72 e thus must stor
13a0: 65 20 74 68 65 69 72 20 66 75 6c 6c 0a 40 20 2d e their full.@ -
13b0: 2d 20 55 55 49 44 2e 0a 40 20 2d 2d 0a 40 20 43 - UUID..@ --.@ C
13c0: 52 45 41 54 45 20 54 41 42 4c 45 20 73 68 75 6e REATE TABLE shun
13d0: 28 75 75 69 64 20 55 4e 49 51 55 45 29 3b 0a 40 (uuid UNIQUE);.@
13e0: 0a 40 20 2d 2d 20 41 72 74 69 66 61 63 74 73 20 .@ -- Artifacts
13f0: 74 68 61 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20 that should not
1400: 62 65 20 70 75 73 68 65 64 20 61 72 65 20 73 74 be pushed are st
1410: 6f 72 65 64 20 69 6e 20 74 68 65 20 22 70 72 69 ored in the "pri
1420: 76 61 74 65 22 0a 40 20 2d 2d 20 74 61 62 6c 65 vate".@ -- table
1430: 2e 20 20 50 72 69 76 61 74 65 20 61 72 74 69 66 . Private artif
1440: 61 63 74 73 20 61 72 65 20 6f 6d 69 74 74 65 64 acts are omitted
1450: 20 66 72 6f 6d 20 74 68 65 20 22 75 6e 63 6c 75 from the "unclu
1460: 73 74 65 72 65 64 22 20 61 6e 64 0a 40 20 2d 2d stered" and.@ --
1470: 20 22 75 6e 73 65 6e 74 22 20 74 61 62 6c 65 73 "unsent" tables
1480: 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 ..@ --.@ CREATE
1490: 54 41 42 4c 45 20 70 72 69 76 61 74 65 28 72 69 TABLE private(ri
14a0: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
14b0: 59 20 4b 45 59 29 3b 0a 40 0a 40 20 2d 2d 20 41 Y KEY);.@.@ -- A
14c0: 6e 20 65 6e 74 72 79 20 69 6e 20 74 68 69 73 20 n entry in this
14d0: 74 61 62 6c 65 20 64 65 73 63 72 69 62 65 73 20 table describes
14e0: 61 20 64 61 74 61 62 61 73 65 20 71 75 65 72 79 a database query
14f0: 20 74 68 61 74 20 67 65 6e 65 72 61 74 65 73 20 that generates
1500: 61 0a 40 20 2d 2d 20 74 61 62 6c 65 20 6f 66 20 a.@ -- table of
1510: 74 69 63 6b 65 74 73 2e 0a 40 20 2d 2d 0a 40 20 tickets..@ --.@
1520: 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 70 CREATE TABLE rep
1530: 6f 72 74 66 6d 74 28 0a 40 20 20 20 20 72 6e 20 ortfmt(.@ rn
1540: 69 6e 74 65 67 65 72 20 70 72 69 6d 61 72 79 20 integer primary
1550: 6b 65 79 2c 20 20 2d 2d 20 52 65 70 6f 72 74 20 key, -- Report
1560: 6e 75 6d 62 65 72 0a 40 20 20 20 20 6f 77 6e 65 number.@ owne
1570: 72 20 74 65 78 74 2c 20 20 20 20 20 20 20 20 20 r text,
1580: 20 20 20 20 20 2d 2d 20 4f 77 6e 65 72 20 6f 66 -- Owner of
1590: 20 74 68 69 73 20 72 65 70 6f 72 74 20 66 6f 72 this report for
15a0: 6d 61 74 20 28 6e 6f 74 20 75 73 65 64 29 0a 40 mat (not used).@
15b0: 20 20 20 20 74 69 74 6c 65 20 74 65 78 74 2c 20 title text,
15c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 --
15d0: 54 69 74 6c 65 20 6f 66 20 74 68 69 73 20 72 65 Title of this re
15e0: 70 6f 72 74 0a 40 20 20 20 20 63 6f 6c 73 20 74 port.@ cols t
15f0: 65 78 74 2c 20 20 20 20 20 20 20 20 20 20 20 20 ext,
1600: 20 20 20 2d 2d 20 41 20 63 6f 6c 6f 72 2d 6b 65 -- A color-ke
1610: 79 20 73 70 65 63 69 66 69 63 61 74 69 6f 6e 0a y specification.
1620: 40 20 20 20 20 73 71 6c 63 6f 64 65 20 74 65 78 @ sqlcode tex
1630: 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d t --
1640: 20 41 6e 20 53 51 4c 20 53 45 4c 45 43 54 20 73 An SQL SELECT s
1650: 74 61 74 65 6d 65 6e 74 20 66 6f 72 20 74 68 69 tatement for thi
1660: 73 20 72 65 70 6f 72 74 0a 40 20 29 3b 0a 40 0a s report.@ );.@.
1670: 40 20 2d 2d 20 53 6f 6d 65 20 74 69 63 6b 65 74 @ -- Some ticket
1680: 20 63 6f 6e 74 65 6e 74 20 28 73 75 63 68 20 61 content (such a
1690: 73 20 74 68 65 20 6f 72 69 67 69 6e 61 74 6f 72 s the originator
16a0: 73 20 65 6d 61 69 6c 20 61 64 64 72 65 73 73 20 s email address
16b0: 6f 72 20 63 6f 6e 74 61 63 74 0a 40 20 2d 2d 20 or contact.@ --
16c0: 69 6e 66 6f 72 6d 61 74 69 6f 6e 29 20 6e 65 65 information) nee
16d0: 64 73 20 74 6f 20 62 65 20 6f 62 73 63 75 72 65 ds to be obscure
16e0: 64 20 74 6f 20 70 72 6f 74 65 63 74 20 70 72 69 d to protect pri
16f0: 76 61 63 79 2e 20 20 54 68 69 73 20 69 73 20 61 vacy. This is a
1700: 63 68 69 65 76 65 64 0a 40 20 2d 2d 20 62 79 20 chieved.@ -- by
1710: 73 74 6f 72 69 6e 67 20 61 6e 20 53 48 41 31 20 storing an SHA1
1720: 68 61 73 68 20 6f 66 20 74 68 65 20 63 6f 6e 74 hash of the cont
1730: 65 6e 74 2e 20 20 46 6f 72 20 64 69 73 70 6c 61 ent. For displa
1740: 79 2c 20 74 68 65 20 68 61 73 68 20 69 73 0a 40 y, the hash is.@
1750: 20 2d 2d 20 6d 61 70 70 65 64 20 62 61 63 6b 20 -- mapped back
1760: 69 6e 74 6f 20 74 68 65 20 6f 72 69 67 69 6e 61 into the origina
1770: 6c 20 74 65 78 74 20 75 73 69 6e 67 20 74 68 69 l text using thi
1780: 73 20 74 61 62 6c 65 2e 20 20 0a 40 20 2d 2d 0a s table. .@ --.
1790: 40 20 2d 2d 20 54 68 69 73 20 74 61 62 6c 65 20 @ -- This table
17a0: 63 6f 6e 74 61 69 6e 73 20 73 65 6e 73 69 74 69 contains sensiti
17b0: 76 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 ve information a
17c0: 6e 64 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 nd should not be
17d0: 20 73 68 61 72 65 64 0a 40 20 2d 2d 20 77 69 74 shared.@ -- wit
17e0: 68 20 75 6e 61 75 74 68 6f 72 69 7a 65 64 20 75 h unauthorized u
17f0: 73 65 72 73 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 sers..@ --.@ CRE
1800: 41 54 45 20 54 41 42 4c 45 20 63 6f 6e 63 65 61 ATE TABLE concea
1810: 6c 65 64 28 0a 40 20 20 20 68 61 73 68 20 54 45 led(.@ hash TE
1820: 58 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a XT PRIMARY KEY,.
1830: 40 20 20 20 63 6f 6e 74 65 6e 74 20 54 45 58 54 @ content TEXT
1840: 0a 40 20 29 3b 0a 3b 0a 0a 63 6f 6e 73 74 20 63 .@ );.;..const c
1850: 68 61 72 20 7a 52 65 70 6f 73 69 74 6f 72 79 53 har zRepositoryS
1860: 63 68 65 6d 61 32 5b 5d 20 3d 0a 40 20 2d 2d 20 chema2[] =.@ --
1870: 46 69 6c 65 6e 61 6d 65 73 0a 40 20 2d 2d 0a 40 Filenames.@ --.@
1880: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 66 69 CREATE TABLE fi
1890: 6c 65 6e 61 6d 65 28 0a 40 20 20 20 66 6e 69 64 lename(.@ fnid
18a0: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
18b0: 20 4b 45 59 2c 20 20 20 20 2d 2d 20 46 69 6c 65 KEY, -- File
18c0: 6e 61 6d 65 20 49 44 0a 40 20 20 20 6e 61 6d 65 name ID.@ name
18d0: 20 54 45 58 54 20 55 4e 49 51 55 45 20 20 20 20 TEXT UNIQUE
18e0: 20 20 20 20 20 20 20 20 20 2d 2d 20 4e 61 6d 65 -- Name
18f0: 20 6f 66 20 66 69 6c 65 20 70 61 67 65 0a 40 20 of file page.@
1900: 29 3b 0a 40 0a 40 20 2d 2d 20 4c 69 6e 6b 61 67 );.@.@ -- Linkag
1910: 65 73 20 62 65 74 77 65 65 6e 20 6d 61 6e 69 66 es between manif
1920: 65 73 74 73 2c 20 66 69 6c 65 73 20 63 72 65 61 ests, files crea
1930: 74 65 64 20 62 79 20 74 68 61 74 20 6d 61 6e 69 ted by that mani
1940: 66 65 73 74 2c 20 61 6e 64 0a 40 20 2d 2d 20 74 fest, and.@ -- t
1950: 68 65 20 6e 61 6d 65 73 20 6f 66 20 74 68 6f 73 he names of thos
1960: 65 20 66 69 6c 65 73 2e 0a 40 20 2d 2d 0a 40 20 e files..@ --.@
1970: 2d 2d 20 70 69 64 3d 3d 30 20 69 66 20 74 68 65 -- pid==0 if the
1980: 20 66 69 6c 65 20 69 73 20 61 64 64 65 64 20 62 file is added b
1990: 79 20 63 68 65 63 6b 2d 69 6e 20 6d 69 64 2e 0a y check-in mid..
19a0: 40 20 2d 2d 20 66 69 64 3d 3d 30 20 69 66 20 74 @ -- fid==0 if t
19b0: 68 65 20 66 69 6c 65 20 69 73 20 72 65 6d 6f 76 he file is remov
19c0: 65 64 20 62 79 20 63 68 65 63 6b 2d 69 6e 20 6d ed by check-in m
19d0: 69 64 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 id..@ --.@ CREAT
19e0: 45 20 54 41 42 4c 45 20 6d 6c 69 6e 6b 28 0a 40 E TABLE mlink(.@
19f0: 20 20 20 6d 69 64 20 49 4e 54 45 47 45 52 20 52 mid INTEGER R
1a00: 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c 20 EFERENCES blob,
1a10: 20 20 20 20 20 20 20 2d 2d 20 4d 61 6e 69 66 65 -- Manife
1a20: 73 74 20 49 44 20 77 68 65 72 65 20 63 68 61 6e st ID where chan
1a30: 67 65 20 6f 63 63 75 72 73 0a 40 20 20 20 70 69 ge occurs.@ pi
1a40: 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 d INTEGER REFERE
1a50: 4e 43 45 53 20 62 6c 6f 62 2c 20 20 20 20 20 20 NCES blob,
1a60: 20 20 2d 2d 20 46 69 6c 65 20 49 44 20 69 6e 20 -- File ID in
1a70: 70 61 72 65 6e 74 20 6d 61 6e 69 66 65 73 74 0a parent manifest.
1a80: 40 20 20 20 66 69 64 20 49 4e 54 45 47 45 52 20 @ fid INTEGER
1a90: 52 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c REFERENCES blob,
1aa0: 20 20 20 20 20 20 20 20 2d 2d 20 43 68 61 6e 67 -- Chang
1ab0: 65 64 20 66 69 6c 65 20 49 44 20 69 6e 20 74 68 ed file ID in th
1ac0: 69 73 20 6d 61 6e 69 66 65 73 74 0a 40 20 20 20 is manifest.@
1ad0: 66 6e 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 fnid INTEGER REF
1ae0: 45 52 45 4e 43 45 53 20 66 69 6c 65 6e 61 6d 65 ERENCES filename
1af0: 20 20 20 20 2d 2d 20 4e 61 6d 65 20 6f 66 20 74 -- Name of t
1b00: 68 65 20 66 69 6c 65 0a 40 20 29 3b 0a 40 20 43 he file.@ );.@ C
1b10: 52 45 41 54 45 20 49 4e 44 45 58 20 6d 6c 69 6e REATE INDEX mlin
1b20: 6b 5f 69 31 20 4f 4e 20 6d 6c 69 6e 6b 28 6d 69 k_i1 ON mlink(mi
1b30: 64 29 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 d);.@ CREATE IND
1b40: 45 58 20 6d 6c 69 6e 6b 5f 69 32 20 4f 4e 20 6d EX mlink_i2 ON m
1b50: 6c 69 6e 6b 28 66 6e 69 64 29 3b 0a 40 20 43 52 link(fnid);.@ CR
1b60: 45 41 54 45 20 49 4e 44 45 58 20 6d 6c 69 6e 6b EATE INDEX mlink
1b70: 5f 69 33 20 4f 4e 20 6d 6c 69 6e 6b 28 66 69 64 _i3 ON mlink(fid
1b80: 29 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 45 );.@ CREATE INDE
1b90: 58 20 6d 6c 69 6e 6b 5f 69 34 20 4f 4e 20 6d 6c X mlink_i4 ON ml
1ba0: 69 6e 6b 28 70 69 64 29 3b 0a 40 0a 40 20 2d 2d ink(pid);.@.@ --
1bb0: 20 50 61 72 65 6e 74 2f 63 68 69 6c 64 20 6c 69 Parent/child li
1bc0: 6e 6b 61 67 65 73 0a 40 20 2d 2d 0a 40 20 43 52 nkages.@ --.@ CR
1bd0: 45 41 54 45 20 54 41 42 4c 45 20 70 6c 69 6e 6b EATE TABLE plink
1be0: 28 0a 40 20 20 20 70 69 64 20 49 4e 54 45 47 45 (.@ pid INTEGE
1bf0: 52 20 52 45 46 45 52 45 4e 43 45 53 20 62 6c 6f R REFERENCES blo
1c00: 62 2c 20 20 20 20 2d 2d 20 50 61 72 65 6e 74 20 b, -- Parent
1c10: 6d 61 6e 69 66 65 73 74 0a 40 20 20 20 63 69 64 manifest.@ cid
1c20: 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 4e INTEGER REFEREN
1c30: 43 45 53 20 62 6c 6f 62 2c 20 20 20 20 2d 2d 20 CES blob, --
1c40: 43 68 69 6c 64 20 6d 61 6e 69 66 65 73 74 0a 40 Child manifest.@
1c50: 20 20 20 69 73 70 72 69 6d 20 42 4f 4f 4c 45 41 isprim BOOLEA
1c60: 4e 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 N,
1c70: 20 20 20 2d 2d 20 70 69 64 20 69 73 20 74 68 65 -- pid is the
1c80: 20 70 72 69 6d 61 72 79 20 70 61 72 65 6e 74 20 primary parent
1c90: 6f 66 20 63 69 64 0a 40 20 20 20 6d 74 69 6d 65 of cid.@ mtime
1ca0: 20 44 41 54 45 54 49 4d 45 2c 20 20 20 20 20 20 DATETIME,
1cb0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 74 68 -- th
1cc0: 65 20 64 61 74 65 2f 74 69 6d 65 20 73 74 61 6d e date/time stam
1cd0: 70 20 6f 6e 20 63 69 64 0a 40 20 20 20 55 4e 49 p on cid.@ UNI
1ce0: 51 55 45 28 70 69 64 2c 20 63 69 64 29 0a 40 20 QUE(pid, cid).@
1cf0: 29 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 45 );.@ CREATE INDE
1d00: 58 20 70 6c 69 6e 6b 5f 69 32 20 4f 4e 20 70 6c X plink_i2 ON pl
1d10: 69 6e 6b 28 63 69 64 29 3b 0a 40 0a 40 20 2d 2d ink(cid);.@.@ --
1d20: 20 45 76 65 6e 74 73 20 75 73 65 64 20 74 6f 20 Events used to
1d30: 67 65 6e 65 72 61 74 65 20 61 20 74 69 6d 65 6c generate a timel
1d40: 69 6e 65 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 ine.@ --.@ CREAT
1d50: 45 20 54 41 42 4c 45 20 65 76 65 6e 74 28 0a 40 E TABLE event(.@
1d60: 20 20 20 74 79 70 65 20 54 45 58 54 2c 20 20 20 type TEXT,
1d70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1d80: 20 20 20 2d 2d 20 54 79 70 65 20 6f 66 20 65 76 -- Type of ev
1d90: 65 6e 74 0a 40 20 20 20 6d 74 69 6d 65 20 44 41 ent.@ mtime DA
1da0: 54 45 54 49 4d 45 2c 20 20 20 20 20 20 20 20 20 TETIME,
1db0: 20 20 20 20 20 20 20 20 2d 2d 20 44 61 74 65 20 -- Date
1dc0: 61 6e 64 20 74 69 6d 65 20 77 68 65 6e 20 74 68 and time when th
1dd0: 65 20 65 76 65 6e 74 20 6f 63 63 75 72 73 0a 40 e event occurs.@
1de0: 20 20 20 6f 62 6a 69 64 20 49 4e 54 45 47 45 52 objid INTEGER
1df0: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 PRIMARY KEY,
1e00: 20 20 20 2d 2d 20 41 73 73 6f 63 69 61 74 65 64 -- Associated
1e10: 20 72 65 63 6f 72 64 20 49 44 0a 40 20 20 20 75 record ID.@ u
1e20: 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 id INTEGER REFER
1e30: 45 4e 43 45 53 20 75 73 65 72 2c 20 20 20 20 2d ENCES user, -
1e40: 2d 20 55 73 65 72 20 77 68 6f 20 63 61 75 73 65 - User who cause
1e50: 64 20 74 68 65 20 65 76 65 6e 74 0a 40 20 20 20 d the event.@
1e60: 62 67 63 6f 6c 6f 72 20 54 45 58 54 2c 20 20 20 bgcolor TEXT,
1e70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1e80: 2d 2d 20 43 6f 6c 6f 72 20 73 65 74 20 62 79 20 -- Color set by
1e90: 27 62 67 63 6f 6c 6f 72 27 20 70 72 6f 70 65 72 'bgcolor' proper
1ea0: 74 79 0a 40 20 20 20 62 72 62 67 63 6f 6c 6f 72 ty.@ brbgcolor
1eb0: 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20 20 TEXT,
1ec0: 20 20 20 20 20 20 20 2d 2d 20 43 6f 6c 6f 72 20 -- Color
1ed0: 73 65 74 20 62 79 20 27 62 72 2d 62 67 63 6f 6c set by 'br-bgcol
1ee0: 6f 72 27 20 70 72 6f 70 65 72 74 79 0a 40 20 20 or' property.@
1ef0: 20 65 75 73 65 72 20 54 45 58 54 2c 20 20 20 20 euser TEXT,
1f00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f10: 20 2d 2d 20 55 73 65 72 20 73 65 74 20 62 79 20 -- User set by
1f20: 27 75 73 65 72 27 20 70 72 6f 70 65 72 74 79 0a 'user' property.
1f30: 40 20 20 20 75 73 65 72 20 54 45 58 54 2c 20 20 @ user TEXT,
1f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1f50: 20 20 20 20 2d 2d 20 4e 61 6d 65 20 6f 66 20 74 -- Name of t
1f60: 68 65 20 75 73 65 72 0a 40 20 20 20 65 63 6f 6d he user.@ ecom
1f70: 6d 65 6e 74 20 54 45 58 54 2c 20 20 20 20 20 20 ment TEXT,
1f80: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 43 -- C
1f90: 6f 6d 6d 65 6e 74 20 73 65 74 20 62 79 20 27 63 omment set by 'c
1fa0: 6f 6d 6d 65 6e 74 27 20 70 72 6f 70 65 72 74 79 omment' property
1fb0: 0a 40 20 20 20 63 6f 6d 6d 65 6e 74 20 54 45 58 .@ comment TEX
1fc0: 54 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 T
1fd0: 20 20 20 20 20 2d 2d 20 43 6f 6d 6d 65 6e 74 20 -- Comment
1fe0: 64 65 73 63 72 69 62 69 6e 67 20 74 68 65 20 65 describing the e
1ff0: 76 65 6e 74 0a 40 20 29 3b 0a 40 20 43 52 45 41 vent.@ );.@ CREA
2000: 54 45 20 49 4e 44 45 58 20 65 76 65 6e 74 5f 69 TE INDEX event_i
2010: 31 20 4f 4e 20 65 76 65 6e 74 28 6d 74 69 6d 65 1 ON event(mtime
2020: 29 3b 0a 40 0a 40 20 2d 2d 20 41 20 72 65 63 6f );.@.@ -- A reco
2030: 72 64 20 6f 66 20 70 68 61 6e 74 6f 6d 73 2e 20 rd of phantoms.
2040: 20 41 20 70 68 61 6e 74 6f 6d 20 69 73 20 61 20 A phantom is a
2050: 72 65 63 6f 72 64 20 66 6f 72 20 77 68 69 63 68 record for which
2060: 20 77 65 20 6b 6e 6f 77 20 74 68 65 0a 40 20 2d we know the.@ -
2070: 2d 20 55 55 49 44 20 62 75 74 20 77 65 20 64 6f - UUID but we do
2080: 20 6e 6f 74 20 28 79 65 74 29 20 6b 6e 6f 77 20 not (yet) know
2090: 74 68 65 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 the file content
20a0: 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 ..@ --.@ CREATE
20b0: 54 41 42 4c 45 20 70 68 61 6e 74 6f 6d 28 0a 40 TABLE phantom(.@
20c0: 20 20 20 72 69 64 20 49 4e 54 45 47 45 52 20 50 rid INTEGER P
20d0: 52 49 4d 41 52 59 20 4b 45 59 20 20 20 20 20 20 RIMARY KEY
20e0: 20 20 20 2d 2d 20 52 65 63 6f 72 64 20 49 44 20 -- Record ID
20f0: 6f 66 20 74 68 65 20 70 68 61 6e 74 6f 6d 0a 40 of the phantom.@
2100: 20 29 3b 0a 40 0a 40 20 2d 2d 20 55 6e 63 6c 75 );.@.@ -- Unclu
2110: 73 74 65 72 65 64 20 72 65 63 6f 72 64 73 2e 20 stered records.
2120: 20 41 6e 20 75 6e 63 6c 75 73 74 65 72 65 64 20 An unclustered
2130: 72 65 63 6f 72 64 20 69 73 20 61 20 72 65 63 6f record is a reco
2140: 72 64 20 28 69 6e 63 6c 75 64 69 6e 67 0a 40 20 rd (including.@
2150: 2d 2d 20 61 20 63 6c 75 73 74 65 72 20 72 65 63 -- a cluster rec
2160: 6f 72 64 73 20 74 68 65 6d 73 65 6c 76 65 73 29 ords themselves)
2170: 20 74 68 61 74 20 69 73 20 6e 6f 74 20 6d 65 6e that is not men
2180: 74 69 6f 6e 65 64 20 62 79 20 73 6f 6d 65 20 6f tioned by some o
2190: 74 68 65 72 0a 40 20 2d 2d 20 63 6c 75 73 74 65 ther.@ -- cluste
21a0: 72 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 50 68 61 r..@ --.@ -- Pha
21b0: 6e 74 6f 6d 73 20 61 72 65 20 75 73 75 61 6c 6c ntoms are usuall
21c0: 79 20 69 6e 63 6c 75 64 65 64 20 69 6e 20 74 68 y included in th
21d0: 65 20 75 6e 63 6c 75 73 74 65 72 65 64 20 74 61 e unclustered ta
21e0: 62 6c 65 2e 20 20 41 20 6e 65 77 20 63 6c 75 73 ble. A new clus
21f0: 74 65 72 0a 40 20 2d 2d 20 77 69 6c 6c 20 6e 65 ter.@ -- will ne
2200: 76 65 72 20 62 65 20 63 72 65 61 74 65 64 20 74 ver be created t
2210: 68 61 74 20 63 6f 6e 74 61 69 6e 73 20 61 20 70 hat contains a p
2220: 68 61 6e 74 6f 6d 2e 20 20 42 75 74 20 61 6e 6f hantom. But ano
2230: 74 68 65 72 20 72 65 70 6f 73 69 74 6f 72 79 0a ther repository.
2240: 40 20 2d 2d 20 6d 69 67 68 74 20 73 65 6e 64 20 @ -- might send
2250: 75 73 20 61 20 63 6c 75 73 74 65 72 20 74 68 61 us a cluster tha
2260: 74 20 63 6f 6e 74 61 69 6e 73 20 65 6e 74 72 69 t contains entri
2270: 65 73 20 74 68 61 74 20 61 72 65 20 70 68 61 6e es that are phan
2280: 74 6f 6d 73 20 74 6f 0a 40 20 2d 2d 20 75 73 2e toms to.@ -- us.
2290: 0a 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 .@ --.@ CREATE T
22a0: 41 42 4c 45 20 75 6e 63 6c 75 73 74 65 72 65 64 ABLE unclustered
22b0: 28 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 (.@ rid INTEGE
22c0: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20 20 R PRIMARY KEY
22d0: 20 20 20 20 20 20 2d 2d 20 52 65 63 6f 72 64 20 -- Record
22e0: 49 44 20 6f 66 20 74 68 65 20 75 6e 63 6c 75 73 ID of the unclus
22f0: 74 65 72 65 64 20 66 69 6c 65 0a 40 20 29 3b 0a tered file.@ );.
2300: 40 0a 40 20 2d 2d 20 52 65 63 6f 72 64 73 20 77 @.@ -- Records w
2310: 68 69 63 68 20 68 61 76 65 20 6e 65 76 65 72 20 hich have never
2320: 62 65 65 6e 20 70 75 73 68 65 64 20 74 6f 20 61 been pushed to a
2330: 6e 6f 74 68 65 72 20 73 65 72 76 65 72 2e 20 20 nother server.
2340: 54 68 69 73 20 69 73 0a 40 20 2d 2d 20 75 73 65 This is.@ -- use
2350: 64 20 74 6f 20 72 65 64 75 63 65 20 70 75 73 68 d to reduce push
2360: 20 6f 70 65 72 61 74 69 6f 6e 73 20 74 6f 20 61 operations to a
2370: 20 73 69 6e 67 6c 65 20 48 54 54 50 20 72 65 71 single HTTP req
2380: 75 65 73 74 20 69 6e 20 74 68 65 0a 40 20 2d 2d uest in the.@ --
2390: 20 63 6f 6d 6d 6f 6e 20 63 61 73 65 20 77 68 65 common case whe
23a0: 6e 20 6f 6e 65 20 72 65 70 6f 73 69 74 6f 72 79 n one repository
23b0: 20 6f 6e 6c 79 20 74 61 6c 6b 73 20 74 6f 20 61 only talks to a
23c0: 20 73 69 6e 67 6c 65 20 73 65 72 76 65 72 2e 0a single server..
23d0: 40 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 @ --.@ CREATE TA
23e0: 42 4c 45 20 75 6e 73 65 6e 74 28 0a 40 20 20 20 BLE unsent(.@
23f0: 72 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d rid INTEGER PRIM
2400: 41 52 59 20 4b 45 59 20 20 20 20 20 20 20 20 20 ARY KEY
2410: 2d 2d 20 52 65 63 6f 72 64 20 49 44 20 6f 66 20 -- Record ID of
2420: 74 68 65 20 70 68 61 6e 74 6f 6d 0a 40 20 29 3b the phantom.@ );
2430: 0a 40 0a 40 20 2d 2d 20 45 61 63 68 20 62 61 73 .@.@ -- Each bas
2440: 65 6c 69 6e 65 20 6f 72 20 6d 61 6e 69 66 65 73 eline or manifes
2450: 74 20 63 61 6e 20 68 61 76 65 20 6f 6e 65 20 6f t can have one o
2460: 72 20 6d 6f 72 65 20 74 61 67 73 2e 20 20 41 20 r more tags. A
2470: 74 61 67 0a 40 20 2d 2d 20 69 73 20 64 65 66 69 tag.@ -- is defi
2480: 6e 65 64 20 62 79 20 61 20 72 6f 77 20 69 6e 20 ned by a row in
2490: 74 68 65 20 6e 65 78 74 20 74 61 62 6c 65 2e 0a the next table..
24a0: 40 20 2d 2d 20 0a 40 20 2d 2d 20 57 69 6b 69 20 @ -- .@ -- Wiki
24b0: 70 61 67 65 73 20 61 72 65 20 74 61 67 67 65 64 pages are tagged
24c0: 20 77 69 74 68 20 22 77 69 6b 69 2d 4e 41 4d 45 with "wiki-NAME
24d0: 22 20 77 68 65 72 65 20 4e 41 4d 45 20 69 73 20 " where NAME is
24e0: 74 68 65 20 6e 61 6d 65 20 6f 66 0a 40 20 2d 2d the name of.@ --
24f0: 20 74 68 65 20 77 69 6b 69 20 70 61 67 65 2e 20 the wiki page.
2500: 20 54 69 63 6b 65 74 73 20 63 68 61 6e 67 65 73 Tickets changes
2510: 20 61 72 65 20 74 61 67 67 65 64 20 77 69 74 68 are tagged with
2520: 20 22 74 69 63 6b 65 74 2d 55 55 49 44 22 20 77 "ticket-UUID" w
2530: 68 65 72 65 20 0a 40 20 2d 2d 20 55 55 49 44 20 here .@ -- UUID
2540: 69 73 20 74 68 65 20 69 6e 64 65 6e 74 69 66 69 is the indentifi
2550: 65 72 20 6f 66 20 74 68 65 20 74 69 63 6b 65 74 er of the ticket
2560: 2e 20 20 54 61 67 73 20 75 73 65 64 20 74 6f 20 . Tags used to
2570: 61 73 73 69 67 6e 20 73 79 6d 62 6f 6c 69 63 0a assign symbolic.
2580: 40 20 2d 2d 20 6e 61 6d 65 73 20 74 6f 20 62 61 @ -- names to ba
2590: 73 65 6c 69 6e 65 73 20 61 72 65 20 62 72 61 6e selines are bran
25a0: 63 68 65 73 20 61 72 65 20 6f 66 20 74 68 65 20 ches are of the
25b0: 66 6f 72 6d 20 22 73 79 6d 2d 4e 41 4d 45 22 20 form "sym-NAME"
25c0: 77 68 65 72 65 0a 40 20 2d 2d 20 4e 41 4d 45 20 where.@ -- NAME
25d0: 69 73 20 74 68 65 20 73 79 6d 62 6f 6c 69 63 20 is the symbolic
25e0: 6e 61 6d 65 2e 0a 40 20 2d 2d 0a 40 20 43 52 45 name..@ --.@ CRE
25f0: 41 54 45 20 54 41 42 4c 45 20 74 61 67 28 0a 40 ATE TABLE tag(.@
2600: 20 20 20 74 61 67 69 64 20 49 4e 54 45 47 45 52 tagid INTEGER
2610: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 20 20 PRIMARY KEY,
2620: 20 20 20 20 2d 2d 20 4e 75 6d 65 72 69 63 20 74 -- Numeric t
2630: 61 67 20 49 44 0a 40 20 20 20 74 61 67 6e 61 6d ag ID.@ tagnam
2640: 65 20 54 45 58 54 20 55 4e 49 51 55 45 20 20 20 e TEXT UNIQUE
2650: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 61 -- Ta
2660: 67 20 6e 61 6d 65 2e 0a 40 20 29 3b 0a 40 20 49 g name..@ );.@ I
2670: 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 67 20 56 NSERT INTO tag V
2680: 41 4c 55 45 53 28 31 2c 20 27 62 67 63 6f 6c 6f ALUES(1, 'bgcolo
2690: 72 27 29 3b 20 20 20 20 20 20 20 20 20 2d 2d 20 r'); --
26a0: 54 41 47 5f 42 47 43 4f 4c 4f 52 0a 40 20 49 4e TAG_BGCOLOR.@ IN
26b0: 53 45 52 54 20 49 4e 54 4f 20 74 61 67 20 56 41 SERT INTO tag VA
26c0: 4c 55 45 53 28 32 2c 20 27 63 6f 6d 6d 65 6e 74 LUES(2, 'comment
26d0: 27 29 3b 20 20 20 20 20 20 20 20 20 2d 2d 20 54 '); -- T
26e0: 41 47 5f 43 4f 4d 4d 45 4e 54 0a 40 20 49 4e 53 AG_COMMENT.@ INS
26f0: 45 52 54 20 49 4e 54 4f 20 74 61 67 20 56 41 4c ERT INTO tag VAL
2700: 55 45 53 28 33 2c 20 27 75 73 65 72 27 29 3b 20 UES(3, 'user');
2710: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 41 -- TA
2720: 47 5f 55 53 45 52 0a 40 20 49 4e 53 45 52 54 20 G_USER.@ INSERT
2730: 49 4e 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 INTO tag VALUES(
2740: 34 2c 20 27 68 69 64 64 65 6e 27 29 3b 20 20 20 4, 'hidden');
2750: 20 20 20 20 20 20 20 2d 2d 20 54 41 47 5f 48 49 -- TAG_HI
2760: 44 44 45 4e 0a 40 20 49 4e 53 45 52 54 20 49 4e DDEN.@ INSERT IN
2770: 54 4f 20 74 61 67 20 56 41 4c 55 45 53 28 35 2c TO tag VALUES(5,
2780: 20 27 70 72 69 76 61 74 65 27 29 3b 20 20 20 20 'private');
2790: 20 20 20 20 20 2d 2d 20 54 41 47 5f 50 52 49 56 -- TAG_PRIV
27a0: 41 54 45 0a 40 20 49 4e 53 45 52 54 20 49 4e 54 ATE.@ INSERT INT
27b0: 4f 20 74 61 67 20 56 41 4c 55 45 53 28 36 2c 20 O tag VALUES(6,
27c0: 27 63 6c 75 73 74 65 72 27 29 3b 20 20 20 20 20 'cluster');
27d0: 20 20 20 20 2d 2d 20 54 41 47 5f 43 4c 55 53 54 -- TAG_CLUST
27e0: 45 52 0a 40 0a 40 20 2d 2d 20 41 73 73 69 67 6e ER.@.@ -- Assign
27f0: 6d 65 6e 74 73 20 6f 66 20 74 61 67 73 20 74 6f ments of tags to
2800: 20 62 61 73 65 6c 69 6e 65 73 2e 20 20 4e 6f 74 baselines. Not
2810: 65 20 74 68 61 74 20 77 65 20 61 6c 6c 6f 77 20 e that we allow
2820: 74 61 67 73 20 74 6f 0a 40 20 2d 2d 20 68 61 76 tags to.@ -- hav
2830: 65 20 76 61 6c 75 65 73 20 61 73 73 69 67 6e 65 e values assigne
2840: 64 20 74 6f 20 74 68 65 6d 2e 20 20 53 6f 20 77 d to them. So w
2850: 65 20 61 72 65 20 6e 6f 74 20 72 65 61 6c 6c 79 e are not really
2860: 20 64 65 61 6c 69 6e 67 20 77 69 74 68 0a 40 20 dealing with.@
2870: 2d 2d 20 74 61 67 73 20 68 65 72 65 2e 20 20 54 -- tags here. T
2880: 68 65 73 65 20 61 72 65 20 72 65 61 6c 6c 79 20 hese are really
2890: 70 72 6f 70 65 72 74 69 65 73 2e 20 20 42 75 74 properties. But
28a0: 20 77 65 20 61 72 65 20 67 6f 69 6e 67 20 74 6f we are going to
28b0: 0a 40 20 2d 2d 20 6b 65 65 70 20 63 61 6c 6c 69 .@ -- keep calli
28c0: 6e 67 20 74 68 65 6d 20 74 61 67 73 20 62 65 63 ng them tags bec
28d0: 61 75 73 65 20 69 6e 20 6d 61 6e 79 20 63 61 73 ause in many cas
28e0: 65 73 20 74 68 65 20 76 61 6c 75 65 20 69 73 20 es the value is
28f0: 69 67 6e 6f 72 65 64 2e 0a 40 20 2d 2d 0a 40 20 ignored..@ --.@
2900: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 61 67 CREATE TABLE tag
2910: 78 72 65 66 28 0a 40 20 20 20 74 61 67 69 64 20 xref(.@ tagid
2920: 49 4e 54 45 47 45 52 20 52 45 46 45 52 45 4e 43 INTEGER REFERENC
2930: 45 53 20 74 61 67 2c 20 20 20 2d 2d 20 54 68 65 ES tag, -- The
2940: 20 74 61 67 20 74 68 61 74 20 61 64 64 65 64 20 tag that added
2950: 6f 72 20 72 65 6d 6f 76 65 64 0a 40 20 20 20 74 or removed.@ t
2960: 61 67 74 79 70 65 20 49 4e 54 45 47 45 52 2c 20 agtype INTEGER,
2970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
2980: 2d 20 30 3a 63 61 6e 63 65 6c 20 20 31 3a 73 69 - 0:cancel 1:si
2990: 6e 67 6c 65 20 20 32 3a 62 72 61 6e 63 68 0a 40 ngle 2:branch.@
29a0: 20 20 20 73 72 63 69 64 20 49 4e 54 45 47 45 52 srcid INTEGER
29b0: 20 52 45 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 REFERENCES blob
29c0: 2c 20 20 2d 2d 20 4f 72 69 67 69 6e 20 6f 66 20 , -- Origin of
29d0: 74 68 65 20 74 61 67 2e 20 30 20 66 6f 72 20 70 the tag. 0 for p
29e0: 72 6f 70 61 67 61 74 65 64 20 74 61 67 73 0a 40 ropagated tags.@
29f0: 20 20 20 76 61 6c 75 65 20 54 45 58 54 2c 20 20 value TEXT,
2a00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a10: 20 20 20 2d 2d 20 56 61 6c 75 65 20 6f 66 20 74 -- Value of t
2a20: 68 65 20 74 61 67 2e 20 20 4d 69 67 68 74 20 62 he tag. Might b
2a30: 65 20 4e 55 4c 4c 2e 0a 40 20 20 20 6d 74 69 6d e NULL..@ mtim
2a40: 65 20 54 49 4d 45 53 54 41 4d 50 2c 20 20 20 20 e TIMESTAMP,
2a50: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 54 -- T
2a60: 69 6d 65 20 6f 66 20 61 64 64 69 74 69 6f 6e 20 ime of addition
2a70: 6f 72 20 72 65 6d 6f 76 61 6c 0a 40 20 20 20 72 or removal.@ r
2a80: 69 64 20 49 4e 54 45 47 45 52 20 52 45 46 45 52 id INTEGER REFER
2a90: 45 4e 43 45 20 62 6c 6f 62 2c 20 20 20 20 20 2d ENCE blob, -
2aa0: 2d 20 42 61 73 65 6c 69 6e 65 20 74 68 61 74 20 - Baseline that
2ab0: 74 61 67 20 61 64 64 65 64 2f 72 65 6d 6f 76 65 tag added/remove
2ac0: 64 20 66 72 6f 6d 0a 40 20 20 20 55 4e 49 51 55 d from.@ UNIQU
2ad0: 45 28 72 69 64 2c 20 74 61 67 69 64 29 0a 40 20 E(rid, tagid).@
2ae0: 29 3b 0a 40 20 43 52 45 41 54 45 20 49 4e 44 45 );.@ CREATE INDE
2af0: 58 20 74 61 67 78 72 65 66 5f 69 31 20 4f 4e 20 X tagxref_i1 ON
2b00: 74 61 67 78 72 65 66 28 74 61 67 69 64 2c 20 6d tagxref(tagid, m
2b10: 74 69 6d 65 29 3b 0a 40 0a 40 20 2d 2d 20 54 65 time);.@.@ -- Te
2b20: 6d 70 6c 61 74 65 20 66 6f 72 20 74 68 65 20 54 mplate for the T
2b30: 49 43 4b 45 54 20 74 61 62 6c 65 0a 40 20 2d 2d ICKET table.@ --
2b40: 0a 40 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 .@ CREATE TABLE
2b50: 74 69 63 6b 65 74 28 0a 40 20 20 20 74 6b 74 5f ticket(.@ tkt_
2b60: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA
2b70: 52 59 20 4b 45 59 2c 0a 40 20 20 20 74 6b 74 5f RY KEY,.@ tkt_
2b80: 75 75 69 64 20 54 45 58 54 2c 0a 40 20 20 20 74 uuid TEXT,.@ t
2b90: 6b 74 5f 6d 74 69 6d 65 20 52 45 41 4c 2c 0a 40 kt_mtime REAL,.@
2ba0: 20 20 20 55 4e 49 51 55 45 28 74 6b 74 5f 75 75 UNIQUE(tkt_uu
2bb0: 69 64 2c 20 74 6b 74 5f 6d 74 69 6d 65 29 0a 40 id, tkt_mtime).@
2bc0: 20 29 3b 0a 3b 0a 0a 2f 2a 0a 2a 2a 20 50 72 65 );.;../*.** Pre
2bd0: 64 65 66 69 6e 65 64 20 74 61 67 69 64 20 76 61 defined tagid va
2be0: 6c 75 65 73 0a 2a 2f 0a 23 69 66 20 49 4e 54 45 lues.*/.#if INTE
2bf0: 52 46 41 43 45 0a 23 20 64 65 66 69 6e 65 20 54 RFACE.# define T
2c00: 41 47 5f 42 47 43 4f 4c 4f 52 20 20 20 20 31 20 AG_BGCOLOR 1
2c10: 20 20 20 20 2f 2a 20 53 65 74 20 74 68 65 20 62 /* Set the b
2c20: 61 63 6b 67 72 6f 75 6e 64 20 63 6f 6c 6f 72 20 ackground color
2c30: 66 6f 72 20 64 69 73 70 6c 61 79 20 2a 2f 0a 23 for display */.#
2c40: 20 64 65 66 69 6e 65 20 54 41 47 5f 43 4f 4d 4d define TAG_COMM
2c50: 45 4e 54 20 20 20 20 32 20 20 20 20 20 2f 2a 20 ENT 2 /*
2c60: 54 68 65 20 63 68 65 63 6b 2d 69 6e 20 63 6f 6d The check-in com
2c70: 6d 65 6e 74 20 2a 2f 0a 23 20 64 65 66 69 6e 65 ment */.# define
2c80: 20 54 41 47 5f 55 53 45 52 20 20 20 20 20 20 20 TAG_USER
2c90: 33 20 20 20 20 20 2f 2a 20 55 73 65 72 20 77 68 3 /* User wh
2ca0: 6f 20 6d 61 64 65 20 61 20 63 68 65 63 6b 69 6e o made a checkin
2cb0: 67 20 2a 2f 0a 23 20 64 65 66 69 6e 65 20 54 41 g */.# define TA
2cc0: 47 5f 48 49 44 44 45 4e 20 20 20 20 20 34 20 20 G_HIDDEN 4
2cd0: 20 20 20 2f 2a 20 44 6f 20 6e 6f 74 20 64 69 73 /* Do not dis
2ce0: 70 6c 61 79 20 6f 72 20 73 79 6e 63 20 2a 2f 0a play or sync */.
2cf0: 23 20 64 65 66 69 6e 65 20 54 41 47 5f 50 52 49 # define TAG_PRI
2d00: 56 41 54 45 20 20 20 20 35 20 20 20 20 20 2f 2a VATE 5 /*
2d10: 20 44 69 73 70 6c 61 79 20 62 75 74 20 64 6f 20 Display but do
2d20: 6e 6f 74 20 73 79 6e 63 20 2a 2f 0a 23 20 64 65 not sync */.# de
2d30: 66 69 6e 65 20 54 41 47 5f 43 4c 55 53 54 45 52 fine TAG_CLUSTER
2d40: 20 20 20 20 36 20 20 20 20 20 2f 2a 20 41 20 63 6 /* A c
2d50: 6c 75 73 74 65 72 20 2a 2f 0a 23 65 6e 64 69 66 luster */.#endif
2d60: 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 73 63 68 65 ../*.** The sche
2d70: 6d 61 20 66 6f 72 20 74 68 65 20 6c 6f 63 61 74 ma for the locat
2d80: 65 20 46 4f 53 53 49 4c 20 64 61 74 61 62 61 73 e FOSSIL databas
2d90: 65 20 66 69 6c 65 20 66 6f 75 6e 64 20 61 74 20 e file found at
2da0: 74 68 65 20 72 6f 6f 74 0a 2a 2a 20 6f 66 20 76 the root.** of v
2db0: 65 72 79 20 63 68 65 63 6b 2d 6f 75 74 2e 20 20 ery check-out.
2dc0: 54 68 69 73 20 64 61 74 61 62 61 73 65 20 63 6f This database co
2dd0: 6e 74 61 69 6e 73 20 74 68 65 20 63 6f 6d 70 6c ntains the compl
2de0: 65 74 65 20 73 74 61 74 65 20 6f 66 0a 2a 2a 20 ete state of.**
2df0: 74 68 65 20 63 68 65 63 6b 6f 75 74 2e 0a 2a 2f the checkout..*/
2e00: 0a 63 6f 6e 73 74 20 63 68 61 72 20 7a 4c 6f 63 .const char zLoc
2e10: 61 6c 53 63 68 65 6d 61 5b 5d 20 3d 0a 40 20 2d alSchema[] =.@ -
2e20: 2d 20 54 68 65 20 56 56 41 52 20 74 61 62 6c 65 - The VVAR table
2e30: 20 68 6f 6c 64 73 20 6d 69 73 63 65 6c 6c 61 6e holds miscellan
2e40: 6f 75 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 ous information
2e50: 61 62 6f 75 74 20 74 68 65 20 6c 6f 63 61 6c 20 about the local
2e60: 64 61 74 61 62 61 73 65 0a 40 20 2d 2d 20 69 6e database.@ -- in
2e70: 20 74 68 65 20 66 6f 72 6d 20 6f 66 20 6e 61 6d the form of nam
2e80: 65 2d 76 61 6c 75 65 20 70 61 69 72 73 2e 20 20 e-value pairs.
2e90: 54 68 69 73 20 69 73 20 73 69 6d 69 6c 61 72 20 This is similar
2ea0: 74 6f 20 74 68 65 20 56 41 52 20 74 61 62 6c 65 to the VAR table
2eb0: 0a 40 20 2d 2d 20 74 61 62 6c 65 20 69 6e 20 74 .@ -- table in t
2ec0: 68 65 20 72 65 70 6f 73 69 74 6f 72 79 20 65 78 he repository ex
2ed0: 63 65 70 74 20 74 68 61 74 20 74 68 69 73 20 74 cept that this t
2ee0: 61 62 6c 65 20 68 6f 6c 64 73 20 69 6e 66 6f 72 able holds infor
2ef0: 6d 61 74 69 6f 6e 20 74 68 61 74 0a 40 20 2d 2d mation that.@ --
2f00: 20 69 73 20 73 70 65 63 69 66 69 63 20 74 6f 20 is specific to
2f10: 74 68 65 20 6c 6f 63 61 6c 20 63 68 65 63 6b 6f the local checko
2f20: 75 74 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 49 6d ut..@ --.@ -- Im
2f30: 70 6f 72 74 61 6e 74 20 56 61 72 69 61 62 6c 65 portant Variable
2f40: 73 3a 0a 40 20 2d 2d 0a 40 20 2d 2d 20 20 20 20 s:.@ --.@ --
2f50: 20 72 65 70 6f 73 69 74 6f 72 79 20 20 20 20 20 repository
2f60: 20 20 20 46 75 6c 6c 20 70 61 74 68 6e 61 6d 65 Full pathname
2f70: 20 6f 66 20 74 68 65 20 72 65 70 6f 73 69 74 6f of the reposito
2f80: 72 79 20 64 61 74 61 62 61 73 65 0a 40 20 2d 2d ry database.@ --
2f90: 20 20 20 20 20 75 73 65 72 2d 69 64 20 20 20 20 user-id
2fa0: 20 20 20 20 20 20 20 55 73 65 72 69 64 20 74 6f Userid to
2fb0: 20 75 73 65 0a 40 20 2d 2d 0a 40 20 43 52 45 41 use.@ --.@ CREA
2fc0: 54 45 20 54 41 42 4c 45 20 76 76 61 72 28 0a 40 TE TABLE vvar(.@
2fd0: 20 20 20 6e 61 6d 65 20 54 45 58 54 20 50 52 49 name TEXT PRI
2fe0: 4d 41 52 59 20 4b 45 59 20 4e 4f 54 20 4e 55 4c MARY KEY NOT NUL
2ff0: 4c 2c 20 20 2d 2d 20 50 72 69 6d 61 72 79 20 6e L, -- Primary n
3000: 61 6d 65 20 6f 66 20 74 68 65 20 65 6e 74 72 79 ame of the entry
3010: 0a 40 20 20 20 76 61 6c 75 65 20 43 4c 4f 42 2c .@ value CLOB,
3020: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3030: 20 20 20 20 20 20 2d 2d 20 43 6f 6e 74 65 6e 74 -- Content
3040: 20 6f 66 20 74 68 65 20 6e 61 6d 65 64 20 70 61 of the named pa
3050: 72 61 6d 65 74 65 72 0a 40 20 20 20 43 48 45 43 rameter.@ CHEC
3060: 4b 28 20 74 79 70 65 6f 66 28 6e 61 6d 65 29 3d K( typeof(name)=
3070: 27 74 65 78 74 27 20 41 4e 44 20 6c 65 6e 67 74 'text' AND lengt
3080: 68 28 6e 61 6d 65 29 3e 3d 31 20 29 0a 40 20 29 h(name)>=1 ).@ )
3090: 3b 0a 40 0a 40 20 2d 2d 20 45 61 63 68 20 65 6e ;.@.@ -- Each en
30a0: 74 72 79 20 69 6e 20 74 68 65 20 76 66 69 6c 65 try in the vfile
30b0: 20 74 61 62 6c 65 20 72 65 70 72 65 73 65 6e 74 table represent
30c0: 73 20 61 20 73 69 6e 67 6c 65 20 66 69 6c 65 20 s a single file
30d0: 6f 72 20 66 6f 6c 64 65 72 0a 40 20 2d 2d 20 74 or folder.@ -- t
30e0: 68 61 74 20 69 73 20 70 61 72 74 20 6f 66 20 61 hat is part of a
30f0: 20 76 65 72 73 69 6f 6e 2e 0a 40 20 2d 2d 0a 40 version..@ --.@
3100: 20 2d 2d 20 54 68 65 20 66 69 6c 65 2e 72 69 64 -- The file.rid
3110: 20 66 69 65 6c 64 20 69 73 20 30 20 66 6f 72 20 field is 0 for
3120: 66 69 6c 65 73 20 6f 72 20 66 6f 6c 64 65 72 73 files or folders
3130: 20 74 68 61 74 20 68 61 76 65 20 62 65 65 6e 0a that have been.
3140: 40 20 2d 2d 20 61 64 64 65 64 20 62 75 74 20 6e @ -- added but n
3150: 6f 74 20 79 65 74 20 63 6f 6d 6d 69 74 74 65 64 ot yet committed
3160: 2e 0a 40 20 2d 2d 0a 40 20 2d 2d 20 56 66 69 6c ..@ --.@ -- Vfil
3170: 65 2e 63 68 6e 67 65 64 20 69 73 20 30 20 66 6f e.chnged is 0 fo
3180: 72 20 75 6e 6d 6f 64 69 66 69 65 64 20 66 69 6c r unmodified fil
3190: 65 73 2c 20 31 20 66 6f 72 20 66 69 6c 65 73 20 es, 1 for files
31a0: 74 68 61 74 20 68 61 76 65 0a 40 20 2d 2d 20 62 that have.@ -- b
31b0: 65 65 6e 20 65 64 69 74 65 64 20 6f 72 20 77 68 een edited or wh
31c0: 69 63 68 20 68 61 76 65 20 62 65 65 6e 20 73 75 ich have been su
31d0: 62 6a 65 63 74 65 64 20 74 6f 20 61 20 33 2d 77 bjected to a 3-w
31e0: 61 79 20 6d 65 72 67 65 2e 20 20 0a 40 20 2d 2d ay merge. .@ --
31f0: 20 56 66 69 6c 65 2e 63 68 6e 67 65 64 20 69 73 Vfile.chnged is
3200: 20 32 20 69 66 20 74 68 65 20 66 69 6c 65 20 68 2 if the file h
3210: 61 73 20 62 65 65 6e 20 72 65 70 6c 61 63 65 64 as been replaced
3220: 20 66 72 6f 6d 20 61 20 64 69 66 66 65 72 65 6e from a differen
3230: 74 0a 40 20 2d 2d 20 76 65 72 73 69 6f 6e 20 62 t.@ -- version b
3240: 79 20 74 68 65 20 6d 65 72 67 65 20 61 6e 64 20 y the merge and
3250: 33 20 69 66 20 74 68 65 20 66 69 6c 65 20 68 61 3 if the file ha
3260: 73 20 62 65 65 6e 20 61 64 64 65 64 20 62 79 20 s been added by
3270: 61 20 6d 65 72 67 65 2e 0a 40 20 2d 2d 20 54 68 a merge..@ -- Th
3280: 65 20 64 69 66 66 65 72 65 6e 63 65 20 62 65 74 e difference bet
3290: 77 65 65 6e 20 76 66 69 6c 65 2e 63 68 6e 67 65 ween vfile.chnge
32a0: 64 3d 3d 32 20 61 6e 64 20 61 20 72 65 67 75 6c d==2 and a regul
32b0: 61 72 20 61 64 64 20 69 73 20 74 68 61 74 0a 40 ar add is that.@
32c0: 20 2d 2d 20 77 69 74 68 20 76 66 69 6c 65 2e 63 -- with vfile.c
32d0: 68 6e 67 65 64 3d 3d 32 20 77 65 20 6b 6e 6f 77 hnged==2 we know
32e0: 20 74 68 61 74 20 74 68 65 20 63 75 72 72 65 6e that the curren
32f0: 74 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 t version of the
3300: 20 66 69 6c 65 0a 40 20 2d 2d 20 69 73 20 61 6c file.@ -- is al
3310: 72 65 61 64 79 20 69 6e 20 74 68 65 20 72 65 70 ready in the rep
3320: 6f 73 69 74 6f 72 79 2e 0a 40 20 2d 2d 20 0a 40 ository..@ -- .@
3330: 20 2d 2d 0a 40 20 43 52 45 41 54 45 20 54 41 42 --.@ CREATE TAB
3340: 4c 45 20 76 66 69 6c 65 28 0a 40 20 20 20 69 64 LE vfile(.@ id
3350: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
3360: 20 4b 45 59 2c 20 20 20 20 20 20 20 20 20 20 20 KEY,
3370: 2d 2d 20 49 44 20 6f 66 20 74 68 65 20 63 68 65 -- ID of the che
3380: 63 6b 65 64 20 6f 75 74 20 66 69 6c 65 0a 40 20 cked out file.@
3390: 20 20 76 69 64 20 49 4e 54 45 47 45 52 20 52 45 vid INTEGER RE
33a0: 46 45 52 45 4e 43 45 53 20 62 6c 6f 62 2c 20 20 FERENCES blob,
33b0: 20 20 20 20 2d 2d 20 54 68 65 20 62 61 73 65 6c -- The basel
33c0: 69 6e 65 20 74 68 69 73 20 66 69 6c 65 20 69 73 ine this file is
33d0: 20 70 61 72 74 20 6f 66 2e 0a 40 20 20 20 63 68 part of..@ ch
33e0: 6e 67 65 64 20 49 4e 54 20 44 45 46 41 55 4c 54 nged INT DEFAULT
33f0: 20 30 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 0,
3400: 2d 2d 20 30 3a 75 6e 63 68 6e 67 65 64 20 31 3a -- 0:unchnged 1:
3410: 65 64 69 74 65 64 20 32 3a 6d 2d 63 68 6e 67 20 edited 2:m-chng
3420: 33 3a 6d 2d 61 64 64 0a 40 20 20 20 64 65 6c 65 3:m-add.@ dele
3430: 74 65 64 20 42 4f 4f 4c 45 41 4e 20 44 45 46 41 ted BOOLEAN DEFA
3440: 55 4c 54 20 30 2c 20 20 20 20 20 20 20 20 2d 2d ULT 0, --
3450: 20 54 72 75 65 20 69 66 20 64 65 6c 65 74 65 64 True if deleted
3460: 20 0a 40 20 20 20 72 69 64 20 49 4e 54 45 47 45 .@ rid INTEGE
3470: 52 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 R,
3480: 20 20 20 20 20 20 20 20 2d 2d 20 4f 72 69 67 69 -- Origi
3490: 6e 61 6c 6c 79 20 66 72 6f 6d 20 74 68 69 73 20 nally from this
34a0: 72 65 70 6f 73 69 74 6f 72 79 20 72 65 63 6f 72 repository recor
34b0: 64 0a 40 20 20 20 6d 72 69 64 20 49 4e 54 45 47 d.@ mrid INTEG
34c0: 45 52 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 ER,
34d0: 20 20 20 20 20 20 20 20 2d 2d 20 42 61 73 65 64 -- Based
34e0: 20 6f 6e 20 74 68 69 73 20 72 65 63 6f 72 64 20 on this record
34f0: 64 75 65 20 74 6f 20 61 20 6d 65 72 67 65 0a 40 due to a merge.@
3500: 20 20 20 70 61 74 68 6e 61 6d 65 20 54 45 58 54 pathname TEXT
3510: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
3520: 20 20 20 20 20 2d 2d 20 46 75 6c 6c 20 70 61 74 -- Full pat
3530: 68 6e 61 6d 65 0a 40 20 20 20 55 4e 49 51 55 45 hname.@ UNIQUE
3540: 28 70 61 74 68 6e 61 6d 65 2c 76 69 64 29 0a 40 (pathname,vid).@
3550: 20 29 3b 0a 40 0a 40 20 2d 2d 20 54 68 69 73 20 );.@.@ -- This
3560: 74 61 62 6c 65 20 68 6f 6c 64 73 20 61 20 72 65 table holds a re
3570: 63 6f 72 64 20 6f 66 20 75 6e 63 6f 6d 6d 69 74 cord of uncommit
3580: 74 65 64 20 6d 65 72 67 65 73 20 69 6e 20 74 68 ted merges in th
3590: 65 20 6c 6f 63 61 6c 0a 40 20 2d 2d 20 66 69 6c e local.@ -- fil
35a0: 65 20 74 72 65 65 2e 20 20 49 66 20 61 20 56 46 e tree. If a VF
35b0: 49 4c 45 20 65 6e 74 72 79 20 77 69 74 68 20 69 ILE entry with i
35c0: 64 20 68 61 73 20 6d 65 72 67 65 64 20 77 69 74 d has merged wit
35d0: 68 20 61 6e 6f 74 68 65 72 0a 40 20 2d 2d 20 72 h another.@ -- r
35e0: 65 63 6f 72 64 2c 20 74 68 65 72 65 20 69 73 20 ecord, there is
35f0: 61 6e 20 65 6e 74 72 79 20 69 6e 20 74 68 69 73 an entry in this
3600: 20 74 61 62 6c 65 20 77 69 74 68 20 28 69 64 2c table with (id,
3610: 6d 65 72 67 65 29 20 77 68 65 72 65 0a 40 20 2d merge) where.@ -
3620: 2d 20 6d 65 72 67 65 20 69 73 20 74 68 65 20 52 - merge is the R
3630: 45 43 4f 52 44 20 74 61 62 6c 65 20 65 6e 74 72 ECORD table entr
3640: 79 20 74 68 61 74 20 74 68 65 20 66 69 6c 65 20 y that the file
3650: 6d 65 72 67 65 64 20 61 67 61 69 6e 73 74 2e 0a merged against..
3660: 40 20 2d 2d 20 41 6e 20 69 64 20 6f 66 20 30 20 @ -- An id of 0
3670: 68 65 72 65 20 6d 65 61 6e 73 20 74 68 65 20 76 here means the v
3680: 65 72 73 69 6f 6e 20 72 65 63 6f 72 64 20 69 74 ersion record it
3690: 73 65 6c 66 2e 0a 40 0a 40 20 43 52 45 41 54 45 self..@.@ CREATE
36a0: 20 54 41 42 4c 45 20 76 6d 65 72 67 65 28 0a 40 TABLE vmerge(.@
36b0: 20 20 20 69 64 20 49 4e 54 45 47 45 52 20 52 45 id INTEGER RE
36c0: 46 45 52 45 4e 43 45 53 20 76 66 69 6c 65 2c 20 FERENCES vfile,
36d0: 20 20 20 20 20 2d 2d 20 56 46 49 4c 45 20 65 6e -- VFILE en
36e0: 74 72 79 20 74 68 61 74 20 68 61 73 20 62 65 65 try that has bee
36f0: 6e 20 6d 65 72 67 65 64 0a 40 20 20 20 6d 65 72 n merged.@ mer
3700: 67 65 20 49 4e 54 45 47 45 52 2c 20 20 20 20 20 ge INTEGER,
3710: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
3720: 2d 20 4d 65 72 67 65 64 20 77 69 74 68 20 74 68 - Merged with th
3730: 69 73 20 72 65 63 6f 72 64 0a 40 20 20 20 55 4e is record.@ UN
3740: 49 51 55 45 28 69 64 2c 20 6d 65 72 67 65 29 0a IQUE(id, merge).
3750: 40 20 29 3b 0a 40 20 20 20 0a 3b 0a @ );.@ .;.