Re: [sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-26 Thread Peter Kolbus


> On Feb 26, 2020, at 5:53 AM, Graham Holden  wrote:
> 
> Wednesday, February 26, 2020, 11:15:14 AM, Richard Hipp  
> wrote:
> 
>>> On 2/25/20, Peter Kolbus  wrote:
>>> I noticed that sqliteDefaultBusyCallback() seems to depend directly on the
>>> OS (behave differently based on SQLITE_OS_WIN||HAVE_USLEEP).  Since the
>>> underlying primitive, sqlite3OsSleep(), actually uses the VFS to sleep, and
>>> unixSleep() also has a roundup to whole seconds when HAVE_USLEEP is not
>>> defined, any time resolution limitations are already handled there. And when
>>> a custom VFS is configured, that VFS may well be able to sleep in milli or
>>> microseconds using an RTOS-specific function that is not usleep() — for
>>> example FreeRTOS has osDelay().
>>> 
>>> Is there a reason sqliteDefaultBusyCallback() has this dual implementation,
>>> and defining HAVE_USLEEP is correct to get better performance on platforms
>>> that don’t have usleep()? Or could it be simplified?
>>> 
> 
>> I don't think I understand the question.  It sounds like you are
>> asking why SQLite does not try to sleep for sub-second intervals on
>> systems that do not support usleep()?
> 
> I've not looked at the source, so I don't know whether what I think
> Peter is saying is correct or not, but what I THINK Peter is implying
> there's POSSIBLY some decision (based on HAVE_USLEEP) in the "core"
> SQLite code about what sort of timeout to ask for, before the request
> gets handed over to the VFS to implement.

Thanks Graham, this is exactly what I’m pointing out.

> 
> Presumably, in the default VFS implementation(S) this also uses
> HAVE_USLEEP to decide whether sub-seconds times are possible or not.

The UNIX VFS implementation does test HAVE_USLEEP in unixSleep(). The Windows 
VFS looks like it supports subsecond times as well but doesn’t use this flag.

> 
> However, a custom VFS may have its own way of implementing sub-second
> delays (but does not implement usleep() itself)... it could therefore
> honour a request for sub-second delay if asked. However, to be asked,
> it has to "lie" about supporting usleep() and define HAVE_USLEEP.
> 
> It may simply be a concern over semantics: i.e. whether HAVE_USLEEP
> means ("implements the function usleep()" vs. "can do short delays
> somehow") or it might be a deeper problem in that if you define
> HAVE_USLEEP (to allow a custom VFS to be asked to sleep for short
> amounts) it also causes other parts of the SQLite code to try and use
> usleep() when it isn't implemented).

My primary concern is indeed semantics, especially as not setting HAVE_USLEEP 
with a custom VFS leads to worse performance when multiple threads are 
contending for a lock. (I’m prepared to go through the exercise of defining 
this for my company’s products, but wanted to raise the question first since 
other SQLite users could well be missing out on performance).

Every other use of a HAVE_XXX define that I’ve ever seen, indicates a function 
or header file is available. The second option Graham suggests (can do short 
delays) doesn’t seem to be consistent with the Winflows VFS, as 
sqliteDefaultBusyCallback() also tests SQLITE_OS_WIN.

The second concern is probably not a concern for SQLite if the project defines 
SQLITE_OS_OTHER, but there could be problems for other software components that 
take HAVE_USLEEP to mean that usleep() is available.

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


[sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-25 Thread Peter Kolbus
I noticed that sqliteDefaultBusyCallback() seems to depend directly on the OS 
(behave differently based on SQLITE_OS_WIN||HAVE_USLEEP).  Since the underlying 
primitive, sqlite3OsSleep(), actually uses the VFS to sleep, and unixSleep() 
also has a roundup to whole seconds when HAVE_USLEEP is not defined, any time 
resolution limitations are already handled there. And when a custom VFS is 
configured, that VFS may well be able to sleep in milli or microseconds using 
an RTOS-specific function that is not usleep() — for example FreeRTOS has 
osDelay().

Is there a reason sqliteDefaultBusyCallback() has this dual implementation, and 
defining HAVE_USLEEP is correct to get better performance on platforms that 
don’t have usleep()? Or could it be simplified?

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


[sqlite] List of innocuous functions?

2020-01-24 Thread Peter Kolbus
Is there any documentation showing, or an easy way to generate, the exact list 
of SQLite-provided functions that are innocuous?

I’d like to turn on the new SQLITE_TRUSTED_SCHEMA but support a variety of 
applications and am hoping for something to guide analysis.

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


Re: [sqlite] INSERT OR IGNORE with rtree virtual tables

2010-11-07 Thread Peter Kolbus
Any thoughts on this?

Thanks,
Peter Kolbus

On Sat, Oct 30, 2010 at 8:27 PM, Peter Kolbus <peter.kol...@gmail.com> wrote:
> Hi,
>
> It seems that the OR IGNORE clause is not working with an RTREE
> virtual table.  The documentation (http://sqlite.org/rtree.html,
> section 3.2) implies that this should work, but is not absolutely
> clear on the point of conflict handling.  I've tried this with both
> 3.6.19 and 3.7.3 with the same result.
>
> In the shell:
>
> SQLite version 3.7.3
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> CREATE VIRTUAL TABLE a_rt USING rtree( _id, min_x, max_x,
> min_y, max_y );
> sqlite> INSERT OR IGNORE INTO a_rt ( _id, min_x, max_x, min_y, max_y )
> VALUES( 2, 3, 4, 5, 6 );
> sqlite> INSERT OR IGNORE INTO a_rt ( _id, min_x, max_x, min_y, max_y )
> VALUES( 2, 3, 4, 5, 6 );
> Error: constraint failed
> sqlite>
>
> Is this a bug, or operating as designed?
>
> Thanks,
> Peter Kolbus
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] INSERT OR IGNORE with rtree virtual tables

2010-10-30 Thread Peter Kolbus
Hi,

It seems that the OR IGNORE clause is not working with an RTREE
virtual table.  The documentation (http://sqlite.org/rtree.html,
section 3.2) implies that this should work, but is not absolutely
clear on the point of conflict handling.  I've tried this with both
3.6.19 and 3.7.3 with the same result.

In the shell:

SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE VIRTUAL TABLE a_rt USING rtree( _id, min_x, max_x,
min_y, max_y );
sqlite> INSERT OR IGNORE INTO a_rt ( _id, min_x, max_x, min_y, max_y )
VALUES( 2, 3, 4, 5, 6 );
sqlite> INSERT OR IGNORE INTO a_rt ( _id, min_x, max_x, min_y, max_y )
VALUES( 2, 3, 4, 5, 6 );
Error: constraint failed
sqlite>

Is this a bug, or operating as designed?

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


Re: [sqlite] SQLite 3.7.0 coming soon....

2010-06-30 Thread Peter Kolbus
This looks like an exciting enhancement, and I look forward to testing it out. 
http://www.sqlite.org/draft/c3ref/io_methods.html seems to be missing 
requirements for the xShm functions, though.  Can you update that?

Thanks,
Peter Kolbus


On Jun 30, 2010, at 12:21 PM, "D. Richard Hipp" <d...@hwaci.com> wrote:

> We are in the final phases of development for SQLite version 3.7.0.   
> The key enhancement over version 3.6.23.1 is support for the use of  
> write-ahead logs for transaction control.  See 
> http://www.sqlite.org/draft/wal.html 
>  for additional information on how this might enhance your  use of  
> SQLite.
> 
> The transition from 3.6.23.1 to 3.7.0 is a large one, and we would  
> appreciate beta testing.  Recent snapshots of SQLite can be found at 
> http://www.sqlite.org/draft/download.html 
>  and those snapshots pass all of our extensive tests.  But testing  
> can only prove the existence of bugs, not their absence and so we are  
> eager for others to try out the latest code changes, and in particular  
> the new write-ahead log feature, and let us know your experiences,  
> before we make the next release.
> 
> Please provide feedback - positive, negative, or indifferent - to this  
> mailing list.
> 
> We are currently aiming to release 3.7.0 sometime during July.  Thank  
> you in advance for your help in testing this important new release.
> 
> D. Richard Hipp
> d...@hwaci.com
> 
> 
> 
> ___
> 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] Problem with sqlite3

2010-06-02 Thread Peter Kolbus
Lukasz,

I think the function you're trying to call is named sqlite3_open.

Regards,
Peter Kolbus

On Wed, Jun 2, 2010 at 10:56 AM, lukasz aaa <zsu...@wp.pl> wrote:
> Hello. Sorry for my English.
> I have a problem with the SQLite library reloaded correctly (use in
> project). I'm using VC++ 2010 and Dev.
> I add to project sqlite3.h, copy to folder with source sqlite3.dll and
> sqlite3.lib. I add sqlite3.lib to linker - i search information on
> forums, but can't compile program.
> I make file sqlite3.lib, with program lib.exe, after it not work do it
> with VC++ Create Library, don't work too.
> Error is " error C3861: 'sqlite_open': identifier not found".
> If you have time pleas help me.
>
>
> ___
> 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] Bug and possible fix: Access violation in rtree.c:nodeGetRowid()

