[sqlite] Shapefile 2.0

2011-09-16 Thread Ben Harper
SQLite, in its 'default' code configuration, contains enough functionality to be a replacement for a shapefile. However, there is one very significant feature that is wasteful to ignore: spatial indexes. In order for the SQLite RTree to be used, it needs accompanying code that understands the

Re: [sqlite] Patch to pass collation through to Virtual Tables (The Patch Text)

2011-09-09 Thread Ben Harper
assignment in the previous line is possible only because ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The ** following asserts verify this fact. */ -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Ben Harper Sent

[sqlite] Patch to pass collation through to Virtual Tables

2011-09-09 Thread Ben Harper
Hi, I have attached a one-liner (vtab-collation.patch) that sends collation information through to virtual tables. The bigger patch (vtab-collation-full.patch) illustrates the header file changes necessary to make this compile. Unfortunately, it's not as simple as just one line of code, since

[sqlite] LIKE operator on virtual table assumes ASCII collation

2011-09-09 Thread Ben Harper
>From xBestIndex and xFilter, there is no way to determine the intended >collation. The default collation for a field is binary. However, a LIKE operator needs an ASCII collation, and in the case of a virtual table, the constraints passed in to xBestIndex and xFilter assume an ASCII collation.

Re: [sqlite] caveat on blanket UPDATE triggers

2011-07-14 Thread Ben Harper
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Dan Kennedy [danielk1...@gmail.com] Sent: 14 July 2011 06:02 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] caveat on blanket UPDATE triggers On 07/14/2011 10:42 PM, Ben Harper wrote

[sqlite] caveat on blanket UPDATE triggers

2011-07-14 Thread Ben Harper
This may be specific to RTree indexes - I haven't taken the time to fully understand it. Dangerous: CREATE TRIGGER ON UPDATE ON tablename { SET RTREE MIN/MAX } Fine: CREATE TRIGGER ON UPDATE OF geometry OF tablename { SET RTREE MIN/MAX } Failure to specify the field name explicitly results in

Re: [sqlite] DROP TABLE yields SQLITE_LOCKED from user-defined function

2011-07-07 Thread Ben Harper
sible to change the database from within a function called from SELECT statement. SELECT query doesn't ever changes any data. Pavel On Thu, Jul 7, 2011 at 10:38 AM, Ben Harper <b...@imqs.co.za> wrote: > I have a user-defined function that I register with create_function. > > Inside my fu

[sqlite] DROP TABLE yields SQLITE_LOCKED from user-defined function

2011-07-07 Thread Ben Harper
I have a user-defined function that I register with create_function. Inside my function I try to drop an r-tree virtual table, but I get the error SQLITE_LOCKED. Is there something special one needs to do in order to drop a table from inside a user-defined function? To test, I call it simply

Re: [sqlite] False negatives from RTree

2011-07-05 Thread Ben Harper
To: General Discussion of SQLite Database Subject: Re: [sqlite] False negatives from RTree On Tue, Jul 5, 2011 at 8:55 AM, Ben Harper <b...@imqs.co.za> wrote: > Hi, > Has anybody ever seen anomalous behaviour on an R*Tree. Specifically, false > negatives? > I'm using Spatialite 2.4.0

Re: [sqlite] False negatives from RTree

2011-07-05 Thread Ben Harper
org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Richard Hipp Sent: 05 July 2011 03:20 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] False negatives from RTree On Tue, Jul 5, 2011 at 8:55 AM, Ben Harper <b...@imqs.co.za> wrote: > Hi, > Has anybody ever s

[sqlite] False negatives from RTree

2011-07-05 Thread Ben Harper
Hi, Has anybody ever seen anomalous behaviour on an R*Tree. Specifically, false negatives? I'm using Spatialite 2.4.0 RC. What I end up with is a table into which I can insert new geometry, but that geometry does not get retrieved by an appropriate RTree search. Indeed, even a search which

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

2010-12-18 Thread Ben Harper
This is low probability, but maybe the Fault Tolerant Heap is turned on for sqlite.exe? I believe you'll see the exe mentioned in here if that is the case: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\FTH\State FTH was introduced in Windows 7. Ben ___

Re: [sqlite] BUSY on COMMIT when EXCLUSIVE is held is an unexpected result

2010-12-17 Thread Ben Harper
: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Dan Kennedy Sent: 17 December 2010 03:53 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] BUSY on COMMIT when EXCLUSIVE is held is an unexpected result On 12/17/2010 07:54 PM, Ben Harper wrote: > I h

[sqlite] BUSY on COMMIT when EXCLUSIVE is held is an unexpected result

