Commit graph

623 commits

Author SHA1 Message Date
Alexander Barkov
bdab5b667e Merge remote-tracking branch 'origin/10.1' into 10.2 2020-05-22 14:22:45 +04:00
Alexander Barkov
cb9c49a9b2 MDEV-22111 ERROR 1064 & 1033 and SIGSEGV on CREATE TABLE w/ various charsets on 10.4/5 optimized builds | Assertion `(uint) (table_check_constraints - share->check_constraints) == (uint) (share->table_check_constraints - share->field_check_constraints)' failed
The code incorrectly assumed in multiple places that TYPELIB
values cannot have 0x00 bytes inside. In fact they can:

  CREATE TABLE t1 (a ENUM(0x61, 0x0062) CHARACTER SET BINARY);

Note, the TYPELIB value encoding used in FRM is ambiguous about 0x00.

So this fix is partial.

It fixes 0x00 bytes in many (but not all) places:

- In the middle or in the end of a value:
    CREATE TABLE t1 (a ENUM(0x6100) ...);
    CREATE TABLE t1 (a ENUM(0x610062) ...);

- In the beginning of the first value:
    CREATE TABLE t1 (a ENUM(0x0061));
    CREATE TABLE t1 (a ENUM(0x0061), b ENUM('b'));

- In the beginning of the second (and following) value of the *last* ENUM/SET
  in the table:

    CREATE TABLE t1 (a ENUM('a',0x0061));
    CREATE TABLE t1 (a ENUM('a'), b ENUM('b',0x0061));

However, it does not fix 0x00 when:

- 0x00 byte is in the beginning of a value of a non-last ENUM/SET
  causes an error:

   CREATE TABLE t1 (a ENUM('a',0x0061), b ENUM('b'));
   ERROR 1033 (HY000): Incorrect information in file: './test/t1.frm'

  This is an ambuguous case and will be fixed separately.
  We need a new TYPELIB encoding to fix this.

Details:

- unireg.cc

  The function pack_header() incorrectly used strlen() to detect
  a TYPELIB value length. Adding a new function typelib_values_packed_length()
  which uses TYPELIB::type_lengths[n] to detect the n-th value length,
  and reusing the new function in pack_header() and packed_fields_length()

- table.cc
  fix_type_pointers() assumed in multiple places that values cannot have
  0x00 inside and used strlen(TYPELIB::type_names[n]) to set
  the corresponding TYPELIB::type_lengths[n].

  Also, fix_type_pointers() did not check the encoded data for consistency.

  Rewriting fix_type_pointers() code to populate TYPELIB::type_names[n] and
  TYPELIB::type_lengths[n] at the same time, so no additional loop
  with strlen() is needed any more.

  Adding many data consistency tests.

  Fixing the main loop in fix_type_pointers() to use memchr() instead of
  strchr() to handle 0x00 properly.

  Fixing create_key_infos() to return the result in a LEX_STRING rather
  that in a char*.
2020-05-22 07:47:49 +04:00
Marko Mäkelä
ccc06931c3 Merge 10.4 into 10.5 2020-04-08 10:36:41 +03:00
Aleksey Midenkov
76063c2a13 MDEV-20494 ER_NOT_FORM_FILE or assertion upon adding partition to period table
- Fixed mysql_prepare_create_table() constraint duplicate checking;
- Refactored period constraint handling in mysql_prepare_alter_table():
  * No need to allocate new objects;
  * Keep old constraint name but exclude it from dup checking by automatic_name;
- Some minor memory leaks fixed;
- Some conceptual TODOs.
2020-04-03 23:55:48 +03:00
Nikita Malyavin
259fb1cbed MDEV-16978 Application-time periods: WITHOUT OVERLAPS
* The overlaps check is implemented on a handler level per row command.
  It creates a separate cursor (actually, another handler instance) and
  caches it inside the original handler, when ha_update_row or
  ha_insert_row is issued. Cursor closes on unlocking the handler.

* Containing the same key in index means unique constraint violation
  even in usual terms. So we fetch left and right neighbours and check
  that they have same key prefix, excluding from the key only the period part.
  If it doesnt match, then there's no such neighbour, and the check passes.
  Otherwise, we check if this neighbour intersects with the considered key.

* The check does not introduce new error and fails with ER_DUPP_KEY error.
  This might break REPLACE workflow and should be fixed separately
2020-03-31 17:42:34 +02:00
Sergei Golubchik
7c58e97bf6 perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
Marko Mäkelä
8cc15c036d Merge 10.4 into 10.5 2019-12-27 21:17:16 +02:00
Marko Mäkelä
4c25e75ce7 Merge 10.3 into 10.4 2019-12-27 18:20:28 +02:00
Marko Mäkelä
5ab70e7f68 Merge 10.2 into 10.3 2019-12-27 15:14:48 +02:00
Marko Mäkelä
73985d8301 Merge 10.1 into 10.2 2019-12-23 07:14:51 +02:00
Sergei Petrunia
984b3c1544 MDEV-21341: Fix UBSAN failures, part #3
One may not call memcpy(dst, src=NULL, size), even if size==0.
2019-12-18 13:11:07 +03:00
Alexander Barkov
afe6eb499d Revert "MDEV-20342 Turn Field::flags from a member to a method"
This reverts commit e86010f909.

Reverting on Monty's request, as this change makes merging
things from 10.5 to 10.2 much harder.
2019-08-14 20:27:00 +04:00
Alexander Barkov
e86010f909 MDEV-20342 Turn Field::flags from a member to a method 2019-08-14 13:33:01 +04:00
Alexander Barkov
1517087b54 MDEV-20042 Implement EXTRA2_FIELD_DATA_TYPE_INFO in FRM 2019-07-11 21:51:18 +04:00
Alexander Barkov
feb2695ed3 MDEV-20004 Move Field_geom from field.cc to sql_type_geom.cc 2019-07-09 19:47:57 +04:00
Alexander Barkov
b3161bd995 A cleanup (to fix ASAN problem) for MDEV-19863 Add const to TYPELIB pointers
In this statement:

  (uint *) thd->alloc(sizeof(uint) * field->interval->count+1);

parentheses around the '+' operator were missing. So too few memory
was allocated, which caused ASAN builds to fail on these tests:

  innodb.innodb-ucs2
  parts.part_ctype_utf32
  main.mix2_myisam_ucs2
  main.case
  main.ctype_ucs
  main.ctype_utf16
  main.ctype_utf16_uca
  main.ctype_utf16le

Fixed to a correct version with parentheses:

  (uint *) thd->alloc(sizeof(uint) * (field->interval->count+1));
2019-07-04 18:26:59 +04:00
Monty
1a41fc77dd Merge remote-tracking branch 'origin/10.4' into 10.5 2019-06-27 01:21:41 +03:00
Alexander Barkov
677133f1b3 MDEV-19863 Add const to TYPELIB pointers 2019-06-26 05:29:44 +04:00
Eugene Kosov
d36c107a6b imporve clang build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug

Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about
deprecated `register` keyword.

Too much warnings came from Mroonga and I gave up on it.
2019-06-25 13:21:36 +03:00
Oleksandr Byelkin
c07325f932 Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Vicențiu Ciorbaru
5543b75550 Update FSF Address
* Update wrong zip-code
2019-05-11 21:29:06 +03:00
Alexander Barkov
ca7fbcea6c MDEV-19317 TEXT column accepts too long literals as a default value
Adding new virtual methods in Field:
- make_empty_rec_store_default_value()
- make_empty_rec_reset()

This simplifies the logic for every Field type,
and makes the code more friendly to pluggable data types.
2019-04-25 08:26:08 +04:00
Sergey Vojtovich
5d8ca98997 Get rid of rea_create_table()
Moved rea_create_table() to the sole caller.

Also ha_create_partitioning_metadata(CHF_CREATE_FLAG) does cleanup on
error now.

Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
2019-04-03 17:43:12 +04:00
Sergey Vojtovich
38e151d155 Fix inplace ALTER TABLE to not register tmp table
Do not register intermediate tables created by inplace ALTER TABLE in
THD::temporary_tables.

Regular ALTER TABLE doesn't create .frm for temporary and discoverable
tables anymore. For inplace ALTER TABLE moved .frm creation to
create_table_for_inplace_alter().

Removed open_in_engine argument of create_and_open_tmp_table() and
open_temporary_table(): it became unused after this patch.

Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
2019-04-03 17:38:26 +04:00
Sergei Golubchik
20c89f9f37 MDEV-18712 InnoDB indexes are inconsistent with what defined in .frm for table after rebuilding table with index on blob
when auto-adding a virtual LONG_UNIQUE_HASH_FIELD, fill in
a Virtual_column_info for it, so that fill_alter_inplace_info()
would know we're adding a virtual field (ALTER_ADD_VIRTUAL_COLUMN).
2019-02-27 23:27:43 -05:00
Sachin
d00f19e832 MDEV-371 Unique Index for long columns
This patch implements engine independent unique hash index.

Usage:- Unique HASH index can be created automatically for blob/varchar/test column whose key
 length > handler->max_key_length()
or it can be explicitly specified.

  Automatic Creation:-
   Create TABLE t1 (a blob unique);
  Explicit Creation:-
   Create TABLE t1 (a int , unique(a) using HASH);

Internal KEY_PART Representations:-
 Long unique key_info will have 2 representations.
 (lets understand this with an example create table t1(a blob, b blob , unique(a, b)); )

 1. User Given Representation:- key_info->key_part array will be similar to what user has defined.
 So in case of example it will have 2 key_parts (a, b)

 2. Storage Engine Representation:- In this case there will be only one key_part and it will point to
 HASH_FIELD. This key_part will be always after user defined key_parts.

 So:- User Given Representation          [a] [b] [hash_key_part]
                  key_info->key_part ----^
  Storage Engine Representation          [a] [b] [hash_key_part]
                  key_info->key_part ------------^

 Table->s->key_info will have User Given Representation, While table->key_info will have Storage Engine
 Representation.Representation can be changed into each other by calling re/setup_keyinfo_hash function.

Working:-

1. So when user specifies HASH_INDEX or key_length is > handler->max_key_length(), In mysql_prepare_create_table
One extra vfield is added (for each long unique key). And key_info->algorithm is set to HA_KEY_ALG_LONG_HASH.

2. In init_from_binary_frm_image values for hash_keypart is set (like fieldnr , field and flags)

3. In parse_vcol_defs, HASH_FIELD->vcol_info is created. Item_func_hash is used with list of Item_fields,
   When Explicit length is given by user then Item_left is used to concatenate Item_field values.

4. In ha_write_row/ha_update_row check_duplicate_long_entry_key is called which will create the hash key from
table->record[0] and then call ha_index_read_map , if we found duplicated hash , we will compare the result
field by field.
2019-02-22 00:35:40 +01:00
Sergei Golubchik
81ecc2b2b5 store string lengths in frm in 1-3 bytes 2019-02-21 14:57:10 +01:00
Sergei Golubchik
81e4b9b3bb misc cleanups 2019-02-21 14:57:10 +01:00
Nikita Malyavin
6294516a56 MDEV-16975 Application-time periods: ALTER TABLE
* implicit period constraint is hidden and cannot be dropped independently
* create...like and create...select support
2019-02-21 14:57:09 +01:00
Nikita Malyavin
073c93b194 MDEV-17082 Application-time periods: CREATE
* add syntax `CREATE TABLE ... PERIOD FOR <apptime>`
* add table period entity
2019-02-21 14:48:04 +01:00
Alexander Barkov
ab297744b7 Merge remote-tracking branch 'origin/10.3' into 10.4 2018-06-05 10:50:08 +04:00
Alexander Barkov
106f0b5798 MDEV-16385 ROW SP variable is allowed in unexpected context
The problem described in the bug report happened because the code
did not test check_cols(1) after fix_fields() in a few places.

Additionally, fix_fields() could be called multiple times for SP variables,
because they are all fixed at a early stage in append_for_log().

Solution:
1. Adding a few helper methods
   - fix_fields_if_needed()
   - fix_fields_if_needed_for_scalar()
   - fix_fields_if_needed_for_bool()
   - fix_fields_if_needed_for_order_by()
  and using it in many cases instead of fix_fields() where
  the "fixed" status is not definitely known to be "false".

2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields()
   to catch double execution.

3. Adding tests.

As a good side effect, the patch removes a lot of duplicate code (~60 lines):

   if (!item->fixed &&
       item->fix_fields(..) &&
       item->check_cols(1))
     return true;
2018-06-05 10:25:39 +04:00
Igor Babaev
cab1d63826 Merge branch '10.3' into 10.4 2018-06-03 10:34:41 -07:00
Alexander Barkov
f584557406 MDEV-9216 Split field.cc:make_field() into virtual methods in Type_handler 2018-05-24 14:47:04 +04:00
Alexander Barkov
dc5802255d MDEV-16280 Add class Bit_addr 2018-05-24 09:31:36 +04:00
Sergei Golubchik
b1a6d2826a cleanup: versioning style fixes
rename LString/XString classes, remove unused ones
2018-05-12 10:16:45 +02:00
Monty
30ebc3ee9e Add likely/unlikely to speed up execution
Added to:
- if (error)
- Lex
- sql_yacc.yy and sql_yacc_ora.yy
- In header files to alloc() calls
- Added thd argument to thd_net_is_killed()
2018-05-07 00:07:32 +03:00
Sergei Golubchik
08a901cc0b cleanup: remove XString::operator== and !=
use named methods instead.
2018-04-10 13:12:36 +02:00
Sergei Golubchik
35678c9572 dead code - related to vtmd
(will be added back when it'll be used)
2018-04-10 13:12:36 +02:00
Marko Mäkelä
b006d2ead4 Merge bb-10.2-ext into 10.3 2018-02-15 10:22:03 +02:00
Alexander Barkov
3cad31f2a7 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2018-02-08 19:06:25 +04:00
Sergei Golubchik
4771ae4b22 Merge branch 'github/10.1' into 10.2 2018-02-06 14:50:50 +01:00
Vladislav Vaintroub
6c279ad6a7 MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from 'size_t' to 'type', possible loss of data)
Handle string length as size_t, consistently (almost always:))
Change function prototypes to accept size_t, where in the past
ulong or uint were used. change local/member variables to size_t
when appropriate.

This fix excludes rocksdb, spider,spider, sphinx and connect for now.
2018-02-06 12:55:58 +00:00
Sergei Golubchik
d4df7bc9b1 Merge branch 'github/10.0' into 10.1 2018-02-02 10:09:44 +01:00
Monty
a7e352b54d Changed database, tablename and alias to be LEX_CSTRING
This was done in, among other things:
- thd->db and thd->db_length
- TABLE_LIST tablename, db, alias and schema_name
- Audit plugin database name
- lex->db
- All db and table names in Alter_table_ctx
- st_select_lex db

Other things:
- Changed a lot of functions to take const LEX_CSTRING* as argument
  for db, table_name and alias. See init_one_table() as an example.
- Changed some function arguments from LEX_CSTRING to const LEX_CSTRING
- Changed some lists from LEX_STRING to LEX_CSTRING
- threads_mysql.result changed because process list_db wasn't always
  correctly updated
- New append_identifier() function that takes LEX_CSTRING* as arguments
- Added new element tmp_buff to Alter_table_ctx to separate temp name
  handling from temporary space
- Ensure we store the length after my_casedn_str() of table/db names
- Removed not used version of rename_table_in_stat_tables()
- Changed Natural_join_column::table_name and db_name() to never return
  NULL (used for print)
- thd->get_db() now returns db as a printable string (thd->db.str or "")
2018-01-30 21:33:55 +02:00
Vicențiu Ciorbaru
d833bb65d5 Merge remote-tracking branch '5.5' into 10.0 2018-01-24 12:29:31 +02:00
Sergei Golubchik
2d52d3c1bf Merge branch 'mysql/5.5' into 5.5 2018-01-18 17:54:48 +01:00
Sergei Golubchik
8aff418ec8 crash with too long index comments 2018-01-18 17:50:34 +01:00
Aleksey Midenkov
ee68d019d1 SQL: removed VERS_HIDDEN_FLAG [closes #409] 2017-12-19 16:12:56 +03:00
Aleksey Midenkov
73606a3977 System Versioning 1.0 pre5 [closes #407]
Merge branch '10.3' into trunk

Both field_visibility and VERS_HIDDEN_FLAG exist independently.

TODO:
VERS_HIDDEN_FLAG should be replaced with SYSTEM_INVISIBLE (or COMPLETELY_INVISIBLE?).
2017-12-15 15:18:59 +03:00
Sachin Setiya
84726906c9 MDEV-10177 Invisible Columns and Invisible Index
Feature Definition:-

This feature adds invisible column functionality to server.
There is 4 level of "invisibility":

1. Not invisible (NOT_INVISIBLE) — Normal columns created by the user

2. A little bit invisible (USER_DEFINED_INVISIBLE) — columns that the
    user has marked invisible. They aren't shown in SELECT * and they
    don't require values in INSERT table VALUE (...). Otherwise
    they behave as normal columns.

3. More invisible (SYSTEM_INVISIBLE) — Can be queried explicitly,
    otherwise invisible from everything. Think ROWID sytem column.
    Because they're invisible from ALTER TABLE and from CREATE TABLE
    they cannot be created or dropped, they're created by the system.
    User cant not create a column name which is same as of
    SYSTEM_INVISIBLE.

4. Very invisible (COMPLETELY_INVISIBLE) — as above, but cannot be
    queried either. They can only show up in EXPLAIN EXTENDED (might
    be possible for a very invisible indexed virtual column) but
    otherwise they don't exist for the user.If user creates a columns
    which has same name as of COMPLETELY_INVISIBLE then
    COMPLETELY_INVISIBLE column is renamed again. So it is completely
    invisible from user.

Invisible Index(HA_INVISIBLE_KEY):-
   Creation of invisible columns require a new type of index which
   will be only visible to system. User cant see/alter/create/delete
   this index. If user creates a index which is same name as of
   invisible index then it will be renamed.

Syntax Details:-

  Only USER_DEFINED_INVISIBLE column can be created by user. This
  can be created by adding INVISIBLE suffix after column definition.

  Create table t1( a int invisible, b int);

Rules:-
  There are some rules/restrictions related to use of invisible columns
  1. All the columns in table cant be invisible.
     Create table t1(a int invisible); \\error
     Create table t1(a int invisible, b int invisble); \\error
  2. If you want invisible column to be NOT NULL then you have to supply
     Default value for the column.
     Create table t1(a int, b int not null); \\error
  3. If you create a view/create table with select * then this wont copy
     invisible fields. So newly created view/table wont have any invisible
     columns.
     Create table t2 as select * from t1;//t2 wont have t1 invisible column
     Create view v1 as select * from t1;//v1 wont have t1 invisible column
  4. Invisibility wont be forwarded to next table in any case of create
     table/view as select */(a,b,c) from table.
     Create table t2 as select a,b,c from t1; // t2 will have t1 invisible
                           // column(b), but this wont be invisible in t2
     Create view v1 as select a,b,c from t1; // v1 will have t1 invisible
                           // column(b), but this wont be invisible in v1

Implementation Details:-
  Parsing:- INVISIBLE_SYM is added into vcol_attribute(so its like unique
      suffix), It is also added into keyword_sp_not_data_type so that table
      can have column with name invisible.
  Implementation detail is given by each modified function/created function.
   (Some function are left as they were self explanatory)
   (m= Modified, n= Newly Created)

  mysql_prepare_create_table(m):- Extra checks for invisible columns are
  added. Also some DEBUG_EXECUTE_IF are also added for test cases.

  mysql_prepare_alter_table(m):- Now this will drop all the
  COMPLETELY_INVISIBLE column and HA_INVISIBLE_KEY index. Further
  Modifications are made to stop drop/change/delete of SYSTEM_INVISIBLE
  column.

  build_frm_image(m):- Now this allows incorporating field_visibility
  status into frm image. To remain compatible with old frms
  field_visibility info will be only written when any of the field is
  not NOT_INVISIBLE.

  extra2_write_additional_field_properties(n):- This will write field
  visibility info into buffer. We first write EXTRA2_FIELD_FLAGS into
  buffer/frm , then each next char will have field_visibility for each
  field.

  init_from_binary_frm_image(m):- Now if we get EXTRA2_FIELD_FLAGS,
  then we will read the next n(n= number of fields) chars and set the
  field_visibility. We also increment
  thd->status_var.feature_invisible_columns. One important thing to
  note if we find out that key contains a field whose visibility is
  > USER_DEFINED_INVISIBLE then , we declare this key as invisible
  key.

  sql_show.cc is changed accordingly to make show table, show keys
  correct.

  mysql_insert(m):- If we get to know that we are doing insert in
  this way insert into t1 values(1,1); without explicitly specifying
  columns, then we check for if we have invisible fields if yes then
  we reset the whole record, Why ? Because first we want hidden columns
  to get default/null value. Second thing auto_increment has property
  no default and no null which voilates invisible key rule 2, And
  because of this it was giving error. Reseting table->record[0]
  eliminates this issue. More info put breakpoint on handler::write_row
  and see auto_increment value.

  fill_record(m):- we continue loop if we find invisible column because
  this is already reseted/will get its value if it is default.

Test cases:- Since we can not directly add > USER_DEFINED_INVISIBLE
  column then I have debug_dbug to create it in mysql_prepare_create_table.

  Patch Credit:- Serg Golubchik
2017-12-15 02:41:52 +05:30
Eugene Kosov
0cdc1164dc SQL, IB: various refactoring [#337] 2017-11-27 15:07:32 +03:00
Aleksey Midenkov
d8d7251019 System Versioning pre0.12
Merge remote-tracking branch 'origin/archive/2017-10-17' into 10.3
2017-11-07 00:37:49 +03:00
Alexander Barkov
835cbbcc7b Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3
TODO: enable MDEV-13049 optimization for 10.3
2017-10-30 20:47:39 +04:00
Karthik Kamath
a542209b9e BUG#26529369: CREATE INDEX WITH LONG COMMENT CAUSE
UNEXPECTED ERROR

ANALYSIS:
=========
Creating many indexes with large amount of index
information causes a server exit.

FIX:
====
A appropriate error is reported when the cumulative index
information length exceeds the 2 byte range (i.e 65535).
2017-10-23 10:56:20 +05:30
Alexander Barkov
30e7d6709f Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-10-18 14:11:55 +04:00
Alexey Botchkov
fe0d2e1a2b MDEV-13923 Assertion `!is_set() || (m_status == DA_OK_BULK &&
is_bulk_op())' failed upon altering table with geometry field.

        Check for the validity of the DEFAULT value for the
        geometry field.
