Commit graph

1755 commits

Author SHA1 Message Date
Oleksandr Byelkin
13ad179c96 MDEV-8756 MariaDB 10.0.21 crashes during PREPARE
Non-select-like queries has no correct JOIN structure connected to top-most SELECT_LEX (and should not).
2015-11-20 14:50:18 +01:00
Oleksandr Byelkin
7e4da9b370 DEV-8632 Segmentation fault on INSERT
View/derived fields should be taken into account when we build ref_pointer_array constructed.

DBUG_ASSERTs added to avoid memory overrun.
2015-11-09 16:08:06 +01:00
Sergei Golubchik
4d5772c578 MDEV-7810 Wrong result on execution of a query as a PS (both 1st and further executions)
Alternative fix that doesn't cause view.test crash in --ps:
Remember when Item_ref was fixed right in the constructor
and did not have a full Item_ref::fix_fields() call. Later
in PS/SP, after Item_ref::cleanup, we use this knowledge
to avoid doing full fix_fields() for items that were never
supposed to be fix_field'ed.

Simplify the test case.
2015-07-31 17:17:33 +02:00
Monty
67c56ab1e4 Simple cleanups
- Removing use of calls to current_thd
- More DBUG_PRINT
- Code style changes
- Made some local functions static
Ensure that calls to print_keyuse are locked with mutex to get all lines in same debug packet
2015-06-25 23:34:54 +03:00
Monty
2e941fe9fc Fixed crashing bug when using ONLY_FULL_GROUP_BY in a stored procedure/trigger that is repeatedly executed.
This is MDEV-7601, including it's sub tasks MDEV-7594, MDEV-7555, MDEV-7590, MDEV-7581, MDEV-7589

The problem was that select_lex->non_agg_fields was not properly reset for re-execution and this caused an overwrite of a random memory position.
The fix was move non_agg_fields from select_lext to JOIN, which is properly reset.
2015-06-25 23:18:48 +03:00
Sergei Golubchik
b96c196f1c Item_cache::safe_charset_converter() fixes
* take into account that example may be NULL
* use example->safe_charset_converter(), copy-paste from
  Item::safe_charset_converter() (example might have its own
  implementation)
* handle the case when the charset doesn't need conversion
  (and return this).
2015-06-11 16:48:10 +02:00
Alexander Barkov
a765cca69f MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT 2015-06-08 20:50:40 +04:00
Alexey Botchkov
b37b52a3a2 MDEV-4922 Stored Procedure - Geometry parameter not working.
Fhe GEOMETRY field should be handled just as the BLOB field. So that was fiexed in field_conv.
  One additional bug was found and fixed meanwhile - thet the geometry field subtypes
  should also be merged for UNION command.
2015-06-08 13:47:07 +05:00
Oleksandr Byelkin
5fd0088356 MDEV-8058: funcs_1.innodb_views and funcs_1.memory_views fail
The double call of ref used tables fixed.
2015-04-27 15:31:56 +02:00
Oleksandr Byelkin
20109712ae MDEV-6892: WHERE does not apply
Taking into account implicit dependence of constant view field from nullable table of left join added.

Fixed finding real table to check if it turned to NULL (materialized view & derived taken into account)

