Commit graph

1733 commits

Author SHA1 Message Date
Alexander Barkov
003cb2f424 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-10-30 16:42:46 +04:00
Sergei Golubchik
e0a1c745ec Merge branch '10.1' into 10.2 2017-10-24 14:53:18 +02:00
Sergei Golubchik
9d2e2d7533 Merge branch '10.0' into 10.1 2017-10-22 13:03:41 +02:00
Sergei Golubchik
da4503e956 Merge branch '5.5' into 10.0 2017-10-18 15:14:39 +02:00
Sergei Golubchik
d76f5774fe MDEV-13459 Warnings, when compiling with gcc-7.x
mostly caused by -Wimplicit-fallthrough
2017-10-17 07:37:39 +02:00
halfspawn
75aabd03d5 MDEV-14013 : sql_mode=EMPTY_STRING_IS_NULL 2017-10-14 17:28:54 +04:00
Oleksandr Byelkin
235b68299b MDEV-9619: Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS
Refer left expression indirectly in case it changes from execution to execution.
2017-10-13 19:32:38 +02:00
Sergei Golubchik
ac2db256d9 MDEV-12874 UPDATE statements with the same source and target
fix --ps-protocol
2017-10-03 21:07:27 +02:00
Alexander Barkov
8ae8cd6348 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-10-02 22:35:13 +04:00
Vladislav Vaintroub
eba44874ca MDEV-13844 : Fix Windows warnings. Fix DBUG_PRINT.
- Fix win64 pointer truncation warnings
(usually coming from misusing 0x%lx and long cast in DBUG)

- Also fix printf-format warnings

Make the above mentioned warnings fatal.

- fix pthread_join on Windows to set return value.
2017-09-28 17:20:46 +00:00
Alexander Barkov
178540b904 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-09-13 12:12:05 +04:00
Oleksandr Byelkin
6b5c0effe4 MDEV-13436 PREPARE doesn't work as expected & throws errors but MySQL is working fine
Now we allow derived in the from clause of subqueries so set
flag which prevent optimisation of subqueries during view
creation before derived processing so subquery will be
correctly printed in the view .frm.
2017-09-11 09:51:51 +02:00
Alexander Barkov
c9218ff439 MDEV-13415 Wrap the code in sp.cc into a class Sp_handler 2017-07-31 23:00:02 +04:00
Sergei Golubchik
c65cce3698 MDEV-12137 DELETE statement with the same source and target
* various cleanups (mostly cosmetic)
* remove useless tests (that were tesing the error condition)
* optimize delete_use_source test (from 6 mins to 50 seconds,
  mainly by removing two huge rollbacks at the end).
2017-07-07 22:38:15 +02:00
halfspawn
abf95afa2a MDEV-12137 DELETE statement with the same source and target
single-table deletes only
2017-07-07 22:38:15 +02:00
Alexander Barkov
5c0df0e4a8 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-07-04 15:31:25 +04:00
Alexander Barkov
96d1cdecbe MDEV-13197 Parser refactoring for CREATE VIEW,TRIGGER,SP,UDF,EVENT 2017-07-01 14:37:12 +04:00
Igor Babaev
13221b1eb2 Fixed a failure of the test case for the bug mdev-13107 in --ps-protocol.
The fix was in the call the open_normal_and_derived_tables() from
the function mysql_test_select() and it was similar to those from
the patch for mdev-13107.

Added explicit PREPARE statements that failed in --ps-protocol.
2017-06-28 22:40:27 -07:00
Oleksandr Byelkin
064d1a480c MDEV-12579: Incorrect arguments to mysqld_stmt_execute when using LOBs
Parameters can be MYSQL_TYPE_VARCHAR for long data load.
2017-06-22 15:28:57 +02:00
Marko Mäkelä
43eec57fab Merge 10.2 into bb-10.2-ext; also, fix MDEV-13015 After restart, InnoDB wrongly thinks that a SEQUENCE is a TABLE
sql_sequence.read_only: Show that the sequence can be read in
both read-only and read-write mode, and that the sequence remains
accessible after a server restart.
2017-06-15 18:06:55 +03:00
Alexander Barkov
765347384a Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-06-15 15:27:11 +04:00
Oleksandr Byelkin
91ae1258ee MDEV-12471: BULK Command
BULK execution moved to a new command.
2017-06-14 12:02:54 +02:00
Marko Mäkelä
8f643e2063 Merge 10.1 into 10.2 2017-05-23 11:09:47 +03:00
Marko Mäkelä
b61700c221 Merge 10.0 into 10.1 2017-05-23 08:59:03 +03:00
Marko Mäkelä
70505dd45b Merge 10.1 into 10.2 2017-05-22 09:46:51 +03:00
Sergei Golubchik
7c03edf2fe MDEV-6262 analyze the coverity report on mariadb
uploaded 10.0, analyzed everything with the Impact=High
(and a couple of Medium)
2017-05-19 20:26:56 +02:00
Marko Mäkelä
71cd205956 Silence bogus GCC 7 warnings -Wimplicit-fallthrough
Do not silence uncertain cases, or fix any bugs.

The only functional change should be that ha_federated::extra()
is not calling DBUG_PRINT to report an unhandled case for
HA_EXTRA_PREPARE_FOR_DROP.
2017-05-17 08:27:04 +03:00
Marko Mäkelä
7972da8aa1 Silence bogus GCC 7 warnings -Wimplicit-fallthrough
Do not silence uncertain cases, or fix any bugs.

The only functional change should be that ha_federated::extra()
is not calling DBUG_PRINT to report an unhandled case for
HA_EXTRA_PREPARE_FOR_DROP.
2017-05-17 08:07:02 +03:00
Monty
71fa413c16 MDEV-10139 Support for SEQUENCE objects
- SETVAL(sequence_name, next_value, is_used, round)
- ALTER SEQUENCE, including RESTART WITH

Other things:
- Added handler::extra() option HA_EXTRA_PREPARE_FOR_ALTER_TABLE to signal
  ha_sequence() that it should allow write_row statments.
- ALTER ONLINE TABLE now works with SEQUENCE:s
2017-05-08 02:44:55 +03:00
Monty
5a759d31f7 Changing field::field_name and Item::name to LEX_CSTRING
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
  accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
  access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)

Changes:
- This caused some ABI changes
  - lex_string_set now uses LEX_CSTRING
  - Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
  errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
  parsing and events.
- Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
  code
- Added item_empty_name and item_used_name to be able to distingush between
  items that was given an empty name and items that was not given a name
  This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item->name_length before some calls to
  my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
  set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
  give the error.

TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
  (as part of lower_case_table_names)
2017-04-23 22:35:46 +03:00
Alexander Barkov
b781408601 MDEV-9235 Add Type_handler::is_param_long_data_type() 2017-04-22 16:49:26 +04:00
Monty
17a87d6063 MDEV-10139 Support for SEQUENCE objects
Working features:
CREATE OR REPLACE [TEMPORARY] SEQUENCE [IF NOT EXISTS] name
    [ INCREMENT [ BY | = ] increment ]
    [ MINVALUE [=] minvalue | NO MINVALUE ]
    [ MAXVALUE [=] maxvalue | NO MAXVALUE ]
    [ START [ WITH | = ] start ] [ CACHE [=] cache ] [ [ NO ] CYCLE ]
    ENGINE=xxx COMMENT=".."
SELECT NEXT VALUE FOR sequence_name;
SELECT NEXTVAL(sequence_name);
SELECT PREVIOUS VALUE FOR sequence_name;
SELECT LASTVAL(sequence_name);

SHOW CREATE SEQUENCE sequence_name;
SHOW CREATE TABLE sequence_name;
CREATE TABLE sequence-structure ... SEQUENCE=1
ALTER TABLE sequence RENAME TO sequence2;
RENAME TABLE sequence TO sequence2;
DROP [TEMPORARY] SEQUENCE  [IF EXISTS] sequence_names

Missing features
- SETVAL(value,sequence_name), to be used with replication.
- Check replication, including checking that sequence tables are marked
  not transactional.
- Check that a commit happens for NEXT VALUE that changes table data (may
  already work)
- ALTER SEQUENCE. ANSI SQL version of setval.
- Share identical sequence entries to not add things twice to table list.
- testing insert/delete/update/truncate/load data
- Run and fix Alibaba sequence tests (part of mysql-test/suite/sql_sequence)
- Write documentation for NEXT VALUE / PREVIOUS_VALUE
- NEXTVAL in DEFAULT
  - Ensure that NEXTVAL in DEFAULT uses database from base table
- Two NEXTVAL for same row should give same answer.
- Oracle syntax sequence_table.nextval, without any FOR or FROM.
- Sequence tables are treated as 'not read constant tables' by SELECT; Would
  be better if we would have a separate list for sequence tables so that
  select doesn't know about them, except if refereed to with FROM.

Other things done:
- Improved output for safemalloc backtrack
- frm_type_enum changed to Table_type
- Removed lex->is_view and replaced with lex->table_type. This allows
  use to more easy check if item is view, sequence or table.
- Added table flag HA_CAN_TABLES_WITHOUT_ROLLBACK, needed for handlers
  that want's to support sequences
- Added handler calls:
 - engine_name(), to simplify getting engine name for partition and sequences
 - update_first_row(), to be able to do efficient sequence implementations.
 - Made binlog_log_row() global to be able to call it from ha_sequence.cc
- Added handler variable: row_already_logged, to be able to flag that the
  changed row is already logging to replication log.
- Added CF_DB_CHANGE and CF_SCHEMA_CHANGE flags to simplify
  deny_updates_if_read_only_option()
- Added sp_add_cfetch() to avoid new conflicts in sql_yacc.yy
- Moved code for add_table_options() out from sql_show.cc::show_create_table()
- Added String::append_longlong() and used it in sql_show.cc to simplify code.
- Added extra option to dd_frm_type() and ha_table_exists to indicate if
  the table is a sequence. Needed by DROP SQUENCE to not drop a table.
