/* This file is automatically generated from wc-queries.sql.
 * Do not edit this file -- edit the source and rerun gen-make.py */

#define STMT_SELECT_NODE_INFO 0
#define STMT_0 \
  "SELECT op_depth, repos_id, repos_path, presence, kind, revision, checksum, " \
  "  translated_size, changed_revision, changed_date, changed_author, depth, " \
  "  symlink_target, last_mod_time, properties " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "ORDER BY op_depth DESC " \
  ""

#define STMT_SELECT_NODE_INFO_WITH_LOCK 1
#define STMT_1 \
  "SELECT op_depth, nodes.repos_id, nodes.repos_path, presence, kind, revision, " \
  "  checksum, translated_size, changed_revision, changed_date, changed_author, " \
  "  depth, symlink_target, last_mod_time, properties, lock_token, lock_owner, " \
  "  lock_comment, lock_date " \
  "FROM nodes " \
  "LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id " \
  "  AND nodes.repos_path = lock.repos_relpath " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "ORDER BY op_depth DESC " \
  ""

#define STMT_SELECT_BASE_NODE 2
#define STMT_2 \
  "SELECT repos_id, repos_path, presence, kind, revision, checksum, " \
  "  translated_size, changed_revision, changed_date, changed_author, depth, " \
  "  symlink_target, last_mod_time, properties, file_external IS NOT NULL " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_BASE_NODE_WITH_LOCK 3
#define STMT_3 \
  "SELECT nodes.repos_id, nodes.repos_path, presence, kind, revision, " \
  "  checksum, translated_size, changed_revision, changed_date, changed_author, " \
  "  depth, symlink_target, last_mod_time, properties, file_external IS NOT NULL, " \
  "  lock_token, lock_owner, lock_comment, lock_date " \
  "FROM nodes " \
  "LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id " \
  "  AND nodes.repos_path = lock.repos_relpath " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_BASE_CHILDREN_INFO 4
#define STMT_4 \
  "SELECT local_relpath, nodes.repos_id, nodes.repos_path, presence, kind, " \
  "  revision, depth, file_external IS NOT NULL, " \
  "  lock_token, lock_owner, lock_comment, lock_date " \
  "FROM nodes " \
  "LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id " \
  "  AND nodes.repos_path = lock.repos_relpath " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_WORKING_NODE 5
#define STMT_5 \
  "SELECT op_depth, presence, kind, checksum, translated_size, " \
  "  changed_revision, changed_date, changed_author, depth, symlink_target, " \
  "  repos_id, repos_path, revision, " \
  "  moved_here, moved_to, last_mod_time, properties " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0 " \
  "ORDER BY op_depth DESC " \
  "LIMIT 1 " \
  ""

#define STMT_SELECT_DEPTH_NODE 6
#define STMT_6 \
  "SELECT repos_id, repos_path, presence, kind, revision, checksum, " \
  "  translated_size, changed_revision, changed_date, changed_author, depth, " \
  "  symlink_target, last_mod_time, properties " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3 " \
  ""

#define STMT_SELECT_LOWEST_WORKING_NODE 7
#define STMT_7 \
  "SELECT op_depth, presence " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0 " \
  "ORDER BY op_depth " \
  "LIMIT 1 " \
  ""

#define STMT_SELECT_ACTUAL_NODE 8
#define STMT_8 \
  "SELECT prop_reject, changelist, conflict_old, conflict_new, " \
  "conflict_working, tree_conflict_data, properties " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_SELECT_ACTUAL_TREE_CONFLICT 9
#define STMT_9 \
  "SELECT tree_conflict_data " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND tree_conflict_data IS NOT NULL " \
  ""

#define STMT_SELECT_ACTUAL_CHANGELIST 10
#define STMT_10 \
  "SELECT changelist " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND changelist IS NOT NULL " \
  ""

#define STMT_SELECT_NODE_CHILDREN_INFO 11
#define STMT_11 \
  "SELECT op_depth, nodes.repos_id, nodes.repos_path, presence, kind, revision, " \
  "  checksum, translated_size, changed_revision, changed_date, changed_author, " \
  "  depth, symlink_target, last_mod_time, properties, lock_token, lock_owner, " \
  "  lock_comment, lock_date, local_relpath " \
  "FROM nodes " \
  "LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id " \
  "  AND nodes.repos_path = lock.repos_relpath " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_SELECT_NODE_CHILDREN_WALKER_INFO 12
#define STMT_12 \
  "SELECT local_relpath, op_depth, presence, kind " \
  "FROM nodes_current " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_SELECT_ACTUAL_CHILDREN_INFO 13
#define STMT_13 \
  "SELECT prop_reject, changelist, conflict_old, conflict_new, " \
  "conflict_working, tree_conflict_data, properties, local_relpath, " \
  "conflict_data " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_SELECT_REPOSITORY_BY_ID 14
#define STMT_14 \
  "SELECT root, uuid FROM repository WHERE id = ?1 " \
  ""

#define STMT_SELECT_WCROOT_NULL 15
#define STMT_15 \
  "SELECT id FROM wcroot WHERE local_abspath IS NULL " \
  ""

#define STMT_SELECT_REPOSITORY 16
#define STMT_16 \
  "SELECT id FROM repository WHERE root = ?1 " \
  ""

#define STMT_INSERT_REPOSITORY 17
#define STMT_17 \
  "INSERT INTO repository (root, uuid) VALUES (?1, ?2) " \
  ""

#define STMT_INSERT_NODE 18
#define STMT_18 \
  "INSERT OR REPLACE INTO nodes ( " \
  "  wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, " \
  "  revision, presence, depth, kind, changed_revision, changed_date, " \
  "  changed_author, checksum, properties, translated_size, last_mod_time, " \
  "  dav_cache, symlink_target, file_external) " \
  "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, " \
  "        ?15, ?16, ?17, ?18, ?19, ?20) " \
  ""

#define STMT_SELECT_OP_DEPTH_CHILDREN 19
#define STMT_19 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = ?3 " \
  "  AND (?3 != 0 OR file_external is NULL) " \
  ""

#define STMT_SELECT_GE_OP_DEPTH_CHILDREN 20
#define STMT_20 \
  "SELECT 1 FROM nodes " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  "  AND (op_depth > ?3 OR (op_depth = ?3 AND presence != 'base-deleted')) " \
  "UNION " \
  "SELECT 1 FROM ACTUAL_NODE " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_DELETE_SHADOWED_RECURSIVE 21
#define STMT_21 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND (op_depth < ?3 " \
  "       OR (op_depth = ?3 AND presence = 'base-deleted')) " \
  ""

#define STMT_SELECT_NOT_PRESENT_DESCENDANTS 22
#define STMT_22 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 AND op_depth = ?3 " \
  "  AND (parent_relpath = ?2 " \
  "       OR ((parent_relpath) > (?2) || '/' AND (parent_relpath) < (?2) || '0') ) " \
  "  AND presence == 'not-present' " \
  ""

#define STMT_COMMIT_DESCENDANT_TO_BASE 23
#define STMT_23 \
  "UPDATE NODES SET op_depth = 0, repos_id = ?4, repos_path = ?5, revision = ?6, " \
  "  moved_here = NULL, moved_to = NULL, dav_cache = NULL, " \
  "  presence = CASE presence WHEN 'normal' THEN 'normal' " \
  "                           WHEN 'excluded' THEN 'excluded' " \
  "                           ELSE 'not-present' END " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 and op_depth = ?3 " \
  ""

#define STMT_SELECT_NODE_CHILDREN 24
#define STMT_24 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_SELECT_WORKING_CHILDREN 25
#define STMT_25 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  "  AND (op_depth > (SELECT MAX(op_depth) FROM nodes " \
  "                   WHERE wc_id = ?1 AND local_relpath = ?2) " \
  "       OR " \
  "       (op_depth = (SELECT MAX(op_depth) FROM nodes " \
  "                    WHERE wc_id = ?1 AND local_relpath = ?2) " \
  "        AND presence != 'base-deleted')) " \
  ""

#define STMT_SELECT_BASE_PROPS 26
#define STMT_26 \
  "SELECT properties FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_NODE_PROPS 27
#define STMT_27 \
  "SELECT properties, presence FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "ORDER BY op_depth DESC " \
  ""

#define STMT_SELECT_ACTUAL_PROPS 28
#define STMT_28 \
  "SELECT properties FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_UPDATE_NODE_BASE_PROPS 29
#define STMT_29 \
  "UPDATE nodes SET properties = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_UPDATE_NODE_WORKING_PROPS 30
#define STMT_30 \
  "UPDATE nodes SET properties = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "  AND op_depth = " \
  "   (SELECT MAX(op_depth) FROM nodes " \
  "    WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0) " \
  ""

#define STMT_UPDATE_ACTUAL_PROPS 31
#define STMT_31 \
  "UPDATE actual_node SET properties = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_ACTUAL_PROPS 32
#define STMT_32 \
  "INSERT INTO actual_node (wc_id, local_relpath, parent_relpath, properties) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_INSERT_LOCK 33
#define STMT_33 \
  "INSERT OR REPLACE INTO lock " \
  "(repos_id, repos_relpath, lock_token, lock_owner, lock_comment, " \
  " lock_date) " \
  "VALUES (?1, ?2, ?3, ?4, ?5, ?6) " \
  ""

#define STMT_SELECT_BASE_NODE_LOCK_TOKENS_RECURSIVE 34
#define STMT_34 \
  "SELECT nodes.repos_id, nodes.repos_path, lock_token " \
  "FROM nodes " \
  "LEFT JOIN lock ON nodes.repos_id = lock.repos_id " \
  "  AND nodes.repos_path = lock.repos_relpath " \
  "WHERE wc_id = ?1 AND op_depth = 0 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_INSERT_WCROOT 35
