summaryrefslogtreecommitdiff
path: root/sql/table.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fixed bug mdev-10782.Igor Babaev2016-09-121-3/+10
| | | | | | | | This bug in the code of Item_ref::build_clone could cause corruption of items in where conditions. Also made sure that equality predicates extracted from multiple equality items to be pushed into materialized views were cloned.
* Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-3/+5
|\
| * MDEV-10360: Extended keys: index properties depend on index orderSergei Petrunia2016-07-121-3/+5
| | | | | | | | | | | | | | | | | | TABLE_SHARE::init_from_binary_frm_image has a rule: if an index has a partially-covered column (like in "KEY(col(N))" ), then dont provide "Extended Keys" feature for this index. The problem was that due to coding error Extended Keys feature was disabled for *ALL* subsequent indexes. Fixed the error.
* | Fixed the previous merge to be able to build mysqld.Igor Babaev2016-09-011-1/+1
| | | | | | | | Adjusted one result file.
* | Merge branch '10.2-mdev9197-cons' of github.com:shagalla/serverIgor Babaev2016-08-311-0/+176
|\ \ | | | | | | | | | into branch 10.2-mdev9197.
| * | The consolidated patch for mdev-9197.Galina Shalygina2016-08-231-0/+176
| | |
* | | Merge 10.2 into 10.2-mdev9864.Igor Babaev2016-08-301-414/+812
|\ \ \
| * | | Feature_check_constraint status variableSergei Golubchik2016-08-271-0/+1
| | | |
| * | | re-fix vcols on demand, not always for every SELECTSergei Golubchik2016-08-271-0/+25
| | | |
| * | | move away from TIMESTAMP_DNUN_FIELD/TIMESTAMP_DN_FIELD codeSergei Golubchik2016-08-271-35/+43
| | | | | | | | | | | | | | | | | | | | use the new approach with Field->default_value expressions. But keep the old TIMESTAMP_UN_FIELD for ON UPDATE NOW().
| * | | optimize constant default expressionsSergei Golubchik2016-08-271-24/+23
| | | | | | | | | | | | | | | | | | | | to be calculated at the CREATE TABLE time and stored in the default row image.
| * | | cleanup: redundant variableSergei Golubchik2016-08-271-5/+0
| | | |
| * | | clarify the commentSergei Golubchik2016-08-271-3/+3
| | | | | | | | | | | | | | | | and use the same error message for CREATE and open table time
| * | | session-state dependent functions in DEFAULT/CHECK/vcolsSergei Golubchik2016-08-271-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * revert part of the db7edfe that moved calculations from fix_fields to val_str for Item_func_sysconst and descendants * mark session state dependent functions in check_vcol_func_processor() * re-run fix_fields for all such functions for every statement * fix CURRENT_USER/CURRENT_ROLE not to use Name_resolution_context (that is allocated on the stack in unpack_vcol_info_from_frm()) Note that NOW(), CURDATE(), etc use lazy initialization and do *not* force fix_fields to be re-run. The rule is: * lazy initialization is *not* allowed, if it changes metadata (so, e.g. DAYNAME() cannot use it) * lazy initialization is *preferrable* if it has side effects (e.g. NOW() sets thd->time_zone_used=1, so it's better to do it when the value of NOW is actually needed, not when NOW is simply prepared)
| * | | split fix_vcol_expr()Sergei Golubchik2016-08-271-43/+45
| | | | | | | | | | | | | | | | into "fix" and "check" parts
| * | | NULL pointer dereferenceSergei Golubchik2016-08-271-2/+2
| | | | | | | | | | | | | | | | in a case of a specially crafted invalid frm
| * | | cleanup: use multi_alloc_rootSergei Golubchik2016-08-271-26/+16
| | | |
| * | | don't save vcol flags in frmSergei Golubchik2016-07-011-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | cannot use item->const_item() in open_table_from_share()Sergei Golubchik2016-07-011-2/+2
| | | | | | | | | | | | | | | | | | | | because table->map is set much later. Use check_vcol_func_processor() to detect fields too.
| * | | Merge branch '10.1' into 10.2Sergei Golubchik2016-06-301-18/+16
| |\ \ \ | | | |/ | | |/|
| | * | Merge branch '10.0' into 10.1Sergei Golubchik2016-06-281-18/+16
| | |\ \
| | | * | MDEV-9524 Cannot load from mysql.event when sql_mode is set to ↵Alexander Barkov2016-06-211-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PAD_CHAR_TO_FULL_LENGTH The patch fixes the problem with loading information from system tables (e.g. event and help related tables) when PAD_CHAR_TO_FULL_LENGTH is enabled, as well as includes some additional minor improvements: - refactoring in get_field() to return an error rather than success if strmake_root() failed - removing of duplicate code in similar functions: char *get_field(MEM_ROOT *mem, Field *field) bool get_field(MEM_ROOT *mem, Field *field, String *res)
| * | | | vcols: store flags firstSergei Golubchik2016-06-301-5/+5
| | | | |
| * | | | various cleanupsSergei Golubchik2016-06-301-27/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * | | | fix for CREATE ... ( ... DEFAULT const_expr ... )Sergei Golubchik2016-06-301-30/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make it return same errors on CREATE as CREATE ... ( ... DEFAULT const ... )
| * | | | change vcol->non_deterministic to vcol->flagsSergei Golubchik2016-06-301-15/+11
| | | | |
| * | | | better ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWEDSergei Golubchik2016-06-301-1/+1
| | | | |
| * | | | cleanup: change Item::walk() to take void* not uchar*Sergei Golubchik2016-06-301-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | and remove all related casts to uchar* also remove a couple of unused methods
| * | | | restore ER_VIEW_CHECK_FAILED to be different from ER_CONSTRAINT_FAILEDSergei Golubchik2016-06-301-27/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | collaterals: * use %`s, not '%s' * use correct SQLSTATE codes for these two errors
| * | | | Use default character set for expressionsMichael Widenius2016-06-301-9/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
| * | | | More tests for "MDEV-7563 Support CHECK constraint".Alexander Barkov2016-06-301-4/+1
| | | | | | | | | | | | | | | | | | | | Testing non-ASCII string literals.
| * | | | various cleanupsMichael Widenius2016-06-301-89/+72
| | | | |
| * | | | MDEV-7563 Support CHECK constraint as in (or close to) SQL StandardMichael Widenius2016-06-301-228/+615
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | MDEV-10138 Support for decimals up to 38 digitsMonty2016-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | MDEV-5535: Cannot reopen temporary tableNirbhay Choubey2016-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | Some trivial changes.Nirbhay Choubey2016-06-101-1/+2
| | | | |
| * | | | Code cleanupsSergey Vojtovich2016-06-101-13/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
| * | | | MDEV-3944: Allow derived tables in VIEWSOleksandr Byelkin2016-05-281-2/+6
| | |_|/ | |/| |
| * | | Merge branch '10.2' into bb-10.2-mdev9543Sergei Petrunia2016-03-281-4/+27
| |\ \ \
| * | | | This is the consolidated patch for mdev-8646:bb-10.2-mdev8646Igor Babaev2016-02-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Re-factor the code for post-join operations". The patch mainly contains the code ported from mysql-5.6 and created for two essential architectural changes: 1. WL#5558: Resolve ORDER BY execution method at the optimization stage 2. WL#6071: Inline tmp tables into the nested loops algorithm The first task was implemented for mysql-5.6 by Ole John Aske. It allows to make all decisions on ORDER BY operation at the optimization stage. The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB nodes for post-join operations that require temporary tables. It allows to execute these operations within the nested loops algorithm that used to be used before this task only for join queries. Besides these task moves all planning on the execution of these operations from the execution phase to the optimization phase. Some other re-factoring changes of mysql-5.6 were pulled in, mainly because it was easier to pull them in than roll them back. In particular all changes concerning Ref_ptr_array were incorporated. The port required some changes in the MariaDB code that concerned the functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey Petrunia.
* | | | | Fixed the following problem:Igor Babaev2016-07-261-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Temporary tables created for recursive CTE were instantiated at the prepare phase. As a result these temporary tables missed indexes for look-ups and optimizer could not use them.
* | | | | Fixed numerous problems for mutually recursive CTE.Igor Babaev2016-06-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually mutually recursive CTE were not functional. Now the code for mutually recursive CTE looks like functional, but still needs re-writing. Added many new test cases for mutually recursive CTE.
* | | | | Main patch for mdev-9864Galina Shalygina2016-05-091-5/+74
| | | | |
* | | | | Merge branch '10.2' into 10.2-mdev9864Galina Shalygina2016-05-081-3/+3
| |/ / / |/| | |
* | | | Manual merge of branch 'bb-10.2-mdev8789' into 10.2Igor Babaev2016-03-211-1/+8
|\ \ \ \
| * | | | MDEV-8789 Implement non-recursive common table expressionsGalina Shalygina2015-12-181-1/+8
| | | | | | | | | | | | | | | | | | | | Initial implementation
* | | | | MDEV-9488 - Table cache cleanupsSergey Vojtovich2016-02-261-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | tdc_assign_new_table_id() does not relate to table cache, move it out of table_cache.cc.
* | | | | Cache check_table_binlog_row_based and mark_trx_read_writeMonty2016-02-161-2/+7
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits: - Speeds up insert,write and delete by avoiding 1-2 function calls per write/update/delete. - Avoiding calling write_locked_table_maps() if not needed. - The inlined code is much smaller than before - Updating of table->s->cached_row_logging_check moved to when table is opened - Moved some bool values together in handler class to get better alignment.
* | | | Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2015-12-291-16/+1
|\ \ \ \ | |/ / / |/| / / | |/ /
| * | Merge branch '10.0' into 10.1Sergei Golubchik2015-12-211-16/+1
| |\ \ | | |/