コード例 #1
0
    public void bumpTo(SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException {
      /*-- STMT_UPGRADE_TO_22
      UPDATE actual_node SET tree_conflict_data = conflict_data;
      UPDATE actual_node SET conflict_data = NULL;
      */
      SVNSqlJetUpdateStatement stmt =
          new SVNSqlJetUpdateStatement(sDb, SVNWCDbSchema.ACTUAL_NODE) {
            public Map<String, Object> getUpdateValues() throws SVNException {
              Map<String, Object> rowValues = getRowValues();
              rowValues.put(
                  SVNWCDbSchema.ACTUAL_NODE__Fields.tree_conflict_data.toString(),
                  rowValues.get(SVNWCDbSchema.ACTUAL_NODE__Fields.conflict_data.toString()));
              return rowValues;
            }
          };
      try {
        stmt.exec();
      } finally {
        stmt.reset();
      }

      stmt =
          new SVNSqlJetUpdateStatement(sDb, SVNWCDbSchema.ACTUAL_NODE) {
            public Map<String, Object> getUpdateValues() throws SVNException {
              Map<String, Object> rowValues = getRowValues();
              rowValues.put(SVNWCDbSchema.ACTUAL_NODE__Fields.conflict_data.toString(), null);
              return rowValues;
            }
          };
      try {
        stmt.exec();
      } finally {
        stmt.reset();
      }

      setVersion(sDb, (int) 22);
    }
コード例 #2
0
    public void bumpTo(SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException {
      /*-- STMT_UPGRADE_TO_25
      UPDATE pristine SET refcount = (SELECT COUNT(*) FROM nodes WHERE checksum = pristine.checksum /*OR checksum = pristine.md5_checksum/);
      */
      SVNSqlJetUpdateStatement stmt =
          new SVNSqlJetUpdateStatement(sDb, SVNWCDbSchema.PRISTINE) {
            private SVNSqlJetSelectFieldsStatement<SVNWCDbSchema.NODES__Fields> select =
                new SVNSqlJetSelectFieldsStatement<SVNWCDbSchema.NODES__Fields>(
                    sDb, SVNWCDbSchema.NODES) {
                  protected boolean isFilterPassed() throws SVNException {
                    return ((String) getBind(1))
                        .equals(getColumnString(SVNWCDbSchema.NODES__Fields.checksum));
                  }

                  protected void defineFields() {
                    fields.add(SVNWCDbSchema.NODES__Fields.wc_id);
                  }

                  protected Object[] getWhere() throws SVNException {
                    return new Object[] {};
                  }
                };

            public Map<String, Object> getUpdateValues() throws SVNException {
              Map<String, Object> rowValues = getRowValues();

              select.bindString(
                  1, (String) rowValues.get(SVNWCDbSchema.PRISTINE__Fields.checksum.toString()));
              long rowCount = 0;
              try {
                while (select.next()) rowCount++;
              } finally {
                select.reset();
              }
              rowValues.put(SVNWCDbSchema.PRISTINE__Fields.refcount.toString(), rowCount);
              return rowValues;
            }
          };

      try {
        stmt.exec();
      } finally {
        stmt.reset();
      }

      setVersion(sDb, (int) 24);

      try {
        sDb.getDb()
            .createTrigger(
                "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;");
        sDb.getDb()
            .createTrigger(
                "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;");
        sDb.getDb()
            .createTrigger(
                "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;");
      } catch (SqlJetException e) {
        SVNSqlJetDb.createSqlJetError(e);
      }
    }
コード例 #3
0
    public void run() throws SVNException {
      SVNSqlJetUpdateStatement stmt =
          new SVNSqlJetUpdateStatement(sDb, tableName) {
            private SVNSqlJetSelectFieldsStatement<SVNWCDbSchema.PRISTINE__Fields> select =
                new SVNSqlJetSelectFieldsStatement<SVNWCDbSchema.PRISTINE__Fields>(
                    sDb, SVNWCDbSchema.PRISTINE) {
                  protected boolean isFilterPassed() throws SVNException {
                    return ((String) getBind(1))
                        .equals(getColumnString(SVNWCDbSchema.PRISTINE__Fields.md5_checksum));
                  }

                  protected void defineFields() {
                    fields.add(SVNWCDbSchema.PRISTINE__Fields.checksum);
                  }

                  protected Object[] getWhere() throws SVNException {
                    return new Object[] {};
                  }
                };

            public Map<String, Object> getUpdateValues() throws SVNException {
              return null;
            }

            public long exec() throws SVNException {
              long n = 0;
              try {
                statementStarted();
                while (next()) {
                  Map<String, Object> rowValues = getRowValues();
                  String checksum = (String) rowValues.get("checksum");
                  if (checksum == null) continue;
                  select.bindString(1, checksum);
                  try {
                    if (select.next()) {
                      rowValues.put(
                          "checksum",
                          select.getColumnString(SVNWCDbSchema.PRISTINE__Fields.checksum));
                    } else {
                      continue;
                    }
                  } finally {
                    select.reset();
                  }

                  update(rowValues);
                  n++;
                }
                statementCompleted(null);
              } catch (SqlJetException e) {
                statementCompleted(e);
                SVNSqlJetDb.createSqlJetError(e);
              }
              return n;
            }
          };

      try {
        stmt.exec();
      } finally {
        stmt.reset();
      }
    }