Re: [sqlite] Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread David Raymond
Don't forget this point about pragmas: https://www.sqlite.org/pragma.html "No error messages are generated if an unknown pragma is issued. Unknown pragmas are simply ignored. This means if there is a typo in a pragma statement the library does not inform the user of the fact." That way if

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
I think you might be right there, but for my practical purpose I need the result to be invalid. I just wonder if a Halt at row 2 and no further rows produced is good way to determine this. RBS On Wed, Aug 1, 2018 at 3:39 PM, Hick Gunter wrote: > Judging from the following output, I would say

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread David Raymond
Use the CLI code as an example and see how they do it? -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Bart Smissaert Sent: Wednesday, August 01, 2018 11:56 AM To: SQLite mailing list Subject: Re: [sqlite] [EXTERNAL] Re: Is

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Hick Gunter
Judging from the following output, I would say it is data producing, but returns no rows for no table or a table that has no indexes. Just because a given select statement returns no matching rows does not make it invalid asql> create temp table test (i integer, t text); asql> create index

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread R Smith
On 2018/08/01 5:29 PM, Charles Leifer wrote: You can simply use: PRAGMA table_info('my_table') To get a list of columns, which you can check against and then conditionally add your column. Aye, but during a script in SQL-only you don't have that luxury. One could also use a similar pragma

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 14:34, Simon White wrote: > I would like to suggest the addition of the "If not exists" to the Add > Column feature of SQLite.  There are quite common situations where > ensuring a column exists is important so that an update to remote > devices will not fail but it is not

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread R Smith
On 2018/08/01 4:50 PM, Bart Smissaert wrote: I think you might be right there, but for my practical purpose I need the result to be invalid. I just wonder if a Halt at row 2 and no further rows produced is good way to determine this. Such a hard question to answer. It's like asking if a

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
Yes, good idea. I would be interested how other users handle this problem, that is determining if a statement is (potentially) data producing, non-data producing or just invalid. RBS On Wed, Aug 1, 2018 at 5:23 PM, David Raymond wrote: > Use the CLI code as an example and see how they do it?

[sqlite] Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
Using SQLite 3.22.0 In my app I have code to determine if a given SQL string is data-producing, non-data producing or invalid. It uses these 3 SQLite functions: sqlite3_prepare_v3 sqlite3_stmt_readonly sqlite3_column_count Have been using this code for a few years and sofar never failed, but

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Charles Leifer
You can simply use: PRAGMA table_info('my_table') To get a list of columns, which you can check against and then conditionally add your column. On Wed, Aug 1, 2018 at 9:13 AM, Tim Streater wrote: > On 01 Aug 2018, at 14:34, Simon White > wrote: > > > I would like to suggest the addition of

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Don V Nielsen
This makes me feel there is a lot of pain coming in the future. Given an update statement for n dbs of unknown state, When a db lacks columns necessary to successfully execute the sql Then add the columns to the db I'm trying to imagine how to keep n remote dbs in a known state, say z, when

[sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Simon White
Hi I would like to suggest the addition of the "If not exists" to the Add Column feature of SQLite.  There are quite common situations where ensuring a column exists is important so that an update to remote devices will not fail but it is not so important that deprecated fields be removed. 

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread David Raymond
Looking like the generalized answer is no, as you can still get that with some valid pragma statements, especially ones that don't return a value. D:\>sqlite3 SQLite version 3.24.0 2018-06-04 19:24:41 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
Yes, it looks indeed explain doesn't help me out there, thanks. Best probably to compare to the pragma list and check the SQL length. RBS On Wed, Aug 1, 2018 at 4:06 PM, David Raymond wrote: > Looking like the generalized answer is no, as you can still get that with > some valid pragma

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
> May I ask about your use-case and what specifically is needed? Probably exactly the same as you are using in your SQLitespeed app. There is a SQL text box and the user can type anything in there he/she wants. App then needs to determine how to handle that string: Produce data to show, run a

[sqlite] UNION ALL bug in Multi-threading

2018-08-01 Thread sanhua.zh
I find a bug that exists in `UNION ALL`. tldr: `UNION ALL` will not merge the data in different schemas in the moment that one of schema is committed but the another not. BUT, `UNION` will. Here are the reproduce steps: Preparation: 1. Prepare a database named "OLD" 1.1 Create a table for

[sqlite] UNION ALL bug in Multi-threading

2018-08-01 Thread sanhua.zh
I find a bug that exists in `UNION ALL`. tldr: `UNION ALL` will not merge the data in different schemas in the moment that one of schema is committed but the another not. BUT, `UNION` will. Here are the reproduce steps: Preparation: 1. Prepare a database named "OLD" 1.1 Create a table for

Re: [sqlite] [EXTERNAL] UNION ALL bug in Multi-threading

2018-08-01 Thread Hick Gunter
Are you sure it is not the special case documented in the ATTACH command? (see https://sqlite.org/lang_attach.html) " Transactions involving multiple attached databases are atomic, assuming that the main database is not ":memory:" and the journal_mode is not WAL. If the main database is

Re: [sqlite] [EXTERNAL] UNION ALL bug in Multi-threading

2018-08-01 Thread Dominique Devienne
On Wed, Aug 1, 2018 at 10:39 AM Hick Gunter wrote: > Are you sure it is not the special case documented in the ATTACH command? > (see https://sqlite.org/lang_attach.html) > Good point. OP will tell us if it applies to his/her case. > " Transactions involving multiple attached databases are

Re: [sqlite] [EXTERNAL] UNION ALL bug in Multi-threading

2018-08-01 Thread Hick Gunter
UNION ALL will just return whatever both sides produce, irrespective of duplicates, whereas UNION will return only 1 copy of duplicated records. asql> select 1 as x union select 1 as x; x - 1 asql> select 1 as x union all select 1 as x; x - 1 1attacho So depending on the relative positions of

[sqlite] Known reasons why sqlite3_open_v2 can take over 60s on windows?

2018-08-01 Thread Andrzej Fiedukowicz
Hi mailing list gurus! I will start with TL;DR version as this may be enough for some of you:  * We are trying to investigate an issue that we see in diagnostic data of our C++ product.  * The issue was pinpointed to be caused by timeout on `sqlite3_open_v2` which supposedly takes over 60s to

Re: [sqlite] Known reasons why sqlite3_open_v2 can take over 60s on windows?

2018-08-01 Thread Richard Hipp
On 7/31/18, Andrzej Fiedukowicz wrote: > * The issue was pinpointed to be caused by timeout on > `sqlite3_open_v2` which supposedly takes over 60s to complete (we only > give it 60s). Are you sure the time is happening on sqlite3_open_v2()? Because that routine just opens the file descriptors

Re: [sqlite] Known reasons why sqlite3_open_v2 can take over 60s on windows?

2018-08-01 Thread R Smith
On 2018/07/31 5:02 PM, Andrzej Fiedukowicz wrote: Hi mailing list gurus! I will start with TL;DR version as this may be enough for some of you:  * We are trying to investigate an issue that we see in diagnostic data of our C++ product.  * The issue was pinpointed to be caused by timeout on

Re: [sqlite] sqlite on freertos/fatfs : SQLITE_NOTADB during create table

2018-08-01 Thread Bram Peeters
Thanks ! The problem was that lseek of fastfs behaves differently from the posix specs. If you do a fatfs lseek to a place beyond the actual file size and the file is opened for writing, he will automatically increase the file size which is not OK according to posix. (lseek is called by de

Re: [sqlite] Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread Bart Smissaert
Yes, thanks, I did forget about that. Would the method with explain then be a good way to pick up that the pragma was unknown, so invalid? I suppose a simpler way might be to compare to all the pragma's produced by pragma_list and determine that pragma index_list is too short (missing the table).

Re: [sqlite] Error: foreign key mismatch - "loan" referencing "user"

2018-08-01 Thread Markos
Hi Clemens, The table user stores info about all users. But some users have administrator privileges and can register a loan or a devolution in the system. On the line: FOREIGN KEY (id_admin_loan, id_admin_devolution) REFERENCES user (id_user, id_user) The id_admin_loan field is the

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 3:57 PM, Tim Streater wrote: > > On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: >>> >>> I don't use the pragma since, officially, they are unsupported. >> > Specific pragma statements may be removed and others added in future releases > of SQLite. There is no guarantee of

Re: [sqlite] Error: foreign key mismatch - "loan" referencing "user"

2018-08-01 Thread Keith Medcalf
Because the required unique index on copy(id_book, copy_number) exists (in the table definition). --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users-

[sqlite] Violated failed foreign key constraint delays the rest of transaction ; Some foreign key violations don't trigger the error at all

2018-08-01 Thread Yuri
The attached testcase injects the foreign key violation into a long transaction. This makes the remainder of the transaction much slower, even though the foreign key is deferred, and should only be checked in the end of the transaction. While working on this testcase, I found that sometimes

Re: [sqlite] [EXTERNAL] Re: Is pragma index_list without supplied table name valid SQL?

2018-08-01 Thread R Smith
On 2018/08/01 5:56 PM, Bart Smissaert wrote: May I ask about your use-case and what specifically is needed? Probably exactly the same as you are using in your SQLitespeed app. There is a SQL text box and the user can type anything in there he/she wants. App then needs to determine how to handle

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: > > I don't use the pragma since, officially, they are unsupported. “Unsupported” how? It’s documented and part of the SQLite file header, which is quite stable. If you mean this is not standard SQL and thus doesn’t work on non-SQLite DBs,

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 21:06, Warren Young wrote: > On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: >> >> I don't use the pragma since, officially, they are unsupported. > > “Unsupported” how? It’s documented and part of the SQLite file header, which > is quite stable. > > If you mean this is not

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 7:34 AM, Simon White wrote: > > I would like to suggest the addition of the "If not exists" to the Add Column > feature of SQLite. I maintain an application that’s been through dozens of schema changes over its nearly quarter century of life, so let me tell you what works

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 20:40, Warren Young wrote: > On Aug 1, 2018, at 7:34 AM, Simon White > wrote: >> >> I would like to suggest the addition of the "If not exists" to the Add >> Column feature of SQLite. > > I maintain an application that’s been through dozens of schema changes over > its