Re: [sqlite] Cannot retrieve SQLite Db Data Immediately After Application Startup

2014-09-04 Thread Bob Moran
Erik,
Are you implying that I must copy the text returned by qPrintable(sql) to a
safe location before calling a method that uses it? I thought that the
string would be valid until I return from the routine.

Bob Moran


On Wed, Sep 3, 2014 at 1:29 PM, Nelson, Erik - 2 <
erik.l.nel...@bankofamerica.com> wrote:

> Bob Moran wrote on Wednesday, September 03, 2014 12:45 PM
> >
> > One added note: My GUI is using QT4, where in this case the SQL text
> > goes something like:
> >
> >   QString qstr = "select id, step, temp from protocols where id
> > = %1";
> >   qstr = qstr.arg(id);
> >   char * str = (char*)qPrintable(qstr);
> >   sqlite3_prepare_v2( db, str, qstr.Length+1, , NULL)
> >
>
> That's pretty different than the pseudocode you presented earlier.
>
> From the docs for qPrintable
> http://qt-project.org/doc/qt-4.8/qtglobal.html#qPrintable
>
> **
> Returns str as a const char *. This is equivalent to
> str.toLocal8Bit().constData().
>
> The char pointer will be invalid after the statement in which qPrintable()
> is used. This is because the array returned by toLocal8Bit() will fall out
> of scope.
> 
>
> Your str is likely pointing to memory that has been freed?
>
> Erik
>
> --
> This message, and any attachments, is for the intended recipient(s) only,
> may contain information that is privileged, confidential and/or proprietary
> and subject to important terms and conditions available at
> http://www.bankofamerica.com/emaildisclaimer.   If you are not the
> intended recipient, please delete this message.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problems uploading CSV into sqlite3 DB

2014-09-04 Thread David Empson
I get similar results on OS X 10.9.4 if I try to use the version of SQLite 
supplied with the operating system (3.7.13) to import a CSV.

