1

I'm try get name of tables in sql expression using sqlite3 API.

Example:

select * form table1, table2, table3;

Sqlite3 API only return data of statment and only have information of name of columns with command sqlite3_column_name but not have information of tables.

I need extract this:

table1
table2
table3
Jones
  • 1,480
  • 19
  • 34
  • To find this using gxxgle it took me 5 seconds: http://stackoverflow.com/q/82875/694576 – alk Oct 09 '14 at 16:31
  • @alk I need to extract it from the sql expression and not from schema database. – Jones Oct 09 '14 at 16:33
  • Doesn't your code build the expression? Are you looking for an SQL parser though? – alk Oct 09 '14 at 16:41
  • @alk No. The expression is write by user. Yes this is what I want but believed the `Sqlite API` provide a way to return this information. – Jones Oct 09 '14 at 19:49

1 Answers1

1

To get the table name of a returned column, call sqlite3_column_table_name. (This works only for actual table columns, not for expressions.)

To detect which tables are actually read by a statement, install an authorizer callback.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Xcode compilation return error `"_sqlite3_column_table_name", referenced from: ... ld: symbol(s) not found for architecture x86_64`. This function included in OSX? Other functions `sqlite3_column_origin_name` and `sqlite3_column_database_name` appear the same error. – Jones Oct 09 '14 at 19:21
  • See the documentation: "These APIs are only available if the library was compiled with the SQLITE_ENABLE_COLUMN_METADATA C-preprocessor symbol." – CL. Oct 10 '14 at 07:11
  • I need include `sqlite-amalgamation` in my project to see these functions. – Jones Dec 26 '14 at 17:31