On Thu, Sep 18, 2014 at 10:10 AM, Prakash Premkumar <prakash.p...@gmail.com> wrote:
> Which function in the sqlite generates the Vdbe program for the given > query? > > Let's take an example of the join of two tables. Table A has n columns and > Table B has m columns, and the result has n+m columns. > > During the execution of the Vdbe program the values from these columns get > copied to the Mem struct randomly (when OP_Column opcode is formed) and > finally when the OP_ResultRow is executed, the Mem's are rearranged so that > the columns of each table are contiguous. > > How does sqlite know in which Mem the value of a column is stored and how > does it finally rearrange the Mems contiguously? > Can you point me to the portion of the source code which makes this > decision? > > Can you kindly explain me the concept? > SQLite is a compiler. It transforms a high-level language (SQL) into machine code (or in this case VDBE code, which is very similar to machine code). In this sense, SQLite is similar to GCC. GCC translates C code into x86 assembly language. SQLite translates SQL into VDBE assembly language. The source and target languages are different, but the fundamental techniques are the same. When you ask "how does sqlite know which Mem the value of a column is stored?" that is the same as asking "how does gcc know which processor registers the value of a variable is stored?". I recommend that you first study up on compiler construction. After you understand how compilers work, SQLite will likely make a lot more sense to you. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users