2017-10-11 11:57:26 +04:00
Marko Mäkelä
2c1067166d Merge bb-10.2-ext into 10.3 2017-10-04 08:24:06 +03: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
7354dc6773 MDEV-13384 - misc Windows warnings fixed 2017-09-28 17:20:46 +00: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
Michael Widenius
cc77f9882d Changed KEY names to use LEX_CSTRING 2017-08-24 01:05:53 +02:00
Michael Widenius
458d5ed8aa Lots of small cleanups
- Simplified use_trans_cache() to return at once if is_transactional is set
- Indentation and spelling errors fixed
- Don't call signal_update() if update_binlog_end_pos() is called as the
  function already calls signal_update()
- Removed not used function wait_for_update_bin_log(), which would cause
  errors if ever used.
- Simplified handler::clone() by always allocating 'ref' in ha_open(). To do
  this I added an optional MEM_ROOT argument to ha_open() to be used when
  allocating 'ref'
- Changed arguments to get_system_var() from LEX_CSTRING to LEX_CSTRING*
- Added THD as argument to create_select_for_variable(). Changed also char*
  argument to LEX_CSTRING to avoid strlen() call.
- Change calls to append() to use LEX_CSTRING
2017-08-24 01:05:49 +02:00
Michael Widenius
4aaa38d26e Enusure that my_global.h is included first
- Added sql/mariadb.h file that should be included first by files in sql
  directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables
  that must be done before my_global.h is included)
