Re: [sqlite] Check if the new table has been created

2018-07-05 Thread Igor Korot
Hi, Simon, On Thu, Jul 5, 2018 at 11:45 AM, Simon Slavin wrote: > On 5 Jul 2018, at 4:51pm, Igor Korot wrote: > >> Is there a way to get which command was executed? >> Or which table was added/changed/dropped? > > There is no reason for SQLite to record the information you want. If a >

Re: [sqlite] Check if the new table has been created

2018-07-05 Thread Simon Slavin
On 5 Jul 2018, at 4:51pm, Igor Korot wrote: > Is there a way to get which command was executed? > Or which table was added/changed/dropped? There is no reason for SQLite to record the information you want. If a connection you have no control over changes your schema you can't do anything

Re: [sqlite] Check if the new table has been created

2018-07-05 Thread Igor Korot
Hi, On Tue, Jun 19, 2018 at 1:56 PM, Richard Hipp wrote: > On 6/19/18, Igor Korot wrote: >> Hi, Wout, >> >> On Tue, Jun 19, 2018 at 1:31 PM, Wout Mertens >> wrote: >>> you can query the table with >>> https://www.sqlite.org/pragma.html#pragma_table_info >> >> Let me give you a scenario: >> >>

Re: [sqlite] Check if the new table has been created

