Commit graph

3917 commits

Author SHA1 Message Date
Alexey Botchkov
90f2c82246 MDEV-7817 ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written into binlog if nothing to do.
Just log the ALTER statement even if there's nothing to do.
2015-10-06 00:18:41 +05:00
Monty
b2b07b33cf Don't write DROP TEMPORARY TABLE to binary log
if we didn't write the CREATE TEMPORARY TABLE statement.

- Enable old code from one of my older changesets that didn't make into 10.0
- Fix test cased that failed as they expected DROP TEMPORARY TABLE in the log.
2015-10-05 17:14:13 +02:00
Nirbhay Choubey
38f3b99d46 MDEV-8831 : enforce_storage_engine doesn't block table creation on other nodes
Check if the engine is supported/allowed before replicating the
statement.
2015-10-01 20:36:25 -04:00
Alexander Barkov
5c9c8ef1ea MDEV-3929 Add system variable explicit_defaults_for_timestamp for compatibility with MySQL 2015-09-22 14:01:54 +04:00
Jan Lindström
9b577edd50 MDEV-8577: With enforce-storage-engine mysql_upgrade corrupts the schema:
ALTER TABLE should either bypass enforce-storage-engine, or mysql_upgrade
should refuse to run

Allow user to alter contents of existing table without enforcing
storage engine. However, enforce storage engine on ALTER TABLE
x ENGINE=y;
2015-09-12 13:16:05 +03:00
Sergei Golubchik
530a6e7481 Merge branch '10.0' into 10.1
referenced_by_foreign_key2(), needed for InnoDB to compile,
was taken from 10.0-galera
2015-09-03 12:58:41 +02:00
Monty
3bca8db4f9 MDEV-6152: Remove calls to current_thd while creating Item
- Part 4: Removing calls to sql_alloc() and sql_calloc()

Other things:
- Added current_thd in some places to make it clear that it's called (easier to remove later)
- Move memory allocation from Item_func_case::fix_length_and_dec() to Item_func_case::fix_fields()
- Added mem_root to some new calls
- Fixed some wrong UNINIT_VAR() calls
- Fixed a bug in generate_partition_syntax() in case of errors
- Added mem_root to argument to new thread_info
- Simplified my_parse_error() call in sql_yacc.yy
2015-08-27 22:29:11 +03:00
Monty
3cb578c001 MDEV-6152: Remove calls to current_thd while creating Item
- Part 3: Adding mem_root to push_back() and push_front()

Other things:
- Added THD as an argument to some partition functions.
- Added memory overflow checking for XML tag's in read_xml()
2015-08-27 22:21:08 +03:00
Monty
1bae0d9e56 Stage 2 of MDEV-6152:
- Added mem_root to all calls to new Item
- Added private method operator new(size_t size) to Item to ensure that
  we always use a mem_root when creating an item.

This saves use once call to current_thd per Item creation
2015-08-21 10:40:51 +04:00
Sergey Vojtovich
31e365efae MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)
Added mandatory thd parameter to Item (and all derivative classes) constructor.
Added thd parameter to all routines that may create items.
Also removed "current_thd" from Item::Item. This reduced number of
pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
2015-08-21 10:40:39 +04:00
Monty
4374da63f0 Merge /my/maria-10.1-default into 10.1 2015-08-18 11:27:00 +03:00
Monty
6b20342651 Ensure that fields declared with NOT NULL doesn't have DEFAULT values if not specified and if not timestamp or auto_increment
In original code, sometimes one got an automatic DEFAULT value in some cases, in other cases not.

For example:
create table t1 (a int primary key)      - No default
create table t2 (a int, primary key(a))  - DEFAULT 0
create table t1 SELECT ....              - Default for all fields, even if they where defined as NOT NULL
ALTER TABLE ... MODIFY could sometimes add an unexpected DEFAULT value.

The patch is quite big because we had some many test cases that used
CREATE ... SELECT or CREATE ... (...PRIMARY KEY(xxx)) which doesn't have an automatic DEFAULT anymore.

