-->

sqlite3 c/c++, get the table names involved int an

2019-02-27 19:02发布

问题:

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...

回答1:

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