2018-06-21 Thread Igor Korot
Hi, again, This page: https://www.sqlite.org/threadsafe.html, says that the default mode for SQLite is "Serialized". It is also said that in this mode it is safe to use SQLite in multiple threads. I am planning to do the polling in the secondary thread and SQLite was compiled with the default

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Igor Korot
David, On Wed, Jun 20, 2018 at 9:12 PM, David Empson wrote: > Apart from the SQLITE_OK vs SQLITE_ROW/DONE check on the sqlite3_step() call > mentioned already, you also have the third parameter to sqlite_prepare_v2() > wrong: nByte = NULL will translate to nByte = 0 which is documented as “no

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread David Empson
Apart from the SQLITE_OK vs SQLITE_ROW/DONE check on the sqlite3_step() call mentioned already, you also have the third parameter to sqlite_prepare_v2() wrong: nByte = NULL will translate to nByte = 0 which is documented as “no prepared statement is generated”. Therefore stmt is not valid and

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread David Burgess
; On Thu, Jun 21, 2018 at 12:03 PM, Igor Korot wrote: > Richard, > > On Wed, Jun 20, 2018 at 8:17 PM, Richard Hipp wrote: >> On 6/20/18, Igor Korot wrote: >>> if( ( res = sqlite3_step( stmt ) ) == SQLITE_OK ) >> >> sqlite3_step() returns SQLITE_ROW when it has data, not

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Igor Korot
Richard, On Wed, Jun 20, 2018 at 8:17 PM, Richard Hipp wrote: > On 6/20/18, Igor Korot wrote: >> if( ( res = sqlite3_step( stmt ) ) == SQLITE_OK ) > > sqlite3_step() returns SQLITE_ROW when it has data, not SQLITE_OK. But SQLITE_ROW value is not 21 - its 101. Thank

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Richard Hipp
On 6/20/18, Igor Korot wrote: > if( ( res = sqlite3_step( stmt ) ) == SQLITE_OK ) sqlite3_step() returns SQLITE_ROW when it has data, not SQLITE_OK. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Igor Korot
Hi, guys, I put in this code: if( sqlite3_prepare_v2( m_db, "PRAGMA schema_version", NULL, , NULL ) == SQLITE_OK ) { if( ( res = sqlite3_step( stmt ) ) == SQLITE_OK ) { m_schema =

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Simon Slavin
On 20 Jun 2018, at 12:29pm, Simon Slavin wrote: > On 20 Jun 2018, at 7:24am, Peter Johnson wrote: > >> Is it possible to create a trigger on sqlite_master which calls a >> user-defined function AFTER INSERT? > > No. sqlite_master is modified using internal methods, not using an INSERT >

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Simon Slavin
On 20 Jun 2018, at 7:24am, Peter Johnson wrote: > Is it possible to create a trigger on sqlite_master which calls a > user-defined function AFTER INSERT? No. sqlite_master is modified using internal methods, not using an INSERT command. TRIGGERs on it won't work. Simon.

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread R Smith
On 2018/06/20 7:05 AM, Igor Korot wrote: One more question: I presume I should call PRAGMA schema_version right after connection has been made, cache the value returned and then create a secondary thread which will call this query continuously. Am I right? That is up to you, but what you

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread R Smith
--Re-posted from correct address - apologies if this comes through twice-- On 2018/06/20 7:05 AM, Igor Korot wrote: One more question: I presume I should call PRAGMA schema_version right after connection has been made, cache the value returned and then create a secondary thread which will call

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Abroży Nieprzełoży
But that trigger would be executed in a context of a process modifying the database. 2018-06-20 8:24 GMT+02:00, Peter Johnson : > Is it possible to create a trigger on sqlite_master which calls a > user-defined function AFTER INSERT? > > That would avoid having to poll, but it'd still allow the

Re: [sqlite] Check if the new table has been created

2018-06-20 Thread Peter Johnson
Is it possible to create a trigger on sqlite_master which calls a user-defined function AFTER INSERT? That would avoid having to poll, but it'd still allow the application to be notified when the schema changed. On 19 June 2018 at 20:56, Richard Hipp wrote: > On 6/19/18, Igor Korot wrote: > >

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Igor Korot
Hi, guys, On Tue, Jun 19, 2018 at 4:37 PM, Igor Korot wrote: > Hi, Ryan, > > On Tue, Jun 19, 2018 at 3:22 PM, R Smith wrote: >> >> On 2018/06/19 8:26 PM, Igor Korot wrote: >>> >>> Hi, >>> Is there a C API which checks if the new table has been created? >> >> >> We could break this down into a

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Igor Korot
Hi, Ryan, On Tue, Jun 19, 2018 at 3:22 PM, R Smith wrote: > > On 2018/06/19 8:26 PM, Igor Korot wrote: >> >> Hi, >> Is there a C API which checks if the new table has been created? > > > We could break this down into a few separate questions: > > 1 - Is there a C API that can return SQL query

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread R Smith
On 2018/06/19 8:26 PM, Igor Korot wrote: Hi, Is there a C API which checks if the new table has been created? We could break this down into a few separate questions: 1 - Is there a C API that can return SQL query answers? YES there is. 2 - Can I ask this API in SQL if the Schema changed,

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Simon Slavin
On 19 Jun 2018, at 7:56pm, Richard Hipp wrote: > Poll the PRAGMA schema_version value and watch for changes. This is the best way. (I'm hardly likely to argue with DRH, am I ?) However, it's a terrible way to communicate using a database system. If you want two connections to communicate

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Abroży Nieprzełoży
afaik there is no such api. You need to periodically check if something changed. Run pragma schema_version; to get current schema version. If it changes then run select name from sqlite_master where type='table' and name not like 'sqlite_%'; to get the list of table names and compare this

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Richard Hipp
On 6/19/18, Igor Korot wrote: > Hi, Wout, > > On Tue, Jun 19, 2018 at 1:31 PM, Wout Mertens > wrote: >> you can query the table with >> https://www.sqlite.org/pragma.html#pragma_table_info > > Let me give you a scenario: > > 1. My application connects to the database and performs some >

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Igor Korot
Hi, Wout, On Tue, Jun 19, 2018 at 1:31 PM, Wout Mertens wrote: > you can query the table with > https://www.sqlite.org/pragma.html#pragma_table_info Let me give you a scenario: 1. My application connects to the database and performs some operations (using C API). 2. During the application run,

Re: [sqlite] Check if the new table has been created

2018-06-19 Thread Wout Mertens
you can query the table with https://www.sqlite.org/pragma.html#pragma_table_info On Tue, Jun 19, 2018, 8:26 PM Igor Korot wrote: > Hi, > Is there a C API which checks if the new table has been created? > > Thank you. > ___ > sqlite-users mailing

[sqlite] Check if the new table has been created

2018-06-19 Thread Igor Korot
Hi, Is there a C API which checks if the new table has been created? Thank you. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users