Commit graph

3978 commits

Author SHA1 Message Date
Oleksandr Byelkin
0ee3e64c55 MDEV-8931: (server part of) session state tracking
Transaction tracker
2016-08-31 17:17:46 +02:00
Oleksandr Byelkin
e7608a78ef MDEV-8931: (server part of) session state tracking
initial commit to test
2016-08-31 17:17:46 +02:00
Sergei Golubchik
cd51c7fb60 move away from TIMESTAMP_DNUN_FIELD/TIMESTAMP_DN_FIELD code
use the new approach with Field->default_value expressions.
But keep the old TIMESTAMP_UN_FIELD for ON UPDATE NOW().
2016-08-27 16:59:13 +02:00
Sergei Golubchik
12d2c4fcd0 optimize constant default expressions
to be calculated at the CREATE TABLE time and stored in
the default row image.
2016-08-27 16:59:12 +02:00
Nirbhay Choubey
69052ed022 MDEV-10320: NO-OP ALTER TABLE on temporary tables getting
.. logged under row binlog format

In the early stages of ALTER TABLE execution, the implementation
checks whether its a NOOP (alter_info->flags == 0), and if so,
it returns after logging the command to binary log. The logging,
however, was done unconditionally.

Fixed by skipping the logging for temporary tables when under row
based replication.
2016-08-08 17:29:22 -04:00
Nirbhay Choubey
df9b4554b7 MDEV-10216: Assertion `strcmp(share->unique_file_name,filename) ||
.. share->last_version' failed in myisam/mi_open.c:67: test_if_reopen

During the RENAME operation since the renamed temporary table is also
opened and added to myisam_open_list/maria_open_list, resetting the
last_version at the end of operation (HA_EXTRA_PREPARE_FOR_RENAME)
will cause an assertion failure when a subsequent query tries to open
an additional temporary table instance and thus attempts to reuse it
from the open table list.

This commit fixes the issue by skipping flush/close operations executed
toward the end of ALTER for temporary tables. It also enables a shortcut
for simple ALTERs (like rename, disable/enable keys) on temporary
tables.

As safety checks, added some assertions at code points that should not
be hit for temporary tables.
2016-08-08 17:26:06 -04:00
Sergei Golubchik
b258f91103 fix ALTER TABLE .. DROP CONSTRAINT IF NOT EXISTS 2016-07-02 14:52:23 +02:00
Sergei Golubchik
5c764a0eb8 clarify ER_CANT_DROP_FIELD_OR_KEY
include the dropped object type
2016-07-02 14:52:20 +02:00
Sergei Golubchik
932646b1ff Merge branch '10.1' into 10.2 2016-06-30 16:38:05 +02:00
Sergei Golubchik
f93a2a3b3b various cleanups
* remove a confusing method name - Field::set_default_expression()
* remove handler::register_columns_for_write()
* rename stuff
* add asserts
* remove unlikely unlikely
* remove redundant if() conditions
* fix mark_unsupported_function() to report the most important violation
* don't scan vfield list for default values (vfields don't have defaults)
* move handling for DROP CONSTRAINT IF EXIST where it belongs
* don't protect engines from Alter_inplace_info::ALTER_ADD_CONSTRAINT
* comments
2016-06-30 11:43:02 +02:00
Michael Widenius
2fe8dd0f90 various cleanups 2016-06-30 11:43:02 +02:00
Michael Widenius
db7edfed17 MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
MDEV-10134 Add full support for DEFAULT

- Added support for using tables with MySQL 5.7 virtual fields,
  including MySQL 5.7 syntax
- Better error messages also for old cases
- CREATE ... SELECT now also updates timestamp columns
- Blob can now have default values
- Added new system variable "check_constraint_checks", to turn of
  CHECK constraint checking if needed.
- Removed some engine independent tests in suite vcol to only test myisam
- Moved some tests from 'include' to 't'. Should some day be done for all tests.
- FRM version increased to 11 if one uses virtual fields or constraints
- Changed to use a bitmap to check if a field has got a value, instead of
  setting HAS_EXPLICIT_VALUE bit in field flags
- Expressions can now be up to 65K in total
- Ensure we are not refering to uninitialized fields when handling virtual fields or defaults
- Changed check_vcol_func_processor() to return a bitmap of used types
- Had to change some functions that calculated cached value in fix_fields to do
  this in val() or getdate() instead.
- store_now_in_TIME() now takes a THD argument
- fill_record() now updates default values
- Add a lookahead for NOT NULL, to be able to handle DEFAULT 1+1 NOT NULL
- Automatically generate a name for constraints that doesn't have a name
- Added support for ALTER TABLE DROP CONSTRAINT
- Ensure that partition functions register virtual fields used. This fixes
  some bugs when using virtual fields in a partitioning function
2016-06-30 11:43:02 +02:00
Monty
34eb10e406 MDEV-10138 Support for decimals up to 38 digits
Decimals with float, double and decimal now works the following way:

- DECIMAL_NOT_SPECIFIED is used when declaring DECIMALS without a firm number
  of decimals.  It's only used in asserts and my_decimal_int_part.
- FLOATING_POINT_DECIMALS (31) is used to mark that a FLOAT or DOUBLE
  was defined without decimals. This is regarded as a floating point value.
- Max decimals allowed for FLOAT and DOUBLE is FLOATING_POINT_DECIMALS-1
- Clients assumes that float and double with decimals >= NOT_FIXED_DEC are
  floating point values (no decimals)
- In the .frm decimals=FLOATING_POINT_DECIMALS are used to define
  floating point for float and double (31, like before)

To ensure compatibility with old clients we do:

- When storing float and double, we change NOT_FIXED_DEC to
  FLOATING_POINT_DECIMALS.
- When creating fields from .frm we change for float and double
  FLOATING_POINT_DEC to NOT_FIXED_DEC
- When sending definition for a float/decimal field without decimals
  to the client as part of a result set we convert NOT_FIXED_DEC to
  FLOATING_POINT_DECIMALS.
- variance() and std() has changed to limit the decimals to
  FLOATING_POINT_DECIMALS -1 to not get the double converted floating point.
  (This was to preserve compatiblity)
- FLOAT and DOUBLE still have 30 as max number of decimals.

Bugs fixed:

variance() printed more decimals than we support for double values.

New behaviour:
- Strings now have 38 decimals instead of 30 when converted to decimal
- CREATE ... SELECT with a decimal with > 30 decimals will create a column
  with a smaller range than before as we are trying to preserve the number of
  decimals.


Other changes
- We are now using the obsolete bit FIELDFLAG_LEFT_FULLSCREEN to specify
  decimals > 31
- NOT_FIXED_DEC is now declared in one place
- For clients, NOT_FIXED_DEC is always 31 (to ensure compatibility).
  On the server NOT_FIXED_DEC is DECIMAL_NOT_SPECIFIED (39)
- AUTO_SEC_PART_DIGITS is taken from DECIMAL_NOT_SPECIFIED
- DOUBLE conversion functions are now using DECIMAL_NOT_SPECIFIED instead of
  NOT_FIXED_DEC
2016-06-22 22:04:55 +03:00
Sergey Vojtovich
5b008d4a27 Merge pull request #181 from ottok/ok-debpkg-10.2
General spell fixing in comments and strings
2016-06-14 16:43:08 +04:00
Nirbhay Choubey
7305be2f7e MDEV-5535: Cannot reopen temporary table
mysqld maintains a list of TABLE objects for all temporary
tables created within a session in THD. Here each table is
represented by a TABLE object.

A query referencing a particular temporary table for more
than once, however, failed with ER_CANT_REOPEN_TABLE error
because a TABLE_SHARE was allocate together with the TABLE,
so temporary tables always had only one TABLE per TABLE_SHARE.

This patch lift this restriction by separating TABLE and
TABLE_SHARE objects and storing TABLE_SHAREs for temporary
tables in a list in THD, and TABLEs in a list within their
respective TABLE_SHAREs.
2016-06-10 18:39:43 -04:00
Sergey Vojtovich
7ecb304996 Code cleanups
- unused TABLE_SHARE::deleting and TABLE_LIST::deleting flags were removed
- kill_delayed_threads_for_table() and intern_close_table() are now private
  methods of table cache
- removed free_share flag of closefrm(): it was never used for temporary
  tables and was rarely useful for regular tables
2016-06-10 17:37:12 +04:00
Otto Kekäläinen
effbe7dd7b General spell fixing in comments and strings 2016-06-08 14:17:23 +03:00
Monty
89685d55d7 Reuse THD for new user connections
- To ensure that mallocs are marked for the correct THD, even if it's
  allocated in another thread, I added the thread_id to the THD constructor
- Added st_my_thread_var to thr_lock_info_init() to avoid a call to my_thread_var
- Moved things from THD::THD() to THD::init()
- Moved some things to THD::cleanup()
- Added THD::free_connection() and THD::reset_for_reuse()
- Added THD to CONNECT::create_thd()
- Added THD::thread_dbug_id and st_my_thread_var->dbug_id. These are needed
  to ensure that we have a constant thread_id used for debugging with a THD,
  even if it changes thread_id (=connection_id)
- Set variables.pseudo_thread_id in constructor. Removed not needed sets.
2016-06-04 09:06:00 +02:00
Sergei Petrunia
99cd5a962c MDEV-8989: ORDER BY optimizer ignores equality propagation
Variant #4 of the fix.

Make ORDER BY optimization functions take into account multiple
equalities. This is done in several places:
- remove_const() checks whether we can sort the first table in the
  join, or we need to put rows into temp.table and then sort.
- test_if_order_by_key() checks whether there are indexes that
  can be used to produce the required ordering
- make_unireg_sortorder() constructs sort criteria for filesort.
2016-05-23 21:17:18 +03:00
Sergei Golubchik
87e3e67f43 Merge branch '10.0' into 10.1 2016-05-04 15:23:26 +02:00
Sergei Golubchik
4f1c81de28 after-merge: simplify, fix a bug
* simplify the code at default: label
* bugfix: flush the checksum for NULL fields
  (perfschema.checksum was failing)
* cleanup: put repeated code into a function
2016-04-29 18:41:00 +02:00
Daniel Black
84b0ac6721 Whitespace fix for mysql_checksum_table function 2016-04-29 18:41:00 +02:00
Daniel Black
1ba90cea25 MDEV-9758: correct checksum on non-continious blocks
Error noted by Sergey Vojtovich.
2016-04-29 18:41:00 +02:00
Daniel Black
51a66299f3 CHECKSUM TABLE to calculate in multiple column chunks
Checksum implementations contain optimizations for calculating
checksums of larger blocks of memory.

This optimization calls my_checksum on a larger block of memory
rather than calling on multiple adjacent memory as its going though
the table columns for each table row.
2016-04-29 18:41:00 +02:00
Sergei Golubchik
872649c7ba Merge branch '5.5' into 10.0 2016-04-26 23:05:26 +02:00
Jan Lindström
19e3597e0c MDEV-9142 :Adding Constraint with no database reference
results in ERROR 1046 (3D000) at line 13: No database selected.

Use database from create table to foreign key database if
nothing else is given.
2016-04-23 13:05:15 +03:00
Sergei Golubchik
9e826bfa36 trivial optimization
don't call write_bin_log() when binlog is known
to be disable
2016-04-20 15:28:44 +02:00
Sergei Golubchik
b069d19284 Merge branch 'mysql/5.5' into 5.5 2016-04-20 15:25:55 +02:00
Sergei Petrunia
2efabf81f1 MDEV-9847: Window functions: crash with big_tables=1
- Move filesort's sort_positions argument into class Filesort.
- Make window function code construct Filesort with sort_positions=true.
2016-04-06 20:34:23 +03:00
Sergei Petrunia
2bd4dc38e0 Merge branch '10.2' into bb-10.2-mdev9543 2016-03-28 22:18:38 +03:00
Monty
260dd476b0 Removed TABLE->sort to make it possible to have multiple active calls to
filesort and init_read_record() for the same table.
This will simplify code for WINDOW FUNCTIONS (MDEV-6115)

- Filesort_info renamed to SORT_INFO and moved to filesort.h
- filesort now returns SORT_INFO
- init_read_record() now takes a SORT_INFO parameter.
- unique declaration is moved to uniques.h
- subselect caching of buffers is now more explicit than before
- filesort_buffer is now reusable even if rec_length has changed.
- filsort_free_buffers() and free_io_cache() calls are removed
- Remove one malloc() when using get_addon_fields()

Other things:
- Added --debug-assert-on-not-freed-memory option to make it easier to
  debug some not-freed-memory issues.
2016-03-22 23:44:52 +02:00
Alexander Barkov
e09299511e MDEV-9665 Remove cs->cset->ismbchar()
Using a more powerfull cs->cset->charlen() instead.
2016-03-16 10:55:12 +04:00
Sergey Vojtovich
03839e78f2 Corrected format string for long long thread_id
This is expected to fix many test failures on 32bit builds where creation of
second temporary table was failing.
2016-02-27 13:27:42 +04:00
Venkatesh Duggirala
29cc2c2883 BUG#20574550 MAIN.MERGE TEST CASE FAILS IF BINLOG_FORMAT=ROW
The main.merge test case was failing when tested using row based
binlog format.

While analyzing the issue it was found the following issues:

a) The server is calling binlog related code even when a statement will
   not be binlogged;
b) The child table list was not present into table structure by the time
   to generate the create table statement;
c) The tables in the child table list will not be opened yet when
   generating table create info using row based replication;
d) CREATE TABLE LIKE TEMP_TABLE does not preserve original table storage
   engine when using row based replication;

This patch addressed all above issues.

@ sql/sql_class.h

Added a function to determine if the binary log is disabled to
  the current session. This is related with issue (a) above.

@ sql/sql_table.cc

Added code to skip binary logging related code if the statement
  will not be binlogged. This is related with issue (a) above.

Added code to add the children to the query list of the table that
  will have its CREATE TABLE generated. This is related with issue (b)
  above.

Added code to force the storage engine to be generated into the
  CREATE TABLE. This is related with issue (d) above.

@ storage/myisammrg/ha_myisammrg.cc

Added a test to skip a table getting info about a child table if the
  child table is not opened. This is related to issue (c) above.
2016-02-26 09:01:49 +05:30
Sergei Golubchik
00d1db7a38 Merge branch '10.1' into 10.2 2016-02-25 18:19:55 +01:00
Sergei Golubchik
a5679af1b1 Merge branch '10.0' into 10.1 2016-02-23 21:35:05 +01:00
Sergei Golubchik
271fed4106 Merge branch '5.5' into 10.0 2016-02-15 22:50:59 +01:00
Sergei Golubchik
3c6b771753 MDEV-9045 Inconsistent handling of "ALGORITHM=INPLACE" with PERSISTENT generated columns
Only set Alter_inplace_info::ALTER_COLUMN_VCOL flag if
a vcol might be affected by the ALTER TABLE statement
2016-02-15 13:02:21 +01:00
Sergei Golubchik
9b9522a8b5 MDEV-8133 ALTER TABLE can perform the operation but escape the binary log
fix a few cases where a successful ALTER was not binlogged:
* on errors after the completed ALTER, binlog it, then return an error
* don't let thd->killed abort open_table() after completed
  online ALTER.
2016-02-15 13:02:21 +01:00
Igor Babaev
2cfc450bf7 This is the consolidated patch for mdev-8646:
"Re-factor the code for post-join operations".

The patch mainly contains the code ported from mysql-5.6 and
created for two essential architectural changes:
1. WL#5558: Resolve ORDER BY execution method at the optimization stage
2. WL#6071: Inline tmp tables into the nested loops algorithm

The first task was implemented for mysql-5.6 by Ole John Aske.
It allows to make all decisions on ORDER BY operation at the optimization
stage.

The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB
nodes for post-join operations that require temporary tables. It allows
to execute these operations within the nested loops algorithm that used to
be used before this task only for join queries. Besides these task moves
all planning on the execution of these operations from the execution phase
to the optimization phase.

Some other re-factoring changes of mysql-5.6 were pulled in, mainly because
it was easier to pull them in than roll them back. In particular all
changes concerning Ref_ptr_array were incorporated.

The port required some changes in the MariaDB code that concerned the
functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey
Petrunia.
2016-02-09 12:35:59 -08:00
Sergei Golubchik
63d3ccdfee Bug#21205695 DROP TABLE MAY CAUSE SLAVES TO BREAK
Correct fix. Generate the query in the client charset,
not in the system one.
2016-02-09 11:28:13 +01:00
Sergei Golubchik
f3444df415 Merge branch 'mysql/5.5' into 5.5
reverted about half of commits as either not applicable or
outright wrong
2016-02-09 11:27:40 +01:00
Alexander Barkov
2ba7ed77aa Merge remote-tracking branch 'origin/10.1' into 10.2 2015-12-29 19:37:11 +04:00
Karthik Kamath
1ec594dd60 BUG#21902059: "CREATE TEMPORARY TABLE SELECT ..." AND BIT(1)
COLUMNS

ANALYSIS:
=========
A valgrind error is reported when CREATE TABLE .. SELECT
involving BIT columns triggers a column type redefinition.

In general the pack_flag is set for BIT columns in
'mysql_prepare_create_table()'. However, during the above
operation, redefined column types was handled after the
special handling for BIT columns and thus pack_flag ended
up not being set correctly triggering the valgrind error.

FIX:
====
The patch fixes this problem by setting pack_flag correctly
for BIT columns in the case of column type redefinition.
2015-12-29 15:58:44 +05:30
Sergei Golubchik
a2bcee626d Merge branch '10.0' into 10.1 2015-12-21 21:24:22 +01:00
Sergei Golubchik
865548fc8d MDEV-9088 Server crashes on shutdown after the second post of feedback report
On shutdown feedback was sending a short report without creating
a THD. At that point current_thd was pointing to the already
destroyed THD from the previous full report.

backport from 10.1:
  commit bfe703a
  Author: Sergei Golubchik <serg@mariadb.org>
  Date:   Tue Feb 3 18:19:56 2015 +0100

      don't let current_thd to point to a destroyed THD
2015-12-19 13:36:21 +01:00
Sergei Golubchik
1623995158 Merge branch '5.5' into 10.0 2015-12-13 00:10:40 +01:00
Jan Lindström
0df22a539e MDEV-7050: MySQL#74603 - Assertion `comma_length > 0' failed in mysql_prepare_create_table
Incorrect array lenght for comma buffer.
2015-12-07 09:34:41 +02:00
Vladislav Vaintroub
089a586b43 Windows : Fix crash with "uninitialized variable keyname used"
by C runtime debug check.
2015-12-02 18:33:54 +01:00
Venkatesh Duggirala
2735f0b920 Bug#21205695 DROP TABLE MAY CAUSE SLAVES TO BREAK
Problem:
    ========
    1) Drop table queries are re-generated by server
    before writing the events(queries) into binlog
    for various reasons. If table name/db name contains
    a non regular characters (like latin characters),
    the generated query is wrong. Hence it breaks the
    replication.
    2) In the edge case, when table name/db name contains
    64 characters, server is throwing an assert
    assert(M_TBLLEN < 128)
    3) In the edge case, when db name contains 64 latin
    characters, binlog content is interpreted badly
    which is leading replication failure.

    Analysis & Fix :
    ================
    1) Parser reads the table name from the query and converts
    it to standard charset(utf8) and stores it in table_name variable.
    When drop table query is regenerated with the same table_name
    variable, it should be converted back to the original charset
    from standard charset(utf8).

    2) Latin character takes two bytes for each character. Limit
    of the identifier is 64. SYSTEM_CHARSET_MBMAXLEN is set to '3'.
    So there is a possiblity that tablename/dbname contains 3 * 64.
    Hence assert is changed to
    (M_TBLLEN <= NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)

    3) db_len in the binlog event header is taking 1 byte.
       db_len is ranged from 0 to 192 bytes (3 * 64).
       While reading the db_len from the event, server
       is casting to uint instead of uchar which is leading
       to bad db_len. This problem is fixed by changing the
       cast type to uchar.
2015-12-01 15:38:11 +05:30