#define STMT_35 \
  "INSERT INTO wcroot (local_abspath) " \
  "VALUES (?1) " \
  ""

#define STMT_UPDATE_BASE_NODE_DAV_CACHE 36
#define STMT_36 \
  "UPDATE nodes SET dav_cache = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_BASE_DAV_CACHE 37
#define STMT_37 \
  "SELECT dav_cache FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_SELECT_DELETION_INFO 38
#define STMT_38 \
  "SELECT nodes_base.presence, nodes_work.presence, nodes_work.moved_to, " \
  "       nodes_work.op_depth " \
  "FROM nodes AS nodes_work " \
  "LEFT OUTER JOIN nodes nodes_base ON nodes_base.wc_id = nodes_work.wc_id " \
  "  AND nodes_base.local_relpath = nodes_work.local_relpath " \
  "  AND nodes_base.op_depth = 0 " \
  "WHERE nodes_work.wc_id = ?1 AND nodes_work.local_relpath = ?2 " \
  "  AND nodes_work.op_depth = (SELECT MAX(op_depth) FROM nodes " \
  "                             WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "                                              AND op_depth > 0) " \
  ""

#define STMT_DELETE_LOCK 39
#define STMT_39 \
  "DELETE FROM lock " \
  "WHERE repos_id = ?1 AND repos_relpath = ?2 " \
  ""

#define STMT_CLEAR_BASE_NODE_RECURSIVE_DAV_CACHE 40
#define STMT_40 \
  "UPDATE nodes SET dav_cache = NULL " \
  "WHERE dav_cache IS NOT NULL AND wc_id = ?1 AND op_depth = 0 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_RECURSIVE_UPDATE_NODE_REPO 41
#define STMT_41 \
  "UPDATE nodes SET repos_id = ?4, dav_cache = NULL " \
  "WHERE wc_id = ?1 " \
  "  AND repos_id = ?3 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_UPDATE_LOCK_REPOS_ID 42
#define STMT_42 \
  "UPDATE lock SET repos_id = ?2 " \
  "WHERE repos_id = ?1 " \
  ""

#define STMT_UPDATE_NODE_FILEINFO 43
#define STMT_43 \
  "UPDATE nodes SET translated_size = ?3, last_mod_time = ?4 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "  AND op_depth = (SELECT MAX(op_depth) FROM nodes " \
  "                  WHERE wc_id = ?1 AND local_relpath = ?2) " \
  ""

#define STMT_UPDATE_ACTUAL_TREE_CONFLICTS 44
#define STMT_44 \
  "UPDATE actual_node SET tree_conflict_data = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_ACTUAL_TREE_CONFLICTS 45
#define STMT_45 \
  "INSERT INTO actual_node ( " \
  "  wc_id, local_relpath, tree_conflict_data, parent_relpath) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_UPDATE_ACTUAL_TEXT_CONFLICTS 46
#define STMT_46 \
  "UPDATE actual_node SET conflict_old = ?3, conflict_new = ?4, " \
  "  conflict_working = ?5 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_ACTUAL_TEXT_CONFLICTS 47
#define STMT_47 \
  "INSERT INTO actual_node ( " \
  "  wc_id, local_relpath, conflict_old, conflict_new, conflict_working, " \
  "  parent_relpath) " \
  "VALUES (?1, ?2, ?3, ?4, ?5, ?6) " \
  ""

#define STMT_UPDATE_ACTUAL_PROPERTY_CONFLICTS 48
#define STMT_48 \
  "UPDATE actual_node SET prop_reject = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_ACTUAL_PROPERTY_CONFLICTS 49
#define STMT_49 \
  "INSERT INTO actual_node ( " \
  "  wc_id, local_relpath, prop_reject, parent_relpath) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_UPDATE_ACTUAL_CHANGELISTS 50
#define STMT_50 \
  "UPDATE actual_node SET changelist = ?2 " \
  "WHERE wc_id = ?1 AND local_relpath IN " \
  "(SELECT local_relpath FROM targets_list WHERE kind = 'file' AND wc_id = ?1) " \
  ""

#define STMT_UPDATE_ACTUAL_CLEAR_CHANGELIST 51
#define STMT_51 \
  "UPDATE actual_node SET changelist = NULL " \
  " WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_MARK_SKIPPED_CHANGELIST_DIRS 52
#define STMT_52 \
  "INSERT INTO changelist_list (wc_id, local_relpath, notify, changelist) " \
  "SELECT wc_id, local_relpath, 7, ?1 FROM targets_list WHERE kind = 'dir' " \
  ""

#define STMT_RESET_ACTUAL_WITH_CHANGELIST 53
#define STMT_53 \
  "REPLACE INTO actual_node ( " \
  "  wc_id, local_relpath, parent_relpath, changelist) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_CREATE_CHANGELIST_LIST 54
#define STMT_54 \
  "DROP TABLE IF EXISTS changelist_list; " \
  "CREATE TEMPORARY TABLE changelist_list ( " \
  "  wc_id  INTEGER NOT NULL, " \
  "  local_relpath TEXT NOT NULL, " \
  "  notify INTEGER, " \
  "  changelist TEXT NOT NULL " \
  "  ); " \
  "CREATE INDEX changelist_list_index ON changelist_list(wc_id, local_relpath); " \
  "DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_insert; " \
  "CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_insert " \
  "BEFORE INSERT ON actual_node " \
  "BEGIN " \
  "    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist) " \
  "    VALUES (NEW.wc_id, NEW.local_relpath, 26, NEW.changelist); " \
  "END; " \
  "DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_clear; " \
  "CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_clear " \
  "BEFORE UPDATE ON actual_node " \
  "WHEN OLD.changelist IS NOT NULL AND " \
  "        (OLD.changelist != NEW.changelist OR NEW.changelist IS NULL) " \
  "BEGIN " \
  "    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist) " \
  "    VALUES (OLD.wc_id, OLD.local_relpath, 27, OLD.changelist); " \
  "END; " \
  "DROP TRIGGER IF EXISTS   trigger_changelist_list_actual_cl_set; " \
  "CREATE TEMPORARY TRIGGER trigger_changelist_list_actual_cl_set " \
  "BEFORE UPDATE ON actual_node " \
  "WHEN NEW.CHANGELIST IS NOT NULL AND " \
  "        (OLD.changelist != NEW.changelist OR OLD.changelist IS NULL) " \
  "BEGIN " \
  "    INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist) " \
  "    VALUES (NEW.wc_id, NEW.local_relpath, 26, NEW.changelist); " \
  "END " \
  ""

#define STMT_INSERT_CHANGELIST_LIST 55
#define STMT_55 \
  "INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_FINALIZE_CHANGELIST 56
#define STMT_56 \
  "DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_insert; " \
  "DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_set; " \
  "DROP TRIGGER IF EXISTS trigger_changelist_list_actual_cl_clear; " \
  "DROP TABLE IF EXISTS changelist_list; " \
  "DROP TABLE IF EXISTS targets_list " \
  ""

#define STMT_SELECT_CHANGELIST_LIST 57
#define STMT_57 \
  "SELECT wc_id, local_relpath, notify, changelist " \
  "FROM changelist_list " \
  "ORDER BY wc_id, local_relpath " \
  ""

#define STMT_CREATE_TARGETS_LIST 58
#define STMT_58 \
  "DROP TABLE IF EXISTS targets_list; " \
  "CREATE TEMPORARY TABLE targets_list ( " \
  "  wc_id  INTEGER NOT NULL, " \
  "  local_relpath TEXT NOT NULL, " \
  "  parent_relpath TEXT, " \
  "  kind TEXT NOT NULL " \
  "  ); " \
  "CREATE INDEX targets_list_kind " \
  "  ON targets_list (kind) " \
  ""

#define STMT_DROP_TARGETS_LIST 59
#define STMT_59 \
  "DROP TABLE IF EXISTS targets_list " \
  ""

#define STMT_INSERT_TARGET 60
#define STMT_60 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT wc_id, local_relpath, parent_relpath, kind " \
  "FROM nodes_current WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_TARGET_DEPTH_FILES 61
#define STMT_61 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT wc_id, local_relpath, parent_relpath, kind " \
  "FROM nodes_current " \
  "WHERE wc_id = ?1 AND ((parent_relpath = ?2 AND kind = 'file') " \
  "                      OR local_relpath = ?2) " \
  ""

#define STMT_INSERT_TARGET_DEPTH_IMMEDIATES 62
#define STMT_62 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT wc_id, local_relpath, parent_relpath, kind " \
  "FROM nodes_current " \
  "WHERE wc_id = ?1 AND (parent_relpath = ?2 OR local_relpath = ?2) " \
  ""

#define STMT_INSERT_TARGET_DEPTH_INFINITY 63
#define STMT_63 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT wc_id, local_relpath, parent_relpath, kind " \
  "FROM nodes_current " \
  "WHERE wc_id = ?1 " \
  "       AND (?2 = '' " \
  "            OR local_relpath = ?2 " \
  "            OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_INSERT_TARGET_WITH_CHANGELIST 64
#define STMT_64 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind " \
  "  FROM actual_node AS A JOIN nodes_current AS N " \
  "    ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath " \
  " WHERE N.wc_id = ?1 AND A.changelist = ?3 AND N.local_relpath = ?2 " \
  ""

#define STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_FILES 65
#define STMT_65 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind " \
  "  FROM actual_node AS A JOIN nodes_current AS N " \
  "    ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath " \
  " WHERE N.wc_id = ?1 AND A.changelist = ?3 " \
  "       AND ((N.parent_relpath = ?2 AND kind = 'file') OR N.local_relpath = ?2) " \
  ""

