mariadb/mysql-test/suite
Alexander Barkov 46be31982a MDEV-16094 Crash when using AS OF with a stored function
MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs

Problem:

Vers_history_point::resolve_unit() tested item->result_type() before
item->fix_fields() was called.

- Item_func_get_user_var::result_type() returned REAL_RESULT by default.
  This caused MDEV-16100.
- Item_func_sp::result_type() crashed on assert.
  This caused MDEV-16094

Changes:
1. Adding item->fix_fields() into Vers_history_point::resolve_unit()
   before using data type specific properties of the history point
   expression.

2. Adding a new virtual method Type_handler::Vers_history_point_resolve_unit()

3. Implementing type-specific
   Type_handler_xxx::Type_handler::Vers_history_point_resolve_unit()
    in the way to:
    a. resolve temporal and general purpose string types to TIMESTAMP
    b. resolve BIT and general purpose INT types to TRANSACTION
    c. disallow use of non-relevant data type expressions in FOR SYSTEM_TIME

    Note, DOUBLE and DECIMAL data types are disallowed intentionally.
    - DOUBLE does not have enough precision to hold huge BIGINT UNSIGNED values
    - DECIMAL rounds on conversion to INT
    Both lack of precision and rounding might potentionally lead to
    very unpredictable results when a wrong transaction ID would be chosen.
    If one really wants dangerous use of DOUBLE and DECIMAL, explicit CAST
    can be used:

      FOR SYSTEM_TIME AS OF CAST(double_or_decimal AS UNSIGNED)

    QQ: perhaps DECIMAL(N,0) could still be allowed.

4. Adding a new virtual method Item::type_handler_for_system_time(),
   to make HEX hybrids and bit literals work as TRANSACTION rather
   than TIMESTAMP.

5. sql_yacc.yy: replacing the rule temporal_literal to "TIMESTAMP TEXT_STRING".
   Other temporal literals now resolve to TIMESTAMP through the new
   Type_handler methods. No special grammar needed. This removed
   a few shift/resolve conflicts.
   (TIMESTAMP related conflicts in "history_point:" will be removed separately)

6. Removing the "timestamp_only" parameter from
   vers_select_conds_t::resolve_units() and Vers_history_point::resolve_unit().
   It was a hint telling that a table did not have any TRANSACTION-aware
   system time columns, so it's OK to resolve to TIMESTAMP in case of uncertainty.
   In the new reduction it works as follows:
   - the decision between TIMESTAMP and TRANSACTION is first made
     based only on the expression data type only
   - then, in case if the expression resolved to TRANSACTION, the table
     is checked if TRANSACTION-aware columns really exist.
   This way is safer against possible ALTER TABLE statements changing
   ROW START and ROW END columns from "BIGINT UNSIGNED" to "TIMESTAMP(x)"
   or the other way around.
2018-05-15 09:33:29 +04:00
..
archive MDEV-12645 - mysql_install_db: no install test db option 2018-04-30 19:34:08 +04:00
binlog MDEV-16020 SP variables inside GROUP BY..WITH ROLLUP break replication 2018-04-27 22:11:18 +04:00
binlog_encryption Merge remote-tracking branch '10.2' into 10.3 2018-04-12 12:41:19 +03:00
compat/oracle MDEV-16152 Expressions with INTERVAL return bad results in some cases 2018-05-14 11:36:22 +04:00
csv Added Max_index_length and Temporary to SHOW TABLE STATUS 2018-02-12 17:17:26 +02:00
encryption MDEV-12645 - mysql_install_db: no install test db option 2018-04-30 19:34:08 +04:00
engines Move mysql-test-run/extra/rpl_tests to suite/rpl/include 2018-03-29 13:59:44 +03:00
federated MDEV-14789 Creating federated table on versioned table fails 2018-02-23 15:33:21 +01:00
funcs_1 Merge 10.2 into 10.3 2018-04-24 20:59:57 +03:00
funcs_2 Added Max_index_length and Temporary to SHOW TABLE STATUS 2018-02-12 17:17:26 +02:00
galera Merge 10.2 into 10.3 2018-05-12 22:14:59 +03:00
galera_3nodes Merge remote-tracking branch '10.2' into 10.3 2018-04-12 12:41:19 +03:00
gcol MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY and ALGORITHM=INSTANT 2018-05-07 14:58:11 +05:30
handler
heap Added Max_index_length and Temporary to SHOW TABLE STATUS 2018-02-12 17:17:26 +02:00
innodb Merge 10.2 into 10.3 2018-05-12 22:14:59 +03:00
innodb_fts Merge 10.2 into 10.3 2018-05-12 22:14:59 +03:00
innodb_gis Merge 10.2 into 10.3 2018-04-23 09:49:58 +03:00
innodb_undo Enable --suite=innodb_undo 2018-03-22 18:02:58 +02:00
innodb_zip MDEV-12645 - mysql_install_db: no install test db option 2018-04-30 19:34:08 +04:00
jp
json MDEV-15561 json_extract returns NULL with numbers in scientific notation. 2018-03-25 00:32:14 +04:00
large_tests
maria Don't report errors from open_table() twice 2018-05-14 10:08:05 +03:00
mariabackup Merge branch '10.2' into 10.3 2018-05-11 13:15:10 +02:00
mtr/t
mtr2
multi_source Mdev-10664 Add statuses about optimistic parallel replication stalls 2018-04-19 16:04:23 +05:30
optimizer_unfixed_bugs
parts Don't report errors from open_table() twice 2018-05-14 10:08:05 +03:00
perfschema Merge remote-tracking branch '10.2' into 10.3 2018-04-12 12:41:19 +03:00
perfschema_stress
plugins Merge 10.2 into 10.3 2018-05-12 22:14:59 +03:00
roles Added flush tables to acl_load_mutex-5170.test 2018-03-29 13:59:44 +03:00
rpl cleanup: include/have_rbr_triggers.inc 2018-05-12 10:16:45 +02:00
sql_sequence MDEV-15970 Crash when doing truncate on locked sequence 2018-05-14 10:08:05 +03:00
storage_engine Follow up for 9a84980668 - adjustments to storage_engine tests 2018-05-03 20:54:23 +03:00
stress
sys_vars MDEV-15995 Drop extra semicolon in VARIABLE_COMMENT for SYSTEM_VERSIONING_ALTER_HISTORY 2018-05-12 10:16:46 +02:00
unit Windows,tests : fix pcre_test_bat test from pcre library. 2018-02-14 23:21:58 +00:00
vcol Merge branch '10.2' into 10.3 2018-05-11 13:15:10 +02:00
versioning MDEV-16094 Crash when using AS OF with a stored function 2018-05-15 09:33:29 +04:00
wsrep