[sqlite] SQLITE_IOERR_SHORT_READ error

2015-03-20 Thread Simon Slavin

On 20 Mar 2015, at 6:12pm, Kumar Suraj  wrote:

> we get error SQLITE_IOERR_SHORT_READ once in a while. While
> 
> error is Ok for us we were interested to know whether there are retries made
> 
> internally when ever SQLite encounter this kind of error.



"The SQLITE_IOERR_SHORT_READ error code is an extended error code for 
SQLITE_IOERR indicating that a read attempt in the VFS layer was unable to 
obtain as many bytes as was requested. This might be due to a truncated file."

This indicates a file format error or possibly a hardware fault.  A retry would 
not help.  You should see this fault.  Seeing this fault should worry you.

I think one of the following is true:

(A) your database is corrupt (and will fail PRAGMA integrity_check)
(B) you are using a non-standard VFS layer and it is buggy
(C) you are accessing the file across a network
(D) you have a hardware fault.

Not 100% sure about the hardware fault but it is something to consider.

Simon.


[sqlite] Clarification regarding Next opcode !

2015-03-20 Thread Sairam Gaddam
What Next opcode does is advance cursor P1 so that it points to the next
key/data pair in its table or index. If there are no more key/value pairs
then fall through to the following instruction.

But i have a program where i need clarification regarding its operation
(I inserted printf statement in Next opcode which will print next followed
by program counter value - printf("in next %d\n",pc);)


//create table
sql="create table em(name int primary key,age int);"\
"create table idv(id int primary key,name text);"\
"create table l(name int primary key,fame int);";

sql="insert into em values(44,21);"\
"insert into em values(11,20);"\
"insert into em values(5,21);"\
"insert into idv values(11,44);"\
"insert into idv values(44,11);"\
"insert into idv values(5,180);"\
"insert into l values(11,11);"\
"insert into l values(12,20);"\
"insert into l values(1,20);";

sql="select * from l,em,idv where l.fame=em.age";

vdbe:

   0 Init 0   330   00
   1 OpenRead 0   110 2 00
   2 OpenRead 250 2 00
   3 OpenRead 120 2 00
   4 Rewind   0   300   00
   5 Rewind   2   290   00
   6 Once 0   150   00
   7 OpenAutoindex330 k(3,nil,nil,nil) 00
   8 Rewind   1   150   00
   9 Column   112   00
  10 Column   103   00
  11 Rowid140   00
  12 MakeRecord   231   00
  13 IdxInsert310   10
  14 Next 190   03
  15 Column   015   00
  16 IsNull   5   280   00
  17 Affinity 510 D 00
  18 SeekGE   3   285 1 00
  19 IdxGT3   285 1 00
  20 Column   006   00
  21 Column   017   00
  22 Column   318   00
  23 Column   309   00
  24 Column   20   10   00
  25 Column   21   11   00
  26 ResultRow660   00
  27 Next 3   190   00
  28 Next 260   01
  29 Next 050   01
  30 Close000   00
  31 Close200   00
  32 Halt 000   00
  33 Transaction  00 45819 0 01
  34 TableLock0   110 l 00
  35 TableLock050 idv   00
  36 TableLock020 em00
  37 Goto 010   00

result:

in next 14
in next 14
in next 14
in next 28
in next 28
in next 28
in next 29
12,20,11,20,11,44.
in next 27
in next 28
12,20,11,20,44,11.
in next 27
in next 28
12,20,11,20,5,180.
in next 27
in next 28
in next 29
1,20,11,20,11,44.
in next 27
in next 28
1,20,11,20,44,11.
in next 27
in next 28
1,20,11,20,5,180.
in next 27
in next 28
in next 29

Here i dont know the behaviour of Next opcode at 27 because whenever it
comes to that opcode it goes to Next opcode at 28.


[sqlite] Clarification regarding Next opcode !

