Why sqlite3_get_table interface in SQLite C interface is not recommended

sqlite3_get_table defined as follows:

 int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ ); 

As stated in the document, it can get a convenient result table and is implemented as a wrapper around sqlite3_exec ().

But now this is not recommended:

This is an outdated interface that is retained for backward compatibility. Using this interface is not recommended.

But if I use sqlite3_exec , I need to write an additional callback function. This is harder.

So my question is, what is the main problem of this interface? Why should it be obsolete?

See http://www.sqlite.org/c3ref/free_table.html for more details.

+4
source share
1 answer

The problems with sqlite3_get_table are that all values ​​are converted to strings, and this memory should be allocated for all result records.

It is supposed to use the sqlite3_prepare_v2 / sqlite3_step / sqlite3_column_xxx / sqlite3_finalize functions.

+4
source

All Articles