本文介绍了sqlite3 c/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.

例如:

SELECT * FROM Employee

应返回 Employee

现在,我已经成功地将 qlite3_column_table_name ( doc )用于此类型,但对于汇总查询,该函数返回null,因为结果不直接属于表.

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.

例如:

SELECT SUM(salary) AS total FROM Employee

当然,当sqlite编译该语句时,"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...

推荐答案

授权者回调使您能够检测查询实际访问了哪些表.

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

这篇关于sqlite3 c/c ++,获取涉及聚合查询的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:02