Author: brane
Date: Sun Sep 10 18:29:33 2017
New Revision: 1807956

URL: http://svn.apache.org/viewvc?rev=1807956&view=rev
Log:
Following up on r1807584, remove unnecessary SQL statements from
the WC schema definition and simplify a step in the upgrade process.

* subversion/libsvn_wc/wc-metadata.sql
  (STMT_CREATE_NODES): Remove and include into STMT_CREATE_SCHEMA.
  (STMT_CREATE_NODES_TRIGGERS): Likewise.
  (STMT_CREATE_EXTERNALS): Likewise.
  (STMT_UPGRADE_TO_31_ALTER_TABLE, STMT_UPGRADE_TO_31_FINALIZE):
   Combine these statements into a single ...
  (STMT_UPGRADE_TO_31): ... which is new.
  (STMT_UPGRADE_TO_32): Remove as unused.
  (-- format: YYY): Remove as unused, it converted to a comment anyway.

* subversion/libsvn_wc/wc_db.c
  (init_db): Remove use of deleted SQL statements.
* subversion/libsvn_wc/upgrade.c
  (bump_to_31): Remove the manual check for the existence of the
   NODES.inherited_props column since we no longer support the
   unreleased formats prior to format 20 that did not have
   a NODES table.

* subversion/tests/libsvn_wc/utils.c
  (svn_test__create_fake_wc): Remove use of deleted SQL statements.
* subversion/tests/libsvn_wc/wc-queries-test.c
  (schema_statements): Remove use of deleted SQL statements.

Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/libsvn_wc/utils.c
    subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1807956&r1=1807955&r2=1807956&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Sun Sep 10 18:29:33 2017
@@ -1374,41 +1374,10 @@ bump_to_31(void *baton,
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_array_header_t *empty_iprops = apr_array_make(
     scratch_pool, 0, sizeof(svn_prop_inherited_item_t *));
-  svn_boolean_t iprops_column_exists = FALSE;
   svn_error_t *err;
 
-  /* Add the inherited_props column to NODES if it does not yet exist.
-   *
-   * When using a format >= 31 client to upgrade from old formats which
-   * did not yet have a NODES table, the inherited_props column has
-   * already been created as part of the NODES table. Attemping to add
-   * the inherited_props column will raise an error in this case, so check
-   * if the column exists first.
-   *
-   * Checking for the existence of a column before ALTER TABLE is not
-   * possible within SQLite. We need to run a separate query and evaluate
-   * its result in C first.
-   */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_PRAGMA_TABLE_INFO_NODES));
-  SVN_ERR(svn_sqlite__step(&have_row, stmt));
-  while (have_row)
-    {
-      const char *column_name = svn_sqlite__column_text(stmt, 1, NULL);
-
-      if (strcmp(column_name, "inherited_props") == 0)
-        {
-          iprops_column_exists = TRUE;
-          break;
-        }
-
-      SVN_ERR(svn_sqlite__step(&have_row, stmt));
-    }
-  SVN_ERR(svn_sqlite__reset(stmt));
-  if (!iprops_column_exists)
-    SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_31_ALTER_TABLE));
-
   /* Run additional statements to finalize the upgrade to format 31. */
-  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_31_FINALIZE));
+  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_31));
 
   /* Set inherited_props to an empty array for the roots of all
      switched subtrees in the WC.  This allows subsequent updates

Modified: subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-metadata.sql?rev=1807956&r1=1807955&r2=1807956&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-metadata.sql Sun Sep 10 18:29:33 
2017
@@ -229,11 +229,6 @@ CREATE TABLE WC_LOCK (
  );
 
 
-PRAGMA user_version =
--- define: SVN_WC__VERSION
-;
-
-
 /* ------------------------------------------------------------------------- */
 
 /* The NODES table describes the way WORKING nodes are layered on top of
@@ -279,7 +274,6 @@ PRAGMA user_version =
    An 'svn revert foo/bar' would remove the NODES of (2).
 
  */
