Re: [sqlite] System function with Sqlite

2008-08-13 Thread Chris Brown
> that seems wrong, for those which are symlinks (ie. 0->6) can you also
> readlink and print that out too please?
>
> it seems like some fd's are beinh held open
>
> as a work around you can loop over these fd's (say 2 though 255) and
> set FD_CLOEXEC (lots of things do this, it's a but of a hack and not
> entirely reliable)

I repeated the test and ran readlink for each fd as you suggested. Here are 
the results before SQLite:

.

..

0
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
1
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
2
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
3
/proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008

After SQLite:

.
/proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
..
/proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
0
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
1
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
2
/dev/console1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
3
/proc/130/fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
5
pipe:[120]fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008
6
pipe:[120]fd1 ¶g¤T 1¤ë 2 04:54:50 CST 2008

I am still relatively new to Linux so some of the commands you mentioned are 
unfamiliar to me. I hope this output is what you wanted. Could you explain 
how I can set FD_CLOEXEC? If its unreliable then I really can't use it 
permanently but it may be a useful test to run.

Thanks Chris 

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


Re: [sqlite] System function with Sqlite

2008-08-13 Thread Peter Holmes
Again, for what it's worth:  I'm using gcc 4.1.3 and I've successfully 
run this as myself, using sudo, and as root.

While I realize we're not talking Windoze, have you tried rebooting, 
recompling, and rerunning it?

> Hi Peter- Yes I'm running the code as you've put above and I used the full 
> source tree also.  Its quite frustrating as to why I'm getting this strange 
> behaviour on my system. I accept that Sqlite may not be directly responsible 
> but the act of running it on my system is having an affect for some reason. 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL error: disk I/O error, for attached DBs on power PC

2008-08-13 Thread France Hsu
Hi! All,

After using strace, we found the root cause.
SQLite will use some temporary files to keep the select (with union all) 
result.
See: http://www.sqlite.org/tempfiles.html

In our system, we allocated 32M for /, and there are only 19M after 
booting up the system.
SQLite can not get enough space for the temporary files (strace shows 
"write error: space is not enough")
After adding a compiling configuration -DSQLITE_TEMP_STORE=3 to SQLIte's 
Makefile, we can finish this job.
http://www.sqlite.org/compile.html#temp_store

Also, we can change the location of the temporary files to solve this 
issue.

France Hsu wrote:
> Hi! All,
>
> We recently got an error "Disk I/O error" while using the select 
> command on attached DBs.
> These DBs have same table format
> We only execute select, insert, and attach commands
>
> The environment is as follows:
> SQLite: V3.5.6
> OS: Linux 2.6.24.2
> Platform Power PC (MPC8543)
> Memory: 256M
> DB Location: SATA hard drive, within a 512-maga-byte partition
>
> The error is happened when the size of one DB file is larger than 10M,
> Ex:
> -rw-r--r--1 root root 10600448 Aug  1 14:38 system_log-07.db
> -rw-r--r--1 root root27648 Aug  7 22:18 system_log-08.db
>
> ./sqlite3 system_log-08.db
> sqlite> attach ''system_log-07.db' as db1;
> sqlite> select * from main.disk_log union all select * from 
> db1.disk_log order by timestamp desc;
> SQL error: disk I/O error
>
> Available partition size: 467.2M
> Sometimes I executed the command "select count(*) ..." successfully, 
> but sometimes failed.
> The total number of the result is about 15.
> Sometimes I executed the command "select * ... limit 0, 3" 
> successfully, but sometimes failed.
> As observing top when executing sqlite, the available memory is enough 
> (about 120-140M).
>
> Would you provide some comments or some solutions?
> Thank you all very much.
>

-- 

Best Regards,
France Hsu 


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


Re: [sqlite] System function with Sqlite

2008-08-13 Thread Stephen Oberholtzer
What does strace reveal?

-- 
-- Stevie-O
Real programmers use COPY CON PROGRAM.EXE
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] System function with Sqlite

2008-08-13 Thread Chris Brown
> #include "sqlite3.h"
>
> main(int argc, char **argv)
> {
> static sqlite3 *db;
>
> system("whoami");
> sqlite3_open("junk.dbs", );
> sqlite3_close(db);
> system("whoami");
> }
>
> Works fine on mine, Chris.  FWIW I did use the full source tree (the
> .tar.gz file) for compilation and install of sqlite3.5.9
>

Hi Peter- Yes I'm running the code as you've put above and I used the full 
source tree also.  Its quite frustrating as to why I'm getting this strange 
behaviour on my system. I accept that Sqlite may not be directly responsible 
but the act of running it on my system is having an affect for some reason. 

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


Re: [sqlite] [Delphi] ANSI characters turned into Unicode?

2008-08-13 Thread Gilles Ganault
On Wed, 13 Aug 2008 14:24:25 -0400, "Igor Tandetnik"
<[EMAIL PROTECTED]> wrote:
>This does look like UTF-8 encoded string - misinterpreted to be in 
>Latin-1 codepage.

Indeed, the wrapper uses UTF8 by default. Setting it to Standard
solved the issue. Thanks.

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


Re: [sqlite] System function with Sqlite

2008-08-13 Thread Chris Brown
> before the system calls can you make a fucntion that does a
> open/readdir of /proc/self/fd/ and prints the results (to compare
> before and after)?

Hi Chris- I did as you suggested and I had the following returned before 
sqlite3_openis called:

