Commit graph

64968 commits

Author SHA1 Message Date
Sergei Golubchik
3aadba1557 compilation warning 2016-06-30 11:43:02 +02:00
Alexander Barkov
afbd28aeff Preparing the CAST(..AS [UN]SIGNED) related code to fix a number
of bugs easier (MDEV-8919, MDEV-10304, MDEV-10305, MDEV-10307)

- Adding Item::push_note_converted_to_negative_complement() and
  Item::push_note_converted_to_positive_complement()
- Adding virtual methods Item::val_int_signed_typecast() and
  Item::val_int_unsigned_typecast()
- Moving COLUMN_GET() related code from
  Item_func_signed::val_int() and Item_func_unsigned::val_int() to
  Item_dyncol_get::val_int_signed_typecast() and
  Item_dyncol_get::val_int_unsigned_typecast()
- Moving Item_func_signed::val_int_from_str() to Item::val_int_from_str()
  and changing it to get the value from "this" instead of args[0].

The patch does not change behaviour. It's only to simplify fixing of the
mentioned bugs. It will also simplify switching the CAST related code to
use the type handler infrastructure easier (soon).
2016-06-29 18:25:51 +04:00
Monty
4dc5075860 Fixed compiler warnings and test failures found by buildbot
Fixed ccfilter to detect errors where the column is included in the error message
2016-06-24 02:25:14 +03:00
Monty
ec38c7e60b MDEV-10219 rpl.rpl_parallel_temptable failed in buildbot: Assertion `!table || !table->in_use || table->in_use == _current_thd()' failed
Problem was that table->in_use was not properly set when dropping a temporary for the slave.
2016-06-22 22:04:55 +03:00
Monty
838205f0bb Fixed compiler warnings and test failures found by buildbot 2016-06-22 22:04:55 +03: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
Sergei Golubchik
9f9eb682d5 MDEV-10098 main.create_delayed fails with ps-protocol: assertion `global_status_var.global_memory_used >= 0' failed
Remove the assert. We cannot verify that
global_memory_used value is valid (>=0)
because some of updates are cached in individual THD's
(e.g. THD1 can have +300 cached, while the other THD2
can have -300 cached. If the second THD exists before
the first one, global_memory_used will be -300
temporarily).

Instead add the assert just before the exit, when all
THDs been already destroyed.
2016-06-13 19:51:20 +02:00
Sergei Golubchik
e65703c6bd cleanup
always update global_status_var.global_memory_used
through update_global_memory_status()
2016-06-13 19:51:20 +02:00
Nirbhay Choubey
b2ae32aafd MDEV-5535: Cannot reopen temporary table
Since a query can now refer to the same temporary table
multiple times, find_dup_table()/find_table_in_list()
have been updated to also consider this new possibility.
2016-06-10 18:39:44 -04:00
Nirbhay Choubey
e2087c6e8d MDEV-5535: Cannot reopen temporary table
Temporary table being created by outer statement
should not be visible to inner statement. And if
inner statement creates a table with same name.
The whole statement should fail with
ER_TABLE_EXISTS_ERROR.