#define STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES 66
#define STMT_66 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind " \
  "  FROM actual_node AS A JOIN nodes_current AS N " \
  "    ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath " \
  " WHERE N.wc_id = ?1 AND A.changelist = ?3 " \
  "       AND (N.parent_relpath = ?2 OR N.local_relpath = ?2) " \
  ""

#define STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_INFINITY 67
#define STMT_67 \
  "INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind) " \
  "SELECT N.wc_id, N.local_relpath, N.parent_relpath, N.kind " \
  "  FROM actual_node AS A JOIN nodes_current AS N " \
  "    ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath " \
  " WHERE N.wc_id = ?1 " \
  "       AND (?2 = '' " \
  "            OR N.local_relpath = ?2 " \
  "            OR ((N.local_relpath) > (?2) || '/' AND (N.local_relpath) < (?2) || '0') ) " \
  "       AND A.changelist = ?3 " \
  ""

#define STMT_SELECT_TARGETS 68
#define STMT_68 \
  "SELECT local_relpath, parent_relpath from targets_list " \
  ""

#define STMT_INSERT_ACTUAL_EMPTIES 69
#define STMT_69 \
  "INSERT OR IGNORE INTO actual_node ( " \
  "     wc_id, local_relpath, parent_relpath, properties, " \
  "     conflict_old, conflict_new, conflict_working, " \
  "     prop_reject, changelist, text_mod, tree_conflict_data ) " \
  "SELECT wc_id, local_relpath, parent_relpath, NULL, NULL, NULL, NULL, " \
  "       NULL, NULL, NULL, NULL " \
  "FROM targets_list " \
  ""

#define STMT_DELETE_ACTUAL_EMPTY 70
#define STMT_70 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "  AND properties IS NULL " \
  "  AND conflict_old IS NULL " \
  "  AND conflict_new IS NULL " \
  "  AND prop_reject IS NULL " \
  "  AND changelist IS NULL " \
  "  AND text_mod IS NULL " \
  "  AND tree_conflict_data IS NULL " \
  "  AND older_checksum IS NULL " \
  "  AND right_checksum IS NULL " \
  "  AND left_checksum IS NULL " \
  ""

#define STMT_DELETE_ACTUAL_EMPTIES 71
#define STMT_71 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 " \
  "  AND properties IS NULL " \
  "  AND conflict_old IS NULL " \
  "  AND conflict_new IS NULL " \
  "  AND prop_reject IS NULL " \
  "  AND changelist IS NULL " \
  "  AND text_mod IS NULL " \
  "  AND tree_conflict_data IS NULL " \
  "  AND older_checksum IS NULL " \
  "  AND right_checksum IS NULL " \
  "  AND left_checksum IS NULL " \
  ""

#define STMT_DELETE_BASE_NODE 72
#define STMT_72 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_DELETE_WORKING_NODE 73
#define STMT_73 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "  AND op_depth = (SELECT MAX(op_depth) FROM nodes " \
  "                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0) " \
  ""

#define STMT_DELETE_LOWEST_WORKING_NODE 74
#define STMT_74 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "  AND op_depth = (SELECT MIN(op_depth) FROM nodes " \
  "                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0) " \
  "  AND presence = 'base-deleted' " \
  ""

#define STMT_DELETE_ALL_LAYERS 75
#define STMT_75 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_DELETE_NODES_RECURSIVE 76
#define STMT_76 \
  "DELETE FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth >= ?3 " \
  ""

#define STMT_DELETE_ACTUAL_NODE 77
#define STMT_77 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_DELETE_ACTUAL_NODE_RECURSIVE 78
#define STMT_78 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_DELETE_ACTUAL_NODE_WITHOUT_CONFLICT 79
#define STMT_79 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "      AND tree_conflict_data IS NULL " \
  ""

#define STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST 80
#define STMT_80 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 " \
  "  AND local_relpath = ?2 " \
  "  AND (changelist IS NULL " \
  "       OR NOT EXISTS (SELECT 1 FROM nodes_current c " \
  "                      WHERE c.wc_id = ?1 AND c.local_relpath = ?2 " \
  "                        AND c.kind = 'file')) " \
  ""

#define STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE 81
#define STMT_81 \
  "DELETE FROM actual_node " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND (changelist IS NULL " \
  "       OR NOT EXISTS (SELECT 1 FROM nodes_current c " \
  "                      WHERE c.wc_id = ?1 " \
  "                        AND c.local_relpath = actual_node.local_relpath " \
  "                        AND c.kind = 'file')) " \
  ""

#define STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST 82
#define STMT_82 \
  "UPDATE actual_node " \
  "SET properties = NULL, " \
  "    text_mod = NULL, " \
  "    tree_conflict_data = NULL, " \
  "    conflict_old = NULL, " \
  "    conflict_new = NULL, " \
  "    conflict_working = NULL, " \
  "    prop_reject = NULL, " \
  "    older_checksum = NULL, " \
  "    left_checksum = NULL, " \
  "    right_checksum = NULL " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE 83
#define STMT_83 \
  "UPDATE actual_node " \
  "SET properties = NULL, " \
  "    text_mod = NULL, " \
  "    tree_conflict_data = NULL, " \
  "    conflict_old = NULL, " \
  "    conflict_new = NULL, " \
  "    conflict_working = NULL, " \
  "    prop_reject = NULL, " \
  "    older_checksum = NULL, " \
  "    left_checksum = NULL, " \
  "    right_checksum = NULL " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_UPDATE_NODE_BASE_DEPTH 84
#define STMT_84 \
  "UPDATE nodes SET depth = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  "  AND kind='dir' " \
  ""

#define STMT_UPDATE_NODE_BASE_PRESENCE 85
#define STMT_85 \
  "UPDATE nodes SET presence = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_UPDATE_BASE_NODE_PRESENCE_REVNUM_AND_REPOS_PATH 86
#define STMT_86 \
  "UPDATE nodes SET presence = ?3, revision = ?4, repos_path = ?5 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_LOOK_FOR_WORK 87
#define STMT_87 \
  "SELECT id FROM work_queue LIMIT 1 " \
  ""

#define STMT_INSERT_WORK_ITEM 88
#define STMT_88 \
  "INSERT INTO work_queue (work) VALUES (?1) " \
  ""

#define STMT_SELECT_WORK_ITEM 89
#define STMT_89 \
  "SELECT id, work FROM work_queue ORDER BY id LIMIT 1 " \
  ""

#define STMT_DELETE_WORK_ITEM 90
#define STMT_90 \
  "DELETE FROM work_queue WHERE id = ?1 " \
  ""

#define STMT_INSERT_OR_IGNORE_PRISTINE 91
#define STMT_91 \
  "INSERT OR IGNORE INTO pristine (checksum, md5_checksum, size, refcount) " \
  "VALUES (?1, ?2, ?3, 0) " \
  ""

#define STMT_INSERT_PRISTINE 92
#define STMT_92 \
  "INSERT INTO pristine (checksum, md5_checksum, size, refcount) " \
  "VALUES (?1, ?2, ?3, 0) " \
  ""

#define STMT_SELECT_PRISTINE 93
#define STMT_93 \
  "SELECT md5_checksum " \
  "FROM pristine " \
  "WHERE checksum = ?1 " \
  ""

#define STMT_SELECT_PRISTINE_SIZE 94
#define STMT_94 \
  "SELECT size " \
  "FROM pristine " \
  "WHERE checksum = ?1 LIMIT 1 " \
  ""

#define STMT_SELECT_PRISTINE_BY_MD5 95
#define STMT_95 \
  "SELECT checksum " \
  "FROM pristine " \
  "WHERE md5_checksum = ?1 " \
  ""

#define STMT_SELECT_UNREFERENCED_PRISTINES 96
#define STMT_96 \
  "SELECT checksum " \
  "FROM pristine " \
  "WHERE refcount = 0 " \
  ""

#define STMT_DELETE_PRISTINE_IF_UNREFERENCED 97
#define STMT_97 \
  "DELETE FROM pristine " \
  "WHERE checksum = ?1 AND refcount = 0 " \
  ""

#define STMT_SELECT_ACTUAL_CONFLICT_VICTIMS 98
#define STMT_98 \
  "SELECT local_relpath " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 AND " \
  "  NOT ((prop_reject IS NULL) AND (conflict_old IS NULL) " \
  "       AND (conflict_new IS NULL) AND (conflict_working IS NULL) " \
  "       AND (tree_conflict_data IS NULL)) " \
  ""

#define STMT_SELECT_CONFLICT_MARKER_FILES 99
#define STMT_99 \
  "SELECT prop_reject, conflict_old, conflict_new, conflict_working " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND (local_relpath = ?2 OR parent_relpath = ?2) " \
  "  AND ((prop_reject IS NOT NULL) OR (conflict_old IS NOT NULL) " \
  "       OR (conflict_new IS NOT NULL) OR (conflict_working IS NOT NULL)) " \
  ""

#define STMT_SELECT_ACTUAL_CHILDREN_TREE_CONFLICT 100
#define STMT_100 \
  "SELECT local_relpath, tree_conflict_data " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 AND tree_conflict_data IS NOT NULL " \
  ""

#define STMT_SELECT_CONFLICT_DETAILS 101
#define STMT_101 \
  "SELECT prop_reject, conflict_old, conflict_new, conflict_working, " \
  "    tree_conflict_data " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_CLEAR_TEXT_CONFLICT 102
#define STMT_102 \
  "UPDATE actual_node SET " \
  "  conflict_old = NULL, " \
  "  conflict_new = NULL, " \
  "  conflict_working = NULL " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_CLEAR_PROPS_CONFLICT 103
