[sqlite] Bug: Compiler Warning, Mac OS X, in proxyGetHostID()

2010-12-20 Thread Jerry Krinock
In sqlite3.c, version 3.7.4, line 28396 is:

  struct timespec timeout = {1, 0}; /* 1 sec timeout */

This declaration should be moved inside this #if

#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\
   && __MAC_OS_X_VERSION_MIN_REQUIRED<1050

because presently you get a compiler warning of "unused variable" if the #if 
condition is not satisfied, that is, if you're compiling for only recent 
versions of Mac OS X.

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


Re: [sqlite] Troubleshooting...

2010-12-20 Thread john darnell
Thank you Igor.  That explanation makes sense.  And it fits all the information 
I had collected.

R,
John
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of Igor Tandetnik
> Sent: Monday, December 20, 2010 12:10 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Troubleshooting...
> 
> On 12/17/2010 6:18 PM, john darnell wrote:
> > Here's that statement from my code again with the mods included that make 
> > the
> code work:
> >
> >char *surbuf[100];
> >memset(surbuf, 0, 100);
> >strcpy(surbuf, CurrentName ->  second.GetSurName().c_str());
> >idx = -1;
> >idx = sqlite3_bind_parameter_index(ResultStmt, ":sur");
> >sqlite3_bind_text(ResultStmt, idx,  surbuf, strlen(surbuf), 
> > SQLITE_STATIC);
> 
> This works because the string no longer disappears from under the
> statement, the way it did before.
> --
> Igor Tandetnik
> 
> ___
> 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] SQLite server

2010-12-20 Thread Simon Slavin

On 20 Dec 2010, at 9:02pm, Richard Hipp wrote:

> (2) Create your own custom mini-SQL-server using SQLite and your own
> protocol for your applications to talk to that min-server over the network.

In your opinion (or in the opinion of anyone else intimately familiar with 
SQLite), is SQLite suited to this ?  It could be done as a standard package, 
provided and supported by the same team that supports standard SQLite and 
provided in the same amalgamated form.  The procedure would presumably be 
something like:

1) Pick a pair of ports for the protocol and start the process of getting the 
IETF to recognise them.
2) Devise a protocol to encode all the functions in 
 so they can be used over IP.
3) Do the programming for the server and client.

Does the team think it's worth doing this ?  Or will the vast majority of 
people who need networked SQL also need a bunch of other features like user 
privilages which mean you might as well just use one of the existing 'big' SQLs 
?

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


Re: [sqlite] SQLite and Windows 95

2010-12-20 Thread Max Vlasov
On Mon, Dec 20, 2010 at 7:44 PM, wrote:

>
> - Using the SQLite sources in my project, but the application do not start
> any more on Windows 95 : error message is that the application is linked
> to kernel32.dll and that function GetFileAttributesExW is not found. If I
> remove this function in the SQLite code, the same problem appears with
> another function.
>
>

Looking at the name of the function that ends with W, the questions is: have
you installed Microsoft Layer for Unicode (
http://msdn.microsoft.com/en-us/goglobal/bb688166)?

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


Re: [sqlite] Fwd: Re: Bug: Umlaut in database filename

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 11:00 AM, Harald Friedrich
wrote:

>
> We are producing the CAD-Software TARGET 
> 3001!and have switched our 
> electronics components libraries to a SQLite database
> lately. As we also sell multiuser licenses, some of the customers want to
> have only one database, accessed from several (e.g. up to 10) workstations.
> 98% reading only. We got the experience that the performance slows down
> significantly, if more than one user accesses the database on a Linux or
> Windows server simultaneously. And even if the multiuser access ends, the
> slowliness remains until the last user of the multiuser access has closed
> our CAD program. Even a Close of the database doesn't help.  It seems to be
> a kind of locking? Any ideas?
>

I'm guessing this is the effect of your network filesystem trying to do
caching.

SQLite really is intended to have the application and the database disk file
on the same host - not separated by a network.  Consider the folowing
ascii-art diagram showing the relationship of an application, a database
engine, and the disk drive:

+--+  +---+  +--+
| App  |<>| DB Engine |<>| Disk |
+--+  +---+  +--+

The high-bandwidth link is the one between the DB engine and the disk.  The
DB engine does a lot of filtering so that much less traffic flows from the
DB Engine to the application than flows from the Disk to the DB engine.

Suppose the disk and the application are on separate computers.  Then there
has to be a network link somewhere.  In a traditional client/server database
(ex: MySQL, PostgreSQL) the DB engine and the Disk are located on the same
computer and the application is on a separate computer.  So the slow network
link is on the connection with the least traffic.  This good.  But with
SQLite, the DB Engine and the Application are on the same computer and the
disk is on a different machine.  That means that the high-bandwidth link
between the DB Engine and the disk has to go over the network.  This is bad.

You have several options:

(1) Switch to PostgreSQL.
(2) Create your own custom mini-SQL-server using SQLite and your own
protocol for your applications to talk to that min-server over the network.
(3) Replicate the database to each host, if it really is read-only.

Regarding option (3), you might work out some hybrid scheme where the
application opens the canonical SQLite database over the network filesystem,
then copies the content it needs into a local in-memory or temp-disk-space
database, then closes the remote database.  Then it uses the local copy,
which should be very fast.  The sqlite3_backup() interface might be useful
to you for making the local copy.

-- 
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] FTS3 indexing in PHP < 5.3

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 1:44 PM, Lee Kulberda wrote:

> Sorry, in my frustration I posted the wrong code.
>
> Obviously I need to enable/install the FTS3 module, just having a tough
> time finding reliable, specific information on how to do this.
>
> Here is the code:
>
> '$table = "CREATE VIRTUAL TABLE indexed_text USING
> fts3(tokenize=simple);";'
>
> and here is the error:
>
> 'SQLSTATE[HY000]: General error: 1 no such module: fts3'
>

There is a compile-time option:  SQLITE_ENABLE_FTS3


>
> lk
> - Original Message -
> From: "Richard Hipp" 
> To: "General Discussion of SQLite Database" 
> Sent: Monday, December 20, 2010 1:36:51 PM GMT -05:00 US/Canada Eastern
> Subject: Re: [sqlite] FTS3 indexing in PHP < 5.3
>
> On Mon, Dec 20, 2010 at 1:31 PM, Lee Kulberda  >wrote:
>
> > Hello all
> >
> > I am trying to run a FTS3 on text files on a server running PHP Version
> > 5.2.14. with sqlite 3.5.9
> >
> > Going through the command line directly to sqlite3 the virtual tables and
> > FTS3 works fine but I am trying to incorporate into a php app.
> >
> > I get the following error:
> >
> > SQLSTATE[HY000]: General error: 1 near "USING": syntax error
> >
> > on this line:
> >
> > $table = "CREATE TABLE indexed_text USING fts4(tokenize=simple);";
> >
>
> Should be:  "create VIRTUAL table ...".   Also, fts4 was added with SQLite
> version 3.7.4, so it clearly won't work with version 3.5.9.  Use fts3.
>
> >
> > new-ish to sqlite, any help appreciated
> >
> > lk
> > ___
> > 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
>



