Author: ehu Date: Fri Sep 10 13:22:33 2010 New Revision: 995788 URL: http://svn.apache.org/viewvc?rev=995788&view=rev Log: Convert more queries from NODE_DATA to NODES.
* subversion/libsvn_wc/wc-queries.sql (STMT_APPLY_CHANGES_TO_BASE_NODE_DATA, STMT_INSERT_WORKING_NODE_DATA_NORTMAL_FROM_BASE_NODE_1, STMT_INSERT_WORKING_NODE_DATA_NORTMAL_FROM_BASE_NODE_2, STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_1, STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_2, STMT_UPDATE_NODE_DATA_RECURSIVE_ORIGINAL_REPO): Remove. (STMT_APPLY_CHANGES_TO_BASE_NODE, STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE, STMT_INSERT_WORKING_NODE_NOT_PRESENT_FROM_BASE, STMT_RECURSIVE_UPDATE_NODE_REPO): New. (STMT_UPDATE_NODE_BASE_PRESENCE, STMT_UPDATE_NODE_WORKING_PRESENCE, STMT_UPDATE_NODE_WORKING_EXCLUDED, STMT_UPDATE_NODE_BASE_EXCLUDED, STMT_UPDATE_NODE_WORKING_DEPTH, STMT_UPDATE_NODE_BASE_DEPTH): Update to run on NODES. * subversion/libsvn_wc/wc_db.c (svn_wc__db_temp_op_remove_working, update_depth_values, db_working_update_presence, relocate_txn, commit_node, svn_wc__db_temp_op_set_base_incomplete, make_copy_txn): Convert NODE_DATA sections to NODES, where appropriate. Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql subversion/trunk/subversion/libsvn_wc/wc_db.c Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=995788&r1=995787&r2=995788&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original) +++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri Sep 10 13:22:33 2010 @@ -223,11 +223,11 @@ where copyfrom_repos_id is not null and (local_relpath = ?2 or local_relpath like ?3 escape '#'); --- STMT_UPDATE_NODE_DATA_RECURSIVE_ORIGINAL_REPO -update node_data set original_repos_id = ?5 -where wc_id = ?1 and original_repos_id = ?4 and - (local_relpath = ?2 or - local_relpath like ?3 escape '#'); +-- STMT_RECURSIVE_UPDATE_NODE_REPO +update NODES set repos_id = ?5, dav_cache = null +where wc_id = ?1 and repos_id = ?4 and + (local_relpath = ?2 + or local_relpath like ?3 escape '#'); -- STMT_UPDATE_LOCK_REPOS_ID update lock set repos_id = ?4 @@ -325,26 +325,28 @@ UPDATE BASE_NODE SET depth = ?3 WHERE wc_id = ?1 AND local_relpath = ?2; -- STMT_UPDATE_NODE_BASE_DEPTH -UPDATE NODE_DATA SET depth = ?3 -WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0; +update NODES set depth = ?3 +where wc_id = ?1 and local_relpath = ?2 and op_depth = 0; -- STMT_UPDATE_WORKING_DEPTH UPDATE WORKING_NODE SET depth = ?3 WHERE wc_id = ?1 AND local_relpath = ?2; -- STMT_UPDATE_NODE_WORKING_DEPTH -UPDATE NODE_DATA SET depth = ?3 -WHERE wc_id = ?1 AND local_relpath = ?2 AND - op_depth IN (SELECT MAX(op_depth) FROM NODE_DATA - WHERE wc_id = ?1 AND local_relpath = ?2); +update NODES set depth = ?3 +where wc_id = ?1 and local_relpath = ?2 and + op_depth in (select op_depth from NODES + where wc_id = ?1 and local_relpath = ?2 + order by op_depth desc + limit 1); -- STMT_UPDATE_BASE_EXCLUDED UPDATE BASE_NODE SET presence = 'excluded', depth = NULL WHERE wc_id = ?1 AND local_relpath = ?2; -- STMT_UPDATE_NODE_BASE_EXCLUDED -UPDATE NODE_DATA SET presence = 'excluded', depth = NULL -WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0; +update NODES set presence = 'excluded', depth = NULL +where wc_id = ?1 and local_relpath = ?2 and op_depth = 0; -- STMT_UPDATE_WORKING_EXCLUDED UPDATE WORKING_NODE SET presence = 'excluded', depth = NULL @@ -363,7 +365,7 @@ update base_node set presence= ?3 where wc_id = ?1 and local_relpath = ?2; -- STMT_UPDATE_NODE_BASE_PRESENCE -update node_data set presence = ?3 +update nodes set presence = ?3 where wc_id = ?1 and local_relpath = ?2 and op_depth = 0; -- STMT_UPDATE_BASE_PRESENCE_KIND @@ -379,7 +381,7 @@ update working_node set presence = ?3 where wc_id = ?1 and local_relpath =?2; -- STMT_UPDATE_NODE_WORKING_PRESENCE -update node_data set presence = ?3 +update nodes set presence = ?3 where wc_id = ?1 and local_relpath = ?2 and op_depth in (select op_depth from node_data where wc_id = ?1 and local_relpath = ?2 @@ -501,12 +503,13 @@ INSERT OR REPLACE INTO BASE_NODE ( depth, symlink_target, dav_cache) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16); --- STMT_APPLY_CHANGES_TO_BASE_NODE_DATA -INSERT OR REPLACE INTO NODE_DATA ( - wc_id, local_relpath, op_depth, parent_relpath, presence, kind, - changed_revision, changed_author, properties, checksum, - changed_date, depth, symlink_target) -VALUES (?1, ?2, 0, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12); +-- STMT_APPLY_CHANGES_TO_BASE_NODE +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 ) +values (?1, ?2, 0, + ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16); -- STMT_INSERT_WORKING_NODE_FROM_BASE_NODE INSERT INTO WORKING_NODE ( @@ -541,30 +544,18 @@ SELECT wc_id, local_relpath, parent_relp repos_relpath, revnum FROM BASE_NODE WHERE wc_id = ?1 AND local_relpath = ?2; - --- STMT_INSERT_WORKING_NODE_DATA_NORMAL_FROM_BASE_NODE_1 -INSERT INTO NODE_DATA ( - wc_id, local_relpath, op_depth, parent_relpath, presence, kind, checksum, - changed_revision, changed_date, changed_author, depth, symlink_target, - properties, original_repos_id, original_repos_path, original_revision ) -SELECT n.wc_id, n.local_relpath, ?3 as op_depth, n.parent_relpath, 'normal', - n.kind, - n.checksum, n.changed_revision, n.changed_date, n.changed_author, n.depth, - n.symlink_target, n.properties, b.repos_id as original_repos_id, - b.repos_relpath as original_repos_relpath, b.revnum as original_revision -FROM BASE_NODE as b INNER JOIN NODE_DATA as n - ON b.wc_id = n.wc_id - AND b.local_relpath = n.local_relpath - AND n.op_depth = 0 -WHERE n.wc_id = ?1 AND n.local_relpath = ?2; - - --- STMT_INSERT_WORKING_NODE_DATA_NORMAL_FROM_BASE_NODE_2 -INSERT INTO WORKING_NODE ( - wc_id, local_relpath, parent_relpath, translated_size, last_mod_time ) -SELECT wc_id, local_relpath, parent_relpath, translated_size, last_mod_time -FROM BASE_NODE -WHERE wc_id = ?1 AND local_relpath = ?2; +-- STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE +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 as op_depth, parent_relpath, repos_id, + repos_path, revision, 'normal', 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; -- STMT_INSERT_WORKING_NODE_NOT_PRESENT_FROM_BASE_NODE @@ -577,26 +568,15 @@ SELECT wc_id, local_relpath, parent_relp repos_relpath, revnum FROM BASE_NODE WHERE wc_id = ?1 AND local_relpath = ?2; - --- STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_1 -INSERT INTO NODE_DATA ( - wc_id, local_relpath, op_depth, parent_relpath, presence, kind, - changed_revision, changed_date, changed_author, original_repos_id, - original_repos_path, original_revision ) -SELECT wc_id, local_relpath, ?3 as op_depth, parent_relpath, 'not-present', - kind, changed_rev, changed_date, changed_author, repos_id, - repos_relpath, revnum -FROM BASE_NODE as b INNER JOIN NODE_DATA as n - ON b.local_relpath = n.local_relpath - AND b.wc_id = n.wc_id - AND n.op_depth = 0 -WHERE n.wc_id = ?1 AND n.local_relpath = ?2; - - --- STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_2 -INSERT INTO WORKING_NODE ( - wc_id, local_relpath, parent_relpath) -VALUES (?1, ?2, ?3); +-- STMT_INSERT_WORKING_NODE_NOT_PRESENT_FROM_BASE +insert into NODES ( + wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path, + revision, presence, kind, changed_revision, changed_date, changed_author ) +select wc_id, local_relpath, ?3 as op_depth, parent_relpath, repos_id, + repos_path, revision, 'not-present', kind, changed_revision, + changed_date, changed_author +from NODES +where wc_id = ?1 and local_relpath = ?2 and op_depth = 0; -- ### the statement below should be setting copyfrom_revision! Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=995788&r1=995787&r2=995788&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/wc_db.c (original) +++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Sep 10 13:22:33 2010 @@ -4217,10 +4217,12 @@ svn_wc__db_temp_op_remove_working(svn_wc SVN_ERR(flush_entries(db, pdh, local_abspath, scratch_pool)); +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, STMT_DELETE_WORKING_NODE)); SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif #ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, @@ -4247,6 +4249,7 @@ update_depth_values(svn_wc__db_t *db, /* Flush any entries before we start monkeying the database. */ SVN_ERR(flush_entries(db, pdh, local_abspath, scratch_pool)); +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, excluded ? STMT_UPDATE_BASE_EXCLUDED @@ -4255,8 +4258,9 @@ update_depth_values(svn_wc__db_t *db, if (!excluded) SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth))); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, excluded ? STMT_UPDATE_NODE_BASE_EXCLUDED @@ -4267,6 +4271,7 @@ update_depth_values(svn_wc__db_t *db, SVN_ERR(svn_sqlite__step_done(stmt)); #endif +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, excluded ? STMT_UPDATE_WORKING_EXCLUDED @@ -4275,8 +4280,9 @@ update_depth_values(svn_wc__db_t *db, if (!excluded) SVN_ERR(svn_sqlite__bind_text(stmt, 3, svn_depth_to_word(depth))); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, excluded ? STMT_UPDATE_NODE_WORKING_EXCLUDED @@ -4335,13 +4341,15 @@ db_working_update_presence(svn_wc__db_st scratch_pool, scratch_pool)); VERIFY_USABLE_PDH(pdh); +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, STMT_UPDATE_WORKING_PRESENCE)); SVN_ERR(svn_sqlite__bindf(stmt, "ist", pdh->wcroot->wc_id, local_relpath, presence_map, status)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb, STMT_UPDATE_NODE_WORKING_PRESENCE)); SVN_ERR(svn_sqlite__bindf(stmt, "ist", pdh->wcroot->wc_id, local_relpath, @@ -5220,16 +5228,19 @@ relocate_txn(void *baton, svn_sqlite__db escape_sqlite_like(rb->local_relpath, scratch_pool), "/%", NULL); +#ifndef SVN_WC__NODES_ONLY /* Update non-NULL WORKING_NODE.copyfrom_repos_id. */ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_UPDATE_WORKING_RECURSIVE_COPYFROM_REPO)); SVN_ERR(svn_sqlite__bindf(stmt, "issi", rb->wc_id, rb->local_relpath, like_arg, new_repos_id)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES + /* Set the (base and working) repos_ids and clear the dav_caches */ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, - STMT_UPDATE_NODE_DATA_RECURSIVE_ORIGINAL_REPO)); + STMT_RECURSIVE_UPDATE_NODE_REPO)); SVN_ERR(svn_sqlite__bindf(stmt, "issii", rb->wc_id, rb->local_relpath, like_arg, rb->old_repos_id, @@ -5241,6 +5252,7 @@ relocate_txn(void *baton, svn_sqlite__db base_node in the first place. */ if (rb->have_base_node) { +#ifndef SVN_WC__NODES_ONLY /* Purge the DAV cache (wcprops) from any BASE that have 'em. */ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_CLEAR_BASE_RECURSIVE_DAV_CACHE)); @@ -5254,6 +5266,7 @@ relocate_txn(void *baton, svn_sqlite__db SVN_ERR(svn_sqlite__bindf(stmt, "issi", rb->wc_id, rb->local_relpath, like_arg, new_repos_id)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif /* Update any locks for the root or its children. */ if (rb->repos_relpath[0] == 0) @@ -5523,6 +5536,7 @@ commit_node(void *baton, svn_sqlite__db_ /* ### other presences? or reserve that for separate functions? */ new_presence = svn_wc__db_status_normal; +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement(&stmt, cb->pdh->wcroot->sdb, STMT_APPLY_CHANGES_TO_BASE)); SVN_ERR(svn_sqlite__bindf(stmt, "issttiisb", @@ -5552,27 +5566,30 @@ commit_node(void *baton, svn_sqlite__db_ scratch_pool)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement(&stmt, cb->pdh->wcroot->sdb, - STMT_APPLY_CHANGES_TO_BASE_NODE_DATA)); - SVN_ERR(svn_sqlite__bindf(stmt, "issttisb", + STMT_APPLY_CHANGES_TO_BASE_NODE)); + SVN_ERR(svn_sqlite__bindf(stmt, "issisrtstrinsbns", cb->pdh->wcroot->wc_id, cb->local_relpath, parent_relpath, + cb->repos_id, + cb->repos_relpath, + cb->new_revision, presence_map, new_presence, + new_depth_str, kind_map, new_kind, - (apr_int64_t)cb->changed_rev, + cb->changed_rev, + cb->changed_date, cb->changed_author, - prop_blob.data, prop_blob.len)); + prop_blob.data, prop_blob.len, + cb->new_dav_cache)); - SVN_ERR(svn_sqlite__bind_checksum(stmt, 9, cb->new_checksum, + SVN_ERR(svn_sqlite__bind_checksum(stmt, 14, cb->new_checksum, scratch_pool)); - if (cb->changed_date > 0) - SVN_ERR(svn_sqlite__bind_int64(stmt, 10, cb->changed_date)); - SVN_ERR(svn_sqlite__bind_text(stmt, 11, new_depth_str)); - /* ### 12. target. */ - SVN_ERR(svn_sqlite__bind_properties(stmt, 12, cb->new_dav_cache, + SVN_ERR(svn_sqlite__bind_properties(stmt, 15, cb->new_dav_cache, scratch_pool)); SVN_ERR(svn_sqlite__step_done(stmt)); @@ -7914,7 +7931,7 @@ svn_wc__db_temp_op_set_base_incomplete(s svn_sqlite__stmt_t *stmt; svn_wc__db_pdh_t *pdh; int affected_rows; -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES int affected_node_rows; #endif svn_wc__db_status_t base_status; @@ -7928,12 +7945,14 @@ svn_wc__db_temp_op_set_base_incomplete(s SVN_ERR_ASSERT(base_status == svn_wc__db_status_normal || base_status == svn_wc__db_status_incomplete); +#ifndef SVN_WC__NODES_ONLY SVN_ERR(get_statement_for_path(&stmt, db, local_dir_abspath, STMT_UPDATE_BASE_PRESENCE, scratch_pool)); SVN_ERR(svn_sqlite__bind_text(stmt, 3, incomplete ? "incomplete" : "normal")); SVN_ERR(svn_sqlite__update(&affected_rows, stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(get_statement_for_path(&stmt, db, local_dir_abspath, STMT_UPDATE_NODE_BASE_PRESENCE, scratch_pool)); SVN_ERR(svn_sqlite__bind_text(stmt, 3, incomplete ? "incomplete" : "normal")); @@ -8192,6 +8211,7 @@ make_copy_txn(void *baton, { /* Add a copy of the BASE_NODE to WORKING_NODE */ +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement( &stmt, sdb, STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE_NODE)); @@ -8201,11 +8221,12 @@ make_copy_txn(void *baton, mcb->local_relpath)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif -#ifdef SVN_WC__NODE_DATA +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement( &stmt, sdb, - STMT_INSERT_WORKING_NODE_DATA_NORMAL_FROM_BASE_NODE_1)); + STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE)); SVN_ERR(svn_sqlite__bindf(stmt, "isi", mcb->pdh->wcroot->wc_id, @@ -8213,20 +8234,6 @@ make_copy_txn(void *baton, (*mcb->local_relpath == '\0') ? 1 : 2)); SVN_ERR(svn_sqlite__step_done(stmt)); - -#if 0 - /* ### NODE_DATA we can't enable the bit below until we stop - running STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE_NODE above */ - SVN_ERR(svn_sqlite__get_statement( - &stmt, sdb, - STMT_INSERT_WORKING_NODE_DATA_NORMAL_FROM_BASE_NODE_2)); - - SVN_ERR(svn_sqlite__bindf(stmt, "is", - mcb->pdh->wcroot->wc_id, - mcb->local_relpath)); - - SVN_ERR(svn_sqlite__step_done(stmt)); -#endif #endif } @@ -8234,6 +8241,7 @@ make_copy_txn(void *baton, { /* Add a not present WORKING_NODE */ +#ifndef SVN_WC__NODES_ONLY SVN_ERR(svn_sqlite__get_statement( &stmt, sdb, STMT_INSERT_WORKING_NODE_NOT_PRESENT_FROM_BASE_NODE)); @@ -8243,13 +8251,12 @@ make_copy_txn(void *baton, mcb->local_relpath)); SVN_ERR(svn_sqlite__step_done(stmt)); +#endif - -#ifdef SVN_WC__NODE_DATA - +#ifdef SVN_WC__NODES SVN_ERR(svn_sqlite__get_statement( &stmt, sdb, - STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_1)); + STMT_INSERT_WORKING_NODE_NOT_PRESENT_FROM_BASE)); SVN_ERR(svn_sqlite__bindf(stmt, "isi", mcb->pdh->wcroot->wc_id, @@ -8257,23 +8264,6 @@ make_copy_txn(void *baton, (*mcb->local_relpath == '\0') ? 1 : 2)); SVN_ERR(svn_sqlite__step_done(stmt)); - -#if 0 - /* ### NODE_DATA we can't enable the bit below until we stop - running STMT_INSERT_WORKING_NODE_NORMAL_FROM_BASE_NODE above */ - SVN_ERR(svn_sqlite__get_statement( - &stmt, sdb, - STMT_INSERT_WORKING_NODE_DATA_NOT_PRESENT_FROM_BASE_NODE_2)); - - SVN_ERR(svn_sqlite__bindf(stmt, "iss", - mcb->pdh->wcroot->wc_id, - mcb->local_relpath, - (*mcb->local_relpath == '\0') ? NULL - : svn_relpath_dirname(pibb->local_relpath, - scratch_pool))); - - SVN_ERR(svn_sqlite__step_done(stmt)); -#endif #endif }