2015-03-20 Thread Hick Gunter
As is readily apparent the next at line 27 deals with the table "em".
Given the constraint "l.fame=em.age" it is blindingly obvious that there is 
only one matching row from table "em".
Therefore it is always correct to exit the innermost loop after only 1 
iteration.


[sqlite] Source code for 3.8.7.4

2015-03-20 Thread Saurav Sarkar
Thanks a ton Dan and Smith for sending the link.

Best Regards,
Saurav

On Fri, Mar 20, 2015 at 2:46 PM, R.Smith  wrote:

> That release was last year I think, try 2014 or 2013.
>
>
> On 2015-03-20 11:11 AM, Saurav Sarkar wrote:
>
>> Hi All,
>>
>> i have tried to download amalagamation source code for sqlite for verions
>> 3.8.7.4
>>
>> By changing the url to
>> http://www.sqlite.org/2015/sqlite-amalgamation-3080704.zip
>>
>> But the file could not be found.
>>
>> Could download for 3.8.8.2
>>
>> Can anyone please help ?
>>
>> Thanks and Regards,
>> Saurav
>>
>> On Thu, Mar 19, 2015 at 9:05 PM, Saurav Sarkar 
>> wrote:
>>
>>  Hi Richard,
>>>
>>> Thanks for the info.
>>> I got this link from the site for 3.8.7.4
>>> http://www.sqlite.org/cgi/src/info/f66f7a17b78ba617
>>>
>>> Hope this is fine.
>>>
>>> I want this version because my project is using this release.
>>>
>>> Best Regards,
>>> Saurav
>>>
>>> On Thu, Mar 19, 2015 at 8:38 PM, Richard Hipp  wrote:
>>>
>>>  On 3/19/15, Saurav Sarkar  wrote:

> Hi All,
>
> Can anyone please tell me how can i get the source code for 3.8.7.4 ?
> In the website of SQLite i could get hold of a amalgamation source code
>
 of

> latest release 3.8.8.3 in a zip file.
>
> Can i similarly get for 3.8.7.4 ?
>
>  Over 14,400 different historical versions of SQLite are available at
 https://www.sqlite.org/src/

 Why do you want 3.8.7.4 instead of 3.8.8.3?
 --
 D. Richard Hipp
 drh at sqlite.org
 ___
 sqlite-users mailing list
 sqlite-users at mailinglists.sqlite.org
 http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


>>>  ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] Source code for 3.8.7.4

2015-03-20 Thread Dan Kennedy
On 03/20/2015 04:11 PM, Saurav Sarkar wrote:
> Hi All,
>
> i have tried to download amalagamation source code for sqlite for verions
> 3.8.7.4
>
> By changing the url to
> http://www.sqlite.org/2015/sqlite-amalgamation-3080704.zip
>
> But the file could not be found.
>
> Could download for 3.8.8.2
>
> Can anyone please help ?

   http://www.sqlite.org/2014/sqlite-amalgamation-3080704.zip






>
> Thanks and Regards,
> Saurav
>
> On Thu, Mar 19, 2015 at 9:05 PM, Saurav Sarkar 
> wrote:
>
>> Hi Richard,
>>
>> Thanks for the info.
>> I got this link from the site for 3.8.7.4
>> http://www.sqlite.org/cgi/src/info/f66f7a17b78ba617
>>
>> Hope this is fine.
>>
>> I want this version because my project is using this release.
>>
>> Best Regards,
>> Saurav
>>
>> On Thu, Mar 19, 2015 at 8:38 PM, Richard Hipp  wrote:
>>
>>> On 3/19/15, Saurav Sarkar  wrote:
 Hi All,

 Can anyone please tell me how can i get the source code for 3.8.7.4 ?
 In the website of SQLite i could get hold of a amalgamation source code
>>> of
 latest release 3.8.8.3 in a zip file.

 Can i similarly get for 3.8.7.4 ?