-- 
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] First(s) select are very slow

2010-12-20 Thread Doug
Adding to what Simon said, even the SQLite cache has to get filled initially
as well.  So those very first hits to the database are always the most
expensive.  Once commonly used pages (index pages?) are loaded, you're
running closer to memory speed than disk speed.

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin
Sent: Monday, December 20, 2010 9:55 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] First(s) select are very slow


On 20 Dec 2010, at 5:33pm, Vander Clock Stephane wrote:

> so what the difference between the sqlite3 cache and the OS cache ?

SQLite caches a number of database pages.

Your operating system has its own caching.  This depends on which OS you're
using, and how it thinks it's addressing your data.  For further details, do
research on a site of the company that provides your OS.

Your computer hardware, also, has many levels of caching: your hard disk
drive probably has onboard caching; your motherboard has a cache; your
processor chip also has caching.

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] FTS3 indexing in PHP < 5.3

2010-12-20 Thread Lee Kulberda
Sorry, in my frustration I posted the wrong code.

Obviously I need to enable/install the FTS3 module, just having a tough time 
finding reliable, specific information on how to do this.

Here is the code:

'$table = "CREATE VIRTUAL TABLE indexed_text USING fts3(tokenize=simple);";'

and here is the error:

'SQLSTATE[HY000]: General error: 1 no such module: fts3'

lk
- Original Message -
From: "Richard Hipp" 
To: "General Discussion of SQLite Database" 
Sent: Monday, December 20, 2010 1:36:51 PM GMT -05:00 US/Canada Eastern
Subject: Re: [sqlite] FTS3 indexing in PHP < 5.3

On Mon, Dec 20, 2010 at 1:31 PM, Lee Kulberda wrote:

> Hello all
>
> I am trying to run a FTS3 on text files on a server running PHP Version
> 5.2.14. with sqlite 3.5.9
>
> Going through the command line directly to sqlite3 the virtual tables and
> FTS3 works fine but I am trying to incorporate into a php app.
>
> I get the following error:
>
> SQLSTATE[HY000]: General error: 1 near "USING": syntax error
>
> on this line:
>
> $table = "CREATE TABLE indexed_text USING fts4(tokenize=simple);";
>

Should be:  "create VIRTUAL table ...".   Also, fts4 was added with SQLite
version 3.7.4, so it clearly won't work with version 3.5.9.  Use fts3.

>
> new-ish to sqlite, any help appreciated
>
> lk
> ___
> 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] FTS3 indexing in PHP < 5.3

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 1:31 PM, Lee Kulberda wrote:

> Hello all
>
> I am trying to run a FTS3 on text files on a server running PHP Version
> 5.2.14. with sqlite 3.5.9
>
> Going through the command line directly to sqlite3 the virtual tables and
> FTS3 works fine but I am trying to incorporate into a php app.
>
> I get the following error:
>
> SQLSTATE[HY000]: General error: 1 near "USING": syntax error
>
> on this line:
>
> $table = "CREATE TABLE indexed_text USING fts4(tokenize=simple);";
>

Should be:  "create VIRTUAL table ...".   Also, fts4 was added with SQLite
version 3.7.4, so it clearly won't work with version 3.5.9.  Use fts3.

>
> new-ish to sqlite, any help appreciated
>
> lk
> ___
> 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


Re: [sqlite] Strange "database disk image is malformed" problems

2010-12-20 Thread Pavel Ivanov
> You are great!
> This is really possible in this case.
> The application runs as a daemon and closes all file handles at startup.
>
> Now I need to check what this library is doing

One of quick solutions to this (without examining library) is to
reopen std* handles to point to /dev/null, so that you protect
yourself from these issues. But if you need those logs your library is
writing then you still need to examine it to understand how to force
it to write to some specific file.


Pavel

On Mon, Dec 20, 2010 at 12:55 PM, Michael Steiger  wrote:
> Hi Pavel!
>
> On 20.12.2010 15:36 Pavel Ivanov said the following:
> Can you tell us what is producing that log text you found ?
 I am developing network appliances using EZchip network processors and
 for implementing some backend code I recently switched to SQLite.
>>>
>>> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
>>> filespace.  My bet is memory.  Or it's possible you've found a bug in 
>>> SQLite where it writes the wrong memory to the file, I suppose.  Perhaps 
>>> lint, clang, or something like them would spot the problem.  Good luck.
>>
>> There's also another possibility that library writing logs do that
>> unconditionally to stdout/stderr, i.e. to file handles 1 or 2. But if
>> you for some reason close those handles next call to sqlite3_open will
>> use them for database file. So in this case library will write
>> straight into your database without knowing about that.
>
> You are great!
> This is really possible in this case.
> The application runs as a daemon and closes all file handles at startup.
>
> Now I need to check what this library is doing
>
> Many thanks
> Michael
>
>
>
>> On Mon, Dec 20, 2010 at 7:58 AM, Simon Slavin  wrote:
>>>
>>> On 20 Dec 2010, at 12:49pm, Michael Steiger wrote:
>>>
> Can you tell us what is producing that log text you found ?
 I am developing network appliances using EZchip network processors and
 for implementing some backend code I recently switched to SQLite.
>>>
>>> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
>>> filespace.  My bet is memory.  Or it's possible you've found a bug in 
>>> SQLite where it writes the wrong memory to the file, I suppose.  Perhaps 
>>> lint, clang, or something like them would spot the problem.  Good luck.
>>>
>>> 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


[sqlite] FTS3 indexing in PHP < 5.3

2010-12-20 Thread Lee Kulberda
Hello all

I am trying to run a FTS3 on text files on a server running PHP Version 5.2.14. 
with sqlite 3.5.9 

Going through the command line directly to sqlite3 the virtual tables and FTS3 
works fine but I am trying to incorporate into a php app.

I get the following error:

SQLSTATE[HY000]: General error: 1 near "USING": syntax error 

on this line:

$table = "CREATE TABLE indexed_text USING fts4(tokenize=simple);";

new-ish to sqlite, any help appreciated

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


Re: [sqlite] SQLite and Windows 95

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 12:51 PM, wrote:

>
> Or if it is not possible to use SQLite, which simple database can I use on
> Win95 ?
>

SQLite can probably be made to work on Win95.  It used to work on Win95.
But we do not have (and have not had for years) the ability to test on
Win95.  It's not like we can go out to BestBuy and pick up a new Win95
machine for testing, you know Hence breakage accumulates.  (A similar
problem exists for OS/2.)

Why don't you go back through some historical versions of SQLite and figure
out when it stopped working.  Maybe you can use that version.  Or maybe you
can take the "os_win.c" source file from that version (which is the only
file that should contain any win95-specific code) and port it to the latest
version of SQLite on the trunk?


-- 
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] Troubleshooting...

2010-12-20 Thread Igor Tandetnik
On 12/17/2010 6:18 PM, john darnell wrote:
> Here's that statement from my code again with the mods included that make the 
> code work:
>
>char *surbuf[100];
>memset(surbuf, 0, 100);
>strcpy(surbuf, CurrentName ->  second.GetSurName().c_str());
>idx = -1;
>idx = sqlite3_bind_parameter_index(ResultStmt, ":sur");
>sqlite3_bind_text(ResultStmt, idx,  surbuf, strlen(surbuf), 
> SQLITE_STATIC);

This works because the string no longer disappears from under the 
statement, the way it did before.
-- 
Igor Tandetnik

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


Re: [sqlite] Troubleshooting...

2010-12-20 Thread Igor Tandetnik
On 12/17/2010 5:23 PM, john darnell wrote:
> I could not figure out how to pipe my info to a file (I guess I am
> still a very young (at 57 years) newbie when it comes to SQLite) so I
> tried something else.  In my code, I hardcoded the data instead of
> using variables.  Here is a copy of one of the statement groups I am
> using to bind data to the insert statement:
>
> idx = -1; idx = sqlite3_bind_parameter_index(ResultStmt, ":disp");
> sqlite3_bind_text(ResultStmt, idx,  CurrentName ->
> second.GetDisplayName().c_str(), -1, SQLITE_STATIC);

GetDisplayName returns a temorary string, which is destroyed at the 
semicolon, and deallocates the internal buffer it maintains. c_str() 
returns a pointer to that buffer, which promptly becomes a dangling 
pointer. Yet, by passing SQLITE_STATIC, you promise that the pointer 
will be valid at least until sqlite3_step call. Pass SQLITE_TRANSIENT 
instead, or make sure the string outlives the execution of the statement.
-- 
Igor Tandetnik

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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 12:47 PM, Jay A. Kreibich  wrote:

> On Mon, Dec 20, 2010 at 12:38:23PM -0500, Dave Watkinson scratched on the
> wall:
> > hey there
> >
> > you seem to have an unescaped apostrophe inside your string, and the
> string
> > itself isn't enclosed by matching quotes
> >
> > X'7801B58E41'
>
>   This is the standard format for a literal BLOB.  See the "Literal
>  Values" section of  http://sqlite.org/lang_expr.html#litvalue
>

Support for blob literals was added on 2004-05-27.
http://www.sqlite.org/src/fdiff?v1=e7536dd31205d5af=28ece63a104850f2

Dagdamor is using a version of SQLite that is on a branch that predates this
change by about a year.



>
>   -j
>
> --
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
>
> "Intelligence is like underwear: it is important that you have it,
>  but showing it to the wrong people has the tendency to make them
>  feel uncomfortable." -- Angela Johnson
> ___
> 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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Dagdamor
Richard Hipp  писал(а) в своём письме Mon, 20 Dec 2010 
23:44:16 +0600:

> 2010/12/20 Dagdamor 
>
>>
>> PHP Version 5.2.6
>>
>> SQLite support  enabled
>> PECL Module version 2.0-dev $Id: sqlite.c,v 1.166.2.13.2.10 2007/12/31
>> 07:20:11 sebastian Exp $
>> SQLite Library  2.8.17
>> SQLite Encoding iso8859
>>
>> Hope that's useful enough... if not, I'll send a test case to reproduce. So
>> far I'm thinking that I've messed with SQL syntax somewhere, but cannot
>> guess where exactly. Thanks in advance.
>>
>>
> SQLite2 does not support binary data.  2.8.17 is a patch release of 2.8.0
> which is 7.5 years old (out of a total history of 10.5 years for SQLite).
> Don't use it.  It is no longer supported.
>
> Please switch to the PDO module for SQLite which makes use of SQLite3.
> SQLite3 is supported, is much faster, has all the latest features, and is
> much more reliable.
>
>

So it's a version issue, not syntax error...
Thanks for the help, Richard. I'll try the PDO interface instead.

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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Simon Slavin

On 20 Dec 2010, at 5:44pm, Richard Hipp wrote:

> Please switch to the PDO module for SQLite which makes use of SQLite3.
> SQLite3 is supported, is much faster, has all the latest features, and is
> much more reliable.

Or use the SQLite3 module which supports sqlite3 more directly, allowing more 
detailed fiddling with SQLite's features.

http://php.net/manual/en/book.sqlite3.php

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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Dave Watkinson
oopsy - thx jay

phooey... i just *knew i should have stayed in bed this morning :-|




On Mon, Dec 20, 2010 at 12:47 PM, Jay A. Kreibich  wrote:

> On Mon, Dec 20, 2010 at 12:38:23PM -0500, Dave Watkinson scratched on the
> wall:
> > hey there
> >
> > you seem to have an unescaped apostrophe inside your string, and the
> string
> > itself isn't enclosed by matching quotes
> >
> > X'7801B58E41'
>
>   This is the standard format for a literal BLOB.  See the "Literal
>  Values" section of  http://sqlite.org/lang_expr.html#litvalue
>
>   -j
>
> --
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
>
> "Intelligence is like underwear: it is important that you have it,
>  but showing it to the wrong people has the tendency to make them
>  feel uncomfortable." -- Angela Johnson
> ___
> 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] Strange "database disk image is malformed" problems

2010-12-20 Thread Michael Steiger
Hi Pavel!

On 20.12.2010 15:36 Pavel Ivanov said the following:
 Can you tell us what is producing that log text you found ?
>>> I am developing network appliances using EZchip network processors and
>>> for implementing some backend code I recently switched to SQLite.
>>
>> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
>> filespace.  My bet is memory.  Or it's possible you've found a bug in SQLite 
>> where it writes the wrong memory to the file, I suppose.  Perhaps lint, 
>> clang, or something like them would spot the problem.  Good luck.
>
> There's also another possibility that library writing logs do that
> unconditionally to stdout/stderr, i.e. to file handles 1 or 2. But if
> you for some reason close those handles next call to sqlite3_open will
> use them for database file. So in this case library will write
> straight into your database without knowing about that.

You are great!
This is really possible in this case.
The application runs as a daemon and closes all file handles at startup.

Now I need to check what this library is doing

Many thanks
Michael



> On Mon, Dec 20, 2010 at 7:58 AM, Simon Slavin  wrote:
>>
>> On 20 Dec 2010, at 12:49pm, Michael Steiger wrote:
>>
 Can you tell us what is producing that log text you found ?
>>> I am developing network appliances using EZchip network processors and
>>> for implementing some backend code I recently switched to SQLite.
>>
>> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
>> filespace.  My bet is memory.  Or it's possible you've found a bug in SQLite 
>> where it writes the wrong memory to the file, I suppose.  Perhaps lint, 
>> clang, or something like them would spot the problem.  Good luck.
>>
>> Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] First(s) select are very slow

2010-12-20 Thread Simon Slavin

On 20 Dec 2010, at 5:33pm, Vander Clock Stephane wrote:

> so what the difference between the sqlite3 cache and the OS cache ?

SQLite caches a number of database pages.

Your operating system has its own caching.  This depends on which OS you're 
using, and how it thinks it's addressing your data.  For further details, do 
research on a site of the company that provides your OS.

Your computer hardware, also, has many levels of caching: your hard disk drive 
probably has onboard caching; your motherboard has a cache; your processor chip 
also has caching.

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


Re: [sqlite] SQLite and Windows 95

2010-12-20 Thread joel . guittet-ext
Hi Kees,

Thanks for your reply.

I'm surprised, in the source code of SQLite (file sqlite3.c), there are a 
lot of references to Win95/98/Me.
If I want to use SQLite under Win95, which (stable) version can I use ? I 
do not need so special functions, just making 3 tables and 
insert/select/delete data in those tables.

Or if it is not possible to use SQLite, which simple database can I use on 
Win95 ? If I do not found solution, I will have to do the jobs around txt 
files  :-(

I'm developping for very specific hardware, and those developments are an 
upgrade of an existing system, I can't upgrade the operating system to a 
newer windows version.

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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Jay A. Kreibich
On Mon, Dec 20, 2010 at 12:38:23PM -0500, Dave Watkinson scratched on the wall:
> hey there
> 
> you seem to have an unescaped apostrophe inside your string, and the string
> itself isn't enclosed by matching quotes
> 
> X'7801B58E41'

  This is the standard format for a literal BLOB.  See the "Literal
  Values" section of  http://sqlite.org/lang_expr.html#litvalue

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] FW: Troubleshooting...

2010-12-20 Thread john darnell
Since Pavel was so certain that my problem was that I was processing a UTF8 
string when I should be processing a UTF16, experience told me that I should 
listen to someone with greater knowledge of SQLite and at least give it a try, 
so  I changed one field in the code to bind the text using sqlite3_bind_text16. 
 Here is the results of the select statement executed in the SQLite3.exe shell:


C:\Sourcecode\SQLite>sqlite3 "C:\_WPCYB\Index Engine\
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .read BuildTables.txt
sqlite> select * from Names;
( It was this field)
 V
1||慄湲汥|JohnDarnell, John||0|1|0
2||慄湲汥|John|A|M||Darnell, John A M||0|1|0
3||敄慬敮|PatrickDelaney, Patrick||0|1|0
4||慍潳⵮慄湲汥|ToddMason-Darnell, Todd||0|
5||Θëŵ╜äµæ╖|WilliamOÆDowd, William||0|1|0
6||潒敢瑲|PatriciaRoberts, Patricia||0|1|0

R,
John
-Original Message-
From: john darnell 
Sent: Monday, December 20, 2010 11:02 AM
To: 'General Discussion of SQLite Database'
Subject: RE: [sqlite] Troubleshooting...

Pavel:

   Though I am a newbie to SQLite I am not a newbie to programming.  Please 
keep that in mind in any future interaction.  

   I did indeed look at the data through the SQLite command utility before I 
offered my answer below, and it supported my conclusion.  And no, I am not 
going to provide you with output.  If my testimony that it worked is not enough 
for you, then...well I'm sorry about that.

   The WideString object InDesign uses is its own WideString class that is part 
of the InDesign SDK.  The headers for both WideString and PMString objects (the 
string object that InDesign uses primarily for UI purposes), declare that a 
WideString may be converted to a PMString simply by using the PMString 
constructor and the WideString as its argument.  So I simply did this:

WideString SomeWString("With some widestring data in it");
PMString SomePMString(SomeWideString);

std::string SomeString = SomePMString.GetPlatformString().

   PMString::GetPlatformString() provides the user with a std::basic_string on 
US-standard Mac and Windows boxes.  I suspect that on computers that use Kanji 
or other non-western alphabets, it provides strings appropriate to their 
language.  That's why it's called "GetPlatformString."

   Oh and by the way, I was using the STL basic_string string object.  I 
have no idea what other kind of basic_string you thought I might be using.

   The PMString does have enough flexibility to use 16-bit chars, but it also 
has enough intelligence to use 8-bit chars if the language warrants it (and a 
few other rules that are not clear but are obviously in play to someone who has 
had to work with PMString for the last eight years or so).  Besides, I only 
used PMString as a stepping stone to get from WideString to basic_string, 
which, by the way, I looked at in the debugger and found it to be standard 
ASCII characters--no spaces or unexpected characters included except at the 
expected places.

   I should think that the fact that I was able to copy the string using the 
old-style strcpy(), and found its true length with strlen(), ending up with the 
expected data in the tables  would have finally been proof enough to you that I 
knew what I was talking about, since strcpy is a simple byte-by-byte copy 
function.

   The locked-in-concrete size of the char buf that you point out is a good 
point.  However, the code was proof of concept code. I was simply trying to 
figure out how to make something work.  I wasn't interested in writing clean, 
elegant code with all the 'i's dotted and the 't's crossed.  Programmers often 
do that when they're first wading into unknown waters.

   When you talk about pointers, there are all sorts of ways in which a pointer 
can be different and yet be functionally the same.  Consider the following:

Char *p;
Char p[100];
Const char *p;
Const char p[100];
Void *p;   //  cast to something like this:  (char *) it would work just fine 
as a null-terminated C-style string.

   One could even do something like this, though why he/she might want to is a 
mystery (but I have seen stranger  and more wondrous code):

Smallint q[100];
Int a = strlen((char *) q);

   (Please note that Outlook is capitalizing the first words of the line--I 
recognize that they all should be lower case-so please don't be petty and point 
it out.)

   In C++ if a function calls for a *p and you give it a p[], the compiler will 
complain.  The compiler did not complain when I used std::basic_string.c_str(), 
which is why this is all so puzzling.  Yet it is obvious to me, even if it is 
not to you, that the data was fine (not UTF16).  sqlite3_bind_text simply did 
not like the std::basic_string.c_str() pointer returned.  But a standard, 
C-style null-terminated string worked fine.

   If the SQLite3 function expects the first kind of pointer and goes crazy 
with anything else, then that 

Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Richard Hipp
2010/12/20 Dagdamor 

>
> PHP Version 5.2.6
>
> SQLite support  enabled
> PECL Module version 2.0-dev $Id: sqlite.c,v 1.166.2.13.2.10 2007/12/31
> 07:20:11 sebastian Exp $
> SQLite Library  2.8.17
> SQLite Encoding iso8859
>
> Hope that's useful enough... if not, I'll send a test case to reproduce. So
> far I'm thinking that I've messed with SQL syntax somewhere, but cannot
> guess where exactly. Thanks in advance.
>
>
SQLite2 does not support binary data.  2.8.17 is a patch release of 2.8.0
which is 7.5 years old (out of a total history of 10.5 years for SQLite).
Don't use it.  It is no longer supported.

Please switch to the PDO module for SQLite which makes use of SQLite3.
SQLite3 is supported, is much faster, has all the latest features, and is
much more reliable.


-- 
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] Inserting BLOB values

2010-12-20 Thread Dave Watkinson
hey there

you seem to have an unescaped apostrophe inside your string, and the string
itself isn't enclosed by matching quotes

X'7801B58E41'




~~~



On Mon, Dec 20, 2010 at 12:27 PM, Dagdamor  wrote:

> Oh, and I forgot to add - the reply comes from PHP, from the functions
> called sqlite_last_error() and sqlite_error_string().
>
> --
> Regards,
> Serge Igitov
> ___
> 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 and Windows 95

2010-12-20 Thread Kees Nuyt
On Mon, 20 Dec 2010 16:44:10 +,
joel.guittet-...@transport.alstom.com wrote:

> Hi,
>
>I'm working with SQLite since few months. I'm developping an application 
>with Visual C++ 6.0 and with SQLite 3.7.2. This application works fine on 
>my computer, which is running Windows XP.
>
>But the final hardware is under Windows 95, and the application does not 
>run on it.

Windows 95 support milestones:
General Availability Date 1995-08-15
Mainstream Support End Date  2000-12-31
Extended Support End Date 2001-12-31

The first Alpha version of SQLite3 is dated 2004-06-18
http://www.sqlite.org/oldnews.html#2004__un_18

In other words, it's not very surprising Windows95 is not supported
any more.

Perhaps you can run a newer Windows version, like Windows CE or
Windows Mobile?

Alternatively, you can build a VFS module which targets Windows95
and avoids newer Windows API calls.
-- 
  (  Kees Nuyt
  )
c[_]
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Dagdamor
Oh, and I forgot to add - the reply comes from PHP, from the functions called 
sqlite_last_error() and sqlite_error_string().

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


Re: [sqlite] First(s) select are very slow

2010-12-20 Thread Vander Clock Stephane
so what the difference between the sqlite3 cache and the OS cache ?

On 12/20/2010 9:49 PM, Doug wrote:
> Possibly because the OS file cache doesn't have any of your database file 
> loaded into memory yet (cold start), so those first selects are experiencing 
> I/O hits.  After a number of them have been done, some/much of the file might 
> be in OS file cache memory, and selects are then hitting memory instead of 
> the much slower disk.
>
> Doug
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Vander Clock Stephane
> Sent: Monday, December 20, 2010 8:43 AM
> To: General Discussion of SQLite Database
> Subject: [sqlite] First(s) select are very slow
>
> hello,
>
> why, on a big table (+5 000 000 rows with RTREE ndex) at the beginning, the 
> select is very slow to return (2-5 secondes), but after 1000 selects, it's 
> start to return immediatly (10 ms) ??
>
> thanks by advance
> st phane
> ___
> 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-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Dagdamor
Richard Hipp  писал(а) в своём письме Mon, 20 Dec 2010 
23:13:33 +0600:

> On Mon, Dec 20, 2010 at 11:59 AM, Dagdamor  wrote:
>
>> Hello guys.
>>
>> I have a problem with inserting BLOB values into a column.
>>
>> Query:
>>
>> INSERT INTO cachebundles (id,styleid,bundles,plugins,content,compressed)
>>   VALUES (NULL,1,'general','',X'7801B58E41',1)
>>
>> SQLite reply:
>>
>> "SQL logic error or missing database"
>>
>
> Where did you get this reply from?  Are you using some third-party tool?  Is
> it coming from your program, in which case where did your program get it?
> Is it coming out of the sqlite3.exe command-line shell?  The differences are
> important.  Please provide details.
>
> A reproducible test case would be nice to have too.

I'm working with PHP (version 5.2.6) and using its standard SQLite extension 
(sqlite_xxx functions).
I've simplified my situation a bit:

CREATE TABLE test1 (content BLOB)
INSERT INTO test1 (content) VALUES ('test')

Works okay, but

CREATE TABLE test2 (content BLOB)
INSERT INTO test2 (content) VALUES (X'1234')

"SQL logic error or missing database"

> :/


Here is an extract from phpinfo():

PHP Version 5.2.6

SQLite support  enabled 
PECL Module version 2.0-dev $Id: sqlite.c,v 1.166.2.13.2.10 2007/12/31 
07:20:11 sebastian Exp $ 
SQLite Library  2.8.17  
SQLite Encoding iso8859

Hope that's useful enough... if not, I'll send a test case to reproduce. So far 
I'm thinking that I've messed with SQL syntax somewhere, but cannot guess where 
exactly. Thanks in advance.

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


Re: [sqlite] Inserting BLOB values

2010-12-20 Thread Richard Hipp
On Mon, Dec 20, 2010 at 11:59 AM, Dagdamor  wrote:

> Hello guys.
>
> I have a problem with inserting BLOB values into a column.
>
> Query:
>
> INSERT INTO cachebundles (id,styleid,bundles,plugins,content,compressed)
>   VALUES (NULL,1,'general','',X'7801B58E41',1)
>
> SQLite reply:
>
> "SQL logic error or missing database"
>

Where did you get this reply from?  Are you using some third-party tool?  Is
it coming from your program, in which case where did your program get it?
Is it coming out of the sqlite3.exe command-line shell?  The differences are
important.  Please provide details.

A reproducible test case would be nice to have too.


>
> Table schema:
>
> CREATE TABLE cachebundles (
>   id INTEGER PRIMARY KEY,
>   styleid INT NOT NULL,
>   bundles TINYTEXT NOT NULL,
>   plugins TINYTEXT NOT NULL,
>   content LONGBLOB NOT NULL,
>   compressed TINYINT(1) NOT NULL,
>   UNIQUE (styleid,bundles))
>
> Inserting data into regular (non-blob) columns seem to work. What exactly
> I'm doing wrong? SQLite reply isn't very informative...
>
> --
> Regards,
> Serge Igitov
> ___
> 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] Inserting BLOB values

2010-12-20 Thread Dagdamor
Hello guys.

I have a problem with inserting BLOB values into a column.

Query:

INSERT INTO cachebundles (id,styleid,bundles,plugins,content,compressed)
   VALUES (NULL,1,'general','',X'7801B58E41',1)

SQLite reply:

"SQL logic error or missing database"

Table schema:

CREATE TABLE cachebundles (
   id INTEGER PRIMARY KEY,
   styleid INT NOT NULL,
   bundles TINYTEXT NOT NULL,
   plugins TINYTEXT NOT NULL,
   content LONGBLOB NOT NULL,
   compressed TINYINT(1) NOT NULL,
   UNIQUE (styleid,bundles))

Inserting data into regular (non-blob) columns seem to work. What exactly I'm 
doing wrong? SQLite reply isn't very informative...

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


Re: [sqlite] Troubleshooting...

2010-12-20 Thread john darnell
Thank you for the reminder, Mr. Archer.  

The basic_string is actually stored as part of a STL map and is fairly 
long-lived; once it is created, it remains until the plugin's destructor clears 
the map.

R,
John


> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of jeff archer
> Sent: Sunday, December 19, 2010 4:21 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Troubleshooting...
> 
> >> My only guess is that basic_string::c_str() doesn't really provide a 
> >> pointer to
> >>a null-terminated c-style string, >but a facsimile of one that SQLite 
> >>doesn't
> >>like.
> >
> >c_str() provides pointer to the data that string has with additional
> >null byte added at the end. That's it. Whether it is a null-terminated
> >c-style string depends on what data you put into it. If that data has
> >null bytes in it then SQLite will see only part of your string, though
> >I'm not sure that it was the actual problem you have seen.
> 
> You may probably already know this but maybe I'll remind you.  The pointer
> returned by c_str() is only valid in the statement where it is used or 
> possibly
> as long as the life of the basic_string it came from.
> ___
> 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] Troubleshooting...