#define STMT_103 \
  "UPDATE actual_node SET " \
  "  prop_reject = NULL " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_WC_LOCK 104
#define STMT_104 \
  "INSERT INTO wc_lock (wc_id, local_dir_relpath, locked_levels) " \
  "VALUES (?1, ?2, ?3) " \
  ""

#define STMT_SELECT_WC_LOCK 105
#define STMT_105 \
  "SELECT locked_levels FROM wc_lock " \
  "WHERE wc_id = ?1 AND local_dir_relpath = ?2 " \
  ""

#define STMT_SELECT_ANCESTOR_WCLOCKS 106
#define STMT_106 \
  "SELECT local_dir_relpath, locked_levels FROM wc_lock " \
  "WHERE wc_id = ?1 " \
  "  AND ((local_dir_relpath <= ?2 AND local_dir_relpath >= ?3) " \
  "       OR local_dir_relpath = '') " \
  "ORDER BY local_dir_relpath DESC " \
  ""

#define STMT_DELETE_WC_LOCK 107
#define STMT_107 \
  "DELETE FROM wc_lock " \
  "WHERE wc_id = ?1 AND local_dir_relpath = ?2 " \
  ""

#define STMT_FIND_WC_LOCK 108
#define STMT_108 \
  "SELECT local_dir_relpath FROM wc_lock " \
  "WHERE wc_id = ?1 AND local_dir_relpath LIKE ?2 ESCAPE '#' " \
  ""

#define STMT_DELETE_WC_LOCK_ORPHAN 109
#define STMT_109 \
  "DELETE FROM wc_lock " \
  "WHERE wc_id = ?1 AND local_dir_relpath = ?2 " \
  "AND NOT EXISTS (SELECT 1 FROM nodes " \
  "                 WHERE nodes.wc_id = ?1 " \
  "                   AND nodes.local_relpath = wc_lock.local_dir_relpath) " \
  ""

#define STMT_DELETE_WC_LOCK_ORPHAN_RECURSIVE 110
#define STMT_110 \
  "DELETE FROM wc_lock " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_dir_relpath = ?2 " \
  "       OR ((local_dir_relpath) > (?2) || '/' AND (local_dir_relpath) < (?2) || '0') ) " \
  "  AND NOT EXISTS (SELECT 1 FROM nodes " \
  "                   WHERE nodes.wc_id = ?1 " \
  "                     AND nodes.local_relpath = wc_lock.local_dir_relpath) " \
  ""

#define STMT_APPLY_CHANGES_TO_BASE_NODE 111
#define STMT_111 \
  "INSERT OR REPLACE INTO nodes ( " \
  "  wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, " \
  "  revision, presence, depth, kind, changed_revision, changed_date, " \
  "  changed_author, checksum, properties, dav_cache, symlink_target, " \
  "  file_external ) " \
  "VALUES (?1, ?2, 0, " \
  "        ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, " \
  "        (SELECT file_external FROM nodes " \
  "          WHERE wc_id = ?1 " \
  "            AND local_relpath = ?2 " \
  "            AND op_depth = 0)) " \
  ""

#define STMT_INSTALL_WORKING_NODE_FOR_DELETE 112
#define STMT_112 \
  "INSERT OR REPLACE INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, " \
  "    parent_relpath, presence, kind) " \
  "SELECT wc_id, local_relpath, ?3 , " \
  "       parent_relpath, ?4 , kind " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_INSERT_DELETE_FROM_NODE_RECURSIVE 113
#define STMT_113 \
  "INSERT INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, presence, kind) " \
  "SELECT wc_id, local_relpath, ?4 , parent_relpath, 'base-deleted', " \
  "       kind " \
  "FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth = ?3 " \
  "  AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent') " \
  ""

#define STMT_INSERT_WORKING_NODE_FROM_BASE_COPY 114
#define STMT_114 \
  "INSERT INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, " \
  "    revision, presence, depth, kind, changed_revision, changed_date, " \
  "    changed_author, checksum, properties, translated_size, last_mod_time, " \
  "    symlink_target ) " \
  "SELECT wc_id, local_relpath, ?3 , parent_relpath, repos_id, " \
  "    repos_path, revision, presence, depth, kind, changed_revision, " \
  "    changed_date, changed_author, checksum, properties, translated_size, " \
  "    last_mod_time, symlink_target " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_INSERT_DELETE_FROM_BASE 115
#define STMT_115 \
  "INSERT INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, presence, kind) " \
  "SELECT wc_id, local_relpath, ?3 , parent_relpath, " \
  "    'base-deleted', kind " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_UPDATE_OP_DEPTH_INCREASE_RECURSIVE 116
#define STMT_116 \
  "UPDATE nodes SET op_depth = ?3 + 1 " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  " AND op_depth = ?3 " \
  ""

#define STMT_DOES_NODE_EXIST 117
#define STMT_117 \
  "SELECT 1 FROM nodes WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_SERVER_EXCLUDED_NODES 118
#define STMT_118 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth = 0 AND presence = 'absent' " \
  "LIMIT 1 " \
  ""

#define STMT_SELECT_ALL_SERVER_EXCLUDED_NODES 119
#define STMT_119 \
  "SELECT local_relpath FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth = 0 " \
  "  AND presence = 'absent' " \
  ""

#define STMT_INSERT_WORKING_NODE_COPY_FROM_BASE 120
#define STMT_120 \
  "INSERT OR REPLACE INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, repos_id, " \
  "    repos_path, revision, presence, depth, kind, changed_revision, " \
  "    changed_date, changed_author, checksum, properties, translated_size, " \
  "    last_mod_time, symlink_target ) " \
  "SELECT wc_id, ?3 , ?4 , ?5 , " \
  "    repos_id, repos_path, revision, ?6 , depth, " \
  "    kind, changed_revision, changed_date, changed_author, checksum, properties, " \
  "    translated_size, last_mod_time, symlink_target " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING 121
#define STMT_121 \
  "INSERT OR REPLACE INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, " \
  "    revision, presence, depth, kind, changed_revision, changed_date, " \
  "    changed_author, checksum, properties, translated_size, last_mod_time, " \
  "    symlink_target ) " \
  "SELECT wc_id, ?3 , ?4 , ?5 , " \
  "    repos_id, repos_path, revision, ?6 , depth, " \
  "    kind, changed_revision, changed_date, changed_author, checksum, properties, " \
  "    translated_size, last_mod_time, symlink_target " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0 " \
  "ORDER BY op_depth DESC " \
  "LIMIT 1 " \
  ""

#define STMT_INSERT_WORKING_NODE_COPY_FROM_DEPTH 122
#define STMT_122 \
  "INSERT OR REPLACE INTO nodes ( " \
  "    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, " \
  "    revision, presence, depth, kind, changed_revision, changed_date, " \
  "    changed_author, checksum, properties, translated_size, last_mod_time, " \
  "    symlink_target ) " \
  "SELECT wc_id, ?3 , ?4 , ?5 , " \
  "    repos_id, repos_path, revision, ?6 , " \
  "    depth, kind, changed_revision, changed_date, changed_author, checksum, " \
  "    properties, translated_size, last_mod_time, symlink_target " \
  "FROM nodes " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?7 " \
  ""

#define STMT_INSERT_ACTUAL_NODE_FROM_ACTUAL_NODE 123
#define STMT_123 \
  "INSERT OR REPLACE INTO actual_node ( " \
  "     wc_id, local_relpath, parent_relpath, properties, " \
  "     conflict_old, conflict_new, conflict_working, " \
  "     prop_reject, changelist, text_mod, tree_conflict_data ) " \
  "SELECT wc_id, ?3 , ?4 , properties, " \
  "     conflict_old, conflict_new, conflict_working, " \
  "     prop_reject, changelist, text_mod, tree_conflict_data " \
  "FROM actual_node " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_UPDATE_BASE_REVISION 124
#define STMT_124 \
  "UPDATE nodes SET revision = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_UPDATE_BASE_REPOS 125
#define STMT_125 \
  "UPDATE nodes SET repos_id = ?3, repos_path = ?4 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0 " \
  ""

#define STMT_ACTUAL_HAS_CHILDREN 126
#define STMT_126 \
  "SELECT 1 FROM actual_node " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  "LIMIT 1 " \
  ""

#define STMT_INSERT_EXTERNAL 127
#define STMT_127 \
  "INSERT OR REPLACE INTO externals ( " \
  "    wc_id, local_relpath, parent_relpath, presence, kind, def_local_relpath, " \
  "    repos_id, def_repos_relpath, def_operational_revision, def_revision) " \
  "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10) " \
  ""

#define STMT_INSERT_EXTERNAL_UPGRADE 128
#define STMT_128 \
  "INSERT OR REPLACE INTO externals ( " \
  "    wc_id, local_relpath, parent_relpath, presence, kind, def_local_relpath, " \
  "    repos_id, def_repos_relpath, def_operational_revision, def_revision) " \
  "VALUES (?1, ?2, ?3, ?4, " \
  "        CASE WHEN (SELECT file_external FROM nodes " \
  "                   WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0) " \
  "             IS NOT NULL THEN 'file' ELSE 'unknown' END, " \
  "        ?5, ?6, ?7, ?8, ?9) " \
  ""

#define STMT_SELECT_EXTERNAL_INFO 129
#define STMT_129 \
  "SELECT presence, kind, def_local_relpath, repos_id, " \
  "    def_repos_relpath, def_operational_revision, def_revision, presence " \
  "FROM externals WHERE wc_id = ?1 AND local_relpath = ?2 " \
  "LIMIT 1 " \
  ""

#define STMT_SELECT_EXTERNAL_CHILDREN 130
#define STMT_130 \
  "SELECT local_relpath " \
  "FROM externals WHERE wc_id = ?1 AND parent_relpath = ?2 " \
  ""