2010-12-17 Thread Ben Harper
I have this case: Thread 1 Thread 2 -- BEGIN EXCLUSIVE BEGIN EXCLUSIVE -> BUSY ... etc ... BEGIN EXCLUSIVE -> BUSY COMMIT BEGIN EXCLUSIVE -> OK ...

Re: [sqlite] WAL file size

2010-11-25 Thread Ben Harper
ical for you... I think this kind of a solution can work of me too (I dont want to block the main thread EVER, and I have a steady stream of writes to the DB). Can you please elaborate how did you implemented your solution? Yoni. On 25/11/2010 8:42 AM, Ben Harper wrote: > A cyclical WAL

Re: [sqlite] WAL file size

2010-11-24 Thread Ben Harper
A cyclical WAL file has this problem: You can never be sure when is the right time to wrap around. If you wrap around too early, you run the risk of hitting the wall put up by the earliest reader, who is still using the end of the WAL file. In which case the writer would have to block on the

Re: [sqlite] virtual tables

2010-11-22 Thread Ben Harper
I have a database library that abstracts various DB types, such as DBF, shapefiles, CSV, PostGIS, etc. I use the Sqlite virtual table mechanism to provide SQL functionality on top of any of these DB types. Normally one would only need to do this for crude databases, such as a CSV file, but the

[sqlite] How can xBestIndex discern 'a' = col COLLATE NOCASE vs 'a' = col

2010-11-19 Thread Ben Harper
I have a virtual table, but I cannot figure out how to discover the collating sequence of a query expression passed to xBestIndex. As far as I can tell, these three statements ... SELECT * FROM tab WHERE col = 'val'; SELECT * FROM tab WHERE col = 'val' COLLATE BINARY; SELECT * FROM tab WHERE col

[sqlite] WAL hash collisions

2010-11-06 Thread Ben Harper
In wal.c, it reads "8 or 10 comparisons (on average) suffice to either locate a frame in the WAL or to establish that the frame does not exist in the WAL". I'm wondering -- how often does it occur that only a small subset of pages is written to again and again, in sequence, such that the WAL

Re: [sqlite] R*Tree module and double precision?

2010-11-04 Thread Ben Harper
Are you sure that double precision in the RTree is necessary for your purposes? Here is a table of floating point precision at various values: The 'flip' values are the 'org' values with the lowest bit flipped. org flip (delta) 0.01 0.01 (

Re: [sqlite] Using sqlite's WAL with a hash table store

2010-11-03 Thread Ben Harper
On Wed, Nov 03, 2010 at 12:31:35PM +0200, Ben Harper scratched on the wall: > I guess I could actually dump the hash table into a blob. > I'm also doing something like a bloom filter, and I guess that can just > as well go into a blob too.. Basically the system is a big cache, >

Re: [sqlite] Using sqlite's WAL with a hash table store

2010-11-03 Thread Ben Harper
] Using sqlite's WAL with a hash table store FTS3 extension is very fast and scalable hash engine. I did test FTS3 up to 400+ millions of record and it's nice. 2010/11/3 Ben Harper <b...@imqs.co.za> > Hi, > I know the answer to this question is really "Just try it and see",

Re: [sqlite] Using sqlite's WAL with a hash table store

2010-11-03 Thread Ben Harper
vember 2010 11:17 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] Using sqlite's WAL with a hash table store On 3 Nov 2010, at 8:30am, Ben Harper wrote: > I know the answer to this question is really "Just try it and see", but I > want to gauge whether the idea

[sqlite] Using sqlite's WAL with a hash table store

2010-11-03 Thread Ben Harper
Hi, I know the answer to this question is really "Just try it and see", but I want to gauge whether the idea is sane or not before I spend/waste time on the effort: I want to build a custom hash table DB, and to solve the concurrency+durability I need something akin to a WAL, and SQLite's WAL

Re: [sqlite] Breakpoints uncorrelated on MSVC amalgamation build

2010-09-23 Thread Ben Harper
September 2010 03:24 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Breakpoints uncorrelated on MSVC amalgamation build Which MSVC compiler has this bug? There's a link to information on that ? On Thu, Sep 23, 2010 at 10:17, Ben Harper <b...@imqs.co.za> wrote: &g

Re: [sqlite] How does xBestIndex know that a LIKE query is case insensitive?

2010-09-23 Thread Ben Harper
users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Richard Hipp Sent: 23 September 2010 01:57 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] How does xBestIndex know that a LIKE query is case insensitive? On Thu, Sep 23, 2010 at 7:16 AM, Ben Harper <b.

Re: [sqlite] Breakpoints uncorrelated on MSVC amalgamation build

2010-09-23 Thread Ben Harper
OK. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Teg Sent: 23 September 2010 03:20 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Breakpoints uncorrelated on MSVC amalgamation build Hello Ben,