The simple ".mode csv" and ".import  tab1" method works if I run the 
copy of SQLite 3.8.5 I built myself from the source code, or if I use the Mac 
OS X precompiled SQLite 3.8.5 shell from the web site. (I prefer to build my 
own copy because the one on the web site doesn't include the readline library, 
so if used interactively it can't recall previous command lines with up-arrow.)

The problem is likely to be that the method you are using to launch sqlite3, 
which is using the system's default search path to locate sqlite3, and that 
will be the Apple-supplied version (3.7.13) which is located at 
/usr/bin/sqlite3. It appears that version doesn't import CSVs properly.

The easiest way to avoid the problem is to specify the path to your downloaded 
copy of sqlite3.

Assuming you have put the downloaded sqlite3 in your Applications folder, then 
to run it from Terminal you can use this command:

$ /Applications/sqlite3 newDB.db < my_script_file

On 4/09/2014, at 3:24 am, Carlos A. Gorricho (HGSAS) 
 wrote:

> ​When I start sqlite double clicking the icon in the Mac Applications
> folder:
> 
> Last login: Wed Sep  3 10:13:32 on ttys000
> 
> HEPTAGON-GROUP-SAS:~ carlosgorricho$ /Applications/sqlite3 ; exit;
> 
> SQLite version 3.8.5 2014-06-04 14:06:34
> 
> Enter ".help" for usage hints.
> 
> Connected to a *transient in-memory database*.
> 
> Use ".open FILENAME" to reopen on a persistent database.
> 
> sqlite>
> 
> ​
> When starting sqlite on a Terminal Window:
> 
> Last login: Wed Sep  3 10:11:42 on ttys002
> 
> HEPTAGON-GROUP-SAS:~ carlosgorricho$ sqlite3
> 
> SQLite version 3.7.13 2012-07-17 17:46:21
> 
> Enter ".help" for instructions
> 
> Enter SQL statements terminated with a ";"
> 
> sqlite>
> 
> 
> I downloaded the only precompile binary currently available for Mac in
> www.sqlite.org website.
> 
> To perform the job described earlier, I run the Terminal version in batch
> mode. That is, I created a script file with all the .commands to upload de
> CSV file, and ran it on a new database:
> 
> $ sqlite3 newDB.db < my_script_file
> 
> 
> When I got the tab1 error message, I reverted to performing the job from
> inside the database, creating first the table and then uploading the data.
> The result was the huge single-record-field DB I shared earlier.
> 
> I would venture to say I did this from the Terminal sqlite version, but I
> am not certain...
> 
> Thanks in advance for your comments and guidance. Please let me know if I
> can do anything to help you in other fronts.
> 
> 
> 
> 
> Saludos/Cheers,

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problems uploading CSV into sqlite3 DB

2014-09-04 Thread Nelson, Erik - 2
Carlos A. Gorricho (HGSAS) wrote on Friday, September 05, 2014 4:17 AM

>So, any ideas on how to solve this issue will be more than welcome. I have 
>tried several shortcuts...none works.
>Latest was to install an Ubuntu 14.04 Virtual Machine on my Mac, via Parallels 
>software.
>

Maybe line endings...

--
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Problems uploading CSV into sqlite3 DB

2014-09-04 Thread Carlos A. Gorricho (HGSAS)
So, any ideas on how to solve this issue will be more than welcome. I have
tried several shortcuts...none works.

Latest was to install an Ubuntu 14.04 Virtual Machine on my Mac, via
Parallels software.

Downloaded sqlite de Linux way:

$ sudo apt-get install sqlite3


Ran the CSV .import protocol and didn't work Result was eve weirder, since
it create a table using ALL the records as columns headers...



Saludos/Cheers,


*CARLOS A. GORRICHO*
Managing Partner
Heptagon Group S.A.S.
cgorri...@heptagongroup.co
Cel COL +57 314 771 0660
Cell USA +1 713 574 2242


2014-09-03 10:24 GMT-05:00 Carlos A. Gorricho (HGSAS) <
cgorri...@heptagongroup.co>:

> ​When I start sqlite double clicking the icon in the Mac Applications
> folder:
>
> Last login: Wed Sep  3 10:13:32 on ttys000
>
> HEPTAGON-GROUP-SAS:~ carlosgorricho$ /Applications/sqlite3 ; exit;
>
> SQLite version 3.8.5 2014-06-04 14:06:34
>
> Enter ".help" for usage hints.
>
> Connected to a *transient in-memory database*.
>
> Use ".open FILENAME" to reopen on a persistent database.
>
> sqlite>
>
> ​
> When starting sqlite on a Terminal Window:
>
> Last login: Wed Sep  3 10:11:42 on ttys002
>
> HEPTAGON-GROUP-SAS:~ carlosgorricho$ sqlite3
>
> SQLite version 3.7.13 2012-07-17 17:46:21
>
> Enter ".help" for instructions
>
> Enter SQL statements terminated with a ";"
>
> sqlite>
>
>
> I downloaded the only precompile binary currently available for Mac in
> www.sqlite.org website.
>
> To perform the job described earlier, I run the Terminal version in batch
> mode. That is, I created a script file with all the .commands to upload de
> CSV file, and ran it on a new database:
>
> $ sqlite3 newDB.db < my_script_file
>
>
> When I got the tab1 error message, I reverted to performing the job from
> inside the database, creating first the table and then uploading the data.
> The result was the huge single-record-field DB I shared earlier.
>
> I would venture to say I did this from the Terminal sqlite version, but I
> am not certain...
>
> Thanks in advance for your comments and guidance. Please let me know if I
> can do anything to help you in other fronts.
>
>
>
>
> Saludos/Cheers,
>
>
> *CARLOS A. GORRICHO*
> Managing Partner
> Heptagon Group S.A.S.
> cgorri...@heptagongroup.co
> Cel COL +57 314 771 0660
> Cell USA +1 713 574 2242
>
>
> 2014-09-03 9:25 GMT-05:00 Simon Slavin :
>
>
>> On 3 Sep 2014, at 1:51pm, Richard Hipp  wrote:
>>
>> > What version of SQLite is installed?
>>
>> Or rather, when you start the shell tool 'sqlite3' what version does it
>> report itself as ?
>>
>> Simon.
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Issue in copying file

2014-09-04 Thread Stephen Chrzanowski
Chances are its Windows UAC that is coming into play.  You've got three
choices;

- Disable UAC entirely (UAC - User Authentication Control or some jazz like
that)
- Have the installer put your program that is NOT in a protected directory
(c:\Program Files; c:\Program Files (x86) for instance)
- Put the database outside the above directories mentioned.  You can find
out via environment variables, or via windows system calls to find out
where "My Documents" is located on the machine (It isn't always c:\Users or
c:\Documents and Settings)


On Thu, Sep 4, 2014 at 11:07 AM, Rommel Ngo  wrote:

> Hi,
>
>
>
> I have created a program in VB.net and created an installer. I included the
> database file (sqlite) as part of the installer.
>
> My problem is that the first time I install the program to my windows 7 or
> 8
> environment, I can no longer overwrite the file when I try to reinstall the
> same.
>
> I have also tried going to the application directory and directly replace
> the db fily by copying a clean db file replacing the one that is already
> there, and in doing so, the data inside the file remains the same. It does
> not change. I also try copy a different named file and delete the existing,
> but when I try to rename the new to its supposed file name, the data inside
> goes back to the "unclean" db state.
>
>
>
> Do you have any idea, why I cannot seem to overwrite my db file?
>
> If I change the installation directory, that is when the db file is
> refreshed to a "clean" state, only for the first time install.
>
>
>
> Your help is highly appreciated.
>
>
>
> Regards,
>
> Rommel
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite Database Decryption

2014-09-04 Thread Richard Hipp
On Thu, Sep 4, 2014 at 8:15 AM, Jude Nicolasora 
wrote:

> Hi guys,
>
> I would like to ask help and some guidance on how to decrypt a database
> that was encrypted by System.Data.SQLite.
>
> We have a database which was encrypted using System.Data.SQLite.
>

The System.Data.SQLite (SDS) encryption is something that was tossed over
the wall to us.  It is unsupported.  And it only works (when it works at
all) with SDS.

Hence to decrypt the database, you'll have to write a C# application to do
the job.  Once decrypted, you can then access the database using Java or
whatever other programming environment you prefer.



> Our team was supposed to decrypt the database file from our client (they
> gave us the password) and use the decrypted database.
> However, the current system used for development is in Java.
>
> The solutions and libraries offered online requires us to build the source
> files.
> So far, I haven't found a way to decrypt the database.
> Can you guys point me to a Java-oriented solution?
> Or can I manually decrypt the SQLite Database?
>
> Thanks for your time and am hoping for your kind response,
>
> Jude Nicolasora,
> A Fellow Engineer
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Issue in copying file

2014-09-04 Thread Rommel Ngo
Hi,

 

I have created a program in VB.net and created an installer. I included the
database file (sqlite) as part of the installer.

My problem is that the first time I install the program to my windows 7 or 8
environment, I can no longer overwrite the file when I try to reinstall the
same.

I have also tried going to the application directory and directly replace
the db fily by copying a clean db file replacing the one that is already
there, and in doing so, the data inside the file remains the same. It does
not change. I also try copy a different named file and delete the existing,
but when I try to rename the new to its supposed file name, the data inside
goes back to the "unclean" db state.

 

Do you have any idea, why I cannot seem to overwrite my db file?

If I change the installation directory, that is when the db file is
refreshed to a "clean" state, only for the first time install.

 

Your help is highly appreciated.

 

Regards,

Rommel

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLite Database Decryption

2014-09-04 Thread Jude Nicolasora
Hi guys,

I would like to ask help and some guidance on how to decrypt a database
that was encrypted by System.Data.SQLite.

We have a database which was encrypted using System.Data.SQLite.
Our team was supposed to decrypt the database file from our client (they
gave us the password) and use the decrypted database.
However, the current system used for development is in Java.

The solutions and libraries offered online requires us to build the source
files.
So far, I haven't found a way to decrypt the database.
Can you guys point me to a Java-oriented solution?
Or can I manually decrypt the SQLite Database?

Thanks for your time and am hoping for your kind response,

Jude Nicolasora,
A Fellow Engineer
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Index on expressions

2014-09-04 Thread Nico Williams
On Thu, Sep 4, 2014 at 3:59 AM, Dominique Devienne  wrote:
> On Thu, Sep 4, 2014 at 2:04 AM, Nico Williams  wrote:
>
>> [...] but there's a gotcha: SELECT * on a table
>> source with computed columns might result in much more work being done
>> than the user might have expected.
>
> If that's a real concern, you can always use the existing HIDDEN keyword to
> remove that virtual/computed column from the select-star. --DD

Ah!  Good point.

Getting computed columns as part of the process of getting indexing on
expressions would be very, very good.  It would allow having computed
columns in PRIMARY KEY and UNIQUE table constraints, for example.

Nico
--
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Index on expressions

2014-09-04 Thread Klaas V
Dominique Devienne wrote:

(double-click on new version) SQLite version 3.8.5 2014-06-04 14:06:34

(terminal) SQLite version 3.7.13 2012-07-17 17:46:21

 
This means you downloaded the new version in a directory not in your $PATH

Add it to your path:

set PATH=: $PATH

If you do this in your startupscript you always get the latest

Another option (not recommended!) is to overwrite the systemversion with 

sudo cp /sqlite3 /usr/bin/sqlite3

Kind regards | Cordiali saluti | Vriendelijke groeten | Freundliche Grüsse,
Klaas `Z4us` V  - OrcID -0001-7190-2544
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Neo Anderson

Understood. Thanks!


> From: d...@sqlite.org
> Date: Thu, 4 Sep 2014 11:42:52 -0400
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] SQLITE_THREADSAFE question
>
> On Thu, Sep 4, 2014 at 11:32 AM, Neo Anderson  wrote:
>
>> Got confused. if I have SQLITE_THREADSAFE=2, do I need to implement mutex
>> proection around this function call?
>>
>
> No.
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_step and SQLITE_LOCKED/BUSY

