You start by presenting us with a stand-alone script that we can run to see your question. See you are getting free help, you really should be striving to make it easy for people to help you. We don't have a script from you, so I made one up. I'm using:
CREATE TABLE employee(eid INTEGER PRIMARY KEY, name TEXT); CREATE TABLE location(lid INTEGER PRIMARY KEY, name TEXT); CREATE TABLE company(cid INTEGER PRIMARY KEY, name TEXT); .explain EXPLAIN SELECT * FROM employee, company, location WHERE location.name=company.name AND location.name=employee.name; Be sure to indent your code clearly so that people and understand it more easily. For the trunk of SQLite, the first few instructions are: addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 44 0 00 Start at 44 1 OpenRead 0 2 0 2 00 root=2 iDb=0; employee 2 OpenRead 2 3 0 2 00 root=3 iDb=0; location 3 OpenRead 1 4 0 2 00 root=4 iDb=0; company 4 Explain 0 0 0 SCAN TABLE employee 00 5 Rewind 0 42 0 00 6 Once 0 14 0 00 7 OpenAutoindex 3 2 0 k(2,nil,nil) 00 nColumn=2; for location 8 Rewind 2 14 0 00 9 Column 2 1 2 00 r[2]= location.name 10 Rowid 2 3 0 00 r[3]=rowid 11 MakeRecord 2 2 1 00 r[1]=mkrec(r[2..3]) 12 IdxInsert 3 1 0 10 key=r[1] 13 Next 2 9 0 03 I think you are interested in knowing where the P3 operand (the output register number) for instruction 9 comes from. (Note that the program shown above might be slightly different in whatever version of SQLite you are running.) The way you find this out is to first compile sqlite3 using -DSQLITE_DEBUG. Then add the statement: PRAGMA vdbe_addoptrace=ON; Right before the "EXPLAIN" in the script. That pragma (only available when SQLite is compiled with -DSQLITE_DEBUG) causes SQLite to print a message on the screen every time it generates a new opcode. Next, run sqlite3 in a debugger and set a breakpoint on the "test_addop_breakpoint" procedure. (This is a dummy procedure created specifically to give you a place to set a breakpoint.) Then run your script. Continue past the first few breakpoints until the "Column" instruction is emitted. Now you can examine the call stack to figure out exactly how that opcode was generated. It appears that the output register 2 comes from here: http://www.sqlite.org/src/artifact/fae81cc2eb14b?ln=812-813 Specifically the last parameter. regBase+j. You can continue to follow the stack to figure out where regBase was computed. There are comments on each function that try to explain what that particular function is doing. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users