Jay Sprenkle wrote:
On 5/24/06, John Stanton <[EMAIL PROTECTED]> wrote:
> IIRC, That has been suggested in the past, the consensus was to not
> include extra functions, in keeping with the 'lite' in the project
> name.
A very sound decision. Bloat is the enemy of all good software.
A conditional compile point however would not bloat the product and
would make it easy for users to keep user functions and up-to-date
Sqlite releases.
Conditional compiles won't help your user functions code migrate
to new versions unless you're very careful not to build in dependencies.
You must stick to the functions the API provides to ensure it will
work. I haven't found conditional compiles to be very helpful in that
regard.
Why add indirection when it is not necessary and is outside the concept
of the product? Sqlite is not a program like a WWW browser, it is a
library of functions. What is wrong with adding to the library?
Nothing at all. I threw it out as an option to consider. If you don't
want to consider it that's up to you.
The drawbacks:
* You have to understand how Sqlite works internally to do it.
* some overhead when functions are used
The benefits:
* Plugins enfore encapsulation so they're easier to write
* porting code to changing versions of the engine requires no effort
* The "minimalist" users and the "everything and the kitchen sink"
users can both have what they want.
Overlays were a nightmare, and have very thankfully been banished by
virtual memory systems. Why do you hold onto the concept? It is more
effective to have direct addressing and let the VM manager do what it
does best.
They worked fine for me. You must have gotten a poor implementation.
When people would complain about a poorly performing program experience
showed that one of the first culprits to look for was overlays.
Good luck on your project John.
Have a look at the Sqlite code dealing with functions, and you will see
that the area of code which would have the conditional compile has a
comment indicating that it has an external linkage. It also already has
conditional compiles for, inter alia, soundex, test functions etc. I
just propose a further use for what is a well thought out interface.
** This function registered all of the above C functions as SQL
** functions. This should be the only routine in this file with
** external linkage.
*/
void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
static const struct {
char *zName;
signed char nArg;
u8 argType; /* 0: none. 1: db 2: (-1) */
u8 eTextRep; /* 1: UTF-16. 0: UTF-8 */
u8 needCollSeq;
void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
} aFuncs[] = {
{ "min", -1, 0, SQLITE_UTF8, 1, minmaxFunc },
{ "min", 0, 0, SQLITE_UTF8, 1, 0 },
{ "max", -1, 2, SQLITE_UTF8, 1, minmaxFunc },
{ "max", 0, 2, SQLITE_UTF8, 1, 0 },
{ "typeof", 1, 0, SQLITE_UTF8, 0, typeofFunc },
{ "length", 1, 0, SQLITE_UTF8, 0, lengthFunc },
{ "substr", 3, 0, SQLITE_UTF8, 0, substrFunc },
#ifndef SQLITE_OMIT_UTF16
{ "substr", 3, 0, SQLITE_UTF16LE, 0, sqlite3utf16Substr },
#endif
{ "abs", 1, 0, SQLITE_UTF8, 0, absFunc },
{ "round", 1, 0, SQLITE_UTF8, 0, roundFunc },
{ "round", 2, 0, SQLITE_UTF8, 0, roundFunc },
{ "upper", 1, 0, SQLITE_UTF8, 0, upperFunc },
{ "lower", 1, 0, SQLITE_UTF8, 0, lowerFunc },
{ "coalesce", -1, 0, SQLITE_UTF8, 0, ifnullFunc },
{ "coalesce", 0, 0, SQLITE_UTF8, 0, 0 },
{ "coalesce", 1, 0, SQLITE_UTF8, 0, 0 },
{ "ifnull", 2, 0, SQLITE_UTF8, 1, ifnullFunc },
{ "random", -1, 0, SQLITE_UTF8, 0, randomFunc },
{ "nullif", 2, 0, SQLITE_UTF8, 1, nullifFunc },
{ "sqlite_version", 0, 0, SQLITE_UTF8, 0, versionFunc},
{ "quote", 1, 0, SQLITE_UTF8, 0, quoteFunc },
{ "last_insert_rowid", 0, 1, SQLITE_UTF8, 0, last_insert_rowid },
{ "changes", 0, 1, SQLITE_UTF8, 0, changes },
{ "total_changes", 0, 1, SQLITE_UTF8, 0, total_changes },
#ifdef SQLITE_SOUNDEX
{ "soundex", 1, 0, SQLITE_UTF8, 0, soundexFunc},
#endif
#ifdef SQLITE_TEST
{ "randstr", 2, 0, SQLITE_UTF8, 0, randStr },
{ "test_destructor", 1, 1, SQLITE_UTF8, 0, test_destructor},
{ "test_destructor_count", 0, 0, SQLITE_UTF8, 0,
test_destructor_count},
{ "test_auxdata", -1, 0, SQLITE_UTF8, 0, test_auxdata},
{ "test_error", 1, 0, SQLITE_UTF8, 0, test_error},
#endif
};