250
253
op_depth values are not normally visible to the user but may become
251
254
visible after reverting local changes.
253
### The following text needs revision
255
Each row in BASE_NODE has an associated row NODE_DATA. Additionally, each
256
row in WORKING_NODE has one or more associated rows in NODE_DATA.
258
256
This table contains full node descriptions for nodes in either the BASE
259
257
or WORKING trees as described in notes/wc-ng/design. Fields relate
260
258
both to BASE and WORKING trees, unless documented otherwise.
262
### This table is to be integrated into the SCHEMA statement as soon
263
the experimental status of NODES is lifted.
264
### This table superseeds NODE_DATA
266
260
For illustration, with a scenario like this:
273
267
svn add foo/bar # (2)
275
, these are the NODES for the path foo/bar (before single-db, the
276
numbering of op_depth is still a bit different):
269
, these are the NODES table rows for the path foo/bar:
278
(0) BASE_NODE -----> NODES (op_depth == 0)
279
(1) NODES (op_depth == 1) ( <----_ )
280
(2) NODES (op_depth == 2) <----- WORKING_NODE
271
(0) "BASE" ---> NODES (op_depth == 0)
272
(1) NODES (op_depth == 1)
273
(2) NODES (op_depth == 2)
282
275
0 is the original data for foo/bar before 'svn rm foo' (if it existed).
283
276
1 is the data for foo/bar copied in from ^/moo/bar.
384
377
perhaps add a column called "moved_from". */
386
379
/* Boolean value, specifying if this node was moved here (rather than just
387
copied). The source of the move is specified in copyfrom_*. */
380
copied). This is set on all the nodes in the moved tree. The source of
381
the move is implied by a different node with a moved_to column pointing
382
at the root node of the moved tree. */
388
383
moved_here INTEGER,
390
385
/* If the underlying node was moved away (rather than just deleted), this
391
specifies the local_relpath of where the BASE node was moved to.
386
specifies the local_relpath of where the node was moved to.
392
387
This is set only on the root of a move, and is NULL for all children.
394
Note that moved_to never refers to *this* node. It always refers
395
to the "underlying" node, whether that is BASE or a child node
396
implied from a parent's move/copy. */
389
The op-depth of the moved-to node is not recorded. A moved_to path
390
always points at a node within the highest op-depth layer at the
391
destination. This invariant must be maintained by operations which
392
change existing move information. */
460
459
node does not have any dav-cache. */
463
/* The serialized file external information. */
464
/* ### hack. hack. hack.
465
### This information is already stored in properties, but because the
466
### current working copy implementation is such a pain, we can't
467
### readily retrieve it, hence this temporary cache column.
468
### When it is removed, be sure to remove the extra column from
471
### Note: This is only here as a hack, and should *NOT* be added
472
### to any wc_db APIs. */
462
/* Is there a file external in this location. NULL if there
463
is no file external, otherwise '1' */
464
/* ### Originally we had a wc-1.0 like skel in this place, so we
466
### In Subversion 1.7 we defined this column as TEXT, but Sqlite
467
### only uses this information for deciding how to optimize
469
file_external INTEGER,
471
/* serialized skel of this node's inherited properties. NULL if this
472
is not the BASE of a WC root node. */
473
inherited_props BLOB,
476
475
PRIMARY KEY (wc_id, local_relpath, op_depth)
480
CREATE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath, op_depth);
479
CREATE UNIQUE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath,
480
local_relpath, op_depth);
481
/* I_NODES_MOVED is introduced in format 30 */
482
CREATE UNIQUE INDEX I_NODES_MOVED ON NODES (wc_id, moved_to, op_depth);
482
484
/* Many queries have to filter the nodes table to pick only that version
483
485
of each node with the highest (most "current") op_depth. This view
566
568
PRIMARY KEY (wc_id, local_relpath)
569
CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath);
570
571
CREATE UNIQUE INDEX I_EXTERNALS_DEFINED ON EXTERNALS (wc_id,
571
572
def_local_relpath,
575
/* ------------------------------------------------------------------------- */
574
577
/* Format 20 introduces NODES and removes BASE_NODE and WORKING_NODE */
576
579
-- STMT_UPGRADE_TO_20
578
UPDATE BASE_NODE SET checksum=(SELECT checksum FROM pristine
579
WHERE md5_checksum=BASE_NODE.checksum)
580
WHERE EXISTS(SELECT 1 FROM pristine WHERE md5_checksum=BASE_NODE.checksum);
581
UPDATE BASE_NODE SET checksum = (SELECT checksum FROM pristine
582
WHERE md5_checksum = BASE_NODE.checksum)
583
WHERE EXISTS (SELECT 1 FROM pristine WHERE md5_checksum = BASE_NODE.checksum);
582
UPDATE WORKING_NODE SET checksum=(SELECT checksum FROM pristine
583
WHERE md5_checksum=WORKING_NODE.checksum)
584
WHERE EXISTS(SELECT 1 FROM pristine WHERE md5_checksum=WORKING_NODE.checksum);
585
UPDATE WORKING_NODE SET checksum = (SELECT checksum FROM pristine
586
WHERE md5_checksum = WORKING_NODE.checksum)
587
WHERE EXISTS (SELECT 1 FROM pristine
588
WHERE md5_checksum = WORKING_NODE.checksum);
586
590
INSERT INTO NODES (
587
591
wc_id, local_relpath, op_depth, parent_relpath,
752
777
/* ------------------------------------------------------------------------- */
779
/* Format 30 creates a new NODES index for move information, and a new
780
PRISTINE index for the md5_checksum column. It also activates use of
781
skel-based conflict storage -- see notes/wc-ng/conflict-storage-2.0.
782
It also renames the "absent" presence to "server-excluded". */
783
-- STMT_UPGRADE_TO_30
784
CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED
785
ON NODES (wc_id, moved_to, op_depth);
787
CREATE INDEX IF NOT EXISTS I_PRISTINE_MD5 ON PRISTINE (md5_checksum);
789
UPDATE nodes SET presence = "server-excluded" WHERE presence = "absent";
791
/* Just to be sure clear out file external skels from pre 1.7.0 development
792
working copies that were never updated by 1.7.0+ style clients */
793
UPDATE nodes SET file_external=1 WHERE file_external IS NOT NULL;
795
-- STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE
796
SELECT wc_id, local_relpath,
797
conflict_old, conflict_working, conflict_new, prop_reject, tree_conflict_data
799
WHERE conflict_old IS NOT NULL
800
OR conflict_working IS NOT NULL
801
OR conflict_new IS NOT NULL
802
OR prop_reject IS NOT NULL
803
OR tree_conflict_data IS NOT NULL
804
ORDER by wc_id, local_relpath
806
-- STMT_UPGRADE_30_SET_CONFLICT
807
UPDATE actual_node SET conflict_data = ?3, conflict_old = NULL,
808
conflict_working = NULL, conflict_new = NULL, prop_reject = NULL,
809
tree_conflict_data = NULL
810
WHERE wc_id = ?1 and local_relpath = ?2
812
/* ------------------------------------------------------------------------- */
814
/* Format 31 adds the inherited_props column to the NODES table. C code then
815
initializes the update/switch roots to make sure future updates fetch the
816
inherited properties */
817
-- STMT_UPGRADE_TO_31_ALTER_TABLE
818
ALTER TABLE NODES ADD COLUMN inherited_props BLOB;
819
-- STMT_UPGRADE_TO_31_FINALIZE
820
DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST;
821
DROP INDEX IF EXISTS I_EXTERNALS_PARENT;
823
DROP INDEX I_NODES_PARENT;
824
CREATE UNIQUE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath,
825
local_relpath, op_depth);
827
DROP INDEX I_ACTUAL_PARENT;
828
CREATE UNIQUE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath,
831
PRAGMA user_version = 31;
833
-- STMT_UPGRADE_31_SELECT_WCROOT_NODES
834
/* Select all base nodes which are the root of a WC, including
835
switched subtrees, but excluding those which map to the root
838
### IPROPS: Is this query horribly inefficient? Quite likely,
839
### but it only runs during an upgrade, so do we care? */
840
SELECT l.wc_id, l.local_relpath FROM nodes as l
841
LEFT OUTER JOIN nodes as r
843
AND r.local_relpath = l.parent_relpath
846
AND l.repos_path != ''
847
AND ((l.repos_id IS NOT r.repos_id)
848
OR (l.repos_path IS NOT RELPATH_SKIP_JOIN(r.local_relpath, r.repos_path, l.local_relpath)))
851
/* ------------------------------------------------------------------------- */
853
-- STMT_UPGRADE_TO_32
855
/* Drop old index. ### Remove this part from the upgrade to 31 once bumped */
856
DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST;
857
DROP INDEX IF EXISTS I_EXTERNALS_PARENT;
858
CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath);
860
DROP INDEX I_NODES_PARENT;
861
CREATE UNIQUE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath,
862
local_relpath, op_depth);
864
DROP INDEX I_ACTUAL_PARENT;
865
CREATE UNIQUE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath,
868
/* ------------------------------------------------------------------------- */
754
870
/* Format YYY introduces new handling for conflict information. */
763
879
number will be, however, so we're just marking it as 99 for now. */
766
/* TODO: Rename the "absent" presence value to "server-excluded" before
767
the 1.7 release. wc_db.c and this file have references to "absent" which
768
still need to be changed to "server-excluded". */
882
/* TODO: Un-confuse *_revision column names in the EXTERNALS table to
883
"-r<operative> foo@<peg>", as suggested by the patch attached to
884
http://svn.haxx.se/dev/archive-2011-09/0478.shtml */
885
/* TODO: Remove column parent_relpath from EXTERNALS. We're not using it and
886
never will. It's not interesting like in the NODES table: the external's
887
parent path may be *anything*: unversioned, "behind" a another WC... */
770
889
/* Now "drop" the tree_conflict_data column from actual_node. */
771
890
CREATE TABLE ACTUAL_NODE_BACKUP (