2010-12-20 Thread john darnell
Pavel:

   Though I am a newbie to SQLite I am not a newbie to programming.  Please 
keep that in mind in any future interaction.  

   I did indeed look at the data through the SQLite command utility before I 
offered my answer below, and it supported my conclusion.  And no, I am not 
going to provide you with output.  If my testimony that it worked is not enough 
for you, then...well I'm sorry about that.

   The WideString object InDesign uses is its own WideString class that is part 
of the InDesign SDK.  The headers for both WideString and PMString objects (the 
string object that InDesign uses primarily for UI purposes), declare that a 
WideString may be converted to a PMString simply by using the PMString 
constructor and the WideString as its argument.  So I simply did this:

WideString SomeWString("With some widestring data in it");
PMString SomePMString(SomeWideString);

std::string SomeString = SomePMString.GetPlatformString().

   PMString::GetPlatformString() provides the user with a std::basic_string on 
US-standard Mac and Windows boxes.  I suspect that on computers that use Kanji 
or other non-western alphabets, it provides strings appropriate to their 
language.  That's why it's called "GetPlatformString."

   Oh and by the way, I was using the STL basic_string string object.  I 
have no idea what other kind of basic_string you thought I might be using.

   The PMString does have enough flexibility to use 16-bit chars, but it also 
has enough intelligence to use 8-bit chars if the language warrants it (and a 
few other rules that are not clear but are obviously in play to someone who has 
had to work with PMString for the last eight years or so).  Besides, I only 
used PMString as a stepping stone to get from WideString to basic_string, 
which, by the way, I looked at in the debugger and found it to be standard 
ASCII characters--no spaces or unexpected characters included except at the 
expected places.

   I should think that the fact that I was able to copy the string using the 
old-style strcpy(), and found its true length with strlen(), ending up with the 
expected data in the tables  would have finally been proof enough to you that I 
knew what I was talking about, since strcpy is a simple byte-by-byte copy 
function.

   The locked-in-concrete size of the char buf that you point out is a good 
point.  However, the code was proof of concept code. I was simply trying to 
figure out how to make something work.  I wasn't interested in writing clean, 
elegant code with all the 'i's dotted and the 't's crossed.  Programmers often 
do that when they're first wading into unknown waters.

   When you talk about pointers, there are all sorts of ways in which a pointer 
can be different and yet be functionally the same.  Consider the following:

Char *p;
Char p[100];
Const char *p;
Const char p[100];
Void *p;   //  cast to something like this:  (char *) it would work just fine 
as a null-terminated C-style string.

   One could even do something like this, though why he/she might want to is a 
mystery (but I have seen stranger  and more wondrous code):

Smallint q[100];
Int a = strlen((char *) q);

   (Please note that Outlook is capitalizing the first words of the line--I 
recognize that they all should be lower case-so please don't be petty and point 
it out.)

   In C++ if a function calls for a *p and you give it a p[], the compiler will 
complain.  The compiler did not complain when I used std::basic_string.c_str(), 
which is why this is all so puzzling.  Yet it is obvious to me, even if it is 
not to you, that the data was fine (not UTF16).  sqlite3_bind_text simply did 
not like the std::basic_string.c_str() pointer returned.  But a standard, 
C-style null-terminated string worked fine.

   If the SQLite3 function expects the first kind of pointer and goes crazy 
with anything else, then that could have been my problem.

   I hope I have answered all of your questions.  As far as I am concerned, my 
problem is solved so unless you have some new insight that will greatly speed 
my program or enhance efficiency, you do not have to respond to this email.

R,
John
 
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of Pavel Ivanov
> Sent: Saturday, December 18, 2010 9:28 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Troubleshooting...
> 
> > Okay.  I worked out a solution, but I am still unsure of why it fixes the 
> > problem.
> 
> Does it really fix your problem? Can you provide output from command
> line utility before the fix and after? I don't see how it can fix
> anything.
> 
> >  Nevertheless your point is well-taken that the data could be something 
> > other
> than UTF8, especially since InDesign uses a WideString class internally.
> 
> Which means that you most probably deal with UTF-16 and maybe need to
> use sqlite3_bind_text16 instead of sqlite3_bind_text.
> 
> > I'm pretty sure I 

Re: [sqlite] First(s) select are very slow

2010-12-20 Thread Doug
Possibly because the OS file cache doesn't have any of your database file 
loaded into memory yet (cold start), so those first selects are experiencing 
I/O hits.  After a number of them have been done, some/much of the file might 
be in OS file cache memory, and selects are then hitting memory instead of the 
much slower disk.

Doug

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Vander Clock Stephane
Sent: Monday, December 20, 2010 8:43 AM
To: General Discussion of SQLite Database
Subject: [sqlite] First(s) select are very slow

hello,

why, on a big table (+5 000 000 rows with RTREE ndex) at the beginning, the 
select is very slow to return (2-5 secondes), but after 1000 selects, it's 
start to return immediatly (10 ms) ??

thanks by advance
st phane
___
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] SQLite and Windows 95

2010-12-20 Thread joel . guittet-ext
 Hi,

I'm working with SQLite since few months. I'm developping an application 
with Visual C++ 6.0 and with SQLite 3.7.2. This application works fine on 
my computer, which is running Windows XP.

But the final hardware is under Windows 95, and the application does not 
run on it.

I tried :

- Using SQLite DLL, with the function LoadLibrary, but LoadLibrary call 
fails on Windows 95 (returns NULL).

- Using the SQLite sources in my project, but the application do not start 
any more on Windows 95 : error message is that the application is linked 
to kernel32.dll and that function GetFileAttributesExW is not found. If I 
remove this function in the SQLite code, the same problem appears with 
another function.

So I'm looking for help to run my application on Windows 95. Maybe I 
simply forget a definition to do before building ?
I found some information on the Internet, but nothing very easy to 
understand and use. Is there somewhere a basic application which runs 
under Windows 95 ? Of course I'm particularly interrested by Visual C++ 
6.0 examples, but any other examples will be apreciated.

Thanks for your help.
Joel


Alstom protège l'environnement : n'imprimez ce mail que si nécessaire.
With Alstom, preserve the environment. Is printing this email really 
necessary ?
:.___

CONFIDENTIALITE : Ce message et les éventuelles pièces attachées sont 
confidentiels. Si vous n'êtes pas dans la liste des destinataires, 
veuillez informer l'expéditeur immédiatement et ne pas divulguer le 
contenu à une tierce personne, ne pas l'utiliser pour quelque raison que 
ce soit, ne pas stocker ou copier l'information qu'il contient sur un 
quelconque support.
CONFIDENTIALITY : This  e-mail  and  any attachments are confidential and 
may be privileged. If  you are not a named recipient, please notify the 
sender immediately and do not disclose the contents to another person, use 
it for any purpose or store or copy the information in any medium.

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