Other things:
- Removed warnings from InnoDB when waiting from semaphore (got this when testing things with --big)
2015-08-18 11:18:57 +03:00
Alexander Barkov
86a3613d4e MDEV-8441 Bad SHOW CREATE TABLE output for a table with a virtual column 2015-08-10 11:46:41 +04:00
Jan Lindström
46ad86f6a3 MDEV-8582: innodb_force_primary_key option does not force PK or unique key
Analysis: Handler used table flag HA_REQUIRE_PRIMARY_KEY but a bug on
sql_table.cc function mysql_prepare_create_table internally marked
secondary key with NOT NULL colums as unique key and did not then
fail on requirement that table should have primary key or unique key.
2015-08-08 19:32:40 +03:00
Sergei Petrunia
3025c42605 Make ANALYZE FORMAT=JSON show execution time for filesort element. 2015-08-07 17:41:35 +03:00
Monty
f3e578ab30 Fixed MDEV-8428: Mangled DML statements on 2nd level slave when enabling binlog checksums
Fix was to add a test in Query_log_event::Query_log_event() if we are using
CREATE ... SELECT and in this case use trans cache, like we do on the master.
This avoid using (with doesn't have checksum)

Other things:
- Removed dummy call my_checksum(0L, NULL, 0)
- More DBUG_PRINT
- Cleaned up Log_event::need_checksum() to make it more readable (similar as in MySQL 5.6)
- Renamed variable that was hiding another one in create_table_imp()
2015-07-26 14:32:45 +03:00
Nirbhay Choubey
dced5146bd Merge branch '10.0-galera' into 10.1 2015-07-14 16:05:29 -04:00
Monty
7332af49e4 - Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)
- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
2015-07-06 20:24:14 +03:00
Sergei Golubchik
658992699b Merge tag 'mariadb-10.0.20' into 10.1 2015-06-27 20:35:26 +02:00
Jan Lindström
d535728165 MDEV-8219: enforce_storage_engine cannot be set globally
Change session only variable enforce_storage_engine to be
session variable and make sure that also global value
is used if session variable is not set.
2015-06-26 11:43:16 +03:00
Sergei Golubchik
b56ad494b4 MDEV-8287 DROP TABLE suppresses all engine errors
in ha_delete_table()
* only convert ENOENT and HA_ERR_NO_SUCH_TABLE to warnings
* only return real error codes (that is, not ENOENT and
  not HA_ERR_NO_SUCH_TABLE)
* intercept HA_ERR_ROW_IS_REFERENCED to generate backward
  compatible ER_ROW_IS_REFERENCED

in mysql_rm_table_no_locks()
* no special code to handle HA_ERR_ROW_IS_REFERENCED
* no special code to handle ENOENT and HA_ERR_NO_SUCH_TABLE
* return multi-table error ER_BAD_TABLE_ERROR <table list> only
  when there were many errors, not when there were many
  tables to drop (but only one table generated an error)
2015-06-16 23:58:40 +02:00
Sergei Golubchik
985e430c0f after-merge fixes
in innobase: compilation error on windows
other changes: perfschema merge followup
2015-06-16 23:55:56 +02:00
Sergey Vojtovich
909f760701 MDEV-5309 - RENAME TABLE does not check for existence of the table's engine
When RENAME TABLE is executed, it apparently does not check whether the engine
is available (unlike ALTER TABLE .. RENAME, which does). It means that if the
engine in question was not loaded on some reason, the table might become
unusable, since the engine won't know about the change.

With this patch RENAME TABLE fails if storage engine is not available.
2015-06-16 12:12:17 +04:00
Alexey Botchkov
196528eb42 MDEV-8212 alter table - failing to ADD PRIMARY KEY IF NOT EXISTS when existing index of same as column name.
The default name for the primary key is rather 'PRIMARY' instead of the indexed column name.
2015-06-14 18:54:13 +05:00
Sergei Golubchik
810cf362ea Merge branch '5.5' into 10.0 2015-06-11 20:20:35 +02:00
Sergei Golubchik
f84f577aa1 Merge tag 'mysql-5.5.44' into bb-5.5-serg 2015-06-05 02:06:51 +02:00
Sergei Golubchik
5091a4ba75 Merge tag 'mariadb-10.0.19' into 10.1 2015-06-01 15:51:25 +02:00
Sergey Vojtovich
4d1ccc4289 MDEV-7951 - sql_alloc() takes 0.25% in OLTP RO
sql_alloc() has additional costs compared to direct mem_root allocation:
- function call: it is defined in a separate translation unit and can't be
  inlined
- it needs to call pthread_getspecific() to get THD::mem_root

It is called dozens of times implicitely at least by:
- List<>::push_back()
- List<>::push_front()
- new (for Sql_alloc derived classes)
- sql_memdup()

Replaced lots of implicit sql_alloc() calls with direct mem_root allocation,
passing through THD pointer whenever it is needed.

