X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseSqlite.php;h=f282b17a0f8a1346618408c1af4c0705f9d4d737;hp=d5a74891bed8eeedccfb942fa3f9bee8d0168de0;hb=0d57b370dfe726af5f3ecf210f9f352ad9e26f0f;hpb=87f40138c64ddccb6dc6d54531cea02af40ef0f3 diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index d5a74891be..f282b17a0f 100644 --- a/includes/libs/rdbms/database/DatabaseSqlite.php +++ b/includes/libs/rdbms/database/DatabaseSqlite.php @@ -120,7 +120,7 @@ class DatabaseSqlite extends Database { protected function doInitConnection() { if ( $this->dbPath !== null ) { // Standalone .sqlite file mode. - $this->openFile( $this->dbPath ); + $this->openFile( $this->dbPath, $this->connectionParams['dbname'] ); } elseif ( $this->dbDir !== null ) { // Stock wiki mode using standard file names per DB if ( strlen( $this->connectionParams['dbname'] ) ) { @@ -173,11 +173,7 @@ class DatabaseSqlite extends Database { $this->conn = false; throw new DBConnectionError( $this, "SQLite database not accessible" ); } - $this->openFile( $fileName ); - - if ( $this->conn ) { - $this->dbName = $dbName; - } + $this->openFile( $fileName, $dbName ); return (bool)$this->conn; } @@ -186,10 +182,11 @@ class DatabaseSqlite extends Database { * Opens a database file * * @param string $fileName + * @param string $dbName * @throws DBConnectionError * @return PDO|bool SQL connection or false if failed */ - protected function openFile( $fileName ) { + protected function openFile( $fileName, $dbName ) { $err = false; $this->dbPath = $fileName; @@ -211,6 +208,7 @@ class DatabaseSqlite extends Database { $this->opened = is_object( $this->conn ); if ( $this->opened ) { + $this->dbName = $dbName; # Set error codes only, don't raise exceptions $this->conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT ); # Enforce LIKE to be case sensitive, just like MySQL @@ -222,10 +220,6 @@ class DatabaseSqlite extends Database { return false; } - public function selectDB( $db ) { - return false; // doesn't make sense - } - /** * @return string SQLite DB file path * @since 1.25 @@ -727,6 +721,14 @@ class DatabaseSqlite extends Database { return $errno == 17; // SQLITE_SCHEMA; } + protected function wasKnownStatementRollbackError() { + // ON CONFLICT ROLLBACK clauses make it so that SQLITE_CONSTRAINT error is + // ambiguous with regard to whether it implies a ROLLBACK or an ABORT happened. + // https://sqlite.org/lang_createtable.html#uniqueconst + // https://sqlite.org/lang_conflict.html + return false; + } + /** * @return string Wikitext of a link to the server software's web site */ @@ -1073,6 +1075,16 @@ class DatabaseSqlite extends Database { } } + public function resetSequenceForTable( $table, $fname = __METHOD__ ) { + $encTable = $this->addIdentifierQuotes( 'sqlite_sequence' ); + $encName = $this->addQuotes( $this->tableName( $table, 'raw' ) ); + $this->query( "DELETE FROM $encTable WHERE name = $encName", $fname ); + } + + public function databasesAreIndependent() { + return true; + } + /** * @return string */