#define STMT_SELECT_EXTERNALS_DEFINED 131
#define STMT_131 \
  "SELECT local_relpath, def_local_relpath " \
  "FROM externals " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR def_local_relpath = ?2 " \
  "       OR ((def_local_relpath) > (?2) || '/' AND (def_local_relpath) < (?2) || '0') ) " \
  ""

#define STMT_UPDATE_EXTERNAL_FILEINFO 132
#define STMT_132 \
  "UPDATE externals SET recorded_size = ?3, recorded_mod_time = ?4 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_DELETE_EXTERNAL 133
#define STMT_133 \
  "DELETE FROM externals " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_SELECT_EXTERNAL_PROPERTIES 134
#define STMT_134 \
  "SELECT IFNULL((SELECT properties FROM actual_node a " \
  "               WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath), " \
  "              properties), " \
  "       local_relpath, depth " \
  "FROM nodes n " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND kind = 'dir' AND presence='normal' " \
  "  AND op_depth=(SELECT MAX(op_depth) FROM nodes o " \
  "                WHERE o.wc_id = ?1 AND o.local_relpath = n.local_relpath) " \
  ""

#define STMT_INSERT_ACTUAL_NODE 135
#define STMT_135 \
  "INSERT OR REPLACE INTO actual_node ( " \
  "  wc_id, local_relpath, parent_relpath, properties, conflict_old, " \
  "  conflict_new, " \
  "  conflict_working, prop_reject, changelist, text_mod, " \
  "  tree_conflict_data) " \
  "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, NULL, ?10) " \
  ""

#define STMT_UPDATE_ACTUAL_CONFLICT_DATA 136
#define STMT_136 \
  "UPDATE actual_node SET conflict_data = ?3 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 " \
  ""

#define STMT_INSERT_ACTUAL_CONFLICT_DATA 137
#define STMT_137 \
  "INSERT INTO actual_node ( " \
  "  wc_id, local_relpath, conflict_data, parent_relpath) " \
  "VALUES (?1, ?2, ?3, ?4) " \
  ""

#define STMT_SELECT_OLD_TREE_CONFLICT 138
#define STMT_138 \
  "SELECT wc_id, local_relpath, tree_conflict_data " \
  "FROM actual_node " \
  "WHERE tree_conflict_data IS NOT NULL " \
  ""

#define STMT_ERASE_OLD_CONFLICTS 139
#define STMT_139 \
  "UPDATE actual_node SET tree_conflict_data = NULL " \
  ""

#define STMT_SELECT_ALL_FILES 140
#define STMT_140 \
  "SELECT local_relpath FROM nodes_current " \
  "WHERE wc_id = ?1 AND parent_relpath = ?2 AND kind = 'file' " \
  ""

#define STMT_UPDATE_NODE_PROPS 141
#define STMT_141 \
  "UPDATE nodes SET properties = ?4 " \
  "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3 " \
  ""

#define STMT_HAS_WORKING_NODES 142
#define STMT_142 \
  "SELECT 1 FROM nodes WHERE op_depth > 0 " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_ACTUAL_NODES_CONFLICTS 143
#define STMT_143 \
  "SELECT 1 FROM actual_node " \
  "WHERE NOT ((prop_reject IS NULL) AND (conflict_old IS NULL) " \
  "           AND (conflict_new IS NULL) AND (conflict_working IS NULL) " \
  "           AND (tree_conflict_data IS NULL)) " \
  "LIMIT 1 " \
  ""

#define STMT_CREATE_NODE_PROPS_CACHE 144
#define STMT_144 \
  "DROP TABLE IF EXISTS temp__node_props_cache; " \
  "CREATE TEMPORARY TABLE temp__node_props_cache ( " \
  "  local_Relpath TEXT NOT NULL, " \
  "  kind TEXT NOT NULL, " \
  "  properties BLOB " \
  "  ); " \
  ""

#define STMT_CACHE_NODE_PROPS 145
#define STMT_145 \
  "INSERT INTO temp__node_props_cache(local_relpath, kind, properties) " \
  " SELECT local_relpath, kind, properties FROM nodes_current " \
  "  WHERE wc_id = ?1 " \
  "    AND local_relpath IN (SELECT local_relpath FROM targets_list) " \
  "    AND presence IN ('normal', 'incomplete') " \
  ""

#define STMT_CACHE_ACTUAL_PROPS 146
#define STMT_146 \
  "UPDATE temp__node_props_cache " \
  "   SET properties= " \
  "        IFNULL((SELECT properties FROM actual_node a " \
  "                 WHERE a.wc_id = ?1 " \
  "                   AND a.local_relpath = temp__node_props_cache.local_relpath), " \
  "               properties) " \
  ""

#define STMT_CACHE_NODE_BASE_PROPS 147
#define STMT_147 \
  "INSERT INTO temp__node_props_cache (local_relpath, kind, properties) " \
  "  SELECT local_relpath, kind, properties FROM nodes_base " \
  "  WHERE wc_id = ?1 " \
  "    AND local_relpath IN (SELECT local_relpath FROM targets_list) " \
  "    AND presence IN ('normal', 'incomplete') " \
  ""

#define STMT_CACHE_NODE_PRISTINE_PROPS 148
#define STMT_148 \
  "INSERT INTO temp__node_props_cache(local_relpath, kind, properties) " \
  " SELECT local_relpath, kind, " \
  "        IFNULL((SELECT properties FROM nodes nn " \
  "                 WHERE n.presence = 'base-deleted' " \
  "                   AND nn.wc_id = n.wc_id " \
  "                   AND nn.local_relpath = n.local_relpath " \
  "                   AND nn.op_depth < n.op_depth " \
  "                 ORDER BY op_depth DESC), " \
  "               properties) " \
  "  FROM nodes_current n " \
  "  WHERE wc_id = ?1 " \
  "    AND local_relpath IN (SELECT local_relpath FROM targets_list) " \
  "    AND presence IN ('normal', 'incomplete', 'base-deleted') " \
  ""

#define STMT_SELECT_RELEVANT_PROPS_FROM_CACHE 149
#define STMT_149 \
  "SELECT local_relpath, properties FROM temp__node_props_cache " \
  "ORDER BY local_relpath " \
  ""

#define STMT_DROP_NODE_PROPS_CACHE 150
#define STMT_150 \
  "DROP TABLE IF EXISTS temp__node_props_cache; " \
  ""

#define STMT_CREATE_REVERT_LIST 151
#define STMT_151 \
  "DROP TABLE IF EXISTS revert_list; " \
  "CREATE TEMPORARY TABLE revert_list ( " \
  "   local_relpath TEXT NOT NULL, " \
  "   actual INTEGER NOT NULL, " \
  "   conflict_old TEXT, " \
  "   conflict_new TEXT, " \
  "   conflict_working TEXT, " \
  "   prop_reject TEXT, " \
  "   notify INTEGER, " \
  "   op_depth INTEGER, " \
  "   repos_id INTEGER, " \
  "   kind TEXT, " \
  "   PRIMARY KEY (local_relpath, actual) " \
  "   ); " \
  "DROP TRIGGER IF EXISTS   trigger_revert_list_nodes; " \
  "CREATE TEMPORARY TRIGGER trigger_revert_list_nodes " \
  "BEFORE DELETE ON nodes " \
  "BEGIN " \
  "   INSERT OR REPLACE INTO revert_list(local_relpath, actual, op_depth, " \
  "                                      repos_id, kind) " \
  "   SELECT OLD.local_relpath, 0, OLD.op_depth, OLD.repos_id, OLD.kind; " \
  "END; " \
  "DROP TRIGGER IF EXISTS   trigger_revert_list_actual_delete; " \
  "CREATE TEMPORARY TRIGGER trigger_revert_list_actual_delete " \
  "BEFORE DELETE ON actual_node " \
  "BEGIN " \
  "   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old, " \
  "                                       conflict_new, conflict_working, " \
  "                                       prop_reject, notify) " \
  "   SELECT OLD.local_relpath, 1, " \
  "          OLD.conflict_old, OLD.conflict_new, OLD.conflict_working, " \
  "          OLD.prop_reject, " \
  "          CASE " \
  "          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL " \
  "          THEN 1 ELSE NULL END; " \
  "END; " \
  "DROP TRIGGER IF EXISTS   trigger_revert_list_actual_update; " \
  "CREATE TEMPORARY TRIGGER trigger_revert_list_actual_update " \
  "BEFORE UPDATE ON actual_node " \
  "BEGIN " \
  "   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old, " \
  "                                       conflict_new, conflict_working, " \
  "                                       prop_reject, notify) " \
  "   SELECT OLD.local_relpath, 1, " \
  "          OLD.conflict_old, OLD.conflict_new, OLD.conflict_working, " \
  "          OLD.prop_reject, " \
  "          CASE " \
  "          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL " \
  "          THEN 1 ELSE NULL END; " \
  "END " \
  ""

#define STMT_DROP_REVERT_LIST_TRIGGERS 152
#define STMT_152 \
  "DROP TRIGGER IF EXISTS trigger_revert_list_nodes; " \
  "DROP TRIGGER IF EXISTS trigger_revert_list_actual_delete; " \
  "DROP TRIGGER IF EXISTS trigger_revert_list_actual_update " \
  ""

#define STMT_SELECT_REVERT_LIST 153
#define STMT_153 \
  "SELECT conflict_old, conflict_new, conflict_working, prop_reject, notify, " \
  "       actual, op_depth, repos_id, kind " \
  "FROM revert_list " \
  "WHERE local_relpath = ?1 " \
  "ORDER BY actual DESC " \
  ""