Removed incorrect uninitialization.
2015-04-23 15:56:10 +02:00
unknown
a4ff2afcb4 cleanup 2014-12-17 14:38:14 +01:00
unknown
ff5349bd6c MDEV-6985: MariaDB crashes on stored procedure call
Item_ident fixed to allow double cleanup().
2014-12-17 14:35:13 +01:00
Sergei Golubchik
1ddfce4840 mysql-5.5.40 2014-10-06 19:53:55 +02:00
Alexander Barkov
68354ef272 MDEV-6592 Assertion `ltime->day == 0' failed with TIMESTAMP, MAKETIME 2014-10-03 15:07:53 +04:00
Tor Didriksen
ab727cec04 Bug#18928848 II. MALLOC OF UNINITIALIZED MEMORY SIZE
Several string functions have optimizations for constant
sub-expressions which lead to setting max_length == 0.

For subqueries, where we need a temporary table to holde the result,
we need to ensure that we use a VARCHAR(0) column rather than a
CHAR(0) column when such expressions take part in grouping.
With CHAR(0) end_update() may write garbage into the next field.
2014-08-21 16:42:04 +02:00
Alexander Barkov
c57c5be12a MDEV-5745 analyze MySQL fix for bug#12368495 2014-07-28 12:47:14 +04:00
Tor Didriksen
dbed459a6f Bug#18935421 RPAD DIES WITH CERTAIN PADSTR INTPUTS....
For rpad() and lpad(): verify that the padding string is well-formed.
2014-07-07 12:05:30 +02:00
Alexander Barkov
284479c085 Merge 5.3->5.5 2014-06-04 21:53:15 +04:00
Alexander Barkov
661daf16f1 MDEV-4858 Wrong results for a huge unsigned value inserted into a TIME column
MDEV-6099 Bad results for DATE_ADD(.., INTERVAL 2000000000000000000.0 SECOND)
MDEV-6097 Inconsistent results for CAST(int,decimal,double AS DATETIME)
MDEV-6100 No warning on CAST(9000000 AS TIME)
2014-06-04 20:32:57 +04:00
unknown
3f80740aa8 merge 5.5->5.3 2014-05-07 09:28:12 +03:00
unknown
285160dee2 MDEV-5981: name resolution issues with views and multi-update in ps-protocol
It is triple bug with one test suite:
1. Incorrect outer table detection
2. Incorrect leaf table processing for multi-update (should be full like for usual updates and inserts)
3. ON condition fix_fields() fould be called for all tables of the query.
2014-05-01 17:19:17 +03:00
Sergei Golubchik
5d0c01608c 5.2 merge 2014-03-16 21:03:01 +01:00
Sergei Golubchik
e772cbd7b7 5.1 merge 2014-03-16 13:59:44 +01:00
Sergei Golubchik
d7304375e5 mysql-5.1.73 merge 2014-03-15 18:24:15 +01:00
unknown
5c8ed7dd54 MDEV-5446: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' fails on EXPLAIN EXTENDED with VALUES function
field_index should be set correctly for null field created by Item_insert_value::fix_fields().
2014-03-14 11:38:17 +02:00
Michael Widenius
b17a053cc9 MDEV-6129: Server crashes during UNION with ORDER BY field IS NULL
Fixed crashing bug for union queries where there was no real tables.


mysql-test/r/group_by.result:
  Added test case
mysql-test/t/group_by.test:
  Added test case
sql/db.opt:
  Removed genrated file
sql/item.cc:
  Handled case when table_list->pos_in_tables is not set. Can only happens when there is no real tables in query
2014-04-24 18:20:57 +03:00
Sergei Golubchik
5d8c15228e 5.3-merge 2014-03-16 19:21:37 +01:00
Sergei Golubchik
913beda8c8 5.2 merge 2014-02-13 10:15:03 +01:00
Sergei Golubchik
fb27ce22f7 5.3 merge 2014-02-14 14:09:29 +01:00
Sergei Golubchik
48445f3556 5.1 merge 2014-02-13 08:25:33 +01:00
Sergei Golubchik
52f038c5c3 MDEV-5655 Server crashes on NAME_CONST containing AND/OR expressions
fix the NAME_CONST check to only allow literals, negated literals, and literals with
the explicit collation.
2014-02-12 21:17:28 +01:00
Michael Widenius
1bdf2151da Fixed MDEV-5617: mysqld crashes when running a query with ONLY_FULL_GROUP_BY
Problem was that we used cache_table in some cases where it was not initialized

mysql-test/r/func_group.result:
  Added test case
mysql-test/t/func_group.test:
  Added test case
sql/item.cc:
  Don't use cached_table if not set
sql/item_sum.cc:
  Don't use cached_table
2014-02-11 16:58:49 +02:00
Michael Widenius
d15b3386db Fix for MDEV-5531: double call procedure in one session - hard shutdown the server
Main fix was to not cache derivied tables as they may be temporary tables that are deleted before the next query.
This was a bit tricky as Item_field::fix_fields depended on cached_tables to be set to resolve some columns.



mysql-test/r/sp-bugs.result:
  Added test case
mysql-test/t/sp-bugs.test:
  Added test case
sql/item.cc:
  Fixed fix_outer_field to handle case where found field did not have in cached_table
  Idea is that if cached_table is not avaliable, use from_field->table->pos_in_table_list instead
sql/records.cc:
  Also accept INTERNAL_TMP_TABLE for memmap
sql/sql_base.cc:
  More DBUG_PRINT
  Fixed that setup_natural_join_row_types() is not run twice.
  Original code modified context->first_name_resolution_table also for second executions.
  This was wrong as this could give wrong results if some joins had been optimized away between calls.
sql/sql_derived.cc:
  Mark derived tables as internal temporary tables (INTERNAL_TMP_TABLE), not as NON_TRANSACTIONAL_TMP_TABLE.
  This is more correct as the tables are not visible by the end user.
sql/sql_insert.cc:
  Reset pos_in_table_list before calling fix_fields.
  One of the consequences of the change of not caching all generated tables in Item_ident is that
  pos_in_table_list needs to be correct in calls to fix_fields.
sql/sql_lex.cc:
  More DBUG_PRINT
sql/sql_parse.cc:
  Don't cache derivied tables as they may be temporary tables that are deleted before the next query
sql/sql_select.cc:
  Reset table_vector. This was required as some code checked the vector to see if temporary tables had already been created.
sql/table.cc:
  Mark tables with field translations as cacheable (as these will not disapper between stmt executions.
2014-01-24 14:50:18 +02:00
Alexander Barkov
2394fa67d4 MDEV-4859 Wrong value and data type of "SELECT MAX(time_column) + 1 FROM t1"
Fixed.
2013-11-21 11:46:36 +04:00
Alexander Barkov
c7355b1982 Merge 5.3->5.5 2013-11-21 13:09:08 +04:00
Alexander Barkov
a33bb00144 MDEV-4842 STR_TO_DATE does not work with UCS2/UTF16/UTF32 2013-11-08 14:18:16 +04:00
Alexander Barkov
d79d0c4045 merge 5.3 -> 5.5 2013-11-08 14:30:35 +04:00
Igor Babaev
ec226e553a Fixed bug mdev-5078.
For aggregated fields from views/derived tables the possible adjustment
of thd->lex->in_sum_func->max_arg_level in the function Item_field::fix_fields
must be done before we leave the function.
2013-10-04 09:51:07 -07:00
Igor Babaev
c7db46a242 Merge 5.3-5.5 2013-10-13 13:43:29 -07:00
unknown
64d6d8334f merge 5.3 -> 5.5 2013-09-25 17:16:13 +03:00
unknown
ec7da1561e MDEV-5039: incorrect Item_func_regex::update_used_tables()
Other fix of maybe_null problem and revert of revno: 3608 "MDEV-3873 & MDEV-3876 & MDEV-3912 : Wrong result (extra rows) with ALL subquery from a MERGE view."
2013-09-25 15:30:13 +03:00
Alexander Barkov
cf9cc19e91 MDEV-4724 Some temporal functions do not preserve microseconds 2013-09-13 14:43:10 +04:00
Alexander Barkov
51dcf4dcff Merge from 5.3.
pending merges:
  Alexander Barkov 2013-09-12 MDEV-4724 Some temporal functions do not pre...
2013-09-13 12:06:17 +04:00
Alexander Barkov
499ddea576 MDEV-4724 Some temporal functions do not preserve microseconds 2013-09-12 21:31:14 +04:00
Alexander Barkov
b59738a598 Merge from 5.3
modified:
  mysql-test/r/dyncol.result
  mysql-test/r/type_time.result
  mysql-test/t/dyncol.test
  mysql-test/t/type_time.test
  mysys/ma_dyncol.c
  sql/item.cc
  sql/item_func.cc
pending merges:
  Alexander Barkov 2013-08-12 MDEV-4652 Wrong result for CONCAT(GREATEST(T...
    sanja@montyprogr... 2013-08-01 MDEV-4811 Assertion `offset < 0x1f' f...
