[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    [sqlite] System.Data.Sqlite extension function - performing INSERT
From:       Brad Hards <bradh () frogmouth ! net>
Date:       2012-06-30 0:53:06
Message-ID: 201206301053.06676.bradh () frogmouth ! net
[Download RAW message or body]

Hi,

I'm trying to provide a not-really-spatialite toolset for C# users (since they 
often seem to have trouble with spatialite / extension loading).

No problem with SELECT from an existing database / table. However I'd like to 
provide the capability to perform an INSERT of a newly created geometry into 
an existing spatialite geometry column. I can do that if there isn't an index.

If there is an index, then the insertion will invoke triggers to update the 
RTree index table. Those triggers use two SQL functions that are provided by 
libspatialite - GeometryConstraints() and RTreeAlign(). I don't have 
libspatialite in this example, so I need to provide those functions myself.

GeometryConstraints() is no problem.

RTreeAlign is OK up to the point where I need to actually update the index 
table. Now I'm stuck because I don't have access to the connection.

http://system.data.sqlite.org/index.html/annotate?checkin=2849c1b71384d52d&filename=System.Data.SQLite/SQLiteFunction.cs \
 indicates that this is intentional:
ec237b0123 2005-03-01     rmsimpson:   /// Although there is one instance of a 
class derived from SQLiteFunction per database connection, the derived class 
has no access
ec237b0123 2005-03-01     rmsimpson:   /// to the underlying connection.  This 
is necessary to deter implementers from thinking it would be a good idea to 
make database
ec237b0123 2005-03-01     rmsimpson:   /// calls during processing.

I can read that two ways:
1. Most implementers aren't smart enough to get that right (probably true in 
my case).
2. No-one is smart enough to get that right - its a "Here Be Dragons" place.

However, I still need to do it (or toss the code onto the "nice idea at the 
time" scrapheap).

Is there a workaround to get at the underlying connection from my extension 
function class?

Is there anything to be aware of in implementing a "SQLiteFunction2" that does 
allow access to the underlying connection?

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic