Greetings,
Hope you are safe and doing great,
This post describes the things I've done in my third week [ 18-24 May ] of Community Bonding Period under the mentor-ship of Sergei Golubchik and Oleksandr Byelkin for GSoC-20. The tasks taken up for this week was to study and analyze:
INSERT.... RETURNING:
• TableList consists of 1 table instance to use, where each instance is a structure consisting of db argument, table name argument, alias argument and lock type argument. Referenced this from the table.h file.
• In sql_parse.cc under case SQLCOM_INSERT:
we do a DBUG_ASSERT where first_table == all_table && first_table!=0 // we check if only 1 table is used and the table used is already created.
• if lex-> has_returning() we increment the system status var by 1 and perform analyze.. insert.. returning.
• we compute result by mysql_insert function by passing the following arguments.
- Thread Handler thd
- all table instances
- list of all the fields used
- the values we want to insert
- the list of update feilds
- and update value list
- duplicate flag
- ignore
- result of select
• if Inserting fails due to some reason we equate result to send_explain(thd)
• we also update the MYSQL_INSERT_DONE with result of insert and the the row count.
INSERT.. SELECT.. RETURNING:
• We fix the lock on first table.
• lock other tables until command is written to the binary log.
• the procedure is same as discussed earlier with respect to insert.... returning.
• To switch to the second table we traverse from first_table to (->) next_local and we compute select result with the help of select insert function.
• we can now unlock the tables and we also need to check if something changed after unlocking, of that happens we should invalidate the table from the query cache using query_cache_invalidate3 function.
• Manual cleaning of select result obtained from select insert must be done.
Regards,
Mohammed Hammaad Mateen