>>> Over 14,400 different historical versions of SQLite are available at
>>> https://www.sqlite.org/src/
>>>
>>> Why do you want 3.8.7.4 instead of 3.8.8.3?
>>> --
>>> D. Richard Hipp
>>> drh at sqlite.org
>>> ___
>>> sqlite-users mailing list
>>> sqlite-users at mailinglists.sqlite.org
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>>
>>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] Source code for 3.8.7.4

2015-03-20 Thread Saurav Sarkar
Hi All,

i have tried to download amalagamation source code for sqlite for verions
3.8.7.4

By changing the url to
http://www.sqlite.org/2015/sqlite-amalgamation-3080704.zip

But the file could not be found.

Could download for 3.8.8.2

Can anyone please help ?

Thanks and Regards,
Saurav

On Thu, Mar 19, 2015 at 9:05 PM, Saurav Sarkar 
wrote:

> Hi Richard,
>
> Thanks for the info.
> I got this link from the site for 3.8.7.4
> http://www.sqlite.org/cgi/src/info/f66f7a17b78ba617
>
> Hope this is fine.
>
> I want this version because my project is using this release.
>
> Best Regards,
> Saurav
>
> On Thu, Mar 19, 2015 at 8:38 PM, Richard Hipp  wrote:
>
>> On 3/19/15, Saurav Sarkar  wrote:
>> > Hi All,
>> >
>> > Can anyone please tell me how can i get the source code for 3.8.7.4 ?
>> > In the website of SQLite i could get hold of a amalgamation source code
>> of
>> > latest release 3.8.8.3 in a zip file.
>> >
>> > Can i similarly get for 3.8.7.4 ?
>> >
>>
>> Over 14,400 different historical versions of SQLite are available at
>> https://www.sqlite.org/src/
>>
>> Why do you want 3.8.7.4 instead of 3.8.8.3?
>> --
>> D. Richard Hipp
>> drh at sqlite.org
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>


[sqlite] insert or increment?

2015-03-20 Thread Felipe Gasper
Hello,

I?m looking for logic like this:

INSERT data
ON CONFLICT oldrow.col1 += oldrow.col2

Does SQLite have anything that would make this simpler than:

1) UPDATE
2) if 0 rows updated, then INSERT

Thank you!

??

-FG


[sqlite] insert or increment?

2015-03-20 Thread David King
Both of the answers here are pretty good if you have a primary key/unique 
constraint on the name 

https://stackoverflow.com/questions/3647454/increment-counter-or-insert-row-in-one-statement-in-sqlite

My personal favourite is there as:

BEGIN;
  INSERT OR IGNORE INTO observations VALUES (:src, :dest, :verb, 0);
  UPDATE observations SET occurrences = occurrences + 1
WHERE src = :src
AND dest = :dest
AND verb = :verb;
COMMIT;


On 20 Mar 2015, at 11:07, Felipe Gasper  wrote:

> Hello,
> 
>   I?m looking for logic like this:
> 
> INSERT data
> ON CONFLICT oldrow.col1 += oldrow.col2
> 
> Does SQLite have anything that would make this simpler than:
> 
> 1) UPDATE
> 2) if 0 rows updated, then INSERT
> 
>   Thank you!
> 
> ??
> 
> -FG
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: 
<http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/attachments/20150320/b6070fbb/attachment.pgp>


[sqlite] Sqlite3 Bug Found

2015-03-20 Thread Carabas, Costin
The bug was found on Linux (Ubuntu) 64bit architecture and the source code was 
downloaded from https://www.sqlite.org/download.html. The executable 
https://www.sqlite.org/2015/sqlite-amalgamation-3080803.zip was downloaded and 
compiled from the host.

I also checked and the bug doesn't reproduce on Windows.

Regards,
Costin



-Original Message-
From: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Simon Davies
Sent: Thursday, March 19, 2015 4:32 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sqlite3 Bug Found