[sqlite] First(s) select are very slow

2010-12-20 Thread Vander Clock Stephane
hello,

why, on a big table (+5 000 000 rows with RTREE ndex) at the beginning, 
the select is very slow to return (2-5 secondes), but after 1000 selects,
it's start to return immediatly (10 ms) ??

thanks by advance
stéphane
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Windows performance problems associated with malloc()

2010-12-20 Thread Max Vlasov
On Fri, Dec 17, 2010 at 7:29 PM, Richard Hipp  wrote:

>
> For certain full-text search queries against a large database, we are
> seeing
> speeds which are 3x faster when using "-heap 300M" (the memsys5 memory
> allocator) versus omitting the -heap option and thus using system malloc().
> This is on windows7.  Similar results are seen with both gcc and vs2010
> builds.
>
> If you have any large queries that you can run on windows using the
> command-line shell, I would appreciate you timing those queries using the
> new shells from the download page, both with "-heap 300M" and without it,
> and letting me know about any performance differences you see.
>
>
Just tested a feature to see the number of memory requests for a given
query. It is made by keeping a global variable incremented each time malloc
is called (actually it is mapped to a different proc) and showing the
difference between the values at the start and at the end of the query.

Sqlite version 3.7.4 (fts-enabled)

For general queries the number of requests is not great, from 10 to 10,000
and if recalculated to requests per second also not so big (100 per sec for
example). But for fts3 a small difference in match operand can lead to huge
difference in the number of memory requests and you can see that for the
phrase query the request per second value is very big. The queries bellow
was made against a db with English wikipedia abstracts. The times measured
after several repeats so no disk waiting to be affecting.

SELECT Count(*) FROM (SELECT * FROM WikiData WHERE Abstract LIKE
"%official%" LIMIT 500)
  Result: 500,
  mem req: 2163
  664 ms.

SELECT count(docid) FROM WikiFTS3 where Abstract Match 'after before';
  Result: 1539,
  mem requests: 10157
  44 ms.

SELECT count(docid) FROM WikiFTS3 where Abstract Match '"of the previous"'
   Result: 403,
   mem requests: 1,627,732
  3400 ms

I don't know what it means, maybe that some optimization might be possible
in the internal implementation of fts3 to minimize the number of memory
requests.

Thanks

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


Re: [sqlite] Troubleshooting...

2010-12-20 Thread Pavel Ivanov
> You may probably already know this but maybe I'll remind you.  The pointer
> returned by c_str() is only valid in the statement where it is used or 
> possibly
> as long as the life of the basic_string it came from.

Good catch, Jeff! I thought it's so obvious that I didn't even
consider that as a potential problem. So this code can easily write
trash into database:

 idx = sqlite3_bind_parameter_index(ResultStmt, ":sur");
 sqlite3_bind_text(ResultStmt, idx,  CurrentName ->
second.GetSurName().c_str(), -1, SQLITE_STATIC);
 sqlite3_step(...)

When this code will be always correct:

 idx = sqlite3_bind_parameter_index(ResultStmt, ":sur");
 sqlite3_bind_text(ResultStmt, idx,  CurrentName ->
second.GetSurName().c_str(), -1, SQLITE_TRANSIENT);
 sqlite3_step(...)


Pavel

On Sun, Dec 19, 2010 at 5:21 PM, jeff archer  wrote:
>>> My only guess is that basic_string::c_str() doesn't really provide a 
>>> pointer to
>>>a null-terminated c-style string, >but a facsimile of one that SQLite doesn't
>>>like.
>>
>>c_str() provides pointer to the data that string has with additional
>>null byte added at the end. That's it. Whether it is a null-terminated
>>c-style string depends on what data you put into it. If that data has
>>null bytes in it then SQLite will see only part of your string, though
>>I'm not sure that it was the actual problem you have seen.
>
> You may probably already know this but maybe I'll remind you.  The pointer
> returned by c_str() is only valid in the statement where it is used or 
> possibly
> as long as the life of the basic_string it came from.
> ___
> 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] Strange "database disk image is malformed" problems

2010-12-20 Thread Pavel Ivanov
>>> Can you tell us what is producing that log text you found ?
>> I am developing network appliances using EZchip network processors and
>> for implementing some backend code I recently switched to SQLite.
>
> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
> filespace.  My bet is memory.  Or it's possible you've found a bug in SQLite 
> where it writes the wrong memory to the file, I suppose.  Perhaps lint, 
> clang, or something like them would spot the problem.  Good luck.

There's also another possibility that library writing logs do that
unconditionally to stdout/stderr, i.e. to file handles 1 or 2. But if
you for some reason close those handles next call to sqlite3_open will
use them for database file. So in this case library will write
straight into your database without knowing about that.


Pavel

On Mon, Dec 20, 2010 at 7:58 AM, Simon Slavin  wrote:
>
> On 20 Dec 2010, at 12:49pm, Michael Steiger wrote:
>
>>> Can you tell us what is producing that log text you found ?
>> I am developing network appliances using EZchip network processors and
>> for implementing some backend code I recently switched to SQLite.
>
> Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
> filespace.  My bet is memory.  Or it's possible you've found a bug in SQLite 
> where it writes the wrong memory to the file, I suppose.  Perhaps lint, 
> clang, or something like them would spot the problem.  Good luck.
>
> 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] Virtual table optimization using xBestIndex/xFilter

2010-12-20 Thread Sören Brunk
Thanks Jay and Roger, for your explanations and ideas.

I did't think of passing my own data structure to xFilter using idxStr before, 
but in my case that seems to be the easiest way.

In xBestIndex I'm allocating enough memory to hold information about all 
usable constraints, using sqlite3_malloc. Then I'm packing a struct containing 
iColumn and op into that memory for each usable constraint and I'm using
idxinfo->aConstraintUsage[x].argvIndex to get the right-hand side value for 
each constraint in the same order as the constraint information in xFilter.
Finally I'm setting needToFreeIdxStr to make sure all memory is freed.
It seems to work fine that way.

Regards,
Sören
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Strange "database disk image is malformed" problems

2010-12-20 Thread Simon Slavin

On 20 Dec 2010, at 12:49pm, Michael Steiger wrote:

>> Can you tell us what is producing that log text you found ?
> I am developing network appliances using EZchip network processors and 
> for implementing some backend code I recently switched to SQLite.

Mmm.  Well, it could be overwriting some of your memory, or overwriting the 
filespace.  My bet is memory.  Or it's possible you've found a bug in SQLite 
where it writes the wrong memory to the file, I suppose.  Perhaps lint, clang, 
or something like them would spot the problem.  Good luck.

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


Re: [sqlite] Strange "database disk image is malformed" problems

