Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite given a statement it is possible to know what table will be touched [duplicate]

Tags:

c++

c

sqlite

I am using sqlite in a C++ project and I would like to be able to get the table names involved in a query.

Ex:

SELECT * FROM Employee

should return Employee

Now I use successfully qlite3_column_table_name (doc) for this kind of queries but for aggregate queries, the function returns null as the result does not belong to a table directly.

ex:

SELECT SUM(salary) AS total FROM Employee

Surely, when sqlite compiles the statement, the "Employee" keyword is recognised as a table. Do you know aby way to have access to this? I tried to step through the code of the parser without success...

like image 452
overlii Avatar asked Nov 19 '22 09:11

overlii


1 Answers

An authorizer callback allows you to detect which tables are actually accessed by a query.

like image 129
CL. Avatar answered Dec 23 '22 02:12

CL.