2013-08-12 17:33:08 +04:00
Alexander Barkov
f1b4718ec8 MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')) 2013-08-12 16:47:59 +04:00
Sergei Golubchik
005c7e5421 mysql-5.5.32 merge 2013-07-16 19:09:54 +02:00
Alexander Barkov
1f3ec9800c Merging from 5.3
modified:
  include/my_time.h
  libmysql/libmysql.c
  mysql-test/r/adddate_454.result
  mysql-test/r/cast.result
  mysql-test/r/date_formats.result
  mysql-test/r/func_sapdb.result
  mysql-test/r/func_time.result
  mysql-test/r/mdev316.result
  mysql-test/r/parser.result
  mysql-test/r/partition_datatype.result
  mysql-test/r/partition_pruning.result
  mysql-test/r/type_date.result
  mysql-test/r/type_datetime.result
  mysql-test/suite/vcol/r/vcol_misc.result
  mysql-test/t/cast.test
  sql-common/my_time.c
  sql/field.cc
  sql/field_conv.cc
  sql/filesort.cc
  sql/item.cc
  sql/item.h
  sql/item_cmpfunc.cc
  sql/item_func.cc
  sql/item_strfunc.cc
  sql/item_timefunc.cc
  sql/sql_time.cc
pending merges:
  Sergei Golubchik 2013-07-03 MDEV-4667 DATE('string') incompability betwe...
