Merge "rdbms: add QUERY_IGNORE_DBO_TRX to duplicateTableStructure() queries"

This commit is contained in:
jenkins-bot 2020-03-29 16:42:34 +00:00 committed by Gerrit Code Review
commit 20a0c8ab5a
3 changed files with 31 additions and 14 deletions

View file

@ -1429,9 +1429,12 @@ abstract class DatabaseMysqlBase extends Database {
$tmp = $temporary ? 'TEMPORARY ' : '';
$newName = $this->addIdentifierQuotes( $newName );
$oldName = $this->addIdentifierQuotes( $oldName );
$query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
return $this->query( $query, $fname, $this::QUERY_PSEUDO_PERMANENT );
return $this->query(
"CREATE $tmp TABLE $newName (LIKE $oldName)",
$fname,
self::QUERY_PSEUDO_PERMANENT | self::QUERY_IGNORE_DBO_TRX
);
}
/**
@ -1442,7 +1445,7 @@ abstract class DatabaseMysqlBase extends Database {
* @return array
*/
public function listTables( $prefix = null, $fname = __METHOD__ ) {
$result = $this->query( "SHOW TABLES", $fname );
$result = $this->query( "SHOW TABLES", $fname, self::QUERY_IGNORE_DBO_TRX );
$endArray = [];

View file

@ -749,12 +749,13 @@ __INDEXATTR__;
$oldNameE = $this->addIdentifierQuotes( $oldName );
$temporary = $temporary ? 'TEMPORARY' : '';
$queryFlags = self::QUERY_PSEUDO_PERMANENT | self::QUERY_IGNORE_DBO_TRX;
$ret = $this->query(
"CREATE $temporary TABLE $newNameE " .
"(LIKE $oldNameE INCLUDING DEFAULTS INCLUDING INDEXES)",
$fname,
$this::QUERY_PSEUDO_PERMANENT
$queryFlags
);
if ( !$ret ) {
return $ret;
@ -779,11 +780,13 @@ __INDEXATTR__;
$newSeqQ = $this->addQuotes( $newSeq );
$this->query(
"CREATE $temporary SEQUENCE $newSeqE OWNED BY $newNameE.$fieldE",
$fname
$fname,
$queryFlags
);
$this->query(
"ALTER TABLE $newNameE ALTER COLUMN $fieldE SET DEFAULT nextval({$newSeqQ}::regclass)",
$fname
$fname,
$queryFlags
);
}

View file

@ -996,10 +996,13 @@ class DatabaseSqlite extends Database {
* @throws RuntimeException
*/
function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) {
$queryFlags = self::QUERY_PSEUDO_PERMANENT | self::QUERY_IGNORE_DBO_TRX;
$res = $this->query(
"SELECT sql FROM sqlite_master WHERE tbl_name=" .
$this->addQuotes( $oldName ) . " AND type='table'",
$fname
$fname,
$queryFlags
);
$obj = $this->fetchObject( $res );
if ( !$obj ) {
@ -1023,10 +1026,14 @@ class DatabaseSqlite extends Database {
}
}
$res = $this->query( $sql, $fname, self::QUERY_PSEUDO_PERMANENT );
$res = $this->query( $sql, $fname, $queryFlags );
// Take over indexes
$indexList = $this->query( 'PRAGMA INDEX_LIST(' . $this->addQuotes( $oldName ) . ')' );
$indexList = $this->query(
'PRAGMA INDEX_LIST(' . $this->addQuotes( $oldName ) . ')',
$fname,
$queryFlags
);
foreach ( $indexList as $index ) {
if ( strpos( $index->name, 'sqlite_autoindex' ) === 0 ) {
continue;
@ -1041,7 +1048,11 @@ class DatabaseSqlite extends Database {
$indexName = $newName . '_' . $index->name;
$sql .= ' ' . $indexName . ' ON ' . $newName;
$indexInfo = $this->query( 'PRAGMA INDEX_INFO(' . $this->addQuotes( $index->name ) . ')' );
$indexInfo = $this->query(
'PRAGMA INDEX_INFO(' . $this->addQuotes( $index->name ) . ')',
$fname,
$queryFlags
);
$fields = [];
foreach ( $indexInfo as $indexInfoRow ) {
$fields[$indexInfoRow->seqno] = $indexInfoRow->name;
@ -1064,10 +1075,10 @@ class DatabaseSqlite extends Database {
* @return array
*/
function listTables( $prefix = null, $fname = __METHOD__ ) {
$result = $this->select(
'sqlite_master',
'name',
"type='table'"
$result = $this->query(
"SELECT name FROM sqlite_master WHERE type = 'table'",
$fname,
self::QUERY_IGNORE_DBO_TRX
);
$endArray = [];