Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
neoppod
Commits
9af7ecab
Commit
9af7ecab
authored
Nov 07, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql: quote `partition` column for compatibility with recent MariaDB (>=10)
parent
059cb03c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+35
-35
No files found.
neo/storage/database/mysqldb.py
View file @
9af7ecab
...
@@ -157,12 +157,12 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -157,12 +157,12 @@ class MySQLDatabaseManager(DatabaseManager):
PRIMARY KEY (rid, nid)
PRIMARY KEY (rid, nid)
) ENGINE = InnoDB"""
)
) ENGINE = InnoDB"""
)
p
=
self
.
_use_partition
and
""" PARTITION BY LIST (
partition
) (
p
=
self
.
_use_partition
and
""" PARTITION BY LIST (
`partition`
) (
PARTITION dummy VALUES IN (NULL))"""
or
''
PARTITION dummy VALUES IN (NULL))"""
or
''
# The table "trans" stores information on committed transactions.
# The table "trans" stores information on committed transactions.
q
(
"""CREATE TABLE IF NOT EXISTS trans (
q
(
"""CREATE TABLE IF NOT EXISTS trans (
partition
SMALLINT UNSIGNED NOT NULL,
`partition`
SMALLINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
packed BOOLEAN NOT NULL,
packed BOOLEAN NOT NULL,
oids MEDIUMBLOB NOT NULL,
oids MEDIUMBLOB NOT NULL,
...
@@ -170,18 +170,18 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -170,18 +170,18 @@ class MySQLDatabaseManager(DatabaseManager):
description BLOB NOT NULL,
description BLOB NOT NULL,
ext BLOB NOT NULL,
ext BLOB NOT NULL,
ttid BIGINT UNSIGNED NOT NULL,
ttid BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (
partition
, tid)
PRIMARY KEY (
`partition`
, tid)
) ENGINE = InnoDB"""
+
p
)
) ENGINE = InnoDB"""
+
p
)
# The table "obj" stores committed object metadata.
# The table "obj" stores committed object metadata.
q
(
"""CREATE TABLE IF NOT EXISTS obj (
q
(
"""CREATE TABLE IF NOT EXISTS obj (
partition
SMALLINT UNSIGNED NOT NULL,
`partition`
SMALLINT UNSIGNED NOT NULL,
oid BIGINT UNSIGNED NOT NULL,
oid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
data_id BIGINT UNSIGNED NULL,
data_id BIGINT UNSIGNED NULL,
value_tid BIGINT UNSIGNED NULL,
value_tid BIGINT UNSIGNED NULL,
PRIMARY KEY (
partition
, tid, oid),
PRIMARY KEY (
`partition`
, tid, oid),
KEY (
partition
, oid, tid),
KEY (
`partition`
, oid, tid),
KEY (data_id)
KEY (data_id)
) ENGINE = InnoDB"""
+
p
)
) ENGINE = InnoDB"""
+
p
)
...
@@ -197,7 +197,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -197,7 +197,7 @@ class MySQLDatabaseManager(DatabaseManager):
# The table "ttrans" stores information on uncommitted transactions.
# The table "ttrans" stores information on uncommitted transactions.
q
(
"""CREATE TABLE IF NOT EXISTS ttrans (
q
(
"""CREATE TABLE IF NOT EXISTS ttrans (
partition
SMALLINT UNSIGNED NOT NULL,
`partition`
SMALLINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
packed BOOLEAN NOT NULL,
packed BOOLEAN NOT NULL,
oids MEDIUMBLOB NOT NULL,
oids MEDIUMBLOB NOT NULL,
...
@@ -209,7 +209,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -209,7 +209,7 @@ class MySQLDatabaseManager(DatabaseManager):
# The table "tobj" stores uncommitted object metadata.
# The table "tobj" stores uncommitted object metadata.
q
(
"""CREATE TABLE IF NOT EXISTS tobj (
q
(
"""CREATE TABLE IF NOT EXISTS tobj (
partition
SMALLINT UNSIGNED NOT NULL,
`partition`
SMALLINT UNSIGNED NOT NULL,
oid BIGINT UNSIGNED NOT NULL,
oid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
tid BIGINT UNSIGNED NOT NULL,
data_id BIGINT UNSIGNED NULL,
data_id BIGINT UNSIGNED NULL,
...
@@ -262,13 +262,13 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -262,13 +262,13 @@ class MySQLDatabaseManager(DatabaseManager):
p64
=
util
.
p64
p64
=
util
.
p64
q
=
self
.
query
q
=
self
.
query
trans
=
{
partition
:
p64
(
tid
)
trans
=
{
partition
:
p64
(
tid
)
for
partition
,
tid
in
q
(
"SELECT
partition
, MAX(tid)"
for
partition
,
tid
in
q
(
"SELECT
`partition`
, MAX(tid)"
" FROM trans GROUP BY
partition
"
)}
" FROM trans GROUP BY
`partition`
"
)}
obj
=
{
partition
:
p64
(
tid
)
obj
=
{
partition
:
p64
(
tid
)
for
partition
,
tid
in
q
(
"SELECT
partition
, MAX(tid)"
for
partition
,
tid
in
q
(
"SELECT
`partition`
, MAX(tid)"
" FROM obj GROUP BY
partition
"
)}
" FROM obj GROUP BY
`partition`
"
)}
oid
=
q
(
"SELECT MAX(oid) FROM (SELECT MAX(oid) AS oid FROM obj"
oid
=
q
(
"SELECT MAX(oid) FROM (SELECT MAX(oid) AS oid FROM obj"
" GROUP BY
partition
) as t"
)[
0
][
0
]
" GROUP BY
`partition`
) as t"
)[
0
][
0
]
if
all
:
if
all
:
tid
=
q
(
"SELECT MAX(tid) FROM ttrans"
)[
0
][
0
]
tid
=
q
(
"SELECT MAX(tid) FROM ttrans"
)[
0
][
0
]
if
tid
is
not
None
:
if
tid
is
not
None
:
...
@@ -289,21 +289,21 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -289,21 +289,21 @@ class MySQLDatabaseManager(DatabaseManager):
oid
=
util
.
u64
(
oid
)
oid
=
util
.
u64
(
oid
)
tid
=
util
.
u64
(
tid
)
tid
=
util
.
u64
(
tid
)
q
=
self
.
query
q
=
self
.
query
return
q
(
"SELECT 1 FROM obj WHERE
partition
=%d AND oid=%d AND tid=%d"
return
q
(
"SELECT 1 FROM obj WHERE
`partition`
=%d AND oid=%d AND tid=%d"
%
(
self
.
_getPartition
(
oid
),
oid
,
tid
))
or
all
and
\
%
(
self
.
_getPartition
(
oid
),
oid
,
tid
))
or
all
and
\
q
(
"SELECT 1 FROM tobj WHERE tid=%d AND oid=%d"
%
(
tid
,
oid
))
q
(
"SELECT 1 FROM tobj WHERE tid=%d AND oid=%d"
%
(
tid
,
oid
))
def
getLastObjectTID
(
self
,
oid
):
def
getLastObjectTID
(
self
,
oid
):
oid
=
util
.
u64
(
oid
)
oid
=
util
.
u64
(
oid
)
r
=
self
.
query
(
"SELECT tid FROM obj"
r
=
self
.
query
(
"SELECT tid FROM obj"
" WHERE
partition
=%d AND oid=%d"
" WHERE
`partition`
=%d AND oid=%d"
" ORDER BY tid DESC LIMIT 1"
" ORDER BY tid DESC LIMIT 1"
%
(
self
.
_getPartition
(
oid
),
oid
))
%
(
self
.
_getPartition
(
oid
),
oid
))
return
util
.
p64
(
r
[
0
][
0
])
if
r
else
None
return
util
.
p64
(
r
[
0
][
0
])
if
r
else
None
def
_getNextTID
(
self
,
*
args
):
# partition, oid, tid
def
_getNextTID
(
self
,
*
args
):
# partition, oid, tid
r
=
self
.
query
(
"SELECT tid FROM obj"
r
=
self
.
query
(
"SELECT tid FROM obj"
" WHERE
partition
=%d AND oid=%d AND tid>%d"
" WHERE
`partition`
=%d AND oid=%d AND tid>%d"
" ORDER BY tid LIMIT 1"
%
args
)
" ORDER BY tid LIMIT 1"
%
args
)
return
r
[
0
][
0
]
if
r
else
None
return
r
[
0
][
0
]
if
r
else
None
...
@@ -312,7 +312,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -312,7 +312,7 @@ class MySQLDatabaseManager(DatabaseManager):
partition
=
self
.
_getPartition
(
oid
)
partition
=
self
.
_getPartition
(
oid
)
sql
=
(
'SELECT tid, compression, data.hash, value, value_tid'
sql
=
(
'SELECT tid, compression, data.hash, value, value_tid'
' FROM obj LEFT JOIN data ON (obj.data_id = data.id)'
' FROM obj LEFT JOIN data ON (obj.data_id = data.id)'
' WHERE
partition
= %d AND oid = %d'
)
%
(
partition
,
oid
)
' WHERE
`partition`
= %d AND oid = %d'
)
%
(
partition
,
oid
)
if
before_tid
is
not
None
:
if
before_tid
is
not
None
:
sql
+=
' AND tid < %d ORDER BY tid DESC LIMIT 1'
%
before_tid
sql
+=
' AND tid < %d ORDER BY tid DESC LIMIT 1'
%
before_tid
elif
tid
is
not
None
:
elif
tid
is
not
None
:
...
@@ -363,7 +363,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -363,7 +363,7 @@ class MySQLDatabaseManager(DatabaseManager):
# row count, although we use indexes) when there are rows to
# row count, although we use indexes) when there are rows to
# delete. It should be done as an idle task, by chunks.
# delete. It should be done as an idle task, by chunks.
for
partition
in
offset_list
:
for
partition
in
offset_list
:
where
=
" WHERE
partition
=%d"
%
partition
where
=
" WHERE
`partition`
=%d"
%
partition
data_id_list
=
[
x
for
x
,
in
data_id_list
=
[
x
for
x
,
in
q
(
"SELECT DISTINCT data_id FROM obj"
+
where
)
if
x
]
q
(
"SELECT DISTINCT data_id FROM obj"
+
where
)
if
x
]
if
not
self
.
_use_partition
:
if
not
self
.
_use_partition
:
...
@@ -404,7 +404,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -404,7 +404,7 @@ class MySQLDatabaseManager(DatabaseManager):
if
value_serial
:
if
value_serial
:
value_serial
=
u64
(
value_serial
)
value_serial
=
u64
(
value_serial
)
(
data_id
,),
=
q
(
"SELECT data_id FROM obj"
(
data_id
,),
=
q
(
"SELECT data_id FROM obj"
" WHERE
partition
=%d AND oid=%d AND tid=%d"
" WHERE
`partition`
=%d AND oid=%d AND tid=%d"
%
(
partition
,
oid
,
value_serial
))
%
(
partition
,
oid
,
value_serial
))
if
temporary
:
if
temporary
:
self
.
holdData
(
data_id
)
self
.
holdData
(
data_id
)
...
@@ -447,7 +447,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -447,7 +447,7 @@ class MySQLDatabaseManager(DatabaseManager):
def
_getDataTID
(
self
,
oid
,
tid
=
None
,
before_tid
=
None
):
def
_getDataTID
(
self
,
oid
,
tid
=
None
,
before_tid
=
None
):
sql
=
(
'SELECT tid, value_tid FROM obj'
sql
=
(
'SELECT tid, value_tid FROM obj'
' WHERE
partition
= %d AND oid = %d'
' WHERE
`partition`
= %d AND oid = %d'
)
%
(
self
.
_getPartition
(
oid
),
oid
)
)
%
(
self
.
_getPartition
(
oid
),
oid
)
if
tid
is
not
None
:
if
tid
is
not
None
:
sql
+=
' AND tid = %d'
%
tid
sql
+=
' AND tid = %d'
%
tid
...
@@ -482,13 +482,13 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -482,13 +482,13 @@ class MySQLDatabaseManager(DatabaseManager):
self
.
releaseData
(
data_id_list
)
self
.
releaseData
(
data_id_list
)
q
(
"DELETE"
+
sql
)
q
(
"DELETE"
+
sql
)
q
(
"""DELETE FROM ttrans WHERE tid = %d"""
%
tid
)
q
(
"""DELETE FROM ttrans WHERE tid = %d"""
%
tid
)
q
(
"""DELETE FROM trans WHERE
partition
= %d AND tid = %d"""
%
q
(
"""DELETE FROM trans WHERE
`partition`
= %d AND tid = %d"""
%
(
getPartition
(
tid
),
tid
))
(
getPartition
(
tid
),
tid
))
# delete from obj using indexes
# delete from obj using indexes
data_id_set
=
set
()
data_id_set
=
set
()
for
oid
in
oid_list
:
for
oid
in
oid_list
:
oid
=
u64
(
oid
)
oid
=
u64
(
oid
)
sql
=
" FROM obj WHERE
partition
=%d AND oid=%d AND tid=%d"
\
sql
=
" FROM obj WHERE
`partition`
=%d AND oid=%d AND tid=%d"
\
%
(
getPartition
(
oid
),
oid
,
tid
)
%
(
getPartition
(
oid
),
oid
,
tid
)
data_id_set
.
update
(
*
q
(
"SELECT data_id"
+
sql
))
data_id_set
.
update
(
*
q
(
"SELECT data_id"
+
sql
))
q
(
"DELETE"
+
sql
)
q
(
"DELETE"
+
sql
)
...
@@ -498,7 +498,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -498,7 +498,7 @@ class MySQLDatabaseManager(DatabaseManager):
def
deleteObject
(
self
,
oid
,
serial
=
None
):
def
deleteObject
(
self
,
oid
,
serial
=
None
):
u64
=
util
.
u64
u64
=
util
.
u64
oid
=
u64
(
oid
)
oid
=
u64
(
oid
)
sql
=
" FROM obj WHERE
partition
=%d AND oid=%d"
\
sql
=
" FROM obj WHERE
`partition`
=%d AND oid=%d"
\
%
(
self
.
_getPartition
(
oid
),
oid
)
%
(
self
.
_getPartition
(
oid
),
oid
)
if
serial
:
if
serial
:
sql
+=
' AND tid=%d'
%
u64
(
serial
)
sql
+=
' AND tid=%d'
%
u64
(
serial
)
...
@@ -508,7 +508,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -508,7 +508,7 @@ class MySQLDatabaseManager(DatabaseManager):
self
.
_pruneData
(
data_id_list
)
self
.
_pruneData
(
data_id_list
)
def
_deleteRange
(
self
,
partition
,
min_tid
=
None
,
max_tid
=
None
):
def
_deleteRange
(
self
,
partition
,
min_tid
=
None
,
max_tid
=
None
):
sql
=
" WHERE
partition
=%d"
%
partition
sql
=
" WHERE
`partition`
=%d"
%
partition
if
min_tid
:
if
min_tid
:
sql
+=
" AND %d < tid"
%
util
.
u64
(
min_tid
)
sql
+=
" AND %d < tid"
%
util
.
u64
(
min_tid
)
if
max_tid
:
if
max_tid
:
...
@@ -524,7 +524,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -524,7 +524,7 @@ class MySQLDatabaseManager(DatabaseManager):
tid
=
util
.
u64
(
tid
)
tid
=
util
.
u64
(
tid
)
q
=
self
.
query
q
=
self
.
query
r
=
q
(
"SELECT oids, user, description, ext, packed, ttid"
r
=
q
(
"SELECT oids, user, description, ext, packed, ttid"
" FROM trans WHERE
partition
= %d AND tid = %d"
" FROM trans WHERE
`partition`
= %d AND tid = %d"
%
(
self
.
_getPartition
(
tid
),
tid
))
%
(
self
.
_getPartition
(
tid
),
tid
))
if
not
r
and
all
:
if
not
r
and
all
:
r
=
q
(
"SELECT oids, user, description, ext, packed, ttid"
r
=
q
(
"SELECT oids, user, description, ext, packed, ttid"
...
@@ -542,7 +542,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -542,7 +542,7 @@ class MySQLDatabaseManager(DatabaseManager):
p64
=
util
.
p64
p64
=
util
.
p64
r
=
self
.
query
(
"""SELECT tid, LENGTH(value)
r
=
self
.
query
(
"""SELECT tid, LENGTH(value)
FROM obj LEFT JOIN data ON (obj.data_id = data.id)
FROM obj LEFT JOIN data ON (obj.data_id = data.id)
WHERE
partition
= %d AND oid = %d AND tid >= %d
WHERE
`partition`
= %d AND oid = %d AND tid >= %d
ORDER BY tid DESC LIMIT %d, %d"""
%
ORDER BY tid DESC LIMIT %d, %d"""
%
(
self
.
_getPartition
(
oid
),
oid
,
self
.
_getPackTID
(),
offset
,
length
))
(
self
.
_getPartition
(
oid
),
oid
,
self
.
_getPackTID
(),
offset
,
length
))
if
r
:
if
r
:
...
@@ -554,7 +554,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -554,7 +554,7 @@ class MySQLDatabaseManager(DatabaseManager):
p64
=
util
.
p64
p64
=
util
.
p64
min_tid
=
u64
(
min_tid
)
min_tid
=
u64
(
min_tid
)
r
=
self
.
query
(
'SELECT tid, oid FROM obj'
r
=
self
.
query
(
'SELECT tid, oid FROM obj'
' WHERE
partition
= %d AND tid <= %d'
' WHERE
`partition`
= %d AND tid <= %d'
' AND (tid = %d AND %d <= oid OR %d < tid)'
' AND (tid = %d AND %d <= oid OR %d < tid)'
' ORDER BY tid ASC, oid ASC LIMIT %d'
%
(
' ORDER BY tid ASC, oid ASC LIMIT %d'
%
(
partition
,
u64
(
max_tid
),
min_tid
,
u64
(
min_oid
),
min_tid
,
length
))
partition
,
u64
(
max_tid
),
min_tid
,
u64
(
min_oid
),
min_tid
,
length
))
...
@@ -562,7 +562,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -562,7 +562,7 @@ class MySQLDatabaseManager(DatabaseManager):
def
getTIDList
(
self
,
offset
,
length
,
partition_list
):
def
getTIDList
(
self
,
offset
,
length
,
partition_list
):
q
=
self
.
query
q
=
self
.
query
r
=
q
(
"""SELECT tid FROM trans WHERE
partition
in (%s)
r
=
q
(
"""SELECT tid FROM trans WHERE
`partition`
in (%s)
ORDER BY tid DESC LIMIT %d,%d"""
\
ORDER BY tid DESC LIMIT %d,%d"""
\
%
(
','
.
join
(
map
(
str
,
partition_list
)),
offset
,
length
))
%
(
','
.
join
(
map
(
str
,
partition_list
)),
offset
,
length
))
return
[
util
.
p64
(
t
[
0
])
for
t
in
r
]
return
[
util
.
p64
(
t
[
0
])
for
t
in
r
]
...
@@ -573,7 +573,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -573,7 +573,7 @@ class MySQLDatabaseManager(DatabaseManager):
min_tid
=
u64
(
min_tid
)
min_tid
=
u64
(
min_tid
)
max_tid
=
u64
(
max_tid
)
max_tid
=
u64
(
max_tid
)
r
=
self
.
query
(
"""SELECT tid FROM trans
r
=
self
.
query
(
"""SELECT tid FROM trans
WHERE
partition
= %(partition)d
WHERE
`partition`
= %(partition)d
AND tid >= %(min_tid)d AND tid <= %(max_tid)d
AND tid >= %(min_tid)d AND tid <= %(max_tid)d
ORDER BY tid ASC LIMIT %(length)d"""
%
{
ORDER BY tid ASC LIMIT %(length)d"""
%
{
'partition'
:
partition
,
'partition'
:
partition
,
...
@@ -599,11 +599,11 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -599,11 +599,11 @@ class MySQLDatabaseManager(DatabaseManager):
}
}
for
kw
[
'table'
]
in
'obj'
,
'tobj'
:
for
kw
[
'table'
]
in
'obj'
,
'tobj'
:
for
kw
[
'tid'
],
in
q
(
'SELECT tid FROM %(table)s'
for
kw
[
'tid'
],
in
q
(
'SELECT tid FROM %(table)s'
' WHERE
partition
=%(partition)d AND oid=%(oid)d'
' WHERE
`partition`
=%(partition)d AND oid=%(oid)d'
' AND tid>=%(max_tid)d AND value_tid=%(orig_tid)d'
' AND tid>=%(max_tid)d AND value_tid=%(orig_tid)d'
' ORDER BY tid ASC'
%
kw
):
' ORDER BY tid ASC'
%
kw
):
q
(
'UPDATE %(table)s SET value_tid=%(new_tid)s'
q
(
'UPDATE %(table)s SET value_tid=%(new_tid)s'
' WHERE
partition
=%(partition)d AND oid=%(oid)d'
' WHERE
`partition`
=%(partition)d AND oid=%(oid)d'
' AND tid=%(tid)d'
%
kw
)
' AND tid=%(tid)d'
%
kw
)
if
value_serial
is
None
:
if
value_serial
is
None
:
# First found, mark its serial for future reference.
# First found, mark its serial for future reference.
...
@@ -622,7 +622,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -622,7 +622,7 @@ class MySQLDatabaseManager(DatabaseManager):
" FROM obj WHERE tid <= %d GROUP BY oid"
" FROM obj WHERE tid <= %d GROUP BY oid"
%
tid
):
%
tid
):
partition
=
getPartition
(
oid
)
partition
=
getPartition
(
oid
)
if
q
(
"SELECT 1 FROM obj WHERE
partition
= %d"
if
q
(
"SELECT 1 FROM obj WHERE
`partition`
= %d"
" AND oid = %d AND tid = %d AND data_id IS NULL"
" AND oid = %d AND tid = %d AND data_id IS NULL"
%
(
partition
,
oid
,
max_serial
)):
%
(
partition
,
oid
,
max_serial
)):
max_serial
+=
1
max_serial
+=
1
...
@@ -630,7 +630,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -630,7 +630,7 @@ class MySQLDatabaseManager(DatabaseManager):
continue
continue
# There are things to delete for this object
# There are things to delete for this object
data_id_set
=
set
()
data_id_set
=
set
()
sql
=
' FROM obj WHERE
partition
=%d AND oid=%d'
\
sql
=
' FROM obj WHERE
`partition`
=%d AND oid=%d'
\
' AND tid<%d'
%
(
partition
,
oid
,
max_serial
)
' AND tid<%d'
%
(
partition
,
oid
,
max_serial
)
for
serial
,
data_id
in
q
(
'SELECT tid, data_id'
+
sql
):
for
serial
,
data_id
in
q
(
'SELECT tid, data_id'
+
sql
):
data_id_set
.
add
(
data_id
)
data_id_set
.
add
(
data_id
)
...
@@ -648,7 +648,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -648,7 +648,7 @@ class MySQLDatabaseManager(DatabaseManager):
count
,
tid_checksum
,
max_tid
=
self
.
query
(
count
,
tid_checksum
,
max_tid
=
self
.
query
(
"""SELECT COUNT(*), SHA1(GROUP_CONCAT(tid SEPARATOR ",")), MAX(tid)
"""SELECT COUNT(*), SHA1(GROUP_CONCAT(tid SEPARATOR ",")), MAX(tid)
FROM (SELECT tid FROM trans
FROM (SELECT tid FROM trans
WHERE
partition
= %(partition)s
WHERE
`partition`
= %(partition)s
AND tid >= %(min_tid)d
AND tid >= %(min_tid)d
AND tid <= %(max_tid)d
AND tid <= %(max_tid)d
ORDER BY tid ASC %(limit)s) AS t"""
%
{
ORDER BY tid ASC %(limit)s) AS t"""
%
{
...
@@ -670,7 +670,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -670,7 +670,7 @@ class MySQLDatabaseManager(DatabaseManager):
r
=
self
.
query
(
r
=
self
.
query
(
"""SELECT tid, oid
"""SELECT tid, oid
FROM obj
FROM obj
WHERE
partition
= %(partition)s
WHERE
`partition`
= %(partition)s
AND tid <= %(max_tid)d
AND tid <= %(max_tid)d
AND (tid > %(min_tid)d OR
AND (tid > %(min_tid)d OR
tid = %(min_tid)d AND oid >= %(min_oid)d)
tid = %(min_tid)d AND oid >= %(min_oid)d)
...
...
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