зеркало из https://github.com/github/vitess-gh.git
Disallow PASS_DML plan
PASS_DML doesn't play well with rowcache, update stream, and filtered replication. Blacklisting it for now. We'll need to later clean up the code paths that lead to it once things stabilize.
This commit is contained in:
Родитель
428e929fdb
Коммит
b4a7090051
|
@ -242,10 +242,9 @@ func (qe *QueryEngine) Execute(logStats *sqlQueryStats, query *proto.Query) (rep
|
|||
}
|
||||
switch plan.PlanId {
|
||||
case sqlparser.PLAN_PASS_DML:
|
||||
if plan.TableInfo != nil && plan.TableInfo.CacheType != schema.CACHE_NONE {
|
||||
panic(NewTabletError(FAIL, "DML too complex for cached table"))
|
||||
}
|
||||
reply = qe.directFetch(logStats, conn, plan.FullQuery, plan.BindVars, nil, nil)
|
||||
// TODO(sougou): Delete code path that leads here.
|
||||
// We need to permanently disallow this plan.
|
||||
panic(NewTabletError(FAIL, "DML too complex"))
|
||||
case sqlparser.PLAN_INSERT_PK:
|
||||
reply = qe.execInsertPK(logStats, conn, plan, invalidator)
|
||||
case sqlparser.PLAN_INSERT_SUBQUERY:
|
||||
|
|
|
@ -299,30 +299,6 @@ cases = [
|
|||
'delete from vtocc_a where eid>1',
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'expressions',
|
||||
['begin',
|
||||
Case(sql="insert into vtocc_a(eid, id, name, foo) values (7, 1+1, '', '')",
|
||||
rewritten="insert into vtocc_a(eid, id, name, foo) values (7, 1+1, '', '')"),
|
||||
'commit',
|
||||
Case('select * from vtocc_a where eid = 7',
|
||||
result=[(7L, 2L, '', '')]),
|
||||
'begin',
|
||||
'delete from vtocc_a where eid>1',
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'no index',
|
||||
['begin',
|
||||
Case(sql="insert into vtocc_d(eid, id) values (1, 1)",
|
||||
rewritten="insert into vtocc_d(eid, id) values (1, 1)"),
|
||||
'commit',
|
||||
Case(sql='select * from vtocc_d',
|
||||
result=[(1L, 1L)]),
|
||||
'begin',
|
||||
'delete from vtocc_d',
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'on duplicate key',
|
||||
['begin',
|
||||
|
@ -344,12 +320,6 @@ cases = [
|
|||
Case(sql='select * from vtocc_a where eid = 8',
|
||||
result=[(8L, 2L, 'foo', '')]),
|
||||
'begin',
|
||||
Case(sql="insert into vtocc_a(eid, id, name, foo) values (8, 2, '', '') on duplicate key update id = 2+1",
|
||||
rewritten="insert into vtocc_a(eid, id, name, foo) values (8, 2, '', '') on duplicate key update id = 2+1"),
|
||||
'commit',
|
||||
Case(sql='select * from vtocc_a where eid = 8',
|
||||
result=[(8L, 3L, 'foo', '')]),
|
||||
'begin',
|
||||
'delete from vtocc_a where eid>1',
|
||||
'commit']),
|
||||
|
||||
|
@ -479,30 +449,6 @@ cases = [
|
|||
"update vtocc_a set eid=1 where id=1",
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'complex pk change',
|
||||
['begin',
|
||||
Case(sql="update vtocc_a set eid = 1+1 where eid = 1 and id = 1",
|
||||
rewritten="update vtocc_a set eid = 1+1 where eid = 1 and id = 1"),
|
||||
'commit',
|
||||
Case(sql='select eid from vtocc_a where id = 1',
|
||||
result=[(2L,)]),
|
||||
'begin',
|
||||
"update vtocc_a set eid=1 where id=1",
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'complex where',
|
||||
['begin',
|
||||
Case(sql="update vtocc_a set eid = 1+1 where eid = 1 and id = 1+0",
|
||||
rewritten="update vtocc_a set eid = 1+1 where eid = 1 and id = 1+0"),
|
||||
'commit',
|
||||
Case(sql='select eid from vtocc_a where id = 1',
|
||||
result=[(2L,)]),
|
||||
'begin',
|
||||
"update vtocc_a set eid=1 where id=1",
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'partial pk',
|
||||
['begin',
|
||||
|
@ -561,19 +507,6 @@ cases = [
|
|||
"update vtocc_a set foo='fghi' where id=2",
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'no index',
|
||||
['begin',
|
||||
"insert into vtocc_d(eid, id) values (1, 1)",
|
||||
Case(sql="update vtocc_d set id = 2 where eid = 1",
|
||||
rewritten="update vtocc_d set id = 2 where eid = 1"),
|
||||
'commit',
|
||||
Case(sql='select * from vtocc_d',
|
||||
result=[(1L, 2L)]),
|
||||
'begin',
|
||||
'delete from vtocc_d',
|
||||
'commit']),
|
||||
|
||||
MultiCase(
|
||||
'delete',
|
||||
['begin',
|
||||
|
|
|
@ -128,6 +128,22 @@ class TestNocache(framework.TestCase):
|
|||
self.assertEqual(vstart.mget("Voltron.QueryCache.Length", 0)+1, vend.Voltron.QueryCache.Length)
|
||||
self.assertEqual(vstart.mget("QueryCacheLength", 0)+1, vend.QueryCacheLength)
|
||||
|
||||
def test_complex_dmls(self):
|
||||
self.env.conn.begin()
|
||||
try:
|
||||
with self.assertRaises(dbexceptions.DatabaseError):
|
||||
self.env.execute("insert into vtocc_a(eid, id, name, foo) values (7, 1+1, '', '')")
|
||||
with self.assertRaises(dbexceptions.DatabaseError):
|
||||
self.env.execute("insert into vtocc_d(eid, id) values (1, 1)")
|
||||
with self.assertRaises(dbexceptions.DatabaseError):
|
||||
self.env.execute("insert into vtocc_a(eid, id, name, foo) values (8, 2, '', '') on duplicate key update id = 2+1")
|
||||
with self.assertRaises(dbexceptions.DatabaseError):
|
||||
self.env.execute("update vtocc_a set eid = 1+1 where eid = 1 and id = 1")
|
||||
with self.assertRaises(dbexceptions.DatabaseError):
|
||||
self.env.execute("insert into vtocc_d(eid, id) values (1, 1)")
|
||||
finally:
|
||||
self.env.conn.rollback()
|
||||
|
||||
def test_for_update(self):
|
||||
try:
|
||||
self.env.execute("select * from vtocc_test where intval=2 for update")
|
||||
|
|
Загрузка…
Ссылка в новой задаче