2010-12-20 Thread Michael Steiger
On 20.12.2010 13:32 Simon Slavin said the following:
>
> On 20 Dec 2010, at 12:17pm, Michael Steiger wrote:
>
>> In the meantime I further analyzed the problem and I also looked at the
>> corrupt databasefile. To my surprise it contained some logfile output
>> from another library I am using. It seems that if I turn on logging for
>> this library some log output is written to the database file. But I have
>> absolutely no idea how this mixup can happen.
>
> Since SQLite does not do any logging, it would seem that the problem is not 
> entirely within the SQLite library.  Since you appear to be using plain C 
> function calls to access SQLite this suggests that there is some sort of 
> problem with your memory handling.
I am sure that the problem is not entirely within SQLite.
Yes, I am using plain C and it must be some memory error. Just need to 
find it ;-)

 > Is there a chance that you are using either the file handle or the
 > database handle for something other than SQLite3 calls ?

And I have already scanned my code if there is a mixup of the database 
handle and some other code. But I found none.
"Using the file handle"? I only open the database using sqlite3_open and 
then use the database handle returned. No direct file access to the 
SQLite databasefile.


 > Can you tell us what is producing that log text you found ?
I am developing network appliances using EZchip network processors and 
for implementing some backend code I recently switched to SQLite.
The code which produces the log text is not called from my code but is 
used deep inside this library (I have the source code to look at).

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


[sqlite] Fastest null WHERE clause

2010-12-20 Thread Simon Slavin
To keep some of my code simple I will need a WHERE clause of some kind, but 
sometimes it doesn't need to do anything.  I was looking for some text I could 
use which would do nothing, but be simple for the analyser and the virtual 
machine.  I had thought to use 'WHERE 1=1' but I wondered if the people in this 
list knew of something even faster.

It is not absolutely vital that this code execute as fast as possible.  It's 
not going to be used to process millions of rows on a public-facing platform.

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


Re: [sqlite] Strange "database disk image is malformed" problems

2010-12-20 Thread Simon Slavin

On 20 Dec 2010, at 12:17pm, Michael Steiger wrote:

> In the meantime I further analyzed the problem and I also looked at the 
> corrupt databasefile. To my surprise it contained some logfile output 
> from another library I am using. It seems that if I turn on logging for 
> this library some log output is written to the database file. But I have 
> absolutely no idea how this mixup can happen.

Since SQLite does not do any logging, it would seem that the problem is not 
entirely within the SQLite library.  Since you appear to be using plain C 
function calls to access SQLite this suggests that there is some sort of 
problem with your memory handling.  Is there a chance that you are using either 
the file handle or the database handle for something other than SQLite3 calls ? 
 Can you tell us what is producing that log text you found ?

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


Re: [sqlite] Bug: Umlaut in database filename

2010-12-20 Thread Richard Hipp
On Sun, Dec 19, 2010 at 6:26 PM, Harald Friedrich wrote:

>
> Hello SQLite team,
>
> if an umlaut (German mutated vowel with two dots on top äöüÄÖÜß) is
> present in the database filename, the first access to the database after
> opening will result in an exception or a runtime error 216.
>

Are you passing in the filenames as UTF8 or as microsoft codepage-850?
SQLite is expecting UTF8.  If you are sending it codepage-850 text as the
filename, that would certainly explain the error.



>
> Using the user's AppDataPath unfortunately always includes the username.
> If this name has an umlaut, SQLite will not work:
>
> *C:\Users\Jürgen
> Möller\AppData\Roaming\ibf\TarV15\medium\Database\target3001.db*
>
> What can we do?
>
> Best regards
>
>
> Harald Friedrich
> __
> Ing.-Buero FRIEDRICH
> Harald Friedrich, Industrial Engineer
> Am Schwarzen Rain 1
> D-36124 Eichenzell, Germany
> Tel.: ++49 - 66 59 / 919 444
> Fax: ++49 - 66 59 / 919 445
> VAT ID DE112342909
> Tax 01881900337
> tar...@ibfriedrich.com
> www.ibfriedrich.com
> ___
> 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


Re: [sqlite] Strange "database disk image is malformed" problems

2010-12-20 Thread Michael Steiger
Hi Simon,

On 20:59 Simon Slavin said the following:
 >
 > On 19 Dec 2010, at 2:56pm, Michael Steiger wrote:
 >
 >> sqlite3_prepare_v2, sqlite3_step, sqlite_column_*, ...: to read data
 >
 > erm ... sqlite3_finalize() ?
Is already there (just forgot to mention it)


 > http://www.sqlite.org/c3ref/stmt.html
 >
 >> If I try to reproduce this sequence using sqlite3 the problem does not
 >> occur (qed).
 >
 > Sorry, I thought sqlite3 was what got you the problem.
Nope. Using sqlite3 either it works or it shows the error.


In the meantime I further analyzed the problem and I also looked at the 
corrupt databasefile. To my surprise it contained some logfile output 
from another library I am using. It seems that if I turn on logging for 
this library some log output is written to the database file. But I have 
absolutely no idea how this mixup can happen.

If I switch off logging everything works as expected.
I also know now why it works on Windows. This library is HW-dependent 
and therefore not running on my PC.


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


Re: [sqlite] Bug: Umlaut in database filename

2010-12-20 Thread Michael Schlenker
Am 20.12.2010 00:26, schrieb Harald Friedrich:
> 
> Hello SQLite team,
> 
> if an umlaut (German mutated vowel with two dots on top äöüÄÖÜß) is 
> present in the database filename, the first access to the database after 
> opening will result in an exception or a runtime error 216.
> 
> Using the user's AppDataPath unfortunately always includes the username. 
> If this name has an umlaut, SQLite will not work:
> 
> *C:\Users\Jürgen 
> Möller\AppData\Roaming\ibf\TarV15\medium\Database\target3001.db*
> 
> What can we do?

Use the right encoding for the sqlite_open() call (e.g. UTF-8) or use
the sqlite_open16() call which might be easier on Windows. If you use
some kind of wrapper other than the C code, file a bug there.

You probably passed some ANSI/OEM codepage filename to sqlite_open()
which gets messed up.

Michael


-- 
Michael Schlenker
Software Architect

CONTACT Software GmbH   Tel.:   +49 (421) 20153-80
Wiener Straße 1-3   Fax:+49 (421) 20153-41
28359 Bremen
http://www.contact.de/  E-Mail: m...@contact.de

Sitz der Gesellschaft: Bremen
Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug: Umlaut in database filename

2010-12-20 Thread Harald Friedrich

Hello SQLite team,

if an umlaut (German mutated vowel with two dots on top äöüÄÖÜß) is 
present in the database filename, the first access to the database after 
opening will result in an exception or a runtime error 216.

Using the user's AppDataPath unfortunately always includes the username. 
If this name has an umlaut, SQLite will not work:

*C:\Users\Jürgen 
Möller\AppData\Roaming\ibf\TarV15\medium\Database\target3001.db*

What can we do?

Best regards


Harald Friedrich
__
Ing.-Buero FRIEDRICH
Harald Friedrich, Industrial Engineer
Am Schwarzen Rain 1
D-36124 Eichenzell, Germany
Tel.: ++49 - 66 59 / 919 444
Fax: ++49 - 66 59 / 919 445
VAT ID DE112342909
Tax 01881900337
tar...@ibfriedrich.com
www.ibfriedrich.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users