Re: [sqlite] A problem with 'pragma table_info(...)'
On Wed, Sep 21, 2016 at 9:57 AM, Stepan Zakharov wrote: > We are using VFS however, may be that can be ill-implemented somehow so it > makes PRAGMA not to work.. It can. And I think you're the third person on the mailing list to fall into that trap. From an earlier mail ("http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/2015-April/059108.html";) > could you check if it's your > vfs that is handling those pragmas? The documentation at > "http://sqlite.org/c3ref/c_fcntl_busyhandler.html#sqlitefcntlpragma"; > describes that when you run a PRAGMA statement on a database, sqlite > will call the xFileControl method of the vfs file handle (as given in > a sqlite3_io_methods structure) with SQLITE_FCNTL_PRAGMA as the second > parameter. If that method returns SQLITE_OK, then sqlite will assume > the vfs has handled the pragma, and will not handle it itself. This > could cause pragmas to fail silently. -- Ambrus ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
On 09/21/2016 02:57 PM, Stepan Zakharov wrote: Nothing & Nothing. Just returns SQLITE_OK, doesn't enter into Callback. To avoid any doubts, when I change query to "select sql from sqlite_master where (type='table' AND name='TABLE_NAME');" I do enter into Callback and have a result. Perhaps, PRAGMA is somehow broken or disabled in my sqlite. But once again, it doesn't work nor on precompiled official binaries, neither on my own very straight-forward (without any special -D flags) compilation of amalgamation. We are using VFS however, may be that can be ill-implemented somehow so it makes PRAGMA not to work.. What does your xFileControl() method return when it is passed SQLITE_FCNTL_PRAGMA? It should usually return SQLITE_NOTFOUND (unless it is actually a pragma you want your VFS to intercept - bypassing the SQLite core). If it returns SQLITE_OK, I think you will get the behaviour you describe. Some docs here (search the page for "PRAGMA"): https://www.sqlite.org/huawei-th3/uv/th3-392.c?mimetype=application/octet-stream Dan. I don't know what to think anymore. It looks like will have to parse the SQL Create statement, eventually.. Date: Wed, 21 Sep 2016 13:47:41 +0700 From: danielk1...@gmail.com To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] A problem with 'pragma table_info(...)' On 09/21/2016 01:44 PM, Stepan Zakharov wrote: Yes, of course it looks different.pragma table_info(TABLENAME);Where TABLENAME is my table name.I've tried it with single-quotes as well: pragma table_info('TABLENAME');No results in any case.And no errors. Returns SQLITE_OK.A very strange behaviour. Does "PRAGMA table_info('sqlite_master');" return any results? What does "PRAGMA compile_options;" say? Dan. To: sqlite-users@mailinglists.sqlite.org From: clem...@ladisch.de Date: Wed, 21 Sep 2016 08:27:32 +0200 Subject: Re: [sqlite] A problem with 'pragma table_info(...)' Stepan Zakharov wrote: it does not return any results That is because the table name is not correctly quoted: sqlite> pragma table_info(...); Error: near ".": syntax error Or does your statement look different? Regards, Clemens ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
Stepan Zakharov wrote: > Nothing & Nothing. Just returns SQLITE_OK, doesn't enter into Callback. This program: #include #include static int callback(void *p, int cols, char **data, char **names) { printf("%s %s %s %s %s %s\n", data[0], data[1], data[2], data[3], data[4], data[5]); return 0; } int main() { sqlite3 *db; sqlite3_open(":memory:", &db); sqlite3_exec(db, "create table TABLE_NAME(hello world)", NULL, NULL, NULL); sqlite3_exec(db, "pragma table_info(TABLE_NAME)", callback, NULL, NULL); } outputs: 0 hello world 0 (null) 0 Regards, Clemens ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
Nothing & Nothing. Just returns SQLITE_OK, doesn't enter into Callback. To avoid any doubts, when I change query to "select sql from sqlite_master where (type='table' AND name='TABLE_NAME');" I do enter into Callback and have a result. Perhaps, PRAGMA is somehow broken or disabled in my sqlite. But once again, it doesn't work nor on precompiled official binaries, neither on my own very straight-forward (without any special -D flags) compilation of amalgamation. We are using VFS however, may be that can be ill-implemented somehow so it makes PRAGMA not to work.. I don't know what to think anymore. It looks like will have to parse the SQL Create statement, eventually.. > Date: Wed, 21 Sep 2016 13:47:41 +0700 > From: danielk1...@gmail.com > To: sqlite-users@mailinglists.sqlite.org > Subject: Re: [sqlite] A problem with 'pragma table_info(...)' > > On 09/21/2016 01:44 PM, Stepan Zakharov wrote: > > Yes, of course it looks different.pragma table_info(TABLENAME);Where > > TABLENAME is my table name.I've tried it with single-quotes as well: pragma > > table_info('TABLENAME');No results in any case.And no errors. Returns > > SQLITE_OK.A very strange behaviour. > > Does "PRAGMA table_info('sqlite_master');" return any results? > > What does "PRAGMA compile_options;" say? > > Dan. > > > > > > > >> To: sqlite-users@mailinglists.sqlite.org > >> From: clem...@ladisch.de > >> Date: Wed, 21 Sep 2016 08:27:32 +0200 > >> Subject: Re: [sqlite] A problem with 'pragma table_info(...)' > >> > >> Stepan Zakharov wrote: > >>> it does not return any results > >> That is because the table name is not correctly quoted: > >> > >>sqlite> pragma table_info(...); > >>Error: near ".": syntax error > >> > >> Or does your statement look different? > >> > >> > >> Regards, > >> Clemens > >> ___ > >> sqlite-users mailing list > >> sqlite-users@mailinglists.sqlite.org > >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > > ___ > > sqlite-users mailing list > > sqlite-users@mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
On 09/21/2016 01:44 PM, Stepan Zakharov wrote: Yes, of course it looks different.pragma table_info(TABLENAME);Where TABLENAME is my table name.I've tried it with single-quotes as well: pragma table_info('TABLENAME');No results in any case.And no errors. Returns SQLITE_OK.A very strange behaviour. Does "PRAGMA table_info('sqlite_master');" return any results? What does "PRAGMA compile_options;" say? Dan. To: sqlite-users@mailinglists.sqlite.org From: clem...@ladisch.de Date: Wed, 21 Sep 2016 08:27:32 +0200 Subject: Re: [sqlite] A problem with 'pragma table_info(...)' Stepan Zakharov wrote: it does not return any results That is because the table name is not correctly quoted: sqlite> pragma table_info(...); Error: near ".": syntax error Or does your statement look different? Regards, Clemens ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
Yes, of course it looks different.pragma table_info(TABLENAME);Where TABLENAME is my table name.I've tried it with single-quotes as well: pragma table_info('TABLENAME');No results in any case.And no errors. Returns SQLITE_OK.A very strange behaviour. > To: sqlite-users@mailinglists.sqlite.org > From: clem...@ladisch.de > Date: Wed, 21 Sep 2016 08:27:32 +0200 > Subject: Re: [sqlite] A problem with 'pragma table_info(...)' > > Stepan Zakharov wrote: > > it does not return any results > > That is because the table name is not correctly quoted: > > sqlite> pragma table_info(...); > Error: near ".": syntax error > > Or does your statement look different? > > > Regards, > Clemens > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] A problem with 'pragma table_info(...)'
Stepan Zakharov wrote: > it does not return any results That is because the table name is not correctly quoted: sqlite> pragma table_info(...); Error: near ".": syntax error Or does your statement look different? Regards, Clemens ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users