Esempio n. 1
0
  /**
   * Acquires a repository lock and begins a matching MDR transaction (shared lock for read, or
   * exclusive lock for write). Typical usage is start of SQL statement preparation (e.g.
   * readOnly=true for DML or query, false for DDL).
   *
   * @param readOnly if true, a shared lock is acquired on the catalog; otherwise, an exclusive lock
   *     is acquired
   */
  public void beginLockedTxn(boolean readOnly) {
    int level = (readOnly) ? 1 : 2;

    // TODO jvs 24-Jan-2007:  Get rid of downcast here and below by
    // making all creation of FarragoReposTxnContext go through
    // factory method interface on FarragoRepos.

    ((FarragoReposImpl) repos).lockRepos(level);

    // Don't set lockLevel until we've successfully acquired the lock
    lockLevel = level;

    if (readOnly) {
      beginReadTxn();
    } else {
      beginWriteTxn();
    }
  }