2014-09-04 Thread Simon Slavin

> On 4 Sep 2014, at 4:21pm, Jan Slodicka  wrote:
> 
> Our C# wrapper (inspired by system.data.sqlite) uses this quasi-code:
> 
> bool Step(stmt)
> {
>  while(true)
>  {
>start time measurement
>rc = sqlite3_step(stmt);
>if( rc == SQLITE_ROW) return true;// ... reading column values
> possible
>if( rc == SQLITE_DONE) return false;  // ... done
> 
>rc = sqlite3_reset(stmt);// needed? looks strange to me
> 
>if( rc!=SQLITE_LOCKED && rc!=SQLITE_BUSY)
>throw an exception (message taken from sqlite3_errmsg())
>else {
>if timeout expired => throw a timeout exception
>else sleep a bit
>}
>  }
> }

Bad code.  No cookie.  A better structure would be

int stepResult = sqlite3_step(statement);
while (stepResult == SQLITE_ROW) {
// we received a legit row of data
// so handle it here then once it has been handled ...

stepResult = sqlite3_step(statement);
}
sqlite3_finalize(statement);
// now stepResult contains the reason there was no more data.
// if stepResult == SQLITE_DONE then we just finished receiving legit
// results and can carry on with the program.  But ...

if (stepResult != SQLITE_DONE) {
// handle other result codes here and halt/cancel/error
}

