Commit graph

180383 commits

Author SHA1 Message Date
Aleksey Midenkov
b55a149194
Timestamp-based versioning for InnoDB [closes #209]
* Removed integer_fields check
* Reworked Vers_parse_info::check_sys_fields()
* Misc renames
* versioned as vers_sys_type_t

* Removed versioned_by_sql(), versioned_by_engine()

versioned() works as before;
versioned(VERS_TIMESTAMP) is versioned_by_sql();
versioned(VERS_TRX_ID) is versioned_by_engine().

* create_tmp_table() fix
* Foreign constraints for timestamp-based
* Range auto-specifier fix
* SQL: 1-row partition rotation fix [fixes #260]
* Fix 'drop system versioning, algorithm=inplace'
2017-12-18 19:03:51 +03:00
Aleksey Midenkov
d5e37621cf Scripts: VTMD_TEMPLATE removed [#286] 2017-12-17 12:32:33 +03:00
Aleksey Midenkov
62b44b0efa Tests: innodb_encryption detect table count 2017-12-17 12:10:19 +03:00
Eugene Kosov
656d6f399e
SQL: missing stmt_arena [#387] 2017-12-15 23:33:03 +03:00
Eugene Kosov
9b55cc73f1
SQL, IB: unversioned fields with ALTER TABLE [fixes #401] 2017-12-15 20:37:36 +03:00
Aleksey Midenkov
4624e565f3 System Versioning 1.0 pre6
Merge remote-tracking branch 'mariadb/bb-10.3-temporal-serg' into trunk
2017-12-15 18:12:18 +03:00
Aleksey Midenkov
70d7672377 SQL: MDEV-14633 Assertion on TRT read [fixes #406] 2017-12-15 16:42:25 +03:00
Eugene Kosov
0e0f1126e6
MDEV-14649 Assertion `t->mysql_col_len == 8' failed in row_insert_for_mysql
SQL: add check for internal partition table type

Also fixes MDEV-14654
2017-12-15 16:35:53 +03:00
Aleksey Midenkov
73606a3977 System Versioning 1.0 pre5 [closes #407]
Merge branch '10.3' into trunk

Both field_visibility and VERS_HIDDEN_FLAG exist independently.

TODO:
VERS_HIDDEN_FLAG should be replaced with SYSTEM_INVISIBLE (or COMPLETELY_INVISIBLE?).
2017-12-15 15:18:59 +03:00
Aleksey Midenkov
2b67b7cb08 Misc: updated .gitignore 2017-12-15 12:18:06 +04:00
Sachin Setiya
0bc3c0fbc8 mysqldump fix for invisible column
Actually there are 2 issues in the case of invisible columns

  1st `select fields from t1` will have more fields then `select * from t1`.
So instead of `select * from t1` we are using `select a,b,invisible from t1`
these fields are supplied from `select fields from t1`.

  2nd We are using --complete-insert when we detect that this table is using
invisible columns.
2017-12-15 02:41:52 +05:30
Sachin Setiya
c90db2c8be BuildBot bug fix for invisible columns 2017-12-15 02:41:52 +05:30
Sergei Golubchik
022b163ac8 Add tests for system and completely invisible columns
debug only
2017-12-15 02:41:52 +05:30
Sachin Setiya
84726906c9 MDEV-10177 Invisible Columns and Invisible Index
Feature Definition:-

This feature adds invisible column functionality to server.
There is 4 level of "invisibility":

1. Not invisible (NOT_INVISIBLE) — Normal columns created by the user

2. A little bit invisible (USER_DEFINED_INVISIBLE) — columns that the
    user has marked invisible. They aren't shown in SELECT * and they
    don't require values in INSERT table VALUE (...). Otherwise
    they behave as normal columns.

3. More invisible (SYSTEM_INVISIBLE) — Can be queried explicitly,
    otherwise invisible from everything. Think ROWID sytem column.
    Because they're invisible from ALTER TABLE and from CREATE TABLE
    they cannot be created or dropped, they're created by the system.
    User cant not create a column name which is same as of
    SYSTEM_INVISIBLE.

4. Very invisible (COMPLETELY_INVISIBLE) — as above, but cannot be
    queried either. They can only show up in EXPLAIN EXTENDED (might
    be possible for a very invisible indexed virtual column) but
    otherwise they don't exist for the user.If user creates a columns
    which has same name as of COMPLETELY_INVISIBLE then
    COMPLETELY_INVISIBLE column is renamed again. So it is completely
    invisible from user.

Invisible Index(HA_INVISIBLE_KEY):-
   Creation of invisible columns require a new type of index which
   will be only visible to system. User cant see/alter/create/delete
   this index. If user creates a index which is same name as of
   invisible index then it will be renamed.

Syntax Details:-

  Only USER_DEFINED_INVISIBLE column can be created by user. This
  can be created by adding INVISIBLE suffix after column definition.

  Create table t1( a int invisible, b int);

Rules:-
  There are some rules/restrictions related to use of invisible columns
  1. All the columns in table cant be invisible.
     Create table t1(a int invisible); \\error
     Create table t1(a int invisible, b int invisble); \\error
  2. If you want invisible column to be NOT NULL then you have to supply
     Default value for the column.
     Create table t1(a int, b int not null); \\error
  3. If you create a view/create table with select * then this wont copy
     invisible fields. So newly created view/table wont have any invisible
     columns.
     Create table t2 as select * from t1;//t2 wont have t1 invisible column
     Create view v1 as select * from t1;//v1 wont have t1 invisible column
  4. Invisibility wont be forwarded to next table in any case of create
     table/view as select */(a,b,c) from table.
     Create table t2 as select a,b,c from t1; // t2 will have t1 invisible
                           // column(b), but this wont be invisible in t2
     Create view v1 as select a,b,c from t1; // v1 will have t1 invisible
                           // column(b), but this wont be invisible in v1

Implementation Details:-
  Parsing:- INVISIBLE_SYM is added into vcol_attribute(so its like unique
      suffix), It is also added into keyword_sp_not_data_type so that table
      can have column with name invisible.
  Implementation detail is given by each modified function/created function.
   (Some function are left as they were self explanatory)
   (m= Modified, n= Newly Created)

  mysql_prepare_create_table(m):- Extra checks for invisible columns are
  added. Also some DEBUG_EXECUTE_IF are also added for test cases.

  mysql_prepare_alter_table(m):- Now this will drop all the
  COMPLETELY_INVISIBLE column and HA_INVISIBLE_KEY index. Further
  Modifications are made to stop drop/change/delete of SYSTEM_INVISIBLE
  column.

  build_frm_image(m):- Now this allows incorporating field_visibility
  status into frm image. To remain compatible with old frms
  field_visibility info will be only written when any of the field is
  not NOT_INVISIBLE.

  extra2_write_additional_field_properties(n):- This will write field
  visibility info into buffer. We first write EXTRA2_FIELD_FLAGS into
  buffer/frm , then each next char will have field_visibility for each
  field.

  init_from_binary_frm_image(m):- Now if we get EXTRA2_FIELD_FLAGS,
  then we will read the next n(n= number of fields) chars and set the
  field_visibility. We also increment
  thd->status_var.feature_invisible_columns. One important thing to
  note if we find out that key contains a field whose visibility is
  > USER_DEFINED_INVISIBLE then , we declare this key as invisible
  key.

  sql_show.cc is changed accordingly to make show table, show keys
  correct.

  mysql_insert(m):- If we get to know that we are doing insert in
  this way insert into t1 values(1,1); without explicitly specifying
  columns, then we check for if we have invisible fields if yes then
  we reset the whole record, Why ? Because first we want hidden columns
  to get default/null value. Second thing auto_increment has property
  no default and no null which voilates invisible key rule 2, And
  because of this it was giving error. Reseting table->record[0]
  eliminates this issue. More info put breakpoint on handler::write_row
  and see auto_increment value.

  fill_record(m):- we continue loop if we find invisible column because
  this is already reseted/will get its value if it is default.

Test cases:- Since we can not directly add > USER_DEFINED_INVISIBLE
  column then I have debug_dbug to create it in mysql_prepare_create_table.

  Patch Credit:- Serg Golubchik
2017-12-15 02:41:52 +05:30
Sergei Golubchik
84e14bff4a privilege: s/delete versioning rows/delete history/ 2017-12-14 20:19:20 +01:00
Sergei Golubchik
18405e5fd9 Partitioning syntax for versioning
partition by system_time (
    partition p0 history,
    partition pn current
 )
2017-12-14 20:19:14 +01:00
Aleksey Midenkov
2ae2876a6c MDEV-14652 NATURAL JOIN crash in mark_common_columns() [fixes #405]
SQL: reverted NATURAL JOIN fix #161 (deprecated by #383)
2017-12-14 21:31:38 +03:00
Eugene Kosov
4be2173e0f SQL: uninitialized read [#387]
versioning.truncate is affected in embedded mode
2017-12-14 21:27:20 +03:00
Aleksey Midenkov
27187443ef MDEV-14650 Assertion 0 failed in TABLE::vers_update_fields [fixes #402]
SQL: fixed selecion of handlerton by respecting partitioning
2017-12-14 19:45:11 +03:00
Aleksey Midenkov
ab5ec0f346 SQL: disable truncate history on partitioned [fixes #399] 2017-12-14 19:11:02 +03:00
Aleksey Midenkov
f96815fe97 SQL: unit resolution Item_field not yet accessible [fixes #398] 2017-12-14 18:42:53 +03:00
Aleksey Midenkov
1668efb722 MDEV-14645: AS OF TIMESTAMP is misused as TRX_ID [fixes #396] 2017-12-14 18:14:21 +03:00
Eugene Kosov
765569602d System Versioning 1.0 pre4
Merge branch '10.3' into trunk
2017-12-14 17:52:08 +03:00
Eugene Kosov
5d5ae2f4fe Tests: fix encryption.debug_key_management [#387] 2017-12-14 15:50:02 +03:00
Eugene Kosov
f14f04838b Tests: fix encryption.encrypt_and_grep [#387] 2017-12-14 15:38:52 +03:00
Aleksey Midenkov
2e3b580ba4 SQL: inner/outer system_time consistency [fixes #384] 2017-12-14 13:43:37 +03:00
Sergei Golubchik
f149013393 rename versioning_* variables 2017-12-14 11:31:44 +01:00
Marko Mäkelä
866ccc8890 Merge bb-10.2-ext into 10.3 2017-12-14 11:34:30 +02:00
Marko Mäkelä
1b5f0cbd46 Merge 10.2 into bb-10.2-ext 2017-12-14 09:53:19 +02:00
Marko Mäkelä
8063804943 Re-remove the file kill_and_restart_mysqld.inc 2017-12-14 08:40:09 +02:00
Marko Mäkelä
ece9c54e10 Merge 10.1 into 10.2 2017-12-14 08:40:01 +02:00
Marko Mäkelä
7be5b6f0e6 Merge 10.0 into 10.1 2017-12-13 23:04:30 +02:00
Marko Mäkelä
9d76b27498 Follow-up fix for MDEV-12352: Plug a memory leak
trx_rollback_active(): When aborting the rollback, free the query graph.
2017-12-13 23:02:37 +02:00
Aleksey Midenkov
eab471260b Paritioning: better error for disabled IB engine 2017-12-13 23:51:30 +03:00
Sergei Golubchik
ca6454bcfe for now, remove FOR SYSTEM_TIME at the end of the query
non-standard, redundant, potentially risky in the future,
hides bugs. See #383, #384, #385

Fixed a parser bug where
SELECT * FROM (t1 join t2) FOR SYSTEM_TIME ...
was not an error.
2017-12-13 21:51:20 +01:00
Sergei Golubchik
a1141e226d fix nullable autoinc test w/o versioning 2017-12-13 21:44:31 +01:00
Sergei Golubchik
e77080c7d5 if a table is partitioned by system_time, its partitions are not versioned
they store history and the history does not have history
2017-12-13 21:44:30 +01:00
Sergei Golubchik
21d0a9fe3b yet another error message fix 2017-12-13 21:32:52 +01:00
Marko Mäkelä
e9cc486c97 Fix a typo: schedule, scheduling 2017-12-13 20:43:09 +02:00
Marko Mäkelä
2fe990df9f Fix the grammar of an error message 2017-12-13 20:41:32 +02:00
Marko Mäkelä
46305b006b Merge 10.0 into 10.1 2017-12-13 19:12:16 +02:00
Marko Mäkelä
b1977a39de MDEV-12323 Rollback progress log messages during crash recovery are intermixed with unrelated log messages
trx_roll_must_shutdown(): During the rollback of recovered transactions,
report progress and check if the rollback should be interrupted because
of a pending shutdown.

trx_roll_max_undo_no, trx_roll_progress_printed_pct: Remove, along with
the messages that were interleaved with other messages.
2017-12-13 18:56:22 +02:00
Marko Mäkelä
08d0ea1fcf Follow-up to MDEV-11027: Use recv_sys_t::report() 2017-12-13 18:53:46 +02:00
Marko Mäkelä
b46fa627ca MDEV-12352 InnoDB shutdown should not be blocked by a large transaction rollback
row_undo_step(), trx_rollback_active(): Abort the rollback of a
recovered ordinary transaction if fast shutdown has been initiated.

trx_rollback_resurrected(): Convert an aborted-rollback transaction
into a fake XA PREPARE transaction, so that fast shutdown can proceed.
2017-12-13 18:02:09 +02:00
Aleksey Midenkov
8e8363bb75 SQL: VIEW system fields propagation removed [fixes #393] 2017-12-13 18:23:32 +03:00
Eugene Kosov
a83fcbaa3b
MDEV-14632 Assertion `!((new_col->prtype ^ col->prtype) & ~256U)' failed in row_log_table_apply_convert_mrec
SQL: add exclusive lock to ADD/DROP SYSTEM VERSIONING clauses

This is needed because Online DDL is not working yet for such queries.
2017-12-13 17:58:36 +03:00
Marko Mäkelä
6559ba71a5 MDEV-13797 InnoDB may hang if shutdown is initiated soon after startup while rolling back recovered incomplete transactions
trx_rollback_resurrected(): If shutdown was initiated, fake all
remaining active transactions to XA PREPARE state, so that shutdown
can proceed. Also, make the parameter "all" an output that will be
assigned to FALSE in this case.

trx_rollback_or_clean_recovered(): Remove the shutdown check
(it was moved to trx_rollback_resurrected()).

trx_undo_free_prepared(): Relax assertions.
2017-12-13 16:30:38 +02:00
Aleksey Midenkov
bc4a86699d SQL: recursive CTE inner derived vers_conditions [fix #385] 2017-12-13 15:31:46 +03:00
Marko Mäkelä
58eb4e5db9 MDEV-14422 Assertion failure in trx_purge_run() on shutdown
row_quiesce_table_start(), row_quiesce_table_complete():
Use the more appropriate predicate srv_undo_sources for skipping
purge control. (This change alone is insufficient; it is possible
that this predicate will change during the call to trx_purge_stop()
or trx_purge_run().)

trx_purge_stop(), trx_purge_run(): Tolerate PURGE_STATE_EXIT.
It is very well possible to initiate shutdown soon after the statement
FLUSH TABLES FOR EXPORT has been submitted to execution.

srv_purge_coordinator_thread(): Ensure that the wait for purge_sys->event
in trx_purge_stop() will terminate when the coordinator thread exits.
2017-12-13 14:17:26 +02:00
Alexander Barkov
701e22d5cd Removing a dead code in sql_load.cc
The loop in read_xml_field(), unlike the same loop in read_sep_field(),
cannot end with item<>NULL, as it does not have any "break" statements.
The entire block "if (item) {...}" was a dead code.
2017-12-13 15:08:16 +04:00