2013-07-08 16:49:42 +04:00
Sergei Golubchik
78cc6db44a MDEV-4667 DATE('string') incompability between mysql and mariadb
Cleanup: remove TIME_FUZZY_DATE.

Introduce TIME_FUZZY_DATES which means "very fuzzy, the resulting
value is only used for comparison. It can be invalid date, fine, as long as it can be
compared".

Updated many tests results (they're better now).
2013-07-03 09:46:20 +02:00
Alexander Barkov
e013bf9f0e The bug
MDEV-4489 "Replication of big5, cp932, gbk, sjis strings makes wrong values on slave"
has been fixed.

Problem:
String constants of some Asian charsets (big5,cp932,gbk,sjis)
can have backslash '\' (0x5C) in the second byte of multi-byte characters.
Replicating of such constants using the standard '\'-escaping is dangerous.
Therefore, constants of these charsets are replicated using hex notation:
INSERT INTO t1 (a) VALUES (0x815C);

However, 0xHHHH constants do not work well in some cases,
because they can behave as strings and as numbers, depending on context
(for example, depending on the data type of the column in an INSERT statement).

This SQL script was not replicated correctly with statement-based replication:

SET NAMES gbk;
PREPARE STMT FROM 'INSERT INTO t1 (a) VALUES (?)';
SET @a = '1';
EXECUTE STMT USING @a;

The INSERT statement was replicated as:
INSERT INTO t1 (a) VALUES (0x31);

'1' was correctly converted to the number 1 on master.
But the 0x31 constant was treated as number 49 on slave.

Fix:

1. Binary log now uses X'HHHH' instead of 0xHHHH constants.
2. The X'HHHH' constants now work always as strings, in all contexts.
This is the SQL standard compliant behaviour.

After the fix, the above statement is replicated as:
INSERT INTO t1 (a) VALUES (X'31');
X'31' is treated as string '1' on slave, and is correctly converted to 1.


modified:
  @ mysql-test/r/ctype_cp932_binlog_stm.result
  @ mysql-test/r/select.result
  @ mysql-test/r/select_jcl6.result
  @ mysql-test/r/select_pkeycache.result
  @ mysql-test/r/user_var-binlog.result
  @ mysql-test/r/varbinary.result
  @ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
  @ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
  @ mysql-test/suite/rpl/r/rpl_charset_sjis.result
  @ mysql-test/suite/rpl/r/rpl_mdev382.result
  @ mysql-test/suite/rpl/t/rpl_charset_sjis.test
  @ mysql-test/t/ctype_cp932_binlog_stm.test
  @ mysql-test/t/select.test
  @ mysql-test/t/varbinary.test
    Adding and updating tests

  @ sql/item.cc
  @ sql/item.h
  @ sql/sql_yacc.yy
  @ sql/sql_lex.cc
    Splitting the implementations of X'HH' and 0xHH constants into two
    separate classes. Fixing the parser to distinguish the two syntaxes.

  @ sql/log_event.cc
    Using X'HH' instead of 0xHH for binary logging for string constants
    of the "dangerous" charsets.

  @ sql/sql_string.h
    Adding a helped method String::append_hex().
2013-05-08 13:36:17 +04:00