[sqlite] Breakpoints uncorrelated on MSVC amalgamation build

2010-09-23 Thread Ben Harper
I just discovered the MSVC compiler generates bad debug info for source files larger than 64k lines, which is the case with the Sqlite amalgamation. Does anyone know of a workaround? Thanks, Ben ___ sqlite-users mailing list sqlite-users@sqlite.org

[sqlite] How does xBestIndex know that a LIKE query is case insensitive?

2010-09-23 Thread Ben Harper
I have a virtual table implementation that implements the xBestIndex/xFilter functions. Problem: A LIKE query (for eg. field LIKE "prefix%") gets sets to xBestIndex as a GT/LT pair. However, I can't tell from the sqlite3_index_info whether that GT/LT should be NOCASE collation or BINARY

Re: [sqlite] Any way to make xUpdate only alter the columns that are changed?

2010-07-28 Thread Ben Harper
: Re: [sqlite] Any way to make xUpdate only alter the columns that are changed? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/28/2010 07:37 AM, Ben Harper wrote: > then it would be great if the xUpdate function could inform one that only the > field 'age' is being altered. As it

[sqlite] Any way to make xUpdate only alter the columns that are changed?

2010-07-28 Thread Ben Harper
It seems apparent from the docs (and the function headers) that there is no way to cause Sqlite's Virtual Table xUpdate function to notify the implementation of the exact fields that were altered. For example, if I do UPDATE people SET age=40 WHERE name='jim' then it would be great if the

Re: [sqlite] Computed columns in VIEWs return NULL but should be able to be typed! Any ideas?

2010-05-11 Thread Ben Harper
To determine the type of columns in a view I use SELECT typeof(column) FROM viewname LIMIT something; Unfortunately if most of the column data is NULL then you can end up having to scan the entire table. I'm not sure how SQlite calculates these types, but this simple workaround has been OK for

Re: [sqlite] rowid availability from views is inconsistent

2010-03-12 Thread Ben Harper
: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin Sent: 12 March 2010 11:54 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] rowid availability from views is inconsistent On 12 Mar 2010, at 8:47am, Ben Harper wrote: > Under cert

[sqlite] rowid availability from views is inconsistent

2010-03-12 Thread Ben Harper
Under certain conditions, VIEWs do not have rowid values. Is there some recommended workaround that I can use to ensure that I always get non-null rowids with every VIEW? CREATE TABLE one (i32 INTEGER); INSERT INTO one VALUES(100); INSERT INTO one VALUES(200); CREATE VIEW v1 AS SELECT *

[sqlite] Retrieve database modification stamp

2009-05-04 Thread Ben Harper
Hi, Is there any official way of obtaining the database modification counter? I'm talking about the counter that is mentioned in the Atomic Commit docs: " In order to determine whether or not the database file has changed, SQLite uses a counter in the database header (in bytes 24 through 27)

Re: [sqlite] Why must one write a mini SQL parser to read the columnnames?

2008-12-01 Thread Ben Harper
Thanks, that's perfect! On Mon, Dec 1, 2008 at 3:06 PM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > "Ben Harper" <[EMAIL PROTECTED]> wrote in > message > news:[EMAIL PROTECTED] >> To the best of my findings, it seems to me that one needs to write a >>

[sqlite] Why must one write a mini SQL parser to read the column names?

2008-12-01 Thread Ben Harper
To the best of my findings, it seems to me that one needs to write a mini SQL parser in order to read the 'sql' field from sqlite_master, in order to discover the fields in an Sqlite table. Is this really a necessary design? Would it not be better if sqlite3_table_column_metadata had a mode that

Re: [sqlite] Planner choosing wrong index

2008-04-10 Thread Ben Harper
I was thinking about this issue some time ago, and it occurred to me that the root node of a Btree is a great estimator of the contents of the tree. Some brief mucking around proves this to me empirically, and I'm guessing you could prove that it is never out by more than 2x, due to the balancing

Re: [sqlite] Virtual table used to query big external database

2008-04-01 Thread Ben Harper
The only limitation imposed by SQL that I can think of would be inefficiencies in its query plan builder. That is the part that figures out how to use the indexes available in the database in order to execute the SQL query most efficiently. So it really depends on what type of SQL queries you are

Re: [sqlite] Using WHERE within a BLOB

2008-03-11 Thread Ben Harper
The short answer is no. If you want to use the database for the purposes for which it was created, then you have to play by its rules- which in this case is to create fields for each of those categories. On Tue, Mar 11, 2008 at 10:38 PM, Derek Developer <[EMAIL PROTECTED]> wrote: > Is it possible