#define STMT_SELECT_REVERT_LIST_COPIED_CHILDREN 154
#define STMT_154 \
  "SELECT local_relpath, kind " \
  "FROM revert_list " \
  "WHERE local_relpath LIKE ?1 ESCAPE '#' " \
  "  AND op_depth >= ?2 " \
  "  AND repos_id IS NOT NULL " \
  "ORDER BY local_relpath " \
  ""

#define STMT_DELETE_REVERT_LIST 155
#define STMT_155 \
  "DELETE FROM revert_list WHERE local_relpath = ?1 " \
  ""

#define STMT_SELECT_REVERT_LIST_RECURSIVE 156
#define STMT_156 \
  "SELECT DISTINCT local_relpath " \
  "FROM revert_list " \
  "WHERE (local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#') " \
  "  AND (notify OR actual = 0) " \
  "ORDER BY local_relpath " \
  ""

#define STMT_DELETE_REVERT_LIST_RECURSIVE 157
#define STMT_157 \
  "DELETE FROM revert_list " \
  "WHERE local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#' " \
  ""

#define STMT_DROP_REVERT_LIST 158
#define STMT_158 \
  "DROP TABLE IF EXISTS revert_list " \
  ""

#define STMT_CREATE_DELETE_LIST 159
#define STMT_159 \
  "DROP TABLE IF EXISTS delete_list; " \
  "CREATE TEMPORARY TABLE delete_list ( " \
  "   local_relpath TEXT PRIMARY KEY NOT NULL " \
  "   ) " \
  ""

#define STMT_INSERT_DELETE_LIST 160
#define STMT_160 \
  "INSERT INTO delete_list(local_relpath) " \
  "SELECT local_relpath FROM nodes n " \
  "WHERE wc_id = ?1 " \
  "  AND (local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth >= ?3 " \
  "  AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent') " \
  "  AND op_depth = (SELECT MAX(op_depth) FROM nodes s " \
  "                  WHERE s.wc_id = n.wc_id " \
  "                    AND s.local_relpath = n.local_relpath) " \
  ""

#define STMT_SELECT_DELETE_LIST 161
#define STMT_161 \
  "SELECT local_relpath FROM delete_list " \
  "ORDER BY local_relpath " \
  ""

#define STMT_FINALIZE_DELETE 162
#define STMT_162 \
  "DROP TABLE IF EXISTS delete_list " \
  ""

#define STMT_SELECT_MIN_MAX_REVISIONS 163
#define STMT_163 \
  "SELECT MIN(revision), MAX(revision), " \
  "       MIN(changed_revision), MAX(changed_revision) FROM nodes " \
  "  WHERE wc_id = ?1 " \
  "    AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "    AND presence IN ('normal', 'incomplete') " \
  "    AND file_external IS NULL " \
  "    AND op_depth = 0 " \
  ""

#define STMT_HAS_SPARSE_NODES 164
#define STMT_164 \
  "SELECT 1 FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth = 0 " \
  "  AND (presence IN ('absent', 'excluded') " \
  "        OR depth NOT IN ('infinity', 'unknown')) " \
  "  AND file_external IS NULL " \
  "LIMIT 1 " \
  ""

#define STMT_SUBTREE_HAS_TREE_MODIFICATIONS 165
#define STMT_165 \
  "SELECT 1 FROM nodes " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth > 0 " \
  "LIMIT 1 " \
  ""

#define STMT_SUBTREE_HAS_PROP_MODIFICATIONS 166
#define STMT_166 \
  "SELECT 1 FROM actual_node " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND properties IS NOT NULL " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_SWITCHED 167
#define STMT_167 \
  "SELECT o.repos_path || '/' || SUBSTR(s.local_relpath, LENGTH(?2)+2) AS expected " \
  "FROM nodes AS o " \
  "LEFT JOIN nodes AS s " \
  "ON o.wc_id = s.wc_id " \
  "   AND ((s.local_relpath) > (?2) || '/' AND (s.local_relpath) < (?2) || '0') " \
  "   AND s.op_depth = 0 " \
  "   AND s.repos_id = o.repos_id " \
  "   AND s.file_external IS NULL " \
  "WHERE o.wc_id = ?1 AND o.local_relpath=?2 AND o.op_depth=0 " \
  "  AND s.repos_path != expected " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_SWITCHED_REPOS_ROOT 168
#define STMT_168 \
  "SELECT SUBSTR(s.local_relpath, LENGTH(?2)+2) AS expected " \
  "FROM nodes AS o " \
  "LEFT JOIN nodes AS s " \
  "ON o.wc_id = s.wc_id " \
  "   AND ((s.local_relpath) > (?2) || '/' AND (s.local_relpath) < (?2) || '0') " \
  "   AND s.op_depth = 0 " \
  "   AND s.repos_id = o.repos_id " \
  "   AND s.file_external IS NULL " \
  "WHERE o.wc_id = ?1 AND o.local_relpath=?2 AND o.op_depth=0 " \
  "  AND s.repos_path != expected " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_SWITCHED_WCROOT 169
#define STMT_169 \
  "SELECT o.repos_path || '/' || s.local_relpath AS expected " \
  "FROM nodes AS o " \
  "LEFT JOIN nodes AS s " \
  "ON o.wc_id = s.wc_id " \
  "   AND s.local_relpath != '' " \
  "   AND s.op_depth = 0 " \
  "   AND s.repos_id = o.repos_id " \
  "   AND s.file_external IS NULL " \
  "WHERE o.wc_id = ?1 AND o.local_relpath=?2 AND o.op_depth=0 " \
  "  AND s.repos_path != expected " \
  "LIMIT 1 " \
  ""

#define STMT_HAS_SWITCHED_WCROOT_REPOS_ROOT 170
#define STMT_170 \
  "SELECT s.local_relpath AS expected " \
  "FROM nodes AS o " \
  "LEFT JOIN nodes AS s " \
  "ON o.wc_id = s.wc_id " \
  "   AND s.local_relpath != '' " \
  "   AND s.op_depth = 0 " \
  "   AND s.repos_id = o.repos_id " \
  "   AND s.file_external IS NULL " \
  "WHERE o.wc_id = ?1 AND o.local_relpath=?2 AND o.op_depth=0 " \
  "  AND s.repos_path != expected " \
  "LIMIT 1 " \
  ""

#define STMT_SELECT_BASE_FILES_RECURSIVE 171
#define STMT_171 \
  "SELECT local_relpath, translated_size, last_mod_time FROM nodes AS n " \
  "WHERE wc_id = ?1 " \
  "  AND (?2 = '' " \
  "       OR local_relpath = ?2 " \
  "       OR ((local_relpath) > (?2) || '/' AND (local_relpath) < (?2) || '0') ) " \
  "  AND op_depth = 0 " \
  "  AND kind='file' " \
  "  AND presence='normal' " \
  "  AND file_external IS NULL " \
  ""

#define STMT_SELECT_ALL_NODES 172
#define STMT_172 \
  "SELECT op_depth, local_relpath, parent_relpath, file_external FROM nodes " \
  "WHERE wc_id == ?1 " \
  ""

#define STMT_CREATE_SCHEMA 173
#define STMT_173 \
  "CREATE TABLE REPOSITORY ( " \
  "  id INTEGER PRIMARY KEY AUTOINCREMENT, " \
  "  root  TEXT UNIQUE NOT NULL, " \
  "  uuid  TEXT NOT NULL " \
  "  ); " \
  "CREATE INDEX I_UUID ON REPOSITORY (uuid); " \
  "CREATE INDEX I_ROOT ON REPOSITORY (root); " \
  "CREATE TABLE WCROOT ( " \
  "  id  INTEGER PRIMARY KEY AUTOINCREMENT, " \
  "  local_abspath  TEXT UNIQUE " \
  "  ); " \
  "CREATE UNIQUE INDEX I_LOCAL_ABSPATH ON WCROOT (local_abspath); " \
  "CREATE TABLE PRISTINE ( " \
  "  checksum  TEXT NOT NULL PRIMARY KEY, " \
  "  compression  INTEGER, " \
  "  size  INTEGER NOT NULL, " \
  "  refcount  INTEGER NOT NULL, " \
  "  md5_checksum  TEXT NOT NULL " \
  "  ); " \
  "CREATE TABLE ACTUAL_NODE ( " \
  "  wc_id  INTEGER NOT NULL REFERENCES WCROOT (id), " \
  "  local_relpath  TEXT NOT NULL, " \
  "  parent_relpath  TEXT, " \
  "  properties  BLOB, " \
  "  conflict_old  TEXT, " \
  "  conflict_new  TEXT, " \
  "  conflict_working  TEXT, " \
  "  prop_reject  TEXT, " \
  "  changelist  TEXT, " \
  "  text_mod  TEXT, " \
  "  tree_conflict_data  TEXT, " \
  "  conflict_data  BLOB, " \
  "  older_checksum  TEXT REFERENCES PRISTINE (checksum), " \
  "  left_checksum  TEXT REFERENCES PRISTINE (checksum), " \
  "  right_checksum  TEXT REFERENCES PRISTINE (checksum), " \
  "  PRIMARY KEY (wc_id, local_relpath) " \
  "  ); " \
  "CREATE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath); " \
  "CREATE INDEX I_ACTUAL_CHANGELIST ON ACTUAL_NODE (changelist); " \
  "CREATE TABLE LOCK ( " \
  "  repos_id  INTEGER NOT NULL REFERENCES REPOSITORY (id), " \
  "  repos_relpath  TEXT NOT NULL, " \
  "  lock_token  TEXT NOT NULL, " \
  "  lock_owner  TEXT, " \
  "  lock_comment  TEXT, " \
  "  lock_date  INTEGER, " \
  "  PRIMARY KEY (repos_id, repos_relpath) " \
  "  ); " \
  "CREATE TABLE WORK_QUEUE ( " \
  "  id  INTEGER PRIMARY KEY AUTOINCREMENT, " \
  "  work  BLOB NOT NULL " \
  "  ); " \
  "CREATE TABLE WC_LOCK ( " \
  "  wc_id  INTEGER NOT NULL  REFERENCES WCROOT (id), " \
  "  local_dir_relpath  TEXT NOT NULL, " \
  "  locked_levels  INTEGER NOT NULL DEFAULT -1, " \
  "  PRIMARY KEY (wc_id, local_dir_relpath) " \
  " ); " \
  "PRAGMA user_version = " \
  APR_STRINGIFY(SVN_WC__VERSION) \
  "; " \
  ""

