Report for week 5:

Hello!

This week I was able to make INSERT...SELECT...RETURNING return the listed fields from the INSERT table. From the parsing stage in sql_parse.cc, the context and the first table gets masked , so I stored the previous values in another variable just before they are masked and swapped it before and after calling setup_fields() and setup_wild in select_insert :: prepare(). This makes the items and expressions in returning_list point to insert table before the above functions are called, and then swapping it back for the rest of the prepare() function. Here is the link to test cases and code:
Test and result:
https://github.com/MariaDB/server/commit/0792ba33a1b50e7beab3b7e05d36df29e7869fd1
Code:
https://github.com/MariaDB/server/commit/4d1d37f2bdca398ff3ace804cfb3b5a940168422

I also tested my code for some complex queries like subquery in RETURNING and checked if it outputs error message when invalid expressions are used. It was working correctly. Here is the link for the same:
Error message:
https://github.com/MariaDB/server/commit/9ffe813eb82dc0125def187e07dbd5168b46cf95
Subqueries:
https://github.com/MariaDB/server/commit/2363cb3993d86685ff1402cfa7ee050dd74cb7ba

I was also thinking about other ways to get the items and expressions in returning_list, this is one of the ways in which it could be implemented. Here is
the link to GDoc:
https://docs.google.com/document/d/1TZdlL_V9MEbPTuXNwpzR0t9ciNeV25AeUIvSRXHXXo8/edit?usp=sharing

I understand this is too big a change for the grammar and I am trying to find alternate solution.
I also changed the variable names and made them more descriptive.

Regards,
Rucha Deodhar