Number of sql_alloc() calls reduced 345 -> 41 per OLTP RO transaction.
pthread_getspecific() overhead dropped 0.76 -> 0.59
sql_alloc() overhed dropped 0.25 -> 0.06
2015-05-13 10:43:14 +04:00
Sergei Golubchik
49c853fb94 Merge branch '5.5' into 10.0 2015-05-04 22:00:24 +02:00
Sergei Golubchik
532de70269 more tests, moving code around 2015-05-03 11:31:04 +02:00
Daniel Black
2bb0e71358 Alter online table x (no options) possible
This no-op of an operations should be able to occur without locks and
occur online.
2015-05-01 09:57:12 +10:00
Sergei Golubchik
f9c02d7c29 Merge branch 'openquery/MDEV-6916-maria-5.5-check_view-r4408' into 5.5 2015-04-28 21:11:49 +02:00
Sergei Golubchik
0f12ada6b6 Merge remote-tracking branch 'mysql/5.5' into 5.5 2015-04-27 21:04:06 +02:00
Daniel Black
7229b19c67 remove include sql_view.h from sql_table.cc - unneeded 2015-04-13 22:28:12 +10:00
Kristian Nielsen
2de8db6296 Merge MDEV-7936 into 10.1 2015-04-13 14:28:07 +02:00
Kristian Nielsen
60d094aeac MDEV-7936: Assertion `!table || table->in_use == _current_thd()' failed on parallel replication in optimistic mode
Make sure that in parallel replication, we execute wait_for_prior_commit()
before setting table->in_use for a temporary table. Otherwise we can end up
with two parallel replication worker threads competing with each other for
use of a temporary table.

Re-factor the use of find_temporary_table() to be able to handle errors
in the caller (as wait_for_prior_commit() can return error in case of
deadlock kill).
2015-04-13 14:24:18 +02:00
Oleksandr Byelkin
c8dbef22ad MDEV-6916 REPAIR VIEW / mysql migration
from: r4407
2015-04-12 20:41:28 +10:00
Sergei Petrunia
a445b83d73 Merge branch '10.1' of github.com:MariaDB/server into 10.1 2015-04-12 05:16:48 +03:00
Sergei Petrunia
4938b82263 MDEV-7836: ANALYZE FORMAT=JSON should provide info about GROUP/ORDER BY
Provide basic info about sorting/grouping done by the queries.
2015-04-12 04:48:42 +03:00
Alexander Barkov
135f203d28 A cleanup for the contributed patch for
MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment
2015-04-10 17:04:44 +04:00
Alexander Barkov
23e90e9a22 Merge branch 'MDEV-7816' of git://github.com/f4rnham/server into 10.1 2015-04-10 15:17:44 +04:00
Alexander Barkov
7f613ebdb6 MDEV-7284 INDEX: CREATE OR REPLACE 2015-04-03 15:43:55 +04:00
f4rnham
4feaa06c84 MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment
Consider two indexes different if their comments differ
2015-03-26 00:01:14 +01:00
Alexander Barkov
0c26c0032c A preparatory patch for MDEV-7284 INDEX: CREATE OR REPLACE.
Removing "bool Key::create_if_not_exists" and deriving Key from
DDL_options instead.
2015-03-20 13:51:41 +04:00
Venkatesh Duggirala
59142d9a27 Bug #20439913 CREATE TABLE DB.TABLE LIKE TMPTABLE IS
BINLOGGED INCORRECTLY - BREAKS A SLAVE

Submitted a incomplete patch with my previous push,
re submitting the extra changes the required to make
the patch complete.
2015-03-13 13:13:48 +05:30
Venkatesh Duggirala
151b8ec4d1 Bug #20439913 CREATE TABLE DB.TABLE LIKE TMPTABLE IS BINLOGGED INCORRECTLY - BREAKS A SLAVE
Analysis:
In row based replication, Master does not send temp table information
to Slave. If there are any DDLs that involves in regular table that needs
to be sent to Slave and a temp tables (which will not be available at Slave),
the Master rewrites the query replacing temp table with it's defintion.
Eg: create table regular_table like temptable.
In rewrite logic, server is ignoring the database of regular table
which can cause problems mentioned in this bug.

Fix: dont ignore database information (if available) while
rewriting the query
2015-03-13 12:32:44 +05:30
Jan Lindström
8249dcaaeb MDEV-6858: enforce_storage_engine option
Merge from Percona Server enforced use of a specific storage engine
authored by Stewart Smith.

Modified to be session variable and modifiable only by SUPER. Use
similar implementation as default_storage_engine.
2015-03-12 12:17:14 +02:00
Oleksandr Byelkin
80f03abcca MDEV-7671: Cache VIEW definitions in the TDC
(changes of backported patch are very small: strlen removed, error processing fixed, view open statistics added)
2015-03-11 17:39:15 +01:00
Sergei Golubchik
bfe703a458 don't let current_thd to point to a destroyed THD
* reset current_thd in THD::~THD, otherwise my_malloc_size_cb_func()
  might access THD after it was destroyed.
* remove now redundant set_current_thd(0) calls that follow delete thd.
2015-02-03 18:19:56 +01:00
Sergei Golubchik
80ce0c1c9c cleanup: ha_checktype()
* error reporting was never needed
* avoid useless transformaton hton to db_type to hton
* in many cases the engine was guaranteed to exist, add asserts
* use ha_default_handlerton() instead of ha_checktype(DB_TYPE_DEFAULT)
2015-02-02 20:57:46 +01:00