#define STMT_CREATE_NODES 174
#define STMT_174 \
  "CREATE TABLE NODES ( " \
  "  wc_id  INTEGER NOT NULL REFERENCES WCROOT (id), " \
  "  local_relpath  TEXT NOT NULL, " \
  "  op_depth INTEGER NOT NULL, " \
  "  parent_relpath  TEXT, " \
  "  repos_id  INTEGER REFERENCES REPOSITORY (id), " \
  "  repos_path  TEXT, " \
  "  revision  INTEGER, " \
  "  presence  TEXT NOT NULL, " \
  "  moved_here  INTEGER, " \
  "  moved_to  TEXT, " \
  "  kind  TEXT NOT NULL, " \
  "  properties  BLOB, " \
  "  depth  TEXT, " \
  "  checksum  TEXT REFERENCES PRISTINE (checksum), " \
  "  symlink_target  TEXT, " \
  "  changed_revision  INTEGER, " \
  "  changed_date      INTEGER, " \
  "  changed_author    TEXT, " \
  "  translated_size  INTEGER, " \
  "  last_mod_time  INTEGER, " \
  "  dav_cache  BLOB, " \
  "  file_external  TEXT, " \
  "  PRIMARY KEY (wc_id, local_relpath, op_depth) " \
  "  ); " \
  "CREATE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath, op_depth); " \
  "CREATE VIEW NODES_CURRENT AS " \
  "  SELECT * FROM nodes AS n " \
  "    WHERE op_depth = (SELECT MAX(op_depth) FROM nodes AS n2 " \
  "                      WHERE n2.wc_id = n.wc_id " \
  "                        AND n2.local_relpath = n.local_relpath); " \
  "CREATE VIEW NODES_BASE AS " \
  "  SELECT * FROM nodes " \
  "  WHERE op_depth = 0; " \
  ""

#define STMT_CREATE_NODES_TRIGGERS 175
#define STMT_175 \
  "CREATE TRIGGER nodes_insert_trigger " \
  "AFTER INSERT ON nodes " \
  "WHEN NEW.checksum IS NOT NULL " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount + 1 " \
  "  WHERE checksum = NEW.checksum; " \
  "END; " \
  "CREATE TRIGGER nodes_delete_trigger " \
  "AFTER DELETE ON nodes " \
  "WHEN OLD.checksum IS NOT NULL " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount - 1 " \
  "  WHERE checksum = OLD.checksum; " \
  "END; " \
  "CREATE TRIGGER nodes_update_checksum_trigger " \
  "AFTER UPDATE OF checksum ON nodes " \
  "WHEN NEW.checksum IS NOT OLD.checksum " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount + 1 " \
  "  WHERE checksum = NEW.checksum; " \
  "  UPDATE pristine SET refcount = refcount - 1 " \
  "  WHERE checksum = OLD.checksum; " \
  "END; " \
  ""

#define STMT_CREATE_EXTERNALS 176
#define STMT_176 \
  "CREATE TABLE EXTERNALS ( " \
  "  wc_id  INTEGER NOT NULL REFERENCES WCROOT (id), " \
  "  local_relpath  TEXT NOT NULL, " \
  "  parent_relpath  TEXT NOT NULL, " \
  "  repos_id  INTEGER NOT NULL REFERENCES REPOSITORY (id), " \
  "  presence  TEXT NOT NULL, " \
  "  kind  TEXT NOT NULL, " \
  "  def_local_relpath         TEXT NOT NULL, " \
  "  def_repos_relpath         TEXT NOT NULL, " \
  "  def_operational_revision  TEXT, " \
  "  def_revision              TEXT, " \
  "  PRIMARY KEY (wc_id, local_relpath) " \
  "); " \
  "CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath); " \
  "CREATE UNIQUE INDEX I_EXTERNALS_DEFINED ON EXTERNALS (wc_id, " \
  "                                                      def_local_relpath, " \
  "                                                      local_relpath); " \
  ""

#define STMT_UPGRADE_TO_20 177
#define STMT_177 \
  "UPDATE BASE_NODE SET checksum=(SELECT checksum FROM pristine " \
  "                           WHERE md5_checksum=BASE_NODE.checksum) " \
  "WHERE EXISTS(SELECT 1 FROM pristine WHERE md5_checksum=BASE_NODE.checksum); " \
  "UPDATE WORKING_NODE SET checksum=(SELECT checksum FROM pristine " \
  "                           WHERE md5_checksum=WORKING_NODE.checksum) " \
  "WHERE EXISTS(SELECT 1 FROM pristine WHERE md5_checksum=WORKING_NODE.checksum); " \
  "INSERT INTO NODES ( " \
  "       wc_id, local_relpath, op_depth, parent_relpath, " \
  "       repos_id, repos_path, revision, " \
  "       presence, depth, moved_here, moved_to, kind, " \
  "       changed_revision, changed_date, changed_author, " \
  "       checksum, properties, translated_size, last_mod_time, " \
  "       dav_cache, symlink_target, file_external ) " \
  "SELECT wc_id, local_relpath, 0 , parent_relpath, " \
  "       repos_id, repos_relpath, revnum, " \
  "       presence, depth, NULL , NULL , kind, " \
  "       changed_rev, changed_date, changed_author, " \
  "       checksum, properties, translated_size, last_mod_time, " \
  "       dav_cache, symlink_target, file_external " \
  "FROM BASE_NODE; " \
  "INSERT INTO NODES ( " \
  "       wc_id, local_relpath, op_depth, parent_relpath, " \
  "       repos_id, repos_path, revision, " \
  "       presence, depth, moved_here, moved_to, kind, " \
  "       changed_revision, changed_date, changed_author, " \
  "       checksum, properties, translated_size, last_mod_time, " \
  "       dav_cache, symlink_target, file_external ) " \
  "SELECT wc_id, local_relpath, 2 , parent_relpath, " \
  "       copyfrom_repos_id, copyfrom_repos_path, copyfrom_revnum, " \
  "       presence, depth, NULL , NULL , kind, " \
  "       changed_rev, changed_date, changed_author, " \
  "       checksum, properties, translated_size, last_mod_time, " \
  "       NULL , symlink_target, NULL " \
  "FROM WORKING_NODE; " \
  "DROP TABLE BASE_NODE; " \
  "DROP TABLE WORKING_NODE; " \
  "PRAGMA user_version = 20; " \
  ""

#define STMT_UPGRADE_TO_21 178
#define STMT_178 \
  "PRAGMA user_version = 21; " \
  ""

#define STMT_UPGRADE_TO_22 179
#define STMT_179 \
  "UPDATE actual_node SET tree_conflict_data = conflict_data; " \
  "UPDATE actual_node SET conflict_data = NULL; " \
  "PRAGMA user_version = 22; " \
  ""

#define STMT_UPGRADE_TO_23 180
#define STMT_180 \
  "PRAGMA user_version = 23; " \
  ""

#define STMT_UPGRADE_TO_24 181
#define STMT_181 \
  "UPDATE pristine SET refcount = " \
  "  (SELECT COUNT(*) FROM nodes " \
  "   WHERE checksum = pristine.checksum ); " \
  "PRAGMA user_version = 24; " \
  ""

#define STMT_UPGRADE_TO_25 182
#define STMT_182 \
  "DROP VIEW IF EXISTS NODES_CURRENT; " \
  "CREATE VIEW NODES_CURRENT AS " \
  "  SELECT * FROM nodes " \
  "    JOIN (SELECT wc_id, local_relpath, MAX(op_depth) AS op_depth FROM nodes " \
  "          GROUP BY wc_id, local_relpath) AS filter " \
  "    ON nodes.wc_id = filter.wc_id " \
  "      AND nodes.local_relpath = filter.local_relpath " \
  "      AND nodes.op_depth = filter.op_depth; " \
  "PRAGMA user_version = 25; " \
  ""

#define STMT_UPGRADE_TO_26 183
#define STMT_183 \
  "DROP VIEW IF EXISTS NODES_BASE; " \
  "CREATE VIEW NODES_BASE AS " \
  "  SELECT * FROM nodes " \
  "  WHERE op_depth = 0; " \
  "PRAGMA user_version = 26; " \
  ""

#define STMT_UPGRADE_TO_27 184
#define STMT_184 \
  "PRAGMA user_version = 27; " \
  ""

#define STMT_UPGRADE_TO_28 185
#define STMT_185 \
  "UPDATE NODES SET checksum=(SELECT checksum FROM pristine " \
  "                           WHERE md5_checksum=nodes.checksum) " \
  "WHERE EXISTS(SELECT 1 FROM pristine WHERE md5_checksum=nodes.checksum); " \
  "PRAGMA user_version = 28; " \
  ""