You don't need to sleep for timeouts yourself.  Just use this call once, after 
you've opened your connection, to set a timeout of a minute or so ...



and SQLite will handle timeouts and sleeping and exponential backoff itself 
without you having to write your own code to do it.  If the database is still 
locked after the amount of timeout you specified, /then/ you get SQLITE_BUSY.

> If I understand sqlite3_reset correctly (i.e. when it is called after some
> table rows are read, then it returns to the first row), then this code looks
> buggy.

A statement still exists until it has been sqlite3_reset() or 
sqlite3_finalized() and you should act as if it's taking up memory, pointers, 
or some other annoying stuff.  You reset it if you think you're going to start 
it again later, which will restart a SELECT from the first row again.  You 
finalize it if you're done with it and don't intend to execute it again later.  
Both of these calls release resources and set status so that when you 
eventually close the connection to the database SQLite knows you've tidied up 
and can release everything associated with it.

Theoretically you should not execute things like sqlite3_finalize() or 
sqlite3_close() without checking the values they returned to make sure they're 
SQLITE_OK.  I ommitted this check from my above example to make it more 
understandable.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Richard Hipp
On Thu, Sep 4, 2014 at 11:32 AM, Neo Anderson  wrote:

> Got confused. if I have SQLITE_THREADSAFE=2, do I need to implement mutex
> proection around this function call?
>

No.
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Neo Anderson
Got confused. if I have SQLITE_THREADSAFE=2, do I need to implement mutex 
proection around this function call?


> From: d...@sqlite.org
> Date: Thu, 4 Sep 2014 10:18:29 -0400
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] SQLITE_THREADSAFE question
>
> On Thu, Sep 4, 2014 at 10:14 AM, Neo Anderson  wrote:
>
>>
>> 2. Fuctions that do not use sqlite3* and sqite3_stmt* such as
>> sqlite3_mprintf do not need mutex protection.
>>
>
> No. sqlite3_mprintf() does require mutex protection. If you disable
> mutexes using SQLITE_THREADSAFE=0 and then try to use sqlite3_mprintf()
> from multiple threads, you will encounter problems.
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite3_step and SQLITE_LOCKED/BUSY

