X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabaseSqlite.php;h=f282b17a0f8a1346618408c1af4c0705f9d4d737;hb=14d08d1df93a9e2d98d505769be94c96b348f8c5;hp=d0d62e9edb84000c21dd3948a51aa1ad555c2aea;hpb=ebf1570fd1ad7a9fc732e8dfdedcbc540c4a8ec6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index d0d62e9edb..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 @@ -716,13 +710,6 @@ class DatabaseSqlite extends Database { return $this->lastErrno() == 5; // SQLITE_BUSY } - /** - * @return bool - */ - function wasErrorReissuable() { - return $this->lastErrno() == 17; // SQLITE_SCHEMA; - } - /** * @return bool */ @@ -730,6 +717,18 @@ class DatabaseSqlite extends Database { return $this->lastErrno() == 8; // SQLITE_READONLY; } + public function wasConnectionError( $errno ) { + 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 */ @@ -1076,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 */