On 6 March 2015 at 08:38, Carabas, Costin  wrote:
> Hello,
>
> I was working on version 3.8.8.2 of sqlite3 and I found a bug that is trace 
> related. It can be reproduced in 3 steps:
>
> 1.   ".t log" - opens log for tracing
>
> 2.   ".t" - no argument. Closes the file descriptor that was previously 
> opened (Problem)

No - it reports the expected usage - see below

> 3.   ".d" - dumps into the file that was previously closed. = > 
> Segmentation Fault
>
> Where:
> .t = .trace
> .d = .debug

I think you mean .dump here

> Best Regards,
> Costin

Works for me:

C:\sqlite>sqlite3_3.8.8.2 new.db
SQLite version 3.8.8.2 2015-01-30 14:30:45 Enter ".help" for usage hints.
sqlite> .t log
sqlite> .t
Usage: .trace FILE|off
sqlite> .d
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
COMMIT;
sqlite> .q


On 19 March 2015 at 12:52, Carabas, Costin  wrote:
> This bug reproduces to the latest Sqlite release (3.8.8.3).
>
> The log from the bug:
> sqlite> .t file
> sqlite> .t
> Usage: .trace FILE|off
> sqlite> .d
> PRAGMA foreign_keys=OFF;
> BEGIN TRANSACTION;
> Segmentation fault
>
> I also found another bug with the same root cause:
> sqlite> .t file
> sqlite> .t
> Usage: .trace FILE|off
> sqlite> .t
> *** Error in `.libs/lt-sqlite3': double free or corruption (top): 
> 0x024ab340 *** Aborted

Still works for me:

C:\sqlite>sqlite3_3.8.8.3 new.db
SQLite version 3.8.8.3 2015-02-25 13:29:11 Enter ".help" for usage hints.
sqlite>
sqlite> .t log
sqlite> .t
Usage: .trace FILE|off
sqlite> .t
Usage: .trace FILE|off
sqlite>
sqlite> .q

These executables were Win32 downloaded from
https://www.sqlite.org/download.html:
sqlite-shell-win32-x86-3080802.zip
sqlite-shell-win32-x86-3080803.zip

How are you getting your executables?

Regards,
Simon
___
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Source code for 3.8.7.4

2015-03-20 Thread R.Smith
That release was last year I think, try 2014 or 2013.

On 2015-03-20 11:11 AM, Saurav Sarkar wrote:
> Hi All,
>
> i have tried to download amalagamation source code for sqlite for verions
> 3.8.7.4
>
> By changing the url to
> http://www.sqlite.org/2015/sqlite-amalgamation-3080704.zip
>
> But the file could not be found.
>
> Could download for 3.8.8.2
>
> Can anyone please help ?
>
> Thanks and Regards,
> Saurav
>
> On Thu, Mar 19, 2015 at 9:05 PM, Saurav Sarkar 
> wrote:
>
>> Hi Richard,
>>
>> Thanks for the info.
>> I got this link from the site for 3.8.7.4
>> http://www.sqlite.org/cgi/src/info/f66f7a17b78ba617
>>
>> Hope this is fine.
>>
>> I want this version because my project is using this release.
>>
>> Best Regards,
>> Saurav
>>
>> On Thu, Mar 19, 2015 at 8:38 PM, Richard Hipp  wrote:
>>
>>> On 3/19/15, Saurav Sarkar  wrote:
 Hi All,

 Can anyone please tell me how can i get the source code for 3.8.7.4 ?
 In the website of SQLite i could get hold of a amalgamation source code
>>> of
 latest release 3.8.8.3 in a zip file.

 Can i similarly get for 3.8.7.4 ?

>>> Over 14,400 different historical versions of SQLite are available at
>>> https://www.sqlite.org/src/
>>>
>>> Why do you want 3.8.7.4 instead of 3.8.8.3?
>>> --
>>> D. Richard Hipp
>>> drh at sqlite.org
>>> ___
>>> sqlite-users mailing list
>>> sqlite-users at mailinglists.sqlite.org
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>>
>>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] system.data.sqlite.dll and Widows 10

2015-03-20 Thread R.Smith
There were some complaints registered previously with windows about this 
issue where it looks first in the program root for a DLL and then the 
GAC. This is actually unwanted behaviour since if you use a 3rd party 
DLL (let's take the library for Google's Chrome browser as an example) 
in your program - which is the entire beauty of linked libraries - and 
then you update the chrome browser on your machine... the Chrome 
installer doesn't know who all uses the dll and it can only really 
update the one in the GAC.

When you write the software, you of course include the DLL in the 
distribution because you don't know whether a target machine will 
possess a Chrome install - but you would like your program to really use 
an updated DLL if it ever finds one, so loading from GAC first then 
local is the correct behaviour - Windows knows this but they have been 
doing it wrong for legacy reasons, so now maybe they are trying to fix 
it in Win10. (I say maybe cause I am not privy to their decision chain 
and all this is speculation in service of offering a plausible reason).

It goes both ways however: if an older sqlite3.dll somehow finds it's 
way into the GAC (older than 3.7) then things I've made will break horribly.

Either way, I am with you on the issue - it's best to leave it as is 
since a large percentage of existing programs knows it and deals with it 
- It isn't hard to specify loading a DLL from file if you so prefer, but 
it does pose a problem for newer user-centric developers such as VB, VS 
and users not knowing or caring to "deal" with DLL loading issues etc. - 
maybe it's time to do it right - A bit of warning would be welcome though.

If I have to guess, they will probably do the standard WIndows thing 
which works like this:
   We've been doing it like XXX - not perfect but everyone learned to 
use it this way,
   Some users cried and we realised YYY is better, so we changed to YYY,
   Users cry about the change, so we change YYY to work a bit like XXX,
   Other users cry more so we make XXX v2.0 superseding YYY with 
unneeded version control, security prohibitions and a host of other 
nonsense so accommodate everybody sort-of but nobody perfectly - and 
then find a way to market this as a "feature".

Best of luck to you,
Ryan


On 2015-03-20 07:05 AM, Jeff Steinkamp wrote:
> I ran this utility and what I discovered is problematic.
>
> On my development machine, it is always looking for this dependency in 
> the GAC first and loading it from there. as opposed to the start-up 
> folder where the DLL is located.  Why is this looking for the DLL in 
> the GAC first?  This is not normal windows behavior.  I then 
> uninstalled the SQLite setup bundle and ran the program again and 
> according to the utility, it fails finding the DLL in the GAC and 
> loads it from the start-up folder.  This is the behavior on both 
> Windows 7 and 8.
>
>
> On windows 10, which is a basic install of the preview, one for 64 bit 
> and one for 32 bit, and without any development tools installed, or 
> the SQLite setup bundle installed, it failed to find 
> system.data.sqlite.dll.  The first thing I did on my 64 bit was to 
> install the x86 setup bundle.  Now the program runs and loads the dll 
> from the GAC.  I then uninstalled the setup bundle and tried the 
> program again, and I'll be damned it now runs and find the DLL in the 
> launch folder.  Why is that???
>
> Tried the program on a fresh install of the 32 bit win10 and it 
> failed, unable to located the DLL.  I loaded up the SDKs' so I could 
> get the fuslogvw utility.  With the utility running ran the program 
> and It now runs and find the dll in the executable folder.  What's up 
> with this???
>
> I suspect this might be a Windows 10 issues, but why is it looking for 
> the DLL in the GAC first and not in the executable folder which has 
> been the behavior of windows for the last 20 some odd years I have 
> been working with this pig.
>
> Jeff K. Steinkamp (N7YG)
> Tucson, AZ
> Scud Missile Coordinates
> N32.2319 W110.8477
>
> On 3/18/2015 13:09, Nicholas Smit wrote:
>> fuslogvw (
>> https://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.110%29.aspx )
>> might help you understand the DLL binding issue.
>>
>> On 18 March 2015 at 20:04, Jeff Steinkamp  wrote:
>>
>>> One of my users reported that he was unable to get a piece of software
>>> that uses this .NET assembly (x86 version 1.0.9.6) to run on windows 
>>> 10.
>>> It is throwing an error saying that it is unable to located
>>> system.data.sqlite.dll even though it is included in the same folder 
>>> as the
>>> program executable.
>>>
>>> This software is compiled as x86 because of some other included 
>>> assemblies
>>> are complied as x86.  This has been running just fine on both Win7 
>>> and Win8
>>> both 32 and 64 bits this way for quite some time.
>>>
>>> So, I setup a 64 bit Win10 technical preview in a VM and tried it 
>>> myself
>>> and I got the same error.  I tired forcing the 

[sqlite] SQLITE_IOERR_SHORT_READ error

2015-03-20 Thread Kumar Suraj
 Hi

We are using SQLite in our infrastructure and calling following API

sqlite3_step (
but we get error SQLITE_IOERR_SHORT_READ once in a while. While

error is Ok for us we were interested to know whether there are retries made

internally when ever SQLite encounter this kind of error.

Thanks


[sqlite] What is the right order of the main SQLite functions?

2015-03-20 Thread Bart Smissaert
Thanks, all working beautifully now.

RBS

On Fri, Mar 20, 2015 at 1:27 AM, Simon Slavin  wrote:

>
> On 19 Mar 2015, at 11:48pm, Bart Smissaert 
> wrote:
>
> > Is this all how it should be?
>
> Apart from the following, nothing I see looks like it will cause
> problems.  You should be checking the result codes of all the calls you do
> to make sure you are getting SQLITE_OK (==0) returned from them and not an
> error.
>
> > Where/when should I call sqlite3_close?
>
> Once you know you don't need access to the database any more.  Before your
> application quits. As above, check to see that you are getting SQLITE_OK
> back to indicate that your connection to the database was still working
> correctly when you closed it.
>
> > Does Clearbindings come indeed before finalize?
>
> You do not need to clear bindings before _finalize(), since _finalize()
> releases all the bindings for you as part of releasing all resources used
> by the statement.
>
> You might want to clear bindings before or after a _reset(), since it can
> help you to find errors when you start binding for the next use of the
> statement.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] What is the right order of the main SQLite functions?

2015-03-20 Thread Simon Slavin

On 19 Mar 2015, at 11:48pm, Bart Smissaert  wrote:

> Is this all how it should be?

Apart from the following, nothing I see looks like it will cause problems.  You 
should be checking the result codes of all the calls you do to make sure you 
are getting SQLITE_OK (==0) returned from them and not an error.

> Where/when should I call sqlite3_close?

Once you know you don't need access to the database any more.  Before your 
application quits. As above, check to see that you are getting SQLITE_OK back 
to indicate that your connection to the database was still working correctly 
when you closed it.

> Does Clearbindings come indeed before finalize?

You do not need to clear bindings before _finalize(), since _finalize() 
releases all the bindings for you as part of releasing all resources used by 
the statement.

You might want to clear bindings before or after a _reset(), since it can help 
you to find errors when you start binding for the next use of the statement.

Simon.


[sqlite] What is the right order of the main SQLite functions?

2015-03-20 Thread Bart Smissaert
Thanks, that is very useful.
Maybe this should be more clearly (and simple) in the documentation
somewhere.

RBS

On Fri, Mar 20, 2015 at 12:23 AM, Igor Tandetnik  wrote:

> On 3/19/2015 7:48 PM, Bart Smissaert wrote:
>
>> I know this is basic and should be in the documentation, but it is not
>> quite clear to me.
>> Basically I have 3 type of procedures:
>>
>> 1. Getting values from a table. For this I have the following steps:
>>
>> (Open)
>> Prepare
>>
>> Then in a loop:
>>
>> Step
>> ColumnInt, ColumnDouble, ColumnText
>>
>> After the loop:
>>
>> Finalize
>>
>
> Looks good to me.
>
>  2. Putting values in a table:
>>
>> (Open)
>> Start Transaction
>> Prepare
>>
>
> These two could be in any order
>
>  Then in a loop:
>> Bind
>> Step
>> Reset
>>
>> After the loop:
>>
>> Clearbindings
>> Finalize
>> Commit Transaction
>>
>
> It's pointless to clear bindings right before finalize. And commit could
> happen either before or after.
>
>  3. Non looped procedures, eg, delete and update:
>>
>> (Open)
>> Prepare
>> Step
>> Reset
>> Finalize
>>
>
> You don't need reset before finalize.
>
>  Is this all how it should be?
>>
>
> It'll work. There are a few redundancies, but they are harmless.
>
>  Where/when should I call sqlite3_close?
>>
>
> When you no longer need the connection, of course.
>
>  Does Clearbindings come indeed before finalize?
>>
>
> I have yet to find a reason to call sqlite3_clear_bindings. It's needed
> very rarely, if ever. It's absolutely pointless right before finalize.
> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] how to determine the status of last statement in sqlite3 shell ?

2015-03-20 Thread James K. Lowden
On Wed, 18 Mar 2015 21:15:20 +
Simon Slavin  wrote:

> A transaction is ended when you issue the COMMIT command.  A
> transaction fails if any command which changes the database in it
> fails due to violating the schema.  If a transaction fails then all
> commands in it are automatically ignored.  There's no need to use
> ROLLBACK.  You correctly grouped commands together into a transaction
> and SQL knows that if any of them fail none of them must be executed.

$ sqlite3 :memory:<", writing standard SQL, and relying
on -bail to exit on error, whereupon SQLite reaches end-of-input
without an explicit COMMIT, and rolls back.  

--jkl


[sqlite] What is the right order of the main SQLite functions?

2015-03-20 Thread Bart Smissaert
I know this is basic and should be in the documentation, but it is not
quite clear to me.
Basically I have 3 type of procedures:

1. Getting values from a table. For this I have the following steps:

(Open)
Prepare

Then in a loop:

Step
ColumnInt, ColumnDouble, ColumnText

After the loop:

Finalize

2. Putting values in a table:

(Open)
Start Transaction
Prepare

Then in a loop:
Bind
Step
Reset

After the loop:

Clearbindings
Finalize
Commit Transaction

3. Non looped procedures, eg, delete and update:

(Open)
Prepare
Step
Reset
Finalize

Is this all how it should be?
Where/when should I call sqlite3_close?
Does Clearbindings come indeed before finalize?


Thanks for any clarification.


RBS


[sqlite] 55c21521 causes build break on older GCC

2015-03-20 Thread Joe Prostko
 Hello,

I was trying to do a trunk build of Fossil that has incorporated recent
pre-release code via its check-in d1db1e47 <
http://fossil-scm.org/index.html/info/d1db1e47a4acdb7b>.  The build was
done on Haiku via the older GCC 2.95.3 compiler.  I can do a build just
fine with our GCC 4.8.4 compiler, but the build no longer works with the
older compiler.

Here's relevant output of the build error:

/boot/home/fossil/src/sqlite3.c:30973: macro `osGetpid' used without args
/boot/home/fossil/src/sqlite3.c:30973: macro `osGetpid' used without args
/boot/home/fossil/src/sqlite3.c:31365: macro `osGetpid' used without args

>From what I can tell, this is due to preprocessor changes that happened
between GCC 2 and GCC 3.

In any case, this is more an FYI than me asking for a fix, as Fossil and
SQLite can be built just fine using our GCC 4 compiler.  That said, if
SQLite is expected to build with older GCC compilers, then it would affect
other platforms as well.

- joe