#define STMT_UPGRADE_TO_29 186
#define STMT_186 \
  "DROP TRIGGER IF EXISTS nodes_update_checksum_trigger; " \
  "DROP TRIGGER IF EXISTS nodes_insert_trigger; " \
  "DROP TRIGGER IF EXISTS nodes_delete_trigger; " \
  "CREATE TRIGGER nodes_update_checksum_trigger " \
  "AFTER UPDATE OF checksum ON nodes " \
  "WHEN NEW.checksum IS NOT OLD.checksum " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount + 1 " \
  "  WHERE checksum = NEW.checksum; " \
  "  UPDATE pristine SET refcount = refcount - 1 " \
  "  WHERE checksum = OLD.checksum; " \
  "END; " \
  "CREATE TRIGGER nodes_insert_trigger " \
  "AFTER INSERT ON nodes " \
  "WHEN NEW.checksum IS NOT NULL " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount + 1 " \
  "  WHERE checksum = NEW.checksum; " \
  "END; " \
  "CREATE TRIGGER nodes_delete_trigger " \
  "AFTER DELETE ON nodes " \
  "WHEN OLD.checksum IS NOT NULL " \
  "BEGIN " \
  "  UPDATE pristine SET refcount = refcount - 1 " \
  "  WHERE checksum = OLD.checksum; " \
  "END; " \
  "PRAGMA user_version = 29; " \
  "-- format: YYY " \
  ""

#define WC_QUERIES_SQL_99 \
  "CREATE TABLE ACTUAL_NODE_BACKUP ( " \
  "  wc_id  INTEGER NOT NULL, " \
  "  local_relpath  TEXT NOT NULL, " \
  "  parent_relpath  TEXT, " \
  "  properties  BLOB, " \
  "  conflict_old  TEXT, " \
  "  conflict_new  TEXT, " \
  "  conflict_working  TEXT, " \
  "  prop_reject  TEXT, " \
  "  changelist  TEXT, " \
  "  text_mod  TEXT " \
  "  ); " \
  "INSERT INTO ACTUAL_NODE_BACKUP SELECT " \
  "  wc_id, local_relpath, parent_relpath, properties, conflict_old, " \
  "  conflict_new, conflict_working, prop_reject, changelist, text_mod " \
  "FROM ACTUAL_NODE; " \
  "DROP TABLE ACTUAL_NODE; " \
  "CREATE TABLE ACTUAL_NODE ( " \
  "  wc_id  INTEGER NOT NULL REFERENCES WCROOT (id), " \
  "  local_relpath  TEXT NOT NULL, " \
  "  parent_relpath  TEXT, " \
  "  properties  BLOB, " \
  "  conflict_old  TEXT, " \
  "  conflict_new  TEXT, " \
  "  conflict_working  TEXT, " \
  "  prop_reject  TEXT, " \
  "  changelist  TEXT, " \
  "  text_mod  TEXT, " \
  "  PRIMARY KEY (wc_id, local_relpath) " \
  "  ); " \
  "CREATE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath); " \
  "CREATE INDEX I_ACTUAL_CHANGELIST ON ACTUAL_NODE (changelist); " \
  "INSERT INTO ACTUAL_NODE SELECT " \
  "  wc_id, local_relpath, parent_relpath, properties, conflict_old, " \
  "  conflict_new, conflict_working, prop_reject, changelist, text_mod " \
  "FROM ACTUAL_NODE_BACKUP; " \
  "DROP TABLE ACTUAL_NODE_BACKUP; " \
  ""

#define STMT_VERIFICATION_TRIGGERS 187
#define STMT_187 \
  "CREATE TEMPORARY TRIGGER no_repository_updates BEFORE UPDATE ON repository " \
  "BEGIN " \
  "  SELECT RAISE(FAIL, 'Updates to REPOSITORY are not allowed.'); " \
  "END; " \
  "CREATE TEMPORARY TRIGGER validation_01 BEFORE INSERT ON nodes " \
  "WHEN NOT ((new.local_relpath = '' AND new.parent_relpath IS NULL) " \
  "          OR (relpath_depth(new.local_relpath) " \
  "              = relpath_depth(new.parent_relpath) + 1)) " \
  "BEGIN " \
  "  SELECT RAISE(FAIL, 'WC DB validity check 01 failed'); " \
  "END; " \
  "CREATE TEMPORARY TRIGGER validation_02 BEFORE INSERT ON nodes " \
  "WHEN NOT new.op_depth <= relpath_depth(new.local_relpath) " \
  "BEGIN " \
  "  SELECT RAISE(FAIL, 'WC DB validity check 02 failed'); " \
  "END; " \
  "CREATE TEMPORARY TRIGGER validation_03 BEFORE INSERT ON nodes " \
  "WHEN NOT ( " \
  "    (new.op_depth = relpath_depth(new.local_relpath)) " \
  "    OR " \
  "    (EXISTS (SELECT 1 FROM nodes " \
  "              WHERE wc_id = new.wc_id AND op_depth = new.op_depth " \
  "                AND local_relpath = new.parent_relpath)) " \
  "  ) " \
  " AND NOT (new.file_external IS NOT NULL AND new.op_depth = 0) " \
  "BEGIN " \
  "  SELECT RAISE(FAIL, 'WC DB validity check 03 failed'); " \
  "END; " \
  "CREATE TEMPORARY TRIGGER validation_04 BEFORE INSERT ON actual_node " \
  "WHEN NOT (new.local_relpath = '' " \
  "          OR EXISTS (SELECT 1 FROM nodes " \
  "                       WHERE wc_id = new.wc_id " \
  "                         AND local_relpath = new.parent_relpath)) " \
  "BEGIN " \
  "  SELECT RAISE(FAIL, 'WC DB validity check 04 failed'); " \
  "END; " \
  ""

#define WC_QUERIES_SQL_DECLARE_STATEMENTS(varname) \
  static const char * const varname[] = { \
    STMT_0, \
    STMT_1, \
    STMT_2, \
    STMT_3, \
    STMT_4, \
    STMT_5, \
    STMT_6, \
    STMT_7, \
    STMT_8, \
    STMT_9, \
    STMT_10, \
    STMT_11, \
    STMT_12, \
    STMT_13, \
    STMT_14, \
    STMT_15, \
    STMT_16, \
    STMT_17, \
    STMT_18, \
    STMT_19, \
    STMT_20, \
    STMT_21, \
    STMT_22, \
    STMT_23, \
    STMT_24, \
    STMT_25, \
    STMT_26, \
    STMT_27, \
    STMT_28, \
    STMT_29, \
    STMT_30, \
    STMT_31, \
    STMT_32, \
    STMT_33, \
    STMT_34, \
    STMT_35, \
    STMT_36, \
    STMT_37, \
    STMT_38, \
    STMT_39, \
    STMT_40, \
    STMT_41, \
    STMT_42, \
    STMT_43, \
    STMT_44, \
    STMT_45, \
    STMT_46, \
    STMT_47, \
    STMT_48, \
    STMT_49, \
    STMT_50, \
    STMT_51, \
    STMT_52, \
    STMT_53, \
    STMT_54, \
    STMT_55, \
    STMT_56, \
    STMT_57, \
    STMT_58, \
    STMT_59, \
    STMT_60, \
    STMT_61, \
    STMT_62, \
    STMT_63, \
    STMT_64, \
    STMT_65, \
    STMT_66, \
    STMT_67, \
    STMT_68, \
    STMT_69, \
    STMT_70, \
    STMT_71, \
    STMT_72, \
    STMT_73, \
    STMT_74, \
    STMT_75, \
    STMT_76, \
    STMT_77, \
    STMT_78, \
    STMT_79, \
    STMT_80, \
    STMT_81, \
    STMT_82, \
    STMT_83, \
    STMT_84, \
    STMT_85, \
    STMT_86, \
    STMT_87, \
    STMT_88, \
    STMT_89, \
    STMT_90, \
    STMT_91, \
    STMT_92, \
    STMT_93, \
    STMT_94, \
    STMT_95, \
    STMT_96, \
    STMT_97, \
    STMT_98, \
    STMT_99, \
    STMT_100, \
    STMT_101, \
    STMT_102, \
    STMT_103, \
    STMT_104, \
    STMT_105, \
    STMT_106, \
    STMT_107, \
    STMT_108, \
    STMT_109, \
    STMT_110, \
    STMT_111, \
    STMT_112, \
    STMT_113, \
    STMT_114, \
    STMT_115, \
    STMT_116, \
    STMT_117, \
    STMT_118, \
    STMT_119, \
    STMT_120, \
    STMT_121, \
    STMT_122, \
    STMT_123, \
    STMT_124, \
    STMT_125, \
    STMT_126, \
    STMT_127, \
    STMT_128, \
    STMT_129, \
    STMT_130, \
    STMT_131, \
    STMT_132, \
    STMT_133, \
    STMT_134, \
    STMT_135, \
    STMT_136, \
    STMT_137, \
    STMT_138, \
    STMT_139, \
    STMT_140, \
    STMT_141, \
    STMT_142, \
    STMT_143, \
    STMT_144, \
    STMT_145, \
    STMT_146, \
    STMT_147, \
    STMT_148, \
    STMT_149, \
    STMT_150, \
    STMT_151, \
    STMT_152, \
    STMT_153, \
    STMT_154, \
    STMT_155, \
    STMT_156, \
    STMT_157, \
    STMT_158, \
    STMT_159, \
    STMT_160, \
    STMT_161, \
    STMT_162, \
    STMT_163, \
    STMT_164, \
    STMT_165, \
    STMT_166, \
    STMT_167, \
    STMT_168, \
    STMT_169, \
    STMT_170, \
    STMT_171, \
    STMT_172, \
    STMT_173, \
    STMT_174, \
    STMT_175, \
    STMT_176, \
    STMT_177, \
    STMT_178, \
    STMT_179, \
    STMT_180, \
    STMT_181, \
    STMT_182, \
    STMT_183, \
    STMT_184, \
    STMT_185, \
    STMT_186, \
    STMT_187, \
    NULL \
  }