2017-04-07 18:09:56 +04:00
Sergei Golubchik
da4d71d10d Merge branch '10.1' into 10.2 2017-03-30 12:48:42 +02:00
Sergei Golubchik
09a2107b1b Merge branch '10.0' into 10.1 2017-03-21 19:20:44 +01:00
Sergei Golubchik
0d622bed4f Merge branch '5.5' into 10.0 2017-03-21 11:35:50 +01:00
Oleksandr Byelkin
24cbc8dae3 MDEV-11966: Impossible to execute prepared ANALYZE SELECT
Prepare os ANALYZE now respond as EXPLAIN.
2017-03-09 11:04:51 +01:00
Sergei Petrunia
2abc313c37 Use correct function name in DEBUG_ENTER 2017-03-09 12:34:06 +03:00
Sergei Golubchik
2195bb4e41 Merge branch '10.1' into 10.2 2017-02-10 17:01:45 +01:00
Alexander Barkov
106fbadaba MDEV-11848 Automatic statement repreparation changes query semantics 2017-01-24 17:29:51 +04:00
Alexander Barkov
45e40892c5 MDEV-11134 Assertion `fixed' failed in Item::const_charset_converter(THD*, CHARSET_INFO*, bool, const char*)
Problem: Item_param::basic_const_item() returned true when fixed==false.
This unexpected combination made Item::const_charset_converter() crash
on asserts.

Fix:
- Changing all Item_param::set_xxx() to set "fixed" to true.
  This fixes the problem.
- Additionally, changing all Item_param::set_xxx() to set
  Item_param::item_type, to avoid duplicate code, and for consistency,
  to make the code symmetric between different constant types.
  Before this patch only set_null() set item_type.
- Moving Item_param::state and Item_param::item_type from public to private,
  to make sure easier that these members are in sync with "fixed" and to
  each other.
- Adding a new argument "unsigned_arg" to Item::set_decimal(),
  and reusing it in two places instead of duplicate code.
- Adding a new method Item_param::fix_temporal() and reusing it in two places.
- Adding methods has_no_value(), has_long_data_value(), has_int_value(),
  instead of direct access to Item_param::state.
2017-01-23 22:25:29 +04:00
Sergei Golubchik
ef8003eb9a MDEV-11698 Old Bug possibly not fixed; BEFORE INSERT Trigger on NOT NULL
check_that_all_fields_are_given_values() relied on write_set,
but was run too early, before triggers updated write_set.

also, when triggers are present, fields might get values conditionally,
so we need to check that all fields are given values for every row.
2017-01-17 20:16:09 +01:00
Sergei Golubchik
4a5d25c338 Merge branch '10.1' into 10.2 2016-12-29 13:23:18 +01:00
Oleksandr Byelkin
098dff10ba MDEV-11359 Implement IGNORE for bulk operation 2016-11-29 08:29:46 +01:00
Alexander Barkov
9bfde897c3 MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter
This patch adds DEFAULT as a possible dynamic SQL parameter, e.g.:
  EXECUTE IMMEDIATE 'INSERT INTO t1 (column) VALUES(?)' USING DEFAULT;
  EXECUTE IMMEDIATE 'UPDATE t1 SET column=?' USING DEFAULT;
and for similar PREPARE..EXECUTE queries.

This is done for symmetry with the STMT_INDICATOR_DEFAULT indicator in
the client-server PS protocol.

The changes include:
- Allowing DEFAULT as a possible option in execute USING clause (sql_yacc.yy)
- Adding "virtual bool Item::save_in_param(THD *thd, Item_param *param)",
  because "normal" items (that have real values) and Item_default_value
  have now different actions when assigning itself as an Item_param value.
- Fixing switch() statements in a few Item_param methods not to have "default",
  because it was easy to forget to add a new "case" when adding a new XXX_VALUE
  value into the enum Item_param::enum_item_param_state.
  This is important, as we'll be adding new values soon, e.g. for MDEV-11359.
  Removing "default" helped to find and report bugs MDEV-11361 and MDEV-11362,
  because DECIMAL_VALUE is obviously not properly handled in some cases.
2016-11-27 18:21:18 +04:00
Oleksandr Byelkin
b162068456 Fixed embedded prepared statements. 2016-11-18 18:29:03 +01:00
Oleksandr Byelkin
99d07aa9bd Fixed print format. 2016-11-03 16:56:18 +01:00
Oleksandr Byelkin
e2d6912609 MDEV-9114: Bulk operations (Array binding)
(+ default values)
2016-11-02 15:07:52 +01:00
Alexander Barkov
46dc7bdf1d MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
MDEV-10867 PREPARE..EXECUTE is not consistent about non-ASCII characters
2016-10-08 13:06:15 +04:00
Alexander Barkov
e1a212ebbc MDEV-10585 EXECUTE IMMEDIATE statement 2016-10-08 12:32:52 +04:00
Alexander Barkov
4c45b820aa MDEV-10709 Expressions as parameters to Dynamic SQL 2016-10-08 11:50:18 +04:00