Implemented by temporarily de-linking the TABLE_SHARE
being created by outer statement so that it remains
hidden to the inner statement.
2016-06-10 18:39:43 -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
Nirbhay Choubey
78d4276788 Some trivial changes. 2016-06-10 18:00:23 -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
Sergei Golubchik
2dee76f435 MDEV-9518 Increase the range for INFORMATION_SCHEMA.MEMORY_USED column
make INFORMATION_SCHEMA.PROCESSLIST.MEMORY_USED bigint
2016-06-09 00:00:44 +02:00
Sergei Golubchik
dc08c3b15a MDEV-10180 main.events_restart fails on valgrind builder: void THD::inc_thread_count(): Assertion `!abort_loop' failed.
remove an overly strong assert
2016-06-08 17:36:16 +02:00
Otto Kekäläinen
effbe7dd7b General spell fixing in comments and strings 2016-06-08 14:17:23 +03:00
Sergei Golubchik
935033aea7 fix wsrep test crashes on startup 2016-06-05 11:24:10 +02:00
Sergei Golubchik
4a0612ed2a stop binlog background thread together with others
that fixes many rpl tests failures
2016-06-04 09:06:00 +02:00
Sergei Golubchik
562c1df7d9 cleanup: thread_count
move thread_count handling into THD:
* increment thread_count in THD constructor
* decrement thread_count in THD destructor
* never modify thread_count directly!
2016-06-04 09:06:00 +02:00
Sergei Golubchik
7425610c81 decrement thead_count *after* THD is destroyed
because thread_count means just that: number of THDs
and shutdown code looks at it to know when to free
shared data structures that THD uses.

This fixes random crashes in ~THD on shutdown
2016-06-04 09:06:00 +02:00
Sergei Golubchik
74aef87c5e fix the method name
it's always assert_<statement>,
not <do something>_if_<condition>
2016-06-04 09:06:00 +02:00
Sergei Golubchik
725ce0fe84 THD:: cleanup() must be where it used to
between net_end() and ha_close_connection()

this fixes lockups in main.locked_temporary-5955 and some
other innodb tests.
2016-06-04 09:06:00 +02:00
Sergei Golubchik
69da361ccd reset @@TIMESTAMP for COM_CHANGE_USER
this also fixes tokudb.type_year failure
(in ./mtr tokudb.type_timestamp tokudb.type_year)
2016-06-04 09:06:00 +02:00
Sergei Golubchik
4aacb20dce fix XID comparison
according to the standard, the gtrid/bqual pair must be
"globally unique", so XIDs are equal if their gtrids and
bquals are identical, formatID simply tells how
gtrid/bqual were generated. But if formatID == -1
(it means "null") gtrid/bqual don't have any value at all.

This fixes main.xa_sync failure in
./mtr main.quary_cache_debug main.xa_sync
2016-06-04 09:06:00 +02: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
Vladislav Vaintroub
3a7bc23a16 MDEV-9154 : Remove workarounds (mainly dynamic function loading)
for running obsolete versions of Windows
2016-06-01 20:29:10 +02:00
Vladislav Vaintroub
22ede741f0 fix compile error - inconsistent use of 'struct' and 'class' for TDC_element 2016-06-01 20:21:36 +02:00
Nirbhay Choubey
23fed78404 MDEV-6368: assertion xid_seqno > trx_sys_cur_xid_seqno (postfix)
- Fix build failure when built without wsrep (Win)
- Update the expected warning in sys_vars.wsrep_start_position
2016-06-01 13:15:38 -04:00
Sergey Vojtovich
d6d4011211 Move wait_for_mdl_deadlock_detector() call to tc_remove_table()
As a side effect tc_remove_all_unused_tables() has to call
tc_wait_for_mdl_deadlock_detector() once per TABLE object now, while it called
it only once before. This should be acceptable since actual wait will still be
performed only once. It only adds redundant checks for all_tables_refs.
2016-06-01 17:54:23 +04:00
Sergey Vojtovich
41dc2fc129 Move table cache private functions out of header
This is mostly needed to hide all references to free_tables, so that further
implementation of multi-instance list can be done completely inside
table_cache.cc
2016-06-01 17:14:43 +04:00
Sergey Vojtovich
f7048e9a92 Move common code to a separate function 2016-06-01 16:43:22 +04:00
Alexander Barkov
286416404a MDEV-10101 Wrong error message of SELECT 1 UNION (SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP) 2016-06-01 15:31:26 +04:00
Alexander Barkov
caee832df1 MDEV-10124 Incorrect usage of CUBE/ROLLUP and ORDER BY with GROUP_CONCAT(a ORDER BY a)
Allowing GROUP_CONCAT(... ORDER BY ..) in queries with ROLLUP.

The story of the related code:

1. The original patch from Wax
commit: 0b505fb437
date: Tue Mar 18 03:07:40 2003

opt_gorder_clause reused the regular order_clause,
which already had some protection against ROLLUP queries:

order_clause:
        ORDER_SYM BY
        {
          LEX *lex=Lex;
          if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
              lex->current_select->select_lex()->olap !=
              UNSPECIFIED_OLAP_TYPE)
          {
            net_printf(lex->thd, ER_WRONG_USAGE,
                       "CUBE/ROLLUP",
                       "ORDER BY");
            YYABORT;
          }
        } order_list;

The assumption that ORDER BY in group_concat() had to have
the same ROLLUP restriction (with order_clause) was wrong.

Moreover, GROUP_CONCAT() in select_item_list was not affected
by this restriction, because WITH ROLLUP goes after
select_item_list and therefore sel->olap is always equal
to UNSPECIFIED_OLAP_TYPE during select_item_list.

GROUP BY was not affected for two reasons:
- it goes before WITH ROLLUP and sel->olap is still
  UNSPECIFIED_OLAP_TYPE
- Aggregate functions like AVG(), GROUP_CONCAT() in GROUP BY
  are not allowed

So only GROUP_CONCAT() in HAVING and ORDER BY clauses
were erroneously affected by this restriction.

2. Bug#27848 rollup in union part causes error with order of union
commit: 3f6073ae63
Author: unknown <igor@olga.mysql.com>  2007-12-15 01:42:46

The condition in the ROLLUP protection code became more complex.
Note, opt_gconcat_order still reused the regular order_clause.

3. Bug#16347426 ASSERTION FAILED: (SELECT_INSERT &&
                 !TABLES->NEXT_NAME_RESOLUTION_TABLE) || !TAB
commit: 2d83663380
author: Chaithra Gopalareddy <chaithra.gopalareddy@oracle.com>
date: 2013-04-14 06:00:49

opt_gorder_clause was refactored not to use order_clause and
to collect information directly to select->gorder_list.
The ROLLUP protection code was duplicated from order_clause
to the new version of opt_gorder_clause.
2016-06-01 14:29:20 +04:00
Nirbhay Choubey
de7eafc7ce MDEV-6368: assertion xid_seqno > trx_sys_cur_xid_seqno
- Validate the specified wsrep_start_position value by also
checking the return status of wsrep->sst_received. This also
ensures that changes in wsrep_start_position is not allowed
when the node is not in JOINING state.
- Do not allow decrease in seqno within same UUID.
- The initial checkpoint in SEs should be [0...:-1].
2016-05-31 20:37:00 -04:00
Oleksandr Byelkin
7166069537 MDEV-3944: Allow derived tables in VIEWS 2016-05-28 14:44:21 +02:00
Alexander Barkov
1f89ea8ea0 sql_yacc.yy: Removing union_opt.
Using /*empty*/, union_list, union_order_or_limit instead.
This is to get rid of lex->current_select->braces easier
(separately in union_list and in union_order_or_limit)
2016-05-25 18:36:51 +04:00
Alexander Barkov
804b00e878 An sql_yacc.yy clean-up
- Moving opt_union_order_or_limit inside union_opt,
  as it's not used in other places any more.
- Changing union_opt to have no type.
  Earlier (before all MDEV-8909 dependency tasks) it had the <num> type,
  and it's return value was used to generate errors.
  Now union_opt does not need a return value because the grammar
  disallows ORDER and LIMIT clauses in wrong context.
2016-05-24 18:23:18 +04:00
Alexander Barkov
c80c3f6759 MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION .. 2016-05-24 18:05:38 +04:00
Alexander Barkov
ea9a393a86 MDEV-10103 Disallow syntactically UNION SELECT .. PROCEDURE ANALYSE() 2016-05-24 14:18:46 +04:00
Alexander Barkov
9a25c01f78 MDEV-10102 Disallow CREATE VIEW .. PROCEDURE ANALYSE() syntactically 2016-05-23 16:25:51 +04:00
Alexander Barkov
4c0e2960d4 MDEV-10051 Fix subselect to return a syntax error instead of "Incorrect usage of UNION and LIMIT" 2016-05-23 10:54:09 +04:00
Alexander Barkov
a999acf26e MDEV-10095 Fix derived tables to return a syntax error instead of "Illegal usage of UNION and LIMIT" 2016-05-21 16:52:12 +04:00
Alexander Barkov
349da1d643 sql_yacc.yy: Removing unnecessary init_nested_join() and end_nested_join()
from select_derived_init.
2016-05-21 00:27:57 +04:00
Alexander Barkov
c44b2e66a9 A derived_query_specification clean-up
(to simplify further MDEV-8909 changes)

1. Better semantic readability:
- Moving get_select_lex_derived inside select_derived_init
  and decomposing it into get_select_lex and
  $1->init_nested_join(lex->thd)
-  Moving DBUG_ASSERT($1 == Lex->current_select) inside
   select_derived_init

Now init_nested_join() and end_nested_join() reside inside
the same rule select_derived_init.
(It's very likely that they can be further removed,
 as there are no any joins in this rule).

3. Better grammar readability:
  Moving SELECT_SYM from select_derived_init to derived_query_specification.
  It's easier to read a rule when it starts from a terminal symbol.
2016-05-20 20:05:03 +04:00
Oleksandr Byelkin
485ece6da9 MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
Alexander Barkov
f6a7c1c75a MDEV-10080 Derived tables allow double LIMIT clause
1. Moving the "| get_select_lex_derived select_derived_init" part of
select_derived into a separate new rule derived_query_specification.
2. Using derived_query_specification directly in select_derived_union
rather than in select_derived.
3. Moving the sequence "opt_order_clause opt_limit_clause opt_select_lock_type"
from select_derived2 to select_derived_union,
after derived_query_specification.

Effectively, the parser now does not go through the sequence
"opt_order_clause opt_limit_clause ... opt_union_order_or_limit" any more.

This fixes the problem with double LIMIT clause and removes 2 shift/reduce
conflicts.
2016-05-20 09:21:07 +04:00
Alexander Barkov
c9629daa1e This patch is a cleanup simplifying upcoming
"MDEV-8909 union parser cleanup" changes.

When the server parses a query like
  SELECT * FROM (SELECT 1);
a sequence of calls
  st_select_lex::init_nested_join() ..
  st_select_lex::end_nested_join()
was performed two times (tested in gdb).
Both pairs of calls seem to be redundant for a query
like this, because there are actually no any joins here.

This patch moved "table_ref_select" inside "select_derived",
which revealed that one the pairs was definitely redundant:
After this transformation we got an init_nested_join()
immediately followed by end_nested_join() for the same st_select_lex,
which has no any sense. So this pair of calls was removed.
2016-05-19 18:57:23 +04:00
Oleksandr Byelkin
50a17de1ce MDEV-9947: COM_MULTI united response 2016-05-17 13:31:33 +02:00
Alexander Barkov
e7ff281d2e MDEV-6353 my_ismbchar() and my_mbcharlen() refactoring 2016-05-17 15:27:10 +04:00