MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_insert

Function mysql_insert

sql/sql_insert.cc:742–1546  ·  view source on GitHub ↗

INSERT statement implementation SYNOPSIS mysql_insert() result NULL if the insert is not outputing results via 'RETURNING' clause. @note Like implementations of other DDL/DML in MySQL, this function relies on the caller to close the thread tables. This is done in the end of dispatch_command(). */

Source from the content-addressed store, hash-verified

740 end of dispatch_command().
741*/
742bool mysql_insert(THD *thd, TABLE_LIST *table_list,
743 List<Item> &fields, List<List_item> &values_list,
744 List<Item> &update_fields, List<Item> &update_values,
745 enum_duplicates duplic, bool ignore, select_result *result)
746{
747 bool retval= true;
748 int error, res;
749 bool transactional_table, joins_freed= FALSE;
750 bool changed;
751 const bool was_insert_delayed= (table_list->lock_type == TL_WRITE_DELAYED);
752 bool using_bulk_insert= 0;
753 uint value_count;
754 /* counter of iteration in bulk PS operation*/
755 ulonglong iteration= 0;
756 ulonglong last_affected_rows= 0;
757 ulonglong id;
758 COPY_INFO info;
759 TABLE *table= 0;
760 List_iterator_fast<List_item> its(values_list);
761 List_item *values;
762 Name_resolution_context *context;
763 Name_resolution_context_state ctx_state;
764 SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0;
765 unsigned char *readbuff= NULL;
766 Running_stmt_guard guard(thd, active_dml_stmt::INSERTING_STMT);
767
768 List<List_item> insert_values_cache;
769 bool cache_insert_values= FALSE;
770
771#ifndef EMBEDDED_LIBRARY
772 char *query= thd->query();
773 /*
774 log_on is about delayed inserts only.
775 By default, both logs are enabled (this won't cause problems if the server
776 runs without --log-bin).
777 */
778 bool log_on= (thd->variables.option_bits & OPTION_BIN_LOG);
779#endif
780 thr_lock_type lock_type;
781 Item *unused_conds= 0;
782 DBUG_ENTER("mysql_insert");
783
784 bzero((char*) &info,sizeof(info));
785 create_explain_query(thd->lex, thd->mem_root);
786 /*
787 Upgrade lock type if the requested lock is incompatible with
788 the current connection mode or table operation.
789 */
790 upgrade_lock_type(thd, &table_list->lock_type, duplic);
791
792 /*
793 We can't write-delayed into a table locked with LOCK TABLES:
794 this will lead to a deadlock, since the delayed thread will
795 never be able to get a lock on the table.
796 */
797 if (table_list->lock_type == TL_WRITE_DELAYED && thd->locked_tables_mode &&
798 find_locked_table(thd->open_tables, table_list->db.str,
799 table_list->table_name.str))

Callers 1

sql_parse.ccFile · 0.85

Calls 15

create_explain_queryFunction · 0.85
upgrade_lock_typeFunction · 0.85
find_locked_tableFunction · 0.85
my_errorFunction · 0.85
bulk_parameters_setFunction · 0.85
mysql_prepare_insertFunction · 0.85
net_allocate_new_packetFunction · 0.85
setup_fieldsFunction · 0.85
save_insert_query_planFunction · 0.85
rpl_master_has_bugFunction · 0.85

Tested by

no test coverage detected