Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
561834cd
Commit
561834cd
authored
Apr 12, 2015
by
alexpott
Browse files
Issue
#2465221
by amateescu: Raise the minimun version requirement for SQLite to 3.6.8
parent
b75b691a
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
View file @
561834cd
...
...
@@ -9,9 +9,6 @@
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\DatabaseNotFoundException
;
use
Drupal\Core\Database\TransactionNoActiveException
;
use
Drupal\Core\Database\TransactionNameNonUniqueException
;
use
Drupal\Core\Database\TransactionCommitFailedException
;
use
Drupal\Core\Database\Connection
as
DatabaseConnection
;
/**
...
...
@@ -19,16 +16,6 @@
*/
class
Connection
extends
DatabaseConnection
{
/**
* Whether this database connection supports savepoints.
*
* Version of sqlite lower then 3.6.8 can't use savepoints.
* See http://www.sqlite.org/releaselog/3_6_8.html
*
* @var bool
*/
protected
$savepointSupport
=
FALSE
;
/**
* Error code for "Unable to open database file" error.
*/
...
...
@@ -90,10 +77,6 @@ public function __construct(\PDO $connection, array $connection_options) {
}
// Regenerate the prefixes replacement table.
$this
->
setPrefix
(
$prefixes
);
// Detect support for SAVEPOINT.
$version
=
$this
->
query
(
'SELECT sqlite_version()'
)
->
fetchField
();
$this
->
savepointSupport
=
(
version_compare
(
$version
,
'3.6.8'
)
>=
0
);
}
/**
...
...
@@ -426,86 +409,4 @@ public function nextId($existing_id = 0) {
return
$this
->
query
(
'SELECT value FROM {sequences}'
)
->
fetchField
();
}
public
function
rollback
(
$savepoint_name
=
'drupal_transaction'
)
{
if
(
$this
->
savepointSupport
)
{
return
parent
::
rollBack
(
$savepoint_name
);
}
if
(
!
$this
->
inTransaction
())
{
throw
new
TransactionNoActiveException
();
}
// A previous rollback to an earlier savepoint may mean that the savepoint
// in question has already been rolled back.
if
(
!
isset
(
$this
->
transactionLayers
[
$savepoint_name
]))
{
return
;
}
// We need to find the point we're rolling back to, all other savepoints
// before are no longer needed.
while
(
$savepoint
=
array_pop
(
$this
->
transactionLayers
))
{
if
(
$savepoint
==
$savepoint_name
)
{
// Mark whole stack of transactions as needed roll back.
$this
->
willRollback
=
TRUE
;
// If it is the last the transaction in the stack, then it is not a
// savepoint, it is the transaction itself so we will need to roll back
// the transaction rather than a savepoint.
if
(
empty
(
$this
->
transactionLayers
))
{
break
;
}
return
;
}
}
if
(
$this
->
supportsTransactions
())
{
$this
->
connection
->
rollBack
();
}
}
public
function
pushTransaction
(
$name
)
{
if
(
$this
->
savepointSupport
)
{
return
parent
::
pushTransaction
(
$name
);
}
if
(
!
$this
->
supportsTransactions
())
{
return
;
}
if
(
isset
(
$this
->
transactionLayers
[
$name
]))
{
throw
new
TransactionNameNonUniqueException
(
$name
.
" is already in use."
);
}
if
(
!
$this
->
inTransaction
())
{
$this
->
connection
->
beginTransaction
();
}
$this
->
transactionLayers
[
$name
]
=
$name
;
}
public
function
popTransaction
(
$name
)
{
if
(
$this
->
savepointSupport
)
{
return
parent
::
popTransaction
(
$name
);
}
if
(
!
$this
->
supportsTransactions
())
{
return
;
}
if
(
!
$this
->
inTransaction
())
{
throw
new
TransactionNoActiveException
();
}
// Commit everything since SAVEPOINT $name.
while
(
$savepoint
=
array_pop
(
$this
->
transactionLayers
))
{
if
(
$savepoint
!=
$name
)
continue
;
// If there are no more layers left then we should commit or rollback.
if
(
empty
(
$this
->
transactionLayers
))
{
// If there was any rollback() we should roll back whole transaction.
if
(
$this
->
willRollback
)
{
$this
->
willRollback
=
FALSE
;
$this
->
connection
->
rollBack
();
}
elseif
(
!
$this
->
connection
->
commit
())
{
throw
new
TransactionCommitFailedException
();
}
}
else
{
break
;
}
}
}
}
core/lib/Drupal/Core/Database/Driver/sqlite/Delete.php
View file @
561834cd
...
...
@@ -10,24 +10,6 @@
use
Drupal\Core\Database\Query\Delete
as
QueryDelete
;
/**
* SQLite specific implementation of DeleteQuery.
*
* When the WHERE is omitted from a DELETE statement and the table being deleted
* has no triggers, SQLite uses an optimization to erase the entire table content
* without having to visit each row of the table individually.
*
* Prior to SQLite 3.6.5, SQLite does not return the actual number of rows deleted
* by that optimized "truncate" optimization.
* SQLite specific implementation of \Drupal\Core\Database\Query\Delete.
*/
class
Delete
extends
QueryDelete
{
public
function
execute
()
{
if
(
!
count
(
$this
->
condition
))
{
$total_rows
=
$this
->
connection
->
query
(
'SELECT COUNT(*) FROM {'
.
$this
->
connection
->
escapeTable
(
$this
->
table
)
.
'}'
)
->
fetchField
();
parent
::
execute
();
return
$total_rows
;
}
else
{
return
parent
::
execute
();
}
}
}
class
Delete
extends
QueryDelete
{
}
core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php
View file @
561834cd
...
...
@@ -33,8 +33,7 @@ public function name() {
* {@inheritdoc}
*/
public
function
minimumVersion
()
{
// @todo Consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support.
return
'3.3.7'
;
return
'3.6.8'
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment