We added some date functions into Sqlite, and it was a trivial exercise
because the function interface is tidy and easy to figure out.
What would be elegant is to have an ability to compile user written
functions into new versions of Sqlite without having to modify the
source of the new version.
A simple way to do that would be to have a conditional compile built
into the function tables in func.c so that user written modules could be
conditionally compiled in. A quick glance at the code suggests that two
conditional compile points would be necessary, one in
sqlite3RegisterBuiltInFunctions and another elsewhere in the file to
include the code for the added functions.
The only downside seems to be that the table of function names is not
ordered and appears to be searched linearly, so making the table large
could pose a problem. A change to make this an ordered table with a
binary search would solve that potential problem and allow a large set
of added functions.
If you were to define the string routines it would be a handy addition
to Sqlite to have a conditional compile which includes functions giving
compatibility with other much used DBMS's. It would bloat Sqlite to
include such things as standard, which is why it should be an option.
Such an option would facilitate adding application functions to Sqlite.
Since Sqlite links into the application, that would be a tidy way of
partitioning the application by integrating more complex business rules
etc with the SQL.
Mikey C wrote:
Hi,
I am in need of some new SQL functions and wanted to ask advice on the best
way to integrate these functions into SQLite 3. I am not a proficient C
coder unfortunately.
I have compiled the source for 3.5.5 using Visual Studio.NET 2003 and all
works fine.
I have added a couple of simple functions into func.c and these work. Great
so far.
However it would be good if there were a project somewhere to collate
extension functions into a set of C files to enable a more powerful version
of SQLite.
I have found a few already on the web. Eg.
http://www.brayden.org/twiki/bin/view/Software/SqliteExtensions#SQLite_Extensions
What I am looking for specifically are more powerful string manipulation
functions that mimic Microsoft SQL Server. In order of importance:
charindex - This one is a show stopper for me. Need this function badly.
patindex
ltrim
rtrim
replace
difference (integer diff on soundex values)
What is the best way forward? Have someone develop these and add them
directly to func.c or (to aid upgrading) create a new source and header file
and add them to the project? How can new functions be added without
removing the ability to upgrade the source to 3.5.6 etc when patches are
released to func.c?
Does anyone know how these string functions might be implemented?
Any help appreciated.
Thanks,
Mike
--
View this message in context:
http://www.nabble.com/Extra+functions+-+New+Project--t1674436.html#a4539325
Sent from the SQLite forum at Nabble.com.