.
..
0
1
2
3

Then this after sqlite3_close but before the second call to system:

.
..
0
1
2
3
5
6

Thanks
Chris 

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


[sqlite] RTree query

2008-08-13 Thread Hartwig Wiesmann
I have two tables with about 100 000 rows. One is the main data table  
and the other an RTree table.

I started a query like described at http://www.sqlite.org/rtree.html:

SELECT data.location_name FROM data, rtree WHERE data.id=rtree.id AND  
rtree.x >= 0 AND rtree.x <= 10;

This runs for about 4 secs.

When using this query:

SELECT location_name FROM data WHERE id IN (SELECT id FROM rtree WHERE  
rtree.x >= 0 AND rtree.x <= 10);

the result is available after less than 0.4 s. This time I expected  
also for the first query but it seems to be that something is going  
wrong overthere (the index for the ID does not seem to  be used or  
something similar). I had a look at the command using "explain" but I  
am not an expert for the VDBE instructions. Any ideas?

Hartwig

FYI: the rtree query by itself returns less than 50 rows.
FYI: I am using sqlite3 version 3.6.1




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


Re: [sqlite] setting a foreign key in a trigger

2008-08-13 Thread Bruce Clift
Thanks for the responses.  This sounds like just what I will need.
--Bruce
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [Delphi] ANSI characters turned into Unicode?

2008-08-13 Thread Igor Tandetnik
Gilles Ganault <[EMAIL PROTECTED]> wrote:
> Using Aducom's free wrapper for Delphi, when
> using accents in a field, they're turned into (I assume) Unicode:
>
> déjà vu, caché, voilà -> déjà vu, caché, voilà !

This does look like UTF-8 encoded string - misinterpreted to be in 
Latin-1 codepage.

> To be able to tell if it's the wrapper or SQLite
> itself, is there a function I should call when
> using accented characters, or does SQLite not care a bit?

SQLite accepts (and returns) strings in either UTF-8 or UTF-16 encoding. 
If you have a string in any other encoding, you would have to convert it 
to one of those before passing it to SQLite (and convert back when 
retrieving from SQLite).

Igor Tandetnik 



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


[sqlite] [Delphi] ANSI characters turned into Unicode?

2008-08-13 Thread Gilles Ganault
Hello

Using Aducom's free wrapper for Delphi, when 
using accents in a field, they're turned into (I assume) Unicode:

déjà vu, caché, voilà -> déjà vu, caché, voilà !

To be able to tell if it's the wrapper or SQLite 
itself, is there a function I should call when 
using accented characters, or does SQLite not care a bit?

Thank you.

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


Re: [sqlite] "unable to open database file" on DROP

2008-08-13 Thread Dennis Cote
D. Richard Hipp wrote:
> 
> (2) Formal and detail requirements that define precisely what SQLite  
> does.
> 
>  http://www.sqlite.org/draft/tokenreq.html
>  http://www.sqlite.org/draft/syntax.html
> 

These look great. I noticed a few typos, but on the whole they are very 
   good.

I noticed that in many places you specify that sqlite will fail with an 
error, but you do not specify what the error will be (i.e. the error 
code and or message isn't specified). Perhaps these details should be added.

BTW, have you noticed how much closer these documents are to the style 
of the SQL standard than your previous, less formal and more more 
ambiguous, documents were? :-)

> 
> (6) New test harnesses and requirements-based test cases that give  
> 100% branch coverage and that can be run on embedded systems.
> 

Will this test system be written in C instead of TCL to make it portable 
to a wider variety of system?

Dennis Cote

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


Re: [sqlite] System function with Sqlite

2008-08-13 Thread Peter Holmes
#include "sqlite3.h"

main(int argc, char **argv)
{
 static sqlite3 *db;

 system("whoami");
 sqlite3_open("junk.dbs", );
 sqlite3_close(db);
 system("whoami");
}

Works fine on mine, Chris.  FWIW I did use the full source tree (the 
.tar.gz file) for compilation and install of sqlite3.5.9

Chris Brown wrote:
>> The "fossil" configuration management system (used to control the
>> documentation of SQLite - see http://www.fossil-scm.org/ for details
>> and http://www.sqlite.org/docsrc/timeline for an example) calls
>> system() after sqlite3_open() in multiple places and it works just
>> fine on Linux, OSX, various other flavors of unix, and even win32.
>> Are you sure that SQLite is to blame here?
> 
> No I couldn't be 100% certain that SQLite is to blame but I have stripped 
> out all other code to do the following and it hangs on the second system 
> call:
> 
> system("whoami");
> sqlite3_open("/bin/test/testdb", );
> sqlite3_close(db);
> system("whoami");
> 
> I have checked the return value of sqlite3_open and it is zero. If I remove 
> the calls to sqlite3_open and sqlite3_close then both system calls complete 
> correctly.
> 
> I also tried Peter's suggestion but that didn't have any affect either.
> 
> Chris
> 
>  
> 
> ___
> 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] System function with Sqlite

2008-08-13 Thread Chris Wedgwood
On Wed, Aug 13, 2008 at 05:08:26PM +1200, Chris Brown wrote:

> At the moment I can replicate this issue simply by having the code
> sample in my previous post inside my main function with the sqlite
> database variable declaration and thats it.

before the system calls can you make a fucntion that does a
open/readdir of /proc/self/fd/ and prints the results (to compare
before and after)?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users