2010-06-01 Thread Peter Kolbus
I am getting an access violation in rtree.c::nodeGetRowid() using a
database image of questionable integrity (the application the database
was last updated on shut down abnormally, but executing PRAGMA
integrity_check returns "ok" and there is no journal file).  The
access violation can be reproduced by executing the following query in
the sqlite3 shell:

DELETE FROM history_rtree WHERE NOT EXISTS(SELECT _id FROM history
WHERE history._id = history_rtree._id);

Using http://sqlite.org/sqlite-source-3_6_23_1.zip (to get reasonable
line numbers), the call stack is roughly:
>   sqlite.exe!nodeGetRowid(Rtree * pRtree=0x00348340, RtreeNode * 
> pNode=0x, int iCell=0x)  Line 568 + 0x3 bytesC
sqlite.exe!nodeRowidIndex(Rtree * pRtree=0x00348340, RtreeNode *
pNode=0x, __int64 iRowid=0x002d)  Line 874 + 0x23
bytes   C
sqlite.exe!rtreeUpdate(sqlite3_vtab * pVtab=0x00348340, int
nData=0x0001, Mem * * azData=0x0034f908, __int64 *
pRowid=0x0012f100)  Line 2385 + 0x41 bytes  C
sqlite.exe!sqlite3VdbeExec(Vdbe * p=0x00348ff0)  Line 6125 + 0x29 bytes 
C
sqlite.exe!sqlite3Step(Vdbe * p=0x00348ff0)  Line 370 + 0x9 bytes   
C
sqlite.exe!sqlite3_step(sqlite3_stmt * pStmt=0x00348ff0)  Line 432 +
0x9 bytes   C
sqlite.exe!shell_exec(sqlite3 * db=0x00343210, const char *
zSql=0x0052dcc0, int (void *, int, char * *, char * *, int *)*
xCallback=0x00456400, callback_data * pArg=0x0012f940, char * *
pzErrMsg=0x0012f7b4)  Line 1012 + 0x9 bytes C

The call to findLeafNode() at rtree.c line 2379 returned SQLITE_OK but
set pLeaf to NULL, and I note that this postcondition is documented as
possible.

Adding a check for pLeaf to the if condition on line 2383 prevents the
access violation:

if( rc==SQLITE_OK && pLeaf ) {

Is this the correct fix?

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