--- STMT_CREATE_NODES
 CREATE TABLE NODES (
   /* Working copy location related fields */
 
@@ -503,8 +497,6 @@ CREATE VIEW NODES_BASE AS
   SELECT * FROM nodes
   WHERE op_depth = 0;
 
--- STMT_CREATE_NODES_TRIGGERS
-
 CREATE TRIGGER nodes_insert_trigger
 AFTER INSERT ON nodes
 WHEN NEW.checksum IS NOT NULL
@@ -532,8 +524,6 @@ BEGIN
   WHERE checksum = OLD.checksum;
 END;
 
--- STMT_CREATE_EXTERNALS
-
 CREATE TABLE EXTERNALS (
   /* Working copy location related fields (like NODES)*/
 
@@ -572,6 +562,12 @@ CREATE UNIQUE INDEX I_EXTERNALS_DEFINED
                                                       def_local_relpath,
                                                       local_relpath);
 
+
+PRAGMA user_version =
+-- define: SVN_WC__VERSION
+;
+
+
 /* ------------------------------------------------------------------------- */
 /* This statement provides SQLite with the necessary information about our
    indexes to make better decisions in the query planner.
@@ -668,9 +664,9 @@ WHERE wc_id = ?1 and local_relpath = ?2
 /* Format 31 adds the inherited_props column to the NODES table. C code then
    initializes the update/switch roots to make sure future updates fetch the
    inherited properties */
--- STMT_UPGRADE_TO_31_ALTER_TABLE
+-- STMT_UPGRADE_TO_31
 ALTER TABLE NODES ADD COLUMN inherited_props BLOB;
--- STMT_UPGRADE_TO_31_FINALIZE
+
 DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST;
 DROP INDEX IF EXISTS I_EXTERNALS_PARENT;
 
@@ -704,25 +700,8 @@ WHERE l.op_depth = 0
 
 /* ------------------------------------------------------------------------- */
 /* Format 32 ....  */
--- STMT_UPGRADE_TO_32
-
-/* Drop old index. ### Remove this part from the upgrade to 31 once bumped */
-DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST;
-DROP INDEX IF EXISTS I_EXTERNALS_PARENT;
-CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath);
-
-DROP INDEX I_NODES_PARENT;
-CREATE UNIQUE INDEX I_NODES_PARENT ON NODES (wc_id, parent_relpath,
-                                             local_relpath, op_depth);
-
-DROP INDEX I_ACTUAL_PARENT;
-CREATE UNIQUE INDEX I_ACTUAL_PARENT ON ACTUAL_NODE (wc_id, parent_relpath,
-                                                    local_relpath);
-
-/* ------------------------------------------------------------------------- */
-
-/* Format YYY introduces new handling for conflict information.  */
--- format: YYY
+/* -- STMT_UPGRADE_TO_32
+PRAGMA user_version = 32; */
 
 
 /* ------------------------------------------------------------------------- */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1807956&r1=1807955&r2=1807956&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun Sep 10 18:29:33 2017
@@ -1371,9 +1371,6 @@ init_db(/* output values */
 
   /* Create the database's schema.  */
   SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_SCHEMA));
-  SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_NODES));
-  SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_NODES_TRIGGERS));
-  SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_EXTERNALS));
 
   SVN_ERR(svn_wc__db_install_schema_statistics(db, scratch_pool));
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/utils.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/utils.c?rev=1807956&r1=1807955&r2=1807956&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/utils.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/utils.c Sun Sep 10 18:29:33 2017
@@ -139,12 +139,9 @@ svn_test__create_fake_wc(const char *wc_
    * refer to it over its lifetime. */
   my_statements = apr_palloc(scratch_pool, 7 * sizeof(const char *));
   my_statements[0] = statements[STMT_CREATE_SCHEMA];
-  my_statements[1] = statements[STMT_CREATE_NODES];
-  my_statements[2] = statements[STMT_CREATE_NODES_TRIGGERS];
-  my_statements[3] = statements[STMT_CREATE_EXTERNALS];
-  my_statements[4] = statements[STMT_INSTALL_SCHEMA_STATISTICS];
-  my_statements[5] = extra_statements;
-  my_statements[6] = NULL;
+  my_statements[1] = statements[STMT_INSTALL_SCHEMA_STATISTICS];
+  my_statements[2] = extra_statements;
+  my_statements[3] = NULL;
 
   /* Create fake-wc/SUBDIR/.svn/ for placing the metadata. */
   SVN_ERR(svn_io_make_dir_recursively(dotsvn_abspath, scratch_pool));

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c?rev=1807956&r1=1807955&r2=1807956&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c Sun Sep 10 
18:29:33 2017
@@ -70,9 +70,6 @@ static const int schema_statements[] =
 {
   /* Usual tables */
   STMT_CREATE_SCHEMA,
-  STMT_CREATE_NODES,
-  STMT_CREATE_NODES_TRIGGERS,
-  STMT_CREATE_EXTERNALS,
   STMT_INSTALL_SCHEMA_STATISTICS,
   /* Memory tables */
   STMT_CREATE_TARGETS_LIST,


Reply via email to