- Removed a lot of include my_global.h from include files
- Removed include's of some files that my_global.h automatically includes
- Removed duplicated include's of my_sys.h
- Replaced include my_config.h with my_global.h
2017-08-24 01:05:44 +02:00
Aleksey Midenkov
c2c8808a16 SQL: compare TRX_ID fields against timestamps [closes #231] 2017-08-03 16:01:16 +03:00
Eugene Kosov
1903b407da SQL: ignore columns WITHOUT VERSIONING [fixes #220] 2017-07-04 17:45:14 +03:00
Aleksey Midenkov
07ff0e1202 SQL: start_end_t members as LEX_CSTRING 2017-06-23 12:02:06 +03:00
Aleksey Midenkov
448374a228 SQL, IB: (0.10) VTMD tracking [closes #124]
IB: Fixes in logic when to do versioned or usual row updates. Now it is
able to do unversioned updates for versioned tables just by disabling
`TABLE_SHARE::versioned` flag.

SQL: DDL tracking for:
* RENAME TABLE, ALTER TABLE .. RENAME TO;
* DROP TABLE;
* data-modifying operations (f.ex. ALTER TABLE .. ADD/DROP COLUMN).
2017-06-19 15:21:39 +03:00
Kosov Eugene
7d815be198 SQL: store versioning field flags in EXTRA2 2017-05-05 20:36:14 +03:00
Aleksey Midenkov
82114170bc SQL: implicit fields for IB tables + misc cleanups 2017-05-05 20:36:11 +03:00
Daniel Fiala
be6f2d302c 0.1: SQL-level System Versioning 2017-05-05 20:35:08 +03:00
Alexander Barkov
aacb4d57ca MDEV-12695 Add Column_definition::type_handler() 2017-05-05 07:00:18 +04: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
Vladislav Vaintroub
f2fe5cb282 Fix several compile warnings on Windows 2017-03-10 19:07:07 +00:00
Sergei Golubchik
a72f1deb2d rename Virtual_column_info::expr_item
now, when expr_str is gone, expr_item can be unambiguously
renamed to expr.
2016-12-12 20:35:48 +01:00
Sergei Golubchik
a411d7f4f6 store/show vcols as item->print()
otherwise we'd need to store sql_mode *per vcol*
(consider CREATE INDEX...) and how SHOW CREATE TABLE would
support that?

Additionally, get rid of vcol::expr_str, just to make sure
the string is always generated and never leaked in the
original form.
2016-12-12 20:35:41 +01:00
Sergei Golubchik
db3f110864 cleanup: remove unused Field::utype values
and FIELDFLAG_xxx constants
2016-12-12 20:27:30 +01:00
Sergei Golubchik
605cf619ba cleanup: extra_rec_buf_length 2016-12-12 20:27:28 +01:00
kevg
780db8e252 fix build and some warnings 2016-11-24 17:36:02 +03: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
Sergei Golubchik
6e5048e85f clarify the error message for frm size overflow 2016-08-27 16:59:12 +02:00
Sergei Golubchik
06acd7a2fc don't save vcol flags in frm
this is useless now, flags are recalculated on load anyway.
But storing flags on disk means we cannot easily change (add,
remove, or renumber) them in the new MariaDB version.
2016-07-01 22:30:09 +02:00
Sergei Golubchik
20dbfbb49c vcols: store flags first 2016-06-30 11:43:02 +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
Sergei Golubchik
7039077195 change vcol->non_deterministic to vcol->flags 2016-06-30 11:43:02 +02:00
Michael Widenius
fb67cde237 Use default character set for expressions
- Force usage of () around complex DEFAULT expressions
- Give error if DEFAULT expression contains invalid characters
- Don't use const_charset_conversion for stored Item_func_sysconf expressions
  as the result is not constaint over different executions
- Fixed Item_func_user() to not store calculated value in str_value
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
Sergey Vojtovich
54689e1d5c MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()
The following left in semi-improved state to keep patch size reasonable:
- Field operator new: left thd_alloc(current_thd)
- Sql_alloc operator new: left thd_alloc(thd_get_current_thd())
- Item_args constructors: left thd_alloc(thd)
- Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd
- Item_func_dyncol_exists::val_int(): same
- Item_dyncol_get::val_str(): same
- Item_dyncol_get::val_int(): same
- Item_dyncol_get::val_real(): same
- Item_dyncol_get::val_decimal(): same
- Item_singlerow_subselect::fix_length_and_dec(): same
2015-11-26 11:34:17 +04:00
Sergei Golubchik
a099686e2e cleanup: remove Field->stored_in_db, Create_field->stored_in_db
and don't set Create_field->sql_type to MYSQL_TYPE_VIRTUAL
temporarily only to change it again few lines later.
2015-11-24 22:21:42 +01:00
Monty
56aa19989f MDEV-6152: Remove calls to current_thd while creating Item
Part 5: Removing calls to current_thd in net_read calls, creating fields,
        query_cache, acl and some other places where thd was available
2015-09-01 18:42:02 +03: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
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
Alexey Botchkov
c4cb15e87b MDEV-60 Support for Spatial Reference systems for the GIS data.
The GEOMETRY field metadata is stored in the FRM file.
        SRID for a spatial column now can be stored, it was added to the CREATE TABLE syntax,
        so the AddGeometryData() stored procedure is now possible. Script adding the required Add/DropGeometryColumn sp-s added.
2014-12-04 16:09:34 +01:00
Sergei Golubchik
853077ad7e Merge branch '10.0' into bb-10.1-merge
Conflicts:
	.bzrignore
	VERSION
	cmake/plugin.cmake
	debian/dist/Debian/control
	debian/dist/Ubuntu/control
	mysql-test/r/join_outer.result
	mysql-test/r/join_outer_jcl6.result
	mysql-test/r/null.result
	mysql-test/r/old-mode.result
	mysql-test/r/union.result
	mysql-test/t/join_outer.test
	mysql-test/t/null.test
	mysql-test/t/old-mode.test
	mysql-test/t/union.test
	packaging/rpm-oel/mysql.spec.in
	scripts/mysql_config.sh
	sql/ha_ndbcluster.cc
	sql/ha_ndbcluster_binlog.cc
	sql/ha_ndbcluster_cond.cc
	sql/item_cmpfunc.h
	sql/lock.cc
	sql/sql_select.cc
	sql/sql_show.cc
	sql/sql_update.cc
	sql/sql_yacc.yy
	storage/innobase/buf/buf0flu.cc
	storage/innobase/fil/fil0fil.cc
	storage/innobase/include/srv0srv.h
	storage/innobase/lock/lock0lock.cc
	storage/tokudb/CMakeLists.txt
	storage/xtradb/buf/buf0flu.cc
	storage/xtradb/fil/fil0fil.cc
	storage/xtradb/include/srv0srv.h
	storage/xtradb/lock/lock0lock.cc
	support-files/mysql.spec.sh
2014-12-02 22:25:16 +01:00
Sergei Golubchik
f62c12b405 Merge 10.0.14 into 10.1 2014-10-15 12:59:13 +02:00