summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from ↵Vladislav Vaintroub2018-02-061-11/+10
| | | | | | | | | | | '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.
* Mdev-15085 Invisible Column Non-constant Default value results...Sachin Setiya2018-02-021-0/+1
| | | | | | | | | | | | | | | Problem:- If we create table field with dynamic default value then that field always gets NULL value. Analyze:- This is because in fill_record we simple continue at Invisible column because we though that share->default_values(default value is always copied into table->record[0] before insert) will have a default value for them(which is true for constant defaults , but not for dynamic defaults). Solution:- We simple set all_fields_have_value to null , and this will make call to update_default_fields (in the case of dynamic default), And default expr will be evaluted and value will be set in field.
* Changed database, tablename and alias to be LEX_CSTRINGMonty2018-01-301-121/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 "")
* MDEV-11084 Select statement with partition selection against MyISAM table ↵Alexey Botchkov2018-01-291-3/+20
| | | | | | | | opens all partitions. Now we don't open partitions if it was explicitly cpecified. ha_partition::m_opened_partition bitmap added to track partitions that were actually opened.
* MDEV-14786 Server crashes in Item_cond::transform on 2nd execution of SP ↵Sergei Golubchik2018-01-171-4/+0
| | | | | | | | | querying from a view instead of skipping invalid items in setup_conds(), don't pass them into a JOIN at all (test case in versioning.select2)
* cleanup: remove redundant checkSergei Golubchik2018-01-131-5/+2
| | | | | | it's already checked before the update loop (see check_fields()), and this condition cannot suddenly become false in the middle of the statement
* remove dead VERS_EXPERIMENTAL codeSergei Golubchik2018-01-131-35/+1
| | | | | | | changed to use DBUG keywords instead, so that the code is compiled and tested added tests.
* System Versioning 1.0 pre8Aleksey Midenkov2018-01-101-16/+141
|\ | | | | | | Merge branch '10.3' into trunk
| * Fix warningsVladislav Vaintroub2018-01-071-1/+1
| |
| * Fixed that sequences and default works with ps-protocolMonty2018-01-031-7/+36
| | | | | | | | | | The bug was that for prepared statments the new TABLE_LIST was allocated in the wrong arena.
| * MDEV 13679 Enabled sequences to be used in DEFAULTMonty2017-12-221-15/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Other changes done to get this to work: - Added 'internal_tables' to TABLE object to list which sequence tables is needed to use the table. - Mark any expression using DEFAULT() with LEX->default_used. This is needed when deciding if we should open internal sequence tables when a table is opened (we don't need to open sequence tables if the main table is only used with SELECT). - Create_and_open_temporary_table() can now also open all internal sequence tables. - Added option MYSQL_LOCK_USE_MALLOC to mysql_lock_tables() to force memory allocation to be used with malloc instead of memroot. - Added flag to MYSQL_LOCK to remember if allocation was done with malloc or memroot (makes code simpler and safer). - init_one_table_for_prelocking() now takes argument for what lock to use instead of it's a routine or something else. - Renamed prelocking placeholders to make them more understandable as they are now used in more code. - Changed test in check_lock_and_start_stmt() if found table has correct locks. The old test didn't work for tables that has lock TL_WRITE_ALLOW_WRITE, which is what sequence tables are using. - Added VCOL_NOT_VIRTUAL option to ensure that sequence functions can't be used with virtual columns - More sequence tests
* | Daemon: debug_system_versioning_show, debug_system_versioning_forceAleksey Midenkov2018-01-101-1/+36
| |
* | SQL: derived, hiding, error messagesSergei Golubchik2018-01-091-46/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many related changes. Note that AS OF condition must always be pushed down to physical tables, it cannot be applied to a derived or a view. Thus: * no versioning for internal temporary tables, they can never store historical data. * remove special versioning code from mysql_derived_prepare and remove ER_VERS_DERIVED_PROHIBITED - derived can have no historical data and cannot be prohibited for system versioning related reasons. * do not expand select list for derived/views with sys vers fields, derived/views can never have historical data. * remove special invisiblity rules for sys vers fields, they are no longer needed after the previous change * remove system_versioning_hide, it lost the meaning after the previous change. * remove ER_VERS_SYSTEM_TIME_CLASH, it's no "clash", the inner AS OF clause always wins. * non-versioned fields in a historical query reword the warning text, downgrade to note, don't replace values with NULLs
* | MDEV-14764 Confusing error message: Table `t1` must have at least one ↵Sergei Golubchik2018-01-091-1/+1
| | | | | | | | | | | | temporal column compiler warning (mix of bool and enum in ?:)
* | MDEV-14792 INSERT without column list into table with explicit versioning ↵Aleksey Midenkov2018-01-011-24/+17
| | | | | | | | columns produces bad data
* | fix CREATE ... SELECTSergei Golubchik2017-12-291-0/+7
| | | | | | | | | | move table->vers_update_fields() where it belongs - into fill_record(), right after table_arg->update_virtual_fields()
* | SQL: removed VERS_HIDDEN_FLAG [closes #409]Aleksey Midenkov2017-12-191-38/+40
| |
* | Timestamp-based versioning for InnoDB [closes #209]Aleksey Midenkov2017-12-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Removed integer_fields check * Reworked Vers_parse_info::check_sys_fields() * Misc renames * versioned as vers_sys_type_t * Removed versioned_by_sql(), versioned_by_engine() versioned() works as before; versioned(VERS_TIMESTAMP) is versioned_by_sql(); versioned(VERS_TRX_ID) is versioned_by_engine(). * create_tmp_table() fix * Foreign constraints for timestamp-based * Range auto-specifier fix * SQL: 1-row partition rotation fix [fixes #260] * Fix 'drop system versioning, algorithm=inplace'
* | System Versioning 1.0 pre5 [closes #407]Aleksey Midenkov2017-12-151-6/+20
|\ \ | |/ | | | | | | | | | | | | | | 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?).
| * Add tests for system and completely invisible columnsSergei Golubchik2017-12-151-1/+2
| | | | | | | | debug only
| * MDEV-10177 Invisible Columns and Invisible IndexSachin Setiya2017-12-151-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | MDEV-14652 NATURAL JOIN crash in mark_common_columns() [fixes #405]Aleksey Midenkov2017-12-141-9/+0
| | | | | | | | SQL: reverted NATURAL JOIN fix #161 (deprecated by #383)
* | MDEV-14631 Assertion `!sys_trx_start && !sys_trx_end' failed in crete_tmp_tableEugene Kosov2017-12-121-4/+3
| | | | | | | | | | | | | | SQL: remove unneeded assertion SQL: disallow set sys_trx fields in INSERT ... SELECT Fixes by @midenok.
* | SQL: create..select revisited [closes #370]Aleksey Midenkov2017-12-121-5/+4
| |
* | System Versioning 1.0 pre3Aleksey Midenkov2017-12-111-82/+30
|\ \ | |/ | | | | Merge branch '10.3' into trunk
| * CleanupsMonty2017-12-081-78/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove not used thd_rpl_is_parallel() - Remove not used mysql_notify_thread_having_shared_lock() - Remove not needed LOCK_thread_count from MYSQL_BIN_LOG::reset_logs() - LOCK_thread_count is not protecting against rollback, so this code and comment is not needed - Remove mutex_locks in slave.cc that are not needed. Added THD::assert_not_linked() to ensure that it was safe to remove - Fixed not repeatable test load_data_stmt_view - Updated binlog_killed to test removal of mutex (thanks to Andrei Elkin for test) - More code comments
| * MDEV 7701 extra() calls for VP engineMonty2017-12-031-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added Spider patches: 003_mariadb-10.0.15.vp.diff 060_mariadb-10.2.0.partition_reset_top_table_fields.diff - Support HA_EXTRA_ADD_CHILDREN_LIST,HA_EXTRA_ATTACH_CHILDREN, HA_EXTRA_IS_ATTACHED_CHILDREN and HA_EXTRA_DETACH_CHILDREN in partition handler for handlers that has HA_CAN_MULTISTEPL_MERGE flag - Added HA_CAN_MULTISTEPL_MERGE to MERGE handler. - Added handler::get_child_handlers() - Change m_num_lock to contain total number of locks. This was needed as we now adjust number of locks when extra(HA_EXTRA_ATTACH_CHILDREN) is called.
* | SQL: DEFAULT value for system fields [closes #376]Aleksey Midenkov2017-12-101-0/+2
| |
* | SQL: insert delayed fix [#365 bug 3]Aleksey Midenkov2017-11-291-0/+1
| | | | | | | | Affected tests (forced mode): rpl.rpl_timezone
* | SQL: fill_record() field-value inconsistency fix [#365 bug 2]Aleksey Midenkov2017-11-291-8/+7
| | | | | | | | Affected tests (forced mode): binlog_encryption.encrypted_slave
* | SQL: switch_defaults_to_nullable_trigger_fields() fix [#355]Aleksey Midenkov2017-11-271-1/+1
| |
* | System Versioning 1.0pre2Aleksey Midenkov2017-11-231-1/+2
|\ \ | |/ | | | | Merge branch '10.3' into trunk
| * Handle failures from mallocMichael Widenius2017-11-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most "new" failures fixed in the following files: - sql_select.cc - item.cc - item_func.cc - opt_subselect.cc Other things: - Allocate udf_handler strings in mem_root - Required changes in sql_string.h - Add mem_root as argument to some new [] calls - Mark udf_handler strings as thread specific - Removed some comment blocks with code
* | System Versioning pre0.12Aleksey Midenkov2017-11-071-7/+102
|\ \ | |/ |/| | | Merge remote-tracking branch 'origin/archive/2017-10-17' into 10.3
| * SQL: not a VTMD table warning [related to #199]Aleksey Midenkov2017-10-031-4/+25
| |
| * SQL, Parser: system_time logic and syntax fixes [closes #237]Aleksey Midenkov2017-08-081-3/+1
| |
| * SQL: compare TRX_ID fields against timestamps [closes #231]Aleksey Midenkov2017-08-031-0/+1
| |
| * SQL: No implicit versioning when created from SELECT [closes #219]Aleksey Midenkov2017-07-031-9/+18
| |
| * Style: warning fixAleksey Midenkov2017-05-051-1/+1
| |
| * SQL: derived tables improvements [closes #185]Aleksey Midenkov2017-05-051-0/+1
| |
| * SQL: CREATE VIEW and misc improvements [fixes #183]Aleksey Midenkov2017-05-051-3/+2
| |
| * SQL: vers_current_time refactoring [closes #117]Aleksey Midenkov2017-05-051-0/+1
| | | | | | | | | | | | * session sysvars; * moved value parsing to set variable phase; * renamed 'temporal_current_timestamp' to 'vers_current_time'.
| * SQL, IB: Copy history via CREATE .. SELECT [closes #157, #152]Aleksey Midenkov2017-05-051-2/+19
| |
| * SQL: VIEW NATURAL JOIN TABLE [fixes #161]kevg2017-05-051-0/+9
| |
| * SQL: NATURAL LEFT JOIN for versioned tables [fixes #156]kevg2017-05-051-4/+7
| |
| * SQL: INNER JOIN USING with versioned tables [fixes #147]kevg2017-05-051-1/+1
| |
| * SQL: incorrect check on specific JOIN query [fixes #145]kevg2017-05-051-2/+3
| |
| * SQL, Tests: FOR SYSTEM_TIME for VIEWs [closes #98]kevg2017-05-051-0/+13
| |
| * SQL: default NULL for sys fields + misc fixesAleksey Midenkov2017-05-051-4/+4
| | | | | | | | | | | | | | | | | | * sys fields are NULL by default (with exceptions, see comment about NOT_NULL_FLAG in #77); * error codes renamed, messages cleared out; * SHOW CREATE TABLE fixed; * set_max() fix; * redundant flag setters/getters removed; * flags are set in sql_yacc.yy, redundant copy_info_about_generated_fields() eliminated.
| * Comment: reminder for merging HIDDEN feature (closes #38)Aleksey Midenkov2017-05-051-0/+1
| |