2014-09-04 Thread Jan Slodicka
I don't have any real problem this time, just wondered if our C# wrapper is
programmed correctly/efficiently.

Suppose we prepared a statement using sqlite3_prepare_v2(). Could please
anybody explain how to treat above mentioned error codes returned by
sqlite3_step()?

Our C# wrapper (inspired by system.data.sqlite) uses this quasi-code:

bool Step(stmt)
{
  while(true)
  {
start time measurement
rc = sqlite3_step(stmt);
if( rc == SQLITE_ROW) return true;// ... reading column values
possible
if( rc == SQLITE_DONE) return false;  // ... done

rc = sqlite3_reset(stmt);// needed? looks strange to me

if( rc!=SQLITE_LOCKED && rc!=SQLITE_BUSY)
throw an exception (message taken from sqlite3_errmsg())
else {
if timeout expired => throw a timeout exception
else sleep a bit
}
  }
}

If I understand sqlite3_reset correctly (i.e. when it is called after some
table rows are read, then it returns to the first row), then this code looks
buggy.

My web research yielded only unclear (sometimes even contradictory) results,
even from guys who are supposed to understand SQLite internals.

Could please somebody shed more light onto this problem?




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/sqlite3-step-and-SQLITE-LOCKED-BUSY-tp77690.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Richard Hipp
On Thu, Sep 4, 2014 at 10:14 AM, Neo Anderson  wrote:

>
> 2. Fuctions that do not use sqlite3* and sqite3_stmt* such as
> sqlite3_mprintf do not need mutex protection.
>

No.  sqlite3_mprintf() does require mutex protection.  If you disable
mutexes using SQLITE_THREADSAFE=0 and then try to use sqlite3_mprintf()
from multiple threads, you will encounter problems.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Neo Anderson

Understood. I want to more sure of the following assumptions:

1. Trivial fucntions such as sqlite3_close, sqite3_errcode also need mutex 
protection even they seem so simple.
2. Fuctions that do not use sqlite3* and sqite3_stmt* such as sqlite3_mprintf 
do not need mutex protection.

Thanks.


> From: d...@sqlite.org
> Date: Thu, 4 Sep 2014 10:07:02 -0400
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] SQLITE_THREADSAFE question
>
> On Thu, Sep 4, 2014 at 9:59 AM, Neo Anderson  wrote:
>
>> I'm building a custom library wrapper for Cocoa. I want to handle database
>> threading issue myself.
>>
>> From http://sqlite.org/compile.html#threadsafe:
>>
>> [quote]
>> When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a
>> multithreaded program so long as no two threads attempt to use the
>> same database connection (or any prepared statements derived from that
>> database connection) at the same time.
>> [/quote]
>>
>> I have two questions:
>>
>> 1. Does SQLITE_THREADSAFE only and solely affects struct sqlite3* and
>> sqlite3_stmt* related API calls?
>>
>
> The difference between SQLITE_THREADSAFE=1 and SQLITE_THREADSAFE=2 is only
> for sqlite3 and sqlite3_stmt related API calls. But SQLITE_THREADSAFE=0
> affects *all* APIs.
>
>
>
>> 2. Are sqlite3_config(SQLITE_CONFIG_MULTITHREAD) and SQLITE_OPEN_NOMUTEX
>> does the same thing as SQLITE_THREADSAFE=2 define?
>>
>
> Yes, as long as you do not compile with SQLITE_THREADSAFE=0. When you
> compilewith SQLITE_THREADSAFE=0, all mutex logic is omitting from the
> build, and so you can never, ever, safely use the resulting library in a
> multi-threaded program, regardless of how you open your connections.
>
>
>>
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Richard Hipp
On Thu, Sep 4, 2014 at 9:59 AM, Neo Anderson  wrote:

> I'm building a custom library wrapper for Cocoa. I want to handle database
> threading issue myself.
>
> From http://sqlite.org/compile.html#threadsafe:
>
> [quote]
> When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a
> multithreaded program so long as no two threads attempt to use the
> same database connection (or any prepared statements derived from that
> database connection) at the same time.
> [/quote]
>
> I have two questions:
>
> 1. Does SQLITE_THREADSAFE only and solely affects struct sqlite3* and
> sqlite3_stmt* related API calls?
>

The difference between SQLITE_THREADSAFE=1 and SQLITE_THREADSAFE=2 is only
for sqlite3 and sqlite3_stmt related API calls.  But SQLITE_THREADSAFE=0
affects *all* APIs.



> 2. Are sqlite3_config(SQLITE_CONFIG_MULTITHREAD) and SQLITE_OPEN_NOMUTEX
> does the same thing as SQLITE_THREADSAFE=2 define?
>

Yes, as long as you do not compile with SQLITE_THREADSAFE=0.  When you
compilewith SQLITE_THREADSAFE=0, all mutex logic is omitting from the
build, and so you can never, ever, safely use the resulting library in a
multi-threaded program, regardless of how you open your connections.


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



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLITE_THREADSAFE question

2014-09-04 Thread Neo Anderson
I'm building a custom library wrapper for Cocoa. I want to handle database 
threading issue myself.

>From http://sqlite.org/compile.html#threadsafe:

[quote]
When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a multithreaded 
program so long as no two threads attempt to use the same database connection 
(or any prepared statements derived from that database connection) at the same 
time.
[/quote]

I have two questions:

1. Does SQLITE_THREADSAFE only and solely affects struct sqlite3* and 
sqlite3_stmt* related API calls?
2. Are sqlite3_config(SQLITE_CONFIG_MULTITHREAD) and SQLITE_OPEN_NOMUTEX does 
the same thing as SQLITE_THREADSAFE=2 define?

  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Deleting columns in SQLite

2014-09-04 Thread Michael Leung
Hi,

I posted a question on stackoverflow and like to forward it to the sqlite 
community.

java - SQLite Ways to delete column: Using temporary table vs Renaming using 
ALTER TABLE - Stack Overflow

  
  
java - SQLite Ways to delete column: Using temporary table vs Renaming using 
ALTER TABLE - Sta...
I am trying to find the best way to delete a column in SQLite. Here are the two 
ways I found: From the official website http://www.sqlite.org/faq.html#q11: 
BEGIN TRANSACTION;   
View on stackoverflow.com Preview by Yahoo  
  

Thanks,
Michael
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] HELP sqlite3 used in vxworks has some problem

2014-09-04 Thread Andy Ling
> > > Please try the patch at
> > >
> http://www.sqlite.org/src/info/b0f6b91f36b503d8ba8d5257bb194f8c1afb483
> > > 3 and
> > > see if that fixes the problem.
> > >
> >
> > I think that fixes unixDelete. Running on the vxWorks dosFs disk
> > everything works as before.
> >
> > If I use the host filing system, then I think the delete of the
> > non-existent file works, but it then fails in unixSync followed by a fail
> > in unixDelete
> >
> > os_unix.c:27830: (35) full_fsync(/tgtsvr/testdb.sql-journal) -  (1034)
> >
> 
> 
> Error code 35 is ENOTSUP - fsync is apparently not supported on your
> filesystem.
> 

I have asked WindRiver about the various issues we have seen and their initial 
response was...

 An errno of EACCES is set by the hostFS and unfortunately it’s not 
aligned
 with POSIX errno. I have suggested to our developers to update that 
and it’s
 tracked internally as VXW6-83401 but the request will be considered an
 enhancement and the decision will be taken later in time when the 
product management
 team will decide to implement it.

 The fsync is indeed not supported on hostFS so the error is expected. 
Because the target
 server connection is mostly used for debugging sessions implementing 
POSIX API is not in plan.

I did query whether fsync is just "unnecessary" and whether it could be made a 
no-op that
just returned OK. So far I haven't had a response.

I did wonder whether the ENOTSUP error could be ignored for vxWorks. It seems 
vaguely reasonable
that if fsync is not supported it isn't needed so SQLite could just ignore the 
error.

I did complain to WindRiver that this mess of differences between filing 
systems makes writing
portable code very difficult. Again, I haven't had a reply.

Regards

Andy Ling




___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Index on expressions

2014-09-04 Thread Dominique Devienne
On Thu, Sep 4, 2014 at 2:04 AM, Nico Williams  wrote:

> [...] but there's a gotcha: SELECT * on a table
> source with computed columns might result in much more work being done
> than the user might have expected.
>

If that's a real concern, you can always use the existing HIDDEN keyword to
remove that virtual/computed column from the select-star. --DD
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users