X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabasePostgres.php;h=bdac06c121929405338c946223fdebd694bd5373;hb=5604684b4420048b6f0db29daf5b6ae7d600b446;hp=2fe275b5c1c344537e3dd04c6881f56f0d7c6c88;hpb=47156d530e4132f8da112568c5f46ddccd9bdde5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabasePostgres.php b/includes/libs/rdbms/database/DatabasePostgres.php index 2fe275b5c1..bdac06c121 100644 --- a/includes/libs/rdbms/database/DatabasePostgres.php +++ b/includes/libs/rdbms/database/DatabasePostgres.php @@ -256,7 +256,10 @@ class DatabasePostgres extends Database { } /* Transaction stays in the ERROR state until rolled back */ if ( $this->mTrxLevel ) { - $this->rollback( __METHOD__ ); + // Throw away the transaction state, then raise the error as normal. + // Note that if this connection is managed by LBFactory, it's already expected + // that the other transactions LBFactory manages will be rolled back. + $this->rollback( __METHOD__, self::FLUSHING_INTERNAL ); } parent::reportQueryError( $error, $errno, $sql, $fname, false ); } @@ -681,14 +684,13 @@ __INDEXATTR__; * @param string $fname * @param array $insertOptions * @param array $selectOptions + * @param array $selectJoinConds * @return bool */ public function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__, - $insertOptions = [], $selectOptions = [] + $insertOptions = [], $selectOptions = [], $selectJoinConds = [] ) { - $destTable = $this->tableName( $destTable ); - if ( !is_array( $insertOptions ) ) { $insertOptions = [ $insertOptions ]; } @@ -705,28 +707,9 @@ __INDEXATTR__; $savepoint->savepoint(); } - if ( !is_array( $selectOptions ) ) { - $selectOptions = [ $selectOptions ]; - } - list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) = - $this->makeSelectOptions( $selectOptions ); - if ( is_array( $srcTable ) ) { - $srcTable = implode( ',', array_map( [ $this, 'tableName' ], $srcTable ) ); - } else { - $srcTable = $this->tableName( $srcTable ); - } - - $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . - " SELECT $startOpts " . implode( ',', $varMap ) . - " FROM $srcTable $useIndex $ignoreIndex "; - - if ( $conds != '*' ) { - $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); - } - - $sql .= " $tailOpts"; + $res = parent::nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname, + $insertOptions, $selectOptions, $selectJoinConds ); - $res = (bool)$this->query( $sql, $fname, $savepoint ); if ( $savepoint ) { $bar = pg_result_error( $this->mLastResult ); if ( $bar != false ) { @@ -1059,6 +1042,7 @@ __INDEXATTR__; if ( $schema === false ) { $schema = $this->getCoreSchema(); } + $table = $this->realTableName( $table, 'raw' ); $etable = $this->addQuotes( $table ); $eschema = $this->addQuotes( $schema ); $sql = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " @@ -1386,6 +1370,13 @@ SQL; return false; } + public function serverIsReadOnly() { + $res = $this->query( "SHOW default_transaction_read_only", __METHOD__ ); + $row = $this->fetchObject( $res ); + + return $row ? ( strtolower( $row->default_transaction_read_only ) === 'on' ) : false; + } + /** * @param string $lockName * @return string Integer