Skip to content

Commit

Permalink
MDEV-15412 For any non-existing transaction ID, AS OF provides the cu…
Browse files Browse the repository at this point in the history
…rrent table contents without a warning

Fail with error on non-existing TRX_ID.

Closes #832
  • Loading branch information
midenok authored and vuvova committed Mar 29, 2019
1 parent 5c0bb07 commit 8df04fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
14 changes: 6 additions & 8 deletions mysql-test/suite/versioning/r/trx_id.result
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,16 @@ x
#
# HEX hybrids resolve to TRANSACTION
#
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0x60);
x
1
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0x60);
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0xFFFFFFFF);
ERROR HY000: TRX_ID 4294967295 not found in `mysql.transaction_registry`
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0xFFFFFFFF);
ERROR HY000: Transaction system versioning for `t2` is not supported
#
# BIT literals resolve to TRANSACTION
#
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'1100000');
x
1
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'1100000');
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'11111111111111111111111111111111');
ERROR HY000: TRX_ID 4294967295 not found in `mysql.transaction_registry`
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'11111111111111111111111111111111');
ERROR HY000: Transaction system versioning for `t2` is not supported
DROP TABLE t1, t2;
#
Expand Down
10 changes: 6 additions & 4 deletions mysql-test/suite/versioning/t/trx_id.test
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,20 @@ SELECT * FROM t2 FOR SYSTEM_TIME AS OF '2038-12-30 00:00:00';
--echo # HEX hybrids resolve to TRANSACTION
--echo #

SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0x60);
--error ER_VERS_NO_TRX_ID
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0xFFFFFFFF);
--error ER_VERS_ENGINE_UNSUPPORTED
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0x60);
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0xFFFFFFFF);


--echo #
--echo # BIT literals resolve to TRANSACTION
--echo #

SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'1100000');
--error ER_VERS_NO_TRX_ID
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'11111111111111111111111111111111');
--error ER_VERS_ENGINE_UNSUPPORTED
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'1100000');
SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'11111111111111111111111111111111');

DROP TABLE t1, t2;

Expand Down
3 changes: 0 additions & 3 deletions sql/item_vers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ Item_func_trt_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date)

null_value= !trt.query(trx_id);
if (null_value)
{
my_error(ER_VERS_NO_TRX_ID, MYF(0), (longlong) trx_id);
return true;
}

return trt[trt_field]->get_date(res, fuzzy_date);
}
Expand Down
4 changes: 4 additions & 0 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8822,7 +8822,10 @@ bool TR_table::query(ulonglong trx_id)
return false;
select= make_select(table, 0, 0, conds, NULL, 0, &error);
if (unlikely(error || !select))
{
my_error(ER_OUT_OF_RESOURCES, MYF(0));
return false;
}
// FIXME: (performance) force index 'transaction_id'
error= init_read_record(&info, thd, table, select, NULL,
1 /* use_record_cache */, true /* print_error */,
Expand All @@ -8832,6 +8835,7 @@ bool TR_table::query(ulonglong trx_id)
if (select->skip_record(thd) > 0)
return true;
}
my_error(ER_VERS_NO_TRX_ID, MYF(0), (longlong) trx_id);
return false;
}

Expand Down

